@interchain-kit/react 0.2.208 → 0.2.212
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/README.md +2 -2
- package/esm/hooks/useChainWallet.js +2 -2
- package/esm/modal/modal.js +43 -91
- package/esm/modal/provider.js +30 -2
- package/esm/modal/views/Connected.js +3 -15
- package/esm/modal/views/Connecting.js +1 -3
- package/esm/modal/views/NotExist.js +4 -8
- package/esm/modal/views/QRCode.js +4 -15
- package/esm/modal/views/Reject.js +1 -3
- package/esm/modal/views/WalletList.js +3 -35
- package/esm/store/chain-wallet.js +7 -31
- package/esm/store/index.js +0 -219
- package/esm/store/store.js +73 -25
- package/esm/utils/wallet.js +24 -0
- package/hooks/useChainWallet.js +2 -2
- package/modal/modal.d.ts +30 -1
- package/modal/modal.js +41 -89
- package/modal/provider.js +29 -1
- package/modal/views/Connected.d.ts +7 -3
- package/modal/views/Connected.js +3 -15
- package/modal/views/Connecting.d.ts +2 -1
- package/modal/views/Connecting.js +1 -3
- package/modal/views/NotExist.d.ts +10 -3
- package/modal/views/NotExist.js +4 -8
- package/modal/views/QRCode.d.ts +9 -2
- package/modal/views/QRCode.js +4 -15
- package/modal/views/Reject.d.ts +2 -1
- package/modal/views/Reject.js +1 -3
- package/modal/views/WalletList.d.ts +7 -4
- package/modal/views/WalletList.js +3 -35
- package/package.json +19 -10
- package/store/chain-wallet.d.ts +8 -17
- package/store/chain-wallet.js +7 -31
- package/store/index.d.ts +0 -43
- package/store/index.js +0 -221
- package/store/store.d.ts +2 -4
- package/store/store.js +72 -24
- package/utils/wallet.d.ts +26 -0
- package/utils/wallet.js +26 -1
- package/esm/hooks/useAccount.js +0 -39
- package/hooks/useAccount.d.ts +0 -2
- package/hooks/useAccount.js +0 -43
package/README.md
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
</p>
|
|
6
6
|
|
|
7
7
|
<p align="center" width="100%">
|
|
8
|
-
<a href="https://github.com/hyperweb-io/
|
|
9
|
-
<img height="20" src="https://github.com/hyperweb-io/
|
|
8
|
+
<a href="https://github.com/hyperweb-io/interchain-kit/actions/workflows/unit-test.yaml">
|
|
9
|
+
<img height="20" src="https://github.com/hyperweb-io/interchain-kit/actions/workflows/unit-test.yaml/badge.svg" />
|
|
10
10
|
</a>
|
|
11
11
|
<a href="https://github.com/hyperweb-io/lib-count">
|
|
12
12
|
<img height="20" src="https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fhyperweb-io%2Flib-count%2Fmain%2Foutput%2Fbadges%2Fproducts%2Fcosmos-kit%2Ftotal.json"/>
|
|
@@ -9,9 +9,9 @@ export const useChainWallet = (chainName, walletName) => {
|
|
|
9
9
|
return {
|
|
10
10
|
//for migration cosmos kit
|
|
11
11
|
connect: async () => {
|
|
12
|
-
await connect(walletName, chainName);
|
|
13
12
|
setCurrentWalletName(walletName);
|
|
14
13
|
setCurrentChainName(chainName);
|
|
14
|
+
await connect(walletName, chainName);
|
|
15
15
|
await getAccount(walletName, chainName);
|
|
16
16
|
},
|
|
17
17
|
disconnect: () => disconnect(walletName, chainName),
|
|
@@ -24,7 +24,7 @@ export const useChainWallet = (chainName, walletName) => {
|
|
|
24
24
|
chain,
|
|
25
25
|
assetList,
|
|
26
26
|
address: chainWalletStateToShow?.account?.address,
|
|
27
|
-
wallet: new ChainWallet(wallet, () => connect(walletName, chainName), () => disconnect(walletName, chainName), () => getAccount(walletName, chainName)),
|
|
27
|
+
wallet: wallet ? new ChainWallet(wallet, () => connect(walletName, chainName), () => disconnect(walletName, chainName), () => getAccount(walletName, chainName)) : null,
|
|
28
28
|
rpcEndpoint: chainWalletStateToShow?.rpcEndpoint,
|
|
29
29
|
getSigningClient: () => getSigningClient(walletName, chainName),
|
|
30
30
|
};
|
package/esm/modal/modal.js
CHANGED
|
@@ -1,102 +1,54 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { ConnectedContent, ConnectedHeader, ConnectingContent, ConnectingHeader, NotExistContent, NotExistHeader, QRCodeContent, QRCodeHeader, RejectContent, RejectHeader, WalletListContent, WalletListHeader, } from "./views";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
import { ConnectModal, } from "@interchain-ui/react";
|
|
5
|
+
export const WalletModal = ({ shouldShowList, isOpen, walletConnectQRCodeUri, wallets, username, address, currentWallet, isConnecting, isConnected, isRejected, isDisconnected, isNotExist, errorMessage, open, close, disconnect, onSelectWallet, onBack, onReconnect, getDownloadLink, getEnv, }) => {
|
|
6
|
+
const { header, content } = useMemo(() => {
|
|
7
|
+
if (shouldShowList || isDisconnected) {
|
|
8
|
+
return {
|
|
9
|
+
header: _jsx(WalletListHeader, { close: close }),
|
|
10
|
+
content: (_jsx(WalletListContent, { onSelectWallet: onSelectWallet, wallets: wallets })),
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
if (currentWallet &&
|
|
14
|
+
walletConnectQRCodeUri &&
|
|
15
|
+
currentWallet.info.name === "WalletConnect") {
|
|
16
|
+
return {
|
|
17
|
+
header: (_jsx(QRCodeHeader, { wallet: currentWallet, close: close, onBack: onBack })),
|
|
18
|
+
content: (_jsx(QRCodeContent, { walletConnectQRCodeUri: walletConnectQRCodeUri, errorMessage: errorMessage, onReconnect: onReconnect })),
|
|
19
|
+
};
|
|
19
20
|
}
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
if (currentWallet && isNotExist) {
|
|
22
|
+
return {
|
|
23
|
+
header: (_jsx(NotExistHeader, { wallet: currentWallet, close: close, onBack: onBack })),
|
|
24
|
+
content: (_jsx(NotExistContent, { wallet: currentWallet, getDownloadLink: getDownloadLink, getEnv: getEnv })),
|
|
25
|
+
};
|
|
22
26
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
if (currentWallet && isRejected) {
|
|
28
|
+
return {
|
|
29
|
+
header: (_jsx(RejectHeader, { wallet: currentWallet, close: close, onBack: onBack })),
|
|
30
|
+
content: (_jsx(RejectContent, { wallet: currentWallet, onReconnect: onReconnect })),
|
|
31
|
+
};
|
|
27
32
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
if (!selectedWallet) {
|
|
35
|
-
setModalType("wallet-list");
|
|
33
|
+
if (currentWallet && isConnected) {
|
|
34
|
+
return {
|
|
35
|
+
header: (_jsx(ConnectedHeader, { wallet: currentWallet, onBack: onBack, close: close })),
|
|
36
|
+
content: (_jsx(ConnectedContent, { wallet: currentWallet, username: username, address: address, disconnect: disconnect })),
|
|
37
|
+
};
|
|
36
38
|
}
|
|
37
|
-
if (
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
setModalType("connected");
|
|
43
|
-
}
|
|
44
|
-
if (status === WalletState.Rejected) {
|
|
45
|
-
setModalType("reject");
|
|
46
|
-
}
|
|
47
|
-
if (status === WalletState.Disconnected) {
|
|
48
|
-
setModalType("wallet-list");
|
|
49
|
-
}
|
|
50
|
-
if (walletConnectQRCodeUri) {
|
|
51
|
-
setModalType("qr-code");
|
|
52
|
-
}
|
|
39
|
+
if (currentWallet && isConnecting) {
|
|
40
|
+
return {
|
|
41
|
+
header: (_jsx(ConnectingHeader, { wallet: currentWallet, close: close, onBack: onBack })),
|
|
42
|
+
content: _jsx(ConnectingContent, { wallet: currentWallet }),
|
|
43
|
+
};
|
|
53
44
|
}
|
|
54
45
|
}, [
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
46
|
+
currentWallet,
|
|
47
|
+
isConnected,
|
|
48
|
+
isConnecting,
|
|
49
|
+
address,
|
|
50
|
+
shouldShowList,
|
|
60
51
|
walletConnectQRCodeUri,
|
|
61
52
|
]);
|
|
62
|
-
|
|
63
|
-
const { header, content } = useMemo(() => {
|
|
64
|
-
switch (modalType) {
|
|
65
|
-
case "wallet-list":
|
|
66
|
-
return {
|
|
67
|
-
header: _jsx(WalletListHeader, {}),
|
|
68
|
-
content: _jsx(WalletListContent, { onSelectWallet: handleSelectWallet }),
|
|
69
|
-
};
|
|
70
|
-
case "connecting":
|
|
71
|
-
return {
|
|
72
|
-
header: _jsx(ConnectingHeader, { wallet: wallet, onBack: goBackList }),
|
|
73
|
-
content: _jsx(ConnectingContent, { wallet: wallet }),
|
|
74
|
-
};
|
|
75
|
-
case "connected":
|
|
76
|
-
return {
|
|
77
|
-
header: _jsx(ConnectedHeader, { wallet: wallet, onBack: goBackList }),
|
|
78
|
-
content: _jsx(ConnectedContent, { afterDisconnect: goBackList }),
|
|
79
|
-
};
|
|
80
|
-
case "reject":
|
|
81
|
-
return {
|
|
82
|
-
header: _jsx(RejectHeader, { wallet: wallet, onBack: goBackList }),
|
|
83
|
-
content: (_jsx(RejectContent, { wallet: wallet, onReconnect: () => {
|
|
84
|
-
setModalType("connecting");
|
|
85
|
-
wallet.connect(chain.chainId);
|
|
86
|
-
wallet.getAccount(chain.chainId);
|
|
87
|
-
} })),
|
|
88
|
-
};
|
|
89
|
-
case "not-exist":
|
|
90
|
-
return {
|
|
91
|
-
header: _jsx(NotExistHeader, { wallet: wallet, onBack: goBackList }),
|
|
92
|
-
content: _jsx(NotExistContent, { wallet: wallet }),
|
|
93
|
-
};
|
|
94
|
-
case "qr-code":
|
|
95
|
-
return {
|
|
96
|
-
header: _jsx(QRCodeHeader, { onBack: goBackList }),
|
|
97
|
-
content: _jsx(QRCodeContent, {}),
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
}, [modalType]);
|
|
101
|
-
return (_jsx(ConnectModal, { isOpen: modalIsOpen, header: header, onOpen: open, onClose: close, children: content }));
|
|
53
|
+
return (_jsx(ConnectModal, { isOpen: isOpen, header: header, onOpen: open, onClose: close, children: content }));
|
|
102
54
|
};
|
package/esm/modal/provider.js
CHANGED
|
@@ -1,12 +1,40 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { createContext, useContext, useState } from "react";
|
|
2
|
+
import { createContext, useContext, useEffect, useState } from "react";
|
|
3
3
|
import { WalletModal } from "./modal";
|
|
4
|
+
import { WalletState } from "@interchain-kit/core";
|
|
5
|
+
import { useChainWallet, useWalletManager } from "../hooks";
|
|
6
|
+
import { transferToWalletUISchema } from "../utils";
|
|
4
7
|
const WalletModalContext = createContext(null);
|
|
5
8
|
export const WalletModalProvider = ({ children, }) => {
|
|
6
9
|
const [modalIsOpen, setModalIsOpen] = useState(false);
|
|
7
10
|
const open = () => setModalIsOpen(true);
|
|
8
11
|
const close = () => setModalIsOpen(false);
|
|
9
|
-
|
|
12
|
+
const [walletNameToConnect, setWalletNameToConnect] = useState(null);
|
|
13
|
+
const { chains, wallets, setCurrentWalletName, currentChainName, currentWalletName, walletConnectQRCodeUri, getDownloadLink, getEnv, } = useWalletManager();
|
|
14
|
+
const { wallet, status, connect, disconnect, username, address, message } = useChainWallet(currentChainName || chains[0].chainName, currentWalletName);
|
|
15
|
+
const [shouldShowList, setShouldShowList] = useState(!(currentChainName && currentWalletName));
|
|
16
|
+
const walletsForUI = wallets.map(transferToWalletUISchema);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (walletNameToConnect) {
|
|
19
|
+
try {
|
|
20
|
+
connect();
|
|
21
|
+
setWalletNameToConnect(null);
|
|
22
|
+
setShouldShowList(false);
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
console.error("Error connecting to wallet:", error);
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}, [walletNameToConnect]);
|
|
30
|
+
const handleCloseModal = () => {
|
|
31
|
+
close();
|
|
32
|
+
setShouldShowList(false);
|
|
33
|
+
};
|
|
34
|
+
return (_jsxs(WalletModalContext.Provider, { value: { modalIsOpen, open, close }, children: [children, _jsx(WalletModal, { shouldShowList: shouldShowList, username: username, address: address, disconnect: disconnect, isOpen: modalIsOpen, open: open, close: handleCloseModal, wallets: walletsForUI, walletConnectQRCodeUri: walletConnectQRCodeUri, currentWallet: wallet?.originalWallet, isConnecting: status === WalletState.Connecting, isConnected: status === WalletState.Connected, isRejected: status === WalletState.Rejected, isDisconnected: status === WalletState.Disconnected, isNotExist: status === WalletState.NotExist, errorMessage: message, onSelectWallet: (w) => {
|
|
35
|
+
setWalletNameToConnect(w.info.name);
|
|
36
|
+
setCurrentWalletName(w.info.name);
|
|
37
|
+
}, onBack: () => setShouldShowList(true), onReconnect: connect, getDownloadLink: () => getDownloadLink(wallet?.info.name), getEnv: getEnv })] }));
|
|
10
38
|
};
|
|
11
39
|
export const useWalletModal = () => {
|
|
12
40
|
const context = useContext(WalletModalContext);
|
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { ConnectModalHead, ConnectModalStatus } from "@interchain-ui/react";
|
|
3
|
-
import { useChainWallet, useWalletManager } from "../../hooks";
|
|
4
|
-
import { useWalletModal } from "../provider";
|
|
5
3
|
import { getWalletInfo } from "../../utils";
|
|
6
4
|
import { AstronautSvg } from "./Astronaut";
|
|
7
|
-
export const ConnectedHeader = ({ wallet, onBack, }) => {
|
|
8
|
-
const { close } = useWalletModal();
|
|
5
|
+
export const ConnectedHeader = ({ wallet, close, onBack, }) => {
|
|
9
6
|
return (_jsx(ConnectModalHead, { title: wallet?.info?.prettyName || "", hasBackButton: true, onClose: close, onBack: onBack, closeButtonProps: { onClick: close } }));
|
|
10
7
|
};
|
|
11
|
-
export const ConnectedContent = ({
|
|
12
|
-
const { currentChainName, currentWalletName } = useWalletManager();
|
|
13
|
-
const { address, username, wallet } = useChainWallet(currentChainName, currentWalletName);
|
|
14
|
-
const { close } = useWalletModal();
|
|
15
|
-
if (!wallet) {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
8
|
+
export const ConnectedContent = ({ address, username, wallet, disconnect, }) => {
|
|
18
9
|
return (_jsx(ConnectModalStatus, { wallet: getWalletInfo(wallet), status: "Connected", connectedInfo: {
|
|
19
10
|
name: username || "Wallet",
|
|
20
11
|
avatar: (_jsx(AstronautSvg, { style: {
|
|
@@ -23,8 +14,5 @@ export const ConnectedContent = ({ afterDisconnect, }) => {
|
|
|
23
14
|
height: "100%",
|
|
24
15
|
} })),
|
|
25
16
|
address: address,
|
|
26
|
-
}, onDisconnect:
|
|
27
|
-
await wallet.disconnect(currentChainName);
|
|
28
|
-
afterDisconnect();
|
|
29
|
-
} }));
|
|
17
|
+
}, onDisconnect: disconnect }));
|
|
30
18
|
};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { ConnectModalHead, ConnectModalStatus } from "@interchain-ui/react";
|
|
3
|
-
|
|
4
|
-
export const ConnectingHeader = ({ wallet, onBack, }) => {
|
|
5
|
-
const { close } = useWalletModal();
|
|
3
|
+
export const ConnectingHeader = ({ wallet, close, onBack, }) => {
|
|
6
4
|
return (_jsx(ConnectModalHead, { title: wallet.info.prettyName, hasBackButton: true, onClose: close, onBack: onBack, closeButtonProps: {
|
|
7
5
|
onClick: close,
|
|
8
6
|
} }));
|
|
@@ -1,28 +1,24 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { ConnectModalHead, ConnectModalStatus } from "@interchain-ui/react";
|
|
3
|
-
import { useWalletManager } from "../../hooks"; // replace with the actual path
|
|
4
|
-
import { useWalletModal } from "../provider";
|
|
5
3
|
import { useMemo } from "react";
|
|
6
4
|
import { FaAndroid } from "@react-icons/all-files/fa/FaAndroid";
|
|
7
5
|
import { GoDesktopDownload } from "@react-icons/all-files/go/GoDesktopDownload";
|
|
8
6
|
import { GrFirefox } from "@react-icons/all-files/gr/GrFirefox";
|
|
9
7
|
import { RiAppStoreFill } from "@react-icons/all-files/ri/RiAppStoreFill";
|
|
10
8
|
import { RiChromeFill } from "@react-icons/all-files/ri/RiChromeFill";
|
|
11
|
-
export const NotExistHeader = ({ wallet, onBack, }) => {
|
|
12
|
-
const { close } = useWalletModal();
|
|
9
|
+
export const NotExistHeader = ({ wallet, close, onBack, }) => {
|
|
13
10
|
return (_jsx(ConnectModalHead, { title: wallet?.info?.prettyName || "", hasBackButton: true, onClose: close, onBack: onBack, closeButtonProps: { onClick: close } }));
|
|
14
11
|
};
|
|
15
|
-
export const NotExistContent = ({ wallet }) => {
|
|
16
|
-
const walletManager = useWalletManager();
|
|
12
|
+
export const NotExistContent = ({ wallet, getDownloadLink, getEnv, }) => {
|
|
17
13
|
const downloadLink = useMemo(() => {
|
|
18
|
-
return
|
|
14
|
+
return getDownloadLink(wallet.info.name);
|
|
19
15
|
}, [wallet?.info?.name]);
|
|
20
16
|
const onInstall = () => {
|
|
21
17
|
if (downloadLink) {
|
|
22
18
|
window.open(downloadLink.link, "_blank");
|
|
23
19
|
}
|
|
24
20
|
};
|
|
25
|
-
const IconComp = getIcon(
|
|
21
|
+
const IconComp = getIcon(getEnv());
|
|
26
22
|
return (_jsx(ConnectModalStatus, { status: "NotExist", wallet: {
|
|
27
23
|
name: wallet?.info?.prettyName,
|
|
28
24
|
logo: typeof wallet?.info?.logo === "string" ? wallet?.info?.logo : "",
|
|
@@ -1,19 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { ConnectModalHead, ConnectModalQRCode } from "@interchain-ui/react";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export const QRCodeHeader = ({ onBack }) => {
|
|
6
|
-
const { currentChainName, currentWalletName, getWalletByName, disconnect } = useWalletManager();
|
|
7
|
-
const { close } = useWalletModal();
|
|
8
|
-
const currentWallet = getWalletByName(currentWalletName);
|
|
9
|
-
return (_jsx(ConnectModalHead, { title: currentWallet?.info?.prettyName || "", hasBackButton: true, onClose: () => void 0, onBack: async () => {
|
|
10
|
-
await disconnect(currentWallet?.info?.name || "", currentChainName);
|
|
11
|
-
onBack();
|
|
12
|
-
}, closeButtonProps: { onClick: close } }));
|
|
3
|
+
export const QRCodeHeader = ({ wallet, close, onBack, }) => {
|
|
4
|
+
return (_jsx(ConnectModalHead, { title: wallet?.info?.prettyName || "", hasBackButton: true, onClose: () => void 0, onBack: onBack, closeButtonProps: { onClick: close } }));
|
|
13
5
|
};
|
|
14
|
-
export const QRCodeContent = () => {
|
|
15
|
-
|
|
16
|
-
const currentWallet = getWalletByName(currentWalletName);
|
|
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: () => connect(currentWallet?.info?.name || "", currentChainName) }));
|
|
6
|
+
export const QRCodeContent = ({ errorMessage, walletConnectQRCodeUri, onReconnect, }) => {
|
|
7
|
+
return (_jsx(ConnectModalQRCode, { status: walletConnectQRCodeUri ? "Done" : "Pending", link: walletConnectQRCodeUri, description: "Open App to connect", errorTitle: "errorTitle", errorDesc: errorMessage || "", onRefresh: onReconnect }));
|
|
19
8
|
};
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { ConnectModalHead, ConnectModalStatus } from "@interchain-ui/react";
|
|
3
|
-
import { useWalletModal } from "../provider";
|
|
4
3
|
import { getWalletInfo } from "../../utils";
|
|
5
|
-
export const RejectHeader = ({ wallet, onBack, }) => {
|
|
6
|
-
const { close } = useWalletModal();
|
|
4
|
+
export const RejectHeader = ({ wallet, close, onBack, }) => {
|
|
7
5
|
return (_jsx(ConnectModalHead, { title: wallet?.info?.prettyName, hasBackButton: true, onClose: close, onBack: onBack, closeButtonProps: { onClick: close } }));
|
|
8
6
|
};
|
|
9
7
|
export const RejectContent = ({ wallet, onReconnect, }) => {
|
|
@@ -1,40 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { ConnectModalHead, ConnectModalWalletList } from "@interchain-ui/react";
|
|
3
|
-
|
|
4
|
-
import { useWalletManager } from "../../hooks";
|
|
5
|
-
import { isInstanceOf, WCWallet } from "@interchain-kit/core";
|
|
6
|
-
export const WalletListHeader = () => {
|
|
7
|
-
const { close } = useWalletModal();
|
|
3
|
+
export const WalletListHeader = ({ close }) => {
|
|
8
4
|
return (_jsx(ConnectModalHead, { title: "Select your wallet", hasBackButton: false, onClose: close, closeButtonProps: { onClick: close } }));
|
|
9
5
|
};
|
|
10
|
-
export const WalletListContent = ({ onSelectWallet, }) => {
|
|
11
|
-
|
|
12
|
-
const wallets = walletManager.wallets.map((w) => {
|
|
13
|
-
if (isInstanceOf(w, WCWallet) && w.session) {
|
|
14
|
-
return {
|
|
15
|
-
name: w.session.peer.metadata?.name,
|
|
16
|
-
prettyName: `${w.session.peer.metadata?.name} - Mobile`,
|
|
17
|
-
logo: w.session.peer.metadata?.icons?.[0],
|
|
18
|
-
mobileDisabled: true,
|
|
19
|
-
shape: "list",
|
|
20
|
-
originalWallet: { ...w, session: w.session },
|
|
21
|
-
subLogo: w.info.logo,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
return {
|
|
25
|
-
name: w.info.name,
|
|
26
|
-
prettyName: w.info.prettyName,
|
|
27
|
-
logo: w.info.logo,
|
|
28
|
-
mobileDisabled: true,
|
|
29
|
-
shape: "list",
|
|
30
|
-
originalWallet: {
|
|
31
|
-
...w,
|
|
32
|
-
pairing: null,
|
|
33
|
-
session: null,
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
});
|
|
37
|
-
return (_jsx(ConnectModalWalletList, { wallets: wallets, onWalletItemClick: (w) => {
|
|
38
|
-
onSelectWallet(w);
|
|
39
|
-
} }));
|
|
6
|
+
export const WalletListContent = ({ wallets, onSelectWallet, }) => {
|
|
7
|
+
return (_jsx(ConnectModalWalletList, { wallets: wallets, onWalletItemClick: onSelectWallet }));
|
|
40
8
|
};
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { BaseWallet } from "@interchain-kit/core";
|
|
2
2
|
export class ChainWallet extends BaseWallet {
|
|
3
|
+
getProvider(chainId) {
|
|
4
|
+
return this.originalWallet.getProvider(chainId);
|
|
5
|
+
}
|
|
3
6
|
originalWallet;
|
|
4
7
|
connectWithState;
|
|
5
8
|
disconnectWithState;
|
|
@@ -12,7 +15,7 @@ export class ChainWallet extends BaseWallet {
|
|
|
12
15
|
this.getAccountWithState = getAccountWithState;
|
|
13
16
|
}
|
|
14
17
|
async init(meta) {
|
|
15
|
-
return this.originalWallet.init(
|
|
18
|
+
return this.originalWallet.init();
|
|
16
19
|
}
|
|
17
20
|
async connect(chainId) {
|
|
18
21
|
return this.connectWithState(chainId);
|
|
@@ -23,37 +26,10 @@ export class ChainWallet extends BaseWallet {
|
|
|
23
26
|
async getAccount(chainId) {
|
|
24
27
|
return this.getAccountWithState(chainId);
|
|
25
28
|
}
|
|
26
|
-
async
|
|
27
|
-
return this.originalWallet.getAccounts(chainIds);
|
|
28
|
-
}
|
|
29
|
-
async getSimpleAccount(chainId) {
|
|
30
|
-
return this.originalWallet.getSimpleAccount(chainId);
|
|
31
|
-
}
|
|
32
|
-
getOfflineSigner(chainId) {
|
|
29
|
+
async getOfflineSigner(chainId) {
|
|
33
30
|
return this.originalWallet.getOfflineSigner(chainId);
|
|
34
31
|
}
|
|
35
|
-
|
|
36
|
-
return this.originalWallet.
|
|
37
|
-
}
|
|
38
|
-
getOfflineSignerDirect(chainId) {
|
|
39
|
-
return this.originalWallet.getOfflineSignerDirect(chainId);
|
|
40
|
-
}
|
|
41
|
-
async signAmino(chainId, signer, signDoc, signOptions) {
|
|
42
|
-
return this.originalWallet.signAmino(chainId, signer, signDoc, signOptions);
|
|
43
|
-
}
|
|
44
|
-
async signArbitrary(chainId, signer, data) {
|
|
45
|
-
return this.originalWallet.signArbitrary(chainId, signer, data);
|
|
46
|
-
}
|
|
47
|
-
async verifyArbitrary(chainId, signer, data) {
|
|
48
|
-
return this.originalWallet.verifyArbitrary(chainId, signer, data);
|
|
49
|
-
}
|
|
50
|
-
async signDirect(chainId, signer, signDoc, signOptions) {
|
|
51
|
-
return this.originalWallet.signDirect(chainId, signer, signDoc, signOptions);
|
|
52
|
-
}
|
|
53
|
-
async sendTx(chainId, tx, mode) {
|
|
54
|
-
return this.originalWallet.sendTx(chainId, tx, mode);
|
|
55
|
-
}
|
|
56
|
-
async addSuggestChain(chain, assetLists) {
|
|
57
|
-
return this.originalWallet.addSuggestChain(chain, assetLists);
|
|
32
|
+
async addSuggestChain(chainId) {
|
|
33
|
+
return this.originalWallet.addSuggestChain(chainId);
|
|
58
34
|
}
|
|
59
35
|
}
|