@interchain-kit/store 0.3.47 → 0.3.48

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.
@@ -120,6 +120,6 @@ export class InterchainStore {
120
120
  this.setState({ chainWalletStates: newChainWalletStates });
121
121
  }
122
122
  isChainWalletStateExisted(walletName, chainName) {
123
- return this.chainWalletIndexMap.get(`${walletName}-${chainName}`);
123
+ return this.chainWalletIndexMap.get(`${walletName}-${chainName}`) !== undefined;
124
124
  }
125
125
  }
@@ -11,6 +11,7 @@ export class ChainWalletStore extends BaseWallet {
11
11
  this.chain = chain;
12
12
  this.store = store;
13
13
  this.walletManager = walletManager;
14
+ this.info = this.wallet.info;
14
15
  }
15
16
  get walletState() {
16
17
  return this.store.getChainWalletState(this.chain.chainName, this.wallet.info.name)?.walletState || WalletState.NotExist;
@@ -35,7 +36,7 @@ export class ChainWalletStore extends BaseWallet {
35
36
  });
36
37
  }
37
38
  try {
38
- this.store.updateChainWalletState(this.wallet.info.name, this.chain.chainName, { walletState: WalletState.Connecting });
39
+ this.store.updateChainWalletState(this.wallet.info.name, this.chain.chainName, { walletState: WalletState.Connecting, errorMessage: '' });
39
40
  await this.wallet.connect(this.chain.chainId);
40
41
  const account = await this.getAccount();
41
42
  this.store.updateChainWalletState(this.wallet.info.name, this.chain.chainName, { walletState: WalletState.Connected, account });
@@ -61,7 +62,6 @@ export class ChainWalletStore extends BaseWallet {
61
62
  async refreshAccount() {
62
63
  try {
63
64
  const account = await this.wallet.getAccount(this.chain.chainId);
64
- console.log(this.wallet);
65
65
  this.store.updateChainWalletState(this.wallet.info.name, this.chain.chainName, { account });
66
66
  }
67
67
  catch (error) {
@@ -1,4 +1,4 @@
1
- import { BaseWallet, WalletState } from '@interchain-kit/core';
1
+ import { BaseWallet, getWalletByType, WalletState } from '@interchain-kit/core';
2
2
  import { ChainWalletStore } from './chain-wallet-store';
3
3
  export class WalletStore extends BaseWallet {
4
4
  wallet;
@@ -96,4 +96,7 @@ export class WalletStore extends BaseWallet {
96
96
  }
97
97
  return this.getChainWalletStore(chain.chainName).getProvider();
98
98
  }
99
+ getWalletOfType(WalletClass) {
100
+ return getWalletByType(this.wallet, WalletClass);
101
+ }
99
102
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interchain-kit/store",
3
- "version": "0.3.47",
3
+ "version": "0.3.48",
4
4
  "author": "Hyperweb <developers@hyperweb.io>",
5
5
  "description": "interchain-kit wallet connector store package",
6
6
  "main": "index.js",
@@ -31,5 +31,5 @@
31
31
  "watch:dev": "tsc -w -p tsconfig.esm.json & tsc -w"
32
32
  },
33
33
  "keywords": [],
34
- "gitHead": "4583b572672abd85a0918f39f534a5bf9312c261"
34
+ "gitHead": "763ba776cbfcbff8ef76a512ef5758c7187cb1f4"
35
35
  }
package/store/index.d.ts CHANGED
@@ -17,5 +17,5 @@ export declare class InterchainStore {
17
17
  getChainWalletState(walletName: string, chainName: string): ChainWalletState | undefined;
18
18
  buildIndexMap(): void;
19
19
  updateWalletState(walletName: string, state: Partial<ChainWalletState>): void;
20
- isChainWalletStateExisted(walletName: string, chainName: string): number;
20
+ isChainWalletStateExisted(walletName: string, chainName: string): boolean;
21
21
  }
package/store/index.js CHANGED
@@ -123,7 +123,7 @@ class InterchainStore {
123
123
  this.setState({ chainWalletStates: newChainWalletStates });
124
124
  }
125
125
  isChainWalletStateExisted(walletName, chainName) {
126
- return this.chainWalletIndexMap.get(`${walletName}-${chainName}`);
126
+ return this.chainWalletIndexMap.get(`${walletName}-${chainName}`) !== undefined;
127
127
  }
128
128
  }
129
129
  exports.InterchainStore = InterchainStore;
@@ -14,6 +14,7 @@ class ChainWalletStore extends core_1.BaseWallet {
14
14
  this.chain = chain;
15
15
  this.store = store;
16
16
  this.walletManager = walletManager;
17
+ this.info = this.wallet.info;
17
18
  }
18
19
  get walletState() {
19
20
  return this.store.getChainWalletState(this.chain.chainName, this.wallet.info.name)?.walletState || core_1.WalletState.NotExist;
@@ -38,7 +39,7 @@ class ChainWalletStore extends core_1.BaseWallet {
38
39
  });
39
40
  }
40
41
  try {
41
- this.store.updateChainWalletState(this.wallet.info.name, this.chain.chainName, { walletState: core_1.WalletState.Connecting });
42
+ this.store.updateChainWalletState(this.wallet.info.name, this.chain.chainName, { walletState: core_1.WalletState.Connecting, errorMessage: '' });
42
43
  await this.wallet.connect(this.chain.chainId);
43
44
  const account = await this.getAccount();
44
45
  this.store.updateChainWalletState(this.wallet.info.name, this.chain.chainName, { walletState: core_1.WalletState.Connected, account });
@@ -64,7 +65,6 @@ class ChainWalletStore extends core_1.BaseWallet {
64
65
  async refreshAccount() {
65
66
  try {
66
67
  const account = await this.wallet.getAccount(this.chain.chainId);
67
- console.log(this.wallet);
68
68
  this.store.updateChainWalletState(this.wallet.info.name, this.chain.chainName, { account });
69
69
  }
70
70
  catch (error) {
@@ -18,4 +18,5 @@ export declare class WalletStore extends BaseWallet {
18
18
  getAccount(chainId: Chain['chainId']): Promise<WalletAccount>;
19
19
  addSuggestChain(chainId: Chain['chainId']): Promise<void>;
20
20
  getProvider(chainId: Chain['chainId']): Promise<any>;
21
+ getWalletOfType<T>(WalletClass: new (...args: any[]) => T): T;
21
22
  }
@@ -99,5 +99,8 @@ class WalletStore extends core_1.BaseWallet {
99
99
  }
100
100
  return this.getChainWalletStore(chain.chainName).getProvider();
101
101
  }
102
+ getWalletOfType(WalletClass) {
103
+ return (0, core_1.getWalletByType)(this.wallet, WalletClass);
104
+ }
102
105
  }
103
106
  exports.WalletStore = WalletStore;