@interchain-kit/react 0.0.1-beta.39 → 0.0.1-beta.40
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/useAccount.js +4 -1
- package/esm/hooks/useCurrentWallet.js +5 -7
- package/esm/modal/modal.js +6 -8
- package/esm/modal/views/WalletList.js +3 -3
- package/hooks/useAccount.js +4 -1
- package/hooks/useCurrentWallet.js +5 -7
- package/modal/modal.js +6 -8
- package/modal/views/WalletList.js +3 -3
- package/package.json +3 -3
- package/provider.d.ts +2 -2
package/esm/hooks/useAccount.js
CHANGED
|
@@ -3,6 +3,7 @@ import { WalletManagerState, WalletState } from "@interchain-kit/core";
|
|
|
3
3
|
import { useWalletManager } from './useWalletManager';
|
|
4
4
|
export const useAccount = (chainName, walletName) => {
|
|
5
5
|
const walletManager = useWalletManager();
|
|
6
|
+
const [isFetching, setIsFetching] = useState(false);
|
|
6
7
|
const wallet = useMemo(() => {
|
|
7
8
|
return walletManager.wallets.find(w => w.info.name === walletName);
|
|
8
9
|
}, [walletManager, walletName]);
|
|
@@ -12,9 +13,11 @@ export const useAccount = (chainName, walletName) => {
|
|
|
12
13
|
}, [walletManager, chainName]);
|
|
13
14
|
const getAccount = async () => {
|
|
14
15
|
if (wallet && chain) {
|
|
15
|
-
if (wallet.walletState === WalletState.Connected) {
|
|
16
|
+
if (wallet.walletState === WalletState.Connected && !isFetching) {
|
|
17
|
+
setIsFetching(true);
|
|
16
18
|
const account = await walletManager.getAccount(walletName, chainName);
|
|
17
19
|
setAccount(account);
|
|
20
|
+
setIsFetching(false);
|
|
18
21
|
}
|
|
19
22
|
if (wallet.walletState === WalletState.Disconnected) {
|
|
20
23
|
setAccount(null);
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { useEffect } from "react";
|
|
2
1
|
import { useWalletManager } from "./useWalletManager";
|
|
3
2
|
import { useWalletModal } from "../modal";
|
|
4
|
-
import { WalletManagerState } from "@interchain-kit/core";
|
|
5
3
|
export const useCurrentWallet = () => {
|
|
6
4
|
const walletManager = useWalletManager();
|
|
7
5
|
const { open } = useWalletModal();
|
|
8
|
-
useEffect(() => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}, [walletManager.currentWalletName, walletManager.state])
|
|
6
|
+
// useEffect(() => {
|
|
7
|
+
// if (!walletManager.currentWalletName && walletManager.state === WalletManagerState.Initialized) {
|
|
8
|
+
// open()
|
|
9
|
+
// }
|
|
10
|
+
// }, [walletManager.currentWalletName, walletManager.state])
|
|
13
11
|
return walletManager.getCurrentWallet();
|
|
14
12
|
};
|
package/esm/modal/modal.js
CHANGED
|
@@ -25,15 +25,13 @@ export const WalletModal = () => {
|
|
|
25
25
|
}
|
|
26
26
|
try {
|
|
27
27
|
if (selectedWallet.info.mode === "wallet-connect") {
|
|
28
|
-
selectedWallet.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
content: _jsx(QRCodeContent, {}),
|
|
34
|
-
});
|
|
35
|
-
}
|
|
28
|
+
selectedWallet.setOnPairingUriCreatedCallback(() => {
|
|
29
|
+
setModalView({
|
|
30
|
+
header: _jsx(QRCodeHeader, { onBack: gotoWalletList }),
|
|
31
|
+
content: _jsx(QRCodeContent, {}),
|
|
32
|
+
});
|
|
36
33
|
});
|
|
34
|
+
selectedWallet.setPairingToConnect(wallet.pairing);
|
|
37
35
|
}
|
|
38
36
|
await walletManager.connect(selectedWallet?.info?.name);
|
|
39
37
|
setModalView({
|
|
@@ -26,9 +26,9 @@ export const WalletListContent = ({ onSelectWallet, }) => {
|
|
|
26
26
|
const activePairings = wcWallet.getActivePairing();
|
|
27
27
|
activePairings.forEach((pairing) => {
|
|
28
28
|
wallets.push({
|
|
29
|
-
name: pairing
|
|
30
|
-
prettyName: pairing
|
|
31
|
-
logo: pairing
|
|
29
|
+
name: pairing?.peerMetadata?.name,
|
|
30
|
+
prettyName: pairing?.peerMetadata?.name,
|
|
31
|
+
logo: pairing?.peerMetadata?.icons?.[0],
|
|
32
32
|
mobileDisabled: true,
|
|
33
33
|
shape: "list",
|
|
34
34
|
originalWallet: { ...wcWallet, pairing },
|
package/hooks/useAccount.js
CHANGED
|
@@ -6,6 +6,7 @@ const core_1 = require("@interchain-kit/core");
|
|
|
6
6
|
const useWalletManager_1 = require("./useWalletManager");
|
|
7
7
|
const useAccount = (chainName, walletName) => {
|
|
8
8
|
const walletManager = (0, useWalletManager_1.useWalletManager)();
|
|
9
|
+
const [isFetching, setIsFetching] = (0, react_1.useState)(false);
|
|
9
10
|
const wallet = (0, react_1.useMemo)(() => {
|
|
10
11
|
return walletManager.wallets.find(w => w.info.name === walletName);
|
|
11
12
|
}, [walletManager, walletName]);
|
|
@@ -15,9 +16,11 @@ const useAccount = (chainName, walletName) => {
|
|
|
15
16
|
}, [walletManager, chainName]);
|
|
16
17
|
const getAccount = async () => {
|
|
17
18
|
if (wallet && chain) {
|
|
18
|
-
if (wallet.walletState === core_1.WalletState.Connected) {
|
|
19
|
+
if (wallet.walletState === core_1.WalletState.Connected && !isFetching) {
|
|
20
|
+
setIsFetching(true);
|
|
19
21
|
const account = await walletManager.getAccount(walletName, chainName);
|
|
20
22
|
setAccount(account);
|
|
23
|
+
setIsFetching(false);
|
|
21
24
|
}
|
|
22
25
|
if (wallet.walletState === core_1.WalletState.Disconnected) {
|
|
23
26
|
setAccount(null);
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useCurrentWallet = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
4
|
const useWalletManager_1 = require("./useWalletManager");
|
|
6
5
|
const modal_1 = require("../modal");
|
|
7
|
-
const core_1 = require("@interchain-kit/core");
|
|
8
6
|
const useCurrentWallet = () => {
|
|
9
7
|
const walletManager = (0, useWalletManager_1.useWalletManager)();
|
|
10
8
|
const { open } = (0, modal_1.useWalletModal)();
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}, [walletManager.currentWalletName, walletManager.state])
|
|
9
|
+
// useEffect(() => {
|
|
10
|
+
// if (!walletManager.currentWalletName && walletManager.state === WalletManagerState.Initialized) {
|
|
11
|
+
// open()
|
|
12
|
+
// }
|
|
13
|
+
// }, [walletManager.currentWalletName, walletManager.state])
|
|
16
14
|
return walletManager.getCurrentWallet();
|
|
17
15
|
};
|
|
18
16
|
exports.useCurrentWallet = useCurrentWallet;
|
package/modal/modal.js
CHANGED
|
@@ -28,15 +28,13 @@ const WalletModal = () => {
|
|
|
28
28
|
}
|
|
29
29
|
try {
|
|
30
30
|
if (selectedWallet.info.mode === "wallet-connect") {
|
|
31
|
-
selectedWallet.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
content: (0, jsx_runtime_1.jsx)(views_1.QRCodeContent, {}),
|
|
37
|
-
});
|
|
38
|
-
}
|
|
31
|
+
selectedWallet.setOnPairingUriCreatedCallback(() => {
|
|
32
|
+
setModalView({
|
|
33
|
+
header: (0, jsx_runtime_1.jsx)(views_1.QRCodeHeader, { onBack: gotoWalletList }),
|
|
34
|
+
content: (0, jsx_runtime_1.jsx)(views_1.QRCodeContent, {}),
|
|
35
|
+
});
|
|
39
36
|
});
|
|
37
|
+
selectedWallet.setPairingToConnect(wallet.pairing);
|
|
40
38
|
}
|
|
41
39
|
await walletManager.connect(selectedWallet?.info?.name);
|
|
42
40
|
setModalView({
|
|
@@ -30,9 +30,9 @@ const WalletListContent = ({ onSelectWallet, }) => {
|
|
|
30
30
|
const activePairings = wcWallet.getActivePairing();
|
|
31
31
|
activePairings.forEach((pairing) => {
|
|
32
32
|
wallets.push({
|
|
33
|
-
name: pairing
|
|
34
|
-
prettyName: pairing
|
|
35
|
-
logo: pairing
|
|
33
|
+
name: pairing?.peerMetadata?.name,
|
|
34
|
+
prettyName: pairing?.peerMetadata?.name,
|
|
35
|
+
logo: pairing?.peerMetadata?.icons?.[0],
|
|
36
36
|
mobileDisabled: true,
|
|
37
37
|
shape: "list",
|
|
38
38
|
originalWallet: { ...wcWallet, pairing },
|
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.40",
|
|
4
4
|
"author": "cosmology-tech <developers@cosmology.zone>",
|
|
5
5
|
"description": "interchain-kit wallet connector react package",
|
|
6
6
|
"main": "index.js",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"keywords": [],
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@chain-registry/v2-types": "^0.53.0",
|
|
36
|
-
"@interchain-kit/core": "0.0.1-beta.
|
|
36
|
+
"@interchain-kit/core": "0.0.1-beta.40",
|
|
37
37
|
"@interchain-ui/react": "1.24.0",
|
|
38
38
|
"@interchainjs/cosmos": "^0.0.1-beta.34",
|
|
39
39
|
"@interchainjs/cosmos-types": "0.0.1-beta.17",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"react": "^18.3.1",
|
|
46
46
|
"react-dom": "^18.3.1"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "1437ad007c7aa784126ce9a600e8297c99eb90d6"
|
|
49
49
|
}
|
package/provider.d.ts
CHANGED
|
@@ -8,8 +8,8 @@ type InterchainWalletProviderProps = {
|
|
|
8
8
|
chains: Chain[];
|
|
9
9
|
assetLists: AssetList[];
|
|
10
10
|
wallets: BaseWallet[];
|
|
11
|
-
signerOptions
|
|
12
|
-
endpointOptions
|
|
11
|
+
signerOptions?: SignerOptions;
|
|
12
|
+
endpointOptions?: EndpointOptions;
|
|
13
13
|
children: React.ReactNode;
|
|
14
14
|
};
|
|
15
15
|
export declare const ChainProvider: ({ chains, assetLists, wallets, signerOptions, endpointOptions, children, }: InterchainWalletProviderProps) => import("react/jsx-runtime").JSX.Element;
|