Skip to content

Commit 494a339

Browse files
committed
chore: updates for linter and type checker
1 parent de598be commit 494a339

File tree

4 files changed

+29
-27
lines changed

4 files changed

+29
-27
lines changed

bin/gobject-prepare.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import DashGov from "dashgov";
77
import DashRpc from "dashrpc";
88
import DashKeys from "dashkeys";
99
import DashTx from "dashtx";
10-
import Secp256k1 from "@dashincubator/secp256k1";
10+
import * as Secp256k1 from "@dashincubator/secp256k1";
1111

1212
import Fs from "node:fs/promises";
1313

@@ -239,7 +239,6 @@ async function main() {
239239
return;
240240
}
241241

242-
/** @type {import('../dashgov.js').GObjectData} */
243242
let gobjData = DashGov.proposal.draftJson(selected, {
244243
name: proposalName,
245244
payment_address: paymentAddr,
@@ -274,15 +273,15 @@ async function main() {
274273
let keyUtils = {
275274
/**
276275
* @param {DashTx.TxInputForSig} txInput
277-
* @param {Number} i
276+
* @param {Number} [i]
278277
*/
279278
getPrivateKey: async function (txInput, i) {
280279
return DashKeys.wifToPrivKey(burnWif, { version: network });
281280
},
282281

283282
/**
284283
* @param {DashTx.TxInputForSig} txInput
285-
* @param {Number} i
284+
* @param {Number} [i]
286285
*/
287286
getPublicKey: async function (txInput, i) {
288287
let privKeyBytes = await keyUtils.getPrivateKey(txInput, i);

dashgov.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222

2323
/**
2424
* @typedef GObjectData
25-
* @prop {Uint53} end_epoch - whole seconds since epoch (like web-standard `exp`)
25+
* @prop {Uint53} [end_epoch] - whole seconds since epoch (like web-standard `exp`)
2626
* @prop {String} name - kebab case (no spaces)
2727
* @prop {String} payment_address - base58-encoded p2pkh
2828
* @prop {Uint32} payment_amount - in whole DASH
29-
* @prop {Uint53} start_epoch - whole seconds since epoch (like web-standard `iat`)
30-
* @prop {Uint32} type - TODO
29+
* @prop {Uint53} [start_epoch] - whole seconds since epoch (like web-standard `iat`)
30+
* @prop {Uint32} [type] - TODO
3131
* @prop {String} url - conventionally dashcentral, with page the same as the 'name'
3232
*/
3333

@@ -363,6 +363,7 @@ DashGov.proposal = {};
363363
* @param {Estimate} selected.start
364364
* @param {Estimate} selected.end
365365
* @param {GObjectData} proposalData
366+
* @returns {Required<GObjectData>}
366367
*/
367368
DashGov.proposal.draftJson = function (selected, proposalData) {
368369
let startEpoch = selected.start.startMs / 1000;
@@ -389,8 +390,8 @@ DashGov.proposal.draftJson = function (selected, proposalData) {
389390
* Creates a draft object with reasonable and default values
390391
* @param {Uint53} now - use Date.now(), except in testing
391392
* @param {Uint53} startEpochMs - used to create a deterministic gobject time
392-
* @param {GObjectData} data - will be sorted and hex-ified
393-
* @param {GObject} [gobj] - override values
393+
* @param {Required<GObjectData>} data - will be sorted and hex-ified
394+
* @param {Partial<GObject>} [gobj] - override values
394395
*/
395396
DashGov.proposal.draft = function (now, startEpochMs, data, gobj) {
396397
let dataHex = gobj?.dataHex || DashGov.proposal.sortAndEncodeJson(data);
@@ -413,7 +414,7 @@ DashGov.proposal.draft = function (now, startEpochMs, data, gobj) {
413414
};
414415

415416
/**
416-
* @param {GObjectData} normalizedData
417+
* @param {Required<GObjectData>} normalizedData
417418
*/
418419
DashGov.proposal.sortAndEncodeJson = function (normalizedData) {
419420
let keys = Object.keys(normalizedData);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"--------": "-------------------------------------------------",
2323
"jshint": "npx -p [email protected] -- jshint -c ./.jshintrc ./*.js",
2424
"prettier": "npx -p [email protected] -- prettier -w '**/*.{js,md}'",
25-
"tsc": "npx -p [email protected] -- tsc -p ./jsconfig.json",
25+
"tsc": "! npx -p [email protected] -- tsc -p ./jsconfig.json | grep '\\.js(\\d\\+,\\d\\+): error' | grep -v '\\<node_modules/'",
2626
"---------": "------------------------------------------------",
2727
"reexport-types": "npx -p [email protected] -- reexport",
2828
"prepublish": "npm run reexport-types"

tests/gobject-propose-txid.js

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import GObj from "dashgov";
44

5+
let Crypto = globalThis.crypto;
6+
57
// function hexToBytes(hex) {
68
// let len = hex.length / 2;
79
// let bytes = new Uint8Array(len);
@@ -63,8 +65,8 @@ async function main() {
6365

6466
let hashBytes;
6567
{
66-
let hash1 = await crypto.subtle.digest("SHA-256", gobjBurnBytes);
67-
let hash2 = await crypto.subtle.digest("SHA-256", hash1);
68+
let hash1 = await Crypto.subtle.digest("SHA-256", gobjBurnBytes);
69+
let hash2 = await Crypto.subtle.digest("SHA-256", hash1);
6870

6971
let hash1Bytes = new Uint8Array(hash1);
7072
let hash1Hex = GObj.utils.bytesToHex(hash1Bytes);
@@ -83,20 +85,20 @@ async function main() {
8385
return hashBytes;
8486
}
8587

86-
function logLine64(str, comment, value) {
87-
for (let i = 0; i < str.length; i += 64) {
88-
let line = str.substring(i, i + 64);
89-
if (i === 0) {
90-
if (typeof value !== "undefined") {
91-
line = `${line} (${value})`;
92-
}
93-
line = line.padEnd(64, " ");
94-
console.info(line, comment);
95-
} else {
96-
console.info(line);
97-
}
98-
}
99-
}
88+
// function logLine64(str, comment, value) {
89+
// for (let i = 0; i < str.length; i += 64) {
90+
// let line = str.substring(i, i + 64);
91+
// if (i === 0) {
92+
// if (typeof value !== "undefined") {
93+
// line = `${line} (${value})`;
94+
// }
95+
// line = line.padEnd(64, " ");
96+
// console.info(line, comment);
97+
// } else {
98+
// console.info(line);
99+
// }
100+
// }
101+
// }
100102

101103
main()
102104
.then(function () {

0 commit comments

Comments
 (0)