@interchain-kit/react 0.0.1-beta.3 → 0.0.1-beta.30

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.
Files changed (66) hide show
  1. package/README.md +163 -12
  2. package/esm/hooks/index.js +2 -1
  3. package/esm/hooks/useAccount.js +22 -11
  4. package/esm/hooks/useChain.js +37 -5
  5. package/esm/hooks/useChainWallet.js +1 -0
  6. package/esm/hooks/useConfig.js +10 -0
  7. package/esm/hooks/useCurrentWallet.js +14 -0
  8. package/esm/hooks/useInterchainClient.js +38 -39
  9. package/esm/hooks/useOfflineSigner.js +15 -0
  10. package/esm/hooks/useWalletManager.js +2 -2
  11. package/esm/modal/modal.js +45 -13
  12. package/esm/modal/provider.js +1 -2
  13. package/esm/modal/views/Astronaut.js +4 -0
  14. package/esm/modal/views/Connected.js +32 -0
  15. package/esm/modal/views/Connecting.js +33 -0
  16. package/esm/modal/views/QRCode.js +19 -0
  17. package/esm/modal/views/Reject.js +16 -0
  18. package/esm/modal/views/WalletList.js +32 -0
  19. package/esm/modal/views/index.js +5 -0
  20. package/esm/provider.js +9 -9
  21. package/esm/utils/index.js +1 -1
  22. package/esm/utils/wallet.js +8 -0
  23. package/hooks/index.d.ts +2 -1
  24. package/hooks/index.js +2 -1
  25. package/hooks/useAccount.d.ts +1 -1
  26. package/hooks/useAccount.js +21 -10
  27. package/hooks/useChain.d.ts +2 -2
  28. package/hooks/useChain.js +37 -5
  29. package/hooks/useChainWallet.js +1 -0
  30. package/hooks/useConfig.d.ts +8 -0
  31. package/hooks/useConfig.js +14 -0
  32. package/hooks/useCurrentWallet.d.ts +1 -0
  33. package/hooks/useCurrentWallet.js +18 -0
  34. package/hooks/useInterchainClient.d.ts +8 -7
  35. package/hooks/useInterchainClient.js +38 -39
  36. package/hooks/useOfflineSigner.d.ts +4 -0
  37. package/hooks/useOfflineSigner.js +19 -0
  38. package/hooks/useWalletManager.js +1 -1
  39. package/modal/modal.js +43 -11
  40. package/modal/provider.js +1 -2
  41. package/modal/views/Astronaut.d.ts +2 -0
  42. package/modal/views/Astronaut.js +8 -0
  43. package/modal/views/Connected.d.ts +4 -0
  44. package/modal/views/Connected.js +37 -0
  45. package/modal/views/Connecting.d.ts +4 -0
  46. package/modal/views/Connecting.js +38 -0
  47. package/modal/views/QRCode.d.ts +4 -0
  48. package/modal/views/QRCode.js +24 -0
  49. package/modal/views/Reject.d.ts +4 -0
  50. package/modal/views/Reject.js +21 -0
  51. package/modal/views/WalletList.d.ts +2 -0
  52. package/modal/views/WalletList.js +37 -0
  53. package/modal/views/index.d.ts +5 -0
  54. package/modal/views/index.js +21 -0
  55. package/package.json +10 -5
  56. package/provider.d.ts +6 -6
  57. package/provider.js +9 -9
  58. package/types/chain.d.ts +20 -9
  59. package/types/wallet.d.ts +1 -1
  60. package/utils/index.d.ts +1 -0
  61. package/utils/index.js +16 -0
  62. package/utils/wallet.d.ts +7 -0
  63. package/utils/wallet.js +12 -0
  64. package/esm/hooks/useActiveWallet.js +0 -5
  65. package/hooks/useActiveWallet.d.ts +0 -1
  66. package/hooks/useActiveWallet.js +0 -9
package/README.md CHANGED
@@ -1,22 +1,173 @@
1
- # react
2
-
3
1
  <p align="center">
4
2
  <img src="https://user-images.githubusercontent.com/545047/188804067-28e67e5e-0214-4449-ab04-2e0c564a6885.svg" width="80"><br />
5
- interchain-kit wallet connector react package
3
+ @interchain-kit/react
6
4
  </p>
7
5
 
8
- ## install
9
-
6
+ ## Install
7
+ Using npm:
8
+ ```sh
9
+ npm install @interchain-kit/react
10
+ ```
11
+ Using yarn:
10
12
  ```sh
11
- npm install react
13
+ yarn add @interchain-kit/react
14
+ ```
15
+
16
+ ## Usage
17
+ ### Setup
18
+ #### import chain registry info that you need
19
+ ```js
20
+ import { ChainProvider, useChain } from "@interchain-kit/react";
21
+ import { keplrWallet } from "@interchain-kit/keplr-extension";
22
+ import { ThemeProvider } from "@interchain-ui/react";
23
+ import "@interchain-ui/react/styles";
24
+
25
+ import { chain as junoChain, assetList as junoAssetList } from "@chain-registry/v2/mainnet/juno";
26
+ import { chain as osmosisChain,assetList as osmosisAssetList } from "@chain-registry/v2/mainnet/osmosis";
27
+ import { chain as cosmoshubChain, assetList as cosmoshubAssetList } from "@chain-registry/v2/mainnet/cosmoshub";
28
+
29
+ const Show = () => {
30
+ const {address} = useChain('osmosis');
31
+ // will show cosmoshub address from what you selected wallet in modal
32
+ return <div>{address}</div>;
33
+ };
34
+
35
+ function App() {
36
+ return (
37
+ <ThemeProvider>
38
+ <ChainProvider
39
+ chains={[osmosisChain, junoChain, cosmoshubChain]}
40
+ assetLists={[osmosisAssetList, junoAssetList, cosmoshubAssetList]}
41
+ wallets={[keplrWallet]}
42
+ signerOptions={{}}
43
+ endpointOptions={{}}
44
+ >
45
+ <Show />
46
+ </ChainProvider>
47
+ </ThemeProvider>
48
+ );
49
+ }
50
+
51
+ export default App;
52
+ ```
53
+
54
+ #### or import all chain registry
55
+ ```js
56
+ import { ChainProvider, useChain } from "@interchain-kit/react";
57
+ import { keplrWallet } from "@interchain-kit/keplr-extension";
58
+ import { ThemeProvider } from "@interchain-ui/react";
59
+ import "@interchain-ui/react/styles";
60
+ import { chains, assetLists } from '@chain-registry/v2/mainnet'
61
+
62
+
63
+ const Show = () => {
64
+ const {address} = useChain('osmosis');
65
+ // will show cosmoshub address from what you selected wallet in modal
66
+ return <div>{address}</div>;
67
+ };
68
+
69
+ function App() {
70
+ return (
71
+ <ThemeProvider>
72
+ <ChainProvider
73
+ chains={chains}
74
+ assetLists={assetLists}
75
+ wallets={[keplrWallet]}
76
+ signerOptions={{}}
77
+ endpointOptions={{}}
78
+ >
79
+ <Show />
80
+ </ChainProvider>
81
+ </ThemeProvider>
82
+ );
83
+ }
84
+
85
+ export default App;
86
+ ```
87
+
88
+ ### useChain
89
+ ```js
90
+
91
+ const chainName = 'cosmoshub'
92
+ const { chain, assetList, address, wallet, queryClient, signingClient } = useChain(chainName)
93
+
94
+ console.log(wallet) //keprl extension wallet info
95
+ console.log(chain) // chain info for cosmoshub
96
+ console.log(assetList) // assets info for cosmoshub
97
+ console.log(address) // address for cosmoshub in keplr-extension wallet
98
+
99
+ //query
100
+ const { balance } = await queryClient.balance({
101
+ address,
102
+ denom: 'uosmo'
103
+ })
104
+ console.log(balance)
105
+ // { amount: 23423, denom: 'uosmos' }
106
+
107
+ ```
108
+
109
+ ### useChainWallet
110
+ ```js
111
+ import { keplrWallet } from "@interchain-kit/keplr-extension";
112
+ import { leapWallet } from "@interchain-kit/leap-extension";
113
+
114
+ const Show = () => {
115
+ const juno = useChainWallet('juno', 'keplr-extension')
116
+ const stargaze = useChainWallet('stargaze', 'leap-extension')
117
+ console.log(juno.address) // juno1xxxxxxx in keplr extension wallet
118
+ console.log(stargaze.addresss) // stargaze1xxxxxx in leap extension wallet
119
+ };
120
+
121
+ const chainNames
122
+
123
+ function App() {
124
+ return (
125
+ <ThemeProvider>
126
+ <ChainProvider
127
+ chains={chains.filter((c) => c.chainName === chainName)}
128
+ assetLists={assetLists.filter((c) => c.chainName === chainName)}
129
+ wallets={[keplrWallet, leapWallet]}
130
+ signerOptions={{}}
131
+ endpointOptions={{}}
132
+ >
133
+ <Show />
134
+ </ChainProvider>
135
+ </ThemeProvider>
136
+ );
137
+ }
138
+
139
+ export default App;
140
+ ```
141
+
142
+ ### useCurrentWallet
143
+ ```js
144
+ const wallet = useCurrentWallet()
145
+
146
+ console.log(wallet) // current connected wallet
147
+
148
+ ```
149
+
150
+ ### useAccount
151
+ ```js
152
+ const account = useAccount('cosmoshub', 'keplr-extension')
153
+
154
+ console.log(account.address) // cosmoshub address in keplr-extension wallet
155
+
156
+ ```
157
+
158
+ ### useOfflineSigner
159
+ ```js
160
+ const offlineSigner = useOfflineSigner('cosmoshub', 'keplr-extension')
161
+
162
+ console.log(offlineSigner) // cosmoshub offlineSigner in keplr-extension wallet
163
+ ```
164
+
165
+ ### useChains
166
+
167
+ ```js
168
+ WIP
12
169
  ```
13
- ## Table of contents
14
170
 
15
- - [react](#react)
16
- - [Install](#install)
17
- - [Table of contents](#table-of-contents)
18
- - [Developing](#developing)
19
- - [Credits](#credits)
20
171
 
21
172
  ## Developing
22
173
 
@@ -1,6 +1,7 @@
1
1
  export * from './useWalletManager';
2
- export * from './useActiveWallet';
2
+ export * from './useCurrentWallet';
3
3
  export * from './useAccount';
4
4
  export * from './useChain';
5
5
  export * from './useConnect';
6
6
  export * from './useChainWallet';
7
+ export * from './useConfig';
@@ -1,24 +1,35 @@
1
- import { useEffect, useState } from "react";
1
+ import { useEffect, useMemo, useState } from "react";
2
+ import { WalletManagerState, WalletState } from "@interchain-kit/core";
2
3
  import { useWalletManager } from './useWalletManager';
3
4
  export const useAccount = (chainName, walletName) => {
4
5
  const walletManager = useWalletManager();
5
- const wallet = walletManager.wallets.find(w => w.option.name === walletName);
6
+ const wallet = useMemo(() => {
7
+ return walletManager.wallets.find(w => w.option.name === walletName);
8
+ }, [walletManager, walletName]);
6
9
  const [account, setAccount] = useState(null);
7
- const chain = walletManager.chains.find(c => c.chainName === chainName);
10
+ const chain = useMemo(() => {
11
+ return walletManager.chains.find(c => c.chainName === chainName);
12
+ }, [walletManager, chainName]);
8
13
  const getAccount = async () => {
9
- const account = await wallet.getAccount(chain.chainId);
10
- setAccount(account);
14
+ if (wallet && chain) {
15
+ if (wallet.walletState === WalletState.Connected) {
16
+ const account = await wallet.getAccount(chain.chainId);
17
+ setAccount(account);
18
+ }
19
+ if (wallet.walletState === WalletState.Disconnected) {
20
+ setAccount(null);
21
+ }
22
+ }
23
+ if (!wallet) {
24
+ setAccount(null);
25
+ }
11
26
  };
12
27
  useEffect(() => {
13
- if (wallet) {
28
+ if (wallet && walletManager.state === WalletManagerState.Initialized) {
14
29
  wallet.events.on('keystoreChange', getAccount);
15
30
  }
16
- }, [wallet]);
31
+ }, [wallet, walletManager.state]);
17
32
  useEffect(() => {
18
- if (!wallet) {
19
- setAccount(null);
20
- return;
21
- }
22
33
  getAccount();
23
34
  }, [wallet, chainName, wallet?.walletState]);
24
35
  return account;
@@ -1,19 +1,51 @@
1
1
  import { useWalletManager } from "./useWalletManager";
2
2
  import { useAccount } from "./useAccount";
3
- import { useActiveWallet } from './useActiveWallet';
3
+ import { useCurrentWallet } from './useCurrentWallet';
4
4
  import { useInterchainClient } from './useInterchainClient';
5
+ import { useWalletModal } from "../modal";
6
+ import { ChainNameNotExist } from "@interchain-kit/core";
7
+ import { useCallback } from "react";
5
8
  export const useChain = (chainName) => {
6
9
  const walletManager = useWalletManager();
7
10
  const chainToShow = walletManager.chains.find((c) => c.chainName === chainName);
8
11
  const assetList = walletManager.assetLists.find((a) => a.chainName === chainName);
9
- const activeWallet = useActiveWallet();
10
- const account = useAccount(chainName, activeWallet.option.name);
11
- const interchainClient = useInterchainClient(chainName, activeWallet.option.name);
12
+ const currentWallet = useCurrentWallet();
13
+ const account = useAccount(chainName, currentWallet?.option?.name);
14
+ const interchainClient = useInterchainClient(chainName, currentWallet?.option?.name);
15
+ if (!chainToShow) {
16
+ throw new ChainNameNotExist(chainName);
17
+ }
18
+ const { open, close } = useWalletModal();
19
+ const getRpcEndpoint = useCallback(async () => {
20
+ return await walletManager.getRpcEndpoint(currentWallet, chainName);
21
+ }, [walletManager, currentWallet, chainName]);
22
+ const disconnect = useCallback(() => {
23
+ walletManager.disconnect(currentWallet?.option?.name);
24
+ }, [walletManager, currentWallet]);
25
+ const cosmosKitUserChainReturnType = {
26
+ connect: () => {
27
+ if (currentWallet) {
28
+ return;
29
+ }
30
+ open();
31
+ },
32
+ disconnect,
33
+ openView: open,
34
+ closeView: close,
35
+ getRpcEndpoint,
36
+ status: currentWallet?.walletState,
37
+ username: account?.username,
38
+ message: currentWallet?.errorMessage,
39
+ getSigningCosmWasmClient: () => walletManager.getSigningCosmwasmClient(currentWallet.option.name, chainName),
40
+ getSigningCosmosClient: () => walletManager.getSigningCosmosClient(currentWallet.option.name, chainName),
41
+ };
12
42
  return {
43
+ logoUrl: walletManager.getChainLogoUrl(chainName),
13
44
  chain: chainToShow,
14
45
  assetList,
15
46
  address: account?.address,
16
- wallet: activeWallet,
47
+ wallet: currentWallet,
48
+ ...cosmosKitUserChainReturnType, //for migration cosmos kit
17
49
  ...interchainClient
18
50
  };
19
51
  };
@@ -9,6 +9,7 @@ export const useChainWallet = (chainName, walletName) => {
9
9
  const account = useAccount(chainName, walletName);
10
10
  const interchainClient = useInterchainClient(chainName, walletName);
11
11
  return {
12
+ logoUrl: walletManager.getChainLogoUrl(chainName),
12
13
  chain: chainToShow,
13
14
  assetList,
14
15
  address: account?.address,
@@ -0,0 +1,10 @@
1
+ import { useWalletManager } from "./useWalletManager";
2
+ export const useConfig = () => {
3
+ const walletManager = useWalletManager();
4
+ return {
5
+ updateChains: (chains) => walletManager.chains = chains,
6
+ updateAssetLists: (assetLists) => walletManager.assetLists = assetLists,
7
+ updateSignerOptions: (signerOptions) => walletManager.signerOptions = signerOptions,
8
+ updateEndpoints: (endpointOptions) => walletManager.endpointOptions = endpointOptions,
9
+ };
10
+ };
@@ -0,0 +1,14 @@
1
+ import { useEffect } from "react";
2
+ import { useWalletManager } from "./useWalletManager";
3
+ import { useWalletModal } from "../modal";
4
+ import { WalletManagerState } from "@interchain-kit/core";
5
+ export const useCurrentWallet = () => {
6
+ const walletManager = useWalletManager();
7
+ const { open } = useWalletModal();
8
+ useEffect(() => {
9
+ if (!walletManager.currentWalletName && walletManager.state === WalletManagerState.Initialized) {
10
+ open();
11
+ }
12
+ }, [walletManager.currentWalletName, walletManager.state]);
13
+ return walletManager.getCurrentWallet();
14
+ };
@@ -1,59 +1,58 @@
1
1
  import { useEffect, useState } from "react";
2
2
  import { useWalletManager } from './useWalletManager';
3
3
  import { useAccount } from './useAccount';
4
+ import { WalletState } from '@interchain-kit/core';
4
5
  export const useInterchainClient = (chainName, walletName) => {
5
6
  const [rpcEndpoint, setRpcEndpoint] = useState();
7
+ //query
8
+ const [queryClient, setQueryClient] = useState(null);
9
+ //signing
6
10
  const [signingClient, setSigningClient] = useState(null);
7
- const [client, setClient] = useState(null);
8
- const [stargateSigningClient, setStargateSigningClient] = useState(null);
9
- const [stargateClient, setStargateClient] = useState();
10
- const [cosmWasmSigningClient, setCosmWasmSigningClient] = useState(null);
11
+ const [signingCosmosClient, setSigningCosmosClient] = useState(null);
12
+ const [signingCosmWasmClient, setSigningCosmWasmClient] = useState(null);
13
+ const [signingInjectiveClient, setSigningInjectiveClient] = useState(null);
11
14
  const [error, setError] = useState(null);
12
15
  const [isLoading, setIsLoading] = useState(false);
13
16
  const walletManager = useWalletManager();
14
17
  const account = useAccount(chainName, walletName);
18
+ const wallet = walletManager.wallets.find((w) => w.option.name === walletName);
19
+ const chainToShow = walletManager.chains.find((c) => c.chainName === chainName);
15
20
  const initialize = async () => {
16
- const wallet = walletManager.wallets.find((w) => w.option.name === walletName);
17
- const chainToShow = walletManager.chains.find((c) => c.chainName === chainName);
18
- if (!wallet) {
19
- throw new Error('Wallet not found');
20
- }
21
- if (!chainToShow) {
22
- throw new Error('Chain not found');
23
- }
24
- try {
25
- setIsLoading(true);
26
- const rpcEndpoint = await walletManager.getRpcEndpoint(wallet, chainName);
27
- setRpcEndpoint(rpcEndpoint);
28
- const clientFactory = await walletManager.createClientFactory(wallet, chainName);
29
- const client = await clientFactory.getClient();
30
- setClient(client);
31
- const signingClient = await clientFactory.getSigningClient();
32
- setSigningClient(signingClient);
33
- const stargateClient = await clientFactory.getStargateClient();
34
- setStargateClient(stargateClient);
35
- const signingStargateClient = await clientFactory.getSigningStargateClient(chainToShow.bech32Prefix);
36
- setStargateSigningClient(signingStargateClient);
37
- const signingCosmwasmClient = await clientFactory.getSigningCosmwasmClient();
38
- setCosmWasmSigningClient(signingCosmwasmClient);
39
- }
40
- catch (error) {
41
- setError(error);
42
- }
43
- finally {
44
- setIsLoading(false);
21
+ if (wallet && chainToShow && wallet?.walletState === WalletState.Connected) {
22
+ try {
23
+ setIsLoading(true);
24
+ const rpcEndpoint = await walletManager.getRpcEndpoint(wallet, chainName);
25
+ setRpcEndpoint(rpcEndpoint);
26
+ const queryClient = await walletManager.getQueryClient(walletName, chainName);
27
+ setQueryClient(queryClient);
28
+ const signingClient = await walletManager.getSigningClient(walletName, chainName);
29
+ setSigningClient(signingClient);
30
+ const signingStargateClient = await walletManager.getSigningCosmosClient(walletName, chainName);
31
+ setSigningCosmosClient(signingStargateClient);
32
+ const signingCosmwasmClient = await walletManager.getSigningCosmwasmClient(walletName, chainName);
33
+ setSigningCosmWasmClient(signingCosmwasmClient);
34
+ const signingInjectiveClient = await walletManager.getSigningInjectiveClient(walletName, chainName);
35
+ setSigningInjectiveClient(signingInjectiveClient);
36
+ }
37
+ catch (error) {
38
+ setError(error);
39
+ console.log("create client error", error);
40
+ }
41
+ finally {
42
+ setIsLoading(false);
43
+ }
45
44
  }
46
45
  };
47
46
  useEffect(() => {
48
47
  initialize();
49
- }, [chainName, walletName, account?.address]);
48
+ }, [chainName, walletName, account, wallet?.walletState]);
50
49
  return {
51
50
  rpcEndpoint,
52
- signingClient,
53
- client,
54
- stargateSigningClient,
55
- stargateClient,
56
- cosmWasmSigningClient,
51
+ signingClient: chainName === 'injective' ? signingInjectiveClient : signingClient,
52
+ queryClient,
53
+ signingCosmosClient,
54
+ signingCosmWasmClient,
55
+ signingInjectiveClient,
57
56
  error,
58
57
  isLoading
59
58
  };
@@ -0,0 +1,15 @@
1
+ import { useEffect, useState } from "react";
2
+ import { useWalletManager } from "./useWalletManager";
3
+ export const useOfflineSigner = (chainName, walletName) => {
4
+ const walletManager = useWalletManager();
5
+ const wallet = walletManager.wallets.find((w) => w.option.name === walletName);
6
+ const [offlineSigner, setOfflineSigner] = useState(null);
7
+ useEffect(() => {
8
+ if (wallet && chainName) {
9
+ setOfflineSigner(walletManager.getOfflineSigner(wallet, chainName));
10
+ }
11
+ }, [wallet, chainName]);
12
+ return {
13
+ offlineSigner
14
+ };
15
+ };
@@ -1,5 +1,5 @@
1
- import { useInterChainWalletContext } from "../provider";
1
+ import { useInterchainWalletContext } from "../provider";
2
2
  export const useWalletManager = () => {
3
- const { walletManager } = useInterChainWalletContext();
3
+ const { walletManager } = useInterchainWalletContext();
4
4
  return walletManager;
5
5
  };
@@ -1,16 +1,48 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useWalletManager } from "../hooks";
3
- const style = {
4
- position: 'absolute',
5
- top: '50%',
6
- left: '50%',
7
- transform: 'translate(-50%,-50%)',
8
- width: '500px',
9
- backgroundColor: 'white',
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { ConnectModal } from "@interchain-ui/react";
3
+ import { ConnectedContent, ConnectedHeader, ConnectingContent, ConnectingHeader, QRCodeContent, QRCodeHeader, RejectContent, RejectHeader, WalletListContent, WalletListHeader, } from "./views";
4
+ import { useWalletModal } from "./provider";
5
+ import { useCurrentWallet } from "../hooks";
6
+ import { useEffect, useState } from "react";
7
+ import { WalletState } from "@interchain-kit/core";
8
+ const defaultModalView = {
9
+ header: _jsx(WalletListHeader, {}),
10
+ content: _jsx(WalletListContent, {}),
10
11
  };
11
12
  export const WalletModal = () => {
12
- const walletManager = useWalletManager();
13
- return (_jsx("ul", { style: style, children: walletManager.wallets.map(wallet => {
14
- return (_jsxs("li", { children: [_jsx("span", { children: wallet.option.prettyName }), _jsx("button", { onClick: () => walletManager.connect(wallet.option.name), children: "connect" })] }));
15
- }) }));
13
+ const { modalIsOpen, open, close } = useWalletModal();
14
+ const currentWallet = useCurrentWallet();
15
+ const [modalView, setModalView] = useState(defaultModalView);
16
+ const gotoWalletList = () => setModalView(defaultModalView);
17
+ useEffect(() => {
18
+ switch (true) {
19
+ case currentWallet?.option?.mode === "wallet-connect":
20
+ setModalView({
21
+ header: _jsx(QRCodeHeader, { onBack: gotoWalletList }),
22
+ content: _jsx(QRCodeContent, {}),
23
+ });
24
+ break;
25
+ case currentWallet?.walletState === WalletState.Connecting:
26
+ setModalView({
27
+ header: _jsx(ConnectingHeader, { onBack: gotoWalletList }),
28
+ content: _jsx(ConnectingContent, {}),
29
+ });
30
+ break;
31
+ case currentWallet?.walletState === WalletState.Connected:
32
+ setModalView({
33
+ header: _jsx(ConnectedHeader, { onBack: gotoWalletList }),
34
+ content: _jsx(ConnectedContent, {}),
35
+ });
36
+ break;
37
+ case currentWallet?.walletState === WalletState.Reject:
38
+ setModalView({
39
+ header: _jsx(RejectHeader, { onBack: gotoWalletList }),
40
+ content: _jsx(RejectContent, {}),
41
+ });
42
+ break;
43
+ default:
44
+ setModalView(defaultModalView);
45
+ }
46
+ }, [currentWallet, currentWallet?.walletState]);
47
+ return (_jsx(ConnectModal, { isOpen: modalIsOpen, header: modalView.header, onOpen: open, onClose: close, children: modalView.content }));
16
48
  };
@@ -1,13 +1,12 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { createContext, useContext, useState } from "react";
3
- import { createPortal } from "react-dom";
4
3
  import { WalletModal } from "./modal";
5
4
  const WalletModalContext = createContext(null);
6
5
  export const WalletModalProvider = ({ children }) => {
7
6
  const [modalIsOpen, setModalIsOpen] = useState(false);
8
7
  const open = () => setModalIsOpen(true);
9
8
  const close = () => setModalIsOpen(false);
10
- return (_jsxs(WalletModalContext.Provider, { value: { modalIsOpen, open, close }, children: [children, modalIsOpen && createPortal(_jsx(WalletModal, {}), document.body)] }));
9
+ return (_jsxs(WalletModalContext.Provider, { value: { modalIsOpen, open, close }, children: [children, _jsx(WalletModal, {})] }));
11
10
  };
12
11
  export const useWalletModal = () => {
13
12
  const context = useContext(WalletModalContext);
@@ -0,0 +1,4 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ export function AstronautSvg(props) {
3
+ return (_jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", className: "chakra-icon css-1plqj06", viewBox: "0 0 278 255", ...props, children: [_jsx("path", { fill: "#030609", d: "M136.844 254.8c70.527 0 127.7-57.039 127.7-127.4S207.371 0 136.844 0 9.144 57.039 9.144 127.4s57.173 127.4 127.7 127.4Z" }), _jsx("path", { fill: "#F6F5F3", d: "M85.444 22.2a2.9 2.9 0 1 0 0-5.8 2.9 2.9 0 0 0 0 5.8Zm122.7 19.9a2.9 2.9 0 1 0 0-5.801 2.9 2.9 0 0 0 0 5.8Zm18.5 68.5a2.9 2.9 0 1 0-.002-5.802 2.9 2.9 0 0 0 .002 5.802Zm-15.6 71.5a2.9 2.9 0 1 0-.002-5.802 2.9 2.9 0 0 0 .002 5.802Zm-8.8 36a2.9 2.9 0 1 0-.002-5.802 2.9 2.9 0 0 0 .002 5.802Zm-57.5 12.2a2.9 2.9 0 1 0-.002-5.802 2.9 2.9 0 0 0 .002 5.802Zm-32.9-24.2a2.9 2.9 0 1 0-.002-5.802 2.9 2.9 0 0 0 .002 5.802Zm-97.7-94a2.9 2.9 0 1 0-.001-5.8 2.9 2.9 0 0 0 0 5.8Zm34-62.1a2.9 2.9 0 1 0 0-5.8 2.9 2.9 0 0 0 0 5.8Z" }), _jsx("path", { fill: "#BA536A", d: "M235.944 47.1c9.6 11.7 17 25.1 22 39.7-4.5 4.5-10.7 7.4-17.6 7.4-13.4 0-24.2-10.7-24.2-23.8 0-11.6 8.5-21.3 19.8-23.3Z" }), _jsx("path", { fill: "#FF6B84", d: "M242.544 92.9c-13 0-23.6-10.6-23.6-23.7 0-10.6 7-19.6 16.7-22.6 9.7 11.9 17.4 25.6 22.4 40.5-4.2 3.6-9.6 5.8-15.5 5.8Z" }), _jsx("path", { fill: "#124899", d: "M144.744 246.7c0 2.8-.6 5.4-1.5 7.9-2.067.133-4.2.2-6.4.2-14.2 0-28-2.4-40.8-6.7 0-.5-.1-1-.1-1.4 0-13.1 10.9-23.8 24.4-23.8 13.5 0 24.4 10.7 24.4 23.8Z" }), _jsx("path", { fill: "#4CBAB6", d: "M145.644 249.2c0 1.8-.2 3.567-.6 5.3-2.667.2-5.4.3-8.2.3-13.5 0-26.5-2.1-38.7-6 .2-13.4 10.8-24.3 23.7-24.3 13.1 0 23.8 11.1 23.8 24.7Z" }), _jsx("path", { fill: "#D8DEDC", d: "M205.144 117.7c5.9 6.3 17.1 16.7 27.6 23.5 21.8 13.9 20.8 11.7 26.1 14l-8.8 27.9c-13.334-9.733-24.167-17.033-32.5-21.9-10.2-6.067-21.8-12.033-34.8-17.9l22.4-25.6Z" }), _jsx("path", { fill: "#839091", d: "M207.344 119.9c.4.467 2.066 2.1 5 4.9-2.667 5.933-5.067 10.333-7.2 13.2-5 6.8-5.3 6.5-10 11.2l-7.9-3.8 20.1-25.5Z" }), _jsx("path", { fill: "#9CA9A8", d: "M242.844 196.2c-6.934 1.333-10.367.2-10.3-3.4 0-8.4 5.1-7.8 18.6-10.2l-8.3 13.6Z" }), _jsx("path", { fill: "#DAE0DF", d: "M234.844 190.9c-.267-1.6.466-3.067 2.2-4.4 1.666-1.267 4.933-1.933 9.8-2-4.534 1.4-7.334 2.533-8.4 3.4-1 .867-2.2 1.867-3.6 3Z" }), _jsx("path", { fill: "#030609", d: "M251.844 156.9c-4.134-6.6-4.734-10.433-1.8-11.5 4.5-1.6 11.2-1 16.1 1 6.2 2.5 11.7 6.9 11.7 10.5 0 3.133-2.6 5.233-7.8 6.3 3.866 4.6 4.866 7.933 3 10-1.8 2.067-5.267 2.8-10.4 2.2 5 5.133 6.333 8.767 4 10.9-2.6 2.3-12.1 1.6-18.1-.9-5.2-2.1-14.2-12.6-11.5-15.8 1.733-2.133 5.5-3.2 11.3-3.2-5.334-3.067-7-5.567-5-7.5 2-1.867 4.833-2.533 8.5-2Z" }), _jsx("path", { fill: "#9CA9A8", d: "M252.344 148.9c2.9-1.1 8.3.5 12.3 1.8 3.9 1.2 10.5 5.7 9 8-1 1.6-3.267 2.567-6.8 2.9 4.133 5.933 4.966 9.267 2.5 10-3.7 1-11.8.8-11.3 1.3s11.1 10.2 6.5 12.5c-4.5 2.3-10.9.8-15.7-1.8-5.7-3-10.4-10-8.5-12 .733-.8 4.466-1.7 11.2-2.7-5.334-4-7.8-6.533-7.4-7.6.7-1.7 3-2.6 6.4-2.6h6.5c-5.934-5.533-7.5-8.8-4.7-9.8Z" }), _jsx("path", { fill: "#DAE0DF", d: "M256.544 155.2c-3.134-2.733-4.134-4.333-3-4.8 1.066-.4 2.9-.3 5.5.3-1.6 0-2.6.3-3 .9-.4.6-.234 1.8.5 3.6Zm-7.7 6.2c-.534 1.2-.3 2.367.7 3.5-3.2-1.4-4.434-2.666-3.7-3.8.733-1.133 3.4-1.533 8-1.2-2.8-.2-4.467.3-5 1.5Zm-4.3 12.4c-.467 1.067-.167 2.867.9 5.4-3.334-2.933-4.367-5.133-3.1-6.6 1.266-1.533 3.433-2.133 6.5-1.8-2.467.867-3.9 1.867-4.3 3Z" }), _jsx("path", { fill: "#D8DEDC", d: "M180.844 148.9c1.933 5.933 3.933 13.767 6 23.5 3.7 17.5 2.9 36.9-4.1 39.9-2.8 1.2-5.4 3.6-16.1 0-7.2-2.4-22.134-12.133-44.8-29.2l59-34.2Z" }), _jsx("path", { fill: "#687476", d: "M182.744 155.2c-3.2 10.933-12.3 19.7-27.3 26.3-7.334 3.267-16.334 5.4-27 6.4l-10.2-7.5 46.5-25.2h18Z" }), _jsx("path", { fill: "#D8DEDC", d: "M74.044 99.2c-7.467.867-13.3 1.533-17.5 2-1.934.2-4.767 1.167-8.5 2.9-3.2-4.333-5.434-8.533-6.7-12.6-1.5-4.6-3-15.4.2-21.7 2.2-4.2 14.366-9.067 36.5-14.6l-4 44Z" }), _jsx("path", { fill: "#839091", d: "m82.544 53.7-3.5 43.9-23.9 3.9c-1-4.333-1.434-7.933-1.3-10.8.8-14.133 2.466-24.1 5-29.9l23.7-7.1Z" }), _jsx("path", { fill: "#030609", d: "m189.144 137.5-6.4 17.7c-12.4 14.067-26.967 23.533-43.7 28.4-16.8 4.867-34.934 5.467-54.4 1.8l-68.8-32.5c.733-5.933 2.766-11.667 6.1-17.2 5-8.3 15.9-29.3 28.5-33 8.4-2.533 17.6-3.7 27.6-3.5l111.1 38.3Z" }), _jsx("path", { fill: "#D8DEDC", d: "M174.844 148.9c-15.334 26-42.1 37.233-80.3 33.7-16.6-1.6-41.934-12.333-76-32.2 3.666-4.733 5.833-8.467 6.5-11.2 1.1-4 2.4-7.2 6.5-9.5 4.1-2.4 9-6.9 11.7-8.8 4.8-3.5 4.6-9.7 7.2-10.4 4.266-1 12.3-1.933 24.1-2.8l100.3 41.2Z" }), _jsx("path", { fill: "#687476", d: "M113.844 150.7h63.5c-4.334 6.133-11.3 12.2-20.9 18.2-9.6 6-16.4 9-20.4 9-3.334 0-8.6-2.067-15.8-6.2-9.6-5.533-15.734-10.467-18.4-14.8l12-6.2Z" }), _jsx("path", { fill: "#839091", d: "m79.844 106.3 14.8 30.1-20.1 6.9c-5.8-7.667-9.534-12.967-11.2-15.9-1.667-2.933-4.267-8.867-7.8-17.8l24.3-3.3Z" }), _jsx("path", { fill: "#030609", d: "M142.144 166.5c40.869 0 74-33.937 74-75.8s-33.131-75.8-74-75.8-74 33.937-74 75.8 33.131 75.8 74 75.8Z" }), _jsx("path", { fill: "#D8DEDC", d: "M143.444 158.8c37.334 0 67.6-31.027 67.6-69.3 0-38.273-30.266-69.3-67.6-69.3-37.335 0-67.6 31.027-67.6 69.3 0 38.273 30.265 69.3 67.6 69.3Z" }), _jsx("path", { fill: "#fff", d: "M172.344 29.4c9.066 4.133 15.9 10.033 20.5 17.7-.534 1.933-7.367 4.033-20.5 6.3-4.667.8-8.934 1.4-12.8 1.8.066-5.467-.5-10.667-1.7-15.6-1.867-7.467-3.867-12.034-6-13.7 6.6-.867 13.433.3 20.5 3.5Z" }), _jsx("path", { fill: "#030609", d: "M85.444 50c23.133 6.6 44.366 9.566 63.7 8.9 19.333-.667 37.033-3.634 53.1-8.9 6.533 14.4 10.433 25.266 11.7 32.6 1.266 7.333.3 16.633-2.9 27.9-16.334 16.666-38.9 24.3-67.7 22.9-35.8-1.734-58.633-11.267-68.5-28.6-2.6-15.467-2.7-27.134-.3-35 2.4-7.934 6.033-14.534 10.9-19.8Z" }), _jsx("path", { fill: "#173D3E", d: "M96.744 75.6c5.7 1.4 15.8-.4 20.1 1.3 4.2 1.8 11.7 12.8 16.3 14.4 4.6 1.5 11.7-5.4 14-5 2.3.3 1.9 4.4 4.9 6.6 1.2.9 3.2 1.9 7.3 3 3.066.866 6.233 1.866 9.5 3-20.334 11.666-40.3 15.533-59.9 11.6-19.6-3.867-30.067-8.267-31.4-13.2-.467-4.667-.3-10.367.5-17.1.666-5.134 1.7-9.567 3.1-13.3 6.666 4.866 11.866 7.766 15.6 8.7Z" }), _jsx("path", { fill: "#276A69", d: "M77.344 91.7c2.733-.6 5.166-.2 7.3 1.2 3.1 2.1 14.7 9.3 18.7 10.8s24.9-.2 26.8-1.5c1.2-.934 3.1-1.7 5.7-2.3 3.333 2.733 5.933 4 7.8 3.8 2.7-.4 6 1.2 9.9-1.3 4-2.5 6-5.6 8.8-5.6 2.7 0 5.9 1.8 8 2.1 6.5 1.1 8.2-1.5 11-.5 2.8 1 4.2 1.5 8.8 1.3 3.066-.2 9.033-.834 17.9-1.9 1.6 4.466-3.534 11.333-15.4 20.6-6.3 4.9-19.3 12-55 12-5.8 0-27.9-1.1-46-14.5-11.4-8.334-16.167-16.4-14.3-24.2Z" }), _jsx("path", { fill: "#388688", d: "M122.844 103.5c4.466-.467 8.566-2.434 12.3-5.9l1.7 2.7c.133 2.266-.767 4.266-2.7 6-2.9 2.6-7.3 4.6-12.3 4.2-3.267-.2-7.934-2.334-14-6.4 5.4.133 10.4-.067 15-.6Zm27.8-.9c3.6-.6 6.7-2.7 9.2-5 1.666-1.534 3.9-1.534 6.7 0-1 .733-2 1.433-3 2.1-1.4 1-2.6 1.1-5.2 2.2s-6.6 4.4-13.8 4.4c-3 0-5.134-1.6-6.4-4.8 4.266 1.466 8.4 1.833 12.4 1.1h.1Z" }), _jsx("path", { fill: "#fff", d: "m159.344 60.9 20-2.5c4.2 14.266 4.833 36.333 1.9 66.2-4.067 1.266-7.634 2.3-10.7 3.1-4.6 1.2-8.934 1.866-13 2 2.533-7.667 3.633-19.5 3.3-35.5-.2-11.867-.7-22.967-1.5-33.3Zm40-6c2.4 2.7 7.5 10.9 8.8 20 1.9 14.4 1.3 21.5-.6 27.8-2.134 4-4.634 7.1-7.5 9.3-2.867 2.266-5.434 4.466-7.7 6.6 3.2-5.067 4.466-14.734 3.8-29-.667-15.134-2.534-26.134-5.6-33l8.8-1.7Z", opacity: 0.4 }), _jsx("path", { fill: "#030609", d: "M74.544 142.9c15.733-15.333 28.166-21.9 37.3-19.7 15.3 3.6 14.9 13.9 11.4 24.4-2.334 6.933-15.2 12.7-38.6 17.3l-10.1-22Z" }), _jsx("path", { fill: "#9CA9A8", d: "M78.144 146.2c4-4.667 11.233-8.5 21.7-11.5 15.8-4.5 18.3 4.3 18.4 7.2.2 3-1.4 7.2-6.4 8.8-3.334 1.067-11.567 3.8-24.7 8.2l-9-12.7Z" }), _jsx("path", { fill: "#515C5C", d: "m78.144 144.9 4.2-2.3c3.933 4.6 6.6 6.867 8 6.8 4.2-.1 9.3.4 9.5-.5.2-.6.866-2.7 2-6.3-.134 2.8-.134 4.5 0 5.1.2.9 9.1-.2 11.3-1.3 2-1 3.7-2.5 5.1-4.5.2 3.2-.534 5.367-2.2 6.5-3.6 2.6-13.234 6.1-28.9 10.5l-9-14Z" }), _jsx("path", { fill: "#DAE0DF", d: "M105.144 136.1c1-.3 6.2-.7 7.7 0 1 .467 1.633 1.5 1.9 3.1-.8-.733-1.767-1.433-2.9-2.1-.934-.533-3.167-.867-6.7-1Zm-4.5 7.8-1.5 4.2c-.267.867-2.367 1.067-6.3.6 2.466-.2 4.233-.8 5.3-1.8 1.133-.933 1.966-1.933 2.5-3Z" }), _jsx("path", { fill: "#030609", d: "M57.844 227.4c-.1 2.8 0 7.5-3.3 9.3-3.2 1.7-31 3.2-36.5-2.8-5.4-6-15.4-25.5-17.2-36.5-1.2-7.3-2-20.5 4-22.2 4-1.2 8.066-.833 12.2 1.1-3.934-5.933-5.9-11.4-5.9-16.4 0-3.6 1.3-9.5 5.9-10.5 3.066-.667 9.333-.167 18.8 1.5-2-7.2-2-12.2 0-15 6-8.5 22.5-7.2 27-6 4.5 1.3 39.8 37 42 46.4 1.4 5.7-2.3 21.4-6.7 24-1.867 1.133-6.1 2.1-12.7 2.9 4.2 8 4.2 13.4 0 16.2-4.267 2.867-13.467 2.867-27.6 0v8Z" }), _jsx("path", { fill: "#9CA9A8", d: "M38.844 152.9c-1.2-6.867-.7-11.034 1.5-12.5 3.2-2.3 12-2.7 16.5-2.2s5.1 8 11.5 12.2c11 7.3 24 25.3 25.5 28.8s.3 6 0 8.5-12.5 6.6-16 3.7c-1.4-1.1-7.2-8.4-12-12.2-4.667-3.8-9.1-6.567-13.3-8.3 7 7.8 10.933 12.566 11.8 14.3 1.3 2.6 4.1 10.2 7 12.2 2.9 2 10.1 7.8 11.2 8.6 1.1.9 1.6 8.9 1.1 10.4-1.8 2-15.3-4.6-17.3-5-2-.3-7.2-1.2-11.7-2.5-3.067-.8-10.5-7.8-22.3-21 2.733 8.866 5.333 14.9 7.8 18.1 3.6 4.8 6 12 9.2 12 4.5 0 3.8 9.2 1.7 10.9-2.2 1.8-18.3 1.4-24.7-1.5-4.7-2.1-24.5-46.5-19-48.2 7-2.3 11.8-1 14.2 1.3 1.533 1.533 3.133 3.1 4.8 4.7-6.867-19.067-8.367-28.834-4.5-29.3 4.466-.534 9.4-.934 14.8-1.2l1.5 4.7.5-4.2 3.2 1-3-3.3Z" }), _jsx("path", { fill: "#515C5C", d: "M12.244 178.1c-2 2.533-2.367 5.566-1.1 9.1 2 5.2 5.4 15 7.7 18.8 2.3 3.9 9.2 16.4 10.8 18.5 1 1.466 2.4 3.066 4.2 4.8-2.867-.267-5.367-.9-7.5-1.9-4.1-1.8-16.2-25.1-19-38.5-1.3-6.3-1.5-8.9 0-9.7 2.533-1.334 4.166-1.7 4.9-1.1Zm21.6 51.2c4.666-3 7.6-5.134 8.8-6.4a99.173 99.173 0 0 1 5.2-5.4c2.666.266 4.333.9 5 1.9 1 1.5-.4 8.9-1.8 9.5-2.4 1.1-5.1 1.3-6.9 1.4-3.867.133-7.3-.2-10.3-1Zm1.4-33c.9 3 3.7 7.6 6.1 11.6 2.533 4.266 4.233 7.033 5.1 8.3-8.2-7-12.9-12.667-14.1-17-1.2-4.334-1.2-8.1 0-11.3.533.533 1.5 3.333 2.9 8.4Zm47.3 9.7c1.6 2.9 2.3 7.7 1 10.4-.8 1.866-6.534.2-17.2-5 1.6-1.334 3-3.134 4.2-5.4 3.2-5.7 3.2-5.7 3.5-6.6 4.533 2.533 7.366 4.733 8.5 6.6Zm-20-23.4c2.533 3.533 5.033 8.066 7.5 13.6-6.334-4-11-8.534-14-13.6-2.334-4.067-4-8.634-5-13.7 5.733 6.466 9.566 11.033 11.5 13.7Zm12 5.3c3.2-.734 6.433-2.034 9.7-3.9 4.266-2.4 7.266-4.4 9-6 1.8 2.666 2 5.9.6 9.7-1.4 3.5-11.3 7.2-16 3.7-2-1.467-3.1-2.634-3.3-3.5Z" }), _jsx("path", { fill: "#DAE0DF", d: "M43.344 150.7c-.867-6.6.733-10.367 4.8-11.3 4-.867 8.133.566 12.4 4.3-4.534-1.2-7.9-1.634-10.1-1.3-2.134.333-4.5 3.1-7.1 8.3Zm-17.5 11c-.667 2-.334 7.833 1 17.5-5.2-12.4-6.467-19.4-3.8-21 3.2-1.934 6.8-1.934 10.8 0-4.667.333-7.334 1.5-8 3.5Zm-10.2 20.3c-1.134.533-2 2.5-2.6 5.9-1.667-5.8-1.334-8.7 1-8.7 3.666-.067 6.3 1.533 7.9 4.8-2.134-2.334-4.267-3-6.4-2h.1Z" })] }));
4
+ }
@@ -0,0 +1,32 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { ConnectModalHead, ConnectModalStatus } from "@interchain-ui/react";
3
+ import { useAccount, useCurrentWallet, useWalletManager } from "../../hooks";
4
+ import { useWalletModal } from "../provider";
5
+ import { getWalletInfo } from "../../utils";
6
+ import { AstronautSvg } from "./Astronaut";
7
+ export const ConnectedHeader = ({ onBack }) => {
8
+ const currentWallet = useCurrentWallet();
9
+ const { close } = useWalletModal();
10
+ return (_jsx(ConnectModalHead, { title: currentWallet?.option?.prettyName || "", hasBackButton: true, onClose: close, onBack: onBack, closeButtonProps: { onClick: close } }));
11
+ };
12
+ export const ConnectedContent = () => {
13
+ const currentWallet = useCurrentWallet();
14
+ const walletManager = useWalletManager();
15
+ const account = useAccount(walletManager.chains[0].chainName, currentWallet?.option?.name);
16
+ const { close } = useWalletModal();
17
+ if (!currentWallet) {
18
+ return null;
19
+ }
20
+ return (_jsx(ConnectModalStatus, { wallet: getWalletInfo(currentWallet), status: "Connected", connectedInfo: {
21
+ name: account?.username || "Wallet",
22
+ avatar: (_jsx(AstronautSvg, { style: {
23
+ fontSize: "inherit",
24
+ width: "100%",
25
+ height: "100%",
26
+ } })),
27
+ address: account?.address,
28
+ }, onDisconnect: async () => {
29
+ await walletManager.disconnect(currentWallet?.option?.name);
30
+ close();
31
+ } }));
32
+ };
@@ -0,0 +1,33 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { ConnectModalHead, ConnectModalStatus } from "@interchain-ui/react";
3
+ import { useCurrentWallet, useWalletManager } from "../../hooks";
4
+ import { useWalletModal } from "../provider";
5
+ export const ConnectingHeader = ({ onBack }) => {
6
+ const currentWallet = useCurrentWallet();
7
+ const { close } = useWalletModal();
8
+ const walletManager = useWalletManager();
9
+ if (!currentWallet)
10
+ return null;
11
+ return (_jsx(ConnectModalHead, { title: currentWallet.option.prettyName, hasBackButton: true, onClose: close, onBack: onBack, closeButtonProps: {
12
+ onClick: async () => {
13
+ await walletManager.disconnect(currentWallet.option.name);
14
+ close();
15
+ },
16
+ } }));
17
+ };
18
+ export const ConnectingContent = () => {
19
+ const currentWallet = useCurrentWallet();
20
+ const { option: { prettyName, mode }, } = currentWallet;
21
+ let title = "Requesting Connection";
22
+ let desc = mode === "wallet-connect"
23
+ ? `Approve ${prettyName} connection request on your mobile.`
24
+ : `Open the ${prettyName} browser extension to connect your wallet.`;
25
+ if (!currentWallet)
26
+ return null;
27
+ return (_jsx(ConnectModalStatus, { wallet: {
28
+ name: currentWallet.option.name,
29
+ prettyName: currentWallet.option.prettyName,
30
+ logo: currentWallet.option.logo,
31
+ mobileDisabled: true,
32
+ }, status: "Connecting", contentHeader: title, contentDesc: desc }));
33
+ };
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { ConnectModalHead, ConnectModalQRCode } from "@interchain-ui/react";
3
+ import { useCurrentWallet, useWalletManager } from "../../hooks";
4
+ import { useWalletModal } from "../provider";
5
+ export const QRCodeHeader = ({ onBack }) => {
6
+ const currentWallet = useCurrentWallet();
7
+ const walletManager = useWalletManager();
8
+ const { close } = useWalletModal();
9
+ return (_jsx(ConnectModalHead, { title: currentWallet?.option?.prettyName || "", hasBackButton: true, onClose: () => void 0, onBack: async () => {
10
+ await walletManager.disconnect(currentWallet?.option?.name || "");
11
+ onBack();
12
+ }, closeButtonProps: { onClick: close } }));
13
+ };
14
+ export const QRCodeContent = () => {
15
+ const currentWallet = useCurrentWallet();
16
+ const walletManager = useWalletManager();
17
+ const data = currentWallet.pairingUri;
18
+ return (_jsx(ConnectModalQRCode, { status: data ? "Done" : "Pending", link: data, description: "Open App to connect", errorTitle: "errorTitle", errorDesc: currentWallet.errorMessage || "", onRefresh: () => walletManager.connect(currentWallet?.option?.name || "") }));
19
+ };