btc-wallet 0.5.79-beta → 0.5.81-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 +30 -38
- package/dist/index.js.map +2 -2
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/satoshi.d.ts +3 -7
- package/esm/index.js +30 -38
- package/esm/index.js.map +2 -2
- package/package.json +1 -1
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/satoshi.d.ts
CHANGED
@@ -22,14 +22,10 @@ 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
|
25
|
+
export declare function hasBridgeTransaction({ env, btcAccount }: {
|
26
26
|
env: ENV;
|
27
|
-
|
28
|
-
|
29
|
-
fromAddress?: string;
|
30
|
-
page?: number;
|
31
|
-
pageSize?: number;
|
32
|
-
}): Promise<any[]>;
|
27
|
+
btcAccount: string;
|
28
|
+
}): Promise<boolean>;
|
33
29
|
export declare function checkBridgeTransactionStatus({ txHash, fromChain, env, }: {
|
34
30
|
txHash: string;
|
35
31
|
fromChain?: 'BTC' | 'NEAR';
|
package/esm/index.js
CHANGED
@@ -2988,12 +2988,7 @@ function getWalletConfig(env) {
|
|
2988
2988
|
});
|
2989
2989
|
}
|
2990
2990
|
var nearRpcUrls = {
|
2991
|
-
mainnet: [
|
2992
|
-
"https://near.lava.build",
|
2993
|
-
"https://rpc.mainnet.near.org",
|
2994
|
-
"https://free.rpc.fastnear.com",
|
2995
|
-
"https://near.drpc.org"
|
2996
|
-
],
|
2991
|
+
mainnet: ["https://near.lava.build", "https://free.rpc.fastnear.com"],
|
2997
2992
|
testnet: ["https://rpc.testnet.near.org"]
|
2998
2993
|
};
|
2999
2994
|
var btcRpcUrls = {
|
@@ -3351,23 +3346,17 @@ function receiveDepositMsg(_0) {
|
|
3351
3346
|
return result_data;
|
3352
3347
|
});
|
3353
3348
|
}
|
3354
|
-
function
|
3355
|
-
return __async(this, arguments, function* ({
|
3356
|
-
env,
|
3357
|
-
fromChainId = 0,
|
3358
|
-
fromAddress,
|
3359
|
-
page = 1,
|
3360
|
-
pageSize = 10
|
3361
|
-
}) {
|
3349
|
+
function hasBridgeTransaction(_0) {
|
3350
|
+
return __async(this, arguments, function* ({ env, btcAccount }) {
|
3362
3351
|
try {
|
3363
3352
|
const config = getWalletConfig(env);
|
3364
3353
|
const { result_data = [] } = yield request(
|
3365
|
-
`${config.base_url}/v1/history?fromChainId
|
3354
|
+
`${config.base_url}/v1/history?fromChainId=0&fromAddress=${btcAccount}&page=1&pageSize=1`
|
3366
3355
|
);
|
3367
|
-
return result_data;
|
3356
|
+
return (result_data == null ? void 0 : result_data.length) > 0;
|
3368
3357
|
} catch (error) {
|
3369
|
-
console.error("
|
3370
|
-
return
|
3358
|
+
console.error("hasBridgeTransaction error:", error);
|
3359
|
+
return false;
|
3371
3360
|
}
|
3372
3361
|
});
|
3373
3362
|
}
|
@@ -3772,10 +3761,10 @@ var NEAR_STORAGE_DEPOSIT_AMOUNT = "1250000000000000000000";
|
|
3772
3761
|
var NBTC_STORAGE_DEPOSIT_AMOUNT = 800;
|
3773
3762
|
var NEW_ACCOUNT_MIN_DEPOSIT_AMOUNT = 1e3;
|
3774
3763
|
function getBtcProvider() {
|
3775
|
-
if (typeof window === "undefined" || !
|
3764
|
+
if (typeof window === "undefined" || !window.btcContext) {
|
3776
3765
|
throw new Error("BTC Provider is not initialized.");
|
3777
3766
|
}
|
3778
|
-
return window.btcContext
|
3767
|
+
return window.btcContext;
|
3779
3768
|
}
|
3780
3769
|
function getNetwork() {
|
3781
3770
|
return __async(this, null, function* () {
|
@@ -3803,18 +3792,20 @@ function nearCall(contractId, methodName, args) {
|
|
3803
3792
|
return nearCallFunction(contractId, methodName, args, { network });
|
3804
3793
|
});
|
3805
3794
|
}
|
3806
|
-
function checkGasTokenDebt(
|
3807
|
-
return __async(this,
|
3795
|
+
function checkGasTokenDebt(_0) {
|
3796
|
+
return __async(this, arguments, function* ({
|
3797
|
+
csna,
|
3798
|
+
btcAccount,
|
3799
|
+
env,
|
3800
|
+
autoDeposit
|
3801
|
+
}) {
|
3808
3802
|
var _a, _b, _c;
|
3809
3803
|
const accountInfo = yield getAccountInfo({ csna, env });
|
3810
|
-
const
|
3811
|
-
const bridgeTransactions = yield getBridgeTransactions({
|
3804
|
+
const bridgeTransactions = yield hasBridgeTransaction({
|
3812
3805
|
env,
|
3813
|
-
|
3814
|
-
page: 1,
|
3815
|
-
pageSize: 1
|
3806
|
+
btcAccount
|
3816
3807
|
});
|
3817
|
-
const isNewAccount = !(accountInfo == null ? void 0 : accountInfo.nonce) && bridgeTransactions
|
3808
|
+
const isNewAccount = !(accountInfo == null ? void 0 : accountInfo.nonce) && !bridgeTransactions;
|
3818
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();
|
3819
3810
|
const relayerFeeAmount = isNewAccount ? NBTC_STORAGE_DEPOSIT_AMOUNT : ((_c = accountInfo == null ? void 0 : accountInfo.relayer_fee) == null ? void 0 : _c.amount) || 0;
|
3820
3811
|
const hasDebtArrears = new Big2(debtAmount).gt(0);
|
@@ -3932,8 +3923,9 @@ function getDepositAmount(amount, option) {
|
|
3932
3923
|
const env = (option == null ? void 0 : option.env) || "mainnet";
|
3933
3924
|
const _newAccountMinDepositAmount = (_a = option == null ? void 0 : option.newAccountMinDepositAmount) != null ? _a : true;
|
3934
3925
|
const csna = (option == null ? void 0 : option.csna) || (yield getCsnaAccountId(env));
|
3926
|
+
const btcAccount = (option == null ? void 0 : option.btcAccount) || getBtcProvider().account;
|
3935
3927
|
const accountInfo = yield getAccountInfo({ csna, env });
|
3936
|
-
const debtAction = yield checkGasTokenDebt(csna, env, false);
|
3928
|
+
const debtAction = yield checkGasTokenDebt({ csna, btcAccount, env, autoDeposit: false });
|
3937
3929
|
const repayAmount = (debtAction == null ? void 0 : debtAction.amount) || 0;
|
3938
3930
|
const depositAmount = Number(amount);
|
3939
3931
|
const {
|
@@ -4010,7 +4002,7 @@ function executeBTCDepositAndAction(_0) {
|
|
4010
4002
|
registerContractId
|
4011
4003
|
});
|
4012
4004
|
checkDepositDisabledAddress();
|
4013
|
-
const { getPublicKey } = getBtcProvider();
|
4005
|
+
const { getPublicKey, account: btcAccount } = getBtcProvider();
|
4014
4006
|
const config = getWalletConfig(env);
|
4015
4007
|
const btcPublicKey = yield getPublicKey();
|
4016
4008
|
if (!btcPublicKey) {
|
@@ -4039,7 +4031,7 @@ function executeBTCDepositAndAction(_0) {
|
|
4039
4031
|
}
|
4040
4032
|
const accountInfo = yield getAccountInfo({ csna, env });
|
4041
4033
|
const newActions = [];
|
4042
|
-
const debtAction = yield checkGasTokenDebt(csna, env, false);
|
4034
|
+
const debtAction = yield checkGasTokenDebt({ csna, btcAccount, env, autoDeposit: false });
|
4043
4035
|
if (debtAction) {
|
4044
4036
|
newActions.push(__spreadProps(__spreadValues({}, debtAction), {
|
4045
4037
|
gas: "30000000000000"
|
@@ -4080,11 +4072,11 @@ function executeBTCDepositAndAction(_0) {
|
|
4080
4072
|
const _feeRate = feeRate || (yield getBtcGasPrice());
|
4081
4073
|
console.table({
|
4082
4074
|
"User Deposit Address": userDepositAddress,
|
4083
|
-
"Deposit Amount": depositAmount,
|
4084
|
-
"Protocol Fee": protocolFee,
|
4085
|
-
"Repay Amount": repayAmount,
|
4086
|
-
"Receive Amount": receiveAmount,
|
4087
|
-
"Fee Rate": _feeRate
|
4075
|
+
"Deposit Amount": Number(depositAmount),
|
4076
|
+
"Protocol Fee": Number(protocolFee),
|
4077
|
+
"Repay Amount": Number(repayAmount),
|
4078
|
+
"Receive Amount": Number(receiveAmount),
|
4079
|
+
"Fee Rate": Number(_feeRate)
|
4088
4080
|
});
|
4089
4081
|
const postActionsStr = newActions.length > 0 ? JSON.stringify(newActions) : void 0;
|
4090
4082
|
yield preReceiveDepositMsg({
|
@@ -5084,7 +5076,7 @@ var BTCWallet = (_0) => __async(void 0, [_0], function* ({
|
|
5084
5076
|
const btcContext = window.btcContext;
|
5085
5077
|
const csna = state_default.getAccount();
|
5086
5078
|
const accountInfo = yield getAccountInfo({ csna, env });
|
5087
|
-
yield checkGasTokenDebt(csna, env, true);
|
5079
|
+
yield checkGasTokenDebt({ csna, env, btcAccount: btcContext.account, autoDeposit: true });
|
5088
5080
|
const trans = [...params.transactions];
|
5089
5081
|
console.log("signAndSendTransactions raw trans:", trans);
|
5090
5082
|
const { transferGasTransaction, useNearPayGas, gasLimit } = yield calculateGasStrategy({
|
@@ -5328,7 +5320,7 @@ function getGroup(state) {
|
|
5328
5320
|
|
5329
5321
|
// src/index.ts
|
5330
5322
|
var getVersion = () => {
|
5331
|
-
return "0.5.
|
5323
|
+
return "0.5.81-beta";
|
5332
5324
|
};
|
5333
5325
|
if (typeof window !== "undefined") {
|
5334
5326
|
window.__BTC_WALLET_VERSION = getVersion();
|