@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/index.cjs CHANGED
@@ -50,7 +50,7 @@ __export(index_exports, {
50
50
  convertFixedU128ToBigNumber: () => convertFixedU128ToBigNumber,
51
51
  convertPermillToBigNumber: () => convertPermillToBigNumber,
52
52
  createKeyringPair: () => createKeyringPair,
53
- decodeAddress: () => import_util_crypto2.decodeAddress,
53
+ decodeAddress: () => import_util_crypto.decodeAddress,
54
54
  dispatchErrorToString: () => dispatchErrorToString,
55
55
  eventDataToJson: () => eventDataToJson,
56
56
  filterUndefined: () => filterUndefined,
@@ -60,10 +60,8 @@ __export(index_exports, {
60
60
  getClient: () => getClient,
61
61
  getTickFromHeader: () => getTickFromHeader,
62
62
  gettersToObject: () => gettersToObject,
63
- keyringFromCli: () => keyringFromCli,
64
- keyringFromFile: () => keyringFromFile,
65
63
  keyringFromSuri: () => keyringFromSuri,
66
- mnemonicGenerate: () => import_util_crypto2.mnemonicGenerate,
64
+ mnemonicGenerate: () => import_util_crypto.mnemonicGenerate,
67
65
  waitForLoad: () => waitForLoad
68
66
  });
69
67
  module.exports = __toCommonJS(index_exports);
@@ -94,7 +92,7 @@ var import_registry = require("@polkadot/types/types/registry");
94
92
 
95
93
  // src/index.ts
96
94
  var import_api = require("@polkadot/api");
97
- var import_util_crypto2 = require("@polkadot/util-crypto");
95
+ var import_util_crypto = require("@polkadot/util-crypto");
98
96
  __reExport(index_exports, require("@polkadot/types-codec/types"), module.exports);
99
97
 
100
98
  // src/WageProtector.ts
@@ -438,11 +436,8 @@ var AccountRegistry = class _AccountRegistry {
438
436
  // src/Accountset.ts
439
437
  var process2 = __toESM(require("process"), 1);
440
438
 
441
- // src/AccountMiners.ts
442
- var import_node_events2 = __toESM(require("events"), 1);
443
-
444
439
  // src/BlockWatch.ts
445
- var import_node_events = __toESM(require("events"), 1);
440
+ var import_nanoevents = require("nanoevents");
446
441
  function getTickFromHeader(client, header) {
447
442
  for (const x of header.digest.logs) {
448
443
  if (x.isPreRuntime) {
@@ -472,7 +467,7 @@ var BlockWatch = class {
472
467
  this.options.shouldLog ??= true;
473
468
  this.options.finalizedBlocks ??= false;
474
469
  }
475
- events = new import_node_events.default();
470
+ events = (0, import_nanoevents.createNanoEvents)();
476
471
  obligationsById = {};
477
472
  obligationIdByUtxoId = {};
478
473
  unsubscribe;
@@ -649,10 +644,10 @@ var MiningRotations = class {
649
644
  }));
650
645
  this.genesisTick ??= await client.query.ticks.genesisTick().then((x) => x.toNumber());
651
646
  const ticksBetweenSlots = this.miningConfig.ticksBetweenSlots;
652
- const slot1BiddingStartTick = this.genesisTick + this.miningConfig.slotBiddingStartAfterTicks;
653
- if (tick < slot1BiddingStartTick) return 0;
654
- const ticksSinceBiddingStart = tick - slot1BiddingStartTick;
655
- return Math.floor(ticksSinceBiddingStart / ticksBetweenSlots) + 1;
647
+ const slot1StartTick = this.genesisTick + this.miningConfig.slotBiddingStartAfterTicks + ticksBetweenSlots;
648
+ if (tick < slot1StartTick) return 0;
649
+ const ticksSinceSlot1 = tick - slot1StartTick;
650
+ return Math.floor(ticksSinceSlot1 / ticksBetweenSlots);
656
651
  }
657
652
  async getForHeader(client, header) {
658
653
  if (header.number.toNumber() === 0) return 0;
@@ -663,6 +658,7 @@ var MiningRotations = class {
663
658
  };
664
659
 
665
660
  // src/AccountMiners.ts
661
+ var import_nanoevents2 = require("nanoevents");
666
662
  var AccountMiners = class _AccountMiners {
667
663
  constructor(accountset, registeredMiners, options = { shouldLog: false }) {
668
664
  this.accountset = accountset;
@@ -675,7 +671,7 @@ var AccountMiners = class _AccountMiners {
675
671
  };
676
672
  }
677
673
  }
678
- events = new import_node_events2.default();
674
+ events = (0, import_nanoevents2.createNanoEvents)();
679
675
  miningRotations;
680
676
  trackedAccountsByAddress = {};
681
677
  async watch() {
@@ -790,7 +786,7 @@ var AccountMiners = class _AccountMiners {
790
786
  };
791
787
 
792
788
  // src/Accountset.ts
793
- var Accountset = class _Accountset {
789
+ var Accountset = class {
794
790
  txSubmitterPair;
795
791
  isProxy = false;
796
792
  seedAddress;
@@ -1173,24 +1169,6 @@ var Accountset = class _Accountset {
1173
1169
  await accountMiners.watch();
1174
1170
  return accountMiners;
1175
1171
  }
1176
- static async fromCli(program, proxyForAddress) {
1177
- const parentOptions = program.parent?.optsWithGlobals();
1178
- const keypair = await keyringFromCli(parentOptions);
1179
- const client = getClient(parentOptions.mainchainUrl);
1180
- if (proxyForAddress) {
1181
- return new _Accountset({
1182
- client,
1183
- isProxy: true,
1184
- seedAddress: proxyForAddress,
1185
- txSubmitter: keypair
1186
- });
1187
- } else {
1188
- return new _Accountset({
1189
- seedAccount: keypair,
1190
- client
1191
- });
1192
- }
1193
- }
1194
1172
  };
1195
1173
  function getDefaultSubaccountRange() {
1196
1174
  try {
@@ -1402,8 +1380,8 @@ var Vault = class {
1402
1380
  };
1403
1381
 
1404
1382
  // src/VaultMonitor.ts
1405
- var import_node_events3 = require("events");
1406
1383
  var import_console_table_printer2 = require("console-table-printer");
1384
+ var import_nanoevents3 = require("nanoevents");
1407
1385
  var VaultMonitor = class {
1408
1386
  constructor(accountset, alerts = {}, options = {}) {
1409
1387
  this.accountset = accountset;
@@ -1433,7 +1411,7 @@ var VaultMonitor = class {
1433
1411
  this.printBids(header.hash);
1434
1412
  });
1435
1413
  }
1436
- events = new import_node_events3.EventEmitter();
1414
+ events = (0, import_nanoevents3.createNanoEvents)();
1437
1415
  vaultsById = {};
1438
1416
  blockWatch;
1439
1417
  mainchain;
@@ -2311,81 +2289,20 @@ var BitcoinLocks = class _BitcoinLocks {
2311
2289
  };
2312
2290
 
2313
2291
  // src/keyringUtils.ts
2314
- var import_node_fs = require("fs");
2315
- var os = __toESM(require("os"), 1);
2316
- var { readFile, writeFile } = import_node_fs.promises;
2317
- async function keyringFromCli(opts) {
2318
- if (opts.accountSuri) {
2319
- return keyringFromSuri(opts.accountSuri);
2320
- }
2321
- if (opts.accountFilePath) {
2322
- return keyringFromFile({
2323
- filePath: opts.accountFilePath,
2324
- passphrase: opts.accountPassphrase
2325
- });
2326
- }
2327
- throw new Error(
2328
- "No ACCOUNT account loaded (either ACCOUNT_SURI or ACCOUNT_JSON_PATH required)"
2329
- );
2330
- }
2331
2292
  function keyringFromSuri(suri, cryptoType = "sr25519") {
2332
2293
  return new import_api.Keyring({ type: cryptoType }).createFromUri(suri);
2333
2294
  }
2334
- async function keyringFromFile(opts) {
2335
- if (!opts.filePath) {
2336
- throw new Error(
2337
- "No ACCOUNT account loaded (either ACCOUNT_SURI or ACCOUNT_JSON_PATH required)"
2338
- );
2339
- }
2340
- const path = opts.filePath.replace("~", os.homedir());
2341
- const json = JSON.parse(await readFile(path, "utf-8"));
2342
- const mainAccount = new import_api.Keyring().createFromJson(json);
2343
- mainAccount.decodePkcs8(opts.passphrase);
2344
- return mainAccount;
2345
- }
2346
- async function createKeyringPair(opts) {
2347
- const { filePath, passphrase, cryptoType } = opts;
2348
- const seed = (0, import_util_crypto2.mnemonicGenerate)();
2349
- const keyring = keyringFromSuri(seed, cryptoType);
2350
- if (filePath) {
2351
- const json = keyring.toJson(passphrase);
2352
- await writeFile(filePath, JSON.stringify(json, null, 2));
2353
- }
2354
- return keyring;
2295
+ function createKeyringPair(opts) {
2296
+ const { cryptoType } = opts;
2297
+ const seed = (0, import_util_crypto.mnemonicGenerate)();
2298
+ return keyringFromSuri(seed, cryptoType);
2355
2299
  }
2356
2300
 
2357
- // src/clis/index.ts
2358
- var import_extra_typings6 = require("@commander-js/extra-typings");
2359
-
2360
- // src/clis/accountCli.ts
2361
- var import_extra_typings = require("@commander-js/extra-typings");
2362
- var import_console_table_printer4 = require("console-table-printer");
2363
- var import_util_crypto = require("@polkadot/util-crypto");
2364
- var import_node_fs2 = require("fs");
2365
- var process3 = __toESM(require("process"), 1);
2366
-
2367
- // src/clis/index.ts
2368
- var import_dotenv = require("dotenv");
2369
- var import_node_path = __toESM(require("path"), 1);
2370
-
2371
- // src/clis/vaultCli.ts
2372
- var import_extra_typings2 = require("@commander-js/extra-typings");
2373
-
2374
- // src/clis/miningCli.ts
2375
- var import_extra_typings3 = require("@commander-js/extra-typings");
2376
- var import_console_table_printer5 = require("console-table-printer");
2377
-
2378
- // src/clis/liquidityCli.ts
2379
- var import_extra_typings4 = require("@commander-js/extra-typings");
2380
-
2381
- // src/clis/bitcoinCli.ts
2382
- var import_extra_typings5 = require("@commander-js/extra-typings");
2383
-
2384
2301
  // src/index.ts
2385
2302
  __reExport(index_exports, require("@polkadot/types"), module.exports);
2386
2303
  __reExport(index_exports, require("@polkadot/types/interfaces"), module.exports);
2387
2304
  async function waitForLoad() {
2388
- await (0, import_util_crypto2.cryptoWaitReady)();
2305
+ await (0, import_util_crypto.cryptoWaitReady)();
2389
2306
  }
2390
2307
  async function getClient(host) {
2391
2308
  let provider;
@@ -2427,8 +2344,6 @@ async function getClient(host) {
2427
2344
  getClient,
2428
2345
  getTickFromHeader,
2429
2346
  gettersToObject,
2430
- keyringFromCli,
2431
- keyringFromFile,
2432
2347
  keyringFromSuri,
2433
2348
  mnemonicGenerate,
2434
2349
  waitForLoad,