@interchain-kit/react 0.0.1-beta.13 → 0.0.1-beta.15
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/enum/connection.js +1 -1
- package/esm/hooks/useAccount.js +2 -3
- package/esm/hooks/useChain.js +1 -1
- package/esm/hooks/useInterchainClient.js +2 -2
- package/esm/modal/modal.js +8 -5
- package/esm/modal/views/QRCode.js +14 -0
- package/esm/modal/views/index.js +1 -0
- package/hooks/useAccount.js +2 -3
- package/hooks/useActiveWallet.d.ts +1 -1
- package/hooks/useChain.js +1 -1
- package/hooks/useConfig.d.ts +1 -0
- package/hooks/useInterchainClient.js +2 -2
- package/hooks/useWalletManager.d.ts +1 -0
- package/modal/modal.js +6 -3
- package/modal/views/QRCode.d.ts +2 -0
- package/modal/views/QRCode.js +19 -0
- package/modal/views/index.d.ts +1 -0
- package/modal/views/index.js +1 -0
- package/package.json +3 -3
- package/utils/index.d.ts +3 -2
package/enum/connection.js
CHANGED
|
@@ -6,4 +6,4 @@ var ConnectState;
|
|
|
6
6
|
ConnectState["CONNECTING"] = "connecting";
|
|
7
7
|
ConnectState["CONNECTED"] = "connected";
|
|
8
8
|
ConnectState["DISCONNECTED"] = "disconnected";
|
|
9
|
-
})(ConnectState
|
|
9
|
+
})(ConnectState || (exports.ConnectState = ConnectState = {}));
|
package/esm/hooks/useAccount.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { useEffect, useState } from "react";
|
|
2
|
-
import { WalletState } from "@interChain-kit/core";
|
|
3
2
|
import { useWalletManager } from './useWalletManager';
|
|
4
3
|
export const useAccount = (chainName, walletName) => {
|
|
5
4
|
const walletManager = useWalletManager();
|
|
@@ -8,11 +7,11 @@ export const useAccount = (chainName, walletName) => {
|
|
|
8
7
|
const chain = walletManager.chains.find(c => c.chainName === chainName);
|
|
9
8
|
const getAccount = async () => {
|
|
10
9
|
if (wallet && chain) {
|
|
11
|
-
if (wallet.walletState === WalletState.Connected) {
|
|
10
|
+
if (wallet.walletState === "Connected" /* WalletState.Connected */) {
|
|
12
11
|
const account = await wallet.getAccount(chain.chainId);
|
|
13
12
|
setAccount(account);
|
|
14
13
|
}
|
|
15
|
-
if (wallet.walletState === WalletState.Disconnected) {
|
|
14
|
+
if (wallet.walletState === "Disconnected" /* WalletState.Disconnected */) {
|
|
16
15
|
setAccount(null);
|
|
17
16
|
}
|
|
18
17
|
}
|
package/esm/hooks/useChain.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { useEffect, useState } from "react";
|
|
2
2
|
import { useWalletManager } from './useWalletManager';
|
|
3
3
|
import { useAccount } from './useAccount';
|
|
4
|
-
import { WalletState } from '@interChain-kit/core';
|
|
5
4
|
export const useInterchainClient = (chainName, walletName) => {
|
|
6
5
|
const [rpcEndpoint, setRpcEndpoint] = useState();
|
|
7
6
|
//query
|
|
@@ -18,7 +17,7 @@ export const useInterchainClient = (chainName, walletName) => {
|
|
|
18
17
|
const wallet = walletManager.wallets.find((w) => w.option.name === walletName);
|
|
19
18
|
const chainToShow = walletManager.chains.find((c) => c.chainName === chainName);
|
|
20
19
|
const initialize = async () => {
|
|
21
|
-
if (wallet && chainToShow && wallet?.walletState === WalletState.Connected) {
|
|
20
|
+
if (wallet && chainToShow && wallet?.walletState === "Connected" /* WalletState.Connected */) {
|
|
22
21
|
try {
|
|
23
22
|
setIsLoading(true);
|
|
24
23
|
const rpcEndpoint = await walletManager.getRpcEndpoint(wallet, chainName);
|
|
@@ -37,6 +36,7 @@ export const useInterchainClient = (chainName, walletName) => {
|
|
|
37
36
|
}
|
|
38
37
|
catch (error) {
|
|
39
38
|
setError(error);
|
|
39
|
+
console.log("create client error", error);
|
|
40
40
|
}
|
|
41
41
|
finally {
|
|
42
42
|
setIsLoading(false);
|
package/esm/modal/modal.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { ConnectModal } from "@interchain-ui/react";
|
|
3
|
-
import { ConnectedContent, ConnectedHeader, ConnectingContent, ConnectingHeader, RejectContent, RejectHeader, WalletListContent, WalletListHeader } from "./views";
|
|
3
|
+
import { ConnectedContent, ConnectedHeader, ConnectingContent, ConnectingHeader, QRCodeContent, QRCodeHeader, RejectContent, RejectHeader, WalletListContent, WalletListHeader } from "./views";
|
|
4
4
|
import { useWalletModal } from "./provider";
|
|
5
5
|
import { useActiveWallet } from "../hooks";
|
|
6
6
|
import { useEffect, useState } from "react";
|
|
7
|
-
import {
|
|
7
|
+
import { WCWallet } from "@interChain-kit/core";
|
|
8
8
|
const defaultModalView = {
|
|
9
9
|
header: _jsx(WalletListHeader, {}), content: _jsx(WalletListContent, {})
|
|
10
10
|
};
|
|
@@ -15,13 +15,16 @@ export const WalletModal = () => {
|
|
|
15
15
|
const gotoWalletList = () => setModalView(defaultModalView);
|
|
16
16
|
useEffect(() => {
|
|
17
17
|
switch (true) {
|
|
18
|
-
case activeWallet
|
|
18
|
+
case activeWallet instanceof WCWallet && !activeWallet.session:
|
|
19
|
+
setModalView({ header: _jsx(QRCodeHeader, {}), content: _jsx(QRCodeContent, {}) });
|
|
20
|
+
break;
|
|
21
|
+
case activeWallet?.walletState === "Connecting" /* WalletState.Connecting */:
|
|
19
22
|
setModalView({ header: _jsx(ConnectingHeader, { onBack: gotoWalletList }), content: _jsx(ConnectingContent, {}) });
|
|
20
23
|
break;
|
|
21
|
-
case activeWallet?.walletState === WalletState.Connected
|
|
24
|
+
case activeWallet?.walletState === "Connected" /* WalletState.Connected */:
|
|
22
25
|
setModalView({ header: _jsx(ConnectedHeader, { onBack: gotoWalletList }), content: _jsx(ConnectedContent, {}) });
|
|
23
26
|
break;
|
|
24
|
-
case activeWallet?.walletState === WalletState.Reject
|
|
27
|
+
case activeWallet?.walletState === "Reject" /* WalletState.Reject */:
|
|
25
28
|
setModalView({ header: _jsx(RejectHeader, { onBack: gotoWalletList }), content: _jsx(RejectContent, {}) });
|
|
26
29
|
break;
|
|
27
30
|
default:
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ConnectModalHead, ConnectModalQRCode } from "@interchain-ui/react";
|
|
3
|
+
import { useActiveWallet, useWalletManager, useWalletModal } from "@interchain-kit/react";
|
|
4
|
+
export const QRCodeHeader = () => {
|
|
5
|
+
const activeWallet = useActiveWallet();
|
|
6
|
+
const { close } = useWalletModal();
|
|
7
|
+
return (_jsx(ConnectModalHead, { title: activeWallet?.option?.prettyName || '', hasBackButton: true, onClose: () => void 0, onBack: () => void 0, closeButtonProps: { onClick: close } }));
|
|
8
|
+
};
|
|
9
|
+
export const QRCodeContent = () => {
|
|
10
|
+
const activeWallet = useActiveWallet();
|
|
11
|
+
const walletManager = useWalletManager();
|
|
12
|
+
const data = activeWallet.pairingUri;
|
|
13
|
+
return (_jsx(ConnectModalQRCode, { status: data ? "Done" : 'Pending', link: data, description: 'Open App to connect', errorTitle: 'errorTitle', errorDesc: 'errorDesc', onRefresh: () => walletManager.connect(activeWallet?.option?.name || '') }));
|
|
14
|
+
};
|
package/esm/modal/views/index.js
CHANGED
package/hooks/useAccount.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useAccount = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
-
const core_1 = require("@interChain-kit/core");
|
|
6
5
|
const useWalletManager_1 = require("./useWalletManager");
|
|
7
6
|
const useAccount = (chainName, walletName) => {
|
|
8
7
|
const walletManager = (0, useWalletManager_1.useWalletManager)();
|
|
@@ -11,11 +10,11 @@ const useAccount = (chainName, walletName) => {
|
|
|
11
10
|
const chain = walletManager.chains.find(c => c.chainName === chainName);
|
|
12
11
|
const getAccount = async () => {
|
|
13
12
|
if (wallet && chain) {
|
|
14
|
-
if (wallet.walletState ===
|
|
13
|
+
if (wallet.walletState === "Connected" /* WalletState.Connected */) {
|
|
15
14
|
const account = await wallet.getAccount(chain.chainId);
|
|
16
15
|
setAccount(account);
|
|
17
16
|
}
|
|
18
|
-
if (wallet.walletState ===
|
|
17
|
+
if (wallet.walletState === "Disconnected" /* WalletState.Disconnected */) {
|
|
19
18
|
setAccount(null);
|
|
20
19
|
}
|
|
21
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useActiveWallet: () =>
|
|
1
|
+
export declare const useActiveWallet: () => import("@interChain-kit/core").BaseWallet;
|
package/hooks/useChain.js
CHANGED
package/hooks/useConfig.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AssetList, Chain } from "@chain-registry/v2-types";
|
|
2
|
+
import { EndpointOptions, SignerOptions } from "@interChain-kit/core";
|
|
2
3
|
export declare const useConfig: () => {
|
|
3
4
|
updateChains: (chains: Chain[]) => Chain[];
|
|
4
5
|
updateAssetLists: (assetLists: AssetList[]) => AssetList[];
|
|
@@ -4,7 +4,6 @@ exports.useInterchainClient = void 0;
|
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const useWalletManager_1 = require("./useWalletManager");
|
|
6
6
|
const useAccount_1 = require("./useAccount");
|
|
7
|
-
const core_1 = require("@interChain-kit/core");
|
|
8
7
|
const useInterchainClient = (chainName, walletName) => {
|
|
9
8
|
const [rpcEndpoint, setRpcEndpoint] = (0, react_1.useState)();
|
|
10
9
|
//query
|
|
@@ -21,7 +20,7 @@ const useInterchainClient = (chainName, walletName) => {
|
|
|
21
20
|
const wallet = walletManager.wallets.find((w) => w.option.name === walletName);
|
|
22
21
|
const chainToShow = walletManager.chains.find((c) => c.chainName === chainName);
|
|
23
22
|
const initialize = async () => {
|
|
24
|
-
if (wallet && chainToShow && wallet?.walletState ===
|
|
23
|
+
if (wallet && chainToShow && wallet?.walletState === "Connected" /* WalletState.Connected */) {
|
|
25
24
|
try {
|
|
26
25
|
setIsLoading(true);
|
|
27
26
|
const rpcEndpoint = await walletManager.getRpcEndpoint(wallet, chainName);
|
|
@@ -40,6 +39,7 @@ const useInterchainClient = (chainName, walletName) => {
|
|
|
40
39
|
}
|
|
41
40
|
catch (error) {
|
|
42
41
|
setError(error);
|
|
42
|
+
console.log("create client error", error);
|
|
43
43
|
}
|
|
44
44
|
finally {
|
|
45
45
|
setIsLoading(false);
|
package/modal/modal.js
CHANGED
|
@@ -18,13 +18,16 @@ const WalletModal = () => {
|
|
|
18
18
|
const gotoWalletList = () => setModalView(defaultModalView);
|
|
19
19
|
(0, react_2.useEffect)(() => {
|
|
20
20
|
switch (true) {
|
|
21
|
-
case activeWallet
|
|
21
|
+
case activeWallet instanceof core_1.WCWallet && !activeWallet.session:
|
|
22
|
+
setModalView({ header: (0, jsx_runtime_1.jsx)(views_1.QRCodeHeader, {}), content: (0, jsx_runtime_1.jsx)(views_1.QRCodeContent, {}) });
|
|
23
|
+
break;
|
|
24
|
+
case activeWallet?.walletState === "Connecting" /* WalletState.Connecting */:
|
|
22
25
|
setModalView({ header: (0, jsx_runtime_1.jsx)(views_1.ConnectingHeader, { onBack: gotoWalletList }), content: (0, jsx_runtime_1.jsx)(views_1.ConnectingContent, {}) });
|
|
23
26
|
break;
|
|
24
|
-
case activeWallet?.walletState ===
|
|
27
|
+
case activeWallet?.walletState === "Connected" /* WalletState.Connected */:
|
|
25
28
|
setModalView({ header: (0, jsx_runtime_1.jsx)(views_1.ConnectedHeader, { onBack: gotoWalletList }), content: (0, jsx_runtime_1.jsx)(views_1.ConnectedContent, {}) });
|
|
26
29
|
break;
|
|
27
|
-
case activeWallet?.walletState ===
|
|
30
|
+
case activeWallet?.walletState === "Reject" /* WalletState.Reject */:
|
|
28
31
|
setModalView({ header: (0, jsx_runtime_1.jsx)(views_1.RejectHeader, { onBack: gotoWalletList }), content: (0, jsx_runtime_1.jsx)(views_1.RejectContent, {}) });
|
|
29
32
|
break;
|
|
30
33
|
default:
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QRCodeContent = exports.QRCodeHeader = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("@interchain-ui/react");
|
|
6
|
+
const react_2 = require("@interchain-kit/react");
|
|
7
|
+
const QRCodeHeader = () => {
|
|
8
|
+
const activeWallet = (0, react_2.useActiveWallet)();
|
|
9
|
+
const { close } = (0, react_2.useWalletModal)();
|
|
10
|
+
return ((0, jsx_runtime_1.jsx)(react_1.ConnectModalHead, { title: activeWallet?.option?.prettyName || '', hasBackButton: true, onClose: () => void 0, onBack: () => void 0, closeButtonProps: { onClick: close } }));
|
|
11
|
+
};
|
|
12
|
+
exports.QRCodeHeader = QRCodeHeader;
|
|
13
|
+
const QRCodeContent = () => {
|
|
14
|
+
const activeWallet = (0, react_2.useActiveWallet)();
|
|
15
|
+
const walletManager = (0, react_2.useWalletManager)();
|
|
16
|
+
const data = activeWallet.pairingUri;
|
|
17
|
+
return ((0, jsx_runtime_1.jsx)(react_1.ConnectModalQRCode, { status: data ? "Done" : 'Pending', link: data, description: 'Open App to connect', errorTitle: 'errorTitle', errorDesc: 'errorDesc', onRefresh: () => walletManager.connect(activeWallet?.option?.name || '') }));
|
|
18
|
+
};
|
|
19
|
+
exports.QRCodeContent = QRCodeContent;
|
package/modal/views/index.d.ts
CHANGED
package/modal/views/index.js
CHANGED
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.15",
|
|
4
4
|
"author": "cosmology-tech <developers@cosmology.zone>",
|
|
5
5
|
"description": "interchain-kit wallet connector react package",
|
|
6
6
|
"main": "index.js",
|
|
@@ -32,7 +32,7 @@
|
|
|
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.15",
|
|
36
36
|
"@interchain-ui/react": "^1.23.31",
|
|
37
37
|
"@interchainjs/cosmos-types": "0.0.1-beta.9",
|
|
38
38
|
"@interchainjs/injective": "0.0.1-beta.13",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"react": "^18.3.1",
|
|
43
43
|
"react-dom": "^18.3.1"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "869409826a19f1339b5c34bcb5bbcc7529805ce8"
|
|
46
46
|
}
|
package/utils/index.d.ts
CHANGED