@interchain-kit/react 0.0.1-beta.48 → 0.0.1-beta.49

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.
@@ -8,6 +8,8 @@ import { useCurrentChainWallet } from "./useCurrentChainWallet";
8
8
  export const useChain = (chainName) => {
9
9
  const walletManager = useWalletManager();
10
10
  const chainAccount = useCurrentChainWallet();
11
+ const chain = walletManager.getChainByName(chainName);
12
+ walletManager.currentChainName = chainName;
11
13
  const walletName = chainAccount?.info?.name;
12
14
  const rpcEndpointHook = useRpcEndpoint(chainName, walletName);
13
15
  const accountHook = useAccount(chainName, walletName);
@@ -21,9 +23,9 @@ export const useChain = (chainName) => {
21
23
  walletManager.currentChainName = chainName;
22
24
  open();
23
25
  },
24
- disconnect: () => {
26
+ disconnect: async () => {
25
27
  walletManager.currentChainName = chainName;
26
- chainAccount ?? chainAccount.disconnect();
28
+ await chainAccount?.disconnect();
27
29
  },
28
30
  openView: () => {
29
31
  walletManager.currentChainName = chainName;
@@ -38,7 +40,7 @@ export const useChain = (chainName) => {
38
40
  if (chainAccount && chainAccount?.walletState === WalletState.Connected) {
39
41
  return {
40
42
  logoUrl: walletManager.getChainLogoUrl(chainName),
41
- chain: chainAccount?.chain,
43
+ chain,
42
44
  assetList: chainAccount?.assetList,
43
45
  address: accountHook.account?.address,
44
46
  wallet: chainAccount,
@@ -57,7 +59,7 @@ export const useChain = (chainName) => {
57
59
  }
58
60
  return {
59
61
  logoUrl: walletManager.getChainLogoUrl(chainName),
60
- chain: chainAccount?.chain,
62
+ chain,
61
63
  assetList: chainAccount?.assetList,
62
64
  address: accountHook.account?.address,
63
65
  wallet: chainAccount,
@@ -18,7 +18,7 @@ export const WalletModal = () => {
18
18
  header: _jsx(ConnectingHeader, { wallet: wallet, onBack: gotoWalletList }),
19
19
  content: _jsx(ConnectingContent, { wallet: wallet }),
20
20
  });
21
- if (currentWallet.wallet.info.mode === "extension" &&
21
+ if (currentWallet.wallet?.info.mode === "extension" &&
22
22
  !currentWallet.wallet.isExtensionInstalled) {
23
23
  setModalView({
24
24
  header: (_jsx(NotExistHeader, { wallet: currentWallet, onBack: gotoWalletList })),
@@ -27,7 +27,7 @@ export const WalletModal = () => {
27
27
  return;
28
28
  }
29
29
  try {
30
- if (currentWallet.wallet.info.mode === "wallet-connect") {
30
+ if (currentWallet.wallet?.info.mode === "wallet-connect") {
31
31
  currentWallet.wallet.setOnPairingUriCreatedCallback(() => {
32
32
  setModalView({
33
33
  header: _jsx(QRCodeHeader, { onBack: gotoWalletList }),
package/esm/provider.js CHANGED
@@ -7,10 +7,7 @@ const InterchainWalletContext = createContext(null);
7
7
  export const ChainProvider = ({ chains, assetLists, wallets, signerOptions, endpointOptions, children, }) => {
8
8
  const [_, forceRender] = useState({});
9
9
  const walletManager = useMemo(() => {
10
- const wm = new WalletManager(chains, assetLists, wallets, signerOptions, endpointOptions);
11
- const observable = wm.getObservableObj();
12
- observable.subscribe(() => forceRender({}));
13
- return observable;
10
+ return new WalletManager(chains, assetLists, wallets, signerOptions, endpointOptions, () => forceRender({}));
14
11
  }, []);
15
12
  useEffect(() => {
16
13
  walletManager.init();
package/hooks/useChain.js CHANGED
@@ -11,6 +11,8 @@ const useCurrentChainWallet_1 = require("./useCurrentChainWallet");
11
11
  const useChain = (chainName) => {
12
12
  const walletManager = (0, useWalletManager_1.useWalletManager)();
13
13
  const chainAccount = (0, useCurrentChainWallet_1.useCurrentChainWallet)();
14
+ const chain = walletManager.getChainByName(chainName);
15
+ walletManager.currentChainName = chainName;
14
16
  const walletName = chainAccount?.info?.name;
15
17
  const rpcEndpointHook = (0, useRpcEndpoint_1.useRpcEndpoint)(chainName, walletName);
16
18
  const accountHook = (0, useAccount_1.useAccount)(chainName, walletName);
@@ -24,9 +26,9 @@ const useChain = (chainName) => {
24
26
  walletManager.currentChainName = chainName;
25
27
  open();
26
28
  },
27
- disconnect: () => {
29
+ disconnect: async () => {
28
30
  walletManager.currentChainName = chainName;
29
- chainAccount ?? chainAccount.disconnect();
31
+ await chainAccount?.disconnect();
30
32
  },
31
33
  openView: () => {
32
34
  walletManager.currentChainName = chainName;
@@ -41,7 +43,7 @@ const useChain = (chainName) => {
41
43
  if (chainAccount && chainAccount?.walletState === core_1.WalletState.Connected) {
42
44
  return {
43
45
  logoUrl: walletManager.getChainLogoUrl(chainName),
44
- chain: chainAccount?.chain,
46
+ chain,
45
47
  assetList: chainAccount?.assetList,
46
48
  address: accountHook.account?.address,
47
49
  wallet: chainAccount,
@@ -60,7 +62,7 @@ const useChain = (chainName) => {
60
62
  }
61
63
  return {
62
64
  logoUrl: walletManager.getChainLogoUrl(chainName),
63
- chain: chainAccount?.chain,
65
+ chain,
64
66
  assetList: chainAccount?.assetList,
65
67
  address: accountHook.account?.address,
66
68
  wallet: chainAccount,
package/modal/modal.js CHANGED
@@ -21,7 +21,7 @@ const WalletModal = () => {
21
21
  header: (0, jsx_runtime_1.jsx)(views_1.ConnectingHeader, { wallet: wallet, onBack: gotoWalletList }),
22
22
  content: (0, jsx_runtime_1.jsx)(views_1.ConnectingContent, { wallet: wallet }),
23
23
  });
24
- if (currentWallet.wallet.info.mode === "extension" &&
24
+ if (currentWallet.wallet?.info.mode === "extension" &&
25
25
  !currentWallet.wallet.isExtensionInstalled) {
26
26
  setModalView({
27
27
  header: ((0, jsx_runtime_1.jsx)(views_1.NotExistHeader, { wallet: currentWallet, onBack: gotoWalletList })),
@@ -30,7 +30,7 @@ const WalletModal = () => {
30
30
  return;
31
31
  }
32
32
  try {
33
- if (currentWallet.wallet.info.mode === "wallet-connect") {
33
+ if (currentWallet.wallet?.info.mode === "wallet-connect") {
34
34
  currentWallet.wallet.setOnPairingUriCreatedCallback(() => {
35
35
  setModalView({
36
36
  header: (0, jsx_runtime_1.jsx)(views_1.QRCodeHeader, { onBack: gotoWalletList }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interchain-kit/react",
3
- "version": "0.0.1-beta.48",
3
+ "version": "0.0.1-beta.49",
4
4
  "author": "cosmology-tech <developers@cosmology.zone>",
5
5
  "description": "interchain-kit wallet connector react package",
6
6
  "main": "index.js",
@@ -28,12 +28,12 @@
28
28
  "lint": "eslint . --fix",
29
29
  "test": "jest",
30
30
  "test:watch": "jest --watch",
31
- "dev": "tsc -w --preserveWatchOutput -p tsconfig.esm.json"
31
+ "dev": "tsc -w --preserveWatchOutput"
32
32
  },
33
33
  "keywords": [],
34
34
  "dependencies": {
35
35
  "@chain-registry/v2-types": "^0.53.40",
36
- "@interchain-kit/core": "0.0.1-beta.48",
36
+ "@interchain-kit/core": "0.0.1-beta.49",
37
37
  "@interchain-ui/react": "1.26.1",
38
38
  "@interchainjs/cosmos": "1.6.3",
39
39
  "@interchainjs/cosmos-types": "1.6.3",
@@ -48,5 +48,5 @@
48
48
  "react": "^18.3.1",
49
49
  "react-dom": "^18.3.1"
50
50
  },
51
- "gitHead": "b78c7ffdf4e93298add4400bbc85148996ae5545"
51
+ "gitHead": "4d6dee8065ce9e7180277126a37b6ae5ceb7b4d2"
52
52
  }
package/provider.js CHANGED
@@ -10,10 +10,7 @@ const InterchainWalletContext = (0, react_2.createContext)(null);
10
10
  const ChainProvider = ({ chains, assetLists, wallets, signerOptions, endpointOptions, children, }) => {
11
11
  const [_, forceRender] = (0, react_1.useState)({});
12
12
  const walletManager = (0, react_1.useMemo)(() => {
13
- const wm = new core_1.WalletManager(chains, assetLists, wallets, signerOptions, endpointOptions);
14
- const observable = wm.getObservableObj();
15
- observable.subscribe(() => forceRender({}));
16
- return observable;
13
+ return new core_1.WalletManager(chains, assetLists, wallets, signerOptions, endpointOptions, () => forceRender({}));
17
14
  }, []);
18
15
  (0, react_1.useEffect)(() => {
19
16
  walletManager.init();