btc-wallet 0.4.1-beta → 0.4.3-beta
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 +1 -1
- package/dist/index.js +10 -3
- package/dist/index.js.map +2 -2
- package/esm/index.js +10 -3
- package/esm/index.js.map +2 -2
- package/package.json +1 -1
package/dist/core/btcUtils.d.ts
CHANGED
@@ -13,7 +13,7 @@ export interface DebtInfo {
|
|
13
13
|
near_gas_debt_amount: string;
|
14
14
|
protocol_fee_debt_amount: string;
|
15
15
|
}
|
16
|
-
export declare function getAccountInfo(csna: string, accountContractId: string): Promise<AccountInfo>;
|
16
|
+
export declare function getAccountInfo(csna: string, accountContractId: string): Promise<AccountInfo | undefined>;
|
17
17
|
export declare function checkGasTokenBalance(csna: string, gasToken: string, minAmount: string, env: ENV): Promise<void>;
|
18
18
|
type CheckGasTokenArrearsReturnType<T extends boolean> = T extends true ? void : {
|
19
19
|
receiver_id: string;
|
package/dist/index.js
CHANGED
@@ -3306,6 +3306,8 @@ function getAccountInfo(csna, accountContractId) {
|
|
3306
3306
|
return __async(this, null, function* () {
|
3307
3307
|
const accountInfo = yield nearCall(accountContractId, "get_account", {
|
3308
3308
|
account_id: csna
|
3309
|
+
}).catch((error) => {
|
3310
|
+
return void 0;
|
3309
3311
|
});
|
3310
3312
|
console.log("get_account accountInfo:", accountInfo);
|
3311
3313
|
return accountInfo;
|
@@ -3418,8 +3420,11 @@ function sendBitcoin(address, amount, feeRate) {
|
|
3418
3420
|
}
|
3419
3421
|
function estimateDepositAmount(amount, option) {
|
3420
3422
|
return __async(this, null, function* () {
|
3423
|
+
const config = yield getConfig((option == null ? void 0 : option.env) || "mainnet");
|
3424
|
+
const csna = yield getCsnaAccountId((option == null ? void 0 : option.env) || "mainnet");
|
3425
|
+
const accountInfo = yield getAccountInfo(csna, config.accountContractId);
|
3421
3426
|
const { receiveAmount } = yield getDepositAmount(amount, __spreadProps(__spreadValues({}, option), { isEstimate: true }));
|
3422
|
-
return receiveAmount;
|
3427
|
+
return (accountInfo == null ? void 0 : accountInfo.nonce) ? receiveAmount : new import_big.default(receiveAmount).minus(NBTC_STORAGE_DEPOSIT_AMOUNT).round(0, import_big.default.roundDown).toNumber();
|
3423
3428
|
});
|
3424
3429
|
}
|
3425
3430
|
function getDepositAmount(amount, option) {
|
@@ -3921,8 +3926,10 @@ var BTCWallet = (_0) => __async(void 0, [_0], function* ({
|
|
3921
3926
|
near_transactions: transactions2
|
3922
3927
|
});
|
3923
3928
|
const predictedGasAmount = new import_big2.default(predictedGas).mul(1.2).toFixed(0);
|
3929
|
+
const miniGasAmount = 200 * transactions2.length;
|
3930
|
+
const gasAmount = Math.max(Number(predictedGasAmount), miniGasAmount);
|
3924
3931
|
console.log("predictedGas:", predictedGasAmount);
|
3925
|
-
return
|
3932
|
+
return gasAmount.toString();
|
3926
3933
|
});
|
3927
3934
|
}
|
3928
3935
|
function calculateGasStrategy(gasTokenBalance, transactions2) {
|
@@ -4054,7 +4061,7 @@ function setupBTCWallet({
|
|
4054
4061
|
|
4055
4062
|
// src/index.ts
|
4056
4063
|
var getVersion = () => {
|
4057
|
-
return "0.4.
|
4064
|
+
return "0.4.3-beta";
|
4058
4065
|
};
|
4059
4066
|
if (typeof window !== "undefined") {
|
4060
4067
|
window.__BTC_WALLET_VERSION = getVersion();
|