btc-wallet 0.4.8-beta → 0.5.1-beta
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +3 -1
- package/dist/core/btcUtils.d.ts +4 -1
- package/dist/index.js +21 -18
- package/dist/index.js.map +2 -2
- package/esm/index.js +21 -18
- package/esm/index.js.map +2 -2
- package/package.json +2 -1
package/README.md
CHANGED
@@ -69,6 +69,7 @@ interface ExecuteBTCDepositAndActionParams<T extends boolean = true> {
|
|
69
69
|
env?: 'mainnet' | 'testnet' | 'private_mainnet' | 'dev'; // optional: defaults to NEAR network environment
|
70
70
|
pollResult?: T; // optional: whether to poll for transaction result
|
71
71
|
registerDeposit?: string; // optional: whether to register deposit,default 0.000125 NEAR
|
72
|
+
newAccountMinDepositAmount?: boolean; // default is true, if true, new account minimum deposit BTC amount 1000sat, otherwise 0
|
72
73
|
}
|
73
74
|
|
74
75
|
// Example 1: dApp one-click BTC deposit
|
@@ -110,7 +111,8 @@ import { getDepositAmount } from 'btc-wallet';
|
|
110
111
|
const result = await getDepositAmount(
|
111
112
|
amount: string, // Amount in satoshi units
|
112
113
|
options?: {
|
113
|
-
env?: 'mainnet' | 'testnet' | 'private_mainnet' | 'dev' // Optional: Defaults to NEAR network environment
|
114
|
+
env?: 'mainnet' | 'testnet' | 'private_mainnet' | 'dev', // Optional: Defaults to NEAR network environment
|
115
|
+
newAccountMinDepositAmount?: boolean // default is true, if true, new account minimum deposit amount 1000sat, otherwise 0
|
114
116
|
}
|
115
117
|
);
|
116
118
|
|
package/dist/core/btcUtils.d.ts
CHANGED
@@ -39,6 +39,8 @@ export declare function estimateDepositAmount(amount: string, option?: {
|
|
39
39
|
}): Promise<string>;
|
40
40
|
export declare function getDepositAmount(amount: string, option?: {
|
41
41
|
env?: ENV;
|
42
|
+
/** default is true, if true, new account minimum deposit amount 1000sat, otherwise 0 */
|
43
|
+
newAccountMinDepositAmount?: boolean;
|
42
44
|
}): Promise<{
|
43
45
|
depositAmount: number;
|
44
46
|
totalDepositAmount: number;
|
@@ -59,12 +61,13 @@ interface ExecuteBTCDepositAndActionParams<T extends boolean = true> {
|
|
59
61
|
feeRate?: number;
|
60
62
|
env?: ENV;
|
61
63
|
pollResult?: T;
|
64
|
+
newAccountMinDepositAmount?: boolean;
|
62
65
|
}
|
63
66
|
/**
|
64
67
|
* @param T - if true, return the poll result, otherwise return the btcTxHash
|
65
68
|
*/
|
66
69
|
type ExecuteBTCDepositAndActionReturn<T extends boolean> = T extends true ? FinalExecutionOutcome[] : string;
|
67
|
-
export declare function executeBTCDepositAndAction<T extends boolean = true>({ action, amount, feeRate, pollResult, registerDeposit, env, }: ExecuteBTCDepositAndActionParams<T>): Promise<ExecuteBTCDepositAndActionReturn<T>>;
|
70
|
+
export declare function executeBTCDepositAndAction<T extends boolean = true>({ action, amount, feeRate, pollResult, registerDeposit, env, newAccountMinDepositAmount, }: ExecuteBTCDepositAndActionParams<T>): Promise<ExecuteBTCDepositAndActionReturn<T>>;
|
68
71
|
export declare function checkSatoshiWhitelist(btcAccountId: string, env?: ENV): Promise<void>;
|
69
72
|
interface WithdrawParams {
|
70
73
|
amount: string | number;
|
package/dist/index.js
CHANGED
@@ -2855,6 +2855,7 @@ function useBtcWalletSelector() {
|
|
2855
2855
|
}),
|
2856
2856
|
autoConnect: () => __async(this, null, function* () {
|
2857
2857
|
requestDirectAccount(connectorRef.current).catch((e) => {
|
2858
|
+
console.error("btcLoginError", e);
|
2858
2859
|
context.emit("btcLoginError");
|
2859
2860
|
});
|
2860
2861
|
}),
|
@@ -2924,16 +2925,16 @@ var walletConfig = {
|
|
2924
2925
|
token: "nbtc.toalice.near",
|
2925
2926
|
accountContractId: "acc.toalice.near",
|
2926
2927
|
bridgeContractId: "brg.toalice.near",
|
2927
|
-
walletUrl: "
|
2928
|
-
bridgeUrl: "https://ramp.satos.network
|
2928
|
+
walletUrl: "http://localhost:3100",
|
2929
|
+
bridgeUrl: "https://old.ramp.satos.network"
|
2929
2930
|
},
|
2930
2931
|
mainnet: {
|
2931
|
-
base_url: "https://api.
|
2932
|
-
token: "nbtc.
|
2933
|
-
accountContractId: "acc.
|
2934
|
-
bridgeContractId: "
|
2932
|
+
base_url: "https://api.satos.network",
|
2933
|
+
token: "nbtc.bridge.near",
|
2934
|
+
accountContractId: "acc.ref-labs.near",
|
2935
|
+
bridgeContractId: "btc-connector.bridge.near",
|
2935
2936
|
walletUrl: "https://wallet.satoshibridge.top",
|
2936
|
-
bridgeUrl: "https://
|
2937
|
+
bridgeUrl: "https://ramp.satos.network"
|
2937
2938
|
}
|
2938
2939
|
};
|
2939
2940
|
var nearRpcUrls = {
|
@@ -3006,6 +3007,7 @@ function createFloatingButtonWithIframe({
|
|
3006
3007
|
userSelect: "none"
|
3007
3008
|
});
|
3008
3009
|
document.body.appendChild(button);
|
3010
|
+
updateIframePosition(iframe, right, bottom, windowWidth, windowHeight);
|
3009
3011
|
let isDragging = false;
|
3010
3012
|
let startX = 0;
|
3011
3013
|
let startY = 0;
|
@@ -3445,10 +3447,11 @@ var NBTC_STORAGE_DEPOSIT_AMOUNT = "3000";
|
|
3445
3447
|
var GAS_LIMIT = "50000000000000";
|
3446
3448
|
var NEW_ACCOUNT_MIN_DEPOSIT_AMOUNT = "1000";
|
3447
3449
|
function getBtcProvider() {
|
3448
|
-
|
3450
|
+
var _a, _b;
|
3451
|
+
if (typeof window === "undefined" || !window.btcContext && !((_a = window.top) == null ? void 0 : _a.btcContext)) {
|
3449
3452
|
throw new Error("BTC Provider is not initialized.");
|
3450
3453
|
}
|
3451
|
-
return window.btcContext;
|
3454
|
+
return window.btcContext || ((_b = window.top) == null ? void 0 : _b.btcContext);
|
3452
3455
|
}
|
3453
3456
|
function getNetwork() {
|
3454
3457
|
return __async(this, null, function* () {
|
@@ -3602,7 +3605,9 @@ function estimateDepositAmount(amount, option) {
|
|
3602
3605
|
}
|
3603
3606
|
function getDepositAmount(amount, option) {
|
3604
3607
|
return __async(this, null, function* () {
|
3608
|
+
var _a;
|
3605
3609
|
const env = (option == null ? void 0 : option.env) || "mainnet";
|
3610
|
+
const _newAccountMinDepositAmount = (_a = option == null ? void 0 : option.newAccountMinDepositAmount) != null ? _a : true;
|
3606
3611
|
const config = yield getConfig(env);
|
3607
3612
|
const csna = yield getCsnaAccountId(env);
|
3608
3613
|
const accountInfo = yield getAccountInfo(csna, config.accountContractId);
|
@@ -3614,7 +3619,7 @@ function getDepositAmount(amount, option) {
|
|
3614
3619
|
} = yield nearCall(config.bridgeContractId, "get_config", {});
|
3615
3620
|
const depositAmount = Math.max(Number(min_deposit_amount), Number(amount));
|
3616
3621
|
const protocolFee = Math.max(Number(fee_min), Number(depositAmount) * fee_rate);
|
3617
|
-
const newAccountMinDepositAmount = !(accountInfo == null ? void 0 : accountInfo.nonce) ? NEW_ACCOUNT_MIN_DEPOSIT_AMOUNT : 0;
|
3622
|
+
const newAccountMinDepositAmount = !(accountInfo == null ? void 0 : accountInfo.nonce) && _newAccountMinDepositAmount ? NEW_ACCOUNT_MIN_DEPOSIT_AMOUNT : 0;
|
3618
3623
|
const totalDepositAmount = new import_big.default(depositAmount).plus(protocolFee).plus(repayAmount).plus(newAccountMinDepositAmount).round(0, import_big.default.roundDown).toNumber();
|
3619
3624
|
return {
|
3620
3625
|
depositAmount,
|
@@ -3647,7 +3652,8 @@ function executeBTCDepositAndAction(_0) {
|
|
3647
3652
|
feeRate,
|
3648
3653
|
pollResult = true,
|
3649
3654
|
registerDeposit,
|
3650
|
-
env = "mainnet"
|
3655
|
+
env = "mainnet",
|
3656
|
+
newAccountMinDepositAmount
|
3651
3657
|
}) {
|
3652
3658
|
var _a;
|
3653
3659
|
try {
|
@@ -3666,7 +3672,8 @@ function executeBTCDepositAndAction(_0) {
|
|
3666
3672
|
throw new Error("amount must be greater than 0");
|
3667
3673
|
}
|
3668
3674
|
const { totalDepositAmount, protocolFee, repayAmount } = yield getDepositAmount(depositAmount, {
|
3669
|
-
env
|
3675
|
+
env,
|
3676
|
+
newAccountMinDepositAmount
|
3670
3677
|
});
|
3671
3678
|
const accountInfo = yield getAccountInfo(csna, config.accountContractId);
|
3672
3679
|
const newActions = [];
|
@@ -4043,7 +4050,7 @@ var BTCWallet = (_0) => __async(void 0, [_0], function* ({
|
|
4043
4050
|
if (btcContext.account) {
|
4044
4051
|
const btcPublicKey = yield btcContext.getPublicKey();
|
4045
4052
|
if (btcPublicKey) {
|
4046
|
-
|
4053
|
+
yield getNearAccountByBtcPublicKey(btcPublicKey);
|
4047
4054
|
yield checkSatoshiWhitelist(btcContext.account, env);
|
4048
4055
|
removeWalletButton();
|
4049
4056
|
setupWalletButton(env, wallet, btcContext);
|
@@ -4075,10 +4082,6 @@ var BTCWallet = (_0) => __async(void 0, [_0], function* ({
|
|
4075
4082
|
}
|
4076
4083
|
}));
|
4077
4084
|
context.on("btcLoginError", () => __async(this, null, function* () {
|
4078
|
-
console.log("btcLoginError");
|
4079
|
-
state.clear();
|
4080
|
-
emitter.emit("accountsChanged", { accounts: [] });
|
4081
|
-
yield handleConnectionUpdate();
|
4082
4085
|
}));
|
4083
4086
|
context.on("btcLogOut", () => __async(this, null, function* () {
|
4084
4087
|
console.log("btcLogOut");
|
@@ -4435,7 +4438,7 @@ function setupBTCWallet({
|
|
4435
4438
|
|
4436
4439
|
// src/index.ts
|
4437
4440
|
var getVersion = () => {
|
4438
|
-
return "0.
|
4441
|
+
return "0.5.1-beta";
|
4439
4442
|
};
|
4440
4443
|
if (typeof window !== "undefined") {
|
4441
4444
|
window.__BTC_WALLET_VERSION = getVersion();
|