@interchain-kit/react 0.3.45 → 0.3.47

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.
Files changed (44) hide show
  1. package/esm/hooks/useChain.js +4 -4
  2. package/esm/hooks/useChainWallet.js +5 -5
  3. package/esm/hooks/useForceUpdate.js +5 -0
  4. package/esm/hooks/useSigningClient.js +3 -3
  5. package/esm/hooks/useWalletManager.js +12 -4
  6. package/esm/hooks/useWalletModal.js +1 -1
  7. package/esm/index.js +3 -4
  8. package/esm/modal/modal.js +2 -2
  9. package/esm/provider.js +3 -4
  10. package/esm/utils/bindContext.js +54 -0
  11. package/hooks/useChain.js +4 -4
  12. package/hooks/useChainWallet.d.ts +1 -1
  13. package/hooks/useChainWallet.js +4 -4
  14. package/hooks/useForceUpdate.d.ts +1 -0
  15. package/hooks/useForceUpdate.js +9 -0
  16. package/hooks/useSigningClient.d.ts +1 -1
  17. package/hooks/useSigningClient.js +2 -2
  18. package/hooks/useWalletManager.d.ts +1 -1
  19. package/hooks/useWalletManager.js +11 -3
  20. package/index.d.ts +3 -4
  21. package/index.js +3 -4
  22. package/modal/modal.d.ts +7 -7
  23. package/modal/modal.js +8 -8
  24. package/modal/views/Error.d.ts +3 -3
  25. package/modal/views/NotExist.d.ts +3 -3
  26. package/modal/views/Reject.d.ts +3 -3
  27. package/package.json +8 -7
  28. package/provider.d.ts +4 -6
  29. package/provider.js +3 -4
  30. package/types/chain.d.ts +20 -3
  31. package/utils/bindContext.d.ts +21 -0
  32. package/utils/bindContext.js +57 -0
  33. package/esm/store/chain-wallet.js +0 -35
  34. package/esm/store/index.js +0 -2
  35. package/esm/store/stateful-wallet.js +0 -182
  36. package/esm/store/store.js +0 -262
  37. package/store/chain-wallet.d.ts +0 -17
  38. package/store/chain-wallet.js +0 -39
  39. package/store/index.d.ts +0 -2
  40. package/store/index.js +0 -18
  41. package/store/stateful-wallet.d.ts +0 -21
  42. package/store/stateful-wallet.js +0 -186
  43. package/store/store.d.ts +0 -51
  44. package/store/store.js +0 -266
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ /**
3
+ * 绑定上下文工具函数的类型定义
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.bindAllMethods = bindAllMethods;
7
+ /**
8
+ * 绑定对象的所有方法,确保 getter 属性能正确访问原始对象的上下文
9
+ * @param obj 要绑定方法的对象
10
+ * @returns 绑定后的对象副本
11
+ */
12
+ function bindAllMethods(obj) {
13
+ if (!obj)
14
+ return obj;
15
+ const boundObj = { ...obj };
16
+ // 处理原型链上的方法和 getter
17
+ Object.getOwnPropertyNames(Object.getPrototypeOf(obj)).forEach((key) => {
18
+ const descriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(obj), key);
19
+ if (descriptor) {
20
+ if (typeof descriptor.value === 'function' && key !== 'constructor') {
21
+ // 原型链上的方法
22
+ boundObj[key] = descriptor.value.bind(obj);
23
+ }
24
+ else if (descriptor.get) {
25
+ // 原型链上的 getter 属性 - 绑定 this 上下文到原始对象
26
+ Object.defineProperty(boundObj, key, {
27
+ get: function () {
28
+ return descriptor.get.call(obj);
29
+ },
30
+ enumerable: descriptor.enumerable,
31
+ configurable: descriptor.configurable
32
+ });
33
+ }
34
+ }
35
+ });
36
+ // 处理实例上的方法,包括 getter 属性
37
+ Object.getOwnPropertyNames(obj).forEach((key) => {
38
+ const descriptor = Object.getOwnPropertyDescriptor(obj, key);
39
+ if (descriptor) {
40
+ if (typeof descriptor.value === 'function') {
41
+ // 普通方法
42
+ boundObj[key] = descriptor.value.bind(obj);
43
+ }
44
+ else if (descriptor.get) {
45
+ // getter 属性 - 绑定 this 上下文到原始对象
46
+ Object.defineProperty(boundObj, key, {
47
+ get: function () {
48
+ return descriptor.get.call(obj);
49
+ },
50
+ enumerable: descriptor.enumerable,
51
+ configurable: descriptor.configurable
52
+ });
53
+ }
54
+ }
55
+ });
56
+ return boundObj;
57
+ }
@@ -1,35 +0,0 @@
1
- import { BaseWallet } from "@interchain-kit/core";
2
- export class ChainWallet extends BaseWallet {
3
- getProvider(chainId) {
4
- return this.originalWallet.getProvider(chainId);
5
- }
6
- originalWallet;
7
- connectWithState;
8
- disconnectWithState;
9
- getAccountWithState;
10
- constructor(originalWallet, connectWithState, disconnectWithState, getAccountWithState) {
11
- super(originalWallet?.info);
12
- this.originalWallet = originalWallet;
13
- this.connectWithState = connectWithState;
14
- this.disconnectWithState = disconnectWithState;
15
- this.getAccountWithState = getAccountWithState;
16
- }
17
- async init(meta) {
18
- return this.originalWallet.init();
19
- }
20
- async connect(chainId) {
21
- return this.connectWithState(chainId);
22
- }
23
- async disconnect(chainId) {
24
- return this.disconnectWithState(chainId);
25
- }
26
- async getAccount(chainId) {
27
- return this.getAccountWithState(chainId);
28
- }
29
- async getOfflineSigner(chainId) {
30
- return this.originalWallet.getOfflineSigner(chainId);
31
- }
32
- async addSuggestChain(chainId) {
33
- return this.originalWallet.addSuggestChain(chainId);
34
- }
35
- }
@@ -1,2 +0,0 @@
1
- export * from './chain-wallet';
2
- export * from './store';
@@ -1,182 +0,0 @@
1
- import { BaseWallet, clientNotExistError, CosmosWallet, EthereumWallet, MultiChainWallet, WalletState, WCWallet } from "@interchain-kit/core";
2
- import { isSameConstructor } from "../utils/isSameConstructor";
3
- export class StatefulWallet extends BaseWallet {
4
- originalWallet;
5
- walletName;
6
- get;
7
- constructor(wallet, get) {
8
- super(wallet.info);
9
- this.originalWallet = wallet;
10
- this.walletName = wallet.info.name;
11
- this.get = get;
12
- }
13
- get store() {
14
- return this.get();
15
- }
16
- get walletState() {
17
- // 獲取此錢包在所有鏈上的狀態
18
- const states = (this.store.chainWalletState || [])
19
- .filter(cws => cws.walletName === this.walletName)
20
- .map(cws => cws.walletState);
21
- // If any chain is in the connected state, return connected
22
- if (states.includes(WalletState.Connected)) {
23
- return WalletState.Connected;
24
- }
25
- // 如果有任何一個鏈正在連接中,則返回連接中
26
- if (states.includes(WalletState.Connecting)) {
27
- return WalletState.Connecting;
28
- }
29
- // 如果所有鏈都是不存在狀態,則返回不存在
30
- if (states.length > 0 && states.every(state => state === WalletState.NotExist)) {
31
- return WalletState.NotExist;
32
- }
33
- // 如果有任何一個鏈是被拒絕狀態,則返回被拒絕
34
- if (states.includes(WalletState.Rejected)) {
35
- return WalletState.Rejected;
36
- }
37
- // 預設返回未連接
38
- return WalletState.Disconnected;
39
- }
40
- get errorMessage() {
41
- // 獲取此錢包在所有鏈上的錯誤訊息
42
- const errors = (this.store.chainWalletState || [])
43
- .filter(cws => cws.walletName === this.walletName)
44
- .map(cws => cws.errorMessage)
45
- .filter(error => error && error.trim() !== '');
46
- // 返回第一個非空錯誤訊息,如果沒有則返回空字串
47
- return errors.length > 0 ? errors[0] : '';
48
- }
49
- async init() {
50
- try {
51
- await this.originalWallet.init();
52
- this.originalWallet.events.on('accountChanged', async () => {
53
- const chains = Array.from(this.originalWallet.chainMap.values());
54
- for (const chain of chains) {
55
- await this.getAccount(chain.chainId);
56
- }
57
- });
58
- this.originalWallet.events.on('disconnect', () => {
59
- // Update all chains for this wallet to disconnected state
60
- this.store.chains.forEach(chain => {
61
- this.store.updateChainWalletState(this.walletName, chain.chainName, {
62
- walletState: WalletState.Disconnected,
63
- account: null,
64
- errorMessage: ''
65
- });
66
- });
67
- });
68
- this.store.chains.forEach(chain => {
69
- const lastChainWalletState = this.store.getChainWalletState(this.walletName, chain.chainName)?.walletState;
70
- if (lastChainWalletState === WalletState.NotExist) {
71
- this.store.updateChainWalletState(this.walletName, chain.chainName, {
72
- walletState: WalletState.Disconnected,
73
- errorMessage: ''
74
- });
75
- }
76
- });
77
- }
78
- catch (error) {
79
- if (error === clientNotExistError) {
80
- this.store.chains.forEach(chain => {
81
- this.store.updateChainWalletState(this.walletName, chain.chainName, {
82
- walletState: WalletState.NotExist,
83
- errorMessage: clientNotExistError.message
84
- });
85
- });
86
- }
87
- }
88
- }
89
- async connect(chainId) {
90
- const { store, walletName, originalWallet } = this;
91
- const chainToConnect = this.getChainById(chainId);
92
- const state = store.getChainWalletState(walletName, chainToConnect.chainName)?.walletState;
93
- if (state === WalletState.NotExist) {
94
- return;
95
- }
96
- if (walletName === 'WalletConnect' && state === WalletState.Connected) {
97
- return;
98
- }
99
- store.setCurrentChainName(chainToConnect.chainName);
100
- store.setCurrentWalletName(walletName);
101
- store.setWalletConnectQRCodeUri('');
102
- store.updateChainWalletState(walletName, chainToConnect.chainName, { walletState: WalletState.Connecting, errorMessage: '' });
103
- try {
104
- if (originalWallet instanceof WCWallet) {
105
- originalWallet.setOnPairingUriCreatedCallback((uri) => {
106
- store.setWalletConnectQRCodeUri(uri);
107
- });
108
- }
109
- await originalWallet.connect(chainToConnect.chainId);
110
- store.updateChainWalletState(walletName, chainToConnect.chainName, { walletState: WalletState.Connected });
111
- await this.getAccount(chainToConnect.chainId);
112
- }
113
- catch (error) {
114
- if (error.message.includes('rejected')) {
115
- store.updateChainWalletState(walletName, chainToConnect.chainName, { walletState: WalletState.Rejected, errorMessage: error.message });
116
- return;
117
- }
118
- else {
119
- store.updateChainWalletState(walletName, chainToConnect.chainName, { walletState: WalletState.Disconnected, errorMessage: error.message });
120
- }
121
- }
122
- }
123
- async disconnect(chainId) {
124
- const { store, walletName, originalWallet } = this;
125
- const chainToConnect = this.getChainById(chainId);
126
- try {
127
- if (this.walletState === WalletState.Connected) {
128
- await originalWallet.disconnect(chainToConnect.chainId);
129
- }
130
- store.updateChainWalletState(walletName, chainToConnect.chainName, { walletState: WalletState.Disconnected, account: null });
131
- }
132
- catch (error) {
133
- }
134
- }
135
- async getAccount(chainId) {
136
- const chainToConnect = this.getChainById(chainId);
137
- const { store, walletName, originalWallet } = this;
138
- try {
139
- const account = await originalWallet.getAccount(chainToConnect.chainId);
140
- store.updateChainWalletState(walletName, chainToConnect.chainName, { account });
141
- if (this.originalWallet instanceof WCWallet) {
142
- this.originalWallet.setAccountToRestore(account);
143
- }
144
- return account;
145
- }
146
- catch (error) {
147
- console.log(error);
148
- }
149
- }
150
- getOfflineSigner(chainId) {
151
- return this.originalWallet.getOfflineSigner(chainId);
152
- }
153
- addSuggestChain(chainId) {
154
- return this.originalWallet.addSuggestChain(chainId);
155
- }
156
- getProvider(chainId) {
157
- return this.originalWallet.getProvider(chainId);
158
- }
159
- getChainById(chainId) {
160
- return this.originalWallet.getChainById(chainId);
161
- }
162
- getWalletOfType(WalletClass) {
163
- if (this.originalWallet instanceof WalletClass) {
164
- return this.originalWallet;
165
- }
166
- if (this.originalWallet instanceof MultiChainWallet) {
167
- if (isSameConstructor(WalletClass, CosmosWallet)) {
168
- const cosmosWallet = this.originalWallet.getWalletByChainType('cosmos');
169
- if (cosmosWallet) {
170
- return cosmosWallet;
171
- }
172
- }
173
- if (isSameConstructor(WalletClass, EthereumWallet)) {
174
- const ethereumWallet = this.originalWallet.getWalletByChainType('eip155');
175
- if (ethereumWallet) {
176
- return ethereumWallet;
177
- }
178
- }
179
- }
180
- return undefined;
181
- }
182
- }
@@ -1,262 +0,0 @@
1
- import { WalletState } from "@interchain-kit/core";
2
- import { createStore } from "zustand";
3
- import { immer } from "zustand/middleware/immer";
4
- import { persist, createJSONStorage } from 'zustand/middleware';
5
- import { dedupeAsync, restoreAccountFromLocalStorage } from '../utils';
6
- import { StatefulWallet } from './stateful-wallet';
7
- const immerSyncUp = (newWalletManager) => {
8
- return (draft) => {
9
- draft.chains = newWalletManager.chains;
10
- draft.assetLists = newWalletManager.assetLists;
11
- draft.wallets = newWalletManager.wallets;
12
- draft.signerOptions = newWalletManager.signerOptions;
13
- draft.endpointOptions = newWalletManager.endpointOptions;
14
- draft.signerOptionMap = newWalletManager.signerOptionMap;
15
- draft.endpointOptionsMap = newWalletManager.endpointOptionsMap;
16
- draft.preferredSignTypeMap = newWalletManager.preferredSignTypeMap;
17
- };
18
- };
19
- export const createInterchainStore = (walletManager) => {
20
- return createStore(persist(immer((set, get) => ({
21
- chainWalletState: [],
22
- currentWalletName: '',
23
- currentChainName: '',
24
- chains: [...walletManager.chains],
25
- assetLists: [...walletManager.assetLists],
26
- wallets: walletManager.wallets.map(wallet => new StatefulWallet(wallet, get)),
27
- signerOptions: walletManager.signerOptions,
28
- endpointOptions: walletManager.endpointOptions,
29
- preferredSignTypeMap: { ...walletManager.preferredSignTypeMap },
30
- signerOptionMap: { ...walletManager.signerOptionMap },
31
- endpointOptionsMap: { ...walletManager.endpointOptionsMap },
32
- walletConnectQRCodeUri: '',
33
- isReady: false,
34
- modalIsOpen: false,
35
- openModal: () => {
36
- set(draft => {
37
- draft.modalIsOpen = true;
38
- });
39
- },
40
- closeModal: () => {
41
- set(draft => {
42
- draft.modalIsOpen = false;
43
- draft.walletConnectQRCodeUri = ''; // reset the QR code uri when modal is closed
44
- });
45
- },
46
- updateChainWalletState: (walletName, chainName, data) => {
47
- set(draft => {
48
- let targetIndex = draft.chainWalletState.findIndex(cws => cws.walletName === walletName && cws.chainName === chainName);
49
- draft.chainWalletState[targetIndex] = { ...draft.chainWalletState[targetIndex], ...data };
50
- });
51
- },
52
- init: async () => {
53
- const oldChainWalletStatesMap = new Map(get().chainWalletState.map(cws => [cws.walletName + cws.chainName, cws]));
54
- // get().createStatefulWallet()
55
- // should remove wallet that already disconnected ,for hydrain back from localstorage
56
- // const oldChainWalletStateMap = new Map()
57
- // get().chainWalletState.forEach(cws => {
58
- // if(cws.walletState === WalletState.Connected) {
59
- // oldChainWalletStateMap.set(cws.walletName + cws.chainName, cws)
60
- // }
61
- // })
62
- get().wallets.forEach(wallet => {
63
- get().chains.forEach(chain => {
64
- set(draft => {
65
- if (!oldChainWalletStatesMap.has(wallet.info.name + chain.chainName)) {
66
- draft.chainWalletState.push({
67
- chainName: chain.chainName,
68
- walletName: wallet.info.name,
69
- walletState: WalletState.Disconnected,
70
- rpcEndpoint: "",
71
- errorMessage: "",
72
- account: undefined
73
- });
74
- }
75
- });
76
- });
77
- });
78
- await Promise.all(get().wallets.map(async (wallet) => wallet.init()));
79
- set(draft => {
80
- draft.isReady = true;
81
- });
82
- },
83
- setCurrentChainName: (chainName) => {
84
- set(draft => { draft.currentChainName = chainName; });
85
- },
86
- setCurrentWalletName: (walletName) => {
87
- set(draft => { draft.currentWalletName = walletName; });
88
- },
89
- setWalletConnectQRCodeUri: (uri) => {
90
- set(draft => { draft.walletConnectQRCodeUri = uri; });
91
- },
92
- getDraftChainWalletState: (state, walletName, chainName) => {
93
- const targetIndex = state.chainWalletState.findIndex(cws => cws.walletName === walletName && cws.chainName === chainName);
94
- return state.chainWalletState[targetIndex];
95
- },
96
- getChainWalletState: (walletName, chainName) => {
97
- return get().chainWalletState.find(cws => cws.walletName === walletName && cws.chainName === chainName);
98
- },
99
- addChains: async (newChains, newAssetLists, newSignerOptions, newEndpointOptions) => {
100
- await walletManager.addChains(newChains, newAssetLists, newSignerOptions, newEndpointOptions);
101
- // console.log(walletManager.chains, walletManager.assetLists)
102
- // set(immerSyncUp(walletManager))
103
- // set(draft => {
104
- // draft.chains = walletManager.chains
105
- // })
106
- set(draft => {
107
- const existedChainMap = new Map(get().chains.map(chain => [chain.chainName, chain]));
108
- const newAssetListMap = new Map(newAssetLists.map(assetList => [assetList.chainName, assetList]));
109
- newChains.forEach(newChain => {
110
- if (!existedChainMap.has(newChain.chainName)) {
111
- draft.chains.push(newChain);
112
- draft.assetLists.push(newAssetListMap.get(newChain.chainName));
113
- }
114
- draft.signerOptionMap[newChain.chainName] = newSignerOptions?.signing(newChain.chainName);
115
- draft.endpointOptionsMap[newChain.chainName] = newEndpointOptions?.endpoints?.[newChain.chainName];
116
- });
117
- get().chains.forEach(chain => {
118
- draft.signerOptionMap[chain.chainName] = {
119
- ...get().signerOptionMap[chain.chainName],
120
- ...newSignerOptions?.signing(chain.chainName)
121
- };
122
- draft.endpointOptionsMap[chain.chainName] = {
123
- ...get().endpointOptionsMap[chain.chainName],
124
- ...newEndpointOptions?.endpoints?.[chain.chainName]
125
- };
126
- });
127
- const existedChainWalletStatesMap = new Map(get().chainWalletState.map(cws => [cws.walletName + cws.chainName, cws]));
128
- get().wallets.forEach(wallet => {
129
- newChains.forEach(newChain => {
130
- if (!existedChainWalletStatesMap.has(wallet.info.name + newChain.chainName)) {
131
- draft.chainWalletState.push({
132
- chainName: newChain.chainName,
133
- walletName: wallet.info.name,
134
- walletState: WalletState.Disconnected,
135
- rpcEndpoint: "",
136
- errorMessage: "",
137
- account: undefined
138
- });
139
- }
140
- });
141
- });
142
- draft.chainWalletState = draft.chainWalletState.map(cws => {
143
- return { ...cws, rpcEndpoint: newEndpointOptions?.endpoints?.[cws.chainName]?.rpc?.[0] || cws.rpcEndpoint };
144
- });
145
- });
146
- },
147
- connect: async (walletName, chainName) => {
148
- const wallet = get().wallets.find(w => w.info.name === walletName);
149
- const chain = get().chains.find(c => c.chainName === chainName);
150
- if (!wallet) {
151
- throw new Error(`Wallet ${walletName} not found`);
152
- }
153
- if (!chain) {
154
- throw new Error(`Chain ${chainName} not found`);
155
- }
156
- return wallet.connect(chain.chainId);
157
- },
158
- disconnect: async (walletName, chainName) => {
159
- const wallet = get().wallets.find(w => w.info.name === walletName);
160
- const chain = get().chains.find(c => c.chainName === chainName);
161
- if (!wallet) {
162
- throw new Error(`Wallet ${walletName} not found`);
163
- }
164
- if (!chain) {
165
- throw new Error(`Chain ${chainName} not found`);
166
- }
167
- return wallet.disconnect(chain.chainId);
168
- },
169
- getAccount: async (walletName, chainName) => {
170
- const wallet = get().wallets.find(w => w.info.name === walletName);
171
- const chain = get().chains.find(c => c.chainName === chainName);
172
- if (!wallet) {
173
- throw new Error(`Wallet ${walletName} not found`);
174
- }
175
- if (!chain) {
176
- throw new Error(`Chain ${chainName} not found`);
177
- }
178
- const existedAccount = get().chainWalletState.find(cws => cws.walletName === walletName && cws.chainName === chainName)?.account;
179
- if (existedAccount) {
180
- return existedAccount;
181
- }
182
- return wallet.getAccount(chain.chainId);
183
- },
184
- getRpcEndpoint: async (walletName, chainName) => {
185
- return dedupeAsync(`${chainName}-rpcEndpoint`, async () => {
186
- const rpcEndpoint = await walletManager.getRpcEndpoint(walletName, chainName);
187
- get().wallets.map(wallet => {
188
- get().updateChainWalletState(wallet.info.name, chainName, { rpcEndpoint });
189
- });
190
- return rpcEndpoint;
191
- });
192
- },
193
- getChainLogoUrl(chainName) {
194
- return walletManager.getChainLogoUrl(chainName);
195
- },
196
- getChainByName(chainName) {
197
- return walletManager.getChainByName(chainName);
198
- },
199
- getAssetListByName(chainName) {
200
- return walletManager.getAssetListByName(chainName);
201
- },
202
- getDownloadLink(walletName) {
203
- return walletManager.getDownloadLink(walletName);
204
- },
205
- async getOfflineSigner(walletName, chainName) {
206
- return walletManager.getOfflineSigner(walletName, chainName);
207
- },
208
- getPreferSignType(chainName) {
209
- const result = walletManager.getPreferSignType(chainName);
210
- // set(immerSyncUp(walletManager))
211
- return result;
212
- },
213
- getSignerOptions(chainName) {
214
- const result = walletManager.getSignerOptions(chainName);
215
- // set(immerSyncUp(walletManager))
216
- return result;
217
- },
218
- getWalletByName(walletName) {
219
- return walletManager.getWalletByName(walletName);
220
- },
221
- getStatefulWalletByName(walletName) {
222
- return get().wallets.find(w => w.info.name === walletName);
223
- },
224
- async getSigningClient(walletName, chainName) {
225
- return walletManager.getSigningClient(walletName, chainName);
226
- },
227
- getEnv() {
228
- return walletManager.getEnv();
229
- },
230
- })), {
231
- name: 'interchain-kit-store',
232
- storage: createJSONStorage(() => localStorage),
233
- partialize: state => ({
234
- chainWalletState: state.chainWalletState.map(cws => ({
235
- chainName: cws.chainName,
236
- walletName: cws.walletName,
237
- account: cws.account,
238
- walletState: cws.walletState,
239
- })),
240
- currentWalletName: state.currentWalletName,
241
- currentChainName: state.currentChainName
242
- }),
243
- onRehydrateStorage: (state) => {
244
- // console.log('interchain-kit store hydration starts')
245
- // optional
246
- return (state, error) => {
247
- if (error) {
248
- console.log('an error happened during hydration', error);
249
- }
250
- else {
251
- // console.log('interchain-kit store hydration finished')
252
- state.chainWalletState = state.chainWalletState.map(cws => {
253
- return {
254
- ...cws,
255
- account: cws.account ? restoreAccountFromLocalStorage(cws.account) : null
256
- };
257
- });
258
- }
259
- };
260
- },
261
- }));
262
- };
@@ -1,17 +0,0 @@
1
- import { Chain } from "@chain-registry/types";
2
- import { BaseWallet, WalletAccount } from "@interchain-kit/core";
3
- import { IGenericOfflineSigner } from "@interchainjs/types";
4
- export declare class ChainWallet<TWallet extends BaseWallet> extends BaseWallet {
5
- getProvider(chainId: Chain["chainId"]): Promise<unknown>;
6
- originalWallet: TWallet;
7
- connectWithState: TWallet['connect'];
8
- disconnectWithState: TWallet['disconnect'];
9
- getAccountWithState: TWallet['getAccount'];
10
- constructor(originalWallet: TWallet, connectWithState: TWallet['connect'], disconnectWithState: TWallet['disconnect'], getAccountWithState: TWallet['getAccount']);
11
- init(meta?: unknown): Promise<void>;
12
- connect(chainId: string): Promise<void>;
13
- disconnect(chainId: string): Promise<void>;
14
- getAccount(chainId: string): Promise<WalletAccount>;
15
- getOfflineSigner(chainId: string): Promise<IGenericOfflineSigner>;
16
- addSuggestChain(chainId: Chain['chainId']): Promise<void>;
17
- }
@@ -1,39 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ChainWallet = void 0;
4
- const core_1 = require("@interchain-kit/core");
5
- class ChainWallet extends core_1.BaseWallet {
6
- getProvider(chainId) {
7
- return this.originalWallet.getProvider(chainId);
8
- }
9
- originalWallet;
10
- connectWithState;
11
- disconnectWithState;
12
- getAccountWithState;
13
- constructor(originalWallet, connectWithState, disconnectWithState, getAccountWithState) {
14
- super(originalWallet?.info);
15
- this.originalWallet = originalWallet;
16
- this.connectWithState = connectWithState;
17
- this.disconnectWithState = disconnectWithState;
18
- this.getAccountWithState = getAccountWithState;
19
- }
20
- async init(meta) {
21
- return this.originalWallet.init();
22
- }
23
- async connect(chainId) {
24
- return this.connectWithState(chainId);
25
- }
26
- async disconnect(chainId) {
27
- return this.disconnectWithState(chainId);
28
- }
29
- async getAccount(chainId) {
30
- return this.getAccountWithState(chainId);
31
- }
32
- async getOfflineSigner(chainId) {
33
- return this.originalWallet.getOfflineSigner(chainId);
34
- }
35
- async addSuggestChain(chainId) {
36
- return this.originalWallet.addSuggestChain(chainId);
37
- }
38
- }
39
- exports.ChainWallet = ChainWallet;
package/store/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from './chain-wallet';
2
- export * from './store';
package/store/index.js DELETED
@@ -1,18 +0,0 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./chain-wallet"), exports);
18
- __exportStar(require("./store"), exports);
@@ -1,21 +0,0 @@
1
- import { BaseWallet, WalletAccount, WalletState } from "@interchain-kit/core";
2
- import { InterchainStore } from "./store";
3
- import { Chain } from "@chain-registry/types";
4
- export declare class StatefulWallet extends BaseWallet {
5
- originalWallet: BaseWallet;
6
- walletName: string;
7
- get: () => InterchainStore;
8
- constructor(wallet: BaseWallet, get: () => InterchainStore);
9
- get store(): InterchainStore;
10
- get walletState(): WalletState;
11
- get errorMessage(): string;
12
- init(): Promise<void>;
13
- connect(chainId: Chain["chainId"]): Promise<void>;
14
- disconnect(chainId: Chain["chainId"]): Promise<void>;
15
- getAccount(chainId: Chain["chainId"]): Promise<WalletAccount>;
16
- getOfflineSigner(chainId: Chain['chainId']): Promise<import("@interchainjs/types").IGenericOfflineSigner<unknown, unknown, unknown, import("@interchainjs/types").IGenericOfflineSignArgs<unknown, unknown>, import("@interchainjs/types").AccountData>>;
17
- addSuggestChain(chainId: Chain["chainId"]): Promise<void>;
18
- getProvider(chainId?: Chain["chainId"]): Promise<any>;
19
- getChainById(chainId: Chain["chainId"]): Chain;
20
- getWalletOfType<T>(WalletClass: new (...args: any[]) => T): T | undefined;
21
- }