@@ -8,7 +8,37 @@ import * as Secp256k1 from "@dashincubator/secp256k1";
8
8
9
9
import Fs from "node:fs/promises" ;
10
10
11
- async function main ( ) {
11
+ /**
12
+ * @typedef ProposalData
13
+ * @prop {"mainnet"|"testnet" } network - The network type, either mainnet or testnet.
14
+ * @prop {String } rpcBasicAuth - Basic authentication credentials for RPC (e.g., `api:null`).
15
+ * @prop {String } rpcBaseUrl - Base URL for the RPC server, adjusted for the network.
16
+ * @prop {String } rpcExplorer - URL for the RPC explorer.
17
+ * @prop {Number } startPeriod - The start period for the proposal.
18
+ * @prop {Number } numPeriods - Number of periods for which the proposal applies.
19
+ * @prop {Number } dashAmount - The amount of Dash for the proposal.
20
+ * @prop {String } proposalUrl - URL of the proposal.
21
+ * @prop {String } proposalName - Name of the proposal.
22
+ * @prop {String } paymentAddr - Payment address for the proposal.
23
+ * @prop {String } burnWif - Wallet Import Format (WIF) key used for the burn address.
24
+ */
25
+
26
+ /**
27
+ * @param {ProposalData } opts
28
+ */
29
+ async function prepAndSubmit ( {
30
+ network,
31
+ rpcBasicAuth,
32
+ rpcBaseUrl,
33
+ rpcExplorer,
34
+ startPeriod,
35
+ numPeriods,
36
+ dashAmount,
37
+ proposalUrl,
38
+ proposalName,
39
+ paymentAddr,
40
+ burnWif,
41
+ } ) {
12
42
/* jshint maxcomplexity: 100 */
13
43
/* jshint maxstatements: 1000 */
14
44
@@ -24,32 +54,6 @@ async function main() {
24
54
) ;
25
55
console . info ( "" ) ;
26
56
27
- /** @type {"mainnet"|"testnet" } */
28
- let network = "mainnet" ;
29
- let rpcBasicAuth = `api:null` ;
30
- let rpcBaseUrl = `https://${ rpcBasicAuth } @rpc.digitalcash.dev/` ;
31
- let rpcExplorer = "https://rpc.digitalcash.dev/" ;
32
-
33
- let isTestnet = takeFlag ( process . argv , [ "--testnet" ] ) ;
34
- if ( isTestnet ) {
35
- rpcBaseUrl = `https://${ rpcBasicAuth } @trpc.digitalcash.dev/` ;
36
- rpcExplorer = "https://trpc.digitalcash.dev/" ;
37
- network = "testnet" ;
38
- }
39
-
40
- let startPeriod = parseInt ( process . argv [ 2 ] || "1" , 10 ) ;
41
- let numPeriods = parseInt ( process . argv [ 3 ] || "1" , 10 ) ;
42
- let dashAmount = parseInt ( process . argv [ 4 ] || "1" , 10 ) ;
43
- let proposalUrl = process . argv [ 5 ] || "" ;
44
- let proposalName = process . argv [ 6 ] || "" ;
45
- let paymentAddr = process . argv [ 7 ] || "" ;
46
- let burnWifPath = process . argv [ 8 ] || "" ;
47
- let burnWif = "" ;
48
- if ( burnWifPath ) {
49
- burnWif = await Fs . readFile ( burnWifPath , "utf8" ) ;
50
- burnWif = burnWif . trim ( ) ;
51
- }
52
-
53
57
/**
54
58
* @param {String } method
55
59
* @param {...any } params
@@ -428,6 +432,48 @@ async function main() {
428
432
}
429
433
}
430
434
435
+ async function main ( ) {
436
+ /** @type {"mainnet"|"testnet" } */
437
+ let network = "mainnet" ;
438
+ let rpcBasicAuth = `api:null` ;
439
+ let rpcBaseUrl = `https://${ rpcBasicAuth } @rpc.digitalcash.dev/` ;
440
+ let rpcExplorer = "https://rpc.digitalcash.dev/" ;
441
+
442
+ let isTestnet = takeFlag ( process . argv , [ "--testnet" ] ) ;
443
+ if ( isTestnet ) {
444
+ rpcBaseUrl = `https://${ rpcBasicAuth } @trpc.digitalcash.dev/` ;
445
+ rpcExplorer = "https://trpc.digitalcash.dev/" ;
446
+ network = "testnet" ;
447
+ }
448
+
449
+ let startPeriod = parseInt ( process . argv [ 2 ] || "1" , 10 ) ;
450
+ let numPeriods = parseInt ( process . argv [ 3 ] || "1" , 10 ) ;
451
+ let dashAmount = parseInt ( process . argv [ 4 ] || "1" , 10 ) ;
452
+ let proposalUrl = process . argv [ 5 ] || "" ;
453
+ let proposalName = process . argv [ 6 ] || "" ;
454
+ let paymentAddr = process . argv [ 7 ] || "" ;
455
+ let burnWifPath = process . argv [ 8 ] || "" ;
456
+ let burnWif = "" ;
457
+ if ( burnWifPath ) {
458
+ burnWif = await Fs . readFile ( burnWifPath , "utf8" ) ;
459
+ burnWif = burnWif . trim ( ) ;
460
+ }
461
+
462
+ await prepAndSubmit ( {
463
+ network,
464
+ rpcBasicAuth,
465
+ rpcBaseUrl,
466
+ rpcExplorer,
467
+ startPeriod,
468
+ numPeriods,
469
+ dashAmount,
470
+ proposalUrl,
471
+ proposalName,
472
+ paymentAddr,
473
+ burnWif,
474
+ } ) ;
475
+ }
476
+
431
477
/**
432
478
* Find, remove, and return the first matching flag from the arguments list
433
479
* @param {Array<String> } argv
0 commit comments