@keplr-wallet/stores 0.12.238-rc.0 → 0.12.239-rc.0
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.d.ts +24 -0
- package/build/account/babylon.js +160 -0
- package/build/account/babylon.js.map +1 -0
- package/build/account/cosmos.js +114 -42
- package/build/account/cosmos.js.map +1 -1
- package/build/account/index.d.ts +1 -0
- package/build/account/index.js +1 -0
- package/build/account/index.js.map +1 -1
- package/build/query/babylon/epoching/index.d.ts +1 -0
- package/build/query/babylon/epoching/index.js +18 -0
- package/build/query/babylon/epoching/index.js.map +1 -0
- package/build/query/babylon/epoching/last-epoch-msgs.d.ts +12 -0
- package/build/query/babylon/epoching/last-epoch-msgs.js +39 -0
- package/build/query/babylon/epoching/last-epoch-msgs.js.map +1 -0
- package/build/query/babylon/epoching/types.d.ts +13 -0
- package/build/query/babylon/epoching/types.js +3 -0
- package/build/query/babylon/epoching/types.js.map +1 -0
- package/build/query/babylon/index.d.ts +2 -0
- package/build/query/babylon/index.js +19 -0
- package/build/query/babylon/index.js.map +1 -0
- package/build/query/babylon/queries.d.ts +15 -0
- package/build/query/babylon/queries.js +20 -0
- package/build/query/babylon/queries.js.map +1 -0
- package/build/query/cosmos/queries.d.ts +2 -0
- package/build/query/cosmos/queries.js +2 -0
- package/build/query/cosmos/queries.js.map +1 -1
- package/build/query/cosmos/staking/initia-validators.d.ts +24 -0
- package/build/query/cosmos/staking/initia-validators.js +126 -0
- package/build/query/cosmos/staking/initia-validators.js.map +1 -0
- package/build/query/cosmos/staking/pool.js +10 -2
- package/build/query/cosmos/staking/pool.js.map +1 -1
- package/build/query/cosmos/staking/types.d.ts +15 -2
- package/build/query/cosmos/staking/types.js.map +1 -1
- package/build/query/index.d.ts +1 -0
- package/build/query/index.js +1 -0
- package/build/query/index.js.map +1 -1
- package/package.json +16 -16
- package/src/account/babylon.ts +235 -0
- package/src/account/cosmos.ts +111 -42
- package/src/account/index.ts +1 -0
- package/src/query/babylon/epoching/index.ts +1 -0
- package/src/query/babylon/epoching/last-epoch-msgs.ts +55 -0
- package/src/query/babylon/epoching/types.ts +14 -0
- package/src/query/babylon/index.ts +2 -0
- package/src/query/babylon/queries.ts +51 -0
- package/src/query/cosmos/queries.ts +7 -0
- package/src/query/cosmos/staking/initia-validators.ts +184 -0
- package/src/query/cosmos/staking/pool.ts +14 -8
- package/src/query/cosmos/staking/types.ts +12 -2
- package/src/query/index.ts +1 -0
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { AccountSetBase, AccountSetBaseSuper } from "./base";
|
|
2
|
+
import {
|
|
3
|
+
QueriesSetBase,
|
|
4
|
+
IQueriesStore,
|
|
5
|
+
CosmosQueries,
|
|
6
|
+
BabylonQueries,
|
|
7
|
+
} from "../query";
|
|
8
|
+
import { ChainGetter } from "../chain";
|
|
9
|
+
import { DeepReadonly } from "utility-types";
|
|
10
|
+
import { CosmosAccount } from "./cosmos";
|
|
11
|
+
import { Dec, DecUtils } from "@keplr-wallet/unit";
|
|
12
|
+
import {
|
|
13
|
+
MsgWrappedBeginRedelegate,
|
|
14
|
+
MsgWrappedDelegate,
|
|
15
|
+
MsgWrappedUndelegate,
|
|
16
|
+
} from "@keplr-wallet/proto-types/babylon/epoching/v1/tx";
|
|
17
|
+
import { Bech32Address } from "@keplr-wallet/cosmos";
|
|
18
|
+
import {} from "../query";
|
|
19
|
+
|
|
20
|
+
export interface BabylonAccount {
|
|
21
|
+
babylon: BabylonAccountImpl;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const BabylonAccount = {
|
|
25
|
+
use(options: {
|
|
26
|
+
queriesStore: IQueriesStore<CosmosQueries & BabylonQueries>;
|
|
27
|
+
}): (
|
|
28
|
+
base: AccountSetBaseSuper & CosmosAccount,
|
|
29
|
+
chainGetter: ChainGetter,
|
|
30
|
+
chainId: string
|
|
31
|
+
) => BabylonAccount {
|
|
32
|
+
return (base, chainGetter, chainId) => {
|
|
33
|
+
return {
|
|
34
|
+
babylon: new BabylonAccountImpl(
|
|
35
|
+
base,
|
|
36
|
+
chainGetter,
|
|
37
|
+
chainId,
|
|
38
|
+
options.queriesStore
|
|
39
|
+
),
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export class BabylonAccountImpl {
|
|
46
|
+
constructor(
|
|
47
|
+
protected readonly base: AccountSetBase & CosmosAccount,
|
|
48
|
+
protected readonly chainGetter: ChainGetter,
|
|
49
|
+
protected readonly chainId: string,
|
|
50
|
+
protected readonly queriesStore: IQueriesStore<
|
|
51
|
+
CosmosQueries & BabylonQueries
|
|
52
|
+
>
|
|
53
|
+
) {}
|
|
54
|
+
|
|
55
|
+
makeDelegateTx(amount: string, validatorAddress: string) {
|
|
56
|
+
Bech32Address.validate(
|
|
57
|
+
validatorAddress,
|
|
58
|
+
this.chainGetter.getChain(this.chainId).bech32Config?.bech32PrefixValAddr
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
const currency = this.chainGetter.getChain(this.chainId).stakeCurrency;
|
|
62
|
+
|
|
63
|
+
if (!currency) {
|
|
64
|
+
throw new Error("Stake currency is null");
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
let dec = new Dec(amount);
|
|
68
|
+
dec = dec.mulTruncate(DecUtils.getPrecisionDec(currency.coinDecimals));
|
|
69
|
+
|
|
70
|
+
const msg = {
|
|
71
|
+
type: "/babylon.epoching.v1.MsgWrappedDelegate",
|
|
72
|
+
value: {
|
|
73
|
+
msg: {
|
|
74
|
+
delegator_address: this.base.bech32Address,
|
|
75
|
+
validator_address: validatorAddress,
|
|
76
|
+
amount: {
|
|
77
|
+
denom: currency.coinMinimalDenom,
|
|
78
|
+
amount: dec.truncate().toString(),
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
return this.base.cosmos.makeTx(
|
|
85
|
+
"delegate",
|
|
86
|
+
{
|
|
87
|
+
aminoMsgs: [msg],
|
|
88
|
+
protoMsgs: [
|
|
89
|
+
{
|
|
90
|
+
typeUrl: msg.type,
|
|
91
|
+
value: MsgWrappedDelegate.encode({
|
|
92
|
+
msg: {
|
|
93
|
+
delegatorAddress: msg.value.msg.delegator_address,
|
|
94
|
+
validatorAddress: msg.value.msg.validator_address,
|
|
95
|
+
amount: msg.value.msg.amount,
|
|
96
|
+
},
|
|
97
|
+
}).finish(),
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
},
|
|
101
|
+
(tx) => {
|
|
102
|
+
if (tx.code == null || tx.code === 0) {
|
|
103
|
+
// After succeeding to delegate, refresh the last epoch message list
|
|
104
|
+
this.queries.babylon.queryLastEpochMsgs.getQuery().fetch();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
makeUndelegateTx(amount: string, validatorAddress: string) {
|
|
111
|
+
Bech32Address.validate(
|
|
112
|
+
validatorAddress,
|
|
113
|
+
this.chainGetter.getChain(this.chainId).bech32Config?.bech32PrefixValAddr
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
const currency = this.chainGetter.getChain(this.chainId).stakeCurrency;
|
|
117
|
+
|
|
118
|
+
if (!currency) {
|
|
119
|
+
throw new Error("Stake currency is null");
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
let dec = new Dec(amount);
|
|
123
|
+
dec = dec.mulTruncate(DecUtils.getPrecisionDec(currency.coinDecimals));
|
|
124
|
+
|
|
125
|
+
const msg = {
|
|
126
|
+
type: "/babylon.epoching.v1.MsgWrappedUndelegate",
|
|
127
|
+
value: {
|
|
128
|
+
msg: {
|
|
129
|
+
delegator_address: this.base.bech32Address,
|
|
130
|
+
validator_address: validatorAddress,
|
|
131
|
+
amount: {
|
|
132
|
+
denom: currency.coinMinimalDenom,
|
|
133
|
+
amount: dec.truncate().toString(),
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
return this.base.cosmos.makeTx(
|
|
140
|
+
"undelegate",
|
|
141
|
+
{
|
|
142
|
+
aminoMsgs: [msg],
|
|
143
|
+
protoMsgs: [
|
|
144
|
+
{
|
|
145
|
+
typeUrl: msg.type,
|
|
146
|
+
value: MsgWrappedUndelegate.encode({
|
|
147
|
+
msg: {
|
|
148
|
+
delegatorAddress: msg.value.msg.delegator_address,
|
|
149
|
+
validatorAddress: msg.value.msg.validator_address,
|
|
150
|
+
amount: msg.value.msg.amount,
|
|
151
|
+
},
|
|
152
|
+
}).finish(),
|
|
153
|
+
},
|
|
154
|
+
],
|
|
155
|
+
},
|
|
156
|
+
(tx) => {
|
|
157
|
+
if (tx.code == null || tx.code === 0) {
|
|
158
|
+
// After succeeding to undelegate, refresh the last epoch message list
|
|
159
|
+
this.queries.babylon.queryLastEpochMsgs.getQuery().fetch();
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
makeBeginRedelegateTx(
|
|
166
|
+
amount: string,
|
|
167
|
+
srcValidatorAddress: string,
|
|
168
|
+
dstValidatorAddress: string
|
|
169
|
+
) {
|
|
170
|
+
Bech32Address.validate(
|
|
171
|
+
srcValidatorAddress,
|
|
172
|
+
this.chainGetter.getChain(this.chainId).bech32Config?.bech32PrefixValAddr
|
|
173
|
+
);
|
|
174
|
+
Bech32Address.validate(
|
|
175
|
+
dstValidatorAddress,
|
|
176
|
+
this.chainGetter.getChain(this.chainId).bech32Config?.bech32PrefixValAddr
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
const currency = this.chainGetter.getChain(this.chainId).stakeCurrency;
|
|
180
|
+
|
|
181
|
+
if (!currency) {
|
|
182
|
+
throw new Error("Stake currency is null");
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
let dec = new Dec(amount);
|
|
186
|
+
dec = dec.mulTruncate(DecUtils.getPrecisionDec(currency.coinDecimals));
|
|
187
|
+
|
|
188
|
+
const msg = {
|
|
189
|
+
type: "/babylon.epoching.v1.MsgWrappedBeginRedelegate",
|
|
190
|
+
value: {
|
|
191
|
+
msg: {
|
|
192
|
+
delegator_address: this.base.bech32Address,
|
|
193
|
+
validator_src_address: srcValidatorAddress,
|
|
194
|
+
validator_dst_address: dstValidatorAddress,
|
|
195
|
+
amount: {
|
|
196
|
+
denom: currency.coinMinimalDenom,
|
|
197
|
+
amount: dec.truncate().toString(),
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
return this.base.cosmos.makeTx(
|
|
204
|
+
"redelegate",
|
|
205
|
+
{
|
|
206
|
+
aminoMsgs: [msg],
|
|
207
|
+
protoMsgs: [
|
|
208
|
+
{
|
|
209
|
+
typeUrl: msg.type,
|
|
210
|
+
value: MsgWrappedBeginRedelegate.encode({
|
|
211
|
+
msg: {
|
|
212
|
+
delegatorAddress: msg.value.msg.delegator_address,
|
|
213
|
+
validatorSrcAddress: msg.value.msg.validator_src_address,
|
|
214
|
+
validatorDstAddress: msg.value.msg.validator_dst_address,
|
|
215
|
+
amount: msg.value.msg.amount,
|
|
216
|
+
},
|
|
217
|
+
}).finish(),
|
|
218
|
+
},
|
|
219
|
+
],
|
|
220
|
+
},
|
|
221
|
+
(tx) => {
|
|
222
|
+
if (tx.code == null || tx.code === 0) {
|
|
223
|
+
// After succeeding to redelegate, refresh the last epoch message list
|
|
224
|
+
this.queries.babylon.queryLastEpochMsgs.getQuery().fetch();
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
protected get queries(): DeepReadonly<
|
|
231
|
+
QueriesSetBase & CosmosQueries & BabylonQueries
|
|
232
|
+
> {
|
|
233
|
+
return this.queriesStore.get(this.chainId);
|
|
234
|
+
}
|
|
235
|
+
}
|
package/src/account/cosmos.ts
CHANGED
|
@@ -1602,14 +1602,23 @@ export class CosmosAccountImpl {
|
|
|
1602
1602
|
dec = dec.mulTruncate(DecUtils.getPrecisionDec(currency.coinDecimals));
|
|
1603
1603
|
|
|
1604
1604
|
const msg = {
|
|
1605
|
-
type: this.
|
|
1605
|
+
type: this.chainId.startsWith("interwoven-")
|
|
1606
|
+
? "mstaking/MsgDelegate"
|
|
1607
|
+
: this.msgOpts.delegate.type,
|
|
1606
1608
|
value: {
|
|
1607
1609
|
delegator_address: this.base.bech32Address,
|
|
1608
1610
|
validator_address: validatorAddress,
|
|
1609
|
-
amount:
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1611
|
+
amount: this.chainId.startsWith("interwoven-")
|
|
1612
|
+
? [
|
|
1613
|
+
{
|
|
1614
|
+
denom: currency.coinMinimalDenom,
|
|
1615
|
+
amount: dec.truncate().toString(),
|
|
1616
|
+
},
|
|
1617
|
+
]
|
|
1618
|
+
: {
|
|
1619
|
+
denom: currency.coinMinimalDenom,
|
|
1620
|
+
amount: dec.truncate().toString(),
|
|
1621
|
+
},
|
|
1613
1622
|
},
|
|
1614
1623
|
};
|
|
1615
1624
|
|
|
@@ -1619,11 +1628,15 @@ export class CosmosAccountImpl {
|
|
|
1619
1628
|
aminoMsgs: [msg],
|
|
1620
1629
|
protoMsgs: [
|
|
1621
1630
|
{
|
|
1622
|
-
typeUrl:
|
|
1631
|
+
typeUrl: this.chainId.startsWith("interwoven-")
|
|
1632
|
+
? "/initia.mstaking.v1.MsgDelegate"
|
|
1633
|
+
: "/cosmos.staking.v1beta1.MsgDelegate",
|
|
1623
1634
|
value: MsgDelegate.encode({
|
|
1624
1635
|
delegatorAddress: msg.value.delegator_address,
|
|
1625
1636
|
validatorAddress: msg.value.validator_address,
|
|
1626
|
-
amount: msg.value.amount
|
|
1637
|
+
amount: Array.isArray(msg.value.amount)
|
|
1638
|
+
? msg.value.amount[0]
|
|
1639
|
+
: msg.value.amount,
|
|
1627
1640
|
}).finish(),
|
|
1628
1641
|
},
|
|
1629
1642
|
],
|
|
@@ -1642,12 +1655,21 @@ export class CosmosAccountImpl {
|
|
|
1642
1655
|
(tx) => {
|
|
1643
1656
|
if (tx.code == null || tx.code === 0) {
|
|
1644
1657
|
// After succeeding to delegate, refresh the validators and delegations, rewards.
|
|
1645
|
-
this.
|
|
1646
|
-
.
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1658
|
+
if (this.chainId.startsWith("interwoven-")) {
|
|
1659
|
+
this.queries.cosmos.queryInitiaValidators
|
|
1660
|
+
.getQueryStatus(BondStatus.Bonded)
|
|
1661
|
+
.fetch();
|
|
1662
|
+
this.queries.cosmos.queryInitiaDelegations
|
|
1663
|
+
.getQueryBech32Address(this.base.bech32Address)
|
|
1664
|
+
.fetch();
|
|
1665
|
+
} else {
|
|
1666
|
+
this.queries.cosmos.queryValidators
|
|
1667
|
+
.getQueryStatus(BondStatus.Bonded)
|
|
1668
|
+
.fetch();
|
|
1669
|
+
this.queries.cosmos.queryDelegations
|
|
1670
|
+
.getQueryBech32Address(this.base.bech32Address)
|
|
1671
|
+
.fetch();
|
|
1672
|
+
}
|
|
1651
1673
|
this.queries.cosmos.queryRewards
|
|
1652
1674
|
.getQueryBech32Address(this.base.bech32Address)
|
|
1653
1675
|
.fetch();
|
|
@@ -1752,14 +1774,23 @@ export class CosmosAccountImpl {
|
|
|
1752
1774
|
dec = dec.mulTruncate(DecUtils.getPrecisionDec(currency.coinDecimals));
|
|
1753
1775
|
|
|
1754
1776
|
const msg = {
|
|
1755
|
-
type: this.
|
|
1777
|
+
type: this.chainId.startsWith("interwoven-")
|
|
1778
|
+
? "mstaking/MsgUndelegate"
|
|
1779
|
+
: this.msgOpts.undelegate.type,
|
|
1756
1780
|
value: {
|
|
1757
1781
|
delegator_address: this.base.bech32Address,
|
|
1758
1782
|
validator_address: validatorAddress,
|
|
1759
|
-
amount:
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1783
|
+
amount: this.chainId.startsWith("interwoven-")
|
|
1784
|
+
? [
|
|
1785
|
+
{
|
|
1786
|
+
denom: currency.coinMinimalDenom,
|
|
1787
|
+
amount: dec.truncate().toString(),
|
|
1788
|
+
},
|
|
1789
|
+
]
|
|
1790
|
+
: {
|
|
1791
|
+
denom: currency.coinMinimalDenom,
|
|
1792
|
+
amount: dec.truncate().toString(),
|
|
1793
|
+
},
|
|
1763
1794
|
},
|
|
1764
1795
|
};
|
|
1765
1796
|
|
|
@@ -1769,11 +1800,15 @@ export class CosmosAccountImpl {
|
|
|
1769
1800
|
aminoMsgs: [msg],
|
|
1770
1801
|
protoMsgs: [
|
|
1771
1802
|
{
|
|
1772
|
-
typeUrl:
|
|
1803
|
+
typeUrl: this.chainId.startsWith("interwoven-")
|
|
1804
|
+
? "/initia.mstaking.v1.MsgUndelegate"
|
|
1805
|
+
: "/cosmos.staking.v1beta1.MsgUndelegate",
|
|
1773
1806
|
value: MsgUndelegate.encode({
|
|
1774
1807
|
delegatorAddress: msg.value.delegator_address,
|
|
1775
1808
|
validatorAddress: msg.value.validator_address,
|
|
1776
|
-
amount: msg.value.amount
|
|
1809
|
+
amount: Array.isArray(msg.value.amount)
|
|
1810
|
+
? msg.value.amount[0]
|
|
1811
|
+
: msg.value.amount,
|
|
1777
1812
|
}).finish(),
|
|
1778
1813
|
},
|
|
1779
1814
|
],
|
|
@@ -1792,15 +1827,27 @@ export class CosmosAccountImpl {
|
|
|
1792
1827
|
(tx) => {
|
|
1793
1828
|
if (tx.code == null || tx.code === 0) {
|
|
1794
1829
|
// After succeeding to unbond, refresh the validators and delegations, unbonding delegations, rewards.
|
|
1795
|
-
this.
|
|
1796
|
-
.
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1830
|
+
if (this.chainId.startsWith("interwoven-")) {
|
|
1831
|
+
this.queries.cosmos.queryInitiaValidators
|
|
1832
|
+
.getQueryStatus(BondStatus.Bonded)
|
|
1833
|
+
.fetch();
|
|
1834
|
+
this.queries.cosmos.queryInitiaDelegations
|
|
1835
|
+
.getQueryBech32Address(this.base.bech32Address)
|
|
1836
|
+
.fetch();
|
|
1837
|
+
this.queries.cosmos.queryInitiaUnbondingDelegations
|
|
1838
|
+
.getQueryBech32Address(this.base.bech32Address)
|
|
1839
|
+
.fetch();
|
|
1840
|
+
} else {
|
|
1841
|
+
this.queries.cosmos.queryValidators
|
|
1842
|
+
.getQueryStatus(BondStatus.Bonded)
|
|
1843
|
+
.fetch();
|
|
1844
|
+
this.queries.cosmos.queryDelegations
|
|
1845
|
+
.getQueryBech32Address(this.base.bech32Address)
|
|
1846
|
+
.fetch();
|
|
1847
|
+
this.queries.cosmos.queryUnbondingDelegations
|
|
1848
|
+
.getQueryBech32Address(this.base.bech32Address)
|
|
1849
|
+
.fetch();
|
|
1850
|
+
}
|
|
1804
1851
|
this.queries.cosmos.queryRewards
|
|
1805
1852
|
.getQueryBech32Address(this.base.bech32Address)
|
|
1806
1853
|
.fetch();
|
|
@@ -1833,15 +1880,24 @@ export class CosmosAccountImpl {
|
|
|
1833
1880
|
dec = dec.mulTruncate(DecUtils.getPrecisionDec(currency.coinDecimals));
|
|
1834
1881
|
|
|
1835
1882
|
const msg = {
|
|
1836
|
-
type: this.
|
|
1883
|
+
type: this.chainId.startsWith("interwoven-")
|
|
1884
|
+
? "mstaking/MsgBeginRedelegate"
|
|
1885
|
+
: this.msgOpts.redelegate.type,
|
|
1837
1886
|
value: {
|
|
1838
1887
|
delegator_address: this.base.bech32Address,
|
|
1839
1888
|
validator_src_address: srcValidatorAddress,
|
|
1840
1889
|
validator_dst_address: dstValidatorAddress,
|
|
1841
|
-
amount:
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1890
|
+
amount: this.chainId.startsWith("interwoven-")
|
|
1891
|
+
? [
|
|
1892
|
+
{
|
|
1893
|
+
denom: currency.coinMinimalDenom,
|
|
1894
|
+
amount: dec.truncate().toString(),
|
|
1895
|
+
},
|
|
1896
|
+
]
|
|
1897
|
+
: {
|
|
1898
|
+
denom: currency.coinMinimalDenom,
|
|
1899
|
+
amount: dec.truncate().toString(),
|
|
1900
|
+
},
|
|
1845
1901
|
},
|
|
1846
1902
|
};
|
|
1847
1903
|
|
|
@@ -1851,12 +1907,16 @@ export class CosmosAccountImpl {
|
|
|
1851
1907
|
aminoMsgs: [msg],
|
|
1852
1908
|
protoMsgs: [
|
|
1853
1909
|
{
|
|
1854
|
-
typeUrl:
|
|
1910
|
+
typeUrl: this.chainId.startsWith("interwoven-")
|
|
1911
|
+
? "/initia.mstaking.v1.MsgBeginRedelegate"
|
|
1912
|
+
: "/cosmos.staking.v1beta1.MsgBeginRedelegate",
|
|
1855
1913
|
value: MsgBeginRedelegate.encode({
|
|
1856
1914
|
delegatorAddress: msg.value.delegator_address,
|
|
1857
1915
|
validatorSrcAddress: msg.value.validator_src_address,
|
|
1858
1916
|
validatorDstAddress: msg.value.validator_dst_address,
|
|
1859
|
-
amount: msg.value.amount
|
|
1917
|
+
amount: Array.isArray(msg.value.amount)
|
|
1918
|
+
? msg.value.amount[0]
|
|
1919
|
+
: msg.value.amount,
|
|
1860
1920
|
}).finish(),
|
|
1861
1921
|
},
|
|
1862
1922
|
],
|
|
@@ -1876,12 +1936,21 @@ export class CosmosAccountImpl {
|
|
|
1876
1936
|
(tx) => {
|
|
1877
1937
|
if (tx.code == null || tx.code === 0) {
|
|
1878
1938
|
// After succeeding to redelegate, refresh the validators and delegations, rewards.
|
|
1879
|
-
this.
|
|
1880
|
-
.
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1939
|
+
if (this.chainId.startsWith("interwoven-")) {
|
|
1940
|
+
this.queries.cosmos.queryInitiaValidators
|
|
1941
|
+
.getQueryStatus(BondStatus.Bonded)
|
|
1942
|
+
.fetch();
|
|
1943
|
+
this.queries.cosmos.queryInitiaDelegations
|
|
1944
|
+
.getQueryBech32Address(this.base.bech32Address)
|
|
1945
|
+
.fetch();
|
|
1946
|
+
} else {
|
|
1947
|
+
this.queries.cosmos.queryValidators
|
|
1948
|
+
.getQueryStatus(BondStatus.Bonded)
|
|
1949
|
+
.fetch();
|
|
1950
|
+
this.queries.cosmos.queryDelegations
|
|
1951
|
+
.getQueryBech32Address(this.base.bech32Address)
|
|
1952
|
+
.fetch();
|
|
1953
|
+
}
|
|
1885
1954
|
this.queries.cosmos.queryRewards
|
|
1886
1955
|
.getQueryBech32Address(this.base.bech32Address)
|
|
1887
1956
|
.fetch();
|
package/src/account/index.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./last-epoch-msgs";
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ObservableChainQuery,
|
|
3
|
+
ObservableChainQueryMap,
|
|
4
|
+
} from "../../chain-query";
|
|
5
|
+
import { ChainGetter } from "../../../chain";
|
|
6
|
+
import { computed, makeObservable } from "mobx";
|
|
7
|
+
import { QuerySharedContext } from "../../../common";
|
|
8
|
+
import { EpochMessage, LatestEpochMessagesResponse } from "./types";
|
|
9
|
+
|
|
10
|
+
export class ObservableQueryBabylonLastEpochMsgsInner extends ObservableChainQuery<LatestEpochMessagesResponse> {
|
|
11
|
+
constructor(
|
|
12
|
+
sharedContext: QuerySharedContext,
|
|
13
|
+
chainId: string,
|
|
14
|
+
chainGetter: ChainGetter
|
|
15
|
+
) {
|
|
16
|
+
super(
|
|
17
|
+
sharedContext,
|
|
18
|
+
chainId,
|
|
19
|
+
chainGetter,
|
|
20
|
+
"/babylon/epoching/v1/epochs:latest/messages?epoch_count=1"
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
makeObservable(this);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@computed
|
|
27
|
+
get msgs(): EpochMessage[] {
|
|
28
|
+
if (!this.response || !this.response.data.latest_epoch_msgs) {
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
return this.response.data.latest_epoch_msgs[0].msgs;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export class ObservableQueryBabylonLastEpochMsgs extends ObservableChainQueryMap<LatestEpochMessagesResponse> {
|
|
36
|
+
constructor(
|
|
37
|
+
sharedContext: QuerySharedContext,
|
|
38
|
+
chainId: string,
|
|
39
|
+
chainGetter: ChainGetter
|
|
40
|
+
) {
|
|
41
|
+
super(sharedContext, chainId, chainGetter, () => {
|
|
42
|
+
return new ObservableQueryBabylonLastEpochMsgsInner(
|
|
43
|
+
this.sharedContext,
|
|
44
|
+
this.chainId,
|
|
45
|
+
this.chainGetter
|
|
46
|
+
);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
getQuery(): ObservableQueryBabylonLastEpochMsgsInner {
|
|
51
|
+
return this.get(
|
|
52
|
+
"babylon-last-epoch-msgs"
|
|
53
|
+
) as ObservableQueryBabylonLastEpochMsgsInner;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface EpochMessage {
|
|
2
|
+
tx_id: string;
|
|
3
|
+
msg_id: string;
|
|
4
|
+
block_height: string;
|
|
5
|
+
block_time: string;
|
|
6
|
+
msg: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface LatestEpochMessagesResponse {
|
|
10
|
+
latest_epoch_msgs: {
|
|
11
|
+
epoch_number: string;
|
|
12
|
+
msgs: EpochMessage[];
|
|
13
|
+
}[];
|
|
14
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { QueriesSetBase } from "../queries";
|
|
2
|
+
import { ChainGetter } from "../../chain";
|
|
3
|
+
import { DeepReadonly } from "utility-types";
|
|
4
|
+
import { QuerySharedContext } from "../../common";
|
|
5
|
+
import { ObservableQueryBabylonLastEpochMsgs } from "./epoching";
|
|
6
|
+
|
|
7
|
+
export interface BabylonQueries {
|
|
8
|
+
babylon: BabylonQueriesImpl;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const BabylonQueries = {
|
|
12
|
+
use(): (
|
|
13
|
+
queriesSetBase: QueriesSetBase,
|
|
14
|
+
sharedContext: QuerySharedContext,
|
|
15
|
+
chainId: string,
|
|
16
|
+
chainGetter: ChainGetter
|
|
17
|
+
) => BabylonQueries {
|
|
18
|
+
return (
|
|
19
|
+
queriesSetBase: QueriesSetBase,
|
|
20
|
+
sharedContext: QuerySharedContext,
|
|
21
|
+
chainId: string,
|
|
22
|
+
chainGetter: ChainGetter
|
|
23
|
+
) => {
|
|
24
|
+
return {
|
|
25
|
+
babylon: new BabylonQueriesImpl(
|
|
26
|
+
queriesSetBase,
|
|
27
|
+
sharedContext,
|
|
28
|
+
chainId,
|
|
29
|
+
chainGetter
|
|
30
|
+
),
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export class BabylonQueriesImpl {
|
|
37
|
+
public readonly queryLastEpochMsgs: DeepReadonly<ObservableQueryBabylonLastEpochMsgs>;
|
|
38
|
+
|
|
39
|
+
constructor(
|
|
40
|
+
_: QueriesSetBase,
|
|
41
|
+
sharedContext: QuerySharedContext,
|
|
42
|
+
chainId: string,
|
|
43
|
+
chainGetter: ChainGetter
|
|
44
|
+
) {
|
|
45
|
+
this.queryLastEpochMsgs = new ObservableQueryBabylonLastEpochMsgs(
|
|
46
|
+
sharedContext,
|
|
47
|
+
chainId,
|
|
48
|
+
chainGetter
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -28,6 +28,7 @@ import { ObservableQueryFeeMarketGasPrices } from "./feemarket";
|
|
|
28
28
|
import { ObservableQueryIBCClientStateV2 } from "./ibc/client-state-v2";
|
|
29
29
|
import { ObservableQueryInitiaUnbondingDelegations } from "./staking/initia-unbonding-delegations";
|
|
30
30
|
import { ObservableQueryInitiaDelegations } from "./staking/initia-delegations";
|
|
31
|
+
import { ObservableQueryInitiaValidators } from "./staking/initia-validators";
|
|
31
32
|
|
|
32
33
|
export interface CosmosQueries {
|
|
33
34
|
cosmos: CosmosQueriesImpl;
|
|
@@ -73,6 +74,7 @@ export class CosmosQueriesImpl {
|
|
|
73
74
|
public readonly queryInitiaUnbondingDelegations: DeepReadonly<ObservableQueryInitiaUnbondingDelegations>;
|
|
74
75
|
public readonly queryValidators: DeepReadonly<ObservableQueryValidators>;
|
|
75
76
|
public readonly queryBabylonBtcDelegationReward: DeepReadonly<ObservableQueryBabylonBtcDelegationReward>;
|
|
77
|
+
public readonly queryInitiaValidators: DeepReadonly<ObservableQueryInitiaValidators>;
|
|
76
78
|
|
|
77
79
|
public readonly queryIBCClientState: DeepReadonly<ObservableQueryIBCClientState>;
|
|
78
80
|
public readonly queryIBCClientStateV2: DeepReadonly<ObservableQueryIBCClientStateV2>;
|
|
@@ -164,6 +166,11 @@ export class CosmosQueriesImpl {
|
|
|
164
166
|
chainGetter
|
|
165
167
|
);
|
|
166
168
|
|
|
169
|
+
this.queryInitiaValidators = new ObservableQueryInitiaValidators(
|
|
170
|
+
sharedContext,
|
|
171
|
+
chainId,
|
|
172
|
+
chainGetter
|
|
173
|
+
);
|
|
167
174
|
this.queryIBCClientState = new ObservableQueryIBCClientState(
|
|
168
175
|
sharedContext,
|
|
169
176
|
chainId,
|