btc-wallet 0.2.2 → 0.2.4

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.
@@ -9,9 +9,10 @@ interface BTCWalletParams {
9
9
  iconUrl?: string;
10
10
  deprecated?: boolean;
11
11
  autoConnect?: boolean;
12
+ syncLogOut?: boolean;
12
13
  isDev?: boolean;
13
14
  }
14
- export declare function setupBTCWallet({ iconUrl, deprecated, autoConnect, }?: BTCWalletParams | undefined): WalletModuleFactory<InjectedWallet>;
15
+ export declare function setupBTCWallet({ iconUrl, deprecated, autoConnect, syncLogOut, isDev, }?: BTCWalletParams | undefined): WalletModuleFactory<InjectedWallet>;
15
16
  declare const _default: {
16
17
  setupBTCWallet: typeof setupBTCWallet;
17
18
  };
package/esm/index.js CHANGED
@@ -2250,6 +2250,10 @@ function useBtcWalletSelector() {
2250
2250
  }, [connector]);
2251
2251
  return {
2252
2252
  login: () => __async(this, null, function* () {
2253
+ const account = accounts && accounts.length ? accounts[0] : null;
2254
+ if (account) {
2255
+ return account;
2256
+ }
2253
2257
  setUpdater(updater + 1);
2254
2258
  if (openConnectModal) {
2255
2259
  yield openConnectModal();
@@ -2270,6 +2274,7 @@ function useBtcWalletSelector() {
2270
2274
  }),
2271
2275
  logout: () => {
2272
2276
  disconnect && disconnect();
2277
+ context.emit("btcLogOut");
2273
2278
  },
2274
2279
  account: accounts && accounts.length ? accounts[0] : null,
2275
2280
  getPublicKey: () => __async(this, null, function* () {
@@ -2458,8 +2463,8 @@ var { transfer, functionCall } = actionCreators;
2458
2463
  var config = {
2459
2464
  dev: {
2460
2465
  base_url: "https://api.dev.satoshibridge.top/v1",
2461
- token: "nbtc1-nsp.dev",
2462
- contractId: "dev1-nsp.dev"
2466
+ token: "nbtc1-nsp.testnet",
2467
+ contractId: "dev1-nsp.testnet"
2463
2468
  },
2464
2469
  testnet: {
2465
2470
  base_url: "https://api.testnet.satoshibridge.top/v1",
@@ -2555,6 +2560,11 @@ var BTCWallet = (_0) => __async(void 0, [_0], function* ({
2555
2560
  accounts: []
2556
2561
  });
2557
2562
  }));
2563
+ context.on("btcLogOut", (e) => __async(void 0, null, function* () {
2564
+ emitter.emit("accountsChanged", {
2565
+ accounts: []
2566
+ });
2567
+ }));
2558
2568
  if ("autoConnect" in metadata && metadata.autoConnect && localStorage.getItem("near-wallet-selector:selectedWalletId") === '"btc-wallet"') {
2559
2569
  yield btcContext.autoConnect();
2560
2570
  }
@@ -2621,7 +2631,9 @@ var BTCWallet = (_0) => __async(void 0, [_0], function* ({
2621
2631
  function signOut() {
2622
2632
  return __async(this, null, function* () {
2623
2633
  const btcContext = window.btcContext;
2624
- btcContext.logout();
2634
+ if (metadata.syncLogOut) {
2635
+ btcContext.logout();
2636
+ }
2625
2637
  state.clear();
2626
2638
  window.localStorage.removeItem("near-wallet-selector:selectedWalletId");
2627
2639
  removeWalletButton();
@@ -2719,7 +2731,12 @@ var BTCWallet = (_0) => __async(void 0, [_0], function* ({
2719
2731
  gas_limit: "3000",
2720
2732
  use_near_pay_gas: false
2721
2733
  };
2722
- const availableBalance = parseFloat(accountInfo.available_balance) / __pow(10, 24);
2734
+ const nearAccount = yield provider.query({
2735
+ request_type: "view_account",
2736
+ account_id: accountId,
2737
+ finality: "final"
2738
+ });
2739
+ const availableBalance = parseFloat(nearAccount.amount) / __pow(10, 24);
2723
2740
  if (availableBalance > 0.2) {
2724
2741
  intention.use_near_pay_gas = true;
2725
2742
  }
@@ -2787,7 +2804,9 @@ function uploadBTCTx(url, data) {
2787
2804
  function setupBTCWallet({
2788
2805
  iconUrl = "https://assets.deltatrade.ai/assets/chain/btc.svg",
2789
2806
  deprecated = false,
2790
- autoConnect = true
2807
+ autoConnect = true,
2808
+ syncLogOut = true,
2809
+ isDev = false
2791
2810
  } = {}) {
2792
2811
  const btcWallet = () => __async(this, null, function* () {
2793
2812
  return {
@@ -2800,7 +2819,9 @@ function setupBTCWallet({
2800
2819
  downloadUrl: iconUrl,
2801
2820
  deprecated,
2802
2821
  available: true,
2803
- autoConnect
2822
+ autoConnect,
2823
+ syncLogOut,
2824
+ isDev
2804
2825
  },
2805
2826
  init: BTCWallet
2806
2827
  };
@@ -2860,7 +2881,7 @@ function pollTransactionStatuses(network, hashes) {
2860
2881
 
2861
2882
  // src/index.ts
2862
2883
  var getVersion = () => {
2863
- return "0.2.2";
2884
+ return "0.2.4";
2864
2885
  };
2865
2886
  if (typeof window !== "undefined") {
2866
2887
  window.__PARTICLE_BTC_CONNECT_VERSION = getVersion();