btc-wallet 0.3.19 → 0.3.21
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 -5
- package/dist/index.js.map +2 -2
- package/dist/utils/nearUtils.d.ts +2 -1
- package/esm/index.js +11 -5
- package/esm/index.js.map +2 -2
- 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
@@ -3387,6 +3387,7 @@ function executeBTCDepositAndAction(_0) {
|
|
3387
3387
|
amount,
|
3388
3388
|
feeRate,
|
3389
3389
|
fixedAmount = true,
|
3390
|
+
pollResult = true,
|
3390
3391
|
isDev = false
|
3391
3392
|
}) {
|
3392
3393
|
var _a;
|
@@ -3470,6 +3471,9 @@ function executeBTCDepositAndAction(_0) {
|
|
3470
3471
|
postActions: postActionsStr,
|
3471
3472
|
extraMsg: depositMsg.extra_msg
|
3472
3473
|
});
|
3474
|
+
if (!pollResult) {
|
3475
|
+
return txHash;
|
3476
|
+
}
|
3473
3477
|
const checkTransactionStatusRes = yield checkBridgeTransactionStatus(config.base_url, txHash);
|
3474
3478
|
console.log("checkBridgeTransactionStatus resp:", checkTransactionStatusRes);
|
3475
3479
|
const network = yield getNetwork();
|
@@ -3917,10 +3921,12 @@ var BTCWallet = (_0) => __async(void 0, [_0], function* ({
|
|
3917
3921
|
return;
|
3918
3922
|
const btcNetwork = yield btcContext.getNetwork();
|
3919
3923
|
console.log("btcNetwork:", btcNetwork, network);
|
3920
|
-
|
3921
|
-
|
3922
|
-
|
3923
|
-
|
3924
|
+
const networkMap = {
|
3925
|
+
livenet: ["mainnet"],
|
3926
|
+
testnet: ["testnet", "dev"]
|
3927
|
+
};
|
3928
|
+
if (!networkMap[btcNetwork].includes(network)) {
|
3929
|
+
yield btcContext.switchNetwork(btcNetwork === "livenet" ? "testnet" : "livenet");
|
3924
3930
|
}
|
3925
3931
|
});
|
3926
3932
|
}
|
@@ -3965,7 +3971,7 @@ function setupBTCWallet({
|
|
3965
3971
|
|
3966
3972
|
// src/index.ts
|
3967
3973
|
var getVersion = () => {
|
3968
|
-
return "0.3.
|
3974
|
+
return "0.3.21";
|
3969
3975
|
};
|
3970
3976
|
if (typeof window !== "undefined") {
|
3971
3977
|
window.__BTC_WALLET_VERSION = getVersion();
|