@keplr-wallet/stores 0.12.300-rc.0 → 0.12.300
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/build/account/babylon.js +7 -19
- package/build/account/babylon.js.map +1 -1
- package/build/account/base.js +5 -7
- package/build/account/base.js.map +1 -1
- package/build/account/cosmos.js +54 -94
- package/build/account/cosmos.js.map +1 -1
- package/build/account/cosmwasm.js +2 -10
- package/build/account/cosmwasm.js.map +1 -1
- package/build/account/secret.js +2 -10
- package/build/account/secret.js.map +1 -1
- package/build/account/store.js +4 -4
- package/build/account/store.js.map +1 -1
- package/build/chain/base.d.ts +1 -122
- package/build/chain/base.js +40 -601
- package/build/chain/base.js.map +1 -1
- package/build/chain/types.d.ts +1 -27
- package/build/common/utils/index.d.ts +2 -2
- package/build/common/utils/index.js.map +1 -1
- package/build/lsm/currency-registrar.js +7 -7
- package/build/lsm/currency-registrar.js.map +1 -1
- package/build/query/balances.js +11 -24
- package/build/query/balances.js.map +1 -1
- package/build/query/chain-query.js +2 -2
- package/build/query/chain-query.js.map +1 -1
- package/build/query/chain-rpc-query.js +2 -2
- package/build/query/chain-rpc-query.js.map +1 -1
- package/build/query/cosmos/balance/balances.js +4 -8
- package/build/query/cosmos/balance/balances.js.map +1 -1
- package/build/query/cosmos/balance/spendable.js +2 -3
- package/build/query/cosmos/balance/spendable.js.map +1 -1
- package/build/query/cosmos/ibc/channel.js +2 -3
- package/build/query/cosmos/ibc/channel.js.map +1 -1
- package/build/query/cosmos/ibc/client-state.js +2 -2
- package/build/query/cosmos/ibc/client-state.js.map +1 -1
- package/build/query/cosmos/ibc/denom-trace.js +8 -6
- package/build/query/cosmos/ibc/denom-trace.js.map +1 -1
- package/build/query/cosmos/staking/babylon-btc-delegation-reward.js +2 -3
- package/build/query/cosmos/staking/babylon-btc-delegation-reward.js.map +1 -1
- package/build/query/cosmos/staking/delegations.js +4 -5
- package/build/query/cosmos/staking/delegations.js.map +1 -1
- package/build/query/cosmos/staking/initia-delegations.js +6 -8
- package/build/query/cosmos/staking/initia-delegations.js.map +1 -1
- package/build/query/cosmos/staking/initia-unbonding-delegations.js +5 -6
- package/build/query/cosmos/staking/initia-unbonding-delegations.js.map +1 -1
- package/build/query/cosmos/staking/initia-validators.js +3 -3
- package/build/query/cosmos/staking/initia-validators.js.map +1 -1
- package/build/query/cosmos/staking/pool.js +3 -3
- package/build/query/cosmos/staking/pool.js.map +1 -1
- package/build/query/cosmos/staking/rewards.js +10 -13
- package/build/query/cosmos/staking/rewards.js.map +1 -1
- package/build/query/cosmos/staking/unbonding-delegations.js +3 -3
- package/build/query/cosmos/staking/unbonding-delegations.js.map +1 -1
- package/build/query/cosmos/staking/validators.js +3 -2
- package/build/query/cosmos/staking/validators.js.map +1 -1
- package/build/query/cosmwasm/contract-query.js +2 -2
- package/build/query/cosmwasm/contract-query.js.map +1 -1
- package/build/query/cosmwasm/cw20-balance.js +4 -7
- package/build/query/cosmwasm/cw20-balance.js.map +1 -1
- package/build/query/cosmwasm/neutron/staking-rewards.js +8 -10
- package/build/query/cosmwasm/neutron/staking-rewards.js.map +1 -1
- package/build/query/noble/swap/simulate-swap.js +1 -1
- package/build/query/noble/swap/simulate-swap.js.map +1 -1
- package/build/query/osmosis/txfees/fee-tokens/index.js +4 -8
- package/build/query/osmosis/txfees/fee-tokens/index.js.map +1 -1
- package/build/query/secret-wasm/secret20-balance.js +5 -7
- package/build/query/secret-wasm/secret20-balance.js.map +1 -1
- package/build/token-factory/currency-registrar.js +1 -1
- package/build/token-factory/currency-registrar.js.map +1 -1
- package/package.json +11 -11
- package/src/account/babylon.ts +7 -21
- package/src/account/base.ts +5 -7
- package/src/account/cosmos.ts +66 -121
- package/src/account/cosmwasm.ts +3 -12
- package/src/account/secret.ts +3 -12
- package/src/account/store.ts +4 -4
- package/src/chain/base.ts +34 -816
- package/src/chain/types.ts +1 -27
- package/src/common/utils/index.ts +2 -2
- package/src/lsm/currency-registrar.ts +7 -9
- package/src/query/balances.ts +13 -30
- package/src/query/chain-query.ts +2 -6
- package/src/query/chain-rpc-query.ts +2 -6
- package/src/query/cosmos/balance/balances.ts +4 -8
- package/src/query/cosmos/balance/spendable.ts +3 -3
- package/src/query/cosmos/ibc/channel.ts +2 -5
- package/src/query/cosmos/ibc/client-state.ts +2 -2
- package/src/query/cosmos/ibc/denom-trace.ts +7 -7
- package/src/query/cosmos/staking/babylon-btc-delegation-reward.ts +2 -5
- package/src/query/cosmos/staking/delegations.ts +4 -9
- package/src/query/cosmos/staking/initia-delegations.ts +7 -14
- package/src/query/cosmos/staking/initia-unbonding-delegations.ts +6 -12
- package/src/query/cosmos/staking/initia-validators.ts +3 -5
- package/src/query/cosmos/staking/pool.ts +3 -3
- package/src/query/cosmos/staking/rewards.ts +10 -13
- package/src/query/cosmos/staking/unbonding-delegations.ts +3 -7
- package/src/query/cosmos/staking/validators.ts +3 -4
- package/src/query/cosmwasm/contract-query.ts +2 -4
- package/src/query/cosmwasm/cw20-balance.ts +5 -8
- package/src/query/cosmwasm/neutron/staking-rewards.ts +8 -10
- package/src/query/noble/swap/simulate-swap.ts +1 -1
- package/src/query/osmosis/txfees/fee-tokens/index.ts +4 -8
- package/src/query/secret-wasm/secret20-balance.ts +5 -7
- package/src/token-factory/currency-registrar.ts +1 -1
package/src/chain/types.ts
CHANGED
|
@@ -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 {
|
|
4
|
+
import { IChainInfoImpl } from "../../chain";
|
|
5
5
|
|
|
6
6
|
export class StoreUtils {
|
|
7
7
|
public static toCoinPretties(
|
|
8
|
-
chainInfo:
|
|
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.
|
|
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.
|
|
82
|
-
if (!
|
|
81
|
+
const chainInfo = this.chainStore.getChain(chainId);
|
|
82
|
+
if (!chainInfo.stakeCurrency) {
|
|
83
83
|
return;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
if (
|
|
87
|
-
!chainInfo.
|
|
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.
|
|
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.
|
|
199
|
+
coinDecimals: chainInfo.stakeCurrency.coinDecimals,
|
|
202
200
|
coinImageUrl: validator.thumbnail || undefined,
|
|
203
201
|
},
|
|
204
202
|
done: !validator.isFetching,
|
package/src/query/balances.ts
CHANGED
|
@@ -74,16 +74,12 @@ export class ObservableQueryBalancesImplMap {
|
|
|
74
74
|
|
|
75
75
|
@computed
|
|
76
76
|
get stakable(): IObservableQueryBalanceImpl | undefined {
|
|
77
|
-
const
|
|
78
|
-
|
|
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.
|
|
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
|
|
90
|
+
const chainInfo = this.chainGetter.getChain(this.chainId);
|
|
95
91
|
|
|
96
|
-
const
|
|
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.
|
|
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.
|
|
140
|
+
chainInfo.stakeCurrency?.coinMinimalDenom
|
|
152
141
|
);
|
|
153
142
|
}
|
|
154
143
|
|
|
155
144
|
@computed
|
|
156
145
|
get unstakables(): IObservableQueryBalanceImpl[] {
|
|
157
|
-
const chainInfo = this.chainGetter.
|
|
158
|
-
if (!("cosmos" in chainInfo)) {
|
|
159
|
-
return [];
|
|
160
|
-
}
|
|
146
|
+
const chainInfo = this.chainGetter.getChain(this.chainId);
|
|
161
147
|
|
|
162
|
-
const currencies = chainInfo.
|
|
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;
|
package/src/query/chain-query.ts
CHANGED
|
@@ -16,13 +16,9 @@ export class ObservableChainQuery<
|
|
|
16
16
|
chainGetter: ChainGetter,
|
|
17
17
|
url: string
|
|
18
18
|
) {
|
|
19
|
-
const
|
|
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
|
|
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.
|
|
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
|
-
|
|
90
|
-
|
|
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 =
|
|
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
|
-
|
|
33
|
-
|
|
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.
|
|
33
|
-
if (chainInfo.
|
|
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
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
46
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
44
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
78
|
-
this.chainId
|
|
79
|
-
).stakeCurrency;
|
|
75
|
+
const stakeCurrency = this.chainGetter.getChain(this.chainId).stakeCurrency;
|
|
80
76
|
|
|
81
77
|
if (!stakeCurrency) {
|
|
82
78
|
return [];
|