@argonprotocol/mainchain 1.3.10 → 1.3.12
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 +11 -5
- package/browser/index.js +20 -14
- package/browser/index.js.map +1 -1
- package/lib/index.cjs +20 -14
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +11 -5
- package/lib/index.d.ts +11 -5
- package/lib/index.js +20 -14
- package/lib/index.js.map +1 -1
- package/package.json +2 -2
package/lib/index.d.cts
CHANGED
|
@@ -10865,10 +10865,12 @@ declare module '@polkadot/types/lookup' {
|
|
|
10865
10865
|
readonly frameId: Compact<u64>;
|
|
10866
10866
|
readonly bitcoinLockFeeRevenue: Compact<u128>;
|
|
10867
10867
|
readonly bitcoinLocksCreated: Compact<u32>;
|
|
10868
|
-
readonly
|
|
10869
|
-
readonly
|
|
10870
|
-
readonly
|
|
10868
|
+
readonly bitcoinLocksNewLiquidityPromised: Compact<u128>;
|
|
10869
|
+
readonly bitcoinLocksReleasedLiquidity: Compact<u128>;
|
|
10870
|
+
readonly bitcoinLocksAddedSatoshis: Compact<u64>;
|
|
10871
|
+
readonly bitcoinLocksReleasedSatoshis: Compact<u64>;
|
|
10871
10872
|
readonly securitizationActivated: Compact<u128>;
|
|
10873
|
+
readonly securitizationRelockable: Compact<u128>;
|
|
10872
10874
|
readonly securitization: Compact<u128>;
|
|
10873
10875
|
readonly treasuryVaultEarnings: Compact<u128>;
|
|
10874
10876
|
readonly treasuryTotalEarnings: Compact<u128>;
|
|
@@ -11477,10 +11479,11 @@ declare class ExtrinsicError extends Error {
|
|
|
11477
11479
|
readonly errorCode: string;
|
|
11478
11480
|
readonly details?: string | undefined;
|
|
11479
11481
|
readonly batchInterruptedIndex?: number | undefined;
|
|
11480
|
-
|
|
11482
|
+
readonly txFee: bigint;
|
|
11483
|
+
constructor(errorCode: string, details?: string | undefined, batchInterruptedIndex?: number | undefined, txFee?: bigint);
|
|
11481
11484
|
toString(): string;
|
|
11482
11485
|
}
|
|
11483
|
-
declare function dispatchErrorToExtrinsicError(client: ArgonClient, error: DispatchError$1, batchInterruptedIndex?: number): ExtrinsicError;
|
|
11486
|
+
declare function dispatchErrorToExtrinsicError(client: ArgonClient, error: DispatchError$1, batchInterruptedIndex?: number, txFee?: bigint): ExtrinsicError;
|
|
11484
11487
|
/**
|
|
11485
11488
|
* Check for an extrinsic success event in the given events. Helpful to validate the result of an extrinsic inclusion in a block (it will be included even if it fails)
|
|
11486
11489
|
* @param events The events to check
|
|
@@ -11628,6 +11631,9 @@ declare class BitcoinLocks {
|
|
|
11628
11631
|
tx: _polkadot_api_types.SubmittableExtrinsic<"promise", _polkadot_types_types_extrinsic.ISubmittableResult>;
|
|
11629
11632
|
securityFee: bigint;
|
|
11630
11633
|
txFee: bigint;
|
|
11634
|
+
canAfford: boolean;
|
|
11635
|
+
availableBalance: bigint;
|
|
11636
|
+
txFeePlusTip: bigint;
|
|
11631
11637
|
}>;
|
|
11632
11638
|
getBitcoinLockFromTxResult(txResult: TxResult): Promise<{
|
|
11633
11639
|
lock: IBitcoinLock;
|
package/lib/index.d.ts
CHANGED
|
@@ -10865,10 +10865,12 @@ declare module '@polkadot/types/lookup' {
|
|
|
10865
10865
|
readonly frameId: Compact<u64>;
|
|
10866
10866
|
readonly bitcoinLockFeeRevenue: Compact<u128>;
|
|
10867
10867
|
readonly bitcoinLocksCreated: Compact<u32>;
|
|
10868
|
-
readonly
|
|
10869
|
-
readonly
|
|
10870
|
-
readonly
|
|
10868
|
+
readonly bitcoinLocksNewLiquidityPromised: Compact<u128>;
|
|
10869
|
+
readonly bitcoinLocksReleasedLiquidity: Compact<u128>;
|
|
10870
|
+
readonly bitcoinLocksAddedSatoshis: Compact<u64>;
|
|
10871
|
+
readonly bitcoinLocksReleasedSatoshis: Compact<u64>;
|
|
10871
10872
|
readonly securitizationActivated: Compact<u128>;
|
|
10873
|
+
readonly securitizationRelockable: Compact<u128>;
|
|
10872
10874
|
readonly securitization: Compact<u128>;
|
|
10873
10875
|
readonly treasuryVaultEarnings: Compact<u128>;
|
|
10874
10876
|
readonly treasuryTotalEarnings: Compact<u128>;
|
|
@@ -11477,10 +11479,11 @@ declare class ExtrinsicError extends Error {
|
|
|
11477
11479
|
readonly errorCode: string;
|
|
11478
11480
|
readonly details?: string | undefined;
|
|
11479
11481
|
readonly batchInterruptedIndex?: number | undefined;
|
|
11480
|
-
|
|
11482
|
+
readonly txFee: bigint;
|
|
11483
|
+
constructor(errorCode: string, details?: string | undefined, batchInterruptedIndex?: number | undefined, txFee?: bigint);
|
|
11481
11484
|
toString(): string;
|
|
11482
11485
|
}
|
|
11483
|
-
declare function dispatchErrorToExtrinsicError(client: ArgonClient, error: DispatchError$1, batchInterruptedIndex?: number): ExtrinsicError;
|
|
11486
|
+
declare function dispatchErrorToExtrinsicError(client: ArgonClient, error: DispatchError$1, batchInterruptedIndex?: number, txFee?: bigint): ExtrinsicError;
|
|
11484
11487
|
/**
|
|
11485
11488
|
* Check for an extrinsic success event in the given events. Helpful to validate the result of an extrinsic inclusion in a block (it will be included even if it fails)
|
|
11486
11489
|
* @param events The events to check
|
|
@@ -11628,6 +11631,9 @@ declare class BitcoinLocks {
|
|
|
11628
11631
|
tx: _polkadot_api_types.SubmittableExtrinsic<"promise", _polkadot_types_types_extrinsic.ISubmittableResult>;
|
|
11629
11632
|
securityFee: bigint;
|
|
11630
11633
|
txFee: bigint;
|
|
11634
|
+
canAfford: boolean;
|
|
11635
|
+
availableBalance: bigint;
|
|
11636
|
+
txFeePlusTip: bigint;
|
|
11631
11637
|
}>;
|
|
11632
11638
|
getBitcoinLockFromTxResult(txResult: TxResult): Promise<{
|
|
11633
11639
|
lock: IBitcoinLock;
|
package/lib/index.js
CHANGED
|
@@ -208,7 +208,12 @@ var TxResult = class {
|
|
|
208
208
|
}
|
|
209
209
|
}
|
|
210
210
|
if (encounteredError) {
|
|
211
|
-
const error = dispatchErrorToExtrinsicError(
|
|
211
|
+
const error = dispatchErrorToExtrinsicError(
|
|
212
|
+
this.client,
|
|
213
|
+
encounteredError,
|
|
214
|
+
batchErrorIndex,
|
|
215
|
+
this.finalFee
|
|
216
|
+
);
|
|
212
217
|
this.reject(error);
|
|
213
218
|
} else {
|
|
214
219
|
this.inBlockResolve(new Uint8Array(status.asInBlock));
|
|
@@ -281,11 +286,12 @@ function dispatchErrorToString(client, error) {
|
|
|
281
286
|
return message;
|
|
282
287
|
}
|
|
283
288
|
var ExtrinsicError2 = class extends Error {
|
|
284
|
-
constructor(errorCode, details, batchInterruptedIndex) {
|
|
289
|
+
constructor(errorCode, details, batchInterruptedIndex, txFee = 0n) {
|
|
285
290
|
super(errorCode);
|
|
286
291
|
this.errorCode = errorCode;
|
|
287
292
|
this.details = details;
|
|
288
293
|
this.batchInterruptedIndex = batchInterruptedIndex;
|
|
294
|
+
this.txFee = txFee;
|
|
289
295
|
}
|
|
290
296
|
toString() {
|
|
291
297
|
if (this.batchInterruptedIndex !== void 0) {
|
|
@@ -294,13 +300,13 @@ var ExtrinsicError2 = class extends Error {
|
|
|
294
300
|
return `${this.errorCode} ${this.details ?? ""}`;
|
|
295
301
|
}
|
|
296
302
|
};
|
|
297
|
-
function dispatchErrorToExtrinsicError(client, error, batchInterruptedIndex) {
|
|
303
|
+
function dispatchErrorToExtrinsicError(client, error, batchInterruptedIndex, txFee) {
|
|
298
304
|
if (error.isModule) {
|
|
299
305
|
const decoded = client.registry.findMetaError(error.asModule);
|
|
300
306
|
const { docs, name, section } = decoded;
|
|
301
|
-
return new ExtrinsicError2(`${section}.${name}`, docs.join(" "), batchInterruptedIndex);
|
|
307
|
+
return new ExtrinsicError2(`${section}.${name}`, docs.join(" "), batchInterruptedIndex, txFee);
|
|
302
308
|
}
|
|
303
|
-
return new ExtrinsicError2(error.toString(), void 0, batchInterruptedIndex);
|
|
309
|
+
return new ExtrinsicError2(error.toString(), void 0, batchInterruptedIndex, txFee);
|
|
304
310
|
}
|
|
305
311
|
function checkForExtrinsicSuccess(events, client) {
|
|
306
312
|
return new Promise((resolve, reject) => {
|
|
@@ -844,12 +850,7 @@ var BitcoinLocks = class {
|
|
|
844
850
|
unavailableBalance: securityFee + (args.reducedBalanceBy ?? 0n),
|
|
845
851
|
includeExistentialDeposit: true
|
|
846
852
|
});
|
|
847
|
-
|
|
848
|
-
throw new Error(
|
|
849
|
-
`Insufficient funds to initialize lock. Available: ${formatArgons(availableBalance)}, Required: ${satoshis}`
|
|
850
|
-
);
|
|
851
|
-
}
|
|
852
|
-
return { tx, securityFee, txFee };
|
|
853
|
+
return { tx, securityFee, txFee, canAfford, availableBalance, txFeePlusTip: txFee + tip };
|
|
853
854
|
}
|
|
854
855
|
async getBitcoinLockFromTxResult(txResult) {
|
|
855
856
|
const client = this.client;
|
|
@@ -868,7 +869,12 @@ var BitcoinLocks = class {
|
|
|
868
869
|
async initializeLock(args) {
|
|
869
870
|
const { argonKeyring, tip = 0n, txProgressCallback } = args;
|
|
870
871
|
const client = this.client;
|
|
871
|
-
const { tx, securityFee } = await this.createInitializeLockTx(args);
|
|
872
|
+
const { tx, securityFee, canAfford, txFeePlusTip } = await this.createInitializeLockTx(args);
|
|
873
|
+
if (!canAfford) {
|
|
874
|
+
throw new Error(
|
|
875
|
+
`Insufficient funds to initialize bitcoin lock. Required security fee: ${formatArgons(securityFee)}, Tx fee plus tip: ${formatArgons(txFeePlusTip)}`
|
|
876
|
+
);
|
|
877
|
+
}
|
|
872
878
|
const submitter = new TxSubmitter(client, tx, argonKeyring);
|
|
873
879
|
const txResult = await submitter.submit({
|
|
874
880
|
waitForBlock: true,
|
|
@@ -895,7 +901,7 @@ var BitcoinLocks = class {
|
|
|
895
901
|
priceIndex,
|
|
896
902
|
releaseRequest: { bitcoinNetworkFee, toScriptPubkey },
|
|
897
903
|
argonKeyring,
|
|
898
|
-
tip,
|
|
904
|
+
tip = 0n,
|
|
899
905
|
txProgressCallback
|
|
900
906
|
} = args;
|
|
901
907
|
if (!toScriptPubkey.startsWith("0x")) {
|
|
@@ -913,7 +919,7 @@ var BitcoinLocks = class {
|
|
|
913
919
|
});
|
|
914
920
|
if (!canAfford.canAfford) {
|
|
915
921
|
throw new Error(
|
|
916
|
-
`Insufficient funds to release lock. Available: ${formatArgons(canAfford.availableBalance)}, Required: ${formatArgons(redemptionPrice)}`
|
|
922
|
+
`Insufficient funds to release lock. Available: ${formatArgons(canAfford.availableBalance)}, Required: ${formatArgons(redemptionPrice + canAfford.txFee + tip)}`
|
|
917
923
|
);
|
|
918
924
|
}
|
|
919
925
|
const txResult = await submitter.submit({
|