@keplr-wallet/hooks 0.9.16 → 0.9.18-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/ibc/amount.d.ts +4 -4
- package/build/ibc/amount.js +9 -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 +8 -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 +18 -19
- package/build/tx/amount.js.map +1 -1
- package/build/tx/delegate-tx.d.ts +35 -6
- package/build/tx/delegate-tx.js +43 -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 +17 -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 +6 -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 +7 -7
- package/src/ibc/amount.ts +9 -15
- package/src/ibc/channel.ts +3 -2
- package/src/ibc/gas.ts +22 -19
- package/src/ibc/send-ibc-transfer.ts +21 -10
- package/src/ibc/types.ts +1 -1
- package/src/sign-doc/amount.ts +15 -16
- package/src/tx/amount.ts +20 -22
- package/src/tx/delegate-tx.ts +74 -15
- package/src/tx/errors.ts +8 -0
- package/src/tx/fee.ts +17 -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 +10 -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/ibc/amount.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
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
|
export declare class IBCAmountConfig extends AmountConfig {
|
|
6
|
-
|
|
5
|
+
protected readonly queriesStore: IQueriesStore<{}>;
|
|
6
|
+
constructor(chainGetter: ChainGetter, queriesStore: IQueriesStore<{}>, initialChainId: string, sender: string, feeConfig: IFeeConfig | undefined);
|
|
7
7
|
get sendableCurrencies(): AppCurrency[];
|
|
8
8
|
}
|
|
9
|
-
export declare const useIBCAmountConfig: (chainGetter: ChainGetter, chainId: string, sender: string
|
|
9
|
+
export declare const useIBCAmountConfig: (chainGetter: ChainGetter, queriesStore: IQueriesStore<{}>, chainId: string, sender: string) => IBCAmountConfig;
|
package/build/ibc/amount.js
CHANGED
|
@@ -12,8 +12,11 @@ const mobx_1 = require("mobx");
|
|
|
12
12
|
const common_1 = require("@keplr-wallet/common");
|
|
13
13
|
const react_1 = require("react");
|
|
14
14
|
class IBCAmountConfig extends tx_1.AmountConfig {
|
|
15
|
-
constructor(chainGetter,
|
|
16
|
-
|
|
15
|
+
constructor(chainGetter,
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
17
|
+
queriesStore, initialChainId, sender, feeConfig) {
|
|
18
|
+
super(chainGetter, queriesStore, initialChainId, sender, feeConfig);
|
|
19
|
+
this.queriesStore = queriesStore;
|
|
17
20
|
mobx_1.makeObservable(this);
|
|
18
21
|
}
|
|
19
22
|
get sendableCurrencies() {
|
|
@@ -25,10 +28,11 @@ __decorate([
|
|
|
25
28
|
mobx_1.computed
|
|
26
29
|
], IBCAmountConfig.prototype, "sendableCurrencies", null);
|
|
27
30
|
exports.IBCAmountConfig = IBCAmountConfig;
|
|
28
|
-
const useIBCAmountConfig = (chainGetter,
|
|
29
|
-
|
|
31
|
+
const useIBCAmountConfig = (chainGetter,
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
33
|
+
queriesStore, chainId, sender) => {
|
|
34
|
+
const [txConfig] = react_1.useState(() => new IBCAmountConfig(chainGetter, queriesStore, chainId, sender, undefined));
|
|
30
35
|
txConfig.setChain(chainId);
|
|
31
|
-
txConfig.setQueryBalances(queryBalances);
|
|
32
36
|
txConfig.setSender(sender);
|
|
33
37
|
return txConfig;
|
|
34
38
|
};
|
package/build/ibc/amount.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"amount.js","sourceRoot":"","sources":["../../src/ibc/amount.ts"],"names":[],"mappings":";;;;;;;;;AAAA,8BAAiD;
|
|
1
|
+
{"version":3,"file":"amount.js","sourceRoot":"","sources":["../../src/ibc/amount.ts"],"names":[],"mappings":";;;;;;;;;AAAA,8BAAiD;AAGjD,+BAAgD;AAChD,iDAAmD;AACnD,iCAAiC;AAEjC,MAAa,eAAgB,SAAQ,iBAAY;IAC/C,YACE,WAAwB;IACxB,wDAAwD;IACrC,YAA+B,EAClD,cAAsB,EACtB,MAAc,EACd,SAAiC;QAEjC,KAAK,CAAC,WAAW,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;QALjD,iBAAY,GAAZ,YAAY,CAAmB;QAOlD,qBAAc,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC;IAGD,IAAI,kBAAkB;QACpB,sDAAsD;QACtD,OAAO,KAAK,CAAC,kBAAkB,CAAC,MAAM,CACpC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,oBAAW,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,IAAI,KAAK,QAAQ,CACjE,CAAC;IACJ,CAAC;CACF;AANC;IADC,eAAQ;yDAMR;AApBH,0CAqBC;AAEM,MAAM,kBAAkB,GAAG,CAChC,WAAwB;AACxB,wDAAwD;AACxD,YAA+B,EAC/B,OAAe,EACf,MAAc,EACd,EAAE;IACF,MAAM,CAAC,QAAQ,CAAC,GAAG,gBAAQ,CACzB,GAAG,EAAE,CACH,IAAI,eAAe,CAAC,WAAW,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,CAC7E,CAAC;IACF,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC3B,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAE3B,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAfW,QAAA,kBAAkB,sBAe7B"}
|
package/build/ibc/channel.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export declare class IBCChannelConfig implements IIBCChannelConfig {
|
|
|
3
3
|
protected _channel: Channel | undefined;
|
|
4
4
|
constructor();
|
|
5
5
|
get channel(): Channel | undefined;
|
|
6
|
-
|
|
6
|
+
get error(): Error | undefined;
|
|
7
7
|
setChannel(channel: Channel | undefined): void;
|
|
8
8
|
}
|
|
9
9
|
export declare const useIBCChannelConfig: () => IBCChannelConfig;
|
package/build/ibc/channel.js
CHANGED
|
@@ -18,7 +18,7 @@ class IBCChannelConfig {
|
|
|
18
18
|
get channel() {
|
|
19
19
|
return this._channel;
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
get error() {
|
|
22
22
|
if (!this._channel) {
|
|
23
23
|
return new errors_1.ChannelNotSetError("Channel not set");
|
|
24
24
|
}
|
|
@@ -31,6 +31,9 @@ class IBCChannelConfig {
|
|
|
31
31
|
__decorate([
|
|
32
32
|
mobx_1.observable.ref
|
|
33
33
|
], IBCChannelConfig.prototype, "_channel", void 0);
|
|
34
|
+
__decorate([
|
|
35
|
+
mobx_1.computed
|
|
36
|
+
], IBCChannelConfig.prototype, "error", null);
|
|
34
37
|
__decorate([
|
|
35
38
|
mobx_1.action
|
|
36
39
|
], IBCChannelConfig.prototype, "setChannel", null);
|
package/build/ibc/channel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel.js","sourceRoot":"","sources":["../../src/ibc/channel.ts"],"names":[],"mappings":";;;;;;;;;AACA,+
|
|
1
|
+
{"version":3,"file":"channel.js","sourceRoot":"","sources":["../../src/ibc/channel.ts"],"names":[],"mappings":";;;;;;;;;AACA,+BAAoE;AACpE,qCAA8C;AAC9C,iCAAiC;AAEjC,MAAa,gBAAgB;IAI3B;QAFU,aAAQ,GAAwB,SAAS,CAAC;QAGlD,qBAAc,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAGD,IAAI,KAAK;QACP,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YAClB,OAAO,IAAI,2BAAkB,CAAC,iBAAiB,CAAC,CAAC;SAClD;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAGD,UAAU,CAAC,OAA4B;QACrC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;CACF;AAtBC;IADC,iBAAU,CAAC,GAAG;kDACqC;AAWpD;IADC,eAAQ;6CAMR;AAGD;IADC,aAAM;kDAGN;AAvBH,4CAwBC;AAEM,MAAM,mBAAmB,GAAG,GAAG,EAAE;IACtC,MAAM,CAAC,MAAM,CAAC,GAAG,gBAAQ,CAAC,GAAG,EAAE;QAC7B,OAAO,IAAI,gBAAgB,EAAE,CAAC;IAChC,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AANW,QAAA,mBAAmB,uBAM9B"}
|
package/build/ibc/gas.d.ts
CHANGED
|
@@ -1,9 +1,26 @@
|
|
|
1
1
|
import { GasConfig } from "../tx";
|
|
2
|
-
import { ChainGetter,
|
|
2
|
+
import { ChainGetter, IAccountStore, MsgOpt } from "@keplr-wallet/stores";
|
|
3
3
|
export declare class IBCTransferGasConfig extends GasConfig {
|
|
4
|
-
protected
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
protected readonly accountStore: IAccountStore<{
|
|
5
|
+
cosmos: {
|
|
6
|
+
readonly msgOpts: {
|
|
7
|
+
readonly ibcTransfer: MsgOpt;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
}>;
|
|
11
|
+
constructor(chainGetter: ChainGetter, accountStore: IAccountStore<{
|
|
12
|
+
cosmos: {
|
|
13
|
+
readonly msgOpts: {
|
|
14
|
+
readonly ibcTransfer: MsgOpt;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
}>, initialChainId: string);
|
|
7
18
|
get gas(): number;
|
|
8
19
|
}
|
|
9
|
-
export declare const useIBCTransferGasConfig: (chainGetter: ChainGetter,
|
|
20
|
+
export declare const useIBCTransferGasConfig: (chainGetter: ChainGetter, accountStore: IAccountStore<{
|
|
21
|
+
cosmos: {
|
|
22
|
+
readonly msgOpts: {
|
|
23
|
+
readonly ibcTransfer: MsgOpt;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
}>, chainId: string) => IBCTransferGasConfig;
|
package/build/ibc/gas.js
CHANGED
|
@@ -11,33 +11,27 @@ const tx_1 = require("../tx");
|
|
|
11
11
|
const mobx_1 = require("mobx");
|
|
12
12
|
const react_1 = require("react");
|
|
13
13
|
class IBCTransferGasConfig extends tx_1.GasConfig {
|
|
14
|
-
constructor(chainGetter,
|
|
14
|
+
constructor(chainGetter, accountStore, initialChainId) {
|
|
15
15
|
super(chainGetter, initialChainId);
|
|
16
|
-
this.
|
|
16
|
+
this.accountStore = accountStore;
|
|
17
17
|
mobx_1.makeObservable(this);
|
|
18
18
|
}
|
|
19
|
-
setMsgOpts(opts) {
|
|
20
|
-
this.msgOpts = opts;
|
|
21
|
-
}
|
|
22
19
|
get gas() {
|
|
23
20
|
// If gas not set manually, assume that the tx is for MsgTransfer.
|
|
24
21
|
if (this._gasRaw == null) {
|
|
25
|
-
return this.msgOpts
|
|
22
|
+
return this.accountStore.getAccount(this.chainId).cosmos.msgOpts
|
|
23
|
+
.ibcTransfer.gas;
|
|
26
24
|
}
|
|
27
25
|
return super.gas;
|
|
28
26
|
}
|
|
29
27
|
}
|
|
30
28
|
__decorate([
|
|
31
|
-
mobx_1.
|
|
32
|
-
], IBCTransferGasConfig.prototype, "
|
|
33
|
-
__decorate([
|
|
34
|
-
mobx_1.action
|
|
35
|
-
], IBCTransferGasConfig.prototype, "setMsgOpts", null);
|
|
29
|
+
mobx_1.override
|
|
30
|
+
], IBCTransferGasConfig.prototype, "gas", null);
|
|
36
31
|
exports.IBCTransferGasConfig = IBCTransferGasConfig;
|
|
37
|
-
const useIBCTransferGasConfig = (chainGetter,
|
|
38
|
-
const [gasConfig] = react_1.useState(() => new IBCTransferGasConfig(chainGetter,
|
|
32
|
+
const useIBCTransferGasConfig = (chainGetter, accountStore, chainId) => {
|
|
33
|
+
const [gasConfig] = react_1.useState(() => new IBCTransferGasConfig(chainGetter, accountStore, chainId));
|
|
39
34
|
gasConfig.setChain(chainId);
|
|
40
|
-
gasConfig.setMsgOpts(msgOpts);
|
|
41
35
|
return gasConfig;
|
|
42
36
|
};
|
|
43
37
|
exports.useIBCTransferGasConfig = useIBCTransferGasConfig;
|
package/build/ibc/gas.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gas.js","sourceRoot":"","sources":["../../src/ibc/gas.ts"],"names":[],"mappings":";;;;;;;;;AAAA,8BAAkC;AAElC,+
|
|
1
|
+
{"version":3,"file":"gas.js","sourceRoot":"","sources":["../../src/ibc/gas.ts"],"names":[],"mappings":";;;;;;;;;AAAA,8BAAkC;AAElC,+BAAgD;AAChD,iCAAiC;AAEjC,MAAa,oBAAqB,SAAQ,cAAS;IACjD,YACE,WAAwB,EACL,YAMjB,EACF,cAAsB;QAEtB,KAAK,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;QAThB,iBAAY,GAAZ,YAAY,CAM7B;QAKF,qBAAc,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC;IAGD,IAAI,GAAG;QACL,kEAAkE;QAClE,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,EAAE;YACxB,OAAO,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,OAAO;iBAC7D,WAAW,CAAC,GAAG,CAAC;SACpB;QAED,OAAO,KAAK,CAAC,GAAG,CAAC;IACnB,CAAC;CACF;AATC;IADC,eAAQ;+CASR;AA1BH,oDA2BC;AAEM,MAAM,uBAAuB,GAAG,CACrC,WAAwB,EACxB,YAME,EACF,OAAe,EACf,EAAE;IACF,MAAM,CAAC,SAAS,CAAC,GAAG,gBAAQ,CAC1B,GAAG,EAAE,CAAC,IAAI,oBAAoB,CAAC,WAAW,EAAE,YAAY,EAAE,OAAO,CAAC,CACnE,CAAC;IACF,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAE5B,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAjBW,QAAA,uBAAuB,2BAiBlC"}
|
|
@@ -1,18 +1,23 @@
|
|
|
1
|
-
import { ChainGetter,
|
|
2
|
-
import { ObservableQueryBalances } from "@keplr-wallet/stores/build/query/balances";
|
|
1
|
+
import { ChainGetter, IAccountStore, IQueriesStore, MsgOpt } from "@keplr-wallet/stores";
|
|
3
2
|
/**
|
|
4
3
|
* useIBCTransferConfig returns the configs for IBC transfer.
|
|
5
4
|
* The recipient config's chain id should be the destination chain id for IBC.
|
|
6
5
|
* But, actually, the recipient config's chain id would be set as the sending chain id if the channel not set.
|
|
7
6
|
* So, you should remember that the recipient config's chain id is equalt to the sending chain id, if channel not set.
|
|
8
7
|
* @param chainGetter
|
|
8
|
+
* @param queriesStore
|
|
9
|
+
* @param accountStore
|
|
9
10
|
* @param chainId
|
|
10
|
-
* @param msgOpts
|
|
11
11
|
* @param sender
|
|
12
|
-
* @param queryBalances
|
|
13
12
|
* @param ensEndpoint
|
|
14
13
|
*/
|
|
15
|
-
export declare const useIBCTransferConfig: (chainGetter: ChainGetter,
|
|
14
|
+
export declare const useIBCTransferConfig: (chainGetter: ChainGetter, queriesStore: IQueriesStore<{}>, accountStore: IAccountStore<{
|
|
15
|
+
cosmos: {
|
|
16
|
+
readonly msgOpts: {
|
|
17
|
+
readonly ibcTransfer: MsgOpt;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
}>, chainId: string, sender: string, ensEndpoint?: string | undefined) => {
|
|
16
21
|
amountConfig: import("./amount").IBCAmountConfig;
|
|
17
22
|
memoConfig: import("../tx").MemoConfig;
|
|
18
23
|
gasConfig: import("./gas").IBCTransferGasConfig;
|
|
@@ -12,17 +12,19 @@ const reciepient_1 = require("./reciepient");
|
|
|
12
12
|
* But, actually, the recipient config's chain id would be set as the sending chain id if the channel not set.
|
|
13
13
|
* So, you should remember that the recipient config's chain id is equalt to the sending chain id, if channel not set.
|
|
14
14
|
* @param chainGetter
|
|
15
|
+
* @param queriesStore
|
|
16
|
+
* @param accountStore
|
|
15
17
|
* @param chainId
|
|
16
|
-
* @param msgOpts
|
|
17
18
|
* @param sender
|
|
18
|
-
* @param queryBalances
|
|
19
19
|
* @param ensEndpoint
|
|
20
20
|
*/
|
|
21
|
-
const useIBCTransferConfig = (chainGetter,
|
|
22
|
-
|
|
21
|
+
const useIBCTransferConfig = (chainGetter,
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
23
|
+
queriesStore, accountStore, chainId, sender, ensEndpoint) => {
|
|
24
|
+
const amountConfig = amount_1.useIBCAmountConfig(chainGetter, queriesStore, chainId, sender);
|
|
23
25
|
const memoConfig = tx_1.useMemoConfig(chainGetter, chainId);
|
|
24
|
-
const gasConfig = gas_1.useIBCTransferGasConfig(chainGetter,
|
|
25
|
-
const feeConfig = tx_1.useFeeConfig(chainGetter, chainId, sender,
|
|
26
|
+
const gasConfig = gas_1.useIBCTransferGasConfig(chainGetter, accountStore, chainId);
|
|
27
|
+
const feeConfig = tx_1.useFeeConfig(chainGetter, queriesStore, chainId, sender, amountConfig, gasConfig);
|
|
26
28
|
// Due to the circular references between the amount config and gas/fee configs,
|
|
27
29
|
// set the fee config of the amount config after initing the gas/fee configs.
|
|
28
30
|
amountConfig.setFeeConfig(feeConfig);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"send-ibc-transfer.js","sourceRoot":"","sources":["../../src/ibc/send-ibc-transfer.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"send-ibc-transfer.js","sourceRoot":"","sources":["../../src/ibc/send-ibc-transfer.ts"],"names":[],"mappings":";;;AAMA,8BAAoD;AACpD,qCAA8C;AAC9C,+BAAgD;AAChD,uCAAgD;AAChD,6CAAqD;AAErD;;;;;;;;;;;GAWG;AACI,MAAM,oBAAoB,GAAG,CAClC,WAAwB;AACxB,wDAAwD;AACxD,YAA+B,EAC/B,YAME,EACF,OAAe,EACf,MAAc,EACd,WAAoB,EACpB,EAAE;IACF,MAAM,YAAY,GAAG,2BAAkB,CACrC,WAAW,EACX,YAAY,EACZ,OAAO,EACP,MAAM,CACP,CAAC;IAEF,MAAM,UAAU,GAAG,kBAAa,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IACvD,MAAM,SAAS,GAAG,6BAAuB,CAAC,WAAW,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;IAC9E,MAAM,SAAS,GAAG,iBAAY,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,aAAa,GAAG,6BAAmB,EAAE,CAAC;IAE5C,MAAM,eAAe,GAAG,kCAAqB,CAC3C,WAAW,EACX,OAAO,EACP,aAAa,EACb,WAAW,CACZ,CAAC;IAEF,OAAO;QACL,YAAY;QACZ,UAAU;QACV,SAAS;QACT,SAAS;QACT,eAAe;QACf,aAAa;KACd,CAAC;AACJ,CAAC,CAAC;AArDW,QAAA,oBAAoB,wBAqD/B"}
|
package/build/ibc/types.d.ts
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { IAmountConfig, TxChainSetter } from "../tx";
|
|
2
|
-
import { ChainGetter, CoinPrimitive, CosmosMsgOpts } from "@keplr-wallet/stores";
|
|
2
|
+
import { ChainGetter, CoinPrimitive, CosmosMsgOpts, IAccountStore } from "@keplr-wallet/stores";
|
|
3
3
|
import { AppCurrency } from "@keplr-wallet/types";
|
|
4
4
|
import { SignDocHelper } from "./index";
|
|
5
5
|
import { Msg } from "@cosmjs/launchpad";
|
|
6
|
+
export declare type AccountStore = IAccountStore<{
|
|
7
|
+
cosmos: {
|
|
8
|
+
readonly msgOpts: CosmosMsgOpts;
|
|
9
|
+
};
|
|
10
|
+
}>;
|
|
6
11
|
export declare class SignDocAmountConfig extends TxChainSetter implements IAmountConfig {
|
|
7
|
-
protected
|
|
12
|
+
protected readonly accountStore: AccountStore;
|
|
8
13
|
protected signDocHelper?: SignDocHelper;
|
|
9
14
|
protected _sender: string;
|
|
10
15
|
protected _disableBalanceCheck: boolean;
|
|
11
|
-
constructor(chainGetter: ChainGetter,
|
|
12
|
-
setMsgOpts(opts: CosmosMsgOpts): void;
|
|
16
|
+
constructor(chainGetter: ChainGetter, accountStore: AccountStore, initialChainId: string, sender: string);
|
|
13
17
|
setSignDocHelper(signDocHelper: SignDocHelper): void;
|
|
14
18
|
get amount(): string;
|
|
15
19
|
get sendCurrency(): AppCurrency;
|
|
@@ -25,7 +29,7 @@ export declare class SignDocAmountConfig extends TxChainSetter implements IAmoun
|
|
|
25
29
|
amount: string;
|
|
26
30
|
denom: string;
|
|
27
31
|
};
|
|
28
|
-
|
|
32
|
+
get error(): Error | undefined;
|
|
29
33
|
setIsMax(_: boolean): void;
|
|
30
34
|
toggleIsMax(): void;
|
|
31
35
|
get isMax(): boolean;
|
|
@@ -36,4 +40,4 @@ export declare class SignDocAmountConfig extends TxChainSetter implements IAmoun
|
|
|
36
40
|
setDisableBalanceCheck(bool: boolean): void;
|
|
37
41
|
get disableBalanceCheck(): boolean;
|
|
38
42
|
}
|
|
39
|
-
export declare const useSignDocAmountConfig: (chainGetter: ChainGetter,
|
|
43
|
+
export declare const useSignDocAmountConfig: (chainGetter: ChainGetter, accountStore: AccountStore, chainId: string, sender: string) => SignDocAmountConfig;
|
package/build/sign-doc/amount.js
CHANGED
|
@@ -17,8 +17,9 @@ const cosmos_1 = require("@keplr-wallet/cosmos");
|
|
|
17
17
|
// the amount in the sign doc.
|
|
18
18
|
// This sets the amount as the sum of the messages in the sign doc if the message is known and can be parsed.
|
|
19
19
|
class SignDocAmountConfig extends tx_1.TxChainSetter {
|
|
20
|
-
constructor(chainGetter,
|
|
20
|
+
constructor(chainGetter, accountStore, initialChainId, sender) {
|
|
21
21
|
super(chainGetter, initialChainId);
|
|
22
|
+
this.accountStore = accountStore;
|
|
22
23
|
this.signDocHelper = undefined;
|
|
23
24
|
this._disableBalanceCheck = false;
|
|
24
25
|
this.getAmountPrimitive = mobx_utils_1.computedFn(() => {
|
|
@@ -38,13 +39,9 @@ class SignDocAmountConfig extends tx_1.TxChainSetter {
|
|
|
38
39
|
return this.computeAmountInProtoMsgs(this.signDocHelper.signDocWrapper.protoSignDoc.txMsgs);
|
|
39
40
|
}
|
|
40
41
|
});
|
|
41
|
-
this.msgOpts = msgOpts;
|
|
42
42
|
this._sender = sender;
|
|
43
43
|
mobx_1.makeObservable(this);
|
|
44
44
|
}
|
|
45
|
-
setMsgOpts(opts) {
|
|
46
|
-
this.msgOpts = opts;
|
|
47
|
-
}
|
|
48
45
|
setSignDocHelper(signDocHelper) {
|
|
49
46
|
this.signDocHelper = signDocHelper;
|
|
50
47
|
}
|
|
@@ -70,10 +67,11 @@ class SignDocAmountConfig extends tx_1.TxChainSetter {
|
|
|
70
67
|
}
|
|
71
68
|
computeAmountInAminoMsgs(msgs) {
|
|
72
69
|
const amount = new unit_1.Coin(this.sendCurrency.coinMinimalDenom, new unit_1.Int(0));
|
|
70
|
+
const account = this.accountStore.getAccount(this.chainId);
|
|
73
71
|
for (const msg of msgs) {
|
|
74
72
|
try {
|
|
75
73
|
switch (msg.type) {
|
|
76
|
-
case
|
|
74
|
+
case account.cosmos.msgOpts.send.native.type:
|
|
77
75
|
if (msg.value.from_address &&
|
|
78
76
|
msg.value.from_address !== this.sender) {
|
|
79
77
|
return {
|
|
@@ -89,7 +87,7 @@ class SignDocAmountConfig extends tx_1.TxChainSetter {
|
|
|
89
87
|
}
|
|
90
88
|
}
|
|
91
89
|
break;
|
|
92
|
-
case
|
|
90
|
+
case account.cosmos.msgOpts.delegate.type:
|
|
93
91
|
if (msg.value.delegator_address &&
|
|
94
92
|
msg.value.delegator_address !== this.sender) {
|
|
95
93
|
return {
|
|
@@ -157,7 +155,7 @@ class SignDocAmountConfig extends tx_1.TxChainSetter {
|
|
|
157
155
|
denom: amount.denom,
|
|
158
156
|
};
|
|
159
157
|
}
|
|
160
|
-
|
|
158
|
+
get error() {
|
|
161
159
|
return undefined;
|
|
162
160
|
}
|
|
163
161
|
setIsMax(_) {
|
|
@@ -190,9 +188,6 @@ class SignDocAmountConfig extends tx_1.TxChainSetter {
|
|
|
190
188
|
return this._disableBalanceCheck;
|
|
191
189
|
}
|
|
192
190
|
}
|
|
193
|
-
__decorate([
|
|
194
|
-
mobx_1.observable.ref
|
|
195
|
-
], SignDocAmountConfig.prototype, "msgOpts", void 0);
|
|
196
191
|
__decorate([
|
|
197
192
|
mobx_1.observable.ref
|
|
198
193
|
], SignDocAmountConfig.prototype, "signDocHelper", void 0);
|
|
@@ -202,9 +197,6 @@ __decorate([
|
|
|
202
197
|
__decorate([
|
|
203
198
|
mobx_1.observable
|
|
204
199
|
], SignDocAmountConfig.prototype, "_disableBalanceCheck", void 0);
|
|
205
|
-
__decorate([
|
|
206
|
-
mobx_1.action
|
|
207
|
-
], SignDocAmountConfig.prototype, "setMsgOpts", null);
|
|
208
200
|
__decorate([
|
|
209
201
|
mobx_1.action
|
|
210
202
|
], SignDocAmountConfig.prototype, "setSignDocHelper", null);
|
|
@@ -218,10 +210,9 @@ __decorate([
|
|
|
218
210
|
mobx_1.action
|
|
219
211
|
], SignDocAmountConfig.prototype, "setDisableBalanceCheck", null);
|
|
220
212
|
exports.SignDocAmountConfig = SignDocAmountConfig;
|
|
221
|
-
const useSignDocAmountConfig = (chainGetter,
|
|
222
|
-
const [config] = react_1.useState(() => new SignDocAmountConfig(chainGetter,
|
|
213
|
+
const useSignDocAmountConfig = (chainGetter, accountStore, chainId, sender) => {
|
|
214
|
+
const [config] = react_1.useState(() => new SignDocAmountConfig(chainGetter, accountStore, chainId, sender));
|
|
223
215
|
config.setChain(chainId);
|
|
224
|
-
config.setMsgOpts(msgOpts);
|
|
225
216
|
config.setSender(sender);
|
|
226
217
|
return config;
|
|
227
218
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"amount.js","sourceRoot":"","sources":["../../src/sign-doc/amount.ts"],"names":[],"mappings":";;;;;;;;;AAAA,8BAAqD;
|
|
1
|
+
{"version":3,"file":"amount.js","sourceRoot":"","sources":["../../src/sign-doc/amount.ts"],"names":[],"mappings":";;;;;;;;;AAAA,8BAAqD;AAQrD,+BAAoE;AACpE,6CAA2D;AAE3D,iCAAiC;AACjC,2CAAwC;AAExC,iDAA8C;AAQ9C,gGAAgG;AAChG,8BAA8B;AAC9B,6GAA6G;AAC7G,MAAa,mBACX,SAAQ,kBAAa;IAWrB,YACE,WAAwB,EACL,YAA0B,EAC7C,cAAsB,EACtB,MAAc;QAEd,KAAK,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;QAJhB,iBAAY,GAAZ,YAAY,CAAc;QAVrC,kBAAa,GAAmB,SAAS,CAAC;QAM1C,yBAAoB,GAAY,KAAK,CAAC;QAoDhD,uBAAkB,GAAG,uBAAU,CAC7B,GAAkB,EAAE;;YAClB,IACE,IAAI,CAAC,mBAAmB;gBACxB,QAAC,IAAI,CAAC,aAAa,0CAAE,cAAc,CAAA;gBACnC,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,MAAM,KAAK,CAAC,EACzC;gBACA,OAAO;oBACL,MAAM,EAAE,GAAG;oBACX,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,gBAAgB;iBAC1C,CAAC;aACH;YAED,IAAI,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,IAAI,KAAK,OAAO,EAAE;gBACtD,OAAO,IAAI,CAAC,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AC;IAED,SAAS;QACP,OAAO;IACT,CAAC;IAED,eAAe;QACb,OAAO;IACT,CAAC;IAGD,sBAAsB,CAAC,IAAa;QAClC,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC;IACnC,CAAC;IAED,IAAI,mBAAmB;QACrB,OAAO,IAAI,CAAC,oBAAoB,CAAC;IACnC,CAAC;CACF;AA5OC;IADC,iBAAU,CAAC,GAAG;0DACqC;AAGpD;IADC,iBAAU;oDACe;AAG1B;IADC,iBAAU;iEACqC;AAgBhD;IADC,aAAM;2DAGN;AAGD;IADC,eAAQ;iDAQR;AAgBD;IADC,aAAM;oDAGN;AAiLD;IADC,aAAM;iEAGN;AA3OH,kDAgPC;AAEM,MAAM,sBAAsB,GAAG,CACpC,WAAwB,EACxB,YAA0B,EAC1B,OAAe,EACf,MAAc,EACd,EAAE;IACF,MAAM,CAAC,MAAM,CAAC,GAAG,gBAAQ,CACvB,GAAG,EAAE,CAAC,IAAI,mBAAmB,CAAC,WAAW,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,CAAC,CAC1E,CAAC;IACF,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACzB,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAEzB,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAbW,QAAA,sBAAsB,0BAajC"}
|
package/build/tx/amount.d.ts
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import { IAmountConfig, IFeeConfig } from "./types";
|
|
2
2
|
import { TxChainSetter } from "./chain";
|
|
3
|
-
import { ChainGetter, CoinPrimitive } from "@keplr-wallet/stores";
|
|
4
|
-
import { ObservableQueryBalances } from "@keplr-wallet/stores/build/query/balances";
|
|
3
|
+
import { ChainGetter, CoinPrimitive, IQueriesStore } from "@keplr-wallet/stores";
|
|
5
4
|
import { AppCurrency } from "@keplr-wallet/types";
|
|
6
5
|
export declare class AmountConfig extends TxChainSetter implements IAmountConfig {
|
|
6
|
+
protected readonly queriesStore: IQueriesStore<{}>;
|
|
7
7
|
protected feeConfig?: IFeeConfig;
|
|
8
|
-
protected queryBalances: ObservableQueryBalances;
|
|
9
8
|
protected _sender: string;
|
|
10
9
|
protected _sendCurrency?: AppCurrency;
|
|
11
10
|
protected _amount: string;
|
|
12
11
|
protected _fraction: number | undefined;
|
|
13
|
-
constructor(chainGetter: ChainGetter, initialChainId: string, sender: string, feeConfig: IFeeConfig | undefined
|
|
12
|
+
constructor(chainGetter: ChainGetter, queriesStore: IQueriesStore<{}>, initialChainId: string, sender: string, feeConfig: IFeeConfig | undefined);
|
|
14
13
|
setFeeConfig(feeConfig: IFeeConfig): void;
|
|
15
|
-
setQueryBalances(queryBalances: ObservableQueryBalances): void;
|
|
16
14
|
setSender(sender: string): void;
|
|
17
15
|
setSendCurrency(currency: AppCurrency | undefined): void;
|
|
18
16
|
setAmount(amount: string): void;
|
|
@@ -26,6 +24,6 @@ export declare class AmountConfig extends TxChainSetter implements IAmountConfig
|
|
|
26
24
|
getAmountPrimitive(): CoinPrimitive;
|
|
27
25
|
get sendCurrency(): AppCurrency;
|
|
28
26
|
get sendableCurrencies(): AppCurrency[];
|
|
29
|
-
|
|
27
|
+
get error(): Error | undefined;
|
|
30
28
|
}
|
|
31
|
-
export declare const useAmountConfig: (chainGetter: ChainGetter, chainId: string, sender: string
|
|
29
|
+
export declare const useAmountConfig: (chainGetter: ChainGetter, queriesStore: IQueriesStore<{}>, chainId: string, sender: string) => AmountConfig;
|
package/build/tx/amount.js
CHANGED
|
@@ -13,22 +13,21 @@ const errors_1 = require("./errors");
|
|
|
13
13
|
const unit_1 = require("@keplr-wallet/unit");
|
|
14
14
|
const react_1 = require("react");
|
|
15
15
|
class AmountConfig extends chain_1.TxChainSetter {
|
|
16
|
-
constructor(chainGetter,
|
|
16
|
+
constructor(chainGetter,
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
18
|
+
queriesStore, initialChainId, sender, feeConfig) {
|
|
17
19
|
super(chainGetter, initialChainId);
|
|
20
|
+
this.queriesStore = queriesStore;
|
|
18
21
|
this._sendCurrency = undefined;
|
|
19
22
|
this._fraction = undefined;
|
|
20
23
|
this._sender = sender;
|
|
21
24
|
this.feeConfig = feeConfig;
|
|
22
|
-
this.queryBalances = queryBalances;
|
|
23
25
|
this._amount = "";
|
|
24
26
|
mobx_1.makeObservable(this);
|
|
25
27
|
}
|
|
26
28
|
setFeeConfig(feeConfig) {
|
|
27
29
|
this.feeConfig = feeConfig;
|
|
28
30
|
}
|
|
29
|
-
setQueryBalances(queryBalances) {
|
|
30
|
-
this.queryBalances = queryBalances;
|
|
31
|
-
}
|
|
32
31
|
setSender(sender) {
|
|
33
32
|
this._sender = sender;
|
|
34
33
|
}
|
|
@@ -65,8 +64,9 @@ class AmountConfig extends chain_1.TxChainSetter {
|
|
|
65
64
|
get amount() {
|
|
66
65
|
var _a;
|
|
67
66
|
if (this.fraction != null) {
|
|
68
|
-
const balance = this.
|
|
69
|
-
.
|
|
67
|
+
const balance = this.queriesStore
|
|
68
|
+
.get(this.chainId)
|
|
69
|
+
.queryBalances.getQueryBech32Address(this.sender)
|
|
70
70
|
.getBalanceFromCurrency(this.sendCurrency);
|
|
71
71
|
const result = ((_a = this.feeConfig) === null || _a === void 0 ? void 0 : _a.fee) ? balance.sub(this.feeConfig.fee)
|
|
72
72
|
: balance;
|
|
@@ -126,7 +126,7 @@ class AmountConfig extends chain_1.TxChainSetter {
|
|
|
126
126
|
get sendableCurrencies() {
|
|
127
127
|
return this.chainInfo.currencies;
|
|
128
128
|
}
|
|
129
|
-
|
|
129
|
+
get error() {
|
|
130
130
|
const sendCurrency = this.sendCurrency;
|
|
131
131
|
if (!sendCurrency) {
|
|
132
132
|
return new Error("Currency to send not set");
|
|
@@ -150,8 +150,9 @@ class AmountConfig extends chain_1.TxChainSetter {
|
|
|
150
150
|
if (new unit_1.Dec(this.amount).lt(new unit_1.Dec(0))) {
|
|
151
151
|
return new errors_1.NegativeAmountError("Amount is negative");
|
|
152
152
|
}
|
|
153
|
-
const balance = this.
|
|
154
|
-
.
|
|
153
|
+
const balance = this.queriesStore
|
|
154
|
+
.get(this.chainId)
|
|
155
|
+
.queryBalances.getQueryBech32Address(this.sender)
|
|
155
156
|
.getBalanceFromCurrency(this.sendCurrency);
|
|
156
157
|
const balanceDec = balance.toDec();
|
|
157
158
|
if (dec.gt(balanceDec)) {
|
|
@@ -163,9 +164,6 @@ class AmountConfig extends chain_1.TxChainSetter {
|
|
|
163
164
|
__decorate([
|
|
164
165
|
mobx_1.observable.ref
|
|
165
166
|
], AmountConfig.prototype, "feeConfig", void 0);
|
|
166
|
-
__decorate([
|
|
167
|
-
mobx_1.observable.ref
|
|
168
|
-
], AmountConfig.prototype, "queryBalances", void 0);
|
|
169
167
|
__decorate([
|
|
170
168
|
mobx_1.observable
|
|
171
169
|
], AmountConfig.prototype, "_sender", void 0);
|
|
@@ -181,9 +179,6 @@ __decorate([
|
|
|
181
179
|
__decorate([
|
|
182
180
|
mobx_1.action
|
|
183
181
|
], AmountConfig.prototype, "setFeeConfig", null);
|
|
184
|
-
__decorate([
|
|
185
|
-
mobx_1.action
|
|
186
|
-
], AmountConfig.prototype, "setQueryBalances", null);
|
|
187
182
|
__decorate([
|
|
188
183
|
mobx_1.action
|
|
189
184
|
], AmountConfig.prototype, "setSender", null);
|
|
@@ -208,11 +203,15 @@ __decorate([
|
|
|
208
203
|
__decorate([
|
|
209
204
|
mobx_1.computed
|
|
210
205
|
], AmountConfig.prototype, "sendCurrency", null);
|
|
206
|
+
__decorate([
|
|
207
|
+
mobx_1.computed
|
|
208
|
+
], AmountConfig.prototype, "error", null);
|
|
211
209
|
exports.AmountConfig = AmountConfig;
|
|
212
|
-
const useAmountConfig = (chainGetter,
|
|
213
|
-
|
|
210
|
+
const useAmountConfig = (chainGetter,
|
|
211
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
212
|
+
queriesStore, chainId, sender) => {
|
|
213
|
+
const [txConfig] = react_1.useState(() => new AmountConfig(chainGetter, queriesStore, chainId, sender, undefined));
|
|
214
214
|
txConfig.setChain(chainId);
|
|
215
|
-
txConfig.setQueryBalances(queryBalances);
|
|
216
215
|
txConfig.setSender(sender);
|
|
217
216
|
return txConfig;
|
|
218
217
|
};
|
package/build/tx/amount.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"amount.js","sourceRoot":"","sources":["../../src/tx/amount.ts"],"names":[],"mappings":";;;;;;;;;AACA,mCAAwC;
|
|
1
|
+
{"version":3,"file":"amount.js","sourceRoot":"","sources":["../../src/tx/amount.ts"],"names":[],"mappings":";;;;;;;;;AACA,mCAAwC;AAMxC,+BAAoE;AAEpE,qCAMkB;AAClB,6CAAmD;AACnD,iCAAiC;AAEjC,MAAa,YAAa,SAAQ,qBAAa;IAgB7C,YACE,WAAwB;IACxB,wDAAwD;IACrC,YAA+B,EAClD,cAAsB,EACtB,MAAc,EACd,SAAiC;QAEjC,KAAK,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;QALhB,iBAAY,GAAZ,YAAY,CAAmB;QAX1C,kBAAa,GAAiB,SAAS,CAAC;QAMxC,cAAS,GAAuB,SAAS,CAAC;QAYlD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAElB,qBAAc,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC;IAGD,YAAY,CAAC,SAAqB;QAChC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAGD,SAAS,CAAC,MAAc;QACtB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAGD,eAAe,CAAC,QAAiC;QAC/C,IAAI,CAAC,aAAa,GAAG,QAAQ,CAAC;IAChC,CAAC;IAGD,SAAS,CAAC,MAAc;QACtB,IAAI,MAAM,CAAC,UAAU,CAAC,GAAG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Getter } from "@keplr-wallet/stores";
|
|
2
|
-
import {
|
|
3
|
-
import { AmountConfig } from "./index";
|
|
1
|
+
import { ChainGetter, IAccountStore, IQueriesStore, MsgOpt } from "@keplr-wallet/stores";
|
|
2
|
+
import { AmountConfig, GasConfig } from "./index";
|
|
4
3
|
import { AppCurrency } from "@keplr-wallet/types";
|
|
5
4
|
export declare class DelegateAmountConfig extends AmountConfig {
|
|
6
5
|
get sendableCurrencies(): AppCurrency[];
|
|
7
6
|
}
|
|
8
|
-
export declare
|
|
9
|
-
|
|
7
|
+
export declare class DelegateGasConfig extends GasConfig {
|
|
8
|
+
protected readonly accountStore: IAccountStore<{
|
|
9
|
+
cosmos: {
|
|
10
|
+
readonly msgOpts: {
|
|
11
|
+
readonly delegate: MsgOpt;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
}>;
|
|
15
|
+
constructor(chainGetter: ChainGetter, accountStore: IAccountStore<{
|
|
16
|
+
cosmos: {
|
|
17
|
+
readonly msgOpts: {
|
|
18
|
+
readonly delegate: MsgOpt;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
}>, initialChainId: string);
|
|
22
|
+
get gas(): number;
|
|
23
|
+
}
|
|
24
|
+
export declare const useDelegateAmountConfig: (chainGetter: ChainGetter, queriesStore: IQueriesStore<{}>, chainId: string, sender: string) => DelegateAmountConfig;
|
|
25
|
+
export declare const useDelegateGasConfig: (chainGetter: ChainGetter, accountStore: IAccountStore<{
|
|
26
|
+
cosmos: {
|
|
27
|
+
readonly msgOpts: {
|
|
28
|
+
readonly delegate: MsgOpt;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
}>, chainId: string) => DelegateGasConfig;
|
|
32
|
+
export declare const useDelegateTxConfig: (chainGetter: ChainGetter, queriesStore: IQueriesStore<{}>, accountStore: IAccountStore<{
|
|
33
|
+
cosmos: {
|
|
34
|
+
readonly msgOpts: {
|
|
35
|
+
readonly delegate: MsgOpt;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
}>, chainId: string, sender: string, ensEndpoint?: string | undefined) => {
|
|
10
39
|
amountConfig: DelegateAmountConfig;
|
|
11
40
|
memoConfig: import("./memo").MemoConfig;
|
|
12
|
-
gasConfig:
|
|
41
|
+
gasConfig: DelegateGasConfig;
|
|
13
42
|
feeConfig: import("./fee").FeeConfig;
|
|
14
43
|
recipientConfig: import("./recipient").RecipientConfig;
|
|
15
44
|
};
|