btc-wallet 0.5.79-beta → 0.5.80-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/index.js +39 -27
- package/dist/index.js.map +2 -2
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/satoshi.d.ts +2 -7
- package/esm/index.js +39 -27
- 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,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
|
25
|
+
export declare function hasBridgeTransaction({ env }: {
|
26
26
|
env: ENV;
|
27
|
-
|
28
|
-
fromChainId?: number;
|
29
|
-
fromAddress?: string;
|
30
|
-
page?: number;
|
31
|
-
pageSize?: number;
|
32
|
-
}): Promise<any[]>;
|
27
|
+
}): Promise<boolean>;
|
33
28
|
export declare function checkBridgeTransactionStatus({ txHash, fromChain, env, }: {
|
34
29
|
txHash: string;
|
35
30
|
fromChain?: 'BTC' | 'NEAR';
|
package/esm/index.js
CHANGED
@@ -209,6 +209,26 @@ 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
|
+
};
|
212
232
|
|
213
233
|
// src/utils/Dialog.ts
|
214
234
|
var Dialog = class {
|
@@ -3351,23 +3371,19 @@ function receiveDepositMsg(_0) {
|
|
3351
3371
|
return result_data;
|
3352
3372
|
});
|
3353
3373
|
}
|
3354
|
-
function
|
3355
|
-
return __async(this, arguments, function* ({
|
3356
|
-
|
3357
|
-
fromChainId = 0,
|
3358
|
-
fromAddress,
|
3359
|
-
page = 1,
|
3360
|
-
pageSize = 10
|
3361
|
-
}) {
|
3374
|
+
function hasBridgeTransaction(_0) {
|
3375
|
+
return __async(this, arguments, function* ({ env }) {
|
3376
|
+
var _a, _b;
|
3362
3377
|
try {
|
3363
3378
|
const config = getWalletConfig(env);
|
3379
|
+
const btcAccount = ((_a = window.btcContext) == null ? void 0 : _a.account) || ((_b = getUrlQuery()) == null ? void 0 : _b.originalAccountId);
|
3364
3380
|
const { result_data = [] } = yield request(
|
3365
|
-
`${config.base_url}/v1/history?fromChainId
|
3381
|
+
`${config.base_url}/v1/history?fromChainId=0&fromAddress=${btcAccount}&page=1&pageSize=1`
|
3366
3382
|
);
|
3367
|
-
return result_data;
|
3383
|
+
return (result_data == null ? void 0 : result_data.length) > 0;
|
3368
3384
|
} catch (error) {
|
3369
|
-
console.error("
|
3370
|
-
return
|
3385
|
+
console.error("hasBridgeTransaction error:", error);
|
3386
|
+
return false;
|
3371
3387
|
}
|
3372
3388
|
});
|
3373
3389
|
}
|
@@ -3772,10 +3788,10 @@ var NEAR_STORAGE_DEPOSIT_AMOUNT = "1250000000000000000000";
|
|
3772
3788
|
var NBTC_STORAGE_DEPOSIT_AMOUNT = 800;
|
3773
3789
|
var NEW_ACCOUNT_MIN_DEPOSIT_AMOUNT = 1e3;
|
3774
3790
|
function getBtcProvider() {
|
3775
|
-
if (typeof window === "undefined" || !
|
3791
|
+
if (typeof window === "undefined" || !window.btcContext) {
|
3776
3792
|
throw new Error("BTC Provider is not initialized.");
|
3777
3793
|
}
|
3778
|
-
return window.btcContext
|
3794
|
+
return window.btcContext;
|
3779
3795
|
}
|
3780
3796
|
function getNetwork() {
|
3781
3797
|
return __async(this, null, function* () {
|
@@ -3807,14 +3823,10 @@ function checkGasTokenDebt(csna, env, autoDeposit) {
|
|
3807
3823
|
return __async(this, null, function* () {
|
3808
3824
|
var _a, _b, _c;
|
3809
3825
|
const accountInfo = yield getAccountInfo({ csna, env });
|
3810
|
-
const
|
3811
|
-
|
3812
|
-
env,
|
3813
|
-
fromAddress: account,
|
3814
|
-
page: 1,
|
3815
|
-
pageSize: 1
|
3826
|
+
const bridgeTransactions = yield hasBridgeTransaction({
|
3827
|
+
env
|
3816
3828
|
});
|
3817
|
-
const isNewAccount = !(accountInfo == null ? void 0 : accountInfo.nonce) && bridgeTransactions
|
3829
|
+
const isNewAccount = !(accountInfo == null ? void 0 : accountInfo.nonce) && !bridgeTransactions;
|
3818
3830
|
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
3831
|
const relayerFeeAmount = isNewAccount ? NBTC_STORAGE_DEPOSIT_AMOUNT : ((_c = accountInfo == null ? void 0 : accountInfo.relayer_fee) == null ? void 0 : _c.amount) || 0;
|
3820
3832
|
const hasDebtArrears = new Big2(debtAmount).gt(0);
|
@@ -4080,11 +4092,11 @@ function executeBTCDepositAndAction(_0) {
|
|
4080
4092
|
const _feeRate = feeRate || (yield getBtcGasPrice());
|
4081
4093
|
console.table({
|
4082
4094
|
"User Deposit Address": userDepositAddress,
|
4083
|
-
"Deposit Amount": depositAmount,
|
4084
|
-
"Protocol Fee": protocolFee,
|
4085
|
-
"Repay Amount": repayAmount,
|
4086
|
-
"Receive Amount": receiveAmount,
|
4087
|
-
"Fee Rate": _feeRate
|
4095
|
+
"Deposit Amount": Number(depositAmount),
|
4096
|
+
"Protocol Fee": Number(protocolFee),
|
4097
|
+
"Repay Amount": Number(repayAmount),
|
4098
|
+
"Receive Amount": Number(receiveAmount),
|
4099
|
+
"Fee Rate": Number(_feeRate)
|
4088
4100
|
});
|
4089
4101
|
const postActionsStr = newActions.length > 0 ? JSON.stringify(newActions) : void 0;
|
4090
4102
|
yield preReceiveDepositMsg({
|
@@ -5328,7 +5340,7 @@ function getGroup(state) {
|
|
5328
5340
|
|
5329
5341
|
// src/index.ts
|
5330
5342
|
var getVersion = () => {
|
5331
|
-
return "0.5.
|
5343
|
+
return "0.5.80-beta";
|
5332
5344
|
};
|
5333
5345
|
if (typeof window !== "undefined") {
|
5334
5346
|
window.__BTC_WALLET_VERSION = getVersion();
|