btc-wallet 0.5.87-beta → 0.5.89-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 +6 -1
- package/dist/index.js +30 -9
- package/dist/index.js.map +2 -2
- package/esm/index.js +30 -9
- package/esm/index.js.map +2 -2
- package/package.json +1 -1
package/dist/core/btcUtils.d.ts
CHANGED
@@ -13,7 +13,7 @@ export declare function checkGasTokenDebt<T extends boolean>({ csna, btcAccount,
|
|
13
13
|
env: ENV;
|
14
14
|
autoDeposit?: T;
|
15
15
|
}): Promise<CheckGasTokenDebtReturnType<T>>;
|
16
|
-
export declare function getBtcGasPrice(): Promise<number>;
|
16
|
+
export declare function getBtcGasPrice(type?: 'fastest' | 'halfHour' | 'hour' | 'economy' | 'minimum'): Promise<number>;
|
17
17
|
export declare function getBtcUtxos(account: string): Promise<{
|
18
18
|
value: number;
|
19
19
|
status: {
|
@@ -50,6 +50,11 @@ export declare function getDepositAmount(amount: string, option?: {
|
|
50
50
|
minDepositAmount: number;
|
51
51
|
}>;
|
52
52
|
export declare function getCsnaAccountId(env: ENV): Promise<string>;
|
53
|
+
export declare function checkNewAccount({ csna, btcAccount, env, }: {
|
54
|
+
csna?: string;
|
55
|
+
btcAccount?: string;
|
56
|
+
env?: ENV;
|
57
|
+
}): Promise<boolean>;
|
53
58
|
interface ExecuteBTCDepositAndActionParams<T extends boolean = true> {
|
54
59
|
action?: {
|
55
60
|
receiver_id: string;
|
package/dist/index.js
CHANGED
@@ -110,6 +110,7 @@ __export(src_exports, {
|
|
110
110
|
calculateWithdraw: () => calculateWithdraw,
|
111
111
|
checkBridgeTransactionStatus: () => checkBridgeTransactionStatus,
|
112
112
|
checkGasTokenDebt: () => checkGasTokenDebt,
|
113
|
+
checkNewAccount: () => checkNewAccount,
|
113
114
|
checkSatoshiWhitelist: () => checkSatoshiWhitelist,
|
114
115
|
estimateDepositAmount: () => estimateDepositAmount,
|
115
116
|
executeBTCDepositAndAction: () => executeBTCDepositAndAction,
|
@@ -3872,12 +3873,8 @@ function checkGasTokenDebt(_0) {
|
|
3872
3873
|
autoDeposit
|
3873
3874
|
}) {
|
3874
3875
|
var _a, _b, _c;
|
3876
|
+
const isNewAccount = yield checkNewAccount({ csna, btcAccount, env });
|
3875
3877
|
const accountInfo = yield getAccountInfo({ csna, env });
|
3876
|
-
const bridgeTransactions = yield hasBridgeTransaction({
|
3877
|
-
env,
|
3878
|
-
btcAccount
|
3879
|
-
});
|
3880
|
-
const isNewAccount = !(accountInfo == null ? void 0 : accountInfo.nonce) && !bridgeTransactions;
|
3881
3878
|
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();
|
3882
3879
|
const relayerFeeAmount = isNewAccount ? NBTC_STORAGE_DEPOSIT_AMOUNT : ((_c = accountInfo == null ? void 0 : accountInfo.relayer_fee) == null ? void 0 : _c.amount) || 0;
|
3883
3880
|
const hasDebtArrears = new import_big2.default(debtAmount).gt(0);
|
@@ -3913,14 +3910,14 @@ function checkGasTokenDebt(_0) {
|
|
3913
3910
|
}
|
3914
3911
|
});
|
3915
3912
|
}
|
3916
|
-
function getBtcGasPrice() {
|
3913
|
+
function getBtcGasPrice(type = "halfHour") {
|
3917
3914
|
return __async(this, null, function* () {
|
3918
3915
|
const network = yield getNetwork();
|
3919
3916
|
const defaultFeeRate = network === "mainnet" ? 5 : 2500;
|
3920
3917
|
try {
|
3921
3918
|
const btcRpcUrl = yield getBtcRpcUrl();
|
3922
3919
|
const res = yield fetch(`${btcRpcUrl}/v1/fees/recommended`).then((res2) => res2.json());
|
3923
|
-
const feeRate = res
|
3920
|
+
const feeRate = res[type + "Fee"] ? Number(res[type + "Fee"]) : defaultFeeRate;
|
3924
3921
|
return feeRate;
|
3925
3922
|
} catch (error) {
|
3926
3923
|
return defaultFeeRate;
|
@@ -3941,7 +3938,7 @@ function calculateGasFee(account, amount, feeRate) {
|
|
3941
3938
|
const _feeRate = feeRate || (yield getBtcGasPrice());
|
3942
3939
|
const utxos = yield getBtcUtxos(account);
|
3943
3940
|
const { fee } = (0, import_coinselect.default)(utxos, [{ address: account, value: amount }], Math.ceil(_feeRate));
|
3944
|
-
console.log("calculateGasFee fee:", fee);
|
3941
|
+
console.log("calculateGasFee fee:", fee, "feeRate:", _feeRate);
|
3945
3942
|
return fee;
|
3946
3943
|
});
|
3947
3944
|
}
|
@@ -4040,6 +4037,30 @@ function getCsnaAccountId(env) {
|
|
4040
4037
|
return csna;
|
4041
4038
|
});
|
4042
4039
|
}
|
4040
|
+
function checkNewAccount(_0) {
|
4041
|
+
return __async(this, arguments, function* ({
|
4042
|
+
csna,
|
4043
|
+
btcAccount,
|
4044
|
+
env = "mainnet"
|
4045
|
+
}) {
|
4046
|
+
try {
|
4047
|
+
const _csna = csna || (yield getCsnaAccountId(env));
|
4048
|
+
const _btcAccount = btcAccount || getBtcProvider().account;
|
4049
|
+
if (!_csna || !_btcAccount)
|
4050
|
+
return false;
|
4051
|
+
const accountInfo = yield getAccountInfo({ csna: _csna, env });
|
4052
|
+
const bridgeTransactions = yield hasBridgeTransaction({
|
4053
|
+
env,
|
4054
|
+
btcAccount: _btcAccount
|
4055
|
+
});
|
4056
|
+
const isNewAccount = !(accountInfo == null ? void 0 : accountInfo.nonce) && !bridgeTransactions;
|
4057
|
+
return isNewAccount;
|
4058
|
+
} catch (error) {
|
4059
|
+
console.error("checkNewAccount error:", error);
|
4060
|
+
return false;
|
4061
|
+
}
|
4062
|
+
});
|
4063
|
+
}
|
4043
4064
|
function checkDepositDisabledAddress() {
|
4044
4065
|
var _a;
|
4045
4066
|
const data = (_a = storageStore("SATOSHI_WALLET_XVERSE")) == null ? void 0 : _a.get(
|
@@ -5390,7 +5411,7 @@ function getGroup(state) {
|
|
5390
5411
|
|
5391
5412
|
// src/index.ts
|
5392
5413
|
var getVersion = () => {
|
5393
|
-
return "0.5.
|
5414
|
+
return "0.5.89-beta";
|
5394
5415
|
};
|
5395
5416
|
if (typeof window !== "undefined") {
|
5396
5417
|
window.__BTC_WALLET_VERSION = getVersion();
|