btc-wallet 0.2.2 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
@@ -4,7 +4,7 @@ export declare function BtcWalletSelectorContextProvider({ children, autoConnect
|
|
4
4
|
autoConnect?: boolean;
|
5
5
|
}): import("react/jsx-runtime").JSX.Element;
|
6
6
|
export declare function useBtcWalletSelector(): {
|
7
|
-
login: () => Promise<null>;
|
7
|
+
login: () => Promise<string | null>;
|
8
8
|
autoConnect: () => Promise<null | undefined>;
|
9
9
|
logout: () => void;
|
10
10
|
account: string | null;
|
package/dist/index.js
CHANGED
@@ -2291,6 +2291,10 @@ function useBtcWalletSelector() {
|
|
2291
2291
|
}, [connector]);
|
2292
2292
|
return {
|
2293
2293
|
login: () => __async(this, null, function* () {
|
2294
|
+
const account = accounts && accounts.length ? accounts[0] : null;
|
2295
|
+
if (account) {
|
2296
|
+
return account;
|
2297
|
+
}
|
2294
2298
|
setUpdater(updater + 1);
|
2295
2299
|
if (openConnectModal) {
|
2296
2300
|
yield openConnectModal();
|
@@ -2311,6 +2315,7 @@ function useBtcWalletSelector() {
|
|
2311
2315
|
}),
|
2312
2316
|
logout: () => {
|
2313
2317
|
disconnect && disconnect();
|
2318
|
+
context.emit("btcLogOut");
|
2314
2319
|
},
|
2315
2320
|
account: accounts && accounts.length ? accounts[0] : null,
|
2316
2321
|
getPublicKey: () => __async(this, null, function* () {
|
@@ -2499,8 +2504,8 @@ var { transfer, functionCall } = import_transactions.actionCreators;
|
|
2499
2504
|
var config = {
|
2500
2505
|
dev: {
|
2501
2506
|
base_url: "https://api.dev.satoshibridge.top/v1",
|
2502
|
-
token: "nbtc1-nsp.
|
2503
|
-
contractId: "dev1-nsp.
|
2507
|
+
token: "nbtc1-nsp.testnet",
|
2508
|
+
contractId: "dev1-nsp.testnet"
|
2504
2509
|
},
|
2505
2510
|
testnet: {
|
2506
2511
|
base_url: "https://api.testnet.satoshibridge.top/v1",
|
@@ -2596,6 +2601,11 @@ var BTCWallet = (_0) => __async(void 0, [_0], function* ({
|
|
2596
2601
|
accounts: []
|
2597
2602
|
});
|
2598
2603
|
}));
|
2604
|
+
context.on("btcLogOut", (e) => __async(void 0, null, function* () {
|
2605
|
+
emitter.emit("accountsChanged", {
|
2606
|
+
accounts: []
|
2607
|
+
});
|
2608
|
+
}));
|
2599
2609
|
if ("autoConnect" in metadata && metadata.autoConnect && localStorage.getItem("near-wallet-selector:selectedWalletId") === '"btc-wallet"') {
|
2600
2610
|
yield btcContext.autoConnect();
|
2601
2611
|
}
|
@@ -2662,7 +2672,9 @@ var BTCWallet = (_0) => __async(void 0, [_0], function* ({
|
|
2662
2672
|
function signOut() {
|
2663
2673
|
return __async(this, null, function* () {
|
2664
2674
|
const btcContext = window.btcContext;
|
2665
|
-
|
2675
|
+
if (metadata.syncLogOut) {
|
2676
|
+
btcContext.logout();
|
2677
|
+
}
|
2666
2678
|
state.clear();
|
2667
2679
|
window.localStorage.removeItem("near-wallet-selector:selectedWalletId");
|
2668
2680
|
removeWalletButton();
|
@@ -2760,7 +2772,12 @@ var BTCWallet = (_0) => __async(void 0, [_0], function* ({
|
|
2760
2772
|
gas_limit: "3000",
|
2761
2773
|
use_near_pay_gas: false
|
2762
2774
|
};
|
2763
|
-
const
|
2775
|
+
const nearAccount = yield provider.query({
|
2776
|
+
request_type: "view_account",
|
2777
|
+
account_id: accountId,
|
2778
|
+
finality: "final"
|
2779
|
+
});
|
2780
|
+
const availableBalance = parseFloat(nearAccount.amount) / __pow(10, 24);
|
2764
2781
|
if (availableBalance > 0.2) {
|
2765
2782
|
intention.use_near_pay_gas = true;
|
2766
2783
|
}
|
@@ -2828,7 +2845,9 @@ function uploadBTCTx(url, data) {
|
|
2828
2845
|
function setupBTCWallet({
|
2829
2846
|
iconUrl = "https://assets.deltatrade.ai/assets/chain/btc.svg",
|
2830
2847
|
deprecated = false,
|
2831
|
-
autoConnect = true
|
2848
|
+
autoConnect = true,
|
2849
|
+
syncLogOut = true,
|
2850
|
+
isDev = false
|
2832
2851
|
} = {}) {
|
2833
2852
|
const btcWallet = () => __async(this, null, function* () {
|
2834
2853
|
return {
|
@@ -2841,7 +2860,9 @@ function setupBTCWallet({
|
|
2841
2860
|
downloadUrl: iconUrl,
|
2842
2861
|
deprecated,
|
2843
2862
|
available: true,
|
2844
|
-
autoConnect
|
2863
|
+
autoConnect,
|
2864
|
+
syncLogOut,
|
2865
|
+
isDev
|
2845
2866
|
},
|
2846
2867
|
init: BTCWallet
|
2847
2868
|
};
|
@@ -2901,7 +2922,7 @@ function pollTransactionStatuses(network, hashes) {
|
|
2901
2922
|
|
2902
2923
|
// src/index.ts
|
2903
2924
|
var getVersion = () => {
|
2904
|
-
return "0.2.
|
2925
|
+
return "0.2.4";
|
2905
2926
|
};
|
2906
2927
|
if (typeof window !== "undefined") {
|
2907
2928
|
window.__PARTICLE_BTC_CONNECT_VERSION = getVersion();
|