@keplr-wallet/stores 0.12.300-rc.0 → 0.12.304

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 (103) hide show
  1. package/build/account/babylon.js +7 -19
  2. package/build/account/babylon.js.map +1 -1
  3. package/build/account/base.js +5 -7
  4. package/build/account/base.js.map +1 -1
  5. package/build/account/cosmos.js +54 -94
  6. package/build/account/cosmos.js.map +1 -1
  7. package/build/account/cosmwasm.js +2 -10
  8. package/build/account/cosmwasm.js.map +1 -1
  9. package/build/account/secret.js +2 -10
  10. package/build/account/secret.js.map +1 -1
  11. package/build/account/store.js +4 -4
  12. package/build/account/store.js.map +1 -1
  13. package/build/chain/base.d.ts +1 -122
  14. package/build/chain/base.js +40 -601
  15. package/build/chain/base.js.map +1 -1
  16. package/build/chain/types.d.ts +1 -27
  17. package/build/common/utils/index.d.ts +2 -2
  18. package/build/common/utils/index.js.map +1 -1
  19. package/build/lsm/currency-registrar.js +7 -7
  20. package/build/lsm/currency-registrar.js.map +1 -1
  21. package/build/query/balances.js +11 -24
  22. package/build/query/balances.js.map +1 -1
  23. package/build/query/chain-query.js +2 -2
  24. package/build/query/chain-query.js.map +1 -1
  25. package/build/query/chain-rpc-query.js +2 -2
  26. package/build/query/chain-rpc-query.js.map +1 -1
  27. package/build/query/cosmos/balance/balances.js +4 -8
  28. package/build/query/cosmos/balance/balances.js.map +1 -1
  29. package/build/query/cosmos/balance/spendable.js +2 -3
  30. package/build/query/cosmos/balance/spendable.js.map +1 -1
  31. package/build/query/cosmos/ibc/channel.js +2 -3
  32. package/build/query/cosmos/ibc/channel.js.map +1 -1
  33. package/build/query/cosmos/ibc/client-state.js +2 -2
  34. package/build/query/cosmos/ibc/client-state.js.map +1 -1
  35. package/build/query/cosmos/ibc/denom-trace.js +8 -6
  36. package/build/query/cosmos/ibc/denom-trace.js.map +1 -1
  37. package/build/query/cosmos/staking/babylon-btc-delegation-reward.js +2 -3
  38. package/build/query/cosmos/staking/babylon-btc-delegation-reward.js.map +1 -1
  39. package/build/query/cosmos/staking/delegations.js +4 -5
  40. package/build/query/cosmos/staking/delegations.js.map +1 -1
  41. package/build/query/cosmos/staking/initia-delegations.js +6 -8
  42. package/build/query/cosmos/staking/initia-delegations.js.map +1 -1
  43. package/build/query/cosmos/staking/initia-unbonding-delegations.js +5 -6
  44. package/build/query/cosmos/staking/initia-unbonding-delegations.js.map +1 -1
  45. package/build/query/cosmos/staking/initia-validators.js +3 -3
  46. package/build/query/cosmos/staking/initia-validators.js.map +1 -1
  47. package/build/query/cosmos/staking/pool.js +3 -3
  48. package/build/query/cosmos/staking/pool.js.map +1 -1
  49. package/build/query/cosmos/staking/rewards.js +10 -13
  50. package/build/query/cosmos/staking/rewards.js.map +1 -1
  51. package/build/query/cosmos/staking/unbonding-delegations.js +3 -3
  52. package/build/query/cosmos/staking/unbonding-delegations.js.map +1 -1
  53. package/build/query/cosmos/staking/validators.js +3 -2
  54. package/build/query/cosmos/staking/validators.js.map +1 -1
  55. package/build/query/cosmwasm/contract-query.js +2 -2
  56. package/build/query/cosmwasm/contract-query.js.map +1 -1
  57. package/build/query/cosmwasm/cw20-balance.js +4 -7
  58. package/build/query/cosmwasm/cw20-balance.js.map +1 -1
  59. package/build/query/cosmwasm/neutron/staking-rewards.js +8 -10
  60. package/build/query/cosmwasm/neutron/staking-rewards.js.map +1 -1
  61. package/build/query/noble/swap/simulate-swap.js +1 -1
  62. package/build/query/noble/swap/simulate-swap.js.map +1 -1
  63. package/build/query/osmosis/txfees/fee-tokens/index.js +4 -8
  64. package/build/query/osmosis/txfees/fee-tokens/index.js.map +1 -1
  65. package/build/query/secret-wasm/secret20-balance.js +5 -7
  66. package/build/query/secret-wasm/secret20-balance.js.map +1 -1
  67. package/build/token-factory/currency-registrar.js +1 -1
  68. package/build/token-factory/currency-registrar.js.map +1 -1
  69. package/package.json +15 -11
  70. package/src/account/babylon.ts +7 -21
  71. package/src/account/base.ts +5 -7
  72. package/src/account/cosmos.ts +66 -121
  73. package/src/account/cosmwasm.ts +3 -12
  74. package/src/account/secret.ts +3 -12
  75. package/src/account/store.ts +4 -4
  76. package/src/chain/base.ts +34 -816
  77. package/src/chain/types.ts +1 -27
  78. package/src/common/utils/index.ts +2 -2
  79. package/src/lsm/currency-registrar.ts +7 -9
  80. package/src/query/balances.ts +13 -30
  81. package/src/query/chain-query.ts +2 -6
  82. package/src/query/chain-rpc-query.ts +2 -6
  83. package/src/query/cosmos/balance/balances.ts +4 -8
  84. package/src/query/cosmos/balance/spendable.ts +3 -3
  85. package/src/query/cosmos/ibc/channel.ts +2 -5
  86. package/src/query/cosmos/ibc/client-state.ts +2 -2
  87. package/src/query/cosmos/ibc/denom-trace.ts +7 -7
  88. package/src/query/cosmos/staking/babylon-btc-delegation-reward.ts +2 -5
  89. package/src/query/cosmos/staking/delegations.ts +4 -9
  90. package/src/query/cosmos/staking/initia-delegations.ts +7 -14
  91. package/src/query/cosmos/staking/initia-unbonding-delegations.ts +6 -12
  92. package/src/query/cosmos/staking/initia-validators.ts +3 -5
  93. package/src/query/cosmos/staking/pool.ts +3 -3
  94. package/src/query/cosmos/staking/rewards.ts +10 -13
  95. package/src/query/cosmos/staking/unbonding-delegations.ts +3 -7
  96. package/src/query/cosmos/staking/validators.ts +3 -4
  97. package/src/query/cosmwasm/contract-query.ts +2 -4
  98. package/src/query/cosmwasm/cw20-balance.ts +5 -8
  99. package/src/query/cosmwasm/neutron/staking-rewards.ts +8 -10
  100. package/src/query/noble/swap/simulate-swap.ts +1 -1
  101. package/src/query/osmosis/txfees/fee-tokens/index.ts +4 -8
  102. package/src/query/secret-wasm/secret20-balance.ts +5 -7
  103. package/src/token-factory/currency-registrar.ts +1 -1
@@ -86,37 +86,11 @@ export interface IModularChainInfoImpl<
86
86
  > {
87
87
  readonly embedded: M;
88
88
  readonly chainId: string;
89
- readonly stakeCurrency: Currency | undefined;
90
- readonly feeCurrencies: FeeCurrency[] | undefined;
91
89
 
92
- getCurrencies(): AppCurrency[];
93
- getCurrenciesByModule(module: ChainInfoModule): AppCurrency[];
90
+ getCurrencies(module: ChainInfoModule): AppCurrency[];
94
91
  addCurrencies(module: ChainInfoModule, ...currencies: AppCurrency[]): void;
95
92
  removeCurrencies(
96
93
  module: ChainInfoModule,
97
94
  ...coinMinimalDenoms: string[]
98
95
  ): void;
99
- findCurrency(coinMinimalDenom: string): AppCurrency | undefined;
100
- forceFindCurrency(coinMinimalDenom: string): AppCurrency;
101
- findCurrencyWithoutReaction(
102
- coinMinimalDenom: string
103
- ): AppCurrency | undefined;
104
- forceFindCurrencyWithoutReaction(coinMinimalDenom: string): AppCurrency;
105
- findCurrencyAsync(coinMinimalDenom: string): Promise<AppCurrency | undefined>;
106
- hasFeature(feature: string): boolean;
107
- addUnknownDenoms(args: {
108
- module: ChainInfoModule;
109
- coinMinimalDenoms: string[];
110
- }): void;
111
- addUnknownDenomsWithoutReaction(args: {
112
- module: ChainInfoModule;
113
- coinMinimalDenoms: string[];
114
- }): void;
115
- isCurrencyRegistrationInProgress(coinMinimalDenom: string): boolean;
116
- matchModules(
117
- conditions:
118
- | { or: ChainInfoModule[]; and?: undefined }
119
- | { and: ChainInfoModule[]; or?: undefined }
120
- ): boolean;
121
- matchModule(module: ChainInfoModule): boolean;
122
96
  }
@@ -1,11 +1,11 @@
1
1
  import { Currency } from "@keplr-wallet/types";
2
2
  import { CoinPrimitive } from "../types";
3
3
  import { CoinPretty, Dec, Int } from "@keplr-wallet/unit";
4
- import { IModularChainInfoImpl } from "../../chain/types";
4
+ import { IChainInfoImpl } from "../../chain";
5
5
 
6
6
  export class StoreUtils {
7
7
  public static toCoinPretties(
8
- chainInfo: IModularChainInfoImpl,
8
+ chainInfo: IChainInfoImpl,
9
9
  balances: CoinPrimitive[]
10
10
  ): CoinPretty[] {
11
11
  const result: CoinPretty[] = [];
@@ -69,7 +69,7 @@ export class LSMCurrencyRegistrar {
69
69
  done: boolean;
70
70
  }
71
71
  | undefined {
72
- if (!this.chainStore.hasModularChain(chainId)) {
72
+ if (!this.chainStore.hasChain(chainId)) {
73
73
  return;
74
74
  }
75
75
 
@@ -78,16 +78,14 @@ export class LSMCurrencyRegistrar {
78
78
  return;
79
79
  }
80
80
 
81
- const chainInfo = this.chainStore.getModularChain(chainId);
82
- if (!("cosmos" in chainInfo) || !chainInfo.cosmos.stakeCurrency) {
81
+ const chainInfo = this.chainStore.getChain(chainId);
82
+ if (!chainInfo.stakeCurrency) {
83
83
  return;
84
84
  }
85
85
 
86
86
  if (
87
- !chainInfo.cosmos.bech32Config ||
88
- !coinMinimalDenom.startsWith(
89
- chainInfo.cosmos.bech32Config.bech32PrefixValAddr
90
- )
87
+ !chainInfo.bech32Config ||
88
+ !coinMinimalDenom.startsWith(chainInfo.bech32Config.bech32PrefixValAddr)
91
89
  ) {
92
90
  return;
93
91
  }
@@ -101,7 +99,7 @@ export class LSMCurrencyRegistrar {
101
99
  try {
102
100
  Bech32Address.validate(
103
101
  valAddress,
104
- chainInfo.cosmos.bech32Config?.bech32PrefixValAddr
102
+ chainInfo.bech32Config?.bech32PrefixValAddr
105
103
  );
106
104
  } catch {
107
105
  // noop
@@ -198,7 +196,7 @@ export class LSMCurrencyRegistrar {
198
196
 
199
197
  return "Unknown";
200
198
  })()}/${id}`,
201
- coinDecimals: chainInfo.cosmos.stakeCurrency.coinDecimals,
199
+ coinDecimals: chainInfo.stakeCurrency.coinDecimals,
202
200
  coinImageUrl: validator.thumbnail || undefined,
203
201
  },
204
202
  done: !validator.isFetching,
@@ -74,16 +74,12 @@ export class ObservableQueryBalancesImplMap {
74
74
 
75
75
  @computed
76
76
  get stakable(): IObservableQueryBalanceImpl | undefined {
77
- const modularChainInfoImpl = this.chainGetter.getModularChainInfoImpl(
78
- this.chainId
79
- );
80
- const chainInfo = modularChainInfoImpl.embedded;
81
-
82
- if (!("cosmos" in chainInfo) || !chainInfo.cosmos.stakeCurrency) {
77
+ const chainInfo = this.chainGetter.getChain(this.chainId);
78
+ if (!chainInfo.stakeCurrency) {
83
79
  return undefined;
84
80
  }
85
81
 
86
- return this.getBalanceInner(chainInfo.cosmos.stakeCurrency);
82
+ return this.getBalanceInner(chainInfo.stakeCurrency);
87
83
  }
88
84
 
89
85
  /**
@@ -91,16 +87,12 @@ export class ObservableQueryBalancesImplMap {
91
87
  */
92
88
  @computed
93
89
  get balances(): IObservableQueryBalanceImpl[] {
94
- const result = [];
90
+ const chainInfo = this.chainGetter.getChain(this.chainId);
95
91
 
96
- const modularChainInfoImpl = this.chainGetter.getModularChainInfoImpl(
97
- this.chainId
98
- );
99
-
100
- const currencies = modularChainInfoImpl.getCurrencies();
92
+ const result = [];
101
93
 
102
- for (let i = 0; i < currencies.length; i++) {
103
- const currency = currencies[i];
94
+ for (let i = 0; i < chainInfo.currencies.length; i++) {
95
+ const currency = chainInfo.currencies[i];
104
96
  const balanceInner = this.getBalanceInner(currency);
105
97
  if (balanceInner) {
106
98
  result.push(balanceInner);
@@ -137,10 +129,7 @@ export class ObservableQueryBalancesImplMap {
137
129
  */
138
130
  @computed
139
131
  get positiveNativeUnstakables(): IObservableQueryBalanceImpl[] {
140
- const chainInfo = this.chainGetter.getModularChain(this.chainId);
141
- if (!("cosmos" in chainInfo)) {
142
- return [];
143
- }
132
+ const chainInfo = this.chainGetter.getChain(this.chainId);
144
133
 
145
134
  const balances = this.balances;
146
135
  return balances.filter(
@@ -148,21 +137,17 @@ export class ObservableQueryBalancesImplMap {
148
137
  new DenomHelper(bal.currency.coinMinimalDenom).type === "native" &&
149
138
  bal.balance.toDec().gt(new Dec(0)) &&
150
139
  bal.currency.coinMinimalDenom !==
151
- chainInfo.cosmos.stakeCurrency?.coinMinimalDenom
140
+ chainInfo.stakeCurrency?.coinMinimalDenom
152
141
  );
153
142
  }
154
143
 
155
144
  @computed
156
145
  get unstakables(): IObservableQueryBalanceImpl[] {
157
- const chainInfo = this.chainGetter.getModularChain(this.chainId);
158
- if (!("cosmos" in chainInfo)) {
159
- return [];
160
- }
146
+ const chainInfo = this.chainGetter.getChain(this.chainId);
161
147
 
162
- const currencies = chainInfo.cosmos.currencies.filter(
148
+ const currencies = chainInfo.currencies.filter(
163
149
  (cur) =>
164
- cur.coinMinimalDenom !==
165
- chainInfo.cosmos.stakeCurrency?.coinMinimalDenom
150
+ cur.coinMinimalDenom !== chainInfo.stakeCurrency?.coinMinimalDenom
166
151
  );
167
152
 
168
153
  const result = [];
@@ -197,9 +182,7 @@ export class ObservableQueryBalancesImplMap {
197
182
  readonly getBalance = computedFn(
198
183
  (currency: AppCurrency): IObservableQueryBalanceImpl | undefined => {
199
184
  const bal = this.balances.find(
200
- (bal) =>
201
- DenomHelper.normalizeDenom(bal.currency.coinMinimalDenom) ===
202
- DenomHelper.normalizeDenom(currency.coinMinimalDenom)
185
+ (bal) => bal.currency.coinMinimalDenom === currency.coinMinimalDenom
203
186
  );
204
187
  if (bal) {
205
188
  return bal;
@@ -16,13 +16,9 @@ export class ObservableChainQuery<
16
16
  chainGetter: ChainGetter,
17
17
  url: string
18
18
  ) {
19
- const modularChainInfo = chainGetter.getModularChain(chainId);
19
+ const chainInfo = chainGetter.getChain(chainId);
20
20
 
21
- super(
22
- sharedContext,
23
- "cosmos" in modularChainInfo ? modularChainInfo.cosmos.rest : "",
24
- url
25
- );
21
+ super(sharedContext, chainInfo.rest, url);
26
22
 
27
23
  this._chainId = chainId;
28
24
  this.chainGetter = chainGetter;
@@ -16,13 +16,9 @@ export class ObservableChainQueryRPC<
16
16
  chainGetter: ChainGetter,
17
17
  url: string
18
18
  ) {
19
- const modularChainInfo = chainGetter.getModularChain(chainId);
19
+ const chainInfo = chainGetter.getChain(chainId);
20
20
 
21
- super(
22
- sharedContext,
23
- "cosmos" in modularChainInfo ? modularChainInfo.cosmos.rpc : "",
24
- url
25
- );
21
+ super(sharedContext, chainInfo.rpc, url);
26
22
 
27
23
  this._chainId = chainId;
28
24
  this.chainGetter = chainGetter;
@@ -47,12 +47,9 @@ export class ObservableQueryCosmosBalancesImplParent extends ObservableChainQuer
47
47
  ) {
48
48
  super.onReceiveResponse(response);
49
49
 
50
- const chainInfo = this.chainGetter.getModularChainInfoImpl(this.chainId);
50
+ const chainInfo = this.chainGetter.getChain(this.chainId);
51
51
  const denoms = response.data.balances.map((coin) => coin.denom);
52
- chainInfo.addUnknownDenoms({
53
- module: "cosmos",
54
- coinMinimalDenoms: denoms,
55
- });
52
+ chainInfo.addUnknownDenoms(...denoms);
56
53
  }
57
54
  }
58
55
 
@@ -86,9 +83,8 @@ export class ObservableQueryCosmosBalancesImpl
86
83
  get currency(): AppCurrency {
87
84
  const denom = this.denomHelper.denom;
88
85
 
89
- return this.chainGetter
90
- .getModularChainInfoImpl(this.chainId)
91
- .forceFindCurrency(denom);
86
+ const chainInfo = this.chainGetter.getChain(this.chainId);
87
+ return chainInfo.forceFindCurrency(denom);
92
88
  }
93
89
 
94
90
  get error(): Readonly<QueryError<unknown>> | undefined {
@@ -31,10 +31,10 @@ export class ObservableChainQuerySpendableBalances extends ObservableChainQuery<
31
31
 
32
32
  const res: CoinPretty[] = [];
33
33
 
34
+ const chainInfo = this.chainGetter.getChain(this.chainId);
35
+
34
36
  for (const bal of this.response.data.balances) {
35
- const currency = this.chainGetter
36
- .getModularChainInfoImpl(this.chainId)
37
- .findCurrency(bal.denom);
37
+ const currency = chainInfo.findCurrency(bal.denom);
38
38
  if (currency) {
39
39
  res.push(new CoinPretty(currency, bal.amount));
40
40
  }
@@ -29,11 +29,8 @@ export class ObservableChainQueryIBCChannel extends ObservableChainQuery<Channel
29
29
  super.onStart();
30
30
 
31
31
  this.disposer = autorun(() => {
32
- if (
33
- this.chainGetter
34
- .getModularChainInfoImpl(this.chainId)
35
- .hasFeature("ibc-go")
36
- ) {
32
+ const chainInfo = this.chainGetter.getChain(this.chainId);
33
+ if (chainInfo.features && chainInfo.features.includes("ibc-go")) {
37
34
  this.setUrl(
38
35
  `/ibc/core/channel/v1/channels/${this.channelId}/ports/${this.portId}`
39
36
  );
@@ -29,8 +29,8 @@ export class ObservableChainQueryClientState extends ObservableChainQuery<Client
29
29
  super.onStart();
30
30
 
31
31
  this.disposer = autorun(() => {
32
- const chainInfo = this.chainGetter.getModularChainInfoImpl(this.chainId);
33
- if (chainInfo.hasFeature("ibc-go")) {
32
+ const chainInfo = this.chainGetter.getChain(this.chainId);
33
+ if (chainInfo.features && chainInfo.features.includes("ibc-go")) {
34
34
  this.setUrl(
35
35
  `/ibc/core/channel/v1/channels/${this.channelId}/ports/${this.portId}/client_state`
36
36
  );
@@ -30,13 +30,13 @@ export class ObservableChainQueryDenomTrace extends ObservableChainQuery<
30
30
  super.onStart();
31
31
 
32
32
  this.disposer = autorun(() => {
33
- const modularChainInfoImpl = this.chainGetter.getModularChainInfoImpl(
34
- this.chainId
35
- );
36
- if (modularChainInfoImpl.hasFeature("ibc-v2")) {
37
- this.setUrl(`/ibc/apps/transfer/v1/denoms/${this.hash}`);
38
- } else if (modularChainInfoImpl.hasFeature("ibc-go")) {
39
- this.setUrl(`/ibc/apps/transfer/v1/denom_traces/${this.hash}`);
33
+ const chainInfo = this.chainGetter.getChain(this.chainId);
34
+ if (chainInfo.features) {
35
+ if (chainInfo.features.includes("ibc-v2")) {
36
+ this.setUrl(`/ibc/apps/transfer/v1/denoms/${this.hash}`);
37
+ } else if (chainInfo.features.includes("ibc-go")) {
38
+ this.setUrl(`/ibc/apps/transfer/v1/denom_traces/${this.hash}`);
39
+ }
40
40
  }
41
41
  });
42
42
  }
@@ -32,16 +32,13 @@ export class ObservableQueryBabylonBtcDelegationRewardInner extends ObservableCh
32
32
  // If bech32 address is empty, it will always fail, so don't need to fetch it.
33
33
  return (
34
34
  this.bech32Address.length > 0 ||
35
- this.chainGetter.getModularChainInfoImpl(this.chainId).stakeCurrency !=
36
- null
35
+ this.chainGetter.getChain(this.chainId).stakeCurrency != null
37
36
  );
38
37
  }
39
38
 
40
39
  @computed
41
40
  get claimable(): CoinPretty | undefined {
42
- const stakeCurrency = this.chainGetter.getModularChainInfoImpl(
43
- this.chainId
44
- ).stakeCurrency;
41
+ const stakeCurrency = this.chainGetter.getChain(this.chainId).stakeCurrency;
45
42
 
46
43
  if (!stakeCurrency) {
47
44
  return;
@@ -33,16 +33,13 @@ export class ObservableQueryDelegationsInner extends ObservableChainQuery<Delega
33
33
  // If bech32 address is empty, it will always fail, so don't need to fetch it.
34
34
  return (
35
35
  this.bech32Address.length > 0 ||
36
- this.chainGetter.getModularChainInfoImpl(this.chainId).stakeCurrency !=
37
- null
36
+ this.chainGetter.getChain(this.chainId).stakeCurrency != null
38
37
  );
39
38
  }
40
39
 
41
40
  @computed
42
41
  get total(): CoinPretty | undefined {
43
- const stakeCurrency = this.chainGetter.getModularChainInfoImpl(
44
- this.chainId
45
- ).stakeCurrency;
42
+ const stakeCurrency = this.chainGetter.getChain(this.chainId).stakeCurrency;
46
43
 
47
44
  if (!stakeCurrency) {
48
45
  return;
@@ -72,9 +69,7 @@ export class ObservableQueryDelegationsInner extends ObservableChainQuery<Delega
72
69
  return [];
73
70
  }
74
71
 
75
- const stakeCurrency = this.chainGetter.getModularChainInfoImpl(
76
- this.chainId
77
- ).stakeCurrency;
72
+ const stakeCurrency = this.chainGetter.getChain(this.chainId).stakeCurrency;
78
73
 
79
74
  if (!stakeCurrency) {
80
75
  return [];
@@ -113,7 +108,7 @@ export class ObservableQueryDelegationsInner extends ObservableChainQuery<Delega
113
108
  (validatorAddress: string): CoinPretty | undefined => {
114
109
  const delegations = this.delegations;
115
110
 
116
- const stakeCurrency = this.chainGetter.getModularChainInfoImpl(
111
+ const stakeCurrency = this.chainGetter.getChain(
117
112
  this.chainId
118
113
  ).stakeCurrency;
119
114
 
@@ -34,16 +34,15 @@ export class ObservableQueryInitiaDelegationsInner extends ObservableChainQuery<
34
34
  // If bech32 address is empty, it will always fail, so don't need to fetch it.
35
35
  return (
36
36
  this.bech32Address.length > 0 ||
37
- this.chainGetter.getModularChainInfoImpl(this.chainId).stakeCurrency !=
38
- null
37
+ this.chainGetter.getChain(this.chainId).stakeCurrency != null
39
38
  );
40
39
  }
41
40
 
42
41
  // a function to extract amount from delegation balance
43
42
  // For Initia chain, the balance is an array of Coin
44
43
  protected getAmountFromBalanceArray(balance: Coin[]): string {
45
- const stakeDenom = this.chainGetter.getModularChainInfoImpl(this.chainId)
46
- .stakeCurrency?.coinMinimalDenom;
44
+ const stakeDenom = this.chainGetter.getChain(this.chainId).stakeCurrency
45
+ ?.coinMinimalDenom;
47
46
 
48
47
  if (!stakeDenom) {
49
48
  return "0";
@@ -55,9 +54,7 @@ export class ObservableQueryInitiaDelegationsInner extends ObservableChainQuery<
55
54
 
56
55
  @computed
57
56
  get total(): CoinPretty | undefined {
58
- const stakeCurrency = this.chainGetter.getModularChainInfoImpl(
59
- this.chainId
60
- ).stakeCurrency;
57
+ const stakeCurrency = this.chainGetter.getChain(this.chainId).stakeCurrency;
61
58
 
62
59
  if (!stakeCurrency) {
63
60
  return;
@@ -89,9 +86,7 @@ export class ObservableQueryInitiaDelegationsInner extends ObservableChainQuery<
89
86
  return [];
90
87
  }
91
88
 
92
- const stakeCurrency = this.chainGetter.getModularChainInfoImpl(
93
- this.chainId
94
- ).stakeCurrency;
89
+ const stakeCurrency = this.chainGetter.getChain(this.chainId).stakeCurrency;
95
90
 
96
91
  if (!stakeCurrency) {
97
92
  return [];
@@ -121,9 +116,7 @@ export class ObservableQueryInitiaDelegationsInner extends ObservableChainQuery<
121
116
  return [];
122
117
  }
123
118
 
124
- const stakeCurrency = this.chainGetter.getModularChainInfoImpl(
125
- this.chainId
126
- ).stakeCurrency;
119
+ const stakeCurrency = this.chainGetter.getChain(this.chainId).stakeCurrency;
127
120
 
128
121
  return this.response.data.delegation_responses
129
122
  .filter((del) => {
@@ -145,7 +138,7 @@ export class ObservableQueryInitiaDelegationsInner extends ObservableChainQuery<
145
138
  (validatorAddress: string): CoinPretty | undefined => {
146
139
  const delegations = this.delegations;
147
140
 
148
- const stakeCurrency = this.chainGetter.getModularChainInfoImpl(
141
+ const stakeCurrency = this.chainGetter.getChain(
149
142
  this.chainId
150
143
  ).stakeCurrency;
151
144
 
@@ -30,7 +30,7 @@ export class ObservableQueryInitiaUnbondingDelegationsInner extends ObservableCh
30
30
  }
31
31
 
32
32
  protected override canFetch(): boolean {
33
- if (!this.chainGetter.getModularChainInfoImpl(this.chainId).stakeCurrency) {
33
+ if (!this.chainGetter.getChain(this.chainId).stakeCurrency) {
34
34
  return false;
35
35
  }
36
36
  // If bech32 address is empty, it will always fail, so don't need to fetch it.
@@ -40,8 +40,8 @@ export class ObservableQueryInitiaUnbondingDelegationsInner extends ObservableCh
40
40
  // a function to extract amount from unbonding balance
41
41
  // For Initia chain, the balance is an array of Coin
42
42
  protected getAmountFromBalanceArray(balance: Coin[]): string {
43
- const stakeDenom = this.chainGetter.getModularChainInfoImpl(this.chainId)
44
- .stakeCurrency?.coinMinimalDenom;
43
+ const stakeDenom = this.chainGetter.getChain(this.chainId).stakeCurrency
44
+ ?.coinMinimalDenom;
45
45
 
46
46
  if (!stakeDenom) {
47
47
  return "0";
@@ -53,9 +53,7 @@ export class ObservableQueryInitiaUnbondingDelegationsInner extends ObservableCh
53
53
 
54
54
  @computed
55
55
  get total(): CoinPretty | undefined {
56
- const stakeCurrency = this.chainGetter.getModularChainInfoImpl(
57
- this.chainId
58
- ).stakeCurrency;
56
+ const stakeCurrency = this.chainGetter.getChain(this.chainId).stakeCurrency;
59
57
 
60
58
  if (!stakeCurrency) {
61
59
  return;
@@ -90,9 +88,7 @@ export class ObservableQueryInitiaUnbondingDelegationsInner extends ObservableCh
90
88
  }[] {
91
89
  const unbondings = this.unbondings;
92
90
 
93
- const stakeCurrency = this.chainGetter.getModularChainInfoImpl(
94
- this.chainId
95
- ).stakeCurrency;
91
+ const stakeCurrency = this.chainGetter.getChain(this.chainId).stakeCurrency;
96
92
 
97
93
  if (!stakeCurrency) {
98
94
  return [];
@@ -130,9 +126,7 @@ export class ObservableQueryInitiaUnbondingDelegationsInner extends ObservableCh
130
126
  return [];
131
127
  }
132
128
 
133
- const stakeCurrency = this.chainGetter.getModularChainInfoImpl(
134
- this.chainId
135
- ).stakeCurrency;
129
+ const stakeCurrency = this.chainGetter.getChain(this.chainId).stakeCurrency;
136
130
 
137
131
  return this.response.data.unbonding_responses.map((unbonding) => {
138
132
  const filtered = unbonding.entries.filter((entry) =>
@@ -42,7 +42,7 @@ export class ObservableQueryInitiaValidatorsInner extends ObservableChainQuery<I
42
42
  }
43
43
 
44
44
  protected override canFetch(): boolean {
45
- if (!this.chainGetter.getModularChainInfoImpl(this.chainId).stakeCurrency) {
45
+ if (!this.chainGetter.getChain(this.chainId).stakeCurrency) {
46
46
  return false;
47
47
  }
48
48
  return super.canFetch();
@@ -54,9 +54,7 @@ export class ObservableQueryInitiaValidatorsInner extends ObservableChainQuery<I
54
54
  return [];
55
55
  }
56
56
 
57
- const stakeCurrency = this.chainGetter.getModularChainInfoImpl(
58
- this.chainId
59
- ).stakeCurrency;
57
+ const stakeCurrency = this.chainGetter.getChain(this.chainId).stakeCurrency;
60
58
 
61
59
  if (!stakeCurrency) {
62
60
  return [];
@@ -150,7 +148,7 @@ export class ObservableQueryInitiaValidatorsInner extends ObservableChainQuery<I
150
148
  return;
151
149
  }
152
150
 
153
- const chainInfo = this.chainGetter.getModularChainInfoImpl(this.chainId);
151
+ const chainInfo = this.chainGetter.getChain(this.chainId);
154
152
  const stakeCurrency = chainInfo.stakeCurrency;
155
153
 
156
154
  if (!stakeCurrency) {
@@ -23,7 +23,7 @@ export class ObservableQueryStakingPool extends ObservableChainQuery<StakingPool
23
23
  }
24
24
 
25
25
  protected override canFetch(): boolean {
26
- if (!this.chainGetter.getModularChainInfoImpl(this.chainId).stakeCurrency) {
26
+ if (!this.chainGetter.getChain(this.chainId).stakeCurrency) {
27
27
  return false;
28
28
  }
29
29
  return super.canFetch();
@@ -31,7 +31,7 @@ export class ObservableQueryStakingPool extends ObservableChainQuery<StakingPool
31
31
 
32
32
  @computed
33
33
  get notBondedTokens(): CoinPretty | undefined {
34
- const chainInfo = this.chainGetter.getModularChainInfoImpl(this.chainId);
34
+ const chainInfo = this.chainGetter.getChain(this.chainId);
35
35
 
36
36
  if (!chainInfo.stakeCurrency) {
37
37
  return;
@@ -52,7 +52,7 @@ export class ObservableQueryStakingPool extends ObservableChainQuery<StakingPool
52
52
 
53
53
  @computed
54
54
  get bondedTokens(): CoinPretty | undefined {
55
- const chainInfo = this.chainGetter.getModularChainInfoImpl(this.chainId);
55
+ const chainInfo = this.chainGetter.getChain(this.chainId);
56
56
 
57
57
  if (!chainInfo.stakeCurrency) {
58
58
  return;
@@ -35,7 +35,7 @@ export class ObservableQueryRewardsInner extends ObservableChainQuery<Rewards> {
35
35
  }
36
36
 
37
37
  protected override canFetch(): boolean {
38
- if (!this.chainGetter.getModularChainInfoImpl(this.chainId).stakeCurrency) {
38
+ if (!this.chainGetter.getChain(this.chainId).stakeCurrency) {
39
39
  return false;
40
40
  }
41
41
  // If bech32 address is empty, it will always fail, so don't need to fetch it.
@@ -44,7 +44,7 @@ export class ObservableQueryRewardsInner extends ObservableChainQuery<Rewards> {
44
44
 
45
45
  @computed
46
46
  get rewards(): CoinPretty[] {
47
- const chainInfo = this.chainGetter.getModularChainInfoImpl(this.chainId);
47
+ const chainInfo = this.chainGetter.getChain(this.chainId);
48
48
 
49
49
  if (!this.response || !this.response.data.rewards) {
50
50
  return [];
@@ -75,7 +75,7 @@ export class ObservableQueryRewardsInner extends ObservableChainQuery<Rewards> {
75
75
 
76
76
  readonly getRewardsOf = computedFn(
77
77
  (validatorAddress: string): CoinPretty[] => {
78
- const chainInfo = this.chainGetter.getModularChainInfoImpl(this.chainId);
78
+ const chainInfo = this.chainGetter.getChain(this.chainId);
79
79
 
80
80
  const rewards = this.response?.data.rewards?.find((r) => {
81
81
  return r.validator_address === validatorAddress;
@@ -109,7 +109,7 @@ export class ObservableQueryRewardsInner extends ObservableChainQuery<Rewards> {
109
109
 
110
110
  @computed
111
111
  get stakableReward(): CoinPretty | undefined {
112
- const chainInfo = this.chainGetter.getModularChainInfoImpl(this.chainId);
112
+ const chainInfo = this.chainGetter.getChain(this.chainId);
113
113
 
114
114
  if (!chainInfo.stakeCurrency) {
115
115
  return;
@@ -127,7 +127,7 @@ export class ObservableQueryRewardsInner extends ObservableChainQuery<Rewards> {
127
127
 
128
128
  readonly getStakableRewardOf = computedFn(
129
129
  (validatorAddress: string): CoinPretty | undefined => {
130
- const chainInfo = this.chainGetter.getModularChainInfoImpl(this.chainId);
130
+ const chainInfo = this.chainGetter.getChain(this.chainId);
131
131
 
132
132
  if (!chainInfo.stakeCurrency) {
133
133
  return;
@@ -147,7 +147,7 @@ export class ObservableQueryRewardsInner extends ObservableChainQuery<Rewards> {
147
147
 
148
148
  @computed
149
149
  get unstakableRewards(): CoinPretty[] {
150
- const chainInfo = this.chainGetter.getModularChainInfoImpl(this.chainId);
150
+ const chainInfo = this.chainGetter.getChain(this.chainId);
151
151
 
152
152
  return this.rewards.filter((r) => {
153
153
  return (
@@ -162,7 +162,7 @@ export class ObservableQueryRewardsInner extends ObservableChainQuery<Rewards> {
162
162
  return this.getRewardsOf(validatorAddress).filter((r) => {
163
163
  return (
164
164
  r.currency.coinMinimalDenom !==
165
- this.chainGetter.getModularChainInfoImpl(this.chainId).stakeCurrency
165
+ this.chainGetter.getChain(this.chainId).stakeCurrency
166
166
  ?.coinMinimalDenom
167
167
  );
168
168
  });
@@ -202,7 +202,7 @@ export class ObservableQueryRewardsInner extends ObservableChainQuery<Rewards> {
202
202
  return [];
203
203
  }
204
204
 
205
- const chainInfo = this.chainGetter.getModularChainInfoImpl(this.chainId);
205
+ const chainInfo = this.chainGetter.getChain(this.chainId);
206
206
 
207
207
  if (!chainInfo.stakeCurrency) {
208
208
  return [];
@@ -250,12 +250,9 @@ export class ObservableQueryRewardsInner extends ObservableChainQuery<Rewards> {
250
250
  ) {
251
251
  super.onReceiveResponse(response);
252
252
 
253
- const chainInfo = this.chainGetter.getModularChainInfoImpl(this.chainId);
253
+ const chainInfo = this.chainGetter.getChain(this.chainId);
254
254
  const denoms = response.data.total.map((coin) => coin.denom);
255
- chainInfo.addUnknownDenoms({
256
- module: "cosmos",
257
- coinMinimalDenoms: denoms,
258
- });
255
+ chainInfo.addUnknownDenoms(...denoms);
259
256
  }
260
257
  }
261
258
 
@@ -29,7 +29,7 @@ export class ObservableQueryUnbondingDelegationsInner extends ObservableChainQue
29
29
  }
30
30
 
31
31
  protected override canFetch(): boolean {
32
- if (!this.chainGetter.getModularChainInfoImpl(this.chainId).stakeCurrency) {
32
+ if (!this.chainGetter.getChain(this.chainId).stakeCurrency) {
33
33
  return false;
34
34
  }
35
35
  // If bech32 address is empty, it will always fail, so don't need to fetch it.
@@ -38,9 +38,7 @@ export class ObservableQueryUnbondingDelegationsInner extends ObservableChainQue
38
38
 
39
39
  @computed
40
40
  get total(): CoinPretty | undefined {
41
- const stakeCurrency = this.chainGetter.getModularChainInfoImpl(
42
- this.chainId
43
- ).stakeCurrency;
41
+ const stakeCurrency = this.chainGetter.getChain(this.chainId).stakeCurrency;
44
42
 
45
43
  if (!stakeCurrency) {
46
44
  return;
@@ -74,9 +72,7 @@ export class ObservableQueryUnbondingDelegationsInner extends ObservableChainQue
74
72
  }[] {
75
73
  const unbondings = this.unbondings;
76
74
 
77
- const stakeCurrency = this.chainGetter.getModularChainInfoImpl(
78
- this.chainId
79
- ).stakeCurrency;
75
+ const stakeCurrency = this.chainGetter.getChain(this.chainId).stakeCurrency;
80
76
 
81
77
  if (!stakeCurrency) {
82
78
  return [];