@sundaeswap/wallet-lite 0.0.37 → 0.0.38

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sundaeswap/wallet-lite",
3
- "version": "0.0.37",
3
+ "version": "0.0.38",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/index.js",
@@ -1,6 +1,6 @@
1
1
  import type { TransactionUnspentOutput } from "@cardano-sdk/core/dist/cjs/Serialization/index.js";
2
2
  import { AssetAmount, IAssetAmountMetadata } from "@sundaeswap/asset";
3
- import { useCallback, useState, useTransition } from "react";
3
+ import { useCallback, useMemo, useState, useTransition } from "react";
4
4
 
5
5
  import {
6
6
  TAssetAmountMap,
@@ -43,6 +43,15 @@ export const useWalletObserverState = <
43
43
  const [switching, setSwitching] = useState(false);
44
44
  const [isPending, startTransition] = useTransition();
45
45
 
46
+ const willAutoConnect = useMemo(
47
+ () =>
48
+ Boolean(
49
+ window.localStorage.getItem(WalletObserver.PERSISTENCE_CACHE_KEY) &&
50
+ observer.getOptions().persistence
51
+ ),
52
+ [observer]
53
+ );
54
+
46
55
  const disconnect = useCallback(() => {
47
56
  // Reset observer state.
48
57
  observer.disconnect();
@@ -175,5 +184,6 @@ export const useWalletObserverState = <
175
184
  switching,
176
185
  setSwitching,
177
186
  isPending,
187
+ willAutoConnect,
178
188
  };
179
189
  };
@@ -1,5 +1,6 @@
1
1
  import { IAssetAmountMetadata } from "@sundaeswap/asset";
2
2
 
3
+ import { useMemo } from "react";
3
4
  import {
4
5
  TUseWalletObserverState,
5
6
  useWalletObserverContext,
@@ -15,26 +16,50 @@ export const useWalletObserver = <
15
16
  >(): TUseWalletObserverState<AssetMetadata> => {
16
17
  const { state } = useWalletObserverContext<AssetMetadata>();
17
18
 
18
- const result: TUseWalletObserverState<AssetMetadata> = {
19
- isCip45: state.isCip45,
20
- activeWallet: state.activeWallet,
21
- adaBalance: state.adaBalance,
22
- balance: state.balance,
23
- mainAddress: state.mainAddress,
24
- stakeAddress: state.stakeAddress,
25
- network: state.network,
26
- utxos: state.utxos,
27
- collateral: state.collateral,
28
- observer: state.observer,
29
- unusedAddresses: state.unusedAddresses,
30
- usedAddresses: state.usedAddresses,
31
- syncWallet: state.syncWallet,
32
- disconnect: state.disconnect,
33
- connectWallet: state.connectWallet,
34
- switching: state.switching,
35
- isPending: state.isPending,
36
- handles: state.handles,
37
- };
19
+ const result: TUseWalletObserverState<AssetMetadata> = useMemo(
20
+ () => ({
21
+ isCip45: state.isCip45,
22
+ activeWallet: state.activeWallet,
23
+ adaBalance: state.adaBalance,
24
+ balance: state.balance,
25
+ mainAddress: state.mainAddress,
26
+ stakeAddress: state.stakeAddress,
27
+ network: state.network,
28
+ utxos: state.utxos,
29
+ collateral: state.collateral,
30
+ observer: state.observer,
31
+ unusedAddresses: state.unusedAddresses,
32
+ usedAddresses: state.usedAddresses,
33
+ syncWallet: state.syncWallet,
34
+ disconnect: state.disconnect,
35
+ connectWallet: state.connectWallet,
36
+ switching: state.switching,
37
+ isPending: state.isPending,
38
+ handles: state.handles,
39
+ willAutoConnect: state.willAutoConnect,
40
+ }),
41
+ [
42
+ state.isCip45,
43
+ state.activeWallet,
44
+ state.adaBalance.amount,
45
+ state.balance.size,
46
+ state.mainAddress,
47
+ state.stakeAddress,
48
+ state.network,
49
+ state.utxos,
50
+ state.collateral,
51
+ state.observer,
52
+ state.unusedAddresses,
53
+ state.usedAddresses,
54
+ state.syncWallet,
55
+ state.disconnect,
56
+ state.connectWallet,
57
+ state.switching,
58
+ state.isPending,
59
+ state.handles,
60
+ state.willAutoConnect,
61
+ ]
62
+ );
38
63
 
39
64
  return result;
40
65
  };