btc-wallet 0.3.20 → 0.3.22
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/dist/core/btcUtils.d.ts +8 -5
- package/dist/index.js +11 -6
- package/dist/index.js.map +3 -3
- package/dist/utils/nearUtils.d.ts +2 -1
- package/esm/index.js +11 -6
- package/esm/index.js.map +3 -3
- package/package.json +1 -1
package/dist/core/btcUtils.d.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import type { FinalExecutionOutcome } from '@near-wallet-selector/core';
|
1
2
|
export interface DebtInfo {
|
2
3
|
gas_token_id: string;
|
3
4
|
transfer_amount: string;
|
@@ -40,19 +41,21 @@ export declare function getDepositAmount(amount: string, option?: {
|
|
40
41
|
receiveAmount: number;
|
41
42
|
fee: number;
|
42
43
|
}>;
|
43
|
-
interface ExecuteBTCDepositAndActionParams {
|
44
|
+
interface ExecuteBTCDepositAndActionParams<T extends boolean = true> {
|
44
45
|
action?: {
|
45
46
|
receiver_id: string;
|
46
47
|
amount: string;
|
47
48
|
msg: string;
|
48
49
|
};
|
49
50
|
amount?: string;
|
50
|
-
/** fee rate, if not provided, will use the recommended fee rate from the btc node */
|
51
51
|
feeRate?: number;
|
52
|
-
/** fixed amount, if true, in arrears mode, amount is fixed, otherwise it is depositAmount-repayAction.amount */
|
53
52
|
fixedAmount?: boolean;
|
54
|
-
/** is dev environment */
|
55
53
|
isDev?: boolean;
|
54
|
+
pollResult?: T;
|
56
55
|
}
|
57
|
-
|
56
|
+
/**
|
57
|
+
* @param T - if true, return the poll result, otherwise return the btcTxHash
|
58
|
+
*/
|
59
|
+
type ExecuteBTCDepositAndActionReturn<T extends boolean> = T extends true ? FinalExecutionOutcome[] : string;
|
60
|
+
export declare function executeBTCDepositAndAction<T extends boolean = true>({ action, amount, feeRate, fixedAmount, pollResult, isDev, }: ExecuteBTCDepositAndActionParams<T>): Promise<ExecuteBTCDepositAndActionReturn<T>>;
|
58
61
|
export {};
|
package/dist/index.js
CHANGED
@@ -2832,10 +2832,10 @@ function pollTransactionStatuses(network, hashes) {
|
|
2832
2832
|
currentAttempt++;
|
2833
2833
|
const promises = Array.from(pendingHashes).map((hash) => __async(this, null, function* () {
|
2834
2834
|
try {
|
2835
|
-
const
|
2836
|
-
if (
|
2837
|
-
console.log(`Transaction ${hash} result:`,
|
2838
|
-
results.set(hash,
|
2835
|
+
const result2 = yield provider.txStatus(hash, "unused", "FINAL");
|
2836
|
+
if (result2 && result2.status) {
|
2837
|
+
console.log(`Transaction ${hash} result:`, result2);
|
2838
|
+
results.set(hash, result2);
|
2839
2839
|
pendingHashes.delete(hash);
|
2840
2840
|
}
|
2841
2841
|
} catch (error) {
|
@@ -2855,7 +2855,8 @@ function pollTransactionStatuses(network, hashes) {
|
|
2855
2855
|
yield delay(1e4);
|
2856
2856
|
}
|
2857
2857
|
}
|
2858
|
-
|
2858
|
+
const result = hashes.map((hash) => results.get(hash)).filter(Boolean);
|
2859
|
+
return result;
|
2859
2860
|
});
|
2860
2861
|
}
|
2861
2862
|
|
@@ -3387,6 +3388,7 @@ function executeBTCDepositAndAction(_0) {
|
|
3387
3388
|
amount,
|
3388
3389
|
feeRate,
|
3389
3390
|
fixedAmount = true,
|
3391
|
+
pollResult = true,
|
3390
3392
|
isDev = false
|
3391
3393
|
}) {
|
3392
3394
|
var _a;
|
@@ -3470,6 +3472,9 @@ function executeBTCDepositAndAction(_0) {
|
|
3470
3472
|
postActions: postActionsStr,
|
3471
3473
|
extraMsg: depositMsg.extra_msg
|
3472
3474
|
});
|
3475
|
+
if (!pollResult) {
|
3476
|
+
return txHash;
|
3477
|
+
}
|
3473
3478
|
const checkTransactionStatusRes = yield checkBridgeTransactionStatus(config.base_url, txHash);
|
3474
3479
|
console.log("checkBridgeTransactionStatus resp:", checkTransactionStatusRes);
|
3475
3480
|
const network = yield getNetwork();
|
@@ -3967,7 +3972,7 @@ function setupBTCWallet({
|
|
3967
3972
|
|
3968
3973
|
// src/index.ts
|
3969
3974
|
var getVersion = () => {
|
3970
|
-
return "0.3.
|
3975
|
+
return "0.3.22";
|
3971
3976
|
};
|
3972
3977
|
if (typeof window !== "undefined") {
|
3973
3978
|
window.__BTC_WALLET_VERSION = getVersion();
|