@interchain-kit/react 0.2.207 → 0.2.211
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 +44 -98
- 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 +2 -34
- package/esm/store/chain-wallet.js +7 -31
- package/esm/store/index.js +2 -214
- package/esm/store/store.js +234 -0
- package/esm/utils/wallet.js +24 -0
- package/hooks/useChainWallet.js +2 -2
- package/modal/modal.d.ts +30 -1
- package/modal/modal.js +42 -96
- 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 +2 -34
- package/package.json +22 -7
- package/store/chain-wallet.d.ts +8 -17
- package/store/chain-wallet.js +7 -31
- package/store/index.d.ts +2 -43
- package/store/index.js +16 -216
- package/store/store.d.ts +43 -0
- package/store/store.js +238 -0
- package/utils/wallet.d.ts +26 -0
- package/utils/wallet.js +26 -1
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,108 +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
|
-
|
|
19
|
-
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
await connect(selectedWallet?.info?.name, chain.chainName);
|
|
23
|
-
await getAccount(selectedWallet?.info?.name, chain.chainName);
|
|
24
|
-
setSelectedWallet(null);
|
|
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
|
+
};
|
|
25
20
|
}
|
|
26
|
-
|
|
27
|
-
|
|
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
|
+
};
|
|
28
26
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
+
};
|
|
33
32
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
if (!selectedWallet) {
|
|
41
|
-
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
|
+
};
|
|
42
38
|
}
|
|
43
|
-
if (
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
setModalType("connected");
|
|
49
|
-
}
|
|
50
|
-
if (status === WalletState.Rejected) {
|
|
51
|
-
setModalType("reject");
|
|
52
|
-
}
|
|
53
|
-
if (status === WalletState.Disconnected) {
|
|
54
|
-
setModalType("wallet-list");
|
|
55
|
-
}
|
|
56
|
-
if (qrCode) {
|
|
57
|
-
setModalType("qr-code");
|
|
58
|
-
}
|
|
39
|
+
if (currentWallet && isConnecting) {
|
|
40
|
+
return {
|
|
41
|
+
header: (_jsx(ConnectingHeader, { wallet: currentWallet, close: close, onBack: onBack })),
|
|
42
|
+
content: _jsx(ConnectingContent, { wallet: currentWallet }),
|
|
43
|
+
};
|
|
59
44
|
}
|
|
60
45
|
}, [
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
46
|
+
currentWallet,
|
|
47
|
+
isConnected,
|
|
48
|
+
isConnecting,
|
|
49
|
+
address,
|
|
50
|
+
shouldShowList,
|
|
51
|
+
walletConnectQRCodeUri,
|
|
67
52
|
]);
|
|
68
|
-
|
|
69
|
-
const { header, content } = useMemo(() => {
|
|
70
|
-
switch (modalType) {
|
|
71
|
-
case "wallet-list":
|
|
72
|
-
return {
|
|
73
|
-
header: _jsx(WalletListHeader, {}),
|
|
74
|
-
content: _jsx(WalletListContent, { onSelectWallet: handleSelectWallet }),
|
|
75
|
-
};
|
|
76
|
-
case "connecting":
|
|
77
|
-
return {
|
|
78
|
-
header: _jsx(ConnectingHeader, { wallet: wallet, onBack: goBackList }),
|
|
79
|
-
content: _jsx(ConnectingContent, { wallet: wallet }),
|
|
80
|
-
};
|
|
81
|
-
case "connected":
|
|
82
|
-
return {
|
|
83
|
-
header: _jsx(ConnectedHeader, { wallet: wallet, onBack: goBackList }),
|
|
84
|
-
content: _jsx(ConnectedContent, { afterDisconnect: goBackList }),
|
|
85
|
-
};
|
|
86
|
-
case "reject":
|
|
87
|
-
return {
|
|
88
|
-
header: _jsx(RejectHeader, { wallet: wallet, onBack: goBackList }),
|
|
89
|
-
content: (_jsx(RejectContent, { wallet: wallet, onReconnect: () => {
|
|
90
|
-
setModalType("connecting");
|
|
91
|
-
wallet.connect(chain.chainId);
|
|
92
|
-
wallet.getAccount(chain.chainId);
|
|
93
|
-
} })),
|
|
94
|
-
};
|
|
95
|
-
case "not-exist":
|
|
96
|
-
return {
|
|
97
|
-
header: _jsx(NotExistHeader, { wallet: wallet, onBack: goBackList }),
|
|
98
|
-
content: _jsx(NotExistContent, { wallet: wallet }),
|
|
99
|
-
};
|
|
100
|
-
case "qr-code":
|
|
101
|
-
return {
|
|
102
|
-
header: _jsx(QRCodeHeader, { onBack: goBackList }),
|
|
103
|
-
content: _jsx(QRCodeContent, {}),
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
}, [modalType]);
|
|
107
|
-
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 }));
|
|
108
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
|
-
export const WalletListHeader = () => {
|
|
6
|
-
const { close } = useWalletModal();
|
|
3
|
+
export const WalletListHeader = ({ close }) => {
|
|
7
4
|
return (_jsx(ConnectModalHead, { title: "Select your wallet", hasBackButton: false, onClose: close, closeButtonProps: { onClick: close } }));
|
|
8
5
|
};
|
|
9
|
-
export const WalletListContent = ({ onSelectWallet, }) => {
|
|
10
|
-
const walletManager = useWalletManager();
|
|
11
|
-
const wallets = walletManager.wallets.map((w) => {
|
|
12
|
-
return {
|
|
13
|
-
name: w.info.name,
|
|
14
|
-
prettyName: w.info.prettyName,
|
|
15
|
-
logo: w.info.logo,
|
|
16
|
-
mobileDisabled: true,
|
|
17
|
-
shape: "list",
|
|
18
|
-
originalWallet: {
|
|
19
|
-
...w,
|
|
20
|
-
pairing: null,
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
});
|
|
24
|
-
const wcWallet = walletManager.wallets.find((w) => w.info.mode === "wallet-connect");
|
|
25
|
-
if (wcWallet) {
|
|
26
|
-
const activePairings = wcWallet.getActivePairing();
|
|
27
|
-
activePairings.forEach((pairing) => {
|
|
28
|
-
wallets.push({
|
|
29
|
-
name: pairing?.peerMetadata?.name,
|
|
30
|
-
prettyName: pairing?.peerMetadata?.name,
|
|
31
|
-
logo: pairing?.peerMetadata?.icons?.[0],
|
|
32
|
-
mobileDisabled: true,
|
|
33
|
-
shape: "list",
|
|
34
|
-
originalWallet: { ...wcWallet, pairing },
|
|
35
|
-
subLogo: wcWallet.info.logo,
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
}
|
|
6
|
+
export const WalletListContent = ({ wallets, onSelectWallet, }) => {
|
|
39
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
|
}
|