@interchain-kit/react 0.0.1-beta.1 → 0.0.1-beta.12
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.
- package/esm/hooks/index.js +1 -0
- package/esm/hooks/useAccount.js +9 -6
- package/esm/hooks/useActiveWallet.js +8 -0
- package/esm/hooks/useChain.js +27 -15
- package/esm/hooks/useChainWallet.js +3 -21
- package/esm/hooks/useConfig.js +10 -0
- package/esm/hooks/useInterchainClient.js +58 -0
- package/esm/hooks/useOfflineSigner.js +15 -0
- package/esm/modal/modal.js +28 -13
- package/esm/modal/provider.js +1 -2
- package/esm/modal/views/Astronaut.js +4 -0
- package/esm/modal/views/Connected.js +32 -0
- package/esm/modal/views/Connecting.js +33 -0
- package/esm/modal/views/Reject.js +16 -0
- package/esm/modal/views/WalletList.js +32 -0
- package/esm/modal/views/index.js +4 -0
- package/esm/utils/index.js +8 -1
- package/esm/utils/wallet.js +1 -0
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +1 -0
- package/hooks/useAccount.js +9 -6
- package/hooks/useActiveWallet.js +8 -0
- package/hooks/useChain.d.ts +2 -2
- package/hooks/useChain.js +27 -15
- package/hooks/useChainWallet.d.ts +2 -15
- package/hooks/useChainWallet.js +3 -21
- package/hooks/useConfig.d.ts +8 -0
- package/hooks/useConfig.js +14 -0
- package/hooks/useInterchainClient.d.ts +16 -0
- package/hooks/useInterchainClient.js +62 -0
- package/hooks/useOfflineSigner.d.ts +4 -0
- package/hooks/useOfflineSigner.js +19 -0
- package/modal/modal.js +26 -11
- package/modal/provider.js +1 -2
- package/modal/views/Astronaut.d.ts +2 -0
- package/modal/views/Astronaut.js +8 -0
- package/modal/views/Connected.d.ts +4 -0
- package/modal/views/Connected.js +37 -0
- package/modal/views/Connecting.d.ts +4 -0
- package/modal/views/Connecting.js +38 -0
- package/modal/views/Reject.d.ts +4 -0
- package/modal/views/Reject.js +21 -0
- package/modal/views/WalletList.d.ts +2 -0
- package/modal/views/WalletList.js +37 -0
- package/modal/views/index.d.ts +4 -0
- package/modal/views/index.js +20 -0
- package/package.json +5 -3
- package/types/chain.d.ts +25 -4
- package/utils/index.d.ts +7 -0
- package/utils/index.js +11 -0
- package/utils/wallet.d.ts +1 -0
- package/utils/wallet.js +17 -0
package/esm/hooks/index.js
CHANGED
package/esm/hooks/useAccount.js
CHANGED
|
@@ -6,8 +6,15 @@ export const useAccount = (chainName, walletName) => {
|
|
|
6
6
|
const [account, setAccount] = useState(null);
|
|
7
7
|
const chain = walletManager.chains.find(c => c.chainName === chainName);
|
|
8
8
|
const getAccount = async () => {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
if (wallet && chain) {
|
|
10
|
+
if (wallet.walletState === "Connected" /* WalletState.Connected */) {
|
|
11
|
+
const account = await wallet.getAccount(chain.chainId);
|
|
12
|
+
setAccount(account);
|
|
13
|
+
}
|
|
14
|
+
if (wallet.walletState === "Disconnected" /* WalletState.Disconnected */) {
|
|
15
|
+
setAccount(null);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
11
18
|
};
|
|
12
19
|
useEffect(() => {
|
|
13
20
|
if (wallet) {
|
|
@@ -15,10 +22,6 @@ export const useAccount = (chainName, walletName) => {
|
|
|
15
22
|
}
|
|
16
23
|
}, [wallet]);
|
|
17
24
|
useEffect(() => {
|
|
18
|
-
if (!wallet) {
|
|
19
|
-
setAccount(null);
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
25
|
getAccount();
|
|
23
26
|
}, [wallet, chainName, wallet?.walletState]);
|
|
24
27
|
return account;
|
|
@@ -1,5 +1,13 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
1
2
|
import { useWalletManager } from "./useWalletManager";
|
|
3
|
+
import { useWalletModal } from "../modal";
|
|
2
4
|
export const useActiveWallet = () => {
|
|
3
5
|
const walletManager = useWalletManager();
|
|
6
|
+
const { open } = useWalletModal();
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
if (!walletManager.activeWalletName) {
|
|
9
|
+
open();
|
|
10
|
+
}
|
|
11
|
+
}, [walletManager.activeWalletName]);
|
|
4
12
|
return walletManager.getActiveWallet();
|
|
5
13
|
};
|
package/esm/hooks/useChain.js
CHANGED
|
@@ -1,30 +1,42 @@
|
|
|
1
1
|
import { useWalletManager } from "./useWalletManager";
|
|
2
2
|
import { useAccount } from "./useAccount";
|
|
3
3
|
import { useActiveWallet } from './useActiveWallet';
|
|
4
|
-
import {
|
|
4
|
+
import { useInterchainClient } from './useInterchainClient';
|
|
5
|
+
import { useWalletModal } from "../modal";
|
|
6
|
+
import { ChainNameNotExist } from "@interChain-kit/core";
|
|
5
7
|
export const useChain = (chainName) => {
|
|
6
8
|
const walletManager = useWalletManager();
|
|
7
9
|
const chainToShow = walletManager.chains.find((c) => c.chainName === chainName);
|
|
8
10
|
const assetList = walletManager.assetLists.find((a) => a.chainName === chainName);
|
|
9
11
|
const activeWallet = useActiveWallet();
|
|
10
|
-
const account = useAccount(chainName, activeWallet
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
const account = useAccount(chainName, activeWallet?.option?.name);
|
|
13
|
+
const interchainClient = useInterchainClient(chainName, activeWallet?.option?.name);
|
|
14
|
+
if (!chainToShow) {
|
|
15
|
+
throw new ChainNameNotExist(chainName);
|
|
16
|
+
}
|
|
17
|
+
const { open, close } = useWalletModal();
|
|
18
|
+
const cosmosKitUserChainReturnType = {
|
|
19
|
+
connect: () => {
|
|
20
|
+
if (activeWallet) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
open();
|
|
24
|
+
},
|
|
25
|
+
openView: open,
|
|
26
|
+
closeView: close,
|
|
27
|
+
getRpcEndpoint: () => walletManager.getRpcEndpoint(activeWallet, chainName),
|
|
28
|
+
status: activeWallet?.walletState,
|
|
29
|
+
username: account?.username,
|
|
30
|
+
message: activeWallet?.errorMessage,
|
|
31
|
+
getSigningCosmWasmClient: () => walletManager.createClientFactory(activeWallet, chainName).then((c) => c.getSigningCosmwasmClient()),
|
|
32
|
+
getSigningCosmosClient: () => walletManager.createClientFactory(activeWallet, chainName).then((c) => c.getSigningCosmosClient())
|
|
33
|
+
};
|
|
17
34
|
return {
|
|
18
35
|
chain: chainToShow,
|
|
19
36
|
assetList,
|
|
20
37
|
address: account?.address,
|
|
21
38
|
wallet: activeWallet,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
getSigningClient: () => clientFactory.getSigningClient(),
|
|
25
|
-
getCosmwasmClient: () => clientFactory.getCosmwasmClient(),
|
|
26
|
-
getSigningCosmwasmClient: () => clientFactory.getSigningCosmwasmClient(),
|
|
27
|
-
getSigningStargateClient: () => clientFactory.getSigningStargateClient(),
|
|
28
|
-
getStargateClient: () => clientFactory.getStargateClient(),
|
|
39
|
+
...cosmosKitUserChainReturnType, //for migration cosmos kit
|
|
40
|
+
...interchainClient
|
|
29
41
|
};
|
|
30
42
|
};
|
|
@@ -1,36 +1,18 @@
|
|
|
1
1
|
import { useWalletManager } from "./useWalletManager";
|
|
2
2
|
import { useAccount } from "./useAccount";
|
|
3
|
-
import {
|
|
4
|
-
import { ChainNotExist, WalletNotExist } from "@interChain-kit/core";
|
|
3
|
+
import { useInterchainClient } from "./useInterchainClient";
|
|
5
4
|
export const useChainWallet = (chainName, walletName) => {
|
|
6
5
|
const walletManager = useWalletManager();
|
|
7
6
|
const chainToShow = walletManager.chains.find((c) => c.chainName === chainName);
|
|
8
7
|
const assetList = walletManager.assetLists.find((a) => a.chainName === chainName);
|
|
9
8
|
const wallet = walletManager.wallets.find((w) => w.option.name === walletName);
|
|
10
9
|
const account = useAccount(chainName, walletName);
|
|
11
|
-
const
|
|
12
|
-
useEffect(() => {
|
|
13
|
-
if (!wallet) {
|
|
14
|
-
throw new WalletNotExist(walletName);
|
|
15
|
-
}
|
|
16
|
-
if (!chainToShow) {
|
|
17
|
-
throw new ChainNotExist(chainName);
|
|
18
|
-
}
|
|
19
|
-
walletManager.createClientFactory(wallet, chainName).then(clientFactory => {
|
|
20
|
-
setClientFactory(clientFactory);
|
|
21
|
-
});
|
|
22
|
-
}, [chainName, walletName, account?.address]);
|
|
10
|
+
const interchainClient = useInterchainClient(chainName, walletName);
|
|
23
11
|
return {
|
|
24
12
|
chain: chainToShow,
|
|
25
13
|
assetList,
|
|
26
14
|
address: account?.address,
|
|
27
15
|
wallet,
|
|
28
|
-
|
|
29
|
-
getClient: () => clientFactory.getClient(),
|
|
30
|
-
getSigningClient: async () => clientFactory.getSigningClient(),
|
|
31
|
-
getCosmwasmClient: () => clientFactory.getCosmwasmClient(),
|
|
32
|
-
getSigningCosmwasmClient: () => clientFactory.getSigningCosmwasmClient(),
|
|
33
|
-
getSigningStargateClient: () => clientFactory.getSigningStargateClient(),
|
|
34
|
-
getStargateClient: () => clientFactory.getStargateClient(),
|
|
16
|
+
...interchainClient
|
|
35
17
|
};
|
|
36
18
|
};
|
|
@@ -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,58 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { useWalletManager } from './useWalletManager';
|
|
3
|
+
import { useAccount } from './useAccount';
|
|
4
|
+
export const useInterchainClient = (chainName, walletName) => {
|
|
5
|
+
const [rpcEndpoint, setRpcEndpoint] = useState();
|
|
6
|
+
//query
|
|
7
|
+
const [queryClient, setQueryClient] = useState(null);
|
|
8
|
+
//signing
|
|
9
|
+
const [signingClient, setSigningClient] = useState(null);
|
|
10
|
+
const [signingCosmosClient, setSigningCosmosClient] = useState(null);
|
|
11
|
+
const [signingCosmWasmClient, setSigningCosmWasmClient] = useState(null);
|
|
12
|
+
const [signingInjectiveClient, setSigningInjectiveClient] = useState(null);
|
|
13
|
+
const [error, setError] = useState(null);
|
|
14
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
15
|
+
const walletManager = useWalletManager();
|
|
16
|
+
const account = useAccount(chainName, walletName);
|
|
17
|
+
const wallet = walletManager.wallets.find((w) => w.option.name === walletName);
|
|
18
|
+
const chainToShow = walletManager.chains.find((c) => c.chainName === chainName);
|
|
19
|
+
const initialize = async () => {
|
|
20
|
+
if (wallet && chainToShow && wallet?.walletState === "Connected" /* WalletState.Connected */) {
|
|
21
|
+
try {
|
|
22
|
+
setIsLoading(true);
|
|
23
|
+
const rpcEndpoint = await walletManager.getRpcEndpoint(wallet, chainName);
|
|
24
|
+
setRpcEndpoint(rpcEndpoint);
|
|
25
|
+
const clientFactory = await walletManager.createClientFactory(wallet, chainName);
|
|
26
|
+
const queryClient = await clientFactory.getClient();
|
|
27
|
+
setQueryClient(queryClient);
|
|
28
|
+
const signingClient = await clientFactory.getSigningClient();
|
|
29
|
+
setSigningClient(signingClient);
|
|
30
|
+
const signingStargateClient = await clientFactory.getSigningCosmosClient(chainToShow.bech32Prefix);
|
|
31
|
+
setSigningCosmosClient(signingStargateClient);
|
|
32
|
+
const signingCosmwasmClient = await clientFactory.getSigningCosmwasmClient(chainToShow.bech32Prefix);
|
|
33
|
+
setSigningCosmWasmClient(signingCosmwasmClient);
|
|
34
|
+
const signingInjectiveClient = await clientFactory.getSigningInjectiveClient(chainToShow.bech32Prefix);
|
|
35
|
+
setSigningInjectiveClient(signingInjectiveClient);
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
setError(error);
|
|
39
|
+
}
|
|
40
|
+
finally {
|
|
41
|
+
setIsLoading(false);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
initialize();
|
|
47
|
+
}, [chainName, walletName, account, wallet?.walletState]);
|
|
48
|
+
return {
|
|
49
|
+
rpcEndpoint,
|
|
50
|
+
signingClient: chainName === 'injective' ? signingInjectiveClient : signingClient,
|
|
51
|
+
queryClient,
|
|
52
|
+
signingCosmosClient,
|
|
53
|
+
signingCosmWasmClient,
|
|
54
|
+
signingInjectiveClient,
|
|
55
|
+
error,
|
|
56
|
+
isLoading
|
|
57
|
+
};
|
|
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
|
+
};
|
package/esm/modal/modal.js
CHANGED
|
@@ -1,16 +1,31 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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, RejectContent, RejectHeader, WalletListContent, WalletListHeader } from "./views";
|
|
4
|
+
import { useWalletModal } from "./provider";
|
|
5
|
+
import { useActiveWallet } from "../hooks";
|
|
6
|
+
import { useEffect, useState } from "react";
|
|
7
|
+
const defaultModalView = {
|
|
8
|
+
header: _jsx(WalletListHeader, {}), content: _jsx(WalletListContent, {})
|
|
10
9
|
};
|
|
11
10
|
export const WalletModal = () => {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
const { modalIsOpen, open, close } = useWalletModal();
|
|
12
|
+
const activeWallet = useActiveWallet();
|
|
13
|
+
const [modalView, setModalView] = useState(defaultModalView);
|
|
14
|
+
const gotoWalletList = () => setModalView(defaultModalView);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
switch (true) {
|
|
17
|
+
case activeWallet?.walletState === "Connecting" /* WalletState.Connecting */:
|
|
18
|
+
setModalView({ header: _jsx(ConnectingHeader, { onBack: gotoWalletList }), content: _jsx(ConnectingContent, {}) });
|
|
19
|
+
break;
|
|
20
|
+
case activeWallet?.walletState === "Connected" /* WalletState.Connected */:
|
|
21
|
+
setModalView({ header: _jsx(ConnectedHeader, { onBack: gotoWalletList }), content: _jsx(ConnectedContent, {}) });
|
|
22
|
+
break;
|
|
23
|
+
case activeWallet?.walletState === "Reject" /* WalletState.Reject */:
|
|
24
|
+
setModalView({ header: _jsx(RejectHeader, { onBack: gotoWalletList }), content: _jsx(RejectContent, {}) });
|
|
25
|
+
break;
|
|
26
|
+
default:
|
|
27
|
+
setModalView(defaultModalView);
|
|
28
|
+
}
|
|
29
|
+
}, [activeWallet, activeWallet?.walletState]);
|
|
30
|
+
return (_jsx(ConnectModal, { isOpen: modalIsOpen, header: modalView.header, onOpen: open, onClose: close, children: modalView.content }));
|
|
16
31
|
};
|
package/esm/modal/provider.js
CHANGED
|
@@ -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,
|
|
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, useActiveWallet, 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 activeWallet = useActiveWallet();
|
|
9
|
+
const { close } = useWalletModal();
|
|
10
|
+
return (_jsx(ConnectModalHead, { title: activeWallet?.option?.prettyName || '', hasBackButton: true, onClose: close, onBack: onBack, closeButtonProps: { onClick: close } }));
|
|
11
|
+
};
|
|
12
|
+
export const ConnectedContent = () => {
|
|
13
|
+
const activeWallet = useActiveWallet();
|
|
14
|
+
const walletManager = useWalletManager();
|
|
15
|
+
const account = useAccount(walletManager.chains[0].chainName, activeWallet?.option?.name);
|
|
16
|
+
const { close } = useWalletModal();
|
|
17
|
+
if (!activeWallet) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
return (_jsx(ConnectModalStatus, { wallet: getWalletInfo(activeWallet), 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(activeWallet?.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 { useActiveWallet, useWalletManager } from '../../hooks';
|
|
4
|
+
import { useWalletModal } from '../provider';
|
|
5
|
+
export const ConnectingHeader = ({ onBack }) => {
|
|
6
|
+
const wallet = useActiveWallet();
|
|
7
|
+
const { close } = useWalletModal();
|
|
8
|
+
const walletManager = useWalletManager();
|
|
9
|
+
if (!wallet)
|
|
10
|
+
return null;
|
|
11
|
+
return (_jsx(ConnectModalHead, { title: wallet.option.prettyName, hasBackButton: true, onClose: close, onBack: onBack, closeButtonProps: {
|
|
12
|
+
onClick: async () => {
|
|
13
|
+
await walletManager.disconnect(wallet.option.name);
|
|
14
|
+
close();
|
|
15
|
+
}
|
|
16
|
+
} }));
|
|
17
|
+
};
|
|
18
|
+
export const ConnectingContent = () => {
|
|
19
|
+
const activeWallet = useActiveWallet();
|
|
20
|
+
const { option: { prettyName, mode } } = activeWallet;
|
|
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 (!activeWallet)
|
|
26
|
+
return null;
|
|
27
|
+
return (_jsx(ConnectModalStatus, { wallet: {
|
|
28
|
+
name: activeWallet.option.name,
|
|
29
|
+
prettyName: activeWallet.option.prettyName,
|
|
30
|
+
logo: activeWallet.option.logo,
|
|
31
|
+
mobileDisabled: true,
|
|
32
|
+
}, status: 'Connecting', contentHeader: title, contentDesc: desc }));
|
|
33
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ConnectModalHead, ConnectModalStatus } from "@interchain-ui/react";
|
|
3
|
+
import { useWalletModal } from "../provider";
|
|
4
|
+
import { useActiveWallet, useWalletManager } from "../../hooks";
|
|
5
|
+
import { getWalletInfo } from "../../utils";
|
|
6
|
+
export const RejectHeader = ({ onBack }) => {
|
|
7
|
+
const { close } = useWalletModal();
|
|
8
|
+
const activeWallet = useActiveWallet();
|
|
9
|
+
return (_jsx(ConnectModalHead, { title: activeWallet.option.prettyName, hasBackButton: true, onClose: close, onBack: onBack, closeButtonProps: { onClick: close } }));
|
|
10
|
+
};
|
|
11
|
+
export const RejectContent = () => {
|
|
12
|
+
const activeWallet = useActiveWallet();
|
|
13
|
+
const walletManager = useWalletManager();
|
|
14
|
+
const { close } = useWalletModal();
|
|
15
|
+
return (_jsx(ConnectModalStatus, { status: "Rejected", wallet: getWalletInfo(activeWallet), contentHeader: 'Request Rejected', contentDesc: activeWallet.errorMessage || 'Connection permission is denied.', onConnect: () => walletManager.connect(activeWallet.option.name).then(close) }));
|
|
16
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ConnectModalHead, ConnectModalWalletList } from "@interchain-ui/react";
|
|
3
|
+
import { useWalletModal } from "../provider";
|
|
4
|
+
import { useWalletManager } from "../../hooks";
|
|
5
|
+
export const WalletListHeader = () => {
|
|
6
|
+
const { close } = useWalletModal();
|
|
7
|
+
return (_jsx(ConnectModalHead, { title: "Select your wallet", hasBackButton: false, onClose: close, closeButtonProps: { onClick: close } }));
|
|
8
|
+
};
|
|
9
|
+
export const WalletListContent = () => {
|
|
10
|
+
const walletManager = useWalletManager();
|
|
11
|
+
const { close } = useWalletModal();
|
|
12
|
+
const wallets = walletManager.wallets.map((w) => {
|
|
13
|
+
return ({
|
|
14
|
+
name: w.option.name,
|
|
15
|
+
prettyName: w.option.prettyName,
|
|
16
|
+
logo: w.option.logo,
|
|
17
|
+
mobileDisabled: true,
|
|
18
|
+
shape: 'list',
|
|
19
|
+
originalWallet: w
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
const onWalletClick = async (wallet) => {
|
|
23
|
+
try {
|
|
24
|
+
await walletManager.connect(wallet.option.name);
|
|
25
|
+
close();
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
console.log(error);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
return _jsx(ConnectModalWalletList, { wallets: wallets, onWalletItemClick: onWalletClick });
|
|
32
|
+
};
|
package/esm/utils/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './wallet';
|
package/hooks/index.d.ts
CHANGED
package/hooks/index.js
CHANGED
package/hooks/useAccount.js
CHANGED
|
@@ -9,8 +9,15 @@ const useAccount = (chainName, walletName) => {
|
|
|
9
9
|
const [account, setAccount] = (0, react_1.useState)(null);
|
|
10
10
|
const chain = walletManager.chains.find(c => c.chainName === chainName);
|
|
11
11
|
const getAccount = async () => {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
if (wallet && chain) {
|
|
13
|
+
if (wallet.walletState === "Connected" /* WalletState.Connected */) {
|
|
14
|
+
const account = await wallet.getAccount(chain.chainId);
|
|
15
|
+
setAccount(account);
|
|
16
|
+
}
|
|
17
|
+
if (wallet.walletState === "Disconnected" /* WalletState.Disconnected */) {
|
|
18
|
+
setAccount(null);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
14
21
|
};
|
|
15
22
|
(0, react_1.useEffect)(() => {
|
|
16
23
|
if (wallet) {
|
|
@@ -18,10 +25,6 @@ const useAccount = (chainName, walletName) => {
|
|
|
18
25
|
}
|
|
19
26
|
}, [wallet]);
|
|
20
27
|
(0, react_1.useEffect)(() => {
|
|
21
|
-
if (!wallet) {
|
|
22
|
-
setAccount(null);
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
28
|
getAccount();
|
|
26
29
|
}, [wallet, chainName, wallet?.walletState]);
|
|
27
30
|
return account;
|
package/hooks/useActiveWallet.js
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useActiveWallet = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
4
5
|
const useWalletManager_1 = require("./useWalletManager");
|
|
6
|
+
const modal_1 = require("../modal");
|
|
5
7
|
const useActiveWallet = () => {
|
|
6
8
|
const walletManager = (0, useWalletManager_1.useWalletManager)();
|
|
9
|
+
const { open } = (0, modal_1.useWalletModal)();
|
|
10
|
+
(0, react_1.useEffect)(() => {
|
|
11
|
+
if (!walletManager.activeWalletName) {
|
|
12
|
+
open();
|
|
13
|
+
}
|
|
14
|
+
}, [walletManager.activeWalletName]);
|
|
7
15
|
return walletManager.getActiveWallet();
|
|
8
16
|
};
|
|
9
17
|
exports.useActiveWallet = useActiveWallet;
|
package/hooks/useChain.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { UseChainReturnType } from '../types/chain';
|
|
2
|
-
export declare const useChain: (chainName: string) => UseChainReturnType;
|
|
1
|
+
import { CosmosKitUseChainReturnType, UseChainReturnType } from '../types/chain';
|
|
2
|
+
export declare const useChain: (chainName: string) => UseChainReturnType & CosmosKitUseChainReturnType;
|
package/hooks/useChain.js
CHANGED
|
@@ -4,31 +4,43 @@ exports.useChain = void 0;
|
|
|
4
4
|
const useWalletManager_1 = require("./useWalletManager");
|
|
5
5
|
const useAccount_1 = require("./useAccount");
|
|
6
6
|
const useActiveWallet_1 = require("./useActiveWallet");
|
|
7
|
-
const
|
|
7
|
+
const useInterchainClient_1 = require("./useInterchainClient");
|
|
8
|
+
const modal_1 = require("../modal");
|
|
9
|
+
const core_1 = require("@interChain-kit/core");
|
|
8
10
|
const useChain = (chainName) => {
|
|
9
11
|
const walletManager = (0, useWalletManager_1.useWalletManager)();
|
|
10
12
|
const chainToShow = walletManager.chains.find((c) => c.chainName === chainName);
|
|
11
13
|
const assetList = walletManager.assetLists.find((a) => a.chainName === chainName);
|
|
12
14
|
const activeWallet = (0, useActiveWallet_1.useActiveWallet)();
|
|
13
|
-
const account = (0, useAccount_1.useAccount)(chainName, activeWallet
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
const account = (0, useAccount_1.useAccount)(chainName, activeWallet?.option?.name);
|
|
16
|
+
const interchainClient = (0, useInterchainClient_1.useInterchainClient)(chainName, activeWallet?.option?.name);
|
|
17
|
+
if (!chainToShow) {
|
|
18
|
+
throw new core_1.ChainNameNotExist(chainName);
|
|
19
|
+
}
|
|
20
|
+
const { open, close } = (0, modal_1.useWalletModal)();
|
|
21
|
+
const cosmosKitUserChainReturnType = {
|
|
22
|
+
connect: () => {
|
|
23
|
+
if (activeWallet) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
open();
|
|
27
|
+
},
|
|
28
|
+
openView: open,
|
|
29
|
+
closeView: close,
|
|
30
|
+
getRpcEndpoint: () => walletManager.getRpcEndpoint(activeWallet, chainName),
|
|
31
|
+
status: activeWallet?.walletState,
|
|
32
|
+
username: account?.username,
|
|
33
|
+
message: activeWallet?.errorMessage,
|
|
34
|
+
getSigningCosmWasmClient: () => walletManager.createClientFactory(activeWallet, chainName).then((c) => c.getSigningCosmwasmClient()),
|
|
35
|
+
getSigningCosmosClient: () => walletManager.createClientFactory(activeWallet, chainName).then((c) => c.getSigningCosmosClient())
|
|
36
|
+
};
|
|
20
37
|
return {
|
|
21
38
|
chain: chainToShow,
|
|
22
39
|
assetList,
|
|
23
40
|
address: account?.address,
|
|
24
41
|
wallet: activeWallet,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
getSigningClient: () => clientFactory.getSigningClient(),
|
|
28
|
-
getCosmwasmClient: () => clientFactory.getCosmwasmClient(),
|
|
29
|
-
getSigningCosmwasmClient: () => clientFactory.getSigningCosmwasmClient(),
|
|
30
|
-
getSigningStargateClient: () => clientFactory.getSigningStargateClient(),
|
|
31
|
-
getStargateClient: () => clientFactory.getStargateClient(),
|
|
42
|
+
...cosmosKitUserChainReturnType, //for migration cosmos kit
|
|
43
|
+
...interchainClient
|
|
32
44
|
};
|
|
33
45
|
};
|
|
34
46
|
exports.useChain = useChain;
|
|
@@ -1,15 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export declare const useChainWallet: (chainName: string, walletName: string) => {
|
|
4
|
-
chain: Chain;
|
|
5
|
-
assetList: AssetList;
|
|
6
|
-
address: string;
|
|
7
|
-
wallet: BaseWallet;
|
|
8
|
-
getRpcEndpoint: () => Promise<string | import("@cosmjs/tendermint-rpc").HttpEndpoint>;
|
|
9
|
-
getClient: () => Promise<import("@cosmjs/stargate").StargateClient | import("@cosmjs/cosmwasm-stargate").CosmWasmClient>;
|
|
10
|
-
getSigningClient: () => Promise<import("@cosmjs/stargate").SigningStargateClient | import("@cosmjs/cosmwasm-stargate").SigningCosmWasmClient>;
|
|
11
|
-
getCosmwasmClient: () => Promise<import("@cosmjs/cosmwasm-stargate").CosmWasmClient>;
|
|
12
|
-
getSigningCosmwasmClient: () => Promise<import("@cosmjs/cosmwasm-stargate").SigningCosmWasmClient>;
|
|
13
|
-
getSigningStargateClient: () => Promise<import("@cosmjs/stargate").SigningStargateClient>;
|
|
14
|
-
getStargateClient: () => Promise<import("@cosmjs/stargate").StargateClient>;
|
|
15
|
-
};
|
|
1
|
+
import { UseChainReturnType } from "../types/chain";
|
|
2
|
+
export declare const useChainWallet: (chainName: string, walletName: string) => UseChainReturnType;
|
package/hooks/useChainWallet.js
CHANGED
|
@@ -3,38 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useChainWallet = void 0;
|
|
4
4
|
const useWalletManager_1 = require("./useWalletManager");
|
|
5
5
|
const useAccount_1 = require("./useAccount");
|
|
6
|
-
const
|
|
7
|
-
const core_1 = require("@interChain-kit/core");
|
|
6
|
+
const useInterchainClient_1 = require("./useInterchainClient");
|
|
8
7
|
const useChainWallet = (chainName, walletName) => {
|
|
9
8
|
const walletManager = (0, useWalletManager_1.useWalletManager)();
|
|
10
9
|
const chainToShow = walletManager.chains.find((c) => c.chainName === chainName);
|
|
11
10
|
const assetList = walletManager.assetLists.find((a) => a.chainName === chainName);
|
|
12
11
|
const wallet = walletManager.wallets.find((w) => w.option.name === walletName);
|
|
13
12
|
const account = (0, useAccount_1.useAccount)(chainName, walletName);
|
|
14
|
-
const
|
|
15
|
-
(0, react_1.useEffect)(() => {
|
|
16
|
-
if (!wallet) {
|
|
17
|
-
throw new core_1.WalletNotExist(walletName);
|
|
18
|
-
}
|
|
19
|
-
if (!chainToShow) {
|
|
20
|
-
throw new core_1.ChainNotExist(chainName);
|
|
21
|
-
}
|
|
22
|
-
walletManager.createClientFactory(wallet, chainName).then(clientFactory => {
|
|
23
|
-
setClientFactory(clientFactory);
|
|
24
|
-
});
|
|
25
|
-
}, [chainName, walletName, account?.address]);
|
|
13
|
+
const interchainClient = (0, useInterchainClient_1.useInterchainClient)(chainName, walletName);
|
|
26
14
|
return {
|
|
27
15
|
chain: chainToShow,
|
|
28
16
|
assetList,
|
|
29
17
|
address: account?.address,
|
|
30
18
|
wallet,
|
|
31
|
-
|
|
32
|
-
getClient: () => clientFactory.getClient(),
|
|
33
|
-
getSigningClient: async () => clientFactory.getSigningClient(),
|
|
34
|
-
getCosmwasmClient: () => clientFactory.getCosmwasmClient(),
|
|
35
|
-
getSigningCosmwasmClient: () => clientFactory.getSigningCosmwasmClient(),
|
|
36
|
-
getSigningStargateClient: () => clientFactory.getSigningStargateClient(),
|
|
37
|
-
getStargateClient: () => clientFactory.getStargateClient(),
|
|
19
|
+
...interchainClient
|
|
38
20
|
};
|
|
39
21
|
};
|
|
40
22
|
exports.useChainWallet = useChainWallet;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AssetList, Chain } from "@chain-registry/v2-types";
|
|
2
|
+
import { EndpointOptions, SignerOptions } from "@interChain-kit/core";
|
|
3
|
+
export declare const useConfig: () => {
|
|
4
|
+
updateChains: (chains: Chain[]) => Chain[];
|
|
5
|
+
updateAssetLists: (assetLists: AssetList[]) => AssetList[];
|
|
6
|
+
updateSignerOptions: (signerOptions: SignerOptions) => SignerOptions;
|
|
7
|
+
updateEndpoints: (endpointOptions: EndpointOptions) => EndpointOptions;
|
|
8
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useConfig = void 0;
|
|
4
|
+
const useWalletManager_1 = require("./useWalletManager");
|
|
5
|
+
const useConfig = () => {
|
|
6
|
+
const walletManager = (0, useWalletManager_1.useWalletManager)();
|
|
7
|
+
return {
|
|
8
|
+
updateChains: (chains) => walletManager.chains = chains,
|
|
9
|
+
updateAssetLists: (assetLists) => walletManager.assetLists = assetLists,
|
|
10
|
+
updateSignerOptions: (signerOptions) => walletManager.signerOptions = signerOptions,
|
|
11
|
+
updateEndpoints: (endpointOptions) => walletManager.endpointOptions = endpointOptions,
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
exports.useConfig = useConfig;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { HttpEndpoint } from '@interchainjs/types';
|
|
2
|
+
import { CosmWasmSigningClient } from 'interchainjs/cosmwasm';
|
|
3
|
+
import { CosmosSigningClient } from 'interchainjs/cosmos';
|
|
4
|
+
import { SigningClient } from 'interchainjs/signing-client';
|
|
5
|
+
import { RpcQuery } from 'interchainjs/query/rpc';
|
|
6
|
+
import { InjSigningClient } from '@interchainjs/injective/signing-client';
|
|
7
|
+
export declare const useInterchainClient: (chainName: string, walletName: string) => {
|
|
8
|
+
rpcEndpoint: string | HttpEndpoint;
|
|
9
|
+
signingClient: SigningClient;
|
|
10
|
+
queryClient: RpcQuery;
|
|
11
|
+
signingCosmosClient: CosmosSigningClient;
|
|
12
|
+
signingCosmWasmClient: CosmWasmSigningClient;
|
|
13
|
+
signingInjectiveClient: InjSigningClient;
|
|
14
|
+
error: unknown;
|
|
15
|
+
isLoading: boolean;
|
|
16
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useInterchainClient = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const useWalletManager_1 = require("./useWalletManager");
|
|
6
|
+
const useAccount_1 = require("./useAccount");
|
|
7
|
+
const useInterchainClient = (chainName, walletName) => {
|
|
8
|
+
const [rpcEndpoint, setRpcEndpoint] = (0, react_1.useState)();
|
|
9
|
+
//query
|
|
10
|
+
const [queryClient, setQueryClient] = (0, react_1.useState)(null);
|
|
11
|
+
//signing
|
|
12
|
+
const [signingClient, setSigningClient] = (0, react_1.useState)(null);
|
|
13
|
+
const [signingCosmosClient, setSigningCosmosClient] = (0, react_1.useState)(null);
|
|
14
|
+
const [signingCosmWasmClient, setSigningCosmWasmClient] = (0, react_1.useState)(null);
|
|
15
|
+
const [signingInjectiveClient, setSigningInjectiveClient] = (0, react_1.useState)(null);
|
|
16
|
+
const [error, setError] = (0, react_1.useState)(null);
|
|
17
|
+
const [isLoading, setIsLoading] = (0, react_1.useState)(false);
|
|
18
|
+
const walletManager = (0, useWalletManager_1.useWalletManager)();
|
|
19
|
+
const account = (0, useAccount_1.useAccount)(chainName, walletName);
|
|
20
|
+
const wallet = walletManager.wallets.find((w) => w.option.name === walletName);
|
|
21
|
+
const chainToShow = walletManager.chains.find((c) => c.chainName === chainName);
|
|
22
|
+
const initialize = async () => {
|
|
23
|
+
if (wallet && chainToShow && wallet?.walletState === "Connected" /* WalletState.Connected */) {
|
|
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 queryClient = await clientFactory.getClient();
|
|
30
|
+
setQueryClient(queryClient);
|
|
31
|
+
const signingClient = await clientFactory.getSigningClient();
|
|
32
|
+
setSigningClient(signingClient);
|
|
33
|
+
const signingStargateClient = await clientFactory.getSigningCosmosClient(chainToShow.bech32Prefix);
|
|
34
|
+
setSigningCosmosClient(signingStargateClient);
|
|
35
|
+
const signingCosmwasmClient = await clientFactory.getSigningCosmwasmClient(chainToShow.bech32Prefix);
|
|
36
|
+
setSigningCosmWasmClient(signingCosmwasmClient);
|
|
37
|
+
const signingInjectiveClient = await clientFactory.getSigningInjectiveClient(chainToShow.bech32Prefix);
|
|
38
|
+
setSigningInjectiveClient(signingInjectiveClient);
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
setError(error);
|
|
42
|
+
}
|
|
43
|
+
finally {
|
|
44
|
+
setIsLoading(false);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
(0, react_1.useEffect)(() => {
|
|
49
|
+
initialize();
|
|
50
|
+
}, [chainName, walletName, account, wallet?.walletState]);
|
|
51
|
+
return {
|
|
52
|
+
rpcEndpoint,
|
|
53
|
+
signingClient: chainName === 'injective' ? signingInjectiveClient : signingClient,
|
|
54
|
+
queryClient,
|
|
55
|
+
signingCosmosClient,
|
|
56
|
+
signingCosmWasmClient,
|
|
57
|
+
signingInjectiveClient,
|
|
58
|
+
error,
|
|
59
|
+
isLoading
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
exports.useInterchainClient = useInterchainClient;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useOfflineSigner = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const useWalletManager_1 = require("./useWalletManager");
|
|
6
|
+
const useOfflineSigner = (chainName, walletName) => {
|
|
7
|
+
const walletManager = (0, useWalletManager_1.useWalletManager)();
|
|
8
|
+
const wallet = walletManager.wallets.find((w) => w.option.name === walletName);
|
|
9
|
+
const [offlineSigner, setOfflineSigner] = (0, react_1.useState)(null);
|
|
10
|
+
(0, react_1.useEffect)(() => {
|
|
11
|
+
if (wallet && chainName) {
|
|
12
|
+
setOfflineSigner(walletManager.getOfflineSigner(wallet, chainName));
|
|
13
|
+
}
|
|
14
|
+
}, [wallet, chainName]);
|
|
15
|
+
return {
|
|
16
|
+
offlineSigner
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
exports.useOfflineSigner = useOfflineSigner;
|
package/modal/modal.js
CHANGED
|
@@ -2,19 +2,34 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WalletModal = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("@interchain-ui/react");
|
|
6
|
+
const views_1 = require("./views");
|
|
7
|
+
const provider_1 = require("./provider");
|
|
5
8
|
const hooks_1 = require("../hooks");
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
left: '50%',
|
|
10
|
-
transform: 'translate(-50%,-50%)',
|
|
11
|
-
width: '500px',
|
|
12
|
-
backgroundColor: 'white',
|
|
9
|
+
const react_2 = require("react");
|
|
10
|
+
const defaultModalView = {
|
|
11
|
+
header: (0, jsx_runtime_1.jsx)(views_1.WalletListHeader, {}), content: (0, jsx_runtime_1.jsx)(views_1.WalletListContent, {})
|
|
13
12
|
};
|
|
14
13
|
const WalletModal = () => {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
const { modalIsOpen, open, close } = (0, provider_1.useWalletModal)();
|
|
15
|
+
const activeWallet = (0, hooks_1.useActiveWallet)();
|
|
16
|
+
const [modalView, setModalView] = (0, react_2.useState)(defaultModalView);
|
|
17
|
+
const gotoWalletList = () => setModalView(defaultModalView);
|
|
18
|
+
(0, react_2.useEffect)(() => {
|
|
19
|
+
switch (true) {
|
|
20
|
+
case activeWallet?.walletState === "Connecting" /* WalletState.Connecting */:
|
|
21
|
+
setModalView({ header: (0, jsx_runtime_1.jsx)(views_1.ConnectingHeader, { onBack: gotoWalletList }), content: (0, jsx_runtime_1.jsx)(views_1.ConnectingContent, {}) });
|
|
22
|
+
break;
|
|
23
|
+
case activeWallet?.walletState === "Connected" /* WalletState.Connected */:
|
|
24
|
+
setModalView({ header: (0, jsx_runtime_1.jsx)(views_1.ConnectedHeader, { onBack: gotoWalletList }), content: (0, jsx_runtime_1.jsx)(views_1.ConnectedContent, {}) });
|
|
25
|
+
break;
|
|
26
|
+
case activeWallet?.walletState === "Reject" /* WalletState.Reject */:
|
|
27
|
+
setModalView({ header: (0, jsx_runtime_1.jsx)(views_1.RejectHeader, { onBack: gotoWalletList }), content: (0, jsx_runtime_1.jsx)(views_1.RejectContent, {}) });
|
|
28
|
+
break;
|
|
29
|
+
default:
|
|
30
|
+
setModalView(defaultModalView);
|
|
31
|
+
}
|
|
32
|
+
}, [activeWallet, activeWallet?.walletState]);
|
|
33
|
+
return ((0, jsx_runtime_1.jsx)(react_1.ConnectModal, { isOpen: modalIsOpen, header: modalView.header, onOpen: open, onClose: close, children: modalView.content }));
|
|
19
34
|
};
|
|
20
35
|
exports.WalletModal = WalletModal;
|
package/modal/provider.js
CHANGED
|
@@ -3,14 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useWalletModal = exports.WalletModalProvider = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
-
const react_dom_1 = require("react-dom");
|
|
7
6
|
const modal_1 = require("./modal");
|
|
8
7
|
const WalletModalContext = (0, react_1.createContext)(null);
|
|
9
8
|
const WalletModalProvider = ({ children }) => {
|
|
10
9
|
const [modalIsOpen, setModalIsOpen] = (0, react_1.useState)(false);
|
|
11
10
|
const open = () => setModalIsOpen(true);
|
|
12
11
|
const close = () => setModalIsOpen(false);
|
|
13
|
-
return ((0, jsx_runtime_1.jsxs)(WalletModalContext.Provider, { value: { modalIsOpen, open, close }, children: [children,
|
|
12
|
+
return ((0, jsx_runtime_1.jsxs)(WalletModalContext.Provider, { value: { modalIsOpen, open, close }, children: [children, (0, jsx_runtime_1.jsx)(modal_1.WalletModal, {})] }));
|
|
14
13
|
};
|
|
15
14
|
exports.WalletModalProvider = WalletModalProvider;
|
|
16
15
|
const useWalletModal = () => {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AstronautSvg = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
function AstronautSvg(props) {
|
|
6
|
+
return ((0, jsx_runtime_1.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", className: "chakra-icon css-1plqj06", viewBox: "0 0 278 255", ...props, children: [(0, jsx_runtime_1.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" }), (0, jsx_runtime_1.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" }), (0, jsx_runtime_1.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" }), (0, jsx_runtime_1.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" }), (0, jsx_runtime_1.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" }), (0, jsx_runtime_1.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" }), (0, jsx_runtime_1.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" }), (0, jsx_runtime_1.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" }), (0, jsx_runtime_1.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" }), (0, jsx_runtime_1.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" }), (0, jsx_runtime_1.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" }), (0, jsx_runtime_1.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" }), (0, jsx_runtime_1.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" }), (0, jsx_runtime_1.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" }), (0, jsx_runtime_1.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" }), (0, jsx_runtime_1.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" }), (0, jsx_runtime_1.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" }), (0, jsx_runtime_1.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" }), (0, jsx_runtime_1.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" }), (0, jsx_runtime_1.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" }), (0, jsx_runtime_1.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" }), (0, jsx_runtime_1.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" }), (0, jsx_runtime_1.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" }), (0, jsx_runtime_1.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" }), (0, jsx_runtime_1.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" }), (0, jsx_runtime_1.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" }), (0, jsx_runtime_1.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" }), (0, jsx_runtime_1.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" }), (0, jsx_runtime_1.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 }), (0, jsx_runtime_1.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" }), (0, jsx_runtime_1.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" }), (0, jsx_runtime_1.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" }), (0, jsx_runtime_1.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" }), (0, jsx_runtime_1.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" }), (0, jsx_runtime_1.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" }), (0, jsx_runtime_1.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" }), (0, jsx_runtime_1.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" })] }));
|
|
7
|
+
}
|
|
8
|
+
exports.AstronautSvg = AstronautSvg;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConnectedContent = exports.ConnectedHeader = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("@interchain-ui/react");
|
|
6
|
+
const hooks_1 = require("../../hooks");
|
|
7
|
+
const provider_1 = require("../provider");
|
|
8
|
+
const utils_1 = require("../../utils");
|
|
9
|
+
const Astronaut_1 = require("./Astronaut");
|
|
10
|
+
const ConnectedHeader = ({ onBack }) => {
|
|
11
|
+
const activeWallet = (0, hooks_1.useActiveWallet)();
|
|
12
|
+
const { close } = (0, provider_1.useWalletModal)();
|
|
13
|
+
return ((0, jsx_runtime_1.jsx)(react_1.ConnectModalHead, { title: activeWallet?.option?.prettyName || '', hasBackButton: true, onClose: close, onBack: onBack, closeButtonProps: { onClick: close } }));
|
|
14
|
+
};
|
|
15
|
+
exports.ConnectedHeader = ConnectedHeader;
|
|
16
|
+
const ConnectedContent = () => {
|
|
17
|
+
const activeWallet = (0, hooks_1.useActiveWallet)();
|
|
18
|
+
const walletManager = (0, hooks_1.useWalletManager)();
|
|
19
|
+
const account = (0, hooks_1.useAccount)(walletManager.chains[0].chainName, activeWallet?.option?.name);
|
|
20
|
+
const { close } = (0, provider_1.useWalletModal)();
|
|
21
|
+
if (!activeWallet) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
return ((0, jsx_runtime_1.jsx)(react_1.ConnectModalStatus, { wallet: (0, utils_1.getWalletInfo)(activeWallet), status: 'Connected', connectedInfo: {
|
|
25
|
+
name: account?.username || 'Wallet',
|
|
26
|
+
avatar: ((0, jsx_runtime_1.jsx)(Astronaut_1.AstronautSvg, { style: {
|
|
27
|
+
fontSize: 'inherit',
|
|
28
|
+
width: '100%',
|
|
29
|
+
height: '100%',
|
|
30
|
+
} })),
|
|
31
|
+
address: account?.address,
|
|
32
|
+
}, onDisconnect: async () => {
|
|
33
|
+
await walletManager.disconnect(activeWallet?.option?.name);
|
|
34
|
+
close();
|
|
35
|
+
} }));
|
|
36
|
+
};
|
|
37
|
+
exports.ConnectedContent = ConnectedContent;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConnectingContent = exports.ConnectingHeader = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("@interchain-ui/react");
|
|
6
|
+
const hooks_1 = require("../../hooks");
|
|
7
|
+
const provider_1 = require("../provider");
|
|
8
|
+
const ConnectingHeader = ({ onBack }) => {
|
|
9
|
+
const wallet = (0, hooks_1.useActiveWallet)();
|
|
10
|
+
const { close } = (0, provider_1.useWalletModal)();
|
|
11
|
+
const walletManager = (0, hooks_1.useWalletManager)();
|
|
12
|
+
if (!wallet)
|
|
13
|
+
return null;
|
|
14
|
+
return ((0, jsx_runtime_1.jsx)(react_1.ConnectModalHead, { title: wallet.option.prettyName, hasBackButton: true, onClose: close, onBack: onBack, closeButtonProps: {
|
|
15
|
+
onClick: async () => {
|
|
16
|
+
await walletManager.disconnect(wallet.option.name);
|
|
17
|
+
close();
|
|
18
|
+
}
|
|
19
|
+
} }));
|
|
20
|
+
};
|
|
21
|
+
exports.ConnectingHeader = ConnectingHeader;
|
|
22
|
+
const ConnectingContent = () => {
|
|
23
|
+
const activeWallet = (0, hooks_1.useActiveWallet)();
|
|
24
|
+
const { option: { prettyName, mode } } = activeWallet;
|
|
25
|
+
let title = 'Requesting Connection';
|
|
26
|
+
let desc = mode === 'wallet-connect'
|
|
27
|
+
? `Approve ${prettyName} connection request on your mobile.`
|
|
28
|
+
: `Open the ${prettyName} browser extension to connect your wallet.`;
|
|
29
|
+
if (!activeWallet)
|
|
30
|
+
return null;
|
|
31
|
+
return ((0, jsx_runtime_1.jsx)(react_1.ConnectModalStatus, { wallet: {
|
|
32
|
+
name: activeWallet.option.name,
|
|
33
|
+
prettyName: activeWallet.option.prettyName,
|
|
34
|
+
logo: activeWallet.option.logo,
|
|
35
|
+
mobileDisabled: true,
|
|
36
|
+
}, status: 'Connecting', contentHeader: title, contentDesc: desc }));
|
|
37
|
+
};
|
|
38
|
+
exports.ConnectingContent = ConnectingContent;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RejectContent = exports.RejectHeader = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("@interchain-ui/react");
|
|
6
|
+
const provider_1 = require("../provider");
|
|
7
|
+
const hooks_1 = require("../../hooks");
|
|
8
|
+
const utils_1 = require("../../utils");
|
|
9
|
+
const RejectHeader = ({ onBack }) => {
|
|
10
|
+
const { close } = (0, provider_1.useWalletModal)();
|
|
11
|
+
const activeWallet = (0, hooks_1.useActiveWallet)();
|
|
12
|
+
return ((0, jsx_runtime_1.jsx)(react_1.ConnectModalHead, { title: activeWallet.option.prettyName, hasBackButton: true, onClose: close, onBack: onBack, closeButtonProps: { onClick: close } }));
|
|
13
|
+
};
|
|
14
|
+
exports.RejectHeader = RejectHeader;
|
|
15
|
+
const RejectContent = () => {
|
|
16
|
+
const activeWallet = (0, hooks_1.useActiveWallet)();
|
|
17
|
+
const walletManager = (0, hooks_1.useWalletManager)();
|
|
18
|
+
const { close } = (0, provider_1.useWalletModal)();
|
|
19
|
+
return ((0, jsx_runtime_1.jsx)(react_1.ConnectModalStatus, { status: "Rejected", wallet: (0, utils_1.getWalletInfo)(activeWallet), contentHeader: 'Request Rejected', contentDesc: activeWallet.errorMessage || 'Connection permission is denied.', onConnect: () => walletManager.connect(activeWallet.option.name).then(close) }));
|
|
20
|
+
};
|
|
21
|
+
exports.RejectContent = RejectContent;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WalletListContent = exports.WalletListHeader = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("@interchain-ui/react");
|
|
6
|
+
const provider_1 = require("../provider");
|
|
7
|
+
const hooks_1 = require("../../hooks");
|
|
8
|
+
const WalletListHeader = () => {
|
|
9
|
+
const { close } = (0, provider_1.useWalletModal)();
|
|
10
|
+
return ((0, jsx_runtime_1.jsx)(react_1.ConnectModalHead, { title: "Select your wallet", hasBackButton: false, onClose: close, closeButtonProps: { onClick: close } }));
|
|
11
|
+
};
|
|
12
|
+
exports.WalletListHeader = WalletListHeader;
|
|
13
|
+
const WalletListContent = () => {
|
|
14
|
+
const walletManager = (0, hooks_1.useWalletManager)();
|
|
15
|
+
const { close } = (0, provider_1.useWalletModal)();
|
|
16
|
+
const wallets = walletManager.wallets.map((w) => {
|
|
17
|
+
return ({
|
|
18
|
+
name: w.option.name,
|
|
19
|
+
prettyName: w.option.prettyName,
|
|
20
|
+
logo: w.option.logo,
|
|
21
|
+
mobileDisabled: true,
|
|
22
|
+
shape: 'list',
|
|
23
|
+
originalWallet: w
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
const onWalletClick = async (wallet) => {
|
|
27
|
+
try {
|
|
28
|
+
await walletManager.connect(wallet.option.name);
|
|
29
|
+
close();
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
console.log(error);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
return (0, jsx_runtime_1.jsx)(react_1.ConnectModalWalletList, { wallets: wallets, onWalletItemClick: onWalletClick });
|
|
36
|
+
};
|
|
37
|
+
exports.WalletListContent = WalletListContent;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./Connecting"), exports);
|
|
18
|
+
__exportStar(require("./WalletList"), exports);
|
|
19
|
+
__exportStar(require("./Connected"), exports);
|
|
20
|
+
__exportStar(require("./Reject"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@interchain-kit/react",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.12",
|
|
4
4
|
"author": "cosmology-tech <developers@cosmology.zone>",
|
|
5
5
|
"description": "interchain-kit wallet connector react package",
|
|
6
6
|
"main": "index.js",
|
|
@@ -32,11 +32,13 @@
|
|
|
32
32
|
"keywords": [],
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@chain-registry/v2-types": "^0.49.6",
|
|
35
|
-
"@interchain-kit/core": "0.0.1-beta.
|
|
35
|
+
"@interchain-kit/core": "0.0.1-beta.12",
|
|
36
|
+
"@interchain-ui/react": "^1.23.31",
|
|
36
37
|
"@types/react": "^18.3.3",
|
|
37
38
|
"@types/react-dom": "^18.3.0",
|
|
39
|
+
"interchainjs": "^0.0.1-beta.13",
|
|
38
40
|
"react": "^18.3.1",
|
|
39
41
|
"react-dom": "^18.3.1"
|
|
40
42
|
},
|
|
41
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "006691cb2cefe22a711860a0d3ee26ddd33c052d"
|
|
42
44
|
}
|
package/types/chain.d.ts
CHANGED
|
@@ -1,10 +1,31 @@
|
|
|
1
|
-
import { HttpEndpoint } from '@
|
|
1
|
+
import { HttpEndpoint } from '@interchainjs/types';
|
|
2
|
+
import { CosmWasmSigningClient } from 'interchainjs/cosmwasm';
|
|
3
|
+
import { SigningClient } from 'interchainjs/signing-client';
|
|
4
|
+
import { RpcQuery } from 'interchainjs/query/rpc';
|
|
5
|
+
import { CosmosSigningClient } from 'interchainjs/cosmos';
|
|
2
6
|
import { Chain, AssetList } from '@chain-registry/v2-types';
|
|
3
|
-
import { BaseWallet,
|
|
7
|
+
import { BaseWallet, WalletState } from '@interchain-kit/core';
|
|
8
|
+
export type CosmosKitUseChainReturnType = {
|
|
9
|
+
connect: () => void;
|
|
10
|
+
openView: () => void;
|
|
11
|
+
closeView: () => void;
|
|
12
|
+
getRpcEndpoint: () => Promise<string | HttpEndpoint>;
|
|
13
|
+
status: WalletState;
|
|
14
|
+
username: string;
|
|
15
|
+
message: string;
|
|
16
|
+
getSigningCosmWasmClient: () => Promise<CosmWasmSigningClient>;
|
|
17
|
+
getSigningCosmosClient: () => Promise<CosmosSigningClient>;
|
|
18
|
+
};
|
|
4
19
|
export type UseChainReturnType = {
|
|
5
20
|
chain: Chain;
|
|
6
21
|
assetList: AssetList;
|
|
7
22
|
address: string;
|
|
8
23
|
wallet: BaseWallet;
|
|
9
|
-
|
|
10
|
-
|
|
24
|
+
rpcEndpoint: string | HttpEndpoint;
|
|
25
|
+
queryClient: RpcQuery;
|
|
26
|
+
signingClient: SigningClient;
|
|
27
|
+
signingCosmosClient: CosmosSigningClient;
|
|
28
|
+
signingCosmWasmClient: CosmWasmSigningClient;
|
|
29
|
+
isLoading: boolean;
|
|
30
|
+
error: unknown;
|
|
31
|
+
};
|
package/utils/index.d.ts
CHANGED
package/utils/index.js
CHANGED
|
@@ -1 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getWalletInfo = void 0;
|
|
4
|
+
const getWalletInfo = (wallet) => {
|
|
5
|
+
return {
|
|
6
|
+
name: wallet.option.name,
|
|
7
|
+
prettyName: wallet.option.prettyName,
|
|
8
|
+
logo: wallet.option.logo,
|
|
9
|
+
mobileDisabled: true,
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
exports.getWalletInfo = getWalletInfo;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './wallet';
|
package/utils/wallet.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./wallet"), exports);
|