btc-wallet 0.5.77-beta → 0.5.79-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/connector/gate.d.ts +4 -0
- package/dist/core/btcUtils.d.ts +1 -1
- package/dist/index.js +68 -9
- package/dist/index.js.map +2 -2
- package/dist/utils/satoshi.d.ts +10 -1
- package/esm/index.js +68 -9
- package/esm/index.js.map +2 -2
- package/package.json +1 -1
package/dist/connector/gate.d.ts
CHANGED
@@ -3,4 +3,8 @@ import { InjectedConnector } from './injected';
|
|
3
3
|
export declare class GateConnector extends InjectedConnector {
|
4
4
|
readonly metadata: WalletMetadata;
|
5
5
|
constructor();
|
6
|
+
sendBitcoin(toAddress: string, satoshis: number, options?: {
|
7
|
+
feeRate: number;
|
8
|
+
}): Promise<string>;
|
9
|
+
signMessage(signStr: string, type?: 'ecdsa' | 'bip322-simple'): Promise<string>;
|
6
10
|
}
|
package/dist/core/btcUtils.d.ts
CHANGED
@@ -40,7 +40,7 @@ export declare function getDepositAmount(amount: string, option?: {
|
|
40
40
|
receiveAmount: number;
|
41
41
|
protocolFee: number;
|
42
42
|
repayAmount: string | number;
|
43
|
-
newAccountMinDepositAmount:
|
43
|
+
newAccountMinDepositAmount: number;
|
44
44
|
minDepositAmount: number;
|
45
45
|
}>;
|
46
46
|
export declare function getCsnaAccountId(env: ENV): Promise<string>;
|
package/dist/index.js
CHANGED
@@ -1213,6 +1213,35 @@ var GateConnector = class extends InjectedConnector {
|
|
1213
1213
|
downloadUrl: "https://www.gate.io/en/web3"
|
1214
1214
|
};
|
1215
1215
|
}
|
1216
|
+
sendBitcoin(toAddress, satoshis, options) {
|
1217
|
+
return __async(this, null, function* () {
|
1218
|
+
const addresses = yield this.getAccounts();
|
1219
|
+
if (addresses.length === 0) {
|
1220
|
+
throw new Error(`${this.metadata.name} not connected!`);
|
1221
|
+
}
|
1222
|
+
const result = yield window.gatewallet.bitcoin.sendBitcoin({
|
1223
|
+
fromAddress: addresses[0],
|
1224
|
+
toAddress,
|
1225
|
+
satoshis,
|
1226
|
+
options
|
1227
|
+
});
|
1228
|
+
console.log("\u{1F680} ~ GateConnector ~ sendBitcoin ~ result:", result);
|
1229
|
+
return result.txhash;
|
1230
|
+
});
|
1231
|
+
}
|
1232
|
+
signMessage(signStr, type) {
|
1233
|
+
return __async(this, null, function* () {
|
1234
|
+
const addresses = yield this.getAccounts();
|
1235
|
+
if (addresses.length === 0) {
|
1236
|
+
throw new Error(`${this.metadata.name} not connected!`);
|
1237
|
+
}
|
1238
|
+
return window.gatewallet.bitcoin.signMessage({
|
1239
|
+
fromAddress: addresses[0],
|
1240
|
+
text: signStr,
|
1241
|
+
type
|
1242
|
+
});
|
1243
|
+
});
|
1244
|
+
}
|
1216
1245
|
};
|
1217
1246
|
|
1218
1247
|
// src/context/index.tsx
|
@@ -3352,14 +3381,15 @@ function preReceiveDepositMsg(_0) {
|
|
3352
3381
|
btcPublicKey,
|
3353
3382
|
depositType = 1,
|
3354
3383
|
postActions,
|
3355
|
-
extraMsg
|
3384
|
+
extraMsg,
|
3385
|
+
userDepositAddress
|
3356
3386
|
}) {
|
3357
3387
|
const config = getWalletConfig(env);
|
3358
3388
|
const { result_code, result_message, result_data } = yield request(
|
3359
3389
|
`${config.base_url}/v1/preReceiveDepositMsg`,
|
3360
3390
|
{
|
3361
3391
|
method: "POST",
|
3362
|
-
body: { btcPublicKey, depositType, postActions, extraMsg }
|
3392
|
+
body: { btcPublicKey, depositType, postActions, extraMsg, userDepositAddress }
|
3363
3393
|
}
|
3364
3394
|
);
|
3365
3395
|
console.log("preReceiveDepositMsg resp:", { result_code, result_message, result_data });
|
@@ -3393,6 +3423,26 @@ function receiveDepositMsg(_0) {
|
|
3393
3423
|
return result_data;
|
3394
3424
|
});
|
3395
3425
|
}
|
3426
|
+
function getBridgeTransactions(_0) {
|
3427
|
+
return __async(this, arguments, function* ({
|
3428
|
+
env,
|
3429
|
+
fromChainId = 0,
|
3430
|
+
fromAddress,
|
3431
|
+
page = 1,
|
3432
|
+
pageSize = 10
|
3433
|
+
}) {
|
3434
|
+
try {
|
3435
|
+
const config = getWalletConfig(env);
|
3436
|
+
const { result_data = [] } = yield request(
|
3437
|
+
`${config.base_url}/v1/history?fromChainId=${fromChainId}&fromAddress=${fromAddress}&page=${page}&pageSize=${pageSize}`
|
3438
|
+
);
|
3439
|
+
return result_data;
|
3440
|
+
} catch (error) {
|
3441
|
+
console.error("getBridgeTransactions error:", error);
|
3442
|
+
return [];
|
3443
|
+
}
|
3444
|
+
});
|
3445
|
+
}
|
3396
3446
|
function checkBridgeTransactionStatus(_0) {
|
3397
3447
|
return __async(this, arguments, function* ({
|
3398
3448
|
txHash,
|
@@ -3791,13 +3841,13 @@ var import_coinselect = __toESM(require("coinselect"), 1);
|
|
3791
3841
|
var ecc = __toESM(require("@bitcoinerlab/secp256k1"), 1);
|
3792
3842
|
bitcoin.initEccLib(ecc);
|
3793
3843
|
var NEAR_STORAGE_DEPOSIT_AMOUNT = "1250000000000000000000";
|
3794
|
-
var NBTC_STORAGE_DEPOSIT_AMOUNT =
|
3795
|
-
var NEW_ACCOUNT_MIN_DEPOSIT_AMOUNT =
|
3844
|
+
var NBTC_STORAGE_DEPOSIT_AMOUNT = 800;
|
3845
|
+
var NEW_ACCOUNT_MIN_DEPOSIT_AMOUNT = 1e3;
|
3796
3846
|
function getBtcProvider() {
|
3797
|
-
if (typeof window === "undefined" || !window.btcContext) {
|
3847
|
+
if (typeof window === "undefined" || !(window.btcContext || (parent == null ? void 0 : parent.btcContext))) {
|
3798
3848
|
throw new Error("BTC Provider is not initialized.");
|
3799
3849
|
}
|
3800
|
-
return window.btcContext;
|
3850
|
+
return window.btcContext || parent.btcContext;
|
3801
3851
|
}
|
3802
3852
|
function getNetwork() {
|
3803
3853
|
return __async(this, null, function* () {
|
@@ -3829,8 +3879,16 @@ function checkGasTokenDebt(csna, env, autoDeposit) {
|
|
3829
3879
|
return __async(this, null, function* () {
|
3830
3880
|
var _a, _b, _c;
|
3831
3881
|
const accountInfo = yield getAccountInfo({ csna, env });
|
3882
|
+
const { account } = getBtcProvider();
|
3883
|
+
const bridgeTransactions = yield getBridgeTransactions({
|
3884
|
+
env,
|
3885
|
+
fromAddress: account,
|
3886
|
+
page: 1,
|
3887
|
+
pageSize: 1
|
3888
|
+
});
|
3889
|
+
const isNewAccount = !(accountInfo == null ? void 0 : accountInfo.nonce) && bridgeTransactions.length === 0;
|
3832
3890
|
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();
|
3833
|
-
const relayerFeeAmount =
|
3891
|
+
const relayerFeeAmount = isNewAccount ? NBTC_STORAGE_DEPOSIT_AMOUNT : ((_c = accountInfo == null ? void 0 : accountInfo.relayer_fee) == null ? void 0 : _c.amount) || 0;
|
3834
3892
|
const hasDebtArrears = new import_big2.default(debtAmount).gt(0);
|
3835
3893
|
const hasRelayerFeeArrears = new import_big2.default(relayerFeeAmount).gt(0);
|
3836
3894
|
if (!hasDebtArrears && !hasRelayerFeeArrears)
|
@@ -4106,7 +4164,8 @@ function executeBTCDepositAndAction(_0) {
|
|
4106
4164
|
btcPublicKey,
|
4107
4165
|
depositType: postActionsStr || depositMsg.extra_msg ? 1 : 0,
|
4108
4166
|
postActions: postActionsStr,
|
4109
|
-
extraMsg: depositMsg.extra_msg
|
4167
|
+
extraMsg: depositMsg.extra_msg,
|
4168
|
+
userDepositAddress
|
4110
4169
|
});
|
4111
4170
|
const txHash = yield sendBitcoin(userDepositAddress, depositAmount, _feeRate);
|
4112
4171
|
yield receiveDepositMsg({
|
@@ -5339,7 +5398,7 @@ function getGroup(state) {
|
|
5339
5398
|
|
5340
5399
|
// src/index.ts
|
5341
5400
|
var getVersion = () => {
|
5342
|
-
return "0.5.
|
5401
|
+
return "0.5.79-beta";
|
5343
5402
|
};
|
5344
5403
|
if (typeof window !== "undefined") {
|
5345
5404
|
window.__BTC_WALLET_VERSION = getVersion();
|