btc-wallet 0.5.80-beta → 0.5.82-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 +7 -1
- package/dist/index.js +18 -38
- package/dist/index.js.map +2 -2
- package/dist/utils/satoshi.d.ts +2 -1
- package/esm/index.js +18 -38
- package/esm/index.js.map +2 -2
- package/package.json +1 -1
package/dist/utils/satoshi.d.ts
CHANGED
@@ -22,8 +22,9 @@ interface ReceiveDepositMsgParams {
|
|
22
22
|
}
|
23
23
|
export declare function preReceiveDepositMsg({ env, btcPublicKey, depositType, postActions, extraMsg, userDepositAddress, }: Omit<ReceiveDepositMsgParams, 'txHash'>): Promise<any>;
|
24
24
|
export declare function receiveDepositMsg({ env, btcPublicKey, txHash, depositType, postActions, extraMsg, }: ReceiveDepositMsgParams): Promise<any>;
|
25
|
-
export declare function hasBridgeTransaction({ env }: {
|
25
|
+
export declare function hasBridgeTransaction({ env, btcAccount }: {
|
26
26
|
env: ENV;
|
27
|
+
btcAccount: string;
|
27
28
|
}): Promise<boolean>;
|
28
29
|
export declare function checkBridgeTransactionStatus({ txHash, fromChain, env, }: {
|
29
30
|
txHash: string;
|
package/esm/index.js
CHANGED
@@ -209,26 +209,6 @@ function storageStore(namespace, options) {
|
|
209
209
|
}
|
210
210
|
};
|
211
211
|
}
|
212
|
-
var getUrlQuery = (url) => {
|
213
|
-
var _a;
|
214
|
-
try {
|
215
|
-
const search = url ? (_a = url.split("?")[1]) == null ? void 0 : _a.split("#")[0] : window.location.search.substring(1).split("#")[0];
|
216
|
-
const urlSearchParams = new URLSearchParams(search);
|
217
|
-
const entries = urlSearchParams.entries();
|
218
|
-
const query = {};
|
219
|
-
for (const [key, value] of entries) {
|
220
|
-
if (query[key]) {
|
221
|
-
query[key] = Array.isArray(query[key]) ? [...query[key], value] : [query[key], value];
|
222
|
-
} else {
|
223
|
-
query[key] = value;
|
224
|
-
}
|
225
|
-
}
|
226
|
-
return query;
|
227
|
-
} catch (error) {
|
228
|
-
console.error("getUrlQuery", error);
|
229
|
-
return {};
|
230
|
-
}
|
231
|
-
};
|
232
212
|
|
233
213
|
// src/utils/Dialog.ts
|
234
214
|
var Dialog = class {
|
@@ -3008,12 +2988,7 @@ function getWalletConfig(env) {
|
|
3008
2988
|
});
|
3009
2989
|
}
|
3010
2990
|
var nearRpcUrls = {
|
3011
|
-
mainnet: [
|
3012
|
-
"https://near.lava.build",
|
3013
|
-
"https://rpc.mainnet.near.org",
|
3014
|
-
"https://free.rpc.fastnear.com",
|
3015
|
-
"https://near.drpc.org"
|
3016
|
-
],
|
2991
|
+
mainnet: ["https://near.lava.build", "https://free.rpc.fastnear.com"],
|
3017
2992
|
testnet: ["https://rpc.testnet.near.org"]
|
3018
2993
|
};
|
3019
2994
|
var btcRpcUrls = {
|
@@ -3372,11 +3347,9 @@ function receiveDepositMsg(_0) {
|
|
3372
3347
|
});
|
3373
3348
|
}
|
3374
3349
|
function hasBridgeTransaction(_0) {
|
3375
|
-
return __async(this, arguments, function* ({ env }) {
|
3376
|
-
var _a, _b;
|
3350
|
+
return __async(this, arguments, function* ({ env, btcAccount }) {
|
3377
3351
|
try {
|
3378
3352
|
const config = getWalletConfig(env);
|
3379
|
-
const btcAccount = ((_a = window.btcContext) == null ? void 0 : _a.account) || ((_b = getUrlQuery()) == null ? void 0 : _b.originalAccountId);
|
3380
3353
|
const { result_data = [] } = yield request(
|
3381
3354
|
`${config.base_url}/v1/history?fromChainId=0&fromAddress=${btcAccount}&page=1&pageSize=1`
|
3382
3355
|
);
|
@@ -3785,7 +3758,7 @@ import coinselect from "coinselect";
|
|
3785
3758
|
import * as ecc from "@bitcoinerlab/secp256k1";
|
3786
3759
|
bitcoin.initEccLib(ecc);
|
3787
3760
|
var NEAR_STORAGE_DEPOSIT_AMOUNT = "1250000000000000000000";
|
3788
|
-
var NBTC_STORAGE_DEPOSIT_AMOUNT =
|
3761
|
+
var NBTC_STORAGE_DEPOSIT_AMOUNT = 2e3;
|
3789
3762
|
var NEW_ACCOUNT_MIN_DEPOSIT_AMOUNT = 1e3;
|
3790
3763
|
function getBtcProvider() {
|
3791
3764
|
if (typeof window === "undefined" || !window.btcContext) {
|
@@ -3819,12 +3792,18 @@ function nearCall(contractId, methodName, args) {
|
|
3819
3792
|
return nearCallFunction(contractId, methodName, args, { network });
|
3820
3793
|
});
|
3821
3794
|
}
|
3822
|
-
function checkGasTokenDebt(
|
3823
|
-
return __async(this,
|
3795
|
+
function checkGasTokenDebt(_0) {
|
3796
|
+
return __async(this, arguments, function* ({
|
3797
|
+
csna,
|
3798
|
+
btcAccount,
|
3799
|
+
env,
|
3800
|
+
autoDeposit
|
3801
|
+
}) {
|
3824
3802
|
var _a, _b, _c;
|
3825
3803
|
const accountInfo = yield getAccountInfo({ csna, env });
|
3826
3804
|
const bridgeTransactions = yield hasBridgeTransaction({
|
3827
|
-
env
|
3805
|
+
env,
|
3806
|
+
btcAccount
|
3828
3807
|
});
|
3829
3808
|
const isNewAccount = !(accountInfo == null ? void 0 : accountInfo.nonce) && !bridgeTransactions;
|
3830
3809
|
const debtAmount = new Big2(((_a = accountInfo == null ? void 0 : accountInfo.debt_info) == null ? void 0 : _a.near_gas_debt_amount) || 0).plus(((_b = accountInfo == null ? void 0 : accountInfo.debt_info) == null ? void 0 : _b.protocol_fee_debt_amount) || 0).toString();
|
@@ -3944,8 +3923,9 @@ function getDepositAmount(amount, option) {
|
|
3944
3923
|
const env = (option == null ? void 0 : option.env) || "mainnet";
|
3945
3924
|
const _newAccountMinDepositAmount = (_a = option == null ? void 0 : option.newAccountMinDepositAmount) != null ? _a : true;
|
3946
3925
|
const csna = (option == null ? void 0 : option.csna) || (yield getCsnaAccountId(env));
|
3926
|
+
const btcAccount = (option == null ? void 0 : option.btcAccount) || getBtcProvider().account;
|
3947
3927
|
const accountInfo = yield getAccountInfo({ csna, env });
|
3948
|
-
const debtAction = yield checkGasTokenDebt(csna, env, false);
|
3928
|
+
const debtAction = yield checkGasTokenDebt({ csna, btcAccount, env, autoDeposit: false });
|
3949
3929
|
const repayAmount = (debtAction == null ? void 0 : debtAction.amount) || 0;
|
3950
3930
|
const depositAmount = Number(amount);
|
3951
3931
|
const {
|
@@ -4022,7 +4002,7 @@ function executeBTCDepositAndAction(_0) {
|
|
4022
4002
|
registerContractId
|
4023
4003
|
});
|
4024
4004
|
checkDepositDisabledAddress();
|
4025
|
-
const { getPublicKey } = getBtcProvider();
|
4005
|
+
const { getPublicKey, account: btcAccount } = getBtcProvider();
|
4026
4006
|
const config = getWalletConfig(env);
|
4027
4007
|
const btcPublicKey = yield getPublicKey();
|
4028
4008
|
if (!btcPublicKey) {
|
@@ -4051,7 +4031,7 @@ function executeBTCDepositAndAction(_0) {
|
|
4051
4031
|
}
|
4052
4032
|
const accountInfo = yield getAccountInfo({ csna, env });
|
4053
4033
|
const newActions = [];
|
4054
|
-
const debtAction = yield checkGasTokenDebt(csna, env, false);
|
4034
|
+
const debtAction = yield checkGasTokenDebt({ csna, btcAccount, env, autoDeposit: false });
|
4055
4035
|
if (debtAction) {
|
4056
4036
|
newActions.push(__spreadProps(__spreadValues({}, debtAction), {
|
4057
4037
|
gas: "30000000000000"
|
@@ -5096,7 +5076,7 @@ var BTCWallet = (_0) => __async(void 0, [_0], function* ({
|
|
5096
5076
|
const btcContext = window.btcContext;
|
5097
5077
|
const csna = state_default.getAccount();
|
5098
5078
|
const accountInfo = yield getAccountInfo({ csna, env });
|
5099
|
-
yield checkGasTokenDebt(csna, env, true);
|
5079
|
+
yield checkGasTokenDebt({ csna, env, btcAccount: btcContext.account, autoDeposit: true });
|
5100
5080
|
const trans = [...params.transactions];
|
5101
5081
|
console.log("signAndSendTransactions raw trans:", trans);
|
5102
5082
|
const { transferGasTransaction, useNearPayGas, gasLimit } = yield calculateGasStrategy({
|
@@ -5340,7 +5320,7 @@ function getGroup(state) {
|
|
5340
5320
|
|
5341
5321
|
// src/index.ts
|
5342
5322
|
var getVersion = () => {
|
5343
|
-
return "0.5.
|
5323
|
+
return "0.5.82-beta";
|
5344
5324
|
};
|
5345
5325
|
if (typeof window !== "undefined") {
|
5346
5326
|
window.__BTC_WALLET_VERSION = getVersion();
|