@interchain-kit/react 0.0.1-beta.58 → 0.0.1-beta.59
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/modal/modal.js +7 -3
- package/esm/modal/provider.js +4 -4
- package/esm/store/chain-wallet.js +1 -1
- package/esm/store/index.js +15 -12
- package/modal/modal.d.ts +2 -1
- package/modal/modal.js +6 -4
- package/modal/provider.d.ts +1 -1
- package/modal/provider.js +37 -4
- package/package.json +3 -3
- package/store/chain-wallet.js +1 -1
- package/store/index.js +15 -12
package/esm/modal/modal.js
CHANGED
|
@@ -5,7 +5,7 @@ import { useChainWallet, useWalletManager } from "../hooks";
|
|
|
5
5
|
import { useEffect, useState } from "react";
|
|
6
6
|
import { WalletState } from "@interchain-kit/core";
|
|
7
7
|
import { ConnectModal } from "@interchain-ui/react";
|
|
8
|
-
|
|
8
|
+
const WalletModal = () => {
|
|
9
9
|
const { modalIsOpen, open, close } = useWalletModal();
|
|
10
10
|
const { currentWalletName, currentChainName, wallets, setCurrentWalletName, connect, getAccount, getWalletByName, } = useWalletManager();
|
|
11
11
|
const handleSelectWallet = async (selectedWallet) => {
|
|
@@ -64,9 +64,13 @@ export const WalletModal = () => {
|
|
|
64
64
|
content: _jsx(ConnectedContent, {}),
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
|
-
else {
|
|
68
|
-
setModalView(
|
|
67
|
+
else if (modalIsOpen && status === WalletState.Disconnected) {
|
|
68
|
+
setModalView({
|
|
69
|
+
header: _jsx(WalletListHeader, {}),
|
|
70
|
+
content: _jsx(WalletListContent, { onSelectWallet: handleSelectWallet }),
|
|
71
|
+
});
|
|
69
72
|
}
|
|
70
73
|
}, [modalIsOpen, status]);
|
|
71
74
|
return (_jsx(ConnectModal, { isOpen: modalIsOpen, header: modalView.header, onOpen: open, onClose: close, children: modalView.content }));
|
|
72
75
|
};
|
|
76
|
+
export default WalletModal;
|
package/esm/modal/provider.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { createContext, useContext, useState } from "react";
|
|
3
|
-
|
|
2
|
+
import { createContext, lazy, useContext, useState } from "react";
|
|
3
|
+
const WalletModal = lazy(() => import(/*webpackChunkName: "interchain-kit-modal" */ "./modal"));
|
|
4
4
|
const WalletModalContext = createContext(null);
|
|
5
|
-
export const WalletModalProvider = ({ children }) => {
|
|
5
|
+
export const WalletModalProvider = ({ children, }) => {
|
|
6
6
|
const [modalIsOpen, setModalIsOpen] = useState(false);
|
|
7
7
|
const open = () => setModalIsOpen(true);
|
|
8
8
|
const close = () => setModalIsOpen(false);
|
|
@@ -11,7 +11,7 @@ export const WalletModalProvider = ({ children }) => {
|
|
|
11
11
|
export const useWalletModal = () => {
|
|
12
12
|
const context = useContext(WalletModalContext);
|
|
13
13
|
if (!context) {
|
|
14
|
-
throw new Error(
|
|
14
|
+
throw new Error("useWalletModal must be used within a WalletModalProvider");
|
|
15
15
|
}
|
|
16
16
|
return context;
|
|
17
17
|
};
|
|
@@ -5,7 +5,7 @@ export class ChainWallet extends BaseWallet {
|
|
|
5
5
|
disconnectWithState;
|
|
6
6
|
getAccountWithState;
|
|
7
7
|
constructor(originalWallet, connectWithState, disconnectWithState, getAccountWithState) {
|
|
8
|
-
super(originalWallet
|
|
8
|
+
super(originalWallet?.info);
|
|
9
9
|
this.originalWallet = originalWallet;
|
|
10
10
|
this.connectWithState = connectWithState;
|
|
11
11
|
this.disconnectWithState = disconnectWithState;
|
package/esm/store/index.js
CHANGED
|
@@ -23,7 +23,7 @@ export const createInterchainStore = (walletManager) => {
|
|
|
23
23
|
chainWalletState.push({
|
|
24
24
|
chainName: chain.chainName,
|
|
25
25
|
walletName: wallet.info.name,
|
|
26
|
-
walletState:
|
|
26
|
+
walletState: WalletState.Disconnected,
|
|
27
27
|
rpcEndpoint: "",
|
|
28
28
|
errorMessage: "",
|
|
29
29
|
signerOption: undefined,
|
|
@@ -77,18 +77,18 @@ export const createInterchainStore = (walletManager) => {
|
|
|
77
77
|
draft.chains.push(newChain);
|
|
78
78
|
const assetList = assetLists.find(a => a.chainName === newChain.chainName);
|
|
79
79
|
draft.assetLists.push(assetList);
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
80
|
+
draft.wallets.forEach(w => {
|
|
81
|
+
draft.chainWalletState.push({
|
|
82
|
+
chainName: newChain.chainName,
|
|
83
|
+
walletName: w.info.name,
|
|
84
|
+
walletState: WalletState.Disconnected,
|
|
85
|
+
rpcEndpoint: "",
|
|
86
|
+
errorMessage: "",
|
|
87
|
+
signerOption: signerOptions?.signing?.(newChain.chainName),
|
|
88
|
+
account: undefined
|
|
89
|
+
});
|
|
90
90
|
});
|
|
91
|
-
}
|
|
91
|
+
}
|
|
92
92
|
draft.signerOptionMap[newChain.chainName] = signerOptions?.signing?.(newChain.chainName);
|
|
93
93
|
draft.endpointOptionsMap[newChain.chainName] = endpointOptions?.endpoints?.[newChain.chainName];
|
|
94
94
|
});
|
|
@@ -122,6 +122,9 @@ export const createInterchainStore = (walletManager) => {
|
|
|
122
122
|
return account;
|
|
123
123
|
},
|
|
124
124
|
getRpcEndpoint: async (walletName, chainName) => {
|
|
125
|
+
const exist = get().getChainWalletState(walletName, chainName).rpcEndpoint;
|
|
126
|
+
if (exist)
|
|
127
|
+
return exist;
|
|
125
128
|
const rpcEndpoint = await walletManager.getRpcEndpoint(walletName, chainName);
|
|
126
129
|
get().updateChainWalletState(walletName, chainName, { rpcEndpoint });
|
|
127
130
|
return rpcEndpoint;
|
package/modal/modal.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
declare const WalletModal: () => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export default WalletModal;
|
package/modal/modal.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WalletModal = void 0;
|
|
4
3
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
4
|
const views_1 = require("./views");
|
|
6
5
|
const provider_1 = require("./provider");
|
|
@@ -67,10 +66,13 @@ const WalletModal = () => {
|
|
|
67
66
|
content: (0, jsx_runtime_1.jsx)(views_1.ConnectedContent, {}),
|
|
68
67
|
});
|
|
69
68
|
}
|
|
70
|
-
else {
|
|
71
|
-
setModalView(
|
|
69
|
+
else if (modalIsOpen && status === core_1.WalletState.Disconnected) {
|
|
70
|
+
setModalView({
|
|
71
|
+
header: (0, jsx_runtime_1.jsx)(views_1.WalletListHeader, {}),
|
|
72
|
+
content: (0, jsx_runtime_1.jsx)(views_1.WalletListContent, { onSelectWallet: handleSelectWallet }),
|
|
73
|
+
});
|
|
72
74
|
}
|
|
73
75
|
}, [modalIsOpen, status]);
|
|
74
76
|
return ((0, jsx_runtime_1.jsx)(react_2.ConnectModal, { isOpen: modalIsOpen, header: modalView.header, onOpen: open, onClose: close, children: modalView.content }));
|
|
75
77
|
};
|
|
76
|
-
exports.
|
|
78
|
+
exports.default = WalletModal;
|
package/modal/provider.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ type WalletModalContextType = {
|
|
|
3
3
|
open: () => void;
|
|
4
4
|
close: () => void;
|
|
5
5
|
};
|
|
6
|
-
export declare const WalletModalProvider: ({ children }: {
|
|
6
|
+
export declare const WalletModalProvider: ({ children, }: {
|
|
7
7
|
children: React.ReactNode;
|
|
8
8
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
9
9
|
export declare const useWalletModal: () => WalletModalContextType;
|
package/modal/provider.js
CHANGED
|
@@ -1,21 +1,54 @@
|
|
|
1
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
exports.useWalletModal = exports.WalletModalProvider = void 0;
|
|
4
37
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
38
|
const react_1 = require("react");
|
|
6
|
-
const
|
|
39
|
+
const WalletModal = (0, react_1.lazy)(() => Promise.resolve().then(() => __importStar(require(/*webpackChunkName: "interchain-kit-modal" */ "./modal"))));
|
|
7
40
|
const WalletModalContext = (0, react_1.createContext)(null);
|
|
8
|
-
const WalletModalProvider = ({ children }) => {
|
|
41
|
+
const WalletModalProvider = ({ children, }) => {
|
|
9
42
|
const [modalIsOpen, setModalIsOpen] = (0, react_1.useState)(false);
|
|
10
43
|
const open = () => setModalIsOpen(true);
|
|
11
44
|
const close = () => setModalIsOpen(false);
|
|
12
|
-
return ((0, jsx_runtime_1.jsxs)(WalletModalContext.Provider, { value: { modalIsOpen, open, close }, children: [children, (0, jsx_runtime_1.jsx)(
|
|
45
|
+
return ((0, jsx_runtime_1.jsxs)(WalletModalContext.Provider, { value: { modalIsOpen, open, close }, children: [children, (0, jsx_runtime_1.jsx)(WalletModal, {})] }));
|
|
13
46
|
};
|
|
14
47
|
exports.WalletModalProvider = WalletModalProvider;
|
|
15
48
|
const useWalletModal = () => {
|
|
16
49
|
const context = (0, react_1.useContext)(WalletModalContext);
|
|
17
50
|
if (!context) {
|
|
18
|
-
throw new Error(
|
|
51
|
+
throw new Error("useWalletModal must be used within a WalletModalProvider");
|
|
19
52
|
}
|
|
20
53
|
return context;
|
|
21
54
|
};
|
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.59",
|
|
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.40",
|
|
36
|
-
"@interchain-kit/core": "0.0.1-beta.
|
|
36
|
+
"@interchain-kit/core": "0.0.1-beta.59",
|
|
37
37
|
"@interchain-ui/react": "1.26.1",
|
|
38
38
|
"@interchainjs/cosmos": "1.6.3",
|
|
39
39
|
"@interchainjs/cosmos-types": "1.6.3",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"react-dom": "^18.3.1",
|
|
47
47
|
"zustand": "^5.0.3"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "ac86d1a418797180f0376335a82402594c823627"
|
|
50
50
|
}
|
package/store/chain-wallet.js
CHANGED
|
@@ -8,7 +8,7 @@ class ChainWallet extends core_1.BaseWallet {
|
|
|
8
8
|
disconnectWithState;
|
|
9
9
|
getAccountWithState;
|
|
10
10
|
constructor(originalWallet, connectWithState, disconnectWithState, getAccountWithState) {
|
|
11
|
-
super(originalWallet
|
|
11
|
+
super(originalWallet?.info);
|
|
12
12
|
this.originalWallet = originalWallet;
|
|
13
13
|
this.connectWithState = connectWithState;
|
|
14
14
|
this.disconnectWithState = disconnectWithState;
|
package/store/index.js
CHANGED
|
@@ -26,7 +26,7 @@ const createInterchainStore = (walletManager) => {
|
|
|
26
26
|
chainWalletState.push({
|
|
27
27
|
chainName: chain.chainName,
|
|
28
28
|
walletName: wallet.info.name,
|
|
29
|
-
walletState:
|
|
29
|
+
walletState: core_1.WalletState.Disconnected,
|
|
30
30
|
rpcEndpoint: "",
|
|
31
31
|
errorMessage: "",
|
|
32
32
|
signerOption: undefined,
|
|
@@ -80,18 +80,18 @@ const createInterchainStore = (walletManager) => {
|
|
|
80
80
|
draft.chains.push(newChain);
|
|
81
81
|
const assetList = assetLists.find(a => a.chainName === newChain.chainName);
|
|
82
82
|
draft.assetLists.push(assetList);
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
83
|
+
draft.wallets.forEach(w => {
|
|
84
|
+
draft.chainWalletState.push({
|
|
85
|
+
chainName: newChain.chainName,
|
|
86
|
+
walletName: w.info.name,
|
|
87
|
+
walletState: core_1.WalletState.Disconnected,
|
|
88
|
+
rpcEndpoint: "",
|
|
89
|
+
errorMessage: "",
|
|
90
|
+
signerOption: signerOptions?.signing?.(newChain.chainName),
|
|
91
|
+
account: undefined
|
|
92
|
+
});
|
|
93
93
|
});
|
|
94
|
-
}
|
|
94
|
+
}
|
|
95
95
|
draft.signerOptionMap[newChain.chainName] = signerOptions?.signing?.(newChain.chainName);
|
|
96
96
|
draft.endpointOptionsMap[newChain.chainName] = endpointOptions?.endpoints?.[newChain.chainName];
|
|
97
97
|
});
|
|
@@ -125,6 +125,9 @@ const createInterchainStore = (walletManager) => {
|
|
|
125
125
|
return account;
|
|
126
126
|
},
|
|
127
127
|
getRpcEndpoint: async (walletName, chainName) => {
|
|
128
|
+
const exist = get().getChainWalletState(walletName, chainName).rpcEndpoint;
|
|
129
|
+
if (exist)
|
|
130
|
+
return exist;
|
|
128
131
|
const rpcEndpoint = await walletManager.getRpcEndpoint(walletName, chainName);
|
|
129
132
|
get().updateChainWalletState(walletName, chainName, { rpcEndpoint });
|
|
130
133
|
return rpcEndpoint;
|