@interchain-kit/react 0.2.215 → 0.2.216

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.
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { createContext, useContext, useEffect, useState } from "react";
2
+ import { createContext, useContext, useState } from "react";
3
3
  import { WalletModal } from "./modal";
4
4
  import { WalletState } from "@interchain-kit/core";
5
5
  import { useChainWallet, useWalletManager } from "../hooks";
@@ -9,35 +9,21 @@ export const WalletModalProvider = ({ children, }) => {
9
9
  const [modalIsOpen, setModalIsOpen] = useState(false);
10
10
  const open = () => setModalIsOpen(true);
11
11
  const close = () => setModalIsOpen(false);
12
- const [walletNameToConnect, setWalletNameToConnect] = useState(null);
13
- const { chains, wallets, setCurrentWalletName, currentChainName, currentWalletName, walletConnectQRCodeUri, getDownloadLink, getEnv, } = useWalletManager();
14
- const { wallet, status, connect, disconnect, username, address, message } = useChainWallet(currentChainName || chains[0].chainName, currentWalletName);
12
+ const { chains, wallets, setCurrentWalletName, currentChainName, currentWalletName, walletConnectQRCodeUri, getDownloadLink, getEnv, connect, getAccount, } = useWalletManager();
13
+ const { wallet, status, disconnect, username, address, message } = useChainWallet(currentChainName || chains[0].chainName, currentWalletName);
15
14
  const [shouldShowList, setShouldShowList] = useState(!(currentChainName && currentWalletName));
16
15
  const walletsForUI = wallets.map(transferToWalletUISchema);
17
- useEffect(() => {
18
- const handleConnect = async () => {
19
- if (walletNameToConnect) {
20
- try {
21
- await connect();
22
- setWalletNameToConnect(null);
23
- setShouldShowList(false);
24
- }
25
- catch (error) {
26
- console.error("Error connecting to wallet:", error);
27
- throw error;
28
- }
29
- }
30
- };
31
- handleConnect();
32
- }, [walletNameToConnect]);
33
16
  const handleCloseModal = () => {
34
17
  close();
35
18
  setShouldShowList(false);
36
19
  };
37
- return (_jsxs(WalletModalContext.Provider, { value: { modalIsOpen, open, close }, children: [children, _jsx(WalletModal, { shouldShowList: shouldShowList, username: username, address: address, disconnect: disconnect, isOpen: modalIsOpen, open: open, close: handleCloseModal, wallets: walletsForUI, walletConnectQRCodeUri: walletConnectQRCodeUri, currentWallet: wallet?.originalWallet, isConnecting: status === WalletState.Connecting, isConnected: status === WalletState.Connected, isRejected: status === WalletState.Rejected, isDisconnected: status === WalletState.Disconnected, isNotExist: status === WalletState.NotExist, errorMessage: message, onSelectWallet: (w) => {
38
- setWalletNameToConnect(w.info.name);
39
- setCurrentWalletName(w.info.name);
40
- }, onBack: () => setShouldShowList(true), onReconnect: connect, getDownloadLink: () => getDownloadLink(wallet?.info.name), getEnv: getEnv })] }));
20
+ const handleConnectWallet = async (walletName) => {
21
+ const chainToConnect = currentChainName || chains[0].chainName;
22
+ setShouldShowList(false);
23
+ setCurrentWalletName(walletName);
24
+ await connect(walletName, chainToConnect);
25
+ };
26
+ return (_jsxs(WalletModalContext.Provider, { value: { modalIsOpen, open, close }, children: [children, _jsx(WalletModal, { shouldShowList: shouldShowList, username: username, address: address, disconnect: disconnect, isOpen: modalIsOpen, open: open, close: handleCloseModal, wallets: walletsForUI, walletConnectQRCodeUri: walletConnectQRCodeUri, currentWallet: wallet?.originalWallet, isConnecting: status === WalletState.Connecting, isConnected: status === WalletState.Connected, isRejected: status === WalletState.Rejected, isDisconnected: status === WalletState.Disconnected, isNotExist: status === WalletState.NotExist, errorMessage: message, onSelectWallet: (w) => handleConnectWallet(w.info.name), onBack: () => setShouldShowList(true), onReconnect: () => handleConnectWallet(currentWalletName), getDownloadLink: () => getDownloadLink(wallet?.info.name), getEnv: getEnv })] }));
41
27
  };
42
28
  export const useWalletModal = () => {
43
29
  const context = useContext(WalletModalContext);
@@ -151,6 +151,7 @@ export const createInterchainStore = (walletManager) => {
151
151
  });
152
152
  });
153
153
  get().updateChainWalletState(walletName, chainName, { walletState: WalletState.Connected });
154
+ await get().getAccount(walletName, chainName);
154
155
  }
155
156
  catch (error) {
156
157
  if (error.message === 'Request rejected') {
package/modal/provider.js CHANGED
@@ -12,35 +12,21 @@ const WalletModalProvider = ({ children, }) => {
12
12
  const [modalIsOpen, setModalIsOpen] = (0, react_1.useState)(false);
13
13
  const open = () => setModalIsOpen(true);
14
14
  const close = () => setModalIsOpen(false);
15
- const [walletNameToConnect, setWalletNameToConnect] = (0, react_1.useState)(null);
16
- const { chains, wallets, setCurrentWalletName, currentChainName, currentWalletName, walletConnectQRCodeUri, getDownloadLink, getEnv, } = (0, hooks_1.useWalletManager)();
17
- const { wallet, status, connect, disconnect, username, address, message } = (0, hooks_1.useChainWallet)(currentChainName || chains[0].chainName, currentWalletName);
15
+ const { chains, wallets, setCurrentWalletName, currentChainName, currentWalletName, walletConnectQRCodeUri, getDownloadLink, getEnv, connect, getAccount, } = (0, hooks_1.useWalletManager)();
16
+ const { wallet, status, disconnect, username, address, message } = (0, hooks_1.useChainWallet)(currentChainName || chains[0].chainName, currentWalletName);
18
17
  const [shouldShowList, setShouldShowList] = (0, react_1.useState)(!(currentChainName && currentWalletName));
19
18
  const walletsForUI = wallets.map(utils_1.transferToWalletUISchema);
20
- (0, react_1.useEffect)(() => {
21
- const handleConnect = async () => {
22
- if (walletNameToConnect) {
23
- try {
24
- await connect();
25
- setWalletNameToConnect(null);
26
- setShouldShowList(false);
27
- }
28
- catch (error) {
29
- console.error("Error connecting to wallet:", error);
30
- throw error;
31
- }
32
- }
33
- };
34
- handleConnect();
35
- }, [walletNameToConnect]);
36
19
  const handleCloseModal = () => {
37
20
  close();
38
21
  setShouldShowList(false);
39
22
  };
40
- return ((0, jsx_runtime_1.jsxs)(WalletModalContext.Provider, { value: { modalIsOpen, open, close }, children: [children, (0, jsx_runtime_1.jsx)(modal_1.WalletModal, { shouldShowList: shouldShowList, username: username, address: address, disconnect: disconnect, isOpen: modalIsOpen, open: open, close: handleCloseModal, wallets: walletsForUI, walletConnectQRCodeUri: walletConnectQRCodeUri, currentWallet: wallet?.originalWallet, isConnecting: status === core_1.WalletState.Connecting, isConnected: status === core_1.WalletState.Connected, isRejected: status === core_1.WalletState.Rejected, isDisconnected: status === core_1.WalletState.Disconnected, isNotExist: status === core_1.WalletState.NotExist, errorMessage: message, onSelectWallet: (w) => {
41
- setWalletNameToConnect(w.info.name);
42
- setCurrentWalletName(w.info.name);
43
- }, onBack: () => setShouldShowList(true), onReconnect: connect, getDownloadLink: () => getDownloadLink(wallet?.info.name), getEnv: getEnv })] }));
23
+ const handleConnectWallet = async (walletName) => {
24
+ const chainToConnect = currentChainName || chains[0].chainName;
25
+ setShouldShowList(false);
26
+ setCurrentWalletName(walletName);
27
+ await connect(walletName, chainToConnect);
28
+ };
29
+ return ((0, jsx_runtime_1.jsxs)(WalletModalContext.Provider, { value: { modalIsOpen, open, close }, children: [children, (0, jsx_runtime_1.jsx)(modal_1.WalletModal, { shouldShowList: shouldShowList, username: username, address: address, disconnect: disconnect, isOpen: modalIsOpen, open: open, close: handleCloseModal, wallets: walletsForUI, walletConnectQRCodeUri: walletConnectQRCodeUri, currentWallet: wallet?.originalWallet, isConnecting: status === core_1.WalletState.Connecting, isConnected: status === core_1.WalletState.Connected, isRejected: status === core_1.WalletState.Rejected, isDisconnected: status === core_1.WalletState.Disconnected, isNotExist: status === core_1.WalletState.NotExist, errorMessage: message, onSelectWallet: (w) => handleConnectWallet(w.info.name), onBack: () => setShouldShowList(true), onReconnect: () => handleConnectWallet(currentWalletName), getDownloadLink: () => getDownloadLink(wallet?.info.name), getEnv: getEnv })] }));
44
30
  };
45
31
  exports.WalletModalProvider = WalletModalProvider;
46
32
  const useWalletModal = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interchain-kit/react",
3
- "version": "0.2.215",
3
+ "version": "0.2.216",
4
4
  "author": "Hyperweb <developers@hyperweb.io>",
5
5
  "description": "interchain-kit wallet connector react package",
6
6
  "main": "index.js",
@@ -34,7 +34,7 @@
34
34
  "keywords": [],
35
35
  "dependencies": {
36
36
  "@chain-registry/v2-types": "^0.53.40",
37
- "@interchain-kit/core": "0.2.215",
37
+ "@interchain-kit/core": "0.2.216",
38
38
  "@interchain-ui/react": "1.26.3",
39
39
  "@interchainjs/cosmos": "1.10.1",
40
40
  "@interchainjs/cosmos-types": "1.10.1",
@@ -61,5 +61,5 @@
61
61
  "jest-environment-jsdom": "^29.7.0",
62
62
  "ts-jest": "^29.3.0"
63
63
  },
64
- "gitHead": "f274cd2494b91fc4ed9693e58d8b9f00807ecaed"
64
+ "gitHead": "625f04af4fe4e4107d371acf0b1fc5454b2af0e5"
65
65
  }
package/store/store.js CHANGED
@@ -154,6 +154,7 @@ const createInterchainStore = (walletManager) => {
154
154
  });
155
155
  });
156
156
  get().updateChainWalletState(walletName, chainName, { walletState: core_1.WalletState.Connected });
157
+ await get().getAccount(walletName, chainName);
157
158
  }
158
159
  catch (error) {
159
160
  if (error.message === 'Request rejected') {