btc-wallet 0.3.27 → 0.3.29
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/README.md +29 -1
- package/dist/core/btcUtils.d.ts +3 -1
- package/dist/index.js +22 -15
- package/dist/index.js.map +2 -2
- package/esm/index.js +22 -15
- package/esm/index.js.map +2 -2
- package/package.json +1 -1
package/esm/index.js
CHANGED
@@ -3184,6 +3184,9 @@ Dialog.style = `
|
|
3184
3184
|
// src/core/btcUtils.ts
|
3185
3185
|
var MINIMUM_DEPOSIT_AMOUNT = 5e3;
|
3186
3186
|
var MINIMUM_DEPOSIT_AMOUNT_BASE = 1e3;
|
3187
|
+
var NEAR_STORAGE_DEPOSIT_AMOUNT = "1250000000000000000000";
|
3188
|
+
var NBTC_STORAGE_DEPOSIT_AMOUNT = 3e3;
|
3189
|
+
var GAS_LIMIT = "50000000000000";
|
3187
3190
|
function getBtcProvider() {
|
3188
3191
|
if (typeof window === "undefined" || !window.btcContext) {
|
3189
3192
|
throw new Error("BTC Provider is not initialized.");
|
@@ -3370,6 +3373,7 @@ function executeBTCDepositAndAction(_0) {
|
|
3370
3373
|
feeRate,
|
3371
3374
|
fixedAmount = true,
|
3372
3375
|
pollResult = true,
|
3376
|
+
registerDeposit,
|
3373
3377
|
env = "mainnet"
|
3374
3378
|
}) {
|
3375
3379
|
var _a;
|
@@ -3393,47 +3397,50 @@ function executeBTCDepositAndAction(_0) {
|
|
3393
3397
|
});
|
3394
3398
|
const accountInfo = yield getAccountInfo(csna, config.accountContractId);
|
3395
3399
|
const newActions = [];
|
3396
|
-
const gasLimit = new Big(50).mul(__pow(10, 12)).toFixed(0);
|
3397
3400
|
const repayAction = yield checkGasTokenArrears(accountInfo == null ? void 0 : accountInfo.debt_info, env, false);
|
3398
3401
|
if (repayAction) {
|
3399
3402
|
newActions.push(__spreadProps(__spreadValues({}, repayAction), {
|
3400
|
-
gas:
|
3403
|
+
gas: GAS_LIMIT
|
3401
3404
|
}));
|
3402
3405
|
}
|
3403
3406
|
if (action || !action && new Big((accountInfo == null ? void 0 : accountInfo.gas_token[config.token]) || 0).lt(MINIMUM_DEPOSIT_AMOUNT_BASE)) {
|
3404
3407
|
newActions.push(
|
3405
3408
|
action ? __spreadProps(__spreadValues({}, action), {
|
3406
3409
|
amount: (repayAction == null ? void 0 : repayAction.amount) && !fixedAmount ? new Big(receiveAmount).minus(repayAction.amount).toString() : receiveAmount.toString(),
|
3407
|
-
gas:
|
3410
|
+
gas: GAS_LIMIT
|
3408
3411
|
}) : {
|
3409
3412
|
receiver_id: config.accountContractId,
|
3410
3413
|
amount: MINIMUM_DEPOSIT_AMOUNT_BASE.toString(),
|
3411
3414
|
msg: JSON.stringify("Deposit"),
|
3412
|
-
gas:
|
3415
|
+
gas: GAS_LIMIT
|
3413
3416
|
}
|
3414
3417
|
);
|
3415
3418
|
}
|
3416
|
-
const depositMsg = {
|
3417
|
-
recipient_id: csna,
|
3418
|
-
post_actions: newActions.length > 0 ? newActions : void 0
|
3419
|
-
};
|
3420
3419
|
const storageDepositMsg = {};
|
3421
|
-
if (!(accountInfo == null ? void 0 : accountInfo.nonce)) {
|
3422
|
-
storageDepositMsg.btc_public_key = btcPublicKey;
|
3423
|
-
}
|
3424
3420
|
const registerRes = yield nearCall((action == null ? void 0 : action.receiver_id) || config.token, "storage_balance_of", {
|
3425
3421
|
account_id: csna
|
3426
3422
|
});
|
3427
3423
|
if (!(registerRes == null ? void 0 : registerRes.available)) {
|
3428
3424
|
storageDepositMsg.storage_deposit_msg = {
|
3429
3425
|
contract_id: (action == null ? void 0 : action.receiver_id) || config.token,
|
3430
|
-
deposit:
|
3426
|
+
deposit: registerDeposit || NEAR_STORAGE_DEPOSIT_AMOUNT,
|
3431
3427
|
registration_only: true
|
3432
3428
|
};
|
3433
3429
|
}
|
3434
|
-
if (
|
3435
|
-
|
3430
|
+
if (!(accountInfo == null ? void 0 : accountInfo.nonce)) {
|
3431
|
+
storageDepositMsg.btc_public_key = btcPublicKey;
|
3432
|
+
newActions.push({
|
3433
|
+
receiver_id: config.accountContractId,
|
3434
|
+
amount: NBTC_STORAGE_DEPOSIT_AMOUNT.toString(),
|
3435
|
+
msg: JSON.stringify("RelayerFee"),
|
3436
|
+
gas: GAS_LIMIT
|
3437
|
+
});
|
3436
3438
|
}
|
3439
|
+
const depositMsg = {
|
3440
|
+
recipient_id: csna,
|
3441
|
+
post_actions: newActions.length > 0 ? newActions : void 0,
|
3442
|
+
extra_msg: Object.keys(storageDepositMsg).length > 0 ? JSON.stringify(storageDepositMsg) : void 0
|
3443
|
+
};
|
3437
3444
|
console.log("get_user_deposit_address params:", { deposit_msg: depositMsg });
|
3438
3445
|
const userDepositAddress = yield nearCall(
|
3439
3446
|
config.bridgeContractId,
|
@@ -3948,7 +3955,7 @@ function setupBTCWallet({
|
|
3948
3955
|
|
3949
3956
|
// src/index.ts
|
3950
3957
|
var getVersion = () => {
|
3951
|
-
return "0.3.
|
3958
|
+
return "0.3.29";
|
3952
3959
|
};
|
3953
3960
|
if (typeof window !== "undefined") {
|
3954
3961
|
window.__BTC_WALLET_VERSION = getVersion();
|