btc-wallet 0.5.0-beta → 0.5.1-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 +3 -1
- package/dist/core/btcUtils.d.ts +4 -1
- package/dist/index.js +14 -12
- package/dist/index.js.map +2 -2
- package/esm/index.js +14 -12
- package/esm/index.js.map +2 -2
- package/package.json +2 -1
package/esm/index.js
CHANGED
@@ -2806,6 +2806,7 @@ function useBtcWalletSelector() {
|
|
2806
2806
|
}),
|
2807
2807
|
autoConnect: () => __async(this, null, function* () {
|
2808
2808
|
requestDirectAccount(connectorRef.current).catch((e) => {
|
2809
|
+
console.error("btcLoginError", e);
|
2809
2810
|
context.emit("btcLoginError");
|
2810
2811
|
});
|
2811
2812
|
}),
|
@@ -2875,7 +2876,7 @@ var walletConfig = {
|
|
2875
2876
|
token: "nbtc.toalice.near",
|
2876
2877
|
accountContractId: "acc.toalice.near",
|
2877
2878
|
bridgeContractId: "brg.toalice.near",
|
2878
|
-
walletUrl: "
|
2879
|
+
walletUrl: "http://localhost:3100",
|
2879
2880
|
bridgeUrl: "https://old.ramp.satos.network"
|
2880
2881
|
},
|
2881
2882
|
mainnet: {
|
@@ -3397,10 +3398,11 @@ var NBTC_STORAGE_DEPOSIT_AMOUNT = "3000";
|
|
3397
3398
|
var GAS_LIMIT = "50000000000000";
|
3398
3399
|
var NEW_ACCOUNT_MIN_DEPOSIT_AMOUNT = "1000";
|
3399
3400
|
function getBtcProvider() {
|
3400
|
-
|
3401
|
+
var _a, _b;
|
3402
|
+
if (typeof window === "undefined" || !window.btcContext && !((_a = window.top) == null ? void 0 : _a.btcContext)) {
|
3401
3403
|
throw new Error("BTC Provider is not initialized.");
|
3402
3404
|
}
|
3403
|
-
return window.btcContext;
|
3405
|
+
return window.btcContext || ((_b = window.top) == null ? void 0 : _b.btcContext);
|
3404
3406
|
}
|
3405
3407
|
function getNetwork() {
|
3406
3408
|
return __async(this, null, function* () {
|
@@ -3554,7 +3556,9 @@ function estimateDepositAmount(amount, option) {
|
|
3554
3556
|
}
|
3555
3557
|
function getDepositAmount(amount, option) {
|
3556
3558
|
return __async(this, null, function* () {
|
3559
|
+
var _a;
|
3557
3560
|
const env = (option == null ? void 0 : option.env) || "mainnet";
|
3561
|
+
const _newAccountMinDepositAmount = (_a = option == null ? void 0 : option.newAccountMinDepositAmount) != null ? _a : true;
|
3558
3562
|
const config = yield getConfig(env);
|
3559
3563
|
const csna = yield getCsnaAccountId(env);
|
3560
3564
|
const accountInfo = yield getAccountInfo(csna, config.accountContractId);
|
@@ -3566,7 +3570,7 @@ function getDepositAmount(amount, option) {
|
|
3566
3570
|
} = yield nearCall(config.bridgeContractId, "get_config", {});
|
3567
3571
|
const depositAmount = Math.max(Number(min_deposit_amount), Number(amount));
|
3568
3572
|
const protocolFee = Math.max(Number(fee_min), Number(depositAmount) * fee_rate);
|
3569
|
-
const newAccountMinDepositAmount = !(accountInfo == null ? void 0 : accountInfo.nonce) ? NEW_ACCOUNT_MIN_DEPOSIT_AMOUNT : 0;
|
3573
|
+
const newAccountMinDepositAmount = !(accountInfo == null ? void 0 : accountInfo.nonce) && _newAccountMinDepositAmount ? NEW_ACCOUNT_MIN_DEPOSIT_AMOUNT : 0;
|
3570
3574
|
const totalDepositAmount = new Big(depositAmount).plus(protocolFee).plus(repayAmount).plus(newAccountMinDepositAmount).round(0, Big.roundDown).toNumber();
|
3571
3575
|
return {
|
3572
3576
|
depositAmount,
|
@@ -3599,7 +3603,8 @@ function executeBTCDepositAndAction(_0) {
|
|
3599
3603
|
feeRate,
|
3600
3604
|
pollResult = true,
|
3601
3605
|
registerDeposit,
|
3602
|
-
env = "mainnet"
|
3606
|
+
env = "mainnet",
|
3607
|
+
newAccountMinDepositAmount
|
3603
3608
|
}) {
|
3604
3609
|
var _a;
|
3605
3610
|
try {
|
@@ -3618,7 +3623,8 @@ function executeBTCDepositAndAction(_0) {
|
|
3618
3623
|
throw new Error("amount must be greater than 0");
|
3619
3624
|
}
|
3620
3625
|
const { totalDepositAmount, protocolFee, repayAmount } = yield getDepositAmount(depositAmount, {
|
3621
|
-
env
|
3626
|
+
env,
|
3627
|
+
newAccountMinDepositAmount
|
3622
3628
|
});
|
3623
3629
|
const accountInfo = yield getAccountInfo(csna, config.accountContractId);
|
3624
3630
|
const newActions = [];
|
@@ -3995,7 +4001,7 @@ var BTCWallet = (_0) => __async(void 0, [_0], function* ({
|
|
3995
4001
|
if (btcContext.account) {
|
3996
4002
|
const btcPublicKey = yield btcContext.getPublicKey();
|
3997
4003
|
if (btcPublicKey) {
|
3998
|
-
|
4004
|
+
yield getNearAccountByBtcPublicKey(btcPublicKey);
|
3999
4005
|
yield checkSatoshiWhitelist(btcContext.account, env);
|
4000
4006
|
removeWalletButton();
|
4001
4007
|
setupWalletButton(env, wallet, btcContext);
|
@@ -4027,10 +4033,6 @@ var BTCWallet = (_0) => __async(void 0, [_0], function* ({
|
|
4027
4033
|
}
|
4028
4034
|
}));
|
4029
4035
|
context.on("btcLoginError", () => __async(this, null, function* () {
|
4030
|
-
console.log("btcLoginError");
|
4031
|
-
state.clear();
|
4032
|
-
emitter.emit("accountsChanged", { accounts: [] });
|
4033
|
-
yield handleConnectionUpdate();
|
4034
4036
|
}));
|
4035
4037
|
context.on("btcLogOut", () => __async(this, null, function* () {
|
4036
4038
|
console.log("btcLogOut");
|
@@ -4387,7 +4389,7 @@ function setupBTCWallet({
|
|
4387
4389
|
|
4388
4390
|
// src/index.ts
|
4389
4391
|
var getVersion = () => {
|
4390
|
-
return "0.5.
|
4392
|
+
return "0.5.1-beta";
|
4391
4393
|
};
|
4392
4394
|
if (typeof window !== "undefined") {
|
4393
4395
|
window.__BTC_WALLET_VERSION = getVersion();
|