@argonprotocol/mainchain 1.1.0-rc.4 → 1.1.0-rc.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cli.cjs +91 -89
- package/lib/cli.cjs.map +1 -1
- package/lib/cli.js +89 -87
- package/lib/cli.js.map +1 -1
- package/lib/clis/index.cjs +97 -89
- package/lib/clis/index.cjs.map +1 -1
- package/lib/clis/index.d.cts +101 -1
- package/lib/clis/index.d.ts +101 -1
- package/lib/clis/index.js +92 -87
- package/lib/clis/index.js.map +1 -1
- package/lib/index.cjs +19 -104
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +274 -265
- package/lib/index.d.ts +274 -265
- package/lib/index.js +27 -110
- package/lib/index.js.map +1 -1
- package/package.json +8 -8
package/lib/cli.cjs
CHANGED
|
@@ -66,8 +66,6 @@ __export(index_exports, {
|
|
|
66
66
|
getClient: () => getClient,
|
|
67
67
|
getTickFromHeader: () => getTickFromHeader,
|
|
68
68
|
gettersToObject: () => gettersToObject,
|
|
69
|
-
keyringFromCli: () => keyringFromCli,
|
|
70
|
-
keyringFromFile: () => keyringFromFile,
|
|
71
69
|
keyringFromSuri: () => keyringFromSuri,
|
|
72
70
|
mnemonicGenerate: () => import_util_crypto.mnemonicGenerate,
|
|
73
71
|
waitForLoad: () => waitForLoad
|
|
@@ -443,11 +441,8 @@ var AccountRegistry = class _AccountRegistry {
|
|
|
443
441
|
// src/Accountset.ts
|
|
444
442
|
var process2 = __toESM(require("process"), 1);
|
|
445
443
|
|
|
446
|
-
// src/AccountMiners.ts
|
|
447
|
-
var import_node_events2 = __toESM(require("events"), 1);
|
|
448
|
-
|
|
449
444
|
// src/BlockWatch.ts
|
|
450
|
-
var
|
|
445
|
+
var import_nanoevents = require("nanoevents");
|
|
451
446
|
function getTickFromHeader(client, header) {
|
|
452
447
|
for (const x of header.digest.logs) {
|
|
453
448
|
if (x.isPreRuntime) {
|
|
@@ -477,7 +472,7 @@ var BlockWatch = class {
|
|
|
477
472
|
this.options.shouldLog ??= true;
|
|
478
473
|
this.options.finalizedBlocks ??= false;
|
|
479
474
|
}
|
|
480
|
-
events =
|
|
475
|
+
events = (0, import_nanoevents.createNanoEvents)();
|
|
481
476
|
obligationsById = {};
|
|
482
477
|
obligationIdByUtxoId = {};
|
|
483
478
|
unsubscribe;
|
|
@@ -654,10 +649,10 @@ var MiningRotations = class {
|
|
|
654
649
|
}));
|
|
655
650
|
this.genesisTick ??= await client.query.ticks.genesisTick().then((x) => x.toNumber());
|
|
656
651
|
const ticksBetweenSlots = this.miningConfig.ticksBetweenSlots;
|
|
657
|
-
const
|
|
658
|
-
if (tick <
|
|
659
|
-
const
|
|
660
|
-
return Math.floor(
|
|
652
|
+
const slot1StartTick = this.genesisTick + this.miningConfig.slotBiddingStartAfterTicks + ticksBetweenSlots;
|
|
653
|
+
if (tick < slot1StartTick) return 0;
|
|
654
|
+
const ticksSinceSlot1 = tick - slot1StartTick;
|
|
655
|
+
return Math.floor(ticksSinceSlot1 / ticksBetweenSlots);
|
|
661
656
|
}
|
|
662
657
|
async getForHeader(client, header) {
|
|
663
658
|
if (header.number.toNumber() === 0) return 0;
|
|
@@ -668,6 +663,7 @@ var MiningRotations = class {
|
|
|
668
663
|
};
|
|
669
664
|
|
|
670
665
|
// src/AccountMiners.ts
|
|
666
|
+
var import_nanoevents2 = require("nanoevents");
|
|
671
667
|
var AccountMiners = class _AccountMiners {
|
|
672
668
|
constructor(accountset, registeredMiners, options = { shouldLog: false }) {
|
|
673
669
|
this.accountset = accountset;
|
|
@@ -680,7 +676,7 @@ var AccountMiners = class _AccountMiners {
|
|
|
680
676
|
};
|
|
681
677
|
}
|
|
682
678
|
}
|
|
683
|
-
events =
|
|
679
|
+
events = (0, import_nanoevents2.createNanoEvents)();
|
|
684
680
|
miningRotations;
|
|
685
681
|
trackedAccountsByAddress = {};
|
|
686
682
|
async watch() {
|
|
@@ -795,7 +791,7 @@ var AccountMiners = class _AccountMiners {
|
|
|
795
791
|
};
|
|
796
792
|
|
|
797
793
|
// src/Accountset.ts
|
|
798
|
-
var Accountset = class
|
|
794
|
+
var Accountset = class {
|
|
799
795
|
txSubmitterPair;
|
|
800
796
|
isProxy = false;
|
|
801
797
|
seedAddress;
|
|
@@ -1178,24 +1174,6 @@ var Accountset = class _Accountset {
|
|
|
1178
1174
|
await accountMiners.watch();
|
|
1179
1175
|
return accountMiners;
|
|
1180
1176
|
}
|
|
1181
|
-
static async fromCli(program2, proxyForAddress) {
|
|
1182
|
-
const parentOptions = program2.parent?.optsWithGlobals();
|
|
1183
|
-
const keypair = await keyringFromCli(parentOptions);
|
|
1184
|
-
const client = getClient(parentOptions.mainchainUrl);
|
|
1185
|
-
if (proxyForAddress) {
|
|
1186
|
-
return new _Accountset({
|
|
1187
|
-
client,
|
|
1188
|
-
isProxy: true,
|
|
1189
|
-
seedAddress: proxyForAddress,
|
|
1190
|
-
txSubmitter: keypair
|
|
1191
|
-
});
|
|
1192
|
-
} else {
|
|
1193
|
-
return new _Accountset({
|
|
1194
|
-
seedAccount: keypair,
|
|
1195
|
-
client
|
|
1196
|
-
});
|
|
1197
|
-
}
|
|
1198
|
-
}
|
|
1199
1177
|
};
|
|
1200
1178
|
function getDefaultSubaccountRange() {
|
|
1201
1179
|
try {
|
|
@@ -1407,8 +1385,8 @@ var Vault = class {
|
|
|
1407
1385
|
};
|
|
1408
1386
|
|
|
1409
1387
|
// src/VaultMonitor.ts
|
|
1410
|
-
var import_node_events3 = require("events");
|
|
1411
1388
|
var import_console_table_printer2 = require("console-table-printer");
|
|
1389
|
+
var import_nanoevents3 = require("nanoevents");
|
|
1412
1390
|
var VaultMonitor = class {
|
|
1413
1391
|
constructor(accountset, alerts = {}, options = {}) {
|
|
1414
1392
|
this.accountset = accountset;
|
|
@@ -1438,7 +1416,7 @@ var VaultMonitor = class {
|
|
|
1438
1416
|
this.printBids(header.hash);
|
|
1439
1417
|
});
|
|
1440
1418
|
}
|
|
1441
|
-
events =
|
|
1419
|
+
events = (0, import_nanoevents3.createNanoEvents)();
|
|
1442
1420
|
vaultsById = {};
|
|
1443
1421
|
blockWatch;
|
|
1444
1422
|
mainchain;
|
|
@@ -2316,47 +2294,13 @@ var BitcoinLocks = class _BitcoinLocks {
|
|
|
2316
2294
|
};
|
|
2317
2295
|
|
|
2318
2296
|
// src/keyringUtils.ts
|
|
2319
|
-
var import_node_fs = require("fs");
|
|
2320
|
-
var os = __toESM(require("os"), 1);
|
|
2321
|
-
var { readFile, writeFile } = import_node_fs.promises;
|
|
2322
|
-
async function keyringFromCli(opts) {
|
|
2323
|
-
if (opts.accountSuri) {
|
|
2324
|
-
return keyringFromSuri(opts.accountSuri);
|
|
2325
|
-
}
|
|
2326
|
-
if (opts.accountFilePath) {
|
|
2327
|
-
return keyringFromFile({
|
|
2328
|
-
filePath: opts.accountFilePath,
|
|
2329
|
-
passphrase: opts.accountPassphrase
|
|
2330
|
-
});
|
|
2331
|
-
}
|
|
2332
|
-
throw new Error(
|
|
2333
|
-
"No ACCOUNT account loaded (either ACCOUNT_SURI or ACCOUNT_JSON_PATH required)"
|
|
2334
|
-
);
|
|
2335
|
-
}
|
|
2336
2297
|
function keyringFromSuri(suri, cryptoType = "sr25519") {
|
|
2337
2298
|
return new import_api.Keyring({ type: cryptoType }).createFromUri(suri);
|
|
2338
2299
|
}
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
throw new Error(
|
|
2342
|
-
"No ACCOUNT account loaded (either ACCOUNT_SURI or ACCOUNT_JSON_PATH required)"
|
|
2343
|
-
);
|
|
2344
|
-
}
|
|
2345
|
-
const path = opts.filePath.replace("~", os.homedir());
|
|
2346
|
-
const json = JSON.parse(await readFile(path, "utf-8"));
|
|
2347
|
-
const mainAccount = new import_api.Keyring().createFromJson(json);
|
|
2348
|
-
mainAccount.decodePkcs8(opts.passphrase);
|
|
2349
|
-
return mainAccount;
|
|
2350
|
-
}
|
|
2351
|
-
async function createKeyringPair(opts) {
|
|
2352
|
-
const { filePath, passphrase, cryptoType } = opts;
|
|
2300
|
+
function createKeyringPair(opts) {
|
|
2301
|
+
const { cryptoType } = opts;
|
|
2353
2302
|
const seed = (0, import_util_crypto.mnemonicGenerate)();
|
|
2354
|
-
|
|
2355
|
-
if (filePath) {
|
|
2356
|
-
const json = keyring.toJson(passphrase);
|
|
2357
|
-
await writeFile(filePath, JSON.stringify(json, null, 2));
|
|
2358
|
-
}
|
|
2359
|
-
return keyring;
|
|
2303
|
+
return keyringFromSuri(seed, cryptoType);
|
|
2360
2304
|
}
|
|
2361
2305
|
|
|
2362
2306
|
// src/index.ts
|
|
@@ -2378,14 +2322,14 @@ async function getClient(host) {
|
|
|
2378
2322
|
// src/clis/accountCli.ts
|
|
2379
2323
|
var import_console_table_printer4 = require("console-table-printer");
|
|
2380
2324
|
var import_util_crypto2 = require("@polkadot/util-crypto");
|
|
2381
|
-
var
|
|
2325
|
+
var import_node_fs = require("fs");
|
|
2382
2326
|
var process3 = __toESM(require("process"), 1);
|
|
2383
2327
|
function accountCli() {
|
|
2384
2328
|
const program2 = new import_extra_typings.Command("accounts").description(
|
|
2385
2329
|
"Manage subaccounts from a single keypair"
|
|
2386
2330
|
);
|
|
2387
2331
|
program2.command("watch").description("Watch for blocks closed by subaccounts").action(async () => {
|
|
2388
|
-
const accountset = await
|
|
2332
|
+
const accountset = await accountsetFromCli(program2);
|
|
2389
2333
|
const accountMiners = await accountset.watchBlocks();
|
|
2390
2334
|
accountMiners.events.on("mined", (_block, mined) => {
|
|
2391
2335
|
console.log("Your accounts authored a block", mined);
|
|
@@ -2396,7 +2340,7 @@ function accountCli() {
|
|
|
2396
2340
|
});
|
|
2397
2341
|
program2.command("list", { isDefault: true }).description("Show subaccounts").option("--addresses", "Just show a list of ids").action(async ({ addresses }) => {
|
|
2398
2342
|
const { subaccounts } = globalOptions(program2);
|
|
2399
|
-
const accountset = await
|
|
2343
|
+
const accountset = await accountsetFromCli(program2);
|
|
2400
2344
|
if (addresses) {
|
|
2401
2345
|
const addresses2 = accountset.addresses;
|
|
2402
2346
|
console.log(addresses2.join(","));
|
|
@@ -2427,7 +2371,7 @@ function accountCli() {
|
|
|
2427
2371
|
"Register the keys to a url (normally this is localhost)"
|
|
2428
2372
|
).action(async ({ registerKeysTo, path }) => {
|
|
2429
2373
|
const { accountPassphrase, accountSuri, accountFilePath } = globalOptions(program2);
|
|
2430
|
-
const accountset = await
|
|
2374
|
+
const accountset = await accountsetFromCli(program2);
|
|
2431
2375
|
process3.env.KEYS_MNEMONIC ||= (0, import_util_crypto.mnemonicGenerate)();
|
|
2432
2376
|
if (registerKeysTo) {
|
|
2433
2377
|
await accountset.registerKeys(registerKeysTo);
|
|
@@ -2447,7 +2391,7 @@ function accountCli() {
|
|
|
2447
2391
|
envfile += line + "\n";
|
|
2448
2392
|
}
|
|
2449
2393
|
}
|
|
2450
|
-
(0,
|
|
2394
|
+
(0, import_node_fs.writeFileSync)(path, envfile);
|
|
2451
2395
|
console.log("Created env file at", path);
|
|
2452
2396
|
process3.exit();
|
|
2453
2397
|
});
|
|
@@ -2468,7 +2412,7 @@ function accountCli() {
|
|
|
2468
2412
|
"--print-only",
|
|
2469
2413
|
"Output as curl commands instead of direct registration"
|
|
2470
2414
|
).action(async (nodeRpcUrl, { printOnly }) => {
|
|
2471
|
-
const accountset = await
|
|
2415
|
+
const accountset = await accountsetFromCli(program2);
|
|
2472
2416
|
if (printOnly) {
|
|
2473
2417
|
const { gran, seal } = accountset.keys();
|
|
2474
2418
|
const commands = [];
|
|
@@ -2502,7 +2446,7 @@ function accountCli() {
|
|
|
2502
2446
|
"Restrict this operation to a subset of the subaccounts (eg, 0-10)",
|
|
2503
2447
|
parseSubaccountRange
|
|
2504
2448
|
).action(async ({ subaccounts }) => {
|
|
2505
|
-
const accountset = await
|
|
2449
|
+
const accountset = await accountsetFromCli(program2);
|
|
2506
2450
|
const result = await accountset.consolidate(subaccounts);
|
|
2507
2451
|
(0, import_console_table_printer4.printTable)(result);
|
|
2508
2452
|
process3.exit(0);
|
|
@@ -2521,7 +2465,7 @@ function vaultCli() {
|
|
|
2521
2465
|
"Monitor vaults and manage securitization"
|
|
2522
2466
|
);
|
|
2523
2467
|
program2.command("list", { isDefault: true }).description("Show current state of vaults").action(async () => {
|
|
2524
|
-
const accountset = await
|
|
2468
|
+
const accountset = await accountsetFromCli(program2);
|
|
2525
2469
|
const vaults = new VaultMonitor(accountset, void 0, {
|
|
2526
2470
|
vaultOnlyWatchMode: true
|
|
2527
2471
|
});
|
|
@@ -2537,7 +2481,7 @@ function vaultCli() {
|
|
|
2537
2481
|
"The tip to include with the transaction",
|
|
2538
2482
|
parseFloat
|
|
2539
2483
|
).action(async ({ tip, argons, vaultId, ratio }) => {
|
|
2540
|
-
const accountset = await
|
|
2484
|
+
const accountset = await accountsetFromCli(program2);
|
|
2541
2485
|
const client = await accountset.client;
|
|
2542
2486
|
const resolvedTip = tip ? BigInt(tip * 1e6) : 0n;
|
|
2543
2487
|
const microgons = BigInt(argons * 1e6);
|
|
@@ -2598,7 +2542,7 @@ function vaultCli() {
|
|
|
2598
2542
|
"Bitcoin pubkey must be 66 characters (add 0x in front optionally)"
|
|
2599
2543
|
);
|
|
2600
2544
|
}
|
|
2601
|
-
const accountset = await
|
|
2545
|
+
const accountset = await accountsetFromCli(program2);
|
|
2602
2546
|
const client = await accountset.client;
|
|
2603
2547
|
const resolvedTip = tip ? BigInt(tip * 1e6) : 0n;
|
|
2604
2548
|
const microgons = BigInt(argons * 1e6);
|
|
@@ -2681,7 +2625,7 @@ function miningCli() {
|
|
|
2681
2625
|
"Watch mining seats or setup bidding"
|
|
2682
2626
|
);
|
|
2683
2627
|
program2.command("list", { isDefault: true }).description("Monitor all miners").action(async () => {
|
|
2684
|
-
const accountset = await
|
|
2628
|
+
const accountset = await accountsetFromCli(program2);
|
|
2685
2629
|
const bids = new MiningBids(accountset.client);
|
|
2686
2630
|
const api = await accountset.client;
|
|
2687
2631
|
let lastMiners = {};
|
|
@@ -2777,7 +2721,7 @@ function miningCli() {
|
|
|
2777
2721
|
bidIncrement,
|
|
2778
2722
|
proxyForAddress
|
|
2779
2723
|
}) => {
|
|
2780
|
-
const accountset = await
|
|
2724
|
+
const accountset = await accountsetFromCli(program2, proxyForAddress);
|
|
2781
2725
|
let cohortBidder;
|
|
2782
2726
|
const miningBids = new MiningBids(accountset.client, false);
|
|
2783
2727
|
const maxCohortSize = await miningBids.maxCohortSize();
|
|
@@ -2864,7 +2808,7 @@ function miningCli() {
|
|
|
2864
2808
|
).action(async ({ outfile, proxyPassphrase, feeArgons }) => {
|
|
2865
2809
|
const { mainchainUrl } = globalOptions(program2);
|
|
2866
2810
|
const client = await getClient(mainchainUrl);
|
|
2867
|
-
const keyringPair = await
|
|
2811
|
+
const keyringPair = await saveKeyringPair({
|
|
2868
2812
|
filePath: outfile,
|
|
2869
2813
|
passphrase: proxyPassphrase
|
|
2870
2814
|
});
|
|
@@ -2878,7 +2822,7 @@ function miningCli() {
|
|
|
2878
2822
|
]);
|
|
2879
2823
|
let keypair;
|
|
2880
2824
|
try {
|
|
2881
|
-
const accountset = await
|
|
2825
|
+
const accountset = await accountsetFromCli(program2);
|
|
2882
2826
|
keypair = accountset.txSubmitterPair;
|
|
2883
2827
|
} catch (e) {
|
|
2884
2828
|
const polkadotLink = `https://polkadot.js.org/apps/?rpc=${mainchainUrl}#/extrinsics/decode/${tx.toHex()}`;
|
|
@@ -2906,7 +2850,7 @@ function liquidityCli() {
|
|
|
2906
2850
|
"Monitor or bond to liquidity pools"
|
|
2907
2851
|
);
|
|
2908
2852
|
program2.command("list", { isDefault: true }).description("Show or watch the vault bid pool rewards").action(async () => {
|
|
2909
|
-
const accountset = await
|
|
2853
|
+
const accountset = await accountsetFromCli(program2);
|
|
2910
2854
|
const bidPool = new BidPool(
|
|
2911
2855
|
accountset.client,
|
|
2912
2856
|
accountset.txSubmitterPair
|
|
@@ -2922,7 +2866,7 @@ function liquidityCli() {
|
|
|
2922
2866
|
"The tip to include with the transaction",
|
|
2923
2867
|
parseFloat
|
|
2924
2868
|
).action(async ({ tip, argons, vaultId }) => {
|
|
2925
|
-
const accountset = await
|
|
2869
|
+
const accountset = await accountsetFromCli(program2);
|
|
2926
2870
|
const resolvedTip = tip ? BigInt(tip * 1e6) : 0n;
|
|
2927
2871
|
const microgons = BigInt(argons * 1e6);
|
|
2928
2872
|
const bidPool = new BidPool(
|
|
@@ -2950,7 +2894,7 @@ function liquidityCli() {
|
|
|
2950
2894
|
parseFloat
|
|
2951
2895
|
).action(async ({ maxArgons, minPctSharing, tip }) => {
|
|
2952
2896
|
const maxAmountPerSlot = BigInt(maxArgons * 1e6);
|
|
2953
|
-
const accountset = await
|
|
2897
|
+
const accountset = await accountsetFromCli(program2);
|
|
2954
2898
|
const vaults = new VaultMonitor(
|
|
2955
2899
|
accountset,
|
|
2956
2900
|
{
|
|
@@ -2999,7 +2943,7 @@ function bitcoinCli() {
|
|
|
2999
2943
|
"Alert when bitcoin space exceeds this amount",
|
|
3000
2944
|
parseFloat
|
|
3001
2945
|
).description("Watch for bitcoin space available").action(async ({ argons }) => {
|
|
3002
|
-
const accountset = await
|
|
2946
|
+
const accountset = await accountsetFromCli(program2);
|
|
3003
2947
|
const bot = new VaultMonitor(accountset, {
|
|
3004
2948
|
bitcoinSpaceAvailable: argons ? BigInt(argons * 1e6) : 1n
|
|
3005
2949
|
});
|
|
@@ -3031,7 +2975,7 @@ function bitcoinCli() {
|
|
|
3031
2975
|
0
|
|
3032
2976
|
).action(async ({ argons, bitcoinXpub, maxLockFee, tip }) => {
|
|
3033
2977
|
const amountToLock = BigInt(argons * 1e6);
|
|
3034
|
-
const accountset = await
|
|
2978
|
+
const accountset = await accountsetFromCli(program2);
|
|
3035
2979
|
await BitcoinLocks.waitForSpace(accountset, {
|
|
3036
2980
|
argonAmount: amountToLock,
|
|
3037
2981
|
bitcoinXpub,
|
|
@@ -3049,6 +2993,32 @@ function bitcoinCli() {
|
|
|
3049
2993
|
return program2;
|
|
3050
2994
|
}
|
|
3051
2995
|
|
|
2996
|
+
// src/clis/keyringStore.ts
|
|
2997
|
+
var import_node_fs2 = require("fs");
|
|
2998
|
+
var os = __toESM(require("os"), 1);
|
|
2999
|
+
var { readFile, writeFile } = import_node_fs2.promises;
|
|
3000
|
+
async function keyringFromFile(opts) {
|
|
3001
|
+
if (!opts.filePath) {
|
|
3002
|
+
throw new Error(
|
|
3003
|
+
"No ACCOUNT account loaded (either ACCOUNT_SURI or ACCOUNT_JSON_PATH required)"
|
|
3004
|
+
);
|
|
3005
|
+
}
|
|
3006
|
+
const path = opts.filePath.replace("~", os.homedir());
|
|
3007
|
+
const json = JSON.parse(await readFile(path, "utf-8"));
|
|
3008
|
+
const mainAccount = new import_api.Keyring().createFromJson(json);
|
|
3009
|
+
mainAccount.decodePkcs8(opts.passphrase);
|
|
3010
|
+
return mainAccount;
|
|
3011
|
+
}
|
|
3012
|
+
async function saveKeyringPair(opts) {
|
|
3013
|
+
const { filePath, passphrase, cryptoType } = opts;
|
|
3014
|
+
const keyring = createKeyringPair({ cryptoType });
|
|
3015
|
+
if (filePath) {
|
|
3016
|
+
const json = keyring.toJson(passphrase);
|
|
3017
|
+
await writeFile(filePath, JSON.stringify(json, null, 2));
|
|
3018
|
+
}
|
|
3019
|
+
return keyring;
|
|
3020
|
+
}
|
|
3021
|
+
|
|
3052
3022
|
// src/clis/index.ts
|
|
3053
3023
|
function globalOptions(program2) {
|
|
3054
3024
|
return program2.optsWithGlobals();
|
|
@@ -3078,6 +3048,38 @@ function buildCli() {
|
|
|
3078
3048
|
).env("SUBACCOUNT_RANGE").argParser(parseSubaccountRange)
|
|
3079
3049
|
).addCommand(accountCli()).addCommand(vaultCli()).addCommand(miningCli()).addCommand(liquidityCli()).addCommand(bitcoinCli());
|
|
3080
3050
|
}
|
|
3051
|
+
async function accountsetFromCli(program2, proxyForAddress) {
|
|
3052
|
+
const opts = program2.parent?.optsWithGlobals();
|
|
3053
|
+
let keypair;
|
|
3054
|
+
if (opts.accountSuri) {
|
|
3055
|
+
keypair = keyringFromSuri(opts.accountSuri);
|
|
3056
|
+
}
|
|
3057
|
+
if (opts.accountFilePath) {
|
|
3058
|
+
keypair = await keyringFromFile({
|
|
3059
|
+
filePath: opts.accountFilePath,
|
|
3060
|
+
passphrase: opts.accountPassphrase
|
|
3061
|
+
});
|
|
3062
|
+
}
|
|
3063
|
+
if (!keypair) {
|
|
3064
|
+
throw new Error(
|
|
3065
|
+
"No ACCOUNT account loaded (either ACCOUNT_SURI or ACCOUNT_JSON_PATH required)"
|
|
3066
|
+
);
|
|
3067
|
+
}
|
|
3068
|
+
const client = getClient(opts.mainchainUrl);
|
|
3069
|
+
if (proxyForAddress) {
|
|
3070
|
+
return new Accountset({
|
|
3071
|
+
client,
|
|
3072
|
+
isProxy: true,
|
|
3073
|
+
seedAddress: proxyForAddress,
|
|
3074
|
+
txSubmitter: keypair
|
|
3075
|
+
});
|
|
3076
|
+
} else {
|
|
3077
|
+
return new Accountset({
|
|
3078
|
+
seedAccount: keypair,
|
|
3079
|
+
client
|
|
3080
|
+
});
|
|
3081
|
+
}
|
|
3082
|
+
}
|
|
3081
3083
|
function addGlobalArgs(program2) {
|
|
3082
3084
|
for (const command of program2.commands) {
|
|
3083
3085
|
command.configureHelp({
|