btc-wallet 0.4.3-beta → 0.4.5-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/README.md +0 -1
- package/dist/core/btcUtils.d.ts +26 -16
- package/dist/index.js +205 -93
- package/dist/index.js.map +3 -3
- package/dist/utils/satoshi.d.ts +1 -0
- package/esm/index.js +205 -93
- package/esm/index.js.map +2 -2
- package/package.json +3 -1
package/dist/utils/satoshi.d.ts
CHANGED
@@ -19,4 +19,5 @@ export declare function checkBtcTransactionStatus(url: string, sig: string): Pro
|
|
19
19
|
NearHashList: string[];
|
20
20
|
}>;
|
21
21
|
export declare function getWhitelist(url: string): Promise<string[]>;
|
22
|
+
export declare function receiveWithdrawMsg(url: string, txHash: string): Promise<any>;
|
22
23
|
export {};
|
package/esm/index.js
CHANGED
@@ -418,39 +418,11 @@ var XverseConnector = class extends BaseConnector {
|
|
418
418
|
if (!provider) {
|
419
419
|
throw new Error(`${this.metadata.name} is not install!`);
|
420
420
|
}
|
421
|
-
const {
|
422
|
-
|
423
|
-
if (addresses.length === 0) {
|
424
|
-
throw new Error(`${this.metadata.name} not connected!`);
|
425
|
-
}
|
426
|
-
const result = yield new Promise((resolve, reject) => {
|
427
|
-
const sendBtcOptions = {
|
428
|
-
payload: {
|
429
|
-
network: {
|
430
|
-
type: __privateGet(this, _network)
|
431
|
-
},
|
432
|
-
recipients: [
|
433
|
-
{
|
434
|
-
address: toAddress,
|
435
|
-
amountSats: BigInt(satoshis)
|
436
|
-
}
|
437
|
-
],
|
438
|
-
senderAddress: addresses[0]
|
439
|
-
},
|
440
|
-
onFinish: (response) => {
|
441
|
-
resolve(response);
|
442
|
-
},
|
443
|
-
onCancel: () => {
|
444
|
-
reject({
|
445
|
-
code: 4001,
|
446
|
-
message: "User rejected the request."
|
447
|
-
});
|
448
|
-
}
|
449
|
-
};
|
450
|
-
console.log("\u{1F680} ~ XverseConnector ~ sendBitcoin ~ sendBtcOptions:", sendBtcOptions);
|
451
|
-
sendBtcTransaction(sendBtcOptions).catch((e) => reject(e));
|
421
|
+
const { result } = yield provider.request("sendTransfer", {
|
422
|
+
recipients: [{ address: toAddress, amount: satoshis }]
|
452
423
|
});
|
453
|
-
|
424
|
+
console.log("\u{1F680} ~ XverseConnector ~ sendBitcoin ~ res:", result);
|
425
|
+
return result.txid;
|
454
426
|
});
|
455
427
|
}
|
456
428
|
disconnect() {
|
@@ -2382,6 +2354,7 @@ function BtcWalletSelectorContextProvider({
|
|
2382
2354
|
const [isProcessing, setIsProcessing] = useState8(false);
|
2383
2355
|
const connectors = [
|
2384
2356
|
new UnisatConnector(),
|
2357
|
+
new XverseConnector(),
|
2385
2358
|
new OKXConnector(),
|
2386
2359
|
new BitgetConnector()
|
2387
2360
|
];
|
@@ -3221,9 +3194,10 @@ Dialog.style = `
|
|
3221
3194
|
`;
|
3222
3195
|
|
3223
3196
|
// src/core/btcUtils.ts
|
3224
|
-
|
3197
|
+
import bitcoin from "bitcoinjs-lib";
|
3198
|
+
import coinselect from "coinselect";
|
3225
3199
|
var NEAR_STORAGE_DEPOSIT_AMOUNT = "1250000000000000000000";
|
3226
|
-
var NBTC_STORAGE_DEPOSIT_AMOUNT =
|
3200
|
+
var NBTC_STORAGE_DEPOSIT_AMOUNT = "3000";
|
3227
3201
|
var GAS_LIMIT = "50000000000000";
|
3228
3202
|
function getBtcProvider() {
|
3229
3203
|
if (typeof window === "undefined" || !window.btcContext) {
|
@@ -3281,11 +3255,11 @@ function checkGasTokenBalance(csna, gasToken, minAmount, env) {
|
|
3281
3255
|
}
|
3282
3256
|
});
|
3283
3257
|
}
|
3284
|
-
function
|
3258
|
+
function checkGasTokenDebt(accountInfo, env, autoDeposit) {
|
3285
3259
|
return __async(this, null, function* () {
|
3286
3260
|
var _a, _b, _c;
|
3287
3261
|
const debtAmount = new Big(((_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();
|
3288
|
-
const relayerFeeAmount = ((_c = accountInfo == null ? void 0 : accountInfo.relayer_fee) == null ? void 0 : _c.amount) ||
|
3262
|
+
const relayerFeeAmount = !(accountInfo == null ? void 0 : accountInfo.nonce) ? NBTC_STORAGE_DEPOSIT_AMOUNT : ((_c = accountInfo == null ? void 0 : accountInfo.relayer_fee) == null ? void 0 : _c.amount) || 0;
|
3289
3263
|
const hasDebtArrears = new Big(debtAmount).gt(0);
|
3290
3264
|
const hasRelayerFeeArrears = new Big(relayerFeeAmount).gt(0);
|
3291
3265
|
if (!hasDebtArrears && !hasRelayerFeeArrears)
|
@@ -3295,7 +3269,7 @@ function checkGasTokenArrears(accountInfo, env, autoDeposit) {
|
|
3295
3269
|
console.log("get_account:", accountInfo);
|
3296
3270
|
const action = {
|
3297
3271
|
receiver_id: config.accountContractId,
|
3298
|
-
amount: transferAmount,
|
3272
|
+
amount: transferAmount.toString(),
|
3299
3273
|
msg: JSON.stringify(hasDebtArrears ? "Repay" : "RelayerFee")
|
3300
3274
|
};
|
3301
3275
|
if (!autoDeposit)
|
@@ -3315,14 +3289,6 @@ function checkGasTokenArrears(accountInfo, env, autoDeposit) {
|
|
3315
3289
|
}
|
3316
3290
|
});
|
3317
3291
|
}
|
3318
|
-
function queryGasTokenArrears(env) {
|
3319
|
-
return __async(this, null, function* () {
|
3320
|
-
const config = yield getConfig(env);
|
3321
|
-
const csna = yield getCsnaAccountId(env);
|
3322
|
-
const accountInfo = yield getAccountInfo(csna, config.accountContractId);
|
3323
|
-
return accountInfo == null ? void 0 : accountInfo.debt_info;
|
3324
|
-
});
|
3325
|
-
}
|
3326
3292
|
function getBtcGasPrice() {
|
3327
3293
|
return __async(this, null, function* () {
|
3328
3294
|
const network = yield getNetwork();
|
@@ -3364,6 +3330,18 @@ function getBtcBalance() {
|
|
3364
3330
|
};
|
3365
3331
|
});
|
3366
3332
|
}
|
3333
|
+
function getNBTCBalance(address, env) {
|
3334
|
+
return __async(this, null, function* () {
|
3335
|
+
const config = yield getConfig(env || "mainnet");
|
3336
|
+
const rawBalance = yield nearCall(config.token, "ft_balance_of", {
|
3337
|
+
account_id: address
|
3338
|
+
});
|
3339
|
+
const balance = new Big(rawBalance).div(__pow(10, 8)).round(8, Big.roundDown).toNumber();
|
3340
|
+
const rawAvailableBalance = new Big(rawBalance).minus(1e3).toNumber();
|
3341
|
+
const availableBalance = new Big(rawAvailableBalance).div(__pow(10, 8)).round(8, Big.roundDown).toNumber();
|
3342
|
+
return { balance, availableBalance, rawBalance, rawAvailableBalance };
|
3343
|
+
});
|
3344
|
+
}
|
3367
3345
|
function sendBitcoin(address, amount, feeRate) {
|
3368
3346
|
return __async(this, null, function* () {
|
3369
3347
|
const { sendBitcoin: sendBitcoin2 } = getBtcProvider();
|
@@ -3373,28 +3351,29 @@ function sendBitcoin(address, amount, feeRate) {
|
|
3373
3351
|
}
|
3374
3352
|
function estimateDepositAmount(amount, option) {
|
3375
3353
|
return __async(this, null, function* () {
|
3376
|
-
|
3377
|
-
const csna = yield getCsnaAccountId((option == null ? void 0 : option.env) || "mainnet");
|
3378
|
-
const accountInfo = yield getAccountInfo(csna, config.accountContractId);
|
3379
|
-
const { receiveAmount } = yield getDepositAmount(amount, __spreadProps(__spreadValues({}, option), { isEstimate: true }));
|
3380
|
-
return (accountInfo == null ? void 0 : accountInfo.nonce) ? receiveAmount : new Big(receiveAmount).minus(NBTC_STORAGE_DEPOSIT_AMOUNT).round(0, Big.roundDown).toNumber();
|
3354
|
+
return amount;
|
3381
3355
|
});
|
3382
3356
|
}
|
3383
3357
|
function getDepositAmount(amount, option) {
|
3384
3358
|
return __async(this, null, function* () {
|
3385
|
-
const
|
3359
|
+
const env = (option == null ? void 0 : option.env) || "mainnet";
|
3360
|
+
const config = yield getConfig(env);
|
3361
|
+
const csna = yield getCsnaAccountId(env);
|
3362
|
+
const accountInfo = yield getAccountInfo(csna, config.accountContractId);
|
3363
|
+
const debtAction = yield checkGasTokenDebt(accountInfo, env, false);
|
3364
|
+
const repayAmount = (debtAction == null ? void 0 : debtAction.amount) || 0;
|
3386
3365
|
const {
|
3387
3366
|
deposit_bridge_fee: { fee_min, fee_rate },
|
3388
3367
|
min_deposit_amount
|
3389
3368
|
} = yield nearCall(config.bridgeContractId, "get_config", {});
|
3390
|
-
const depositAmount =
|
3391
|
-
const
|
3392
|
-
const
|
3393
|
-
console.log("getDepositAmount:", { depositAmount, receiveAmount, fee });
|
3369
|
+
const depositAmount = Math.max(Number(min_deposit_amount), Number(amount));
|
3370
|
+
const protocolFee = Math.max(Number(fee_min), Number(depositAmount) * fee_rate);
|
3371
|
+
const totalDepositAmount = new Big(depositAmount).plus(protocolFee).plus(repayAmount).round(0, Big.roundDown).toNumber();
|
3394
3372
|
return {
|
3395
3373
|
depositAmount,
|
3396
|
-
|
3397
|
-
|
3374
|
+
totalDepositAmount,
|
3375
|
+
protocolFee,
|
3376
|
+
repayAmount
|
3398
3377
|
};
|
3399
3378
|
});
|
3400
3379
|
}
|
@@ -3418,7 +3397,6 @@ function executeBTCDepositAndAction(_0) {
|
|
3418
3397
|
action,
|
3419
3398
|
amount,
|
3420
3399
|
feeRate,
|
3421
|
-
fixedAmount = true,
|
3422
3400
|
pollResult = true,
|
3423
3401
|
registerDeposit,
|
3424
3402
|
env = "mainnet"
|
@@ -3435,33 +3413,25 @@ function executeBTCDepositAndAction(_0) {
|
|
3435
3413
|
throw new Error("amount or action is required");
|
3436
3414
|
}
|
3437
3415
|
const csna = yield getCsnaAccountId(env);
|
3438
|
-
const
|
3439
|
-
if (new Big(
|
3416
|
+
const depositAmount = (_a = action ? action.amount : amount) != null ? _a : "0";
|
3417
|
+
if (new Big(depositAmount).lt(0)) {
|
3440
3418
|
throw new Error("amount must be greater than 0");
|
3441
3419
|
}
|
3442
|
-
const {
|
3420
|
+
const { totalDepositAmount, protocolFee, repayAmount } = yield getDepositAmount(depositAmount, {
|
3443
3421
|
env
|
3444
3422
|
});
|
3445
3423
|
const accountInfo = yield getAccountInfo(csna, config.accountContractId);
|
3446
3424
|
const newActions = [];
|
3447
|
-
const
|
3448
|
-
if (
|
3449
|
-
newActions.push(__spreadProps(__spreadValues({},
|
3425
|
+
const debtAction = yield checkGasTokenDebt(accountInfo, env, false);
|
3426
|
+
if (debtAction) {
|
3427
|
+
newActions.push(__spreadProps(__spreadValues({}, debtAction), {
|
3450
3428
|
gas: GAS_LIMIT
|
3451
3429
|
}));
|
3452
3430
|
}
|
3453
|
-
if (action
|
3454
|
-
newActions.push(
|
3455
|
-
|
3456
|
-
|
3457
|
-
gas: GAS_LIMIT
|
3458
|
-
}) : {
|
3459
|
-
receiver_id: config.accountContractId,
|
3460
|
-
amount: MINIMUM_DEPOSIT_AMOUNT_BASE.toString(),
|
3461
|
-
msg: JSON.stringify("Deposit"),
|
3462
|
-
gas: GAS_LIMIT
|
3463
|
-
}
|
3464
|
-
);
|
3431
|
+
if (action) {
|
3432
|
+
newActions.push(__spreadProps(__spreadValues({}, action), {
|
3433
|
+
gas: GAS_LIMIT
|
3434
|
+
}));
|
3465
3435
|
}
|
3466
3436
|
const storageDepositMsg = {};
|
3467
3437
|
const registerRes = yield nearCall((action == null ? void 0 : action.receiver_id) || config.token, "storage_balance_of", {
|
@@ -3476,12 +3446,6 @@ function executeBTCDepositAndAction(_0) {
|
|
3476
3446
|
}
|
3477
3447
|
if (!(accountInfo == null ? void 0 : accountInfo.nonce)) {
|
3478
3448
|
storageDepositMsg.btc_public_key = btcPublicKey;
|
3479
|
-
newActions.push({
|
3480
|
-
receiver_id: config.accountContractId,
|
3481
|
-
amount: NBTC_STORAGE_DEPOSIT_AMOUNT.toString(),
|
3482
|
-
msg: JSON.stringify("RelayerFee"),
|
3483
|
-
gas: GAS_LIMIT
|
3484
|
-
});
|
3485
3449
|
}
|
3486
3450
|
const depositMsg = {
|
3487
3451
|
recipient_id: csna,
|
@@ -3495,10 +3459,14 @@ function executeBTCDepositAndAction(_0) {
|
|
3495
3459
|
{ deposit_msg: depositMsg }
|
3496
3460
|
);
|
3497
3461
|
const _feeRate = feeRate || (yield getBtcGasPrice());
|
3498
|
-
|
3499
|
-
|
3500
|
-
|
3501
|
-
|
3462
|
+
console.table({
|
3463
|
+
"User Deposit Address": userDepositAddress,
|
3464
|
+
"Deposit Amount": depositAmount,
|
3465
|
+
"Protocol Fee": protocolFee,
|
3466
|
+
"Repay Amount": repayAmount,
|
3467
|
+
"Total Deposit Amount": totalDepositAmount,
|
3468
|
+
"Fee Rate": _feeRate
|
3469
|
+
});
|
3502
3470
|
const postActionsStr = newActions.length > 0 ? JSON.stringify(newActions) : void 0;
|
3503
3471
|
yield preReceiveDepositMsg(config.base_url, {
|
3504
3472
|
btcPublicKey,
|
@@ -3506,7 +3474,7 @@ function executeBTCDepositAndAction(_0) {
|
|
3506
3474
|
postActions: postActionsStr,
|
3507
3475
|
extraMsg: depositMsg.extra_msg
|
3508
3476
|
});
|
3509
|
-
const txHash = yield sendBitcoin(userDepositAddress,
|
3477
|
+
const txHash = yield sendBitcoin(userDepositAddress, totalDepositAmount, _feeRate);
|
3510
3478
|
yield receiveDepositMsg(config.base_url, {
|
3511
3479
|
btcPublicKey,
|
3512
3480
|
txHash,
|
@@ -3551,6 +3519,149 @@ Sign up now: <a style="color: #ff7a00; text-decoration: underline;" href="https:
|
|
3551
3519
|
}
|
3552
3520
|
});
|
3553
3521
|
}
|
3522
|
+
function getWithdrawTransaction(_0) {
|
3523
|
+
return __async(this, arguments, function* ({
|
3524
|
+
amount,
|
3525
|
+
feeRate,
|
3526
|
+
env = "mainnet"
|
3527
|
+
}) {
|
3528
|
+
const provider = getBtcProvider();
|
3529
|
+
const btcAddress = yield provider.account;
|
3530
|
+
const config = yield getConfig(env);
|
3531
|
+
const brgConfig = yield nearCall(config.bridgeContractId, "get_config", {});
|
3532
|
+
const _amount = Number(new Big(amount).mul(__pow(10, 8)).toFixed(0));
|
3533
|
+
if (brgConfig.min_withdraw_amount) {
|
3534
|
+
if (_amount < Number(brgConfig.min_withdraw_amount)) {
|
3535
|
+
throw new Error("Mini withdraw amount is " + brgConfig.min_withdraw_amount);
|
3536
|
+
}
|
3537
|
+
}
|
3538
|
+
const feePercent = Number(brgConfig.withdraw_bridge_fee.fee_rate) * _amount;
|
3539
|
+
const withdrawFee = feePercent > Number(brgConfig.withdraw_bridge_fee.fee_min) ? feePercent : Number(brgConfig.withdraw_bridge_fee.fee_min);
|
3540
|
+
const allUTXO = yield nearCall(config.bridgeContractId, "get_utxos_paged", {});
|
3541
|
+
if (!allUTXO || Object.keys(allUTXO).length === 0) {
|
3542
|
+
throw new Error("The network is busy, please try again later.");
|
3543
|
+
}
|
3544
|
+
const utxos = Object.keys(allUTXO).map((key) => {
|
3545
|
+
const txid = key.split("@");
|
3546
|
+
return {
|
3547
|
+
txid: txid[0],
|
3548
|
+
vout: allUTXO[key].vout,
|
3549
|
+
value: Number(allUTXO[key].balance),
|
3550
|
+
script: allUTXO[key].script
|
3551
|
+
};
|
3552
|
+
});
|
3553
|
+
const _feeRate = feeRate || (yield getBtcGasPrice());
|
3554
|
+
const { inputs, outputs, fee } = coinselect(
|
3555
|
+
utxos,
|
3556
|
+
[{ address: btcAddress, value: _amount }],
|
3557
|
+
Math.ceil(_feeRate)
|
3558
|
+
);
|
3559
|
+
if (!outputs || !inputs) {
|
3560
|
+
throw new Error("The network is busy, please try again later.");
|
3561
|
+
}
|
3562
|
+
const maxBtcFee = Number(brgConfig.max_btc_gas_fee);
|
3563
|
+
const newFee = fee;
|
3564
|
+
const withdrawChangeAddress = brgConfig.change_address;
|
3565
|
+
if (newFee > maxBtcFee) {
|
3566
|
+
throw new Error("Gas exceeds maximum value");
|
3567
|
+
}
|
3568
|
+
let userOutput, noUserOutput;
|
3569
|
+
for (let i = 0; i < outputs.length; i++) {
|
3570
|
+
const output = outputs[i];
|
3571
|
+
if (output.value.toString() === _amount.toString()) {
|
3572
|
+
userOutput = output;
|
3573
|
+
} else {
|
3574
|
+
noUserOutput = output;
|
3575
|
+
}
|
3576
|
+
if (!output.address) {
|
3577
|
+
output.address = withdrawChangeAddress;
|
3578
|
+
}
|
3579
|
+
}
|
3580
|
+
userOutput.value = new Big(userOutput.value).minus(newFee).minus(withdrawFee).toNumber();
|
3581
|
+
if (noUserOutput) {
|
3582
|
+
noUserOutput.value = new Big(noUserOutput.value).plus(newFee).plus(withdrawFee).toNumber();
|
3583
|
+
} else {
|
3584
|
+
noUserOutput = {
|
3585
|
+
address: withdrawChangeAddress,
|
3586
|
+
value: new Big(newFee).plus(withdrawFee).toNumber()
|
3587
|
+
};
|
3588
|
+
outputs.push(noUserOutput);
|
3589
|
+
}
|
3590
|
+
const insufficientOutput = outputs.some((item) => item.value < 0);
|
3591
|
+
if (insufficientOutput) {
|
3592
|
+
throw new Error("Not enough gas");
|
3593
|
+
}
|
3594
|
+
const inputSum = inputs.reduce((sum, cur) => sum + Number(cur.value), 0);
|
3595
|
+
const outputSum = outputs.reduce((sum, cur) => sum + Number(cur.value), 0);
|
3596
|
+
if (newFee + outputSum !== inputSum) {
|
3597
|
+
throw new Error("compute error");
|
3598
|
+
}
|
3599
|
+
const network = yield getNetwork();
|
3600
|
+
const btcNetwork = network === "mainnet" ? bitcoin.networks.bitcoin : bitcoin.networks.testnet;
|
3601
|
+
const psbt = new bitcoin.Psbt({ network: btcNetwork });
|
3602
|
+
const btcRpcUrl = yield getBtcRpcUrl();
|
3603
|
+
for (let i = 0; i < inputs.length; i++) {
|
3604
|
+
const input = inputs[i];
|
3605
|
+
const txData = yield fetch(`${btcRpcUrl}/tx/${input.txid}`).then((res) => res.json());
|
3606
|
+
const inputOptions = {
|
3607
|
+
hash: input.txid,
|
3608
|
+
index: input.vout,
|
3609
|
+
sequence: 4294967293,
|
3610
|
+
witnessUtxo: {
|
3611
|
+
script: Buffer.from(txData.vout[input.vout].scriptpubkey, "hex"),
|
3612
|
+
value: input.value
|
3613
|
+
}
|
3614
|
+
};
|
3615
|
+
psbt.addInput(inputOptions);
|
3616
|
+
}
|
3617
|
+
outputs.forEach((output) => {
|
3618
|
+
psbt.addOutput({
|
3619
|
+
address: output.address,
|
3620
|
+
value: output.value
|
3621
|
+
});
|
3622
|
+
});
|
3623
|
+
const _inputs = inputs.map((item) => {
|
3624
|
+
return `${item.txid}:${item.vout}`;
|
3625
|
+
});
|
3626
|
+
const txOutputs = psbt.txOutputs.map((item) => {
|
3627
|
+
return {
|
3628
|
+
script_pubkey: uint8ArrayToHex(item.script),
|
3629
|
+
value: item.value
|
3630
|
+
};
|
3631
|
+
});
|
3632
|
+
const msg = {
|
3633
|
+
Withdraw: {
|
3634
|
+
target_btc_address: btcAddress,
|
3635
|
+
input: _inputs,
|
3636
|
+
output: txOutputs
|
3637
|
+
}
|
3638
|
+
};
|
3639
|
+
const csna = yield getCsnaAccountId(env);
|
3640
|
+
const transaction = {
|
3641
|
+
receiverId: config.token,
|
3642
|
+
signerId: csna,
|
3643
|
+
actions: [
|
3644
|
+
{
|
3645
|
+
type: "FunctionCall",
|
3646
|
+
params: {
|
3647
|
+
methodName: "ft_transfer_call",
|
3648
|
+
args: {
|
3649
|
+
receiver_id: config.bridgeContractId,
|
3650
|
+
amount: _amount.toString(),
|
3651
|
+
msg: JSON.stringify(msg)
|
3652
|
+
},
|
3653
|
+
gas: "300000000000000",
|
3654
|
+
deposit: "1"
|
3655
|
+
}
|
3656
|
+
}
|
3657
|
+
]
|
3658
|
+
};
|
3659
|
+
return transaction;
|
3660
|
+
});
|
3661
|
+
}
|
3662
|
+
function uint8ArrayToHex(uint8Array) {
|
3663
|
+
return Array.from(uint8Array).map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
3664
|
+
}
|
3554
3665
|
|
3555
3666
|
// src/core/setupBTCWallet.ts
|
3556
3667
|
var { transfer, functionCall } = actionCreators;
|
@@ -3776,7 +3887,7 @@ var BTCWallet = (_0) => __async(void 0, [_0], function* ({
|
|
3776
3887
|
const btcContext = window.btcContext;
|
3777
3888
|
const accountId = state.getAccount();
|
3778
3889
|
const accountInfo = yield getAccountInfo(accountId, currentConfig.accountContractId);
|
3779
|
-
yield
|
3890
|
+
yield checkGasTokenDebt(accountInfo, env, true);
|
3780
3891
|
const trans = [...params.transactions];
|
3781
3892
|
console.log("raw trans:", trans);
|
3782
3893
|
const gasTokenBalance = (accountInfo == null ? void 0 : accountInfo.gas_token[currentConfig.token]) || "0";
|
@@ -3845,7 +3956,7 @@ var BTCWallet = (_0) => __async(void 0, [_0], function* ({
|
|
3845
3956
|
args: {
|
3846
3957
|
receiver_id: currentConfig.accountContractId,
|
3847
3958
|
amount,
|
3848
|
-
msg: JSON.stringify("
|
3959
|
+
msg: JSON.stringify("Repay")
|
3849
3960
|
},
|
3850
3961
|
gas: new Big2(50).mul(__pow(10, 12)).toFixed(0),
|
3851
3962
|
deposit: "1"
|
@@ -3985,7 +4096,7 @@ function setupBTCWallet({
|
|
3985
4096
|
if (!hasShownNotice) {
|
3986
4097
|
Dialog.alert({
|
3987
4098
|
title: "Notice",
|
3988
|
-
message: "You are currently using Satoshi Private Mainnet. This is a private version for testing. Please try a small amount of assets in
|
4099
|
+
message: "You are currently using Satoshi Private Mainnet. This is a private version for testing. Please try a small amount of assets in Ramp"
|
3989
4100
|
});
|
3990
4101
|
localStorage.setItem("satoshi_private_mainnet_notice", "true");
|
3991
4102
|
}
|
@@ -4014,7 +4125,7 @@ function setupBTCWallet({
|
|
4014
4125
|
|
4015
4126
|
// src/index.ts
|
4016
4127
|
var getVersion = () => {
|
4017
|
-
return "0.4.
|
4128
|
+
return "0.4.5-beta";
|
4018
4129
|
};
|
4019
4130
|
if (typeof window !== "undefined") {
|
4020
4131
|
window.__BTC_WALLET_VERSION = getVersion();
|
@@ -4032,8 +4143,8 @@ export {
|
|
4032
4143
|
UnisatConnector,
|
4033
4144
|
WizzConnector,
|
4034
4145
|
XverseConnector,
|
4035
|
-
checkGasTokenArrears,
|
4036
4146
|
checkGasTokenBalance,
|
4147
|
+
checkGasTokenDebt,
|
4037
4148
|
checkSatoshiWhitelist,
|
4038
4149
|
estimateDepositAmount,
|
4039
4150
|
executeBTCDepositAndAction,
|
@@ -4042,8 +4153,9 @@ export {
|
|
4042
4153
|
getBtcGasPrice,
|
4043
4154
|
getCsnaAccountId,
|
4044
4155
|
getDepositAmount,
|
4156
|
+
getNBTCBalance,
|
4045
4157
|
getVersion,
|
4046
|
-
|
4158
|
+
getWithdrawTransaction,
|
4047
4159
|
sendBitcoin,
|
4048
4160
|
setupBTCWallet,
|
4049
4161
|
useAccountContract,
|