@interchain-kit/react 0.0.1-beta.38 → 0.0.1-beta.39

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.
@@ -13,7 +13,7 @@ export const useAccount = (chainName, walletName) => {
13
13
  const getAccount = async () => {
14
14
  if (wallet && chain) {
15
15
  if (wallet.walletState === WalletState.Connected) {
16
- const account = await wallet.getAccount(chain.chainId);
16
+ const account = await walletManager.getAccount(walletName, chainName);
17
17
  setAccount(account);
18
18
  }
19
19
  if (wallet.walletState === WalletState.Disconnected) {
@@ -3,28 +3,30 @@ import { ConnectedContent, ConnectedHeader, ConnectingContent, ConnectingHeader,
3
3
  import { useWalletModal } from "./provider";
4
4
  import { useCurrentWallet, useWalletManager } from "../hooks";
5
5
  import { useEffect, useMemo, useState } from "react";
6
- import { WalletState } from "@interchain-kit/core";
6
+ import { WalletState, } from "@interchain-kit/core";
7
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
11
  const walletManager = useWalletManager();
12
12
  const handleSelectWallet = async (wallet) => {
13
+ const selectedWallet = walletManager.getWalletByName(wallet.info.name);
13
14
  setModalView({
14
15
  header: _jsx(ConnectingHeader, { wallet: wallet, onBack: gotoWalletList }),
15
16
  content: _jsx(ConnectingContent, { wallet: wallet }),
16
17
  });
17
- if (wallet.info.mode === "extension" &&
18
- !wallet.isExtensionInstalled) {
18
+ if (selectedWallet.info.mode === "extension" &&
19
+ !selectedWallet.isExtensionInstalled) {
19
20
  setModalView({
20
- header: _jsx(NotExistHeader, { wallet: wallet, onBack: gotoWalletList }),
21
- content: _jsx(NotExistContent, { wallet: wallet }),
21
+ header: (_jsx(NotExistHeader, { wallet: selectedWallet, onBack: gotoWalletList })),
22
+ content: _jsx(NotExistContent, { wallet: selectedWallet }),
22
23
  });
23
24
  return;
24
25
  }
25
26
  try {
26
- if (wallet.info.mode === "wallet-connect") {
27
- wallet.events.on("displayWalletConnectQRCodeUri", (uri) => {
27
+ if (selectedWallet.info.mode === "wallet-connect") {
28
+ selectedWallet.setPairingToConnect(wallet.pairing);
29
+ selectedWallet.events.on("displayWalletConnectQRCodeUri", (uri) => {
28
30
  if (uri) {
29
31
  setModalView({
30
32
  header: _jsx(QRCodeHeader, { onBack: gotoWalletList }),
@@ -33,7 +35,7 @@ export const WalletModal = () => {
33
35
  }
34
36
  });
35
37
  }
36
- await walletManager.connect(wallet?.info?.name);
38
+ await walletManager.connect(selectedWallet?.info?.name);
37
39
  setModalView({
38
40
  header: _jsx(ConnectedHeader, { onBack: gotoWalletList }),
39
41
  content: _jsx(ConnectedContent, {}),
@@ -15,8 +15,26 @@ export const WalletListContent = ({ onSelectWallet, }) => {
15
15
  logo: w.info.logo,
16
16
  mobileDisabled: true,
17
17
  shape: "list",
18
- originalWallet: w,
18
+ originalWallet: {
19
+ ...w,
20
+ pairing: null,
21
+ },
19
22
  };
20
23
  });
24
+ const wcWallet = walletManager.wallets.find((w) => w.info.mode === "wallet-connect");
25
+ if (wcWallet) {
26
+ const activePairings = wcWallet.getActivePairing();
27
+ activePairings.forEach((pairing) => {
28
+ wallets.push({
29
+ name: pairing.peerMetadata.name,
30
+ prettyName: pairing.peerMetadata.name,
31
+ logo: pairing.peerMetadata.icons[0],
32
+ mobileDisabled: true,
33
+ shape: "list",
34
+ originalWallet: { ...wcWallet, pairing },
35
+ subLogo: wcWallet.info.logo,
36
+ });
37
+ });
38
+ }
21
39
  return (_jsx(ConnectModalWalletList, { wallets: wallets, onWalletItemClick: onSelectWallet }));
22
40
  };
@@ -16,7 +16,7 @@ const useAccount = (chainName, walletName) => {
16
16
  const getAccount = async () => {
17
17
  if (wallet && chain) {
18
18
  if (wallet.walletState === core_1.WalletState.Connected) {
19
- const account = await wallet.getAccount(chain.chainId);
19
+ const account = await walletManager.getAccount(walletName, chainName);
20
20
  setAccount(account);
21
21
  }
22
22
  if (wallet.walletState === core_1.WalletState.Disconnected) {
package/modal/modal.js CHANGED
@@ -13,21 +13,23 @@ const WalletModal = () => {
13
13
  const currentWallet = (0, hooks_1.useCurrentWallet)();
14
14
  const walletManager = (0, hooks_1.useWalletManager)();
15
15
  const handleSelectWallet = async (wallet) => {
16
+ const selectedWallet = walletManager.getWalletByName(wallet.info.name);
16
17
  setModalView({
17
18
  header: (0, jsx_runtime_1.jsx)(views_1.ConnectingHeader, { wallet: wallet, onBack: gotoWalletList }),
18
19
  content: (0, jsx_runtime_1.jsx)(views_1.ConnectingContent, { wallet: wallet }),
19
20
  });
20
- if (wallet.info.mode === "extension" &&
21
- !wallet.isExtensionInstalled) {
21
+ if (selectedWallet.info.mode === "extension" &&
22
+ !selectedWallet.isExtensionInstalled) {
22
23
  setModalView({
23
- header: (0, jsx_runtime_1.jsx)(views_1.NotExistHeader, { wallet: wallet, onBack: gotoWalletList }),
24
- content: (0, jsx_runtime_1.jsx)(views_1.NotExistContent, { wallet: wallet }),
24
+ header: ((0, jsx_runtime_1.jsx)(views_1.NotExistHeader, { wallet: selectedWallet, onBack: gotoWalletList })),
25
+ content: (0, jsx_runtime_1.jsx)(views_1.NotExistContent, { wallet: selectedWallet }),
25
26
  });
26
27
  return;
27
28
  }
28
29
  try {
29
- if (wallet.info.mode === "wallet-connect") {
30
- wallet.events.on("displayWalletConnectQRCodeUri", (uri) => {
30
+ if (selectedWallet.info.mode === "wallet-connect") {
31
+ selectedWallet.setPairingToConnect(wallet.pairing);
32
+ selectedWallet.events.on("displayWalletConnectQRCodeUri", (uri) => {
31
33
  if (uri) {
32
34
  setModalView({
33
35
  header: (0, jsx_runtime_1.jsx)(views_1.QRCodeHeader, { onBack: gotoWalletList }),
@@ -36,7 +38,7 @@ const WalletModal = () => {
36
38
  }
37
39
  });
38
40
  }
39
- await walletManager.connect(wallet?.info?.name);
41
+ await walletManager.connect(selectedWallet?.info?.name);
40
42
  setModalView({
41
43
  header: (0, jsx_runtime_1.jsx)(views_1.ConnectedHeader, { onBack: gotoWalletList }),
42
44
  content: (0, jsx_runtime_1.jsx)(views_1.ConnectedContent, {}),
@@ -19,9 +19,27 @@ const WalletListContent = ({ onSelectWallet, }) => {
19
19
  logo: w.info.logo,
20
20
  mobileDisabled: true,
21
21
  shape: "list",
22
- originalWallet: w,
22
+ originalWallet: {
23
+ ...w,
24
+ pairing: null,
25
+ },
23
26
  };
24
27
  });
28
+ const wcWallet = walletManager.wallets.find((w) => w.info.mode === "wallet-connect");
29
+ if (wcWallet) {
30
+ const activePairings = wcWallet.getActivePairing();
31
+ activePairings.forEach((pairing) => {
32
+ wallets.push({
33
+ name: pairing.peerMetadata.name,
34
+ prettyName: pairing.peerMetadata.name,
35
+ logo: pairing.peerMetadata.icons[0],
36
+ mobileDisabled: true,
37
+ shape: "list",
38
+ originalWallet: { ...wcWallet, pairing },
39
+ subLogo: wcWallet.info.logo,
40
+ });
41
+ });
42
+ }
25
43
  return ((0, jsx_runtime_1.jsx)(react_1.ConnectModalWalletList, { wallets: wallets, onWalletItemClick: onSelectWallet }));
26
44
  };
27
45
  exports.WalletListContent = WalletListContent;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interchain-kit/react",
3
- "version": "0.0.1-beta.38",
3
+ "version": "0.0.1-beta.39",
4
4
  "author": "cosmology-tech <developers@cosmology.zone>",
5
5
  "description": "interchain-kit wallet connector react package",
6
6
  "main": "index.js",
@@ -33,16 +33,17 @@
33
33
  "keywords": [],
34
34
  "dependencies": {
35
35
  "@chain-registry/v2-types": "^0.53.0",
36
- "@interchain-kit/core": "0.0.1-beta.38",
36
+ "@interchain-kit/core": "0.0.1-beta.39",
37
37
  "@interchain-ui/react": "1.24.0",
38
38
  "@interchainjs/cosmos": "^0.0.1-beta.34",
39
39
  "@interchainjs/cosmos-types": "0.0.1-beta.17",
40
40
  "@react-icons/all-files": "^4.1.0",
41
41
  "@types/react": "^18.3.3",
42
42
  "@types/react-dom": "^18.3.0",
43
+ "@walletconnect/types": "^2.17.2",
43
44
  "interchainjs": "0.0.1-beta.27",
44
45
  "react": "^18.3.1",
45
46
  "react-dom": "^18.3.1"
46
47
  },
47
- "gitHead": "a4ef44d9a18e2d3460c760bf30b24685dd49e7f3"
48
+ "gitHead": "efdd2e96b38b8c828b750094865ecf9903c40b25"
48
49
  }