@interchain-kit/react 0.0.1-beta.46 → 0.0.1-beta.47

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.
@@ -15,7 +15,14 @@ export const useChain = (chainName) => {
15
15
  const signingClientHook = useInterchainClient(chainName, walletName);
16
16
  const { open, close } = useWalletModal();
17
17
  const cosmosKitUserChainReturnType = {
18
- connect: () => chainAccount.connect(),
18
+ connect: () => {
19
+ if (chainAccount?.walletState === WalletState.Connected) {
20
+ return;
21
+ }
22
+ else {
23
+ open();
24
+ }
25
+ },
19
26
  disconnect: () => chainAccount.disconnect(),
20
27
  openView: open,
21
28
  closeView: close,
@@ -2,6 +2,7 @@ import { useWalletManager } from "./useWalletManager";
2
2
  import { useAccount } from "./useAccount";
3
3
  import { useInterchainClient } from "./useInterchainClient";
4
4
  import { useRpcEndpoint } from "./useRpcEndpoint";
5
+ import { WalletState } from "@interchain-kit/core";
5
6
  export const useChainWallet = (chainName, walletName) => {
6
7
  const walletManager = useWalletManager();
7
8
  const walletRepository = walletManager.getWalletRepositoryByName(walletName);
@@ -10,7 +11,12 @@ export const useChainWallet = (chainName, walletName) => {
10
11
  const accountHook = useAccount(chainName, walletName);
11
12
  const signingClientHook = useInterchainClient(chainName, walletName);
12
13
  return {
13
- connect: () => chainAccount.connect(),
14
+ connect: () => {
15
+ if (!chainAccount && chainAccount.walletState === WalletState.Connected) {
16
+ return;
17
+ }
18
+ chainAccount.connect();
19
+ },
14
20
  disconnect: () => chainAccount.disconnect(),
15
21
  getRpcEndpoint: () => chainAccount.getRpcEndpoint(),
16
22
  status: chainAccount.walletState,
@@ -8,6 +8,7 @@ import { ConnectModal } from "@interchain-ui/react";
8
8
  export const WalletModal = () => {
9
9
  const { modalIsOpen, open, close } = useWalletModal();
10
10
  const currentWallet = useCurrentWallet();
11
+ const currentChainAccount = currentWallet?.getChainAccountByName?.(currentWallet.currentChainName);
11
12
  const walletManager = useWalletManager();
12
13
  const handleSelectWallet = async (wallet) => {
13
14
  const selectedWallet = walletManager.getWalletByName(wallet.info.name);
@@ -55,7 +56,8 @@ export const WalletModal = () => {
55
56
  const [modalView, setModalView] = useState(defaultModalView);
56
57
  const gotoWalletList = () => setModalView(defaultModalView);
57
58
  useEffect(() => {
58
- if (modalIsOpen && currentWallet?.walletState === WalletState.Connected) {
59
+ if (modalIsOpen &&
60
+ currentChainAccount?.walletState === WalletState.Connected) {
59
61
  setModalView({
60
62
  header: _jsx(ConnectedHeader, { onBack: gotoWalletList }),
61
63
  content: _jsx(ConnectedContent, {}),
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { ConnectModalHead, ConnectModalStatus } from "@interchain-ui/react";
3
- import { useAccount, useCurrentWallet, useWalletManager } from "../../hooks";
3
+ import { useAccount, useCurrentWallet } from "../../hooks";
4
4
  import { useWalletModal } from "../provider";
5
5
  import { getWalletInfo } from "../../utils";
6
6
  import { AstronautSvg } from "./Astronaut";
@@ -11,7 +11,7 @@ export const ConnectedHeader = ({ onBack }) => {
11
11
  };
12
12
  export const ConnectedContent = () => {
13
13
  const currentWallet = useCurrentWallet();
14
- const walletManager = useWalletManager();
14
+ const chainAccount = currentWallet?.getChainAccountByName?.(currentWallet.currentChainName);
15
15
  const { account } = useAccount(currentWallet.currentChainName, currentWallet?.info?.name);
16
16
  const { close } = useWalletModal();
17
17
  if (!currentWallet) {
@@ -26,7 +26,7 @@ export const ConnectedContent = () => {
26
26
  } })),
27
27
  address: account?.address,
28
28
  }, onDisconnect: async () => {
29
- await walletManager.disconnect(currentWallet?.info?.name);
29
+ await chainAccount.disconnect();
30
30
  close();
31
31
  } }));
32
32
  };
package/hooks/useChain.js CHANGED
@@ -18,7 +18,14 @@ const useChain = (chainName) => {
18
18
  const signingClientHook = (0, useInterchainClient_1.useInterchainClient)(chainName, walletName);
19
19
  const { open, close } = (0, modal_1.useWalletModal)();
20
20
  const cosmosKitUserChainReturnType = {
21
- connect: () => chainAccount.connect(),
21
+ connect: () => {
22
+ if (chainAccount?.walletState === core_1.WalletState.Connected) {
23
+ return;
24
+ }
25
+ else {
26
+ open();
27
+ }
28
+ },
22
29
  disconnect: () => chainAccount.disconnect(),
23
30
  openView: open,
24
31
  closeView: close,
@@ -5,6 +5,7 @@ const useWalletManager_1 = require("./useWalletManager");
5
5
  const useAccount_1 = require("./useAccount");
6
6
  const useInterchainClient_1 = require("./useInterchainClient");
7
7
  const useRpcEndpoint_1 = require("./useRpcEndpoint");
8
+ const core_1 = require("@interchain-kit/core");
8
9
  const useChainWallet = (chainName, walletName) => {
9
10
  const walletManager = (0, useWalletManager_1.useWalletManager)();
10
11
  const walletRepository = walletManager.getWalletRepositoryByName(walletName);
@@ -13,7 +14,12 @@ const useChainWallet = (chainName, walletName) => {
13
14
  const accountHook = (0, useAccount_1.useAccount)(chainName, walletName);
14
15
  const signingClientHook = (0, useInterchainClient_1.useInterchainClient)(chainName, walletName);
15
16
  return {
16
- connect: () => chainAccount.connect(),
17
+ connect: () => {
18
+ if (!chainAccount && chainAccount.walletState === core_1.WalletState.Connected) {
19
+ return;
20
+ }
21
+ chainAccount.connect();
22
+ },
17
23
  disconnect: () => chainAccount.disconnect(),
18
24
  getRpcEndpoint: () => chainAccount.getRpcEndpoint(),
19
25
  status: chainAccount.walletState,
package/modal/modal.js CHANGED
@@ -11,6 +11,7 @@ const react_2 = require("@interchain-ui/react");
11
11
  const WalletModal = () => {
12
12
  const { modalIsOpen, open, close } = (0, provider_1.useWalletModal)();
13
13
  const currentWallet = (0, hooks_1.useCurrentWallet)();
14
+ const currentChainAccount = currentWallet?.getChainAccountByName?.(currentWallet.currentChainName);
14
15
  const walletManager = (0, hooks_1.useWalletManager)();
15
16
  const handleSelectWallet = async (wallet) => {
16
17
  const selectedWallet = walletManager.getWalletByName(wallet.info.name);
@@ -58,7 +59,8 @@ const WalletModal = () => {
58
59
  const [modalView, setModalView] = (0, react_1.useState)(defaultModalView);
59
60
  const gotoWalletList = () => setModalView(defaultModalView);
60
61
  (0, react_1.useEffect)(() => {
61
- if (modalIsOpen && currentWallet?.walletState === core_1.WalletState.Connected) {
62
+ if (modalIsOpen &&
63
+ currentChainAccount?.walletState === core_1.WalletState.Connected) {
62
64
  setModalView({
63
65
  header: (0, jsx_runtime_1.jsx)(views_1.ConnectedHeader, { onBack: gotoWalletList }),
64
66
  content: (0, jsx_runtime_1.jsx)(views_1.ConnectedContent, {}),
@@ -15,7 +15,7 @@ const ConnectedHeader = ({ onBack }) => {
15
15
  exports.ConnectedHeader = ConnectedHeader;
16
16
  const ConnectedContent = () => {
17
17
  const currentWallet = (0, hooks_1.useCurrentWallet)();
18
- const walletManager = (0, hooks_1.useWalletManager)();
18
+ const chainAccount = currentWallet?.getChainAccountByName?.(currentWallet.currentChainName);
19
19
  const { account } = (0, hooks_1.useAccount)(currentWallet.currentChainName, currentWallet?.info?.name);
20
20
  const { close } = (0, provider_1.useWalletModal)();
21
21
  if (!currentWallet) {
@@ -30,7 +30,7 @@ const ConnectedContent = () => {
30
30
  } })),
31
31
  address: account?.address,
32
32
  }, onDisconnect: async () => {
33
- await walletManager.disconnect(currentWallet?.info?.name);
33
+ await chainAccount.disconnect();
34
34
  close();
35
35
  } }));
36
36
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interchain-kit/react",
3
- "version": "0.0.1-beta.46",
3
+ "version": "0.0.1-beta.47",
4
4
  "author": "cosmology-tech <developers@cosmology.zone>",
5
5
  "description": "interchain-kit wallet connector react package",
6
6
  "main": "index.js",
@@ -33,7 +33,7 @@
33
33
  "keywords": [],
34
34
  "dependencies": {
35
35
  "@chain-registry/v2-types": "^0.53.40",
36
- "@interchain-kit/core": "0.0.1-beta.46",
36
+ "@interchain-kit/core": "0.0.1-beta.47",
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": "c3d891660283751114a218e8abcbc278700442bd"
51
+ "gitHead": "ecd10d66d0c74955a26c75659d998f31663fcb93"
52
52
  }