@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
package/browser/index.d.ts
CHANGED
|
@@ -11399,6 +11399,7 @@ declare class AccountRegistry {
|
|
|
11399
11399
|
}
|
|
11400
11400
|
|
|
11401
11401
|
declare const MICROGONS_PER_ARGON = 1000000;
|
|
11402
|
+
declare function miniSecretFromUri(uri: string, password?: string): string;
|
|
11402
11403
|
declare function formatArgons(microgons: bigint | number): string;
|
|
11403
11404
|
declare function formatPercent(x: BigNumber | undefined): string;
|
|
11404
11405
|
type NonNullableProps<T> = {
|
|
@@ -11600,12 +11601,12 @@ declare class Accountset {
|
|
|
11600
11601
|
readonly client: Promise<ArgonClient>;
|
|
11601
11602
|
get addresses(): string[];
|
|
11602
11603
|
get namedAccounts(): IAddressNames;
|
|
11603
|
-
private readonly
|
|
11604
|
+
private readonly sessionKeySeed;
|
|
11604
11605
|
constructor(options: {
|
|
11605
11606
|
client: Promise<ArgonClient>;
|
|
11606
11607
|
accountRegistry?: AccountRegistry;
|
|
11607
11608
|
subaccountRange?: SubaccountRange;
|
|
11608
|
-
|
|
11609
|
+
sessionKeySeedOrMnemonic?: string;
|
|
11609
11610
|
name?: string;
|
|
11610
11611
|
} & ({
|
|
11611
11612
|
seedAccount: KeyringPair;
|
|
@@ -12169,7 +12170,7 @@ declare function createKeyringPair(opts: {
|
|
|
12169
12170
|
interface ArgonClientConfig {
|
|
12170
12171
|
debug?: boolean;
|
|
12171
12172
|
keysVersion?: number;
|
|
12172
|
-
|
|
12173
|
+
keySeedOrMnemonic?: string;
|
|
12173
12174
|
subaccountRange?: string;
|
|
12174
12175
|
}
|
|
12175
12176
|
declare function setConfig(newConfig: ArgonClientConfig): void;
|
|
@@ -12187,4 +12188,4 @@ declare function waitForLoad(): Promise<void>;
|
|
|
12187
12188
|
*/
|
|
12188
12189
|
declare function getClient(host: string): Promise<ArgonClient>;
|
|
12189
12190
|
|
|
12190
|
-
export { AccountMiners, AccountRegistry, Accountset, type ArgonClient, type ArgonClientConfig, BidPool, BitcoinLocks, BlockWatch, CohortBidder, ExtrinsicError, FrameCalculator, type IBitcoinLock, type IBitcoinLockConfig, type IMiningIndex, type IReleaseRequest, type IReleaseRequestDetails, type ISubaccountMiner, type ITxProgressCallback, JsonExt, MICROGONS_PER_ARGON, MiningBids, SATS_PER_BTC, TxResult, TxSubmitter, TypedEmitter, Vault, VaultMonitor, WageProtector, checkForExtrinsicSuccess, convertFixedU128ToBigNumber, convertNumberToFixedU128, convertNumberToPermill, convertPermillToBigNumber, createKeyringPair, createNanoEvents, dispatchErrorToExtrinsicError, dispatchErrorToString, eventDataToJson, filterUndefined, formatArgons, formatPercent, getAuthorFromHeader, getClient, getConfig, getTickFromHeader, gettersToObject, keyringFromSuri, setConfig, toFixedNumber, waitForLoad };
|
|
12191
|
+
export { AccountMiners, AccountRegistry, Accountset, type ArgonClient, type ArgonClientConfig, BidPool, BitcoinLocks, BlockWatch, CohortBidder, ExtrinsicError, FrameCalculator, type IBitcoinLock, type IBitcoinLockConfig, type IMiningIndex, type IReleaseRequest, type IReleaseRequestDetails, type ISubaccountMiner, type ITxProgressCallback, JsonExt, MICROGONS_PER_ARGON, MiningBids, SATS_PER_BTC, TxResult, TxSubmitter, TypedEmitter, Vault, VaultMonitor, WageProtector, checkForExtrinsicSuccess, convertFixedU128ToBigNumber, convertNumberToFixedU128, convertNumberToPermill, convertPermillToBigNumber, createKeyringPair, createNanoEvents, dispatchErrorToExtrinsicError, dispatchErrorToString, eventDataToJson, filterUndefined, formatArgons, formatPercent, getAuthorFromHeader, getClient, getConfig, getTickFromHeader, gettersToObject, keyringFromSuri, miniSecretFromUri, setConfig, toFixedNumber, waitForLoad };
|
package/browser/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import '@polkadot/types/types/registry';
|
|
|
9
9
|
export * from '@polkadot/types/lookup';
|
|
10
10
|
import { Keyring, HttpProvider, WsProvider, ApiPromise } from '@polkadot/api';
|
|
11
11
|
export { Keyring } from '@polkadot/api';
|
|
12
|
-
import { mnemonicGenerate, cryptoWaitReady } from '@polkadot/util-crypto';
|
|
12
|
+
import { keyExtractSuri, mnemonicToMiniSecret, ed25519DeriveHard, mnemonicGenerate, cryptoWaitReady } from '@polkadot/util-crypto';
|
|
13
13
|
export { decodeAddress, mnemonicGenerate } from '@polkadot/util-crypto';
|
|
14
14
|
import * as BigNumber from 'bignumber.js';
|
|
15
15
|
import BigNumber__default from 'bignumber.js';
|
|
@@ -94,7 +94,7 @@ function getConfig() {
|
|
|
94
94
|
return {
|
|
95
95
|
debug: config.debug ?? getEnvVar("DEBUG") === "true",
|
|
96
96
|
keysVersion: config.keysVersion ?? (getEnvVar("KEYS_VERSION") ? parseInt(getEnvVar("KEYS_VERSION")) : void 0),
|
|
97
|
-
|
|
97
|
+
keySeedOrMnemonic: config.keySeedOrMnemonic ?? getEnvVar("KEYS_MNEMONIC"),
|
|
98
98
|
subaccountRange: config.subaccountRange ?? getEnvVar("SUBACCOUNT_RANGE") ?? "0-9"
|
|
99
99
|
};
|
|
100
100
|
}
|
|
@@ -256,6 +256,15 @@ var TxResult = class {
|
|
|
256
256
|
};
|
|
257
257
|
var { ROUND_FLOOR } = BigNumber;
|
|
258
258
|
var MICROGONS_PER_ARGON = 1e6;
|
|
259
|
+
function miniSecretFromUri(uri, password) {
|
|
260
|
+
const { phrase, path } = keyExtractSuri(uri);
|
|
261
|
+
let mini = mnemonicToMiniSecret(phrase, password);
|
|
262
|
+
for (const j of path) {
|
|
263
|
+
if (!j.isHard) throw new Error("ed25519 soft derivation not supported");
|
|
264
|
+
mini = ed25519DeriveHard(mini, j.chainCode);
|
|
265
|
+
}
|
|
266
|
+
return u8aToHex(mini);
|
|
267
|
+
}
|
|
259
268
|
function formatArgons(microgons) {
|
|
260
269
|
if (microgons === void 0 || microgons === null) return "na";
|
|
261
270
|
const isNegative = microgons < 0;
|
|
@@ -399,7 +408,7 @@ var JsonExt = class {
|
|
|
399
408
|
}
|
|
400
409
|
static parse(str) {
|
|
401
410
|
return JSON.parse(str, (_, v) => {
|
|
402
|
-
if (typeof v === "string" && v.match(
|
|
411
|
+
if (typeof v === "string" && v.match(/^-?\d+n$/)) {
|
|
403
412
|
return BigInt(v.slice(0, -1));
|
|
404
413
|
}
|
|
405
414
|
if (typeof v === "object" && v !== null && v.type === "Buffer" && Array.isArray(v.data)) {
|
|
@@ -821,7 +830,7 @@ var Accountset = class {
|
|
|
821
830
|
__publicField(this, "subAccountsByAddress", {});
|
|
822
831
|
__publicField(this, "accountRegistry");
|
|
823
832
|
__publicField(this, "client");
|
|
824
|
-
__publicField(this, "
|
|
833
|
+
__publicField(this, "sessionKeySeed");
|
|
825
834
|
if ("seedAccount" in options) {
|
|
826
835
|
this.txSubmitterPair = options.seedAccount;
|
|
827
836
|
this.seedAddress = options.seedAccount.address;
|
|
@@ -831,7 +840,7 @@ var Accountset = class {
|
|
|
831
840
|
this.txSubmitterPair = options.txSubmitter;
|
|
832
841
|
this.seedAddress = options.seedAddress;
|
|
833
842
|
}
|
|
834
|
-
this.
|
|
843
|
+
this.sessionKeySeed = options.sessionKeySeedOrMnemonic;
|
|
835
844
|
this.accountRegistry = options.accountRegistry ?? AccountRegistry.factory(options.name);
|
|
836
845
|
this.client = options.client;
|
|
837
846
|
const defaultRange = options.subaccountRange ?? getDefaultSubaccountRange();
|
|
@@ -918,7 +927,6 @@ var Accountset = class {
|
|
|
918
927
|
];
|
|
919
928
|
const bidAmountsByFrame = {};
|
|
920
929
|
if (frameIds.length) {
|
|
921
|
-
console.log("Looking up cohorts for frames", frameIds);
|
|
922
930
|
const cohorts = await api.query.miningSlot.minersByCohort.multi(frameIds);
|
|
923
931
|
for (let i = 0; i < frameIds.length; i++) {
|
|
924
932
|
const cohort = cohorts[i];
|
|
@@ -1076,12 +1084,12 @@ var Accountset = class {
|
|
|
1076
1084
|
keys(keysVersion) {
|
|
1077
1085
|
const config2 = getConfig();
|
|
1078
1086
|
let version = keysVersion ?? config2.keysVersion ?? 0;
|
|
1079
|
-
const
|
|
1080
|
-
if (!
|
|
1087
|
+
const seed = this.sessionKeySeed ?? config2.keySeedOrMnemonic;
|
|
1088
|
+
if (!seed) {
|
|
1081
1089
|
throw new Error("KEYS_MNEMONIC environment variable not set. Cannot derive keys.");
|
|
1082
1090
|
}
|
|
1083
|
-
const blockSealKey = `${
|
|
1084
|
-
const granKey = `${
|
|
1091
|
+
const blockSealKey = `${seed}//block-seal//${version}`;
|
|
1092
|
+
const granKey = `${seed}//grandpa//${version}`;
|
|
1085
1093
|
const blockSealAccount = new Keyring().createFromUri(blockSealKey, {
|
|
1086
1094
|
type: "ed25519"
|
|
1087
1095
|
});
|
|
@@ -1765,7 +1773,7 @@ var CohortBidder = class {
|
|
|
1765
1773
|
} else {
|
|
1766
1774
|
blockNumber = await client.query.system.number().then((x) => x.toNumber());
|
|
1767
1775
|
}
|
|
1768
|
-
const blockHash = await client.
|
|
1776
|
+
const blockHash = await client.rpc.chain.getBlockHash(blockNumber);
|
|
1769
1777
|
const api = await client.at(blockHash);
|
|
1770
1778
|
const rawBids = await api.query.miningSlot.bidsForNextSlotCohort();
|
|
1771
1779
|
const currentTick = await api.query.ticks.currentTick().then((x) => x.toNumber());
|
|
@@ -1954,6 +1962,7 @@ var CohortBidder = class {
|
|
|
1954
1962
|
}
|
|
1955
1963
|
}
|
|
1956
1964
|
scheduleEvaluation() {
|
|
1965
|
+
if (this.isStopped) return;
|
|
1957
1966
|
const millisPerTick = this.millisPerTick;
|
|
1958
1967
|
const delayTicks = Math.max(this.options.bidDelay, 1);
|
|
1959
1968
|
const delay = delayTicks * millisPerTick;
|
|
@@ -2849,6 +2858,6 @@ async function getClient(host) {
|
|
|
2849
2858
|
return await ApiPromise.create({ provider, noInitWarn: true });
|
|
2850
2859
|
}
|
|
2851
2860
|
|
|
2852
|
-
export { AccountMiners, AccountRegistry, Accountset, BidPool, BitcoinLocks, BlockWatch, CohortBidder, ExtrinsicError2 as ExtrinsicError, FrameCalculator, JsonExt, MICROGONS_PER_ARGON, MiningBids, SATS_PER_BTC, TxResult, TxSubmitter, TypedEmitter, Vault, VaultMonitor, WageProtector, checkForExtrinsicSuccess, convertFixedU128ToBigNumber, convertNumberToFixedU128, convertNumberToPermill, convertPermillToBigNumber, createKeyringPair, createNanoEvents, dispatchErrorToExtrinsicError, dispatchErrorToString, eventDataToJson, filterUndefined, formatArgons, formatPercent, getAuthorFromHeader, getClient, getConfig, getTickFromHeader, gettersToObject, keyringFromSuri, setConfig, toFixedNumber, waitForLoad };
|
|
2861
|
+
export { AccountMiners, AccountRegistry, Accountset, BidPool, BitcoinLocks, BlockWatch, CohortBidder, ExtrinsicError2 as ExtrinsicError, FrameCalculator, JsonExt, MICROGONS_PER_ARGON, MiningBids, SATS_PER_BTC, TxResult, TxSubmitter, TypedEmitter, Vault, VaultMonitor, WageProtector, checkForExtrinsicSuccess, convertFixedU128ToBigNumber, convertNumberToFixedU128, convertNumberToPermill, convertPermillToBigNumber, createKeyringPair, createNanoEvents, dispatchErrorToExtrinsicError, dispatchErrorToString, eventDataToJson, filterUndefined, formatArgons, formatPercent, getAuthorFromHeader, getClient, getConfig, getTickFromHeader, gettersToObject, keyringFromSuri, miniSecretFromUri, setConfig, toFixedNumber, waitForLoad };
|
|
2853
2862
|
//# sourceMappingURL=index.js.map
|
|
2854
2863
|
//# sourceMappingURL=index.js.map
|