btc-wallet 0.2.3 → 0.2.5

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* () {
@@ -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
- btcContext.logout();
2675
+ if (metadata.syncLogOut) {
2676
+ btcContext.logout();
2677
+ }
2666
2678
  state.clear();
2667
2679
  window.localStorage.removeItem("near-wallet-selector:selectedWalletId");
2668
2680
  removeWalletButton();
@@ -2755,10 +2767,10 @@ var BTCWallet = (_0) => __async(void 0, [_0], function* ({
2755
2767
  chain_id: "397",
2756
2768
  csna: accountId,
2757
2769
  near_transactions: newTransactions.map((t) => t.txHex),
2758
- nonce,
2759
2770
  gas_token: currentConfig.token,
2760
2771
  gas_limit: "3000",
2761
- use_near_pay_gas: false
2772
+ use_near_pay_gas: false,
2773
+ nonce
2762
2774
  };
2763
2775
  const nearAccount = yield provider.query({
2764
2776
  request_type: "view_account",
@@ -2834,6 +2846,7 @@ function setupBTCWallet({
2834
2846
  iconUrl = "https://assets.deltatrade.ai/assets/chain/btc.svg",
2835
2847
  deprecated = false,
2836
2848
  autoConnect = true,
2849
+ syncLogOut = true,
2837
2850
  isDev = false
2838
2851
  } = {}) {
2839
2852
  const btcWallet = () => __async(this, null, function* () {
@@ -2848,6 +2861,7 @@ function setupBTCWallet({
2848
2861
  deprecated,
2849
2862
  available: true,
2850
2863
  autoConnect,
2864
+ syncLogOut,
2851
2865
  isDev
2852
2866
  },
2853
2867
  init: BTCWallet
@@ -2908,7 +2922,7 @@ function pollTransactionStatuses(network, hashes) {
2908
2922
 
2909
2923
  // src/index.ts
2910
2924
  var getVersion = () => {
2911
- return "0.2.3";
2925
+ return "0.2.5";
2912
2926
  };
2913
2927
  if (typeof window !== "undefined") {
2914
2928
  window.__PARTICLE_BTC_CONNECT_VERSION = getVersion();