@interchain-kit/react 0.3.21 → 0.3.22

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.
@@ -33,10 +33,19 @@ export const createInterchainStore = (walletManager) => {
33
33
  endpointOptionsMap: { ...walletManager.endpointOptionsMap },
34
34
  walletConnectQRCodeUri: '',
35
35
  isReady: false,
36
+ updateWalletState: (walletName, data) => {
37
+ set(draft => {
38
+ let targetWalletIndex = draft.wallets.findIndex(w => w.info.name === walletName);
39
+ draft.wallets[targetWalletIndex].walletState = data.walletState;
40
+ });
41
+ },
36
42
  updateChainWalletState: (walletName, chainName, data) => {
37
43
  set(draft => {
38
44
  let targetIndex = draft.chainWalletState.findIndex(cws => cws.walletName === walletName && cws.chainName === chainName);
39
45
  draft.chainWalletState[targetIndex] = { ...draft.chainWalletState[targetIndex], ...data };
46
+ if (data.walletState) {
47
+ get().updateWalletState(walletName, data);
48
+ }
40
49
  });
41
50
  },
42
51
  createStatefulWallet: () => {
@@ -167,8 +176,8 @@ export const createInterchainStore = (walletManager) => {
167
176
  });
168
177
  },
169
178
  init: async () => {
170
- get().createStatefulWallet();
171
179
  const oldChainWalletStatesMap = new Map(get().chainWalletState.map(cws => [cws.walletName + cws.chainName, cws]));
180
+ get().createStatefulWallet();
172
181
  // should remove wallet that already disconnected ,for hydrain back from localstorage
173
182
  // const oldChainWalletStateMap = new Map()
174
183
  // get().chainWalletState.forEach(cws => {
@@ -208,13 +217,16 @@ export const createInterchainStore = (walletManager) => {
208
217
  set(draft => {
209
218
  draft.chainWalletState = draft.chainWalletState.map(cws => {
210
219
  if (NotExistWallets.includes(cws.walletName)) {
220
+ get().updateWalletState(cws.walletName, { walletState: WalletState.NotExist });
211
221
  return { ...cws, walletState: WalletState.NotExist };
212
222
  }
213
223
  return cws;
214
224
  });
215
225
  draft.chainWalletState = draft.chainWalletState.map(cws => {
216
226
  if (ExistWallets.includes(cws.walletName)) {
217
- return { ...cws, walletState: cws.walletState === WalletState.NotExist ? WalletState.Disconnected : cws.walletState };
227
+ const newState = cws.walletState === WalletState.NotExist ? WalletState.Disconnected : cws.walletState;
228
+ get().updateWalletState(cws.walletName, { walletState: newState });
229
+ return { ...cws, walletState: newState };
218
230
  }
219
231
  return cws;
220
232
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interchain-kit/react",
3
- "version": "0.3.21",
3
+ "version": "0.3.22",
4
4
  "author": "Hyperweb <developers@hyperweb.io>",
5
5
  "description": "interchain-kit wallet connector react package",
6
6
  "main": "index.js",
@@ -34,7 +34,7 @@
34
34
  "keywords": [],
35
35
  "dependencies": {
36
36
  "@chain-registry/v2-types": "^0.53.40",
37
- "@interchain-kit/core": "^0.3.21",
37
+ "@interchain-kit/core": "^0.3.22",
38
38
  "@interchain-ui/react": "1.26.1",
39
39
  "@interchainjs/cosmos": "1.11.9",
40
40
  "@interchainjs/cosmos-types": "1.11.9",
@@ -64,5 +64,5 @@
64
64
  "react": "^19.0.0",
65
65
  "react-dom": "^19.0.0"
66
66
  },
67
- "gitHead": "55ef30266ed5a638e8724d35bcd5941f88d400c2"
67
+ "gitHead": "c0123638121646a6c503c5be4796bf757ceae166"
68
68
  }
package/store/store.d.ts CHANGED
@@ -19,8 +19,9 @@ export interface InterchainStore extends WalletManager {
19
19
  getDraftChainWalletState: (state: InterchainStore, walletName: string, chainName: string) => ChainWalletState;
20
20
  getChainWalletState: (walletName: string, chainName: string) => ChainWalletState | undefined;
21
21
  updateChainWalletState: (walletName: string, chainName: string, data: Partial<ChainWalletState>) => void;
22
- createStatefulWallet: () => void;
22
+ updateWalletState: (walletName: string, data: Partial<ChainWalletState>) => void;
23
23
  isReady: boolean;
24
+ createStatefulWallet: () => void;
24
25
  }
25
26
  export type InterchainStoreData = {
26
27
  chains: Chain[];
package/store/store.js CHANGED
@@ -36,10 +36,19 @@ const createInterchainStore = (walletManager) => {
36
36
  endpointOptionsMap: { ...walletManager.endpointOptionsMap },
37
37
  walletConnectQRCodeUri: '',
38
38
  isReady: false,
39
+ updateWalletState: (walletName, data) => {
40
+ set(draft => {
41
+ let targetWalletIndex = draft.wallets.findIndex(w => w.info.name === walletName);
42
+ draft.wallets[targetWalletIndex].walletState = data.walletState;
43
+ });
44
+ },
39
45
  updateChainWalletState: (walletName, chainName, data) => {
40
46
  set(draft => {
41
47
  let targetIndex = draft.chainWalletState.findIndex(cws => cws.walletName === walletName && cws.chainName === chainName);
42
48
  draft.chainWalletState[targetIndex] = { ...draft.chainWalletState[targetIndex], ...data };
49
+ if (data.walletState) {
50
+ get().updateWalletState(walletName, data);
51
+ }
43
52
  });
44
53
  },
45
54
  createStatefulWallet: () => {
@@ -170,8 +179,8 @@ const createInterchainStore = (walletManager) => {
170
179
  });
171
180
  },
172
181
  init: async () => {
173
- get().createStatefulWallet();
174
182
  const oldChainWalletStatesMap = new Map(get().chainWalletState.map(cws => [cws.walletName + cws.chainName, cws]));
183
+ get().createStatefulWallet();
175
184
  // should remove wallet that already disconnected ,for hydrain back from localstorage
176
185
  // const oldChainWalletStateMap = new Map()
177
186
  // get().chainWalletState.forEach(cws => {
@@ -211,13 +220,16 @@ const createInterchainStore = (walletManager) => {
211
220
  set(draft => {
212
221
  draft.chainWalletState = draft.chainWalletState.map(cws => {
213
222
  if (NotExistWallets.includes(cws.walletName)) {
223
+ get().updateWalletState(cws.walletName, { walletState: core_1.WalletState.NotExist });
214
224
  return { ...cws, walletState: core_1.WalletState.NotExist };
215
225
  }
216
226
  return cws;
217
227
  });
218
228
  draft.chainWalletState = draft.chainWalletState.map(cws => {
219
229
  if (ExistWallets.includes(cws.walletName)) {
220
- return { ...cws, walletState: cws.walletState === core_1.WalletState.NotExist ? core_1.WalletState.Disconnected : cws.walletState };
230
+ const newState = cws.walletState === core_1.WalletState.NotExist ? core_1.WalletState.Disconnected : cws.walletState;
231
+ get().updateWalletState(cws.walletName, { walletState: newState });
232
+ return { ...cws, walletState: newState };
221
233
  }
222
234
  return cws;
223
235
  });