@keplr-wallet/hooks 0.9.18 → 0.10.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/ibc/amount.d.ts +4 -4
- package/build/ibc/amount.js +5 -5
- package/build/ibc/amount.js.map +1 -1
- package/build/ibc/channel.d.ts +1 -1
- package/build/ibc/channel.js +4 -1
- package/build/ibc/channel.js.map +1 -1
- package/build/ibc/gas.d.ts +22 -5
- package/build/ibc/gas.js +8 -14
- package/build/ibc/gas.js.map +1 -1
- package/build/ibc/send-ibc-transfer.d.ts +10 -5
- package/build/ibc/send-ibc-transfer.js +6 -6
- package/build/ibc/send-ibc-transfer.js.map +1 -1
- package/build/ibc/types.d.ts +1 -1
- package/build/sign-doc/amount.d.ts +10 -6
- package/build/sign-doc/amount.js +8 -17
- package/build/sign-doc/amount.js.map +1 -1
- package/build/tx/amount.d.ts +5 -7
- package/build/tx/amount.js +14 -19
- package/build/tx/amount.js.map +1 -1
- package/build/tx/delegate-tx.d.ts +35 -6
- package/build/tx/delegate-tx.js +39 -9
- package/build/tx/delegate-tx.js.map +1 -1
- package/build/tx/errors.d.ts +3 -0
- package/build/tx/errors.js +9 -1
- package/build/tx/errors.js.map +1 -1
- package/build/tx/fee.d.ts +5 -7
- package/build/tx/fee.js +13 -19
- package/build/tx/fee.js.map +1 -1
- package/build/tx/gas.d.ts +1 -1
- package/build/tx/gas.js +7 -1
- package/build/tx/gas.js.map +1 -1
- package/build/tx/memo.d.ts +1 -1
- package/build/tx/memo.js +1 -1
- package/build/tx/memo.js.map +1 -1
- package/build/tx/recipient.d.ts +1 -1
- package/build/tx/recipient.js +4 -1
- package/build/tx/recipient.js.map +1 -1
- package/build/tx/redelegate-tx.d.ts +36 -4
- package/build/tx/redelegate-tx.js +38 -6
- package/build/tx/redelegate-tx.js.map +1 -1
- package/build/tx/send-gas.d.ts +6 -7
- package/build/tx/send-gas.js +41 -15
- package/build/tx/send-gas.js.map +1 -1
- package/build/tx/send-tx.d.ts +3 -5
- package/build/tx/send-tx.js +4 -4
- package/build/tx/send-tx.js.map +1 -1
- package/build/tx/send-types.d.ts +24 -0
- package/build/tx/send-types.js +3 -0
- package/build/tx/send-types.js.map +1 -0
- package/build/tx/staked-amount.d.ts +11 -6
- package/build/tx/staked-amount.js +14 -19
- package/build/tx/staked-amount.js.map +1 -1
- package/build/tx/types.d.ts +5 -5
- package/build/tx/undelegate-tx.d.ts +36 -4
- package/build/tx/undelegate-tx.js +38 -6
- package/build/tx/undelegate-tx.js.map +1 -1
- package/package.json +11 -11
- package/src/ibc/amount.ts +7 -15
- package/src/ibc/channel.ts +3 -2
- package/src/ibc/gas.ts +22 -19
- package/src/ibc/send-ibc-transfer.ts +20 -10
- package/src/ibc/types.ts +1 -1
- package/src/sign-doc/amount.ts +15 -16
- package/src/tx/amount.ts +18 -22
- package/src/tx/delegate-tx.ts +72 -15
- package/src/tx/errors.ts +8 -0
- package/src/tx/fee.ts +15 -20
- package/src/tx/gas.ts +4 -2
- package/src/tx/memo.ts +1 -1
- package/src/tx/recipient.ts +2 -1
- package/src/tx/redelegate-tx.ts +71 -10
- package/src/tx/send-gas.ts +48 -28
- package/src/tx/send-tx.ts +9 -16
- package/src/tx/send-types.ts +25 -0
- package/src/tx/staked-amount.ts +17 -19
- package/src/tx/types.ts +5 -5
- package/src/tx/undelegate-tx.ts +71 -10
package/build/tx/send-gas.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"send-gas.js","sourceRoot":"","sources":["../../src/tx/send-gas.ts"],"names":[],"mappings":";;;;;;;;;AAAA,+BAAkC;AAClC,iDAAmD;
|
|
1
|
+
{"version":3,"file":"send-gas.js","sourceRoot":"","sources":["../../src/tx/send-gas.ts"],"names":[],"mappings":";;;;;;;;;AAAA,+BAAkC;AAClC,iDAAmD;AAGnD,iCAAiC;AACjC,+BAAgD;AAEhD,qCAAgD;AAEhD,MAAa,aAAc,SAAQ,eAAS;IAC1C,YAC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|
2
|
-
import {
|
|
3
|
-
declare
|
|
4
|
-
export declare const useSendTxConfig: (chainGetter: ChainGetter, chainId: string, sendMsgOpts: MsgOpts["send"], sender: string, queryBalances: ObservableQueryBalances, ensEndpoint?: string | undefined) => {
|
|
1
|
+
import { ChainGetter, IQueriesStore } from "@keplr-wallet/stores";
|
|
2
|
+
import { AccountStore } from "./send-types";
|
|
3
|
+
export declare const useSendTxConfig: (chainGetter: ChainGetter, queriesStore: IQueriesStore, accountStore: AccountStore, chainId: string, sender: string, ensEndpoint?: string | undefined) => {
|
|
5
4
|
amountConfig: import("./amount").AmountConfig;
|
|
6
5
|
memoConfig: import("./memo").MemoConfig;
|
|
7
6
|
gasConfig: import("./send-gas").SendGasConfig;
|
|
8
7
|
feeConfig: import("./fee").FeeConfig;
|
|
9
8
|
recipientConfig: import("./recipient").RecipientConfig;
|
|
10
9
|
};
|
|
11
|
-
export {};
|
package/build/tx/send-tx.js
CHANGED
|
@@ -4,11 +4,11 @@ exports.useSendTxConfig = void 0;
|
|
|
4
4
|
const index_1 = require("./index");
|
|
5
5
|
const send_gas_1 = require("./send-gas");
|
|
6
6
|
const amount_1 = require("./amount");
|
|
7
|
-
const useSendTxConfig = (chainGetter,
|
|
8
|
-
const amountConfig = amount_1.useAmountConfig(chainGetter, chainId, sender
|
|
7
|
+
const useSendTxConfig = (chainGetter, queriesStore, accountStore, chainId, sender, ensEndpoint) => {
|
|
8
|
+
const amountConfig = amount_1.useAmountConfig(chainGetter, queriesStore, chainId, sender);
|
|
9
9
|
const memoConfig = index_1.useMemoConfig(chainGetter, chainId);
|
|
10
|
-
const gasConfig = send_gas_1.useSendGasConfig(chainGetter, chainId, amountConfig
|
|
11
|
-
const feeConfig = index_1.useFeeConfig(chainGetter, chainId, sender,
|
|
10
|
+
const gasConfig = send_gas_1.useSendGasConfig(chainGetter, accountStore, chainId, amountConfig);
|
|
11
|
+
const feeConfig = index_1.useFeeConfig(chainGetter, queriesStore, chainId, sender, amountConfig, gasConfig);
|
|
12
12
|
// Due to the circular references between the amount config and gas/fee configs,
|
|
13
13
|
// set the fee config of the amount config after initing the gas/fee configs.
|
|
14
14
|
amountConfig.setFeeConfig(feeConfig);
|
package/build/tx/send-tx.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"send-tx.js","sourceRoot":"","sources":["../../src/tx/send-tx.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"send-tx.js","sourceRoot":"","sources":["../../src/tx/send-tx.ts"],"names":[],"mappings":";;;AACA,mCAA0E;AAC1E,yCAA8C;AAC9C,qCAA2C;AAGpC,MAAM,eAAe,GAAG,CAC7B,WAAwB,EACxB,YAA2B,EAC3B,YAA0B,EAC1B,OAAe,EACf,MAAc,EACd,WAAoB,EACpB,EAAE;IACF,MAAM,YAAY,GAAG,wBAAe,CAClC,WAAW,EACX,YAAY,EACZ,OAAO,EACP,MAAM,CACP,CAAC;IAEF,MAAM,UAAU,GAAG,qBAAa,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IACvD,MAAM,SAAS,GAAG,2BAAgB,CAChC,WAAW,EACX,YAAY,EACZ,OAAO,EACP,YAAY,CACb,CAAC;IACF,MAAM,SAAS,GAAG,oBAAY,CAC5B,WAAW,EACX,YAAY,EACZ,OAAO,EACP,MAAM,EACN,YAAY,EACZ,SAAS,CACV,CAAC;IACF,gFAAgF;IAChF,6EAA6E;IAC7E,YAAY,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IAErC,MAAM,eAAe,GAAG,0BAAkB,CAAC,WAAW,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;IAE9E,OAAO;QACL,YAAY;QACZ,UAAU;QACV,SAAS;QACT,SAAS;QACT,eAAe;KAChB,CAAC;AACJ,CAAC,CAAC;AA3CW,QAAA,eAAe,mBA2C1B"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { IAccountStore, MsgOpt } from "@keplr-wallet/stores";
|
|
2
|
+
export declare type AccountStore = IAccountStore<{
|
|
3
|
+
cosmos?: {
|
|
4
|
+
readonly msgOpts: {
|
|
5
|
+
readonly send: {
|
|
6
|
+
readonly native: MsgOpt;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
cosmwasm?: {
|
|
11
|
+
readonly msgOpts: {
|
|
12
|
+
readonly send: {
|
|
13
|
+
readonly cw20: Pick<MsgOpt, "gas">;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
secret?: {
|
|
18
|
+
readonly msgOpts: {
|
|
19
|
+
readonly send: {
|
|
20
|
+
readonly secret20: Pick<MsgOpt, "gas">;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send-types.js","sourceRoot":"","sources":["../../src/tx/send-types.ts"],"names":[],"mappings":""}
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { IAmountConfig } from "./types";
|
|
2
2
|
import { TxChainSetter } from "./chain";
|
|
3
|
-
import { ChainGetter, CoinPrimitive,
|
|
3
|
+
import { ChainGetter, CoinPrimitive, CosmosQueriesImpl, IQueriesStore } from "@keplr-wallet/stores";
|
|
4
4
|
import { AppCurrency } from "@keplr-wallet/types";
|
|
5
5
|
export declare class StakedAmountConfig extends TxChainSetter implements IAmountConfig {
|
|
6
|
-
protected
|
|
6
|
+
protected readonly queriesStore: IQueriesStore<{
|
|
7
|
+
cosmos: Pick<CosmosQueriesImpl, "queryDelegations">;
|
|
8
|
+
}>;
|
|
7
9
|
protected _sender: string;
|
|
8
10
|
protected _validatorAddress: string;
|
|
9
11
|
protected _amount: string;
|
|
10
12
|
protected _fraction: number | undefined;
|
|
11
|
-
constructor(chainGetter: ChainGetter,
|
|
13
|
+
constructor(chainGetter: ChainGetter, queriesStore: IQueriesStore<{
|
|
14
|
+
cosmos: Pick<CosmosQueriesImpl, "queryDelegations">;
|
|
15
|
+
}>, initialChainId: string, sender: string, initialValidatorAddress: string);
|
|
12
16
|
setValidatorAddress(validatorAddress: string): void;
|
|
13
17
|
get validatorAddress(): string;
|
|
14
|
-
setQueryDelegations(queryDelegations: ObservableQueryDelegations): void;
|
|
15
18
|
setSender(sender: string): void;
|
|
16
19
|
setSendCurrency(): void;
|
|
17
20
|
setAmount(amount: string): void;
|
|
@@ -25,6 +28,8 @@ export declare class StakedAmountConfig extends TxChainSetter implements IAmount
|
|
|
25
28
|
getAmountPrimitive(): CoinPrimitive;
|
|
26
29
|
get sendCurrency(): AppCurrency;
|
|
27
30
|
get sendableCurrencies(): AppCurrency[];
|
|
28
|
-
|
|
31
|
+
get error(): Error | undefined;
|
|
29
32
|
}
|
|
30
|
-
export declare const useStakedAmountConfig: (chainGetter: ChainGetter,
|
|
33
|
+
export declare const useStakedAmountConfig: (chainGetter: ChainGetter, queriesStore: IQueriesStore<{
|
|
34
|
+
cosmos: Pick<CosmosQueriesImpl, "queryDelegations">;
|
|
35
|
+
}>, chainId: string, sender: string, validatorAddress: string) => StakedAmountConfig;
|
|
@@ -13,11 +13,11 @@ const errors_1 = require("./errors");
|
|
|
13
13
|
const unit_1 = require("@keplr-wallet/unit");
|
|
14
14
|
const react_1 = require("react");
|
|
15
15
|
class StakedAmountConfig extends chain_1.TxChainSetter {
|
|
16
|
-
constructor(chainGetter, initialChainId, sender,
|
|
16
|
+
constructor(chainGetter, queriesStore, initialChainId, sender, initialValidatorAddress) {
|
|
17
17
|
super(chainGetter, initialChainId);
|
|
18
|
+
this.queriesStore = queriesStore;
|
|
18
19
|
this._fraction = undefined;
|
|
19
20
|
this._sender = sender;
|
|
20
|
-
this.queryDelegations = queryDelegations;
|
|
21
21
|
this._amount = "";
|
|
22
22
|
this._validatorAddress = initialValidatorAddress;
|
|
23
23
|
mobx_1.makeObservable(this);
|
|
@@ -28,9 +28,6 @@ class StakedAmountConfig extends chain_1.TxChainSetter {
|
|
|
28
28
|
get validatorAddress() {
|
|
29
29
|
return this._validatorAddress;
|
|
30
30
|
}
|
|
31
|
-
setQueryDelegations(queryDelegations) {
|
|
32
|
-
this.queryDelegations = queryDelegations;
|
|
33
|
-
}
|
|
34
31
|
setSender(sender) {
|
|
35
32
|
this._sender = sender;
|
|
36
33
|
}
|
|
@@ -66,8 +63,9 @@ class StakedAmountConfig extends chain_1.TxChainSetter {
|
|
|
66
63
|
}
|
|
67
64
|
get amount() {
|
|
68
65
|
if (this.fraction != null) {
|
|
69
|
-
const result = this.
|
|
70
|
-
.
|
|
66
|
+
const result = this.queriesStore
|
|
67
|
+
.get(this.chainId)
|
|
68
|
+
.cosmos.queryDelegations.getQueryBech32Address(this.sender)
|
|
71
69
|
.getDelegationTo(this.validatorAddress);
|
|
72
70
|
if (result.toDec().lte(new unit_1.Dec(0))) {
|
|
73
71
|
return "0";
|
|
@@ -112,7 +110,7 @@ class StakedAmountConfig extends chain_1.TxChainSetter {
|
|
|
112
110
|
get sendableCurrencies() {
|
|
113
111
|
return [this.chainInfo.stakeCurrency];
|
|
114
112
|
}
|
|
115
|
-
|
|
113
|
+
get error() {
|
|
116
114
|
const sendCurrency = this.sendCurrency;
|
|
117
115
|
if (!sendCurrency) {
|
|
118
116
|
return new Error("Currency to send not set");
|
|
@@ -136,8 +134,9 @@ class StakedAmountConfig extends chain_1.TxChainSetter {
|
|
|
136
134
|
if (new unit_1.Dec(this.amount).lt(new unit_1.Dec(0))) {
|
|
137
135
|
return new errors_1.NegativeAmountError("Amount is negative");
|
|
138
136
|
}
|
|
139
|
-
const balance = this.
|
|
140
|
-
.
|
|
137
|
+
const balance = this.queriesStore
|
|
138
|
+
.get(this.chainId)
|
|
139
|
+
.cosmos.queryDelegations.getQueryBech32Address(this.sender)
|
|
141
140
|
.getDelegationTo(this.validatorAddress);
|
|
142
141
|
const balanceDec = balance.toDec();
|
|
143
142
|
if (dec.gt(balanceDec)) {
|
|
@@ -146,9 +145,6 @@ class StakedAmountConfig extends chain_1.TxChainSetter {
|
|
|
146
145
|
return;
|
|
147
146
|
}
|
|
148
147
|
}
|
|
149
|
-
__decorate([
|
|
150
|
-
mobx_1.observable.ref
|
|
151
|
-
], StakedAmountConfig.prototype, "queryDelegations", void 0);
|
|
152
148
|
__decorate([
|
|
153
149
|
mobx_1.observable
|
|
154
150
|
], StakedAmountConfig.prototype, "_sender", void 0);
|
|
@@ -164,9 +160,6 @@ __decorate([
|
|
|
164
160
|
__decorate([
|
|
165
161
|
mobx_1.action
|
|
166
162
|
], StakedAmountConfig.prototype, "setValidatorAddress", null);
|
|
167
|
-
__decorate([
|
|
168
|
-
mobx_1.action
|
|
169
|
-
], StakedAmountConfig.prototype, "setQueryDelegations", null);
|
|
170
163
|
__decorate([
|
|
171
164
|
mobx_1.action
|
|
172
165
|
], StakedAmountConfig.prototype, "setSender", null);
|
|
@@ -191,11 +184,13 @@ __decorate([
|
|
|
191
184
|
__decorate([
|
|
192
185
|
mobx_1.computed
|
|
193
186
|
], StakedAmountConfig.prototype, "sendCurrency", null);
|
|
187
|
+
__decorate([
|
|
188
|
+
mobx_1.computed
|
|
189
|
+
], StakedAmountConfig.prototype, "error", null);
|
|
194
190
|
exports.StakedAmountConfig = StakedAmountConfig;
|
|
195
|
-
const useStakedAmountConfig = (chainGetter, chainId, sender,
|
|
196
|
-
const [txConfig] = react_1.useState(() => new StakedAmountConfig(chainGetter, chainId, sender,
|
|
191
|
+
const useStakedAmountConfig = (chainGetter, queriesStore, chainId, sender, validatorAddress) => {
|
|
192
|
+
const [txConfig] = react_1.useState(() => new StakedAmountConfig(chainGetter, queriesStore, chainId, sender, validatorAddress));
|
|
197
193
|
txConfig.setChain(chainId);
|
|
198
|
-
txConfig.setQueryDelegations(queryDelegations);
|
|
199
194
|
txConfig.setSender(sender);
|
|
200
195
|
txConfig.setValidatorAddress(validatorAddress);
|
|
201
196
|
return txConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"staked-amount.js","sourceRoot":"","sources":["../../src/tx/staked-amount.ts"],"names":[],"mappings":";;;;;;;;;AACA,mCAAwC;
|
|
1
|
+
{"version":3,"file":"staked-amount.js","sourceRoot":"","sources":["../../src/tx/staked-amount.ts"],"names":[],"mappings":";;;;;;;;;AACA,mCAAwC;AAOxC,+BAAoE;AAEpE,qCAMkB;AAClB,6CAAmD;AACnD,iCAAiC;AAEjC,MAAa,kBAAmB,SAAQ,qBAAa;IAanD,YACE,WAAwB,EACL,YAEjB,EACF,cAAsB,EACtB,MAAc,EACd,uBAA+B;QAE/B,KAAK,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;QAPhB,iBAAY,GAAZ,YAAY,CAE7B;QANM,cAAS,GAAuB,SAAS,CAAC;QAalD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAClB,IAAI,CAAC,iBAAiB,GAAG,uBAAuB,CAAC;QAEjD,qBAAc,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC;IAGD,mBAAmB,CAAC,gBAAwB;QAC1C,IAAI,CAAC,iBAAiB,GAAG,gBAAgB,CAAC;IAC5C,CAAC;IAED,IAAI,gBAAgB;QAClB,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAChC,CAAC;IAGD,SAAS,CAAC,MAAc;QACtB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAGD,eAAe;QACb,OAAO;IACT,CAAC;IAGD,SAAS,CAAC,MAAc;QACtB,IAAI,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;YAC1B,MAAM,GAAG,GAAG,GAAG,MAAM,CAAC;SACvB;QAED,IAAI,IAAI,CAAC,KAAK,EAAE;YACd,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;SACtB;QACD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAGD,QAAQ,CAAC,KAAc;QACrB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,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AY,EACZ,OAAO,EACP,MAAM,EACN,gBAAgB,CACjB,CACJ,CAAC;IACF,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC3B,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC3B,QAAQ,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;IAE/C,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAxBW,QAAA,qBAAqB,yBAwBhC"}
|
package/build/tx/types.d.ts
CHANGED
|
@@ -9,13 +9,13 @@ export interface ITxChainSetter {
|
|
|
9
9
|
export interface IMemoConfig extends ITxChainSetter {
|
|
10
10
|
memo: string;
|
|
11
11
|
setMemo(memo: string): void;
|
|
12
|
-
|
|
12
|
+
error: Error | undefined;
|
|
13
13
|
}
|
|
14
14
|
export interface IGasConfig extends ITxChainSetter {
|
|
15
15
|
gas: number;
|
|
16
16
|
gasRaw: string;
|
|
17
17
|
setGas(gas: number | string): void;
|
|
18
|
-
|
|
18
|
+
error: Error | undefined;
|
|
19
19
|
}
|
|
20
20
|
export interface IFeeConfig extends ITxChainSetter {
|
|
21
21
|
feeType: FeeType | undefined;
|
|
@@ -27,13 +27,13 @@ export interface IFeeConfig extends ITxChainSetter {
|
|
|
27
27
|
getFeeTypePretty(feeType: FeeType): CoinPretty;
|
|
28
28
|
getFeePrimitive(): CoinPrimitive | undefined;
|
|
29
29
|
isManual: boolean;
|
|
30
|
-
|
|
30
|
+
error: Error | undefined;
|
|
31
31
|
}
|
|
32
32
|
export interface IRecipientConfig extends ITxChainSetter {
|
|
33
33
|
recipient: string;
|
|
34
34
|
rawRecipient: string;
|
|
35
35
|
setRawRecipient(recipient: string): void;
|
|
36
|
-
|
|
36
|
+
error: Error | undefined;
|
|
37
37
|
}
|
|
38
38
|
export interface IAmountConfig extends ITxChainSetter {
|
|
39
39
|
amount: string;
|
|
@@ -59,7 +59,7 @@ export interface IAmountConfig extends ITxChainSetter {
|
|
|
59
59
|
isMax: boolean;
|
|
60
60
|
fraction: number | undefined;
|
|
61
61
|
setFraction(value: number | undefined): void;
|
|
62
|
-
|
|
62
|
+
error: Error | undefined;
|
|
63
63
|
}
|
|
64
64
|
export declare const DefaultGasPriceStep: {
|
|
65
65
|
low: number;
|
|
@@ -1,9 +1,41 @@
|
|
|
1
|
-
import { ChainGetter,
|
|
2
|
-
import {
|
|
3
|
-
export declare
|
|
1
|
+
import { ChainGetter, IQueriesStore, CosmosQueriesImpl, IAccountStore, MsgOpt } from "@keplr-wallet/stores";
|
|
2
|
+
import { GasConfig } from "./index";
|
|
3
|
+
export declare class UndelegateGasConfig extends GasConfig {
|
|
4
|
+
protected readonly accountStore: IAccountStore<{
|
|
5
|
+
cosmos: {
|
|
6
|
+
readonly msgOpts: {
|
|
7
|
+
readonly undelegate: MsgOpt;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
}>;
|
|
11
|
+
constructor(chainGetter: ChainGetter, accountStore: IAccountStore<{
|
|
12
|
+
cosmos: {
|
|
13
|
+
readonly msgOpts: {
|
|
14
|
+
readonly undelegate: MsgOpt;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
}>, initialChainId: string);
|
|
18
|
+
get gas(): number;
|
|
19
|
+
}
|
|
20
|
+
export declare const useUndelegateGasConfig: (chainGetter: ChainGetter, accountStore: IAccountStore<{
|
|
21
|
+
cosmos: {
|
|
22
|
+
readonly msgOpts: {
|
|
23
|
+
readonly undelegate: MsgOpt;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
}>, chainId: string) => UndelegateGasConfig;
|
|
27
|
+
export declare const useUndelegateTxConfig: (chainGetter: ChainGetter, queriesStore: IQueriesStore<{
|
|
28
|
+
cosmos: Pick<CosmosQueriesImpl, "queryDelegations">;
|
|
29
|
+
}>, accountStore: IAccountStore<{
|
|
30
|
+
cosmos: {
|
|
31
|
+
readonly msgOpts: {
|
|
32
|
+
readonly undelegate: MsgOpt;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
}>, chainId: string, sender: string, validatorAddress: string) => {
|
|
4
36
|
amountConfig: import("./staked-amount").StakedAmountConfig;
|
|
5
37
|
memoConfig: import("./memo").MemoConfig;
|
|
6
|
-
gasConfig:
|
|
38
|
+
gasConfig: UndelegateGasConfig;
|
|
7
39
|
feeConfig: import("./fee").FeeConfig;
|
|
8
40
|
recipientConfig: import("./recipient").RecipientConfig;
|
|
9
41
|
};
|
|
@@ -1,14 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
2
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useUndelegateTxConfig = void 0;
|
|
9
|
+
exports.useUndelegateTxConfig = exports.useUndelegateGasConfig = exports.UndelegateGasConfig = void 0;
|
|
4
10
|
const index_1 = require("./index");
|
|
5
11
|
const staked_amount_1 = require("./staked-amount");
|
|
6
|
-
const
|
|
7
|
-
|
|
12
|
+
const mobx_1 = require("mobx");
|
|
13
|
+
const react_1 = require("react");
|
|
14
|
+
class UndelegateGasConfig extends index_1.GasConfig {
|
|
15
|
+
constructor(chainGetter, accountStore, initialChainId) {
|
|
16
|
+
super(chainGetter, initialChainId);
|
|
17
|
+
this.accountStore = accountStore;
|
|
18
|
+
mobx_1.makeObservable(this);
|
|
19
|
+
}
|
|
20
|
+
get gas() {
|
|
21
|
+
// If gas not set manually, assume that the tx is for MsgTransfer.
|
|
22
|
+
if (this._gasRaw == null) {
|
|
23
|
+
return this.accountStore.getAccount(this.chainId).cosmos.msgOpts
|
|
24
|
+
.undelegate.gas;
|
|
25
|
+
}
|
|
26
|
+
return super.gas;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
__decorate([
|
|
30
|
+
mobx_1.override
|
|
31
|
+
], UndelegateGasConfig.prototype, "gas", null);
|
|
32
|
+
exports.UndelegateGasConfig = UndelegateGasConfig;
|
|
33
|
+
const useUndelegateGasConfig = (chainGetter, accountStore, chainId) => {
|
|
34
|
+
const [gasConfig] = react_1.useState(() => new UndelegateGasConfig(chainGetter, accountStore, chainId));
|
|
35
|
+
gasConfig.setChain(chainId);
|
|
36
|
+
return gasConfig;
|
|
37
|
+
};
|
|
38
|
+
exports.useUndelegateGasConfig = useUndelegateGasConfig;
|
|
39
|
+
const useUndelegateTxConfig = (chainGetter, queriesStore, accountStore, chainId, sender, validatorAddress) => {
|
|
40
|
+
const amountConfig = staked_amount_1.useStakedAmountConfig(chainGetter, queriesStore, chainId, sender, validatorAddress);
|
|
8
41
|
const memoConfig = index_1.useMemoConfig(chainGetter, chainId);
|
|
9
|
-
const gasConfig =
|
|
10
|
-
|
|
11
|
-
const feeConfig = index_1.useFeeConfig(chainGetter, chainId, sender, queryBalances, amountConfig, gasConfig, false);
|
|
42
|
+
const gasConfig = exports.useUndelegateGasConfig(chainGetter, accountStore, chainId);
|
|
43
|
+
const feeConfig = index_1.useFeeConfig(chainGetter, queriesStore, chainId, sender, amountConfig, gasConfig, false);
|
|
12
44
|
const recipientConfig = index_1.useRecipientConfig(chainGetter, chainId);
|
|
13
45
|
recipientConfig.setBech32Prefix(chainGetter.getChain(chainId).bech32Config.bech32PrefixValAddr);
|
|
14
46
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"undelegate-tx.js","sourceRoot":"","sources":["../../src/tx/undelegate-tx.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"undelegate-tx.js","sourceR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,CAAC;IACvD,MAAM,SAAS,GAAG,8BAAsB,CAAC,WAAW,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;IAC7E,MAAM,SAAS,GAAG,oBAAY,CAC5B,WAAW,EACX,YAAY,EACZ,OAAO,EACP,MAAM,EACN,YAAY,EACZ,SAAS,EACT,KAAK,CACN,CAAC;IAEF,MAAM,eAAe,GAAG,0BAAkB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IACjE,eAAe,CAAC,eAAe,CAC7B,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC,mBAAmB,CAC/D,CAAC;IAEF,OAAO;QACL,YAAY;QACZ,UAAU;QACV,SAAS;QACT,SAAS;QACT,eAAe;KAChB,CAAC;AACJ,CAAC,CAAC;AAhDW,QAAA,qBAAqB,yBAgDhC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keplr-wallet/hooks",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"main": "build/index.js",
|
|
5
5
|
"author": "chainapsis",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -21,15 +21,15 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@cosmjs/launchpad": "^0.24.0-alpha.25",
|
|
24
|
-
"@keplr-wallet/background": "
|
|
25
|
-
"@keplr-wallet/common": "
|
|
26
|
-
"@keplr-wallet/cosmos": "
|
|
27
|
-
"@keplr-wallet/crypto": "
|
|
28
|
-
"@keplr-wallet/ens": "
|
|
29
|
-
"@keplr-wallet/popup": "
|
|
30
|
-
"@keplr-wallet/stores": "
|
|
31
|
-
"@keplr-wallet/types": "
|
|
32
|
-
"@keplr-wallet/unit": "
|
|
24
|
+
"@keplr-wallet/background": "0.10.0",
|
|
25
|
+
"@keplr-wallet/common": "0.10.0",
|
|
26
|
+
"@keplr-wallet/cosmos": "0.10.0",
|
|
27
|
+
"@keplr-wallet/crypto": "0.10.0",
|
|
28
|
+
"@keplr-wallet/ens": "0.10.0",
|
|
29
|
+
"@keplr-wallet/popup": "0.10.0",
|
|
30
|
+
"@keplr-wallet/stores": "0.10.0",
|
|
31
|
+
"@keplr-wallet/types": "0.10.0",
|
|
32
|
+
"@keplr-wallet/unit": "0.10.0",
|
|
33
33
|
"long": "^4.0.0",
|
|
34
34
|
"mobx": "^6.1.7",
|
|
35
35
|
"mobx-utils": "^6.0.3",
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"react-router": "^5.1.2",
|
|
38
38
|
"utility-types": "^3.10.0"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "d36640a0e864a5c7c6bb65b4556ed38ead94afae"
|
|
41
41
|
}
|
package/src/ibc/amount.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { AmountConfig, IFeeConfig } from "../tx";
|
|
2
|
-
import { ChainGetter } from "@keplr-wallet/stores";
|
|
3
|
-
import { ObservableQueryBalances } from "@keplr-wallet/stores/build/query/balances";
|
|
2
|
+
import { ChainGetter, IQueriesStore } from "@keplr-wallet/stores";
|
|
4
3
|
import { AppCurrency } from "@keplr-wallet/types";
|
|
5
4
|
import { computed, makeObservable } from "mobx";
|
|
6
5
|
import { DenomHelper } from "@keplr-wallet/common";
|
|
@@ -9,12 +8,12 @@ import { useState } from "react";
|
|
|
9
8
|
export class IBCAmountConfig extends AmountConfig {
|
|
10
9
|
constructor(
|
|
11
10
|
chainGetter: ChainGetter,
|
|
11
|
+
protected readonly queriesStore: IQueriesStore,
|
|
12
12
|
initialChainId: string,
|
|
13
13
|
sender: string,
|
|
14
|
-
feeConfig: IFeeConfig | undefined
|
|
15
|
-
queryBalances: ObservableQueryBalances
|
|
14
|
+
feeConfig: IFeeConfig | undefined
|
|
16
15
|
) {
|
|
17
|
-
super(chainGetter, initialChainId, sender, feeConfig
|
|
16
|
+
super(chainGetter, queriesStore, initialChainId, sender, feeConfig);
|
|
18
17
|
|
|
19
18
|
makeObservable(this);
|
|
20
19
|
}
|
|
@@ -30,22 +29,15 @@ export class IBCAmountConfig extends AmountConfig {
|
|
|
30
29
|
|
|
31
30
|
export const useIBCAmountConfig = (
|
|
32
31
|
chainGetter: ChainGetter,
|
|
32
|
+
queriesStore: IQueriesStore,
|
|
33
33
|
chainId: string,
|
|
34
|
-
sender: string
|
|
35
|
-
queryBalances: ObservableQueryBalances
|
|
34
|
+
sender: string
|
|
36
35
|
) => {
|
|
37
36
|
const [txConfig] = useState(
|
|
38
37
|
() =>
|
|
39
|
-
new IBCAmountConfig(
|
|
40
|
-
chainGetter,
|
|
41
|
-
chainId,
|
|
42
|
-
sender,
|
|
43
|
-
undefined,
|
|
44
|
-
queryBalances
|
|
45
|
-
)
|
|
38
|
+
new IBCAmountConfig(chainGetter, queriesStore, chainId, sender, undefined)
|
|
46
39
|
);
|
|
47
40
|
txConfig.setChain(chainId);
|
|
48
|
-
txConfig.setQueryBalances(queryBalances);
|
|
49
41
|
txConfig.setSender(sender);
|
|
50
42
|
|
|
51
43
|
return txConfig;
|
package/src/ibc/channel.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IIBCChannelConfig, Channel } from "./types";
|
|
2
|
-
import { action, makeObservable, observable } from "mobx";
|
|
2
|
+
import { action, computed, makeObservable, observable } from "mobx";
|
|
3
3
|
import { ChannelNotSetError } from "./errors";
|
|
4
4
|
import { useState } from "react";
|
|
5
5
|
|
|
@@ -15,7 +15,8 @@ export class IBCChannelConfig implements IIBCChannelConfig {
|
|
|
15
15
|
return this._channel;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
@computed
|
|
19
|
+
get error(): Error | undefined {
|
|
19
20
|
if (!this._channel) {
|
|
20
21
|
return new ChannelNotSetError("Channel not set");
|
|
21
22
|
}
|
package/src/ibc/gas.ts
CHANGED
|
@@ -1,33 +1,31 @@
|
|
|
1
1
|
import { GasConfig } from "../tx";
|
|
2
|
-
import { ChainGetter,
|
|
3
|
-
import {
|
|
2
|
+
import { ChainGetter, IAccountStore, MsgOpt } from "@keplr-wallet/stores";
|
|
3
|
+
import { makeObservable, override } from "mobx";
|
|
4
4
|
import { useState } from "react";
|
|
5
5
|
|
|
6
6
|
export class IBCTransferGasConfig extends GasConfig {
|
|
7
|
-
@observable.ref
|
|
8
|
-
protected msgOpts: CosmosMsgOpts["ibcTransfer"];
|
|
9
|
-
|
|
10
7
|
constructor(
|
|
11
8
|
chainGetter: ChainGetter,
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
protected readonly accountStore: IAccountStore<{
|
|
10
|
+
cosmos: {
|
|
11
|
+
readonly msgOpts: {
|
|
12
|
+
readonly ibcTransfer: MsgOpt;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
}>,
|
|
16
|
+
initialChainId: string
|
|
14
17
|
) {
|
|
15
18
|
super(chainGetter, initialChainId);
|
|
16
19
|
|
|
17
|
-
this.msgOpts = msgOpts;
|
|
18
|
-
|
|
19
20
|
makeObservable(this);
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
@
|
|
23
|
-
setMsgOpts(opts: CosmosMsgOpts["ibcTransfer"]) {
|
|
24
|
-
this.msgOpts = opts;
|
|
25
|
-
}
|
|
26
|
-
|
|
23
|
+
@override
|
|
27
24
|
get gas(): number {
|
|
28
25
|
// If gas not set manually, assume that the tx is for MsgTransfer.
|
|
29
26
|
if (this._gasRaw == null) {
|
|
30
|
-
return this.msgOpts
|
|
27
|
+
return this.accountStore.getAccount(this.chainId).cosmos.msgOpts
|
|
28
|
+
.ibcTransfer.gas;
|
|
31
29
|
}
|
|
32
30
|
|
|
33
31
|
return super.gas;
|
|
@@ -36,14 +34,19 @@ export class IBCTransferGasConfig extends GasConfig {
|
|
|
36
34
|
|
|
37
35
|
export const useIBCTransferGasConfig = (
|
|
38
36
|
chainGetter: ChainGetter,
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
accountStore: IAccountStore<{
|
|
38
|
+
cosmos: {
|
|
39
|
+
readonly msgOpts: {
|
|
40
|
+
readonly ibcTransfer: MsgOpt;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
}>,
|
|
44
|
+
chainId: string
|
|
41
45
|
) => {
|
|
42
46
|
const [gasConfig] = useState(
|
|
43
|
-
() => new IBCTransferGasConfig(chainGetter,
|
|
47
|
+
() => new IBCTransferGasConfig(chainGetter, accountStore, chainId)
|
|
44
48
|
);
|
|
45
49
|
gasConfig.setChain(chainId);
|
|
46
|
-
gasConfig.setMsgOpts(msgOpts);
|
|
47
50
|
|
|
48
51
|
return gasConfig;
|
|
49
52
|
};
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
ChainGetter,
|
|
3
|
+
IAccountStore,
|
|
4
|
+
IQueriesStore,
|
|
5
|
+
MsgOpt,
|
|
6
|
+
} from "@keplr-wallet/stores";
|
|
3
7
|
import { useFeeConfig, useMemoConfig } from "../tx";
|
|
4
8
|
import { useIBCAmountConfig } from "./amount";
|
|
5
9
|
import { useIBCTransferGasConfig } from "./gas";
|
|
@@ -12,34 +16,40 @@ import { useIBCRecipientConfig } from "./reciepient";
|
|
|
12
16
|
* But, actually, the recipient config's chain id would be set as the sending chain id if the channel not set.
|
|
13
17
|
* So, you should remember that the recipient config's chain id is equalt to the sending chain id, if channel not set.
|
|
14
18
|
* @param chainGetter
|
|
19
|
+
* @param queriesStore
|
|
20
|
+
* @param accountStore
|
|
15
21
|
* @param chainId
|
|
16
|
-
* @param msgOpts
|
|
17
22
|
* @param sender
|
|
18
|
-
* @param queryBalances
|
|
19
23
|
* @param ensEndpoint
|
|
20
24
|
*/
|
|
21
25
|
export const useIBCTransferConfig = (
|
|
22
26
|
chainGetter: ChainGetter,
|
|
27
|
+
queriesStore: IQueriesStore,
|
|
28
|
+
accountStore: IAccountStore<{
|
|
29
|
+
cosmos: {
|
|
30
|
+
readonly msgOpts: {
|
|
31
|
+
readonly ibcTransfer: MsgOpt;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
}>,
|
|
23
35
|
chainId: string,
|
|
24
|
-
msgOpts: CosmosMsgOpts["ibcTransfer"],
|
|
25
36
|
sender: string,
|
|
26
|
-
queryBalances: ObservableQueryBalances,
|
|
27
37
|
ensEndpoint?: string
|
|
28
38
|
) => {
|
|
29
39
|
const amountConfig = useIBCAmountConfig(
|
|
30
40
|
chainGetter,
|
|
41
|
+
queriesStore,
|
|
31
42
|
chainId,
|
|
32
|
-
sender
|
|
33
|
-
queryBalances
|
|
43
|
+
sender
|
|
34
44
|
);
|
|
35
45
|
|
|
36
46
|
const memoConfig = useMemoConfig(chainGetter, chainId);
|
|
37
|
-
const gasConfig = useIBCTransferGasConfig(chainGetter,
|
|
47
|
+
const gasConfig = useIBCTransferGasConfig(chainGetter, accountStore, chainId);
|
|
38
48
|
const feeConfig = useFeeConfig(
|
|
39
49
|
chainGetter,
|
|
50
|
+
queriesStore,
|
|
40
51
|
chainId,
|
|
41
52
|
sender,
|
|
42
|
-
queryBalances,
|
|
43
53
|
amountConfig,
|
|
44
54
|
gasConfig
|
|
45
55
|
);
|
package/src/ibc/types.ts
CHANGED