@argonprotocol/mainchain 1.3.6 → 1.3.7
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/browser/index.d.ts +5 -4
- package/browser/index.js +21 -12
- package/browser/index.js.map +1 -1
- package/lib/{chunk-KYRBSY6G.cjs → chunk-4ZBJ5W3P.cjs} +51 -51
- package/lib/{chunk-KYRBSY6G.cjs.map → chunk-4ZBJ5W3P.cjs.map} +1 -1
- package/lib/{chunk-KMBXJV55.js → chunk-PE7HFDHD.js} +7 -7
- package/lib/{chunk-FGSUNAT4.js → chunk-PXZPYJ4P.js} +32 -20
- package/lib/{chunk-FGSUNAT4.js.map → chunk-PXZPYJ4P.js.map} +1 -1
- package/lib/{chunk-U6J3AWYW.cjs → chunk-VXYWJG66.cjs} +24 -12
- package/lib/chunk-VXYWJG66.cjs.map +1 -0
- package/lib/cli.cjs +6 -6
- package/lib/cli.js +2 -2
- package/lib/clis/index.cjs +3 -3
- package/lib/clis/index.js +2 -2
- package/lib/index.cjs +4 -2
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +5 -4
- package/lib/index.d.ts +5 -4
- package/lib/index.js +3 -1
- package/package.json +19 -19
- package/lib/chunk-U6J3AWYW.cjs.map +0 -1
- /package/lib/{chunk-KMBXJV55.js.map → chunk-PE7HFDHD.js.map} +0 -0
|
@@ -96,7 +96,7 @@ function getConfig() {
|
|
|
96
96
|
return {
|
|
97
97
|
debug: config.debug ?? getEnvVar("DEBUG") === "true",
|
|
98
98
|
keysVersion: config.keysVersion ?? (getEnvVar("KEYS_VERSION") ? parseInt(getEnvVar("KEYS_VERSION")) : void 0),
|
|
99
|
-
|
|
99
|
+
keySeedOrMnemonic: config.keySeedOrMnemonic ?? getEnvVar("KEYS_MNEMONIC"),
|
|
100
100
|
subaccountRange: config.subaccountRange ?? getEnvVar("SUBACCOUNT_RANGE") ?? "0-9"
|
|
101
101
|
};
|
|
102
102
|
}
|
|
@@ -259,8 +259,19 @@ var TxResult = class {
|
|
|
259
259
|
|
|
260
260
|
// src/utils.ts
|
|
261
261
|
import BigNumber, * as BN from "bignumber.js";
|
|
262
|
+
import { ed25519DeriveHard, keyExtractSuri, mnemonicToMiniSecret } from "@polkadot/util-crypto";
|
|
263
|
+
import { u8aToHex } from "@polkadot/util";
|
|
262
264
|
var { ROUND_FLOOR } = BN;
|
|
263
265
|
var MICROGONS_PER_ARGON = 1e6;
|
|
266
|
+
function miniSecretFromUri(uri, password) {
|
|
267
|
+
const { phrase, path } = keyExtractSuri(uri);
|
|
268
|
+
let mini = mnemonicToMiniSecret(phrase, password);
|
|
269
|
+
for (const j of path) {
|
|
270
|
+
if (!j.isHard) throw new Error("ed25519 soft derivation not supported");
|
|
271
|
+
mini = ed25519DeriveHard(mini, j.chainCode);
|
|
272
|
+
}
|
|
273
|
+
return u8aToHex(mini);
|
|
274
|
+
}
|
|
264
275
|
function formatArgons(microgons) {
|
|
265
276
|
if (microgons === void 0 || microgons === null) return "na";
|
|
266
277
|
const isNegative = microgons < 0;
|
|
@@ -404,7 +415,7 @@ var JsonExt = class {
|
|
|
404
415
|
}
|
|
405
416
|
static parse(str) {
|
|
406
417
|
return JSON.parse(str, (_, v) => {
|
|
407
|
-
if (typeof v === "string" && v.match(
|
|
418
|
+
if (typeof v === "string" && v.match(/^-?\d+n$/)) {
|
|
408
419
|
return BigInt(v.slice(0, -1));
|
|
409
420
|
}
|
|
410
421
|
if (typeof v === "object" && v !== null && v.type === "Buffer" && Array.isArray(v.data)) {
|
|
@@ -812,7 +823,7 @@ var AccountMiners = class _AccountMiners {
|
|
|
812
823
|
};
|
|
813
824
|
|
|
814
825
|
// src/Accountset.ts
|
|
815
|
-
import { u8aToHex } from "@polkadot/util";
|
|
826
|
+
import { u8aToHex as u8aToHex2 } from "@polkadot/util";
|
|
816
827
|
var Accountset = class {
|
|
817
828
|
txSubmitterPair;
|
|
818
829
|
isProxy = false;
|
|
@@ -826,7 +837,7 @@ var Accountset = class {
|
|
|
826
837
|
get namedAccounts() {
|
|
827
838
|
return this.accountRegistry.namedAccounts;
|
|
828
839
|
}
|
|
829
|
-
|
|
840
|
+
sessionKeySeed;
|
|
830
841
|
constructor(options) {
|
|
831
842
|
if ("seedAccount" in options) {
|
|
832
843
|
this.txSubmitterPair = options.seedAccount;
|
|
@@ -837,7 +848,7 @@ var Accountset = class {
|
|
|
837
848
|
this.txSubmitterPair = options.txSubmitter;
|
|
838
849
|
this.seedAddress = options.seedAddress;
|
|
839
850
|
}
|
|
840
|
-
this.
|
|
851
|
+
this.sessionKeySeed = options.sessionKeySeedOrMnemonic;
|
|
841
852
|
this.accountRegistry = options.accountRegistry ?? AccountRegistry.factory(options.name);
|
|
842
853
|
this.client = options.client;
|
|
843
854
|
const defaultRange = options.subaccountRange ?? getDefaultSubaccountRange();
|
|
@@ -918,7 +929,6 @@ var Accountset = class {
|
|
|
918
929
|
];
|
|
919
930
|
const bidAmountsByFrame = {};
|
|
920
931
|
if (frameIds.length) {
|
|
921
|
-
console.log("Looking up cohorts for frames", frameIds);
|
|
922
932
|
const cohorts = await api.query.miningSlot.minersByCohort.multi(frameIds);
|
|
923
933
|
for (let i = 0; i < frameIds.length; i++) {
|
|
924
934
|
const cohort = cohorts[i];
|
|
@@ -1076,12 +1086,12 @@ var Accountset = class {
|
|
|
1076
1086
|
keys(keysVersion) {
|
|
1077
1087
|
const config2 = getConfig();
|
|
1078
1088
|
let version = keysVersion ?? config2.keysVersion ?? 0;
|
|
1079
|
-
const
|
|
1080
|
-
if (!
|
|
1089
|
+
const seed = this.sessionKeySeed ?? config2.keySeedOrMnemonic;
|
|
1090
|
+
if (!seed) {
|
|
1081
1091
|
throw new Error("KEYS_MNEMONIC environment variable not set. Cannot derive keys.");
|
|
1082
1092
|
}
|
|
1083
|
-
const blockSealKey = `${
|
|
1084
|
-
const granKey = `${
|
|
1093
|
+
const blockSealKey = `${seed}//block-seal//${version}`;
|
|
1094
|
+
const granKey = `${seed}//grandpa//${version}`;
|
|
1085
1095
|
const blockSealAccount = new Keyring().createFromUri(blockSealKey, {
|
|
1086
1096
|
type: "ed25519"
|
|
1087
1097
|
});
|
|
@@ -1091,12 +1101,12 @@ var Accountset = class {
|
|
|
1091
1101
|
return {
|
|
1092
1102
|
seal: {
|
|
1093
1103
|
privateKey: blockSealKey,
|
|
1094
|
-
publicKey:
|
|
1104
|
+
publicKey: u8aToHex2(blockSealAccount.publicKey),
|
|
1095
1105
|
rawPublicKey: blockSealAccount.publicKey
|
|
1096
1106
|
},
|
|
1097
1107
|
gran: {
|
|
1098
1108
|
privateKey: granKey,
|
|
1099
|
-
publicKey:
|
|
1109
|
+
publicKey: u8aToHex2(grandpaAccount.publicKey),
|
|
1100
1110
|
rawPublicKey: grandpaAccount.publicKey
|
|
1101
1111
|
}
|
|
1102
1112
|
};
|
|
@@ -1775,7 +1785,7 @@ var CohortBidder = class {
|
|
|
1775
1785
|
} else {
|
|
1776
1786
|
blockNumber = await client.query.system.number().then((x) => x.toNumber());
|
|
1777
1787
|
}
|
|
1778
|
-
const blockHash = await client.
|
|
1788
|
+
const blockHash = await client.rpc.chain.getBlockHash(blockNumber);
|
|
1779
1789
|
const api = await client.at(blockHash);
|
|
1780
1790
|
const rawBids = await api.query.miningSlot.bidsForNextSlotCohort();
|
|
1781
1791
|
const currentTick = await api.query.ticks.currentTick().then((x) => x.toNumber());
|
|
@@ -1964,6 +1974,7 @@ var CohortBidder = class {
|
|
|
1964
1974
|
}
|
|
1965
1975
|
}
|
|
1966
1976
|
scheduleEvaluation() {
|
|
1977
|
+
if (this.isStopped) return;
|
|
1967
1978
|
const millisPerTick = this.millisPerTick;
|
|
1968
1979
|
const delayTicks = Math.max(this.options.bidDelay, 1);
|
|
1969
1980
|
const delay = delayTicks * millisPerTick;
|
|
@@ -2356,7 +2367,7 @@ Raising Funds (Frame ${this.nextFrameId + 1}):`);
|
|
|
2356
2367
|
};
|
|
2357
2368
|
|
|
2358
2369
|
// src/BitcoinLocks.ts
|
|
2359
|
-
import { hexToU8a as hexToU8a2, u8aToHex as
|
|
2370
|
+
import { hexToU8a as hexToU8a2, u8aToHex as u8aToHex3 } from "@polkadot/util";
|
|
2360
2371
|
var SATS_PER_BTC = 100000000n;
|
|
2361
2372
|
var BitcoinLocks = class _BitcoinLocks {
|
|
2362
2373
|
constructor(client) {
|
|
@@ -2425,8 +2436,8 @@ var BitcoinLocks = class _BitcoinLocks {
|
|
|
2425
2436
|
return;
|
|
2426
2437
|
}
|
|
2427
2438
|
const ref = refRaw.unwrap();
|
|
2428
|
-
const txid =
|
|
2429
|
-
const bitcoinTxid =
|
|
2439
|
+
const txid = u8aToHex3(ref.txid);
|
|
2440
|
+
const bitcoinTxid = u8aToHex3(ref.txid.reverse());
|
|
2430
2441
|
const vout = ref.outputIndex.toNumber();
|
|
2431
2442
|
return { txid, vout, bitcoinTxid };
|
|
2432
2443
|
}
|
|
@@ -2457,7 +2468,7 @@ var BitcoinLocks = class _BitcoinLocks {
|
|
|
2457
2468
|
`Invalid vault signature length: ${vaultSignature.byteLength}. Must be 70-73 bytes.`
|
|
2458
2469
|
);
|
|
2459
2470
|
}
|
|
2460
|
-
const signature =
|
|
2471
|
+
const signature = u8aToHex3(vaultSignature);
|
|
2461
2472
|
const tx = client.tx.bitcoinLocks.cosignRelease(utxoId, signature);
|
|
2462
2473
|
const submitter = new TxSubmitter(client, tx, argonKeyring);
|
|
2463
2474
|
return await submitter.submit({ txProgressCallback });
|
|
@@ -2853,7 +2864,7 @@ function createKeyringPair(opts) {
|
|
|
2853
2864
|
}
|
|
2854
2865
|
|
|
2855
2866
|
// src/index.ts
|
|
2856
|
-
import { u8aToHex as
|
|
2867
|
+
import { u8aToHex as u8aToHex4, hexToU8a as hexToU8a3, u8aEq } from "@polkadot/util";
|
|
2857
2868
|
import { GenericEvent as GenericEvent2, GenericBlock, GenericAddress } from "@polkadot/types/generic";
|
|
2858
2869
|
import {
|
|
2859
2870
|
BTreeMap,
|
|
@@ -2899,6 +2910,7 @@ export {
|
|
|
2899
2910
|
TxSubmitter,
|
|
2900
2911
|
TxResult,
|
|
2901
2912
|
MICROGONS_PER_ARGON,
|
|
2913
|
+
miniSecretFromUri,
|
|
2902
2914
|
formatArgons,
|
|
2903
2915
|
formatPercent,
|
|
2904
2916
|
filterUndefined,
|
|
@@ -2938,7 +2950,7 @@ export {
|
|
|
2938
2950
|
mnemonicGenerate,
|
|
2939
2951
|
waitForLoad,
|
|
2940
2952
|
getClient,
|
|
2941
|
-
|
|
2953
|
+
u8aToHex4 as u8aToHex,
|
|
2942
2954
|
hexToU8a3 as hexToU8a,
|
|
2943
2955
|
u8aEq,
|
|
2944
2956
|
GenericEvent2 as GenericEvent,
|
|
@@ -2967,4 +2979,4 @@ export {
|
|
|
2967
2979
|
u64,
|
|
2968
2980
|
u8
|
|
2969
2981
|
};
|
|
2970
|
-
//# sourceMappingURL=chunk-
|
|
2982
|
+
//# sourceMappingURL=chunk-PXZPYJ4P.js.map
|