btc-wallet 0.3.14 → 0.3.15
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/config.d.ts +1 -0
- package/dist/core/btcUtils.d.ts +1 -0
- package/dist/index.js +30 -10
- package/dist/index.js.map +3 -3
- package/esm/index.js +30 -10
- package/esm/index.js.map +2 -2
- package/package.json +1 -1
package/dist/config.d.ts
CHANGED
package/dist/core/btcUtils.d.ts
CHANGED
@@ -9,6 +9,7 @@ export declare function getAccountInfo(csna: string, accountContractId: string):
|
|
9
9
|
gas_token: Record<string, string>;
|
10
10
|
debt_info: DebtInfo;
|
11
11
|
}>;
|
12
|
+
export declare function checkGasTokenBalance(csna: string, gasToken: string, isDev: boolean): Promise<void>;
|
12
13
|
type CheckGasTokenArrearsReturnType<T extends boolean> = T extends true ? void : {
|
13
14
|
receiver_id: string;
|
14
15
|
amount: string;
|
package/dist/index.js
CHANGED
@@ -91,6 +91,7 @@ __export(src_exports, {
|
|
91
91
|
WizzConnector: () => WizzConnector,
|
92
92
|
XverseConnector: () => XverseConnector,
|
93
93
|
checkGasTokenArrears: () => checkGasTokenArrears,
|
94
|
+
checkGasTokenBalance: () => checkGasTokenBalance,
|
94
95
|
estimateDepositAmount: () => estimateDepositAmount,
|
95
96
|
executeBTCDepositAndAction: () => executeBTCDepositAndAction,
|
96
97
|
getAccountInfo: () => getAccountInfo,
|
@@ -2729,21 +2730,24 @@ var walletConfig = {
|
|
2729
2730
|
token: "nbtc-dev.testnet",
|
2730
2731
|
accountContractId: "acc-dev.testnet",
|
2731
2732
|
bridgeContractId: "brg-dev.testnet",
|
2732
|
-
walletUrl: "https://wallet-dev.satoshibridge.top"
|
2733
|
+
walletUrl: "https://wallet-dev.satoshibridge.top",
|
2734
|
+
bridgeUrl: "https://dev.satoshibridge.top/"
|
2733
2735
|
},
|
2734
2736
|
testnet: {
|
2735
2737
|
base_url: "https://api.testnet.satoshibridge.top",
|
2736
2738
|
token: "nbtc2-nsp.testnet",
|
2737
|
-
accountContractId: "
|
2739
|
+
accountContractId: "acc2-nsp.testnet",
|
2738
2740
|
bridgeContractId: "brg2-nsp.testnet",
|
2739
|
-
walletUrl: "https://wallet-test.satoshibridge.top"
|
2741
|
+
walletUrl: "https://wallet-test.satoshibridge.top",
|
2742
|
+
bridgeUrl: "https://testnet.satoshibridge.top/"
|
2740
2743
|
},
|
2741
2744
|
mainnet: {
|
2742
2745
|
base_url: "https://api.mainnet.satoshibridge.top",
|
2743
|
-
token: "",
|
2744
|
-
accountContractId: "",
|
2745
|
-
bridgeContractId: "",
|
2746
|
-
walletUrl: "https://wallet.satoshibridge.top"
|
2746
|
+
token: "nbtc.toalice.near",
|
2747
|
+
accountContractId: "acc.toalice.near",
|
2748
|
+
bridgeContractId: "brg.toalice.near",
|
2749
|
+
walletUrl: "https://wallet.satoshibridge.top",
|
2750
|
+
bridgeUrl: "https://www.satoshibridge.top/"
|
2747
2751
|
}
|
2748
2752
|
};
|
2749
2753
|
var nearRpcUrls = {
|
@@ -3178,6 +3182,8 @@ Dialog.style = `
|
|
3178
3182
|
`;
|
3179
3183
|
|
3180
3184
|
// src/core/btcUtils.ts
|
3185
|
+
var MINIMUM_DEPOSIT_AMOUNT = 5e3;
|
3186
|
+
var MINIMUM_DEPOSIT_AMOUNT_BASE = 1e3;
|
3181
3187
|
function getBtcProvider() {
|
3182
3188
|
if (typeof window === "undefined" || !window.btcContext) {
|
3183
3189
|
throw new Error("BTC Provider is not initialized.");
|
@@ -3215,6 +3221,21 @@ function getAccountInfo(csna, accountContractId) {
|
|
3215
3221
|
return accountInfo;
|
3216
3222
|
});
|
3217
3223
|
}
|
3224
|
+
function checkGasTokenBalance(csna, gasToken, isDev) {
|
3225
|
+
return __async(this, null, function* () {
|
3226
|
+
const amount = yield nearCall(gasToken, "ft_balance_of", { account_id: csna });
|
3227
|
+
console.log("gas token balance:", amount);
|
3228
|
+
if (new import_big.default(amount).lte(MINIMUM_DEPOSIT_AMOUNT_BASE)) {
|
3229
|
+
yield Dialog.confirm({
|
3230
|
+
title: "Gas token balance is insufficient",
|
3231
|
+
message: "Please deposit gas token to continue, will open bridge website."
|
3232
|
+
});
|
3233
|
+
const config = yield getConfig(isDev);
|
3234
|
+
window.open(config.bridgeUrl, "_blank");
|
3235
|
+
throw new Error("Gas token balance is insufficient");
|
3236
|
+
}
|
3237
|
+
});
|
3238
|
+
}
|
3218
3239
|
function checkGasTokenArrears(debtInfo, isDev, autoDeposit) {
|
3219
3240
|
return __async(this, null, function* () {
|
3220
3241
|
if (!debtInfo)
|
@@ -3291,8 +3312,6 @@ function sendBitcoin(address, amount, feeRate) {
|
|
3291
3312
|
return txHash;
|
3292
3313
|
});
|
3293
3314
|
}
|
3294
|
-
var MINIMUM_DEPOSIT_AMOUNT = 5e3;
|
3295
|
-
var MINIMUM_DEPOSIT_AMOUNT_BASE = 1e3;
|
3296
3315
|
function estimateDepositAmount(amount, option) {
|
3297
3316
|
return __async(this, null, function* () {
|
3298
3317
|
const { receiveAmount } = yield getDepositAmount(amount, __spreadProps(__spreadValues({}, option), { isEstimate: true }));
|
@@ -3624,6 +3643,7 @@ var BTCWallet = (_0) => __async(void 0, [_0], function* ({
|
|
3624
3643
|
const btcContext = window.btcContext;
|
3625
3644
|
const accountId = state.getAccount();
|
3626
3645
|
const accountInfo = yield getAccountInfo(accountId, currentConfig.accountContractId);
|
3646
|
+
yield checkGasTokenBalance(accountId, currentConfig.token, isDev);
|
3627
3647
|
yield checkGasTokenArrears(accountInfo.debt_info, isDev, true);
|
3628
3648
|
const trans = [...params.transactions];
|
3629
3649
|
console.log("raw trans:", trans);
|
@@ -3883,7 +3903,7 @@ function setupBTCWallet({
|
|
3883
3903
|
|
3884
3904
|
// src/index.ts
|
3885
3905
|
var getVersion = () => {
|
3886
|
-
return "0.3.
|
3906
|
+
return "0.3.15";
|
3887
3907
|
};
|
3888
3908
|
if (typeof window !== "undefined") {
|
3889
3909
|
window.__PARTICLE_BTC_CONNECT_VERSION = getVersion();
|