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/index.js
CHANGED
@@ -281,6 +281,26 @@ function storageStore(namespace, options) {
|
|
281
281
|
}
|
282
282
|
};
|
283
283
|
}
|
284
|
+
var getUrlQuery = (url) => {
|
285
|
+
var _a;
|
286
|
+
try {
|
287
|
+
const search = url ? (_a = url.split("?")[1]) == null ? void 0 : _a.split("#")[0] : window.location.search.substring(1).split("#")[0];
|
288
|
+
const urlSearchParams = new URLSearchParams(search);
|
289
|
+
const entries = urlSearchParams.entries();
|
290
|
+
const query = {};
|
291
|
+
for (const [key, value] of entries) {
|
292
|
+
if (query[key]) {
|
293
|
+
query[key] = Array.isArray(query[key]) ? [...query[key], value] : [query[key], value];
|
294
|
+
} else {
|
295
|
+
query[key] = value;
|
296
|
+
}
|
297
|
+
}
|
298
|
+
return query;
|
299
|
+
} catch (error) {
|
300
|
+
console.error("getUrlQuery", error);
|
301
|
+
return {};
|
302
|
+
}
|
303
|
+
};
|
284
304
|
|
285
305
|
// src/utils/Dialog.ts
|
286
306
|
var Dialog = class {
|
@@ -3423,23 +3443,19 @@ function receiveDepositMsg(_0) {
|
|
3423
3443
|
return result_data;
|
3424
3444
|
});
|
3425
3445
|
}
|
3426
|
-
function
|
3427
|
-
return __async(this, arguments, function* ({
|
3428
|
-
|
3429
|
-
fromChainId = 0,
|
3430
|
-
fromAddress,
|
3431
|
-
page = 1,
|
3432
|
-
pageSize = 10
|
3433
|
-
}) {
|
3446
|
+
function hasBridgeTransaction(_0) {
|
3447
|
+
return __async(this, arguments, function* ({ env }) {
|
3448
|
+
var _a, _b;
|
3434
3449
|
try {
|
3435
3450
|
const config = getWalletConfig(env);
|
3451
|
+
const btcAccount = ((_a = window.btcContext) == null ? void 0 : _a.account) || ((_b = getUrlQuery()) == null ? void 0 : _b.originalAccountId);
|
3436
3452
|
const { result_data = [] } = yield request(
|
3437
|
-
`${config.base_url}/v1/history?fromChainId
|
3453
|
+
`${config.base_url}/v1/history?fromChainId=0&fromAddress=${btcAccount}&page=1&pageSize=1`
|
3438
3454
|
);
|
3439
|
-
return result_data;
|
3455
|
+
return (result_data == null ? void 0 : result_data.length) > 0;
|
3440
3456
|
} catch (error) {
|
3441
|
-
console.error("
|
3442
|
-
return
|
3457
|
+
console.error("hasBridgeTransaction error:", error);
|
3458
|
+
return false;
|
3443
3459
|
}
|
3444
3460
|
});
|
3445
3461
|
}
|
@@ -3844,10 +3860,10 @@ var NEAR_STORAGE_DEPOSIT_AMOUNT = "1250000000000000000000";
|
|
3844
3860
|
var NBTC_STORAGE_DEPOSIT_AMOUNT = 800;
|
3845
3861
|
var NEW_ACCOUNT_MIN_DEPOSIT_AMOUNT = 1e3;
|
3846
3862
|
function getBtcProvider() {
|
3847
|
-
if (typeof window === "undefined" || !
|
3863
|
+
if (typeof window === "undefined" || !window.btcContext) {
|
3848
3864
|
throw new Error("BTC Provider is not initialized.");
|
3849
3865
|
}
|
3850
|
-
return window.btcContext
|
3866
|
+
return window.btcContext;
|
3851
3867
|
}
|
3852
3868
|
function getNetwork() {
|
3853
3869
|
return __async(this, null, function* () {
|
@@ -3879,14 +3895,10 @@ function checkGasTokenDebt(csna, env, autoDeposit) {
|
|
3879
3895
|
return __async(this, null, function* () {
|
3880
3896
|
var _a, _b, _c;
|
3881
3897
|
const accountInfo = yield getAccountInfo({ csna, env });
|
3882
|
-
const
|
3883
|
-
|
3884
|
-
env,
|
3885
|
-
fromAddress: account,
|
3886
|
-
page: 1,
|
3887
|
-
pageSize: 1
|
3898
|
+
const bridgeTransactions = yield hasBridgeTransaction({
|
3899
|
+
env
|
3888
3900
|
});
|
3889
|
-
const isNewAccount = !(accountInfo == null ? void 0 : accountInfo.nonce) && bridgeTransactions
|
3901
|
+
const isNewAccount = !(accountInfo == null ? void 0 : accountInfo.nonce) && !bridgeTransactions;
|
3890
3902
|
const debtAmount = new import_big2.default(((_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();
|
3891
3903
|
const relayerFeeAmount = isNewAccount ? NBTC_STORAGE_DEPOSIT_AMOUNT : ((_c = accountInfo == null ? void 0 : accountInfo.relayer_fee) == null ? void 0 : _c.amount) || 0;
|
3892
3904
|
const hasDebtArrears = new import_big2.default(debtAmount).gt(0);
|
@@ -4152,11 +4164,11 @@ function executeBTCDepositAndAction(_0) {
|
|
4152
4164
|
const _feeRate = feeRate || (yield getBtcGasPrice());
|
4153
4165
|
console.table({
|
4154
4166
|
"User Deposit Address": userDepositAddress,
|
4155
|
-
"Deposit Amount": depositAmount,
|
4156
|
-
"Protocol Fee": protocolFee,
|
4157
|
-
"Repay Amount": repayAmount,
|
4158
|
-
"Receive Amount": receiveAmount,
|
4159
|
-
"Fee Rate": _feeRate
|
4167
|
+
"Deposit Amount": Number(depositAmount),
|
4168
|
+
"Protocol Fee": Number(protocolFee),
|
4169
|
+
"Repay Amount": Number(repayAmount),
|
4170
|
+
"Receive Amount": Number(receiveAmount),
|
4171
|
+
"Fee Rate": Number(_feeRate)
|
4160
4172
|
});
|
4161
4173
|
const postActionsStr = newActions.length > 0 ? JSON.stringify(newActions) : void 0;
|
4162
4174
|
yield preReceiveDepositMsg({
|
@@ -5398,7 +5410,7 @@ function getGroup(state) {
|
|
5398
5410
|
|
5399
5411
|
// src/index.ts
|
5400
5412
|
var getVersion = () => {
|
5401
|
-
return "0.5.
|
5413
|
+
return "0.5.80-beta";
|
5402
5414
|
};
|
5403
5415
|
if (typeof window !== "undefined") {
|
5404
5416
|
window.__BTC_WALLET_VERSION = getVersion();
|