@cheqd/sdk-esm 5.3.7 → 5.4.0-develop.2
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/cjs/src/index.d.ts +142 -0
- package/build/cjs/src/index.d.ts.map +1 -0
- package/build/cjs/src/index.js +184 -0
- package/build/cjs/src/index.js.map +1 -0
- package/build/cjs/src/modules/_.d.ts +81 -0
- package/build/cjs/src/modules/_.d.ts.map +1 -0
- package/build/cjs/src/modules/_.js +93 -0
- package/build/cjs/src/modules/_.js.map +1 -0
- package/build/cjs/src/modules/did.d.ts +488 -0
- package/build/cjs/src/modules/did.d.ts.map +1 -0
- package/build/cjs/src/modules/did.js +1255 -0
- package/build/cjs/src/modules/did.js.map +1 -0
- package/build/cjs/src/modules/feeabstraction.d.ts +429 -0
- package/build/cjs/src/modules/feeabstraction.d.ts.map +1 -0
- package/build/cjs/src/modules/feeabstraction.js +474 -0
- package/build/cjs/src/modules/feeabstraction.js.map +1 -0
- package/build/cjs/src/modules/feemarket.d.ts +244 -0
- package/build/cjs/src/modules/feemarket.d.ts.map +1 -0
- package/build/cjs/src/modules/feemarket.js +297 -0
- package/build/cjs/src/modules/feemarket.js.map +1 -0
- package/build/cjs/src/modules/oracle.d.ts +563 -0
- package/build/cjs/src/modules/oracle.d.ts.map +1 -0
- package/build/cjs/src/modules/oracle.js +784 -0
- package/build/cjs/src/modules/oracle.js.map +1 -0
- package/build/cjs/src/modules/resource.d.ts +330 -0
- package/build/cjs/src/modules/resource.d.ts.map +1 -0
- package/build/cjs/src/modules/resource.js +556 -0
- package/build/cjs/src/modules/resource.js.map +1 -0
- package/build/cjs/src/querier.d.ts +62 -0
- package/build/cjs/src/querier.d.ts.map +1 -0
- package/build/cjs/src/querier.js +87 -0
- package/build/cjs/src/querier.js.map +1 -0
- package/build/cjs/src/registry.d.ts +18 -0
- package/build/cjs/src/registry.d.ts.map +1 -0
- package/build/cjs/src/registry.js +23 -0
- package/build/cjs/src/registry.js.map +1 -0
- package/build/cjs/src/signer.d.ts +250 -0
- package/build/cjs/src/signer.d.ts.map +1 -0
- package/build/cjs/src/signer.js +617 -0
- package/build/cjs/src/signer.js.map +1 -0
- package/build/cjs/src/types.d.ts +221 -0
- package/build/cjs/src/types.d.ts.map +1 -0
- package/build/cjs/src/types.js.map +1 -0
- package/build/cjs/src/utils.d.ts +233 -0
- package/build/cjs/src/utils.d.ts.map +1 -0
- package/build/cjs/src/utils.js +571 -0
- package/build/cjs/src/utils.js.map +1 -0
- package/build/{index.d.ts → esm/src/index.d.ts} +7 -3
- package/build/esm/src/index.d.ts.map +1 -0
- package/build/{index.js → esm/src/index.js} +3 -1
- package/build/esm/src/index.js.map +1 -0
- package/build/esm/src/modules/_.d.ts.map +1 -0
- package/build/esm/src/modules/_.js.map +1 -0
- package/build/{modules → esm/src/modules}/did.d.ts +109 -7
- package/build/esm/src/modules/did.d.ts.map +1 -0
- package/build/{modules → esm/src/modules}/did.js +220 -8
- package/build/esm/src/modules/did.js.map +1 -0
- package/build/esm/src/modules/feeabstraction.d.ts.map +1 -0
- package/build/esm/src/modules/feeabstraction.js.map +1 -0
- package/build/esm/src/modules/feemarket.d.ts.map +1 -0
- package/build/esm/src/modules/feemarket.js.map +1 -0
- package/build/esm/src/modules/oracle.d.ts +563 -0
- package/build/esm/src/modules/oracle.d.ts.map +1 -0
- package/build/esm/src/modules/oracle.js +784 -0
- package/build/esm/src/modules/oracle.js.map +1 -0
- package/build/{modules → esm/src/modules}/resource.d.ts +132 -6
- package/build/esm/src/modules/resource.d.ts.map +1 -0
- package/build/esm/src/modules/resource.js +556 -0
- package/build/esm/src/modules/resource.js.map +1 -0
- package/build/esm/src/querier.d.ts.map +1 -0
- package/build/esm/src/querier.js.map +1 -0
- package/build/esm/src/registry.d.ts.map +1 -0
- package/build/esm/src/registry.js.map +1 -0
- package/build/esm/src/signer.d.ts.map +1 -0
- package/build/esm/src/signer.js.map +1 -0
- package/build/{types → esm/src}/types.d.ts +27 -1
- package/build/esm/src/types.d.ts.map +1 -0
- package/build/esm/src/types.js +43 -0
- package/build/esm/src/types.js.map +1 -0
- package/build/esm/src/utils.d.ts.map +1 -0
- package/build/esm/src/utils.js.map +1 -0
- package/build/types/cjs/src/index.d.ts +142 -0
- package/build/types/cjs/src/index.d.ts.map +1 -0
- package/build/types/cjs/src/modules/_.d.ts +81 -0
- package/build/types/cjs/src/modules/_.d.ts.map +1 -0
- package/build/types/cjs/src/modules/did.d.ts +488 -0
- package/build/types/cjs/src/modules/did.d.ts.map +1 -0
- package/build/types/cjs/src/modules/feeabstraction.d.ts +429 -0
- package/build/types/cjs/src/modules/feeabstraction.d.ts.map +1 -0
- package/build/types/cjs/src/modules/feemarket.d.ts +244 -0
- package/build/types/cjs/src/modules/feemarket.d.ts.map +1 -0
- package/build/types/cjs/src/modules/oracle.d.ts +563 -0
- package/build/types/cjs/src/modules/oracle.d.ts.map +1 -0
- package/build/types/cjs/src/modules/resource.d.ts +330 -0
- package/build/types/cjs/src/modules/resource.d.ts.map +1 -0
- package/build/types/cjs/src/querier.d.ts +62 -0
- package/build/types/cjs/src/querier.d.ts.map +1 -0
- package/build/types/cjs/src/registry.d.ts +18 -0
- package/build/types/cjs/src/registry.d.ts.map +1 -0
- package/build/types/cjs/src/signer.d.ts +250 -0
- package/build/types/cjs/src/signer.d.ts.map +1 -0
- package/build/types/cjs/src/types.d.ts +221 -0
- package/build/types/cjs/src/types.d.ts.map +1 -0
- package/build/types/cjs/src/utils.d.ts +233 -0
- package/build/types/cjs/src/utils.d.ts.map +1 -0
- package/build/types/{index.d.ts → esm/src/index.d.ts} +7 -3
- package/build/types/esm/src/index.d.ts.map +1 -0
- package/build/types/esm/src/modules/_.d.ts.map +1 -0
- package/build/types/{modules → esm/src/modules}/did.d.ts +109 -7
- package/build/types/esm/src/modules/did.d.ts.map +1 -0
- package/build/types/esm/src/modules/feeabstraction.d.ts.map +1 -0
- package/build/types/esm/src/modules/feemarket.d.ts.map +1 -0
- package/build/types/esm/src/modules/oracle.d.ts +563 -0
- package/build/types/esm/src/modules/oracle.d.ts.map +1 -0
- package/build/types/{modules → esm/src/modules}/resource.d.ts +132 -6
- package/build/types/esm/src/modules/resource.d.ts.map +1 -0
- package/build/types/esm/src/querier.d.ts.map +1 -0
- package/build/types/esm/src/registry.d.ts.map +1 -0
- package/build/types/esm/src/signer.d.ts.map +1 -0
- package/build/{types.d.ts → types/esm/src/types.d.ts} +27 -1
- package/build/types/esm/src/types.d.ts.map +1 -0
- package/build/types/esm/src/utils.d.ts.map +1 -0
- package/package.json +2 -2
- package/build/index.d.ts.map +0 -1
- package/build/index.js.map +0 -1
- package/build/modules/_.d.ts.map +0 -1
- package/build/modules/_.js.map +0 -1
- package/build/modules/did.d.ts.map +0 -1
- package/build/modules/did.js.map +0 -1
- package/build/modules/feeabstraction.d.ts.map +0 -1
- package/build/modules/feeabstraction.js.map +0 -1
- package/build/modules/feemarket.d.ts.map +0 -1
- package/build/modules/feemarket.js.map +0 -1
- package/build/modules/resource.d.ts.map +0 -1
- package/build/modules/resource.js +0 -297
- package/build/modules/resource.js.map +0 -1
- package/build/querier.d.ts.map +0 -1
- package/build/querier.js.map +0 -1
- package/build/registry.d.ts.map +0 -1
- package/build/registry.js.map +0 -1
- package/build/signer.d.ts.map +0 -1
- package/build/signer.js.map +0 -1
- package/build/types/index.d.ts.map +0 -1
- package/build/types/modules/_.d.ts.map +0 -1
- package/build/types/modules/did.d.ts.map +0 -1
- package/build/types/modules/feeabstraction.d.ts.map +0 -1
- package/build/types/modules/feemarket.d.ts.map +0 -1
- package/build/types/modules/resource.d.ts.map +0 -1
- package/build/types/querier.d.ts.map +0 -1
- package/build/types/registry.d.ts.map +0 -1
- package/build/types/signer.d.ts.map +0 -1
- package/build/types/types.d.ts.map +0 -1
- package/build/types/utils.d.ts.map +0 -1
- package/build/types.d.ts.map +0 -1
- package/build/types.js.map +0 -1
- package/build/utils.d.ts.map +0 -1
- package/build/utils.js.map +0 -1
- /package/build/{types.js → cjs/src/types.js} +0 -0
- /package/build/{modules → esm/src/modules}/_.d.ts +0 -0
- /package/build/{modules → esm/src/modules}/_.js +0 -0
- /package/build/{modules → esm/src/modules}/feeabstraction.d.ts +0 -0
- /package/build/{modules → esm/src/modules}/feeabstraction.js +0 -0
- /package/build/{modules → esm/src/modules}/feemarket.d.ts +0 -0
- /package/build/{modules → esm/src/modules}/feemarket.js +0 -0
- /package/build/{querier.d.ts → esm/src/querier.d.ts} +0 -0
- /package/build/{querier.js → esm/src/querier.js} +0 -0
- /package/build/{registry.d.ts → esm/src/registry.d.ts} +0 -0
- /package/build/{registry.js → esm/src/registry.js} +0 -0
- /package/build/{signer.d.ts → esm/src/signer.d.ts} +0 -0
- /package/build/{signer.js → esm/src/signer.js} +0 -0
- /package/build/{types → esm/src}/utils.d.ts +0 -0
- /package/build/{utils.js → esm/src/utils.js} +0 -0
- /package/build/types/{modules → esm/src/modules}/_.d.ts +0 -0
- /package/build/types/{modules → esm/src/modules}/feeabstraction.d.ts +0 -0
- /package/build/types/{modules → esm/src/modules}/feemarket.d.ts +0 -0
- /package/build/types/{querier.d.ts → esm/src/querier.d.ts} +0 -0
- /package/build/types/{registry.d.ts → esm/src/registry.d.ts} +0 -0
- /package/build/types/{signer.d.ts → esm/src/signer.d.ts} +0 -0
- /package/build/{utils.d.ts → types/esm/src/utils.d.ts} +0 -0
|
@@ -0,0 +1,784 @@
|
|
|
1
|
+
import { protobufPackage, QueryClientImpl, MsgAggregateExchangeRatePrevote, MsgAggregateExchangeRatePrevoteResponse, MsgAggregateExchangeRateVote, MsgDelegateFeedConsent, MsgLegacyGovUpdateParams, MsgGovUpdateParams, MsgGovAddDenoms, MsgGovRemoveCurrencyPairProviders, MsgGovRemoveCurrencyDeviationThresholds, MsgGovCancelUpdateParamPlan, } from '@cheqd/ts-proto/cheqd/oracle/v2';
|
|
2
|
+
import { Decimal } from '@cosmjs/math';
|
|
3
|
+
import { AbstractCheqdSDKModule } from './_';
|
|
4
|
+
import { createProtobufRpcClient } from '@cosmjs/stargate';
|
|
5
|
+
import { assert } from '@cosmjs/utils';
|
|
6
|
+
import { MsgSubmitProposal } from 'cosmjs-types/cosmos/gov/v1/tx';
|
|
7
|
+
/** Default extension key for Oracle-related query operations */
|
|
8
|
+
export const defaultOracleExtensionKey = 'oracle';
|
|
9
|
+
/**
|
|
10
|
+
* Protobuf message type for Oracle operations.
|
|
11
|
+
* Used for consistent message type identification across the module.
|
|
12
|
+
*/
|
|
13
|
+
export const protobufLiterals = {
|
|
14
|
+
/** Request to fetch exchange rates for specific denoms. */
|
|
15
|
+
QueryExchangeRates: 'QueryExchangeRates',
|
|
16
|
+
/** Response containing the exchange rates payload. */
|
|
17
|
+
QueryExchangeRatesResponse: 'QueryExchangeRatesResponse',
|
|
18
|
+
/** Request to list all active exchange rate denoms. */
|
|
19
|
+
QueryActiveExchangeRates: 'QueryActiveExchangeRates',
|
|
20
|
+
/** Response providing the currently active exchange rate denoms. */
|
|
21
|
+
QueryActiveExchangeRatesResponse: 'QueryActiveExchangeRatesResponse',
|
|
22
|
+
/** Request to retrieve the feeder delegation for a validator. */
|
|
23
|
+
QueryFeederDelegation: 'QueryFeederDelegation',
|
|
24
|
+
/** Response with feeder delegation details. */
|
|
25
|
+
QueryFeederDelegationResponse: 'QueryFeederDelegationResponse',
|
|
26
|
+
/** Request to obtain a validator's miss counter. */
|
|
27
|
+
QueryMissCounter: 'QueryMissCounter',
|
|
28
|
+
/** Response returning the miss counter value. */
|
|
29
|
+
QueryMissCounterResponse: 'QueryMissCounterResponse',
|
|
30
|
+
/** Request to inspect the current slash window information. */
|
|
31
|
+
QuerySlashWindow: 'QuerySlashWindow',
|
|
32
|
+
/** Response detailing the slash window configuration. */
|
|
33
|
+
QuerySlashWindowResponse: 'QuerySlashWindowResponse',
|
|
34
|
+
/** Request for a validator's aggregate prevote. */
|
|
35
|
+
QueryAggregatePrevote: 'QueryAggregatePrevote',
|
|
36
|
+
/** Response containing the aggregate prevote. */
|
|
37
|
+
QueryAggregatePrevoteResponse: 'QueryAggregatePrevoteResponse',
|
|
38
|
+
/** Request for all aggregate prevotes on the network. */
|
|
39
|
+
QueryAggregatePrevotes: 'QueryAggregatePrevotes',
|
|
40
|
+
/** Response listing all aggregate prevotes. */
|
|
41
|
+
QueryAggregatePrevotesResponse: 'QueryAggregatePrevotesResponse',
|
|
42
|
+
/** Request for aggregate votes from a validator. */
|
|
43
|
+
QueryAggregateVotes: 'QueryAggregateVotes',
|
|
44
|
+
/** Response carrying aggregate votes. */
|
|
45
|
+
QueryAggregateVotesResponse: 'QueryAggregateVotesResponse',
|
|
46
|
+
/** Request to fetch the oracle module parameters. */
|
|
47
|
+
QueryParams: 'QueryParams',
|
|
48
|
+
/** Response returning the oracle module parameters. */
|
|
49
|
+
QueryParamsResponse: 'QueryParamsResponse',
|
|
50
|
+
/** Request for price medians across denoms. */
|
|
51
|
+
QueryMedians: 'QueryMedians',
|
|
52
|
+
/** Response containing price medians. */
|
|
53
|
+
QueryMediansResponse: 'QueryMediansResponse',
|
|
54
|
+
/** Request for median deviations to assess volatility. */
|
|
55
|
+
QueryMedianDeviations: 'QueryMedianDeviations',
|
|
56
|
+
/** Response returning median deviation values. */
|
|
57
|
+
QueryMedianDeviationsResponse: 'QueryMedianDeviationsResponse',
|
|
58
|
+
/** Request to fetch the validator reward set. */
|
|
59
|
+
QueryValidatorRewardSet: 'QueryValidatorRewardSet',
|
|
60
|
+
/** Response with validator reward set data. */
|
|
61
|
+
QueryValidatorRewardSetResponse: 'QueryValidatorRewardSetResponse',
|
|
62
|
+
/** Request for an exponential moving average price. */
|
|
63
|
+
QueryEMARequest: 'QueryEMARequest',
|
|
64
|
+
/** Response containing exponential moving average data. */
|
|
65
|
+
QueryEMAResponse: 'QueryEMAResponse',
|
|
66
|
+
/** Request for a weighted moving average price. */
|
|
67
|
+
QueryWMARequest: 'QueryWMARequest',
|
|
68
|
+
/** Response containing weighted moving average data. */
|
|
69
|
+
QueryWMAResponse: 'QueryWMAResponse',
|
|
70
|
+
/** Request for a simple moving average price. */
|
|
71
|
+
QuerySMARequest: 'QuerySMARequest',
|
|
72
|
+
/** Response containing simple moving average data. */
|
|
73
|
+
QuerySMAResponse: 'QuerySMAResponse',
|
|
74
|
+
/** Request to convert a USDC amount into CHEQ. */
|
|
75
|
+
ConvertUSDCtoCHEQRequest: 'ConvertUSDCtoCHEQRequest',
|
|
76
|
+
/** Response returning the converted CHEQ amount. */
|
|
77
|
+
ConvertUSDCtoCHEQResponse: 'ConvertUSDCtoCHEQResponse',
|
|
78
|
+
/** Message to submit an aggregate exchange rate prevote. */
|
|
79
|
+
MsgAggregateExchangeRatePrevote: 'MsgAggregateExchangeRatePrevote',
|
|
80
|
+
/** Message that defines the MsgAggregateExchangeRatePrevote response type. */
|
|
81
|
+
MsgAggregateExchangeRatePrevoteResponse: 'MsgAggregateExchangeRatePrevoteResponse',
|
|
82
|
+
/** Message to submit an aggregate exchange rate vote. */
|
|
83
|
+
MsgAggregateExchangeRateVote: 'MsgAggregateExchangeRateVote',
|
|
84
|
+
/** Message that defines the MsgAggregateExchangeRateVote response type. */
|
|
85
|
+
MsgAggregateExchangeRateVoteResponse: 'MsgAggregateExchangeRateVoteResponse',
|
|
86
|
+
/** Message to delegate oracle voting rights to another address. */
|
|
87
|
+
MsgDelegateFeedConsent: 'MsgDelegateFeedConsent',
|
|
88
|
+
/** Message that defines the MsgDelegateFeedConsent response type. */
|
|
89
|
+
MsgDelegateFeedConsentResponse: 'MsgDelegateFeedConsentResponse',
|
|
90
|
+
/** Message that defines the MsgLegacyGovUpdateParams request type. */
|
|
91
|
+
MsgLegacyGovUpdateParams: 'MsgLegacyGovUpdateParams',
|
|
92
|
+
/** Message that defines the MsgLegacyGovUpdateParams response type. */
|
|
93
|
+
MsgLegacyGovUpdateParamsResponse: 'MsgLegacyGovUpdateParamsResponse',
|
|
94
|
+
/** Message that defines the MsgGovUpdateParams request type. */
|
|
95
|
+
MsgGovUpdateParams: 'MsgGovUpdateParams',
|
|
96
|
+
/** Message that defines the MsgGovUpdateParams response type. */
|
|
97
|
+
MsgGovUpdateParamsResponse: 'MsgGovUpdateParamsResponse',
|
|
98
|
+
/** Message that defines the MsgGovAddDenoms request type. */
|
|
99
|
+
MsgGovAddDenoms: 'MsgGovAddDenoms',
|
|
100
|
+
/** Message that defines the MsgGovAddDenoms response type. */
|
|
101
|
+
MsgGovAddDenomsResponse: 'MsgGovAddDenomsResponse',
|
|
102
|
+
/** Message that defines the MsgGovRemoveCurrencyPairProviders request type. */
|
|
103
|
+
MsgGovRemoveCurrencyPairProviders: 'MsgGovRemoveCurrencyPairProviders',
|
|
104
|
+
/** Message that defines the MsgGovRemoveCurrencyPairProviders response type. */
|
|
105
|
+
MsgGovRemoveCurrencyPairProvidersResponse: 'MsgGovRemoveCurrencyPairProvidersResponse',
|
|
106
|
+
/** Message that defines the MsgGovRemoveCurrencyDeviationThresholds request type. */
|
|
107
|
+
MsgGovRemoveCurrencyDeviationThresholds: 'MsgGovRemoveCurrencyDeviationThresholds',
|
|
108
|
+
/** Message that defines the MsgGovRemoveCurrencyDeviationThresholds response type. */
|
|
109
|
+
MsgGovRemoveCurrencyDeviationThresholdsResponse: 'MsgGovRemoveCurrencyDeviationThresholdsResponse',
|
|
110
|
+
/** Message that defines the MsgGovCancelUpdateParamPlan request type. */
|
|
111
|
+
MsgGovCancelUpdateParamPlan: 'MsgGovCancelUpdateParamPlan',
|
|
112
|
+
/** Message that defines the MsgGovCancelUpdateParamPlan response type. */
|
|
113
|
+
MsgGovCancelUpdateParamPlanResponse: 'MsgGovCancelUpdateParamPlanResponse',
|
|
114
|
+
};
|
|
115
|
+
/** Type URL for MsgAggregateExchangeRatePrevote messages */
|
|
116
|
+
export const typeUrlMsgAggregateExchangeRatePrevote = `/${protobufPackage}.MsgAggregateExchangeRatePrevote`;
|
|
117
|
+
/** Type URL for MsgAggregateExchangeRatePrevoteResponse messages */
|
|
118
|
+
export const typeUrlMsgAggregateExchangeRatePrevoteResponse = `/${protobufPackage}.MsgAggregateExchangeRatePrevoteResponse`;
|
|
119
|
+
/** Type URL for MsgAggregateExchangeRateVote messages */
|
|
120
|
+
export const typeUrlMsgAggregateExchangeRateVote = `/${protobufPackage}.MsgAggregateExchangeRateVote`;
|
|
121
|
+
/** Type URL for MsgAggregateExchangeRateVoteResponse messages */
|
|
122
|
+
export const typeUrlMsgAggregateExchangeRateVoteResponse = `/${protobufPackage}.MsgAggregateExchangeRateVoteResponse`;
|
|
123
|
+
/** Type URL for MsgDelegateFeedConsent messages */
|
|
124
|
+
export const typeUrlMsgDelegateFeedConsent = `/${protobufPackage}.MsgDelegateFeedConsent`;
|
|
125
|
+
/** Type URL for MsgDelegateFeedConsentResponse messages */
|
|
126
|
+
export const typeUrlMsgDelegateFeedConsentResponse = `/${protobufPackage}.MsgDelegateFeedConsentResponse`;
|
|
127
|
+
/** Type URL for MsgLegacyGovUpdateParams messages */
|
|
128
|
+
export const typeUrlMsgLegacyGovUpdateParams = `/${protobufPackage}.MsgLegacyGovUpdateParams`;
|
|
129
|
+
/** Type URL for MsgLegacyGovUpdateParamsResponse messages */
|
|
130
|
+
export const typeUrlMsgLegacyGovUpdateParamsResponse = `/${protobufPackage}.MsgLegacyGovUpdateParamsResponse`;
|
|
131
|
+
/** Type URL for MsgGovUpdateParams messages */
|
|
132
|
+
export const typeUrlMsgGovUpdateParams = `/${protobufPackage}.MsgGovUpdateParams`;
|
|
133
|
+
/** Type URL for MsgGovUpdateParamsResponse messages */
|
|
134
|
+
export const typeUrlMsgGovUpdateParamsResponse = `/${protobufPackage}.MsgGovUpdateParamsResponse`;
|
|
135
|
+
/** Type URL for MsgGovAddDenoms messages */
|
|
136
|
+
export const typeUrlMsgGovAddDenoms = `/${protobufPackage}.MsgGovAddDenoms`;
|
|
137
|
+
/** Type URL for MsgGovAddDenomsResponse messages */
|
|
138
|
+
export const typeUrlMsgGovAddDenomsResponse = `/${protobufPackage}.MsgGovAddDenomsResponse`;
|
|
139
|
+
/** Type URL for MsgGovRemoveCurrencyPairProviders messages */
|
|
140
|
+
export const typeUrlMsgGovRemoveCurrencyPairProviders = `/${protobufPackage}.MsgGovRemoveCurrencyPairProviders`;
|
|
141
|
+
/** Type URL for MsgGovRemoveCurrencyPairProvidersResponse messages */
|
|
142
|
+
export const typeUrlMsgGovRemoveCurrencyPairProvidersResponse = `/${protobufPackage}.MsgGovRemoveCurrencyPairProvidersResponse`;
|
|
143
|
+
/** Type URL for MsgGovRemoveCurrencyDeviationThresholds messages */
|
|
144
|
+
export const typeUrlMsgGovRemoveCurrencyDeviationThresholds = `/${protobufPackage}.MsgGovRemoveCurrencyDeviationThresholds`;
|
|
145
|
+
/** Type URL for MsgGovRemoveCurrencyDeviationThresholdsResponse messages */
|
|
146
|
+
export const typeUrlMsgGovRemoveCurrencyDeviationThresholdsResponse = `/${protobufPackage}.MsgGovRemoveCurrencyDeviationThresholdsResponse`;
|
|
147
|
+
/** Type URL for MsgGovCancelUpdateParamPlan messages */
|
|
148
|
+
export const typeUrlMsgGovCancelUpdateParamPlan = `/${protobufPackage}.MsgGovCancelUpdateParamPlan`;
|
|
149
|
+
/** Type URL for MsgGovCancelUpdateParamPlanResponse messages */
|
|
150
|
+
export const typeUrlMsgGovCancelUpdateParamPlanResponse = `/${protobufPackage}.MsgGovCancelUpdateParamPlanResponse`;
|
|
151
|
+
/**
|
|
152
|
+
* Type guard function to check if an object is a MsgAggregateExchangeRatePrevoteEncodeObject
|
|
153
|
+
* @param obj - EncodeObject to check
|
|
154
|
+
* @returns True if the object is a MsgAggregateExchangeRatePrevoteEncodeObject, false otherwise
|
|
155
|
+
*/
|
|
156
|
+
export function isMsgAggregateExchangeRatePrevoteEncodeObject(obj) {
|
|
157
|
+
return obj.typeUrl === typeUrlMsgAggregateExchangeRatePrevote;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Type guard function to check if an object is a MsgAggregateExchangeRateVoteEncodeObject
|
|
161
|
+
* @param obj - EncodeObject to check
|
|
162
|
+
* @returns True if the object is a MsgAggregateExchangeRateVoteEncodeObject, false otherwise
|
|
163
|
+
*/
|
|
164
|
+
export function isMsgAggregateExchangeRateVoteEncodeObject(obj) {
|
|
165
|
+
return obj.typeUrl === typeUrlMsgAggregateExchangeRateVote;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Type guard function to check if an object is a MsgDelegateFeedConsentEncodeObject
|
|
169
|
+
* @param obj - EncodeObject to check
|
|
170
|
+
* @returns True if the object is a MsgDelegateFeedConsentEncodeObject, false otherwise
|
|
171
|
+
*/
|
|
172
|
+
export function isMsgDelegateFeedConsentEncodeObject(obj) {
|
|
173
|
+
return obj.typeUrl === typeUrlMsgDelegateFeedConsent;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Type guard function to check if an object is a MsgLegacyGovUpdateParamsEncodeObject
|
|
177
|
+
* @param obj - EncodeObject to check
|
|
178
|
+
* @returns True if the object is a MsgLegacyGovUpdateParamsEncodeObject, false otherwise
|
|
179
|
+
*/
|
|
180
|
+
export function isMsgLegacyGovUpdateParamsEncodeObject(obj) {
|
|
181
|
+
return obj.typeUrl === typeUrlMsgLegacyGovUpdateParams;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Type guard function to check if an object is a MsgGovUpdateParamsEncodeObject
|
|
185
|
+
* @param obj - EncodeObject to check
|
|
186
|
+
* @returns True if the object is a MsgGovUpdateParamsEncodeObject, false otherwise
|
|
187
|
+
*/
|
|
188
|
+
export function isMsgGovUpdateParamsEncodeObject(obj) {
|
|
189
|
+
return obj.typeUrl === typeUrlMsgGovUpdateParams;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Type guard function to check if an object is a MsgGovAddDenomsEncodeObject
|
|
193
|
+
* @param obj - EncodeObject to check
|
|
194
|
+
* @returns True if the object is a MsgGovAddDenomsEncodeObject, false otherwise
|
|
195
|
+
*/
|
|
196
|
+
export function isMsgGovAddDenomsEncodeObject(obj) {
|
|
197
|
+
return obj.typeUrl === typeUrlMsgGovAddDenoms;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Type guard function to check if an object is a MsgGovRemoveCurrencyPairProvidersEncodeObject
|
|
201
|
+
* @param obj - EncodeObject to check
|
|
202
|
+
* @returns True if the object is a MsgGovRemoveCurrencyPairProvidersEncodeObject, false otherwise
|
|
203
|
+
*/
|
|
204
|
+
export function isMsgGovRemoveCurrencyPairProvidersEncodeObject(obj) {
|
|
205
|
+
return obj.typeUrl === typeUrlMsgGovRemoveCurrencyPairProviders;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Type guard function to check if an object is a MsgGovRemoveCurrencyDeviationThresholdsEncodeObject
|
|
209
|
+
* @param obj - EncodeObject to check
|
|
210
|
+
* @returns True if the object is a MsgGovRemoveCurrencyDeviationThresholdsEncodeObject, false otherwise
|
|
211
|
+
*/
|
|
212
|
+
export function isMsgGovRemoveCurrencyDeviationThresholdsEncodeObject(obj) {
|
|
213
|
+
return obj.typeUrl === typeUrlMsgGovRemoveCurrencyDeviationThresholds;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Type guard function to check if an object is a MsgGovCancelUpdateParamPlanEncodeObject
|
|
217
|
+
* @param obj - EncodeObject to check
|
|
218
|
+
* @returns True if the object is a MsgGovCancelUpdateParamPlanEncodeObject, false otherwise
|
|
219
|
+
*/
|
|
220
|
+
export function isMsgGovCancelUpdateParamPlanEncodeObject(obj) {
|
|
221
|
+
return obj.typeUrl === typeUrlMsgGovCancelUpdateParamPlan;
|
|
222
|
+
}
|
|
223
|
+
/** Enumeration of WMA strategies */
|
|
224
|
+
export const WMAStrategies = {
|
|
225
|
+
/** Balanced (linear) strategy */
|
|
226
|
+
BALANCED: 'BALANCED',
|
|
227
|
+
/** Recent (weighted) strategy */
|
|
228
|
+
RECENT: 'RECENT',
|
|
229
|
+
/** Oldest (weighted) strategy */
|
|
230
|
+
OLDEST: 'OLDEST',
|
|
231
|
+
/** Custom weights strategy */
|
|
232
|
+
CUSTOM: 'CUSTOM',
|
|
233
|
+
};
|
|
234
|
+
/** Enumeration of moving averages */
|
|
235
|
+
export const MovingAverages = {
|
|
236
|
+
/** Exponential Moving Average */
|
|
237
|
+
EMA: 'ema',
|
|
238
|
+
/** Weighted Moving Average */
|
|
239
|
+
WMA: 'wma',
|
|
240
|
+
/** Simple Moving Average */
|
|
241
|
+
SMA: 'sma',
|
|
242
|
+
};
|
|
243
|
+
/** Sets up the Oracle extension for the querier client.
|
|
244
|
+
* Creates and configures the Oracle-specific query methods.
|
|
245
|
+
* @param base - Base QueryClient to extend
|
|
246
|
+
* @returns Configured Oracle extension with query methods
|
|
247
|
+
*/
|
|
248
|
+
export const setupOracleExtension = (base) => {
|
|
249
|
+
const rpc = createProtobufRpcClient(base);
|
|
250
|
+
const queryService = new QueryClientImpl(rpc);
|
|
251
|
+
return {
|
|
252
|
+
[defaultOracleExtensionKey]: {
|
|
253
|
+
queryExchangeRates: async (denom = '') => {
|
|
254
|
+
const response = await queryService.ExchangeRates({ denom });
|
|
255
|
+
assert(response.exchangeRates, 'Expected exchangeRates in response');
|
|
256
|
+
return response;
|
|
257
|
+
},
|
|
258
|
+
queryActiveExchangeRates: async () => {
|
|
259
|
+
const response = await queryService.ActiveExchangeRates({});
|
|
260
|
+
assert(response.activeRates, 'Expected activeRates in response');
|
|
261
|
+
return response;
|
|
262
|
+
},
|
|
263
|
+
queryFeederDelegation: async (validatorAddr) => {
|
|
264
|
+
const response = await queryService.FeederDelegation({ validatorAddr });
|
|
265
|
+
assert(response.feederAddr, 'Expected feederAddr in response');
|
|
266
|
+
return response;
|
|
267
|
+
},
|
|
268
|
+
queryMissCounter: async (validatorAddr) => {
|
|
269
|
+
const response = await queryService.MissCounter({ validatorAddr });
|
|
270
|
+
assert(response.missCounter, 'Expected missCounter in response');
|
|
271
|
+
return response;
|
|
272
|
+
},
|
|
273
|
+
querySlashWindow: async () => {
|
|
274
|
+
const response = await queryService.SlashWindow({});
|
|
275
|
+
assert(response.windowProgress, 'Expected windowProgress in response');
|
|
276
|
+
return response;
|
|
277
|
+
},
|
|
278
|
+
queryAggregatePrevote: async (validatorAddr) => {
|
|
279
|
+
const response = await queryService.AggregatePrevote({ validatorAddr });
|
|
280
|
+
assert(response.aggregatePrevote, 'Expected aggregatePrevote in response');
|
|
281
|
+
return response;
|
|
282
|
+
},
|
|
283
|
+
queryAggregatePrevotes: async () => {
|
|
284
|
+
const response = await queryService.AggregatePrevotes({});
|
|
285
|
+
assert(response.aggregatePrevotes, 'Expected aggregatePrevotes in response');
|
|
286
|
+
return response;
|
|
287
|
+
},
|
|
288
|
+
queryAggregateVote: async (validatorAddr) => {
|
|
289
|
+
const response = await queryService.AggregateVote({ validatorAddr });
|
|
290
|
+
assert(response.aggregateVote, 'Expected aggregateVote in response');
|
|
291
|
+
return response;
|
|
292
|
+
},
|
|
293
|
+
queryAggregateVotes: async (validatorAddr) => {
|
|
294
|
+
const response = await queryService.AggregateVotes({ validatorAddr });
|
|
295
|
+
assert(response.aggregateVotes, 'Expected aggregateVotes in response');
|
|
296
|
+
return response;
|
|
297
|
+
},
|
|
298
|
+
queryParams: async () => {
|
|
299
|
+
const response = await queryService.Params({});
|
|
300
|
+
assert(response.params, 'Expected params in response');
|
|
301
|
+
return response;
|
|
302
|
+
},
|
|
303
|
+
queryMedians: async (denom, numStamps) => {
|
|
304
|
+
const response = await queryService.Medians({ denom, numStamps });
|
|
305
|
+
assert(response.medians, 'Expected medians in response');
|
|
306
|
+
return response;
|
|
307
|
+
},
|
|
308
|
+
queryMedianDeviations: async (denom) => {
|
|
309
|
+
const response = await queryService.MedianDeviations({ denom });
|
|
310
|
+
assert(response.medianDeviations, 'Expected medianDeviations in response');
|
|
311
|
+
return response;
|
|
312
|
+
},
|
|
313
|
+
queryValidatorRewardSet: async () => {
|
|
314
|
+
const response = await queryService.ValidatorRewardSet({});
|
|
315
|
+
assert(response.validators, 'Expected validators in response');
|
|
316
|
+
return response;
|
|
317
|
+
},
|
|
318
|
+
queryEMA: async (denom) => {
|
|
319
|
+
const response = await queryService.EMA({ denom });
|
|
320
|
+
assert(response.price, 'Expected price in response');
|
|
321
|
+
return response;
|
|
322
|
+
},
|
|
323
|
+
queryWMA: async (denom, strategy = WMAStrategies.BALANCED, weights = []) => {
|
|
324
|
+
const response = await queryService.WMA({ denom, strategy, customWeights: weights });
|
|
325
|
+
assert(response.price, 'Expected price in response');
|
|
326
|
+
return response;
|
|
327
|
+
},
|
|
328
|
+
querySMA: async (denom) => {
|
|
329
|
+
const response = await queryService.SMA({ denom });
|
|
330
|
+
assert(response.price, 'Expected price in response');
|
|
331
|
+
return response;
|
|
332
|
+
},
|
|
333
|
+
convertUSDtoCHEQ: async (usdAmount, movingAverage, wmaStrategy = WMAStrategies.BALANCED, weights = []) => {
|
|
334
|
+
const response = await queryService.ConvertUSDCtoCHEQ({
|
|
335
|
+
amount: `${usdAmount}usd`,
|
|
336
|
+
maType: movingAverage,
|
|
337
|
+
wmaStrategy,
|
|
338
|
+
customWeights: weights.map((w) => Number(w)),
|
|
339
|
+
});
|
|
340
|
+
assert(response.amount, 'Expected amount in response');
|
|
341
|
+
return response;
|
|
342
|
+
},
|
|
343
|
+
},
|
|
344
|
+
};
|
|
345
|
+
};
|
|
346
|
+
/**
|
|
347
|
+
* Oracle Module class providing comprehensive access to Oracle functionalities.
|
|
348
|
+
* Handles both querying and transaction operations related to the Oracle module.
|
|
349
|
+
*/
|
|
350
|
+
export class OracleModule extends AbstractCheqdSDKModule {
|
|
351
|
+
// @ts-expect-error underlying type `GeneratedType` is intentionally wider
|
|
352
|
+
static registryTypes = [
|
|
353
|
+
[typeUrlMsgAggregateExchangeRatePrevote, MsgAggregateExchangeRatePrevote],
|
|
354
|
+
[typeUrlMsgAggregateExchangeRatePrevoteResponse, MsgAggregateExchangeRatePrevoteResponse],
|
|
355
|
+
[typeUrlMsgAggregateExchangeRateVote, MsgAggregateExchangeRateVote],
|
|
356
|
+
[typeUrlMsgDelegateFeedConsent, MsgDelegateFeedConsent],
|
|
357
|
+
[typeUrlMsgLegacyGovUpdateParams, MsgLegacyGovUpdateParams],
|
|
358
|
+
[typeUrlMsgGovUpdateParams, MsgGovUpdateParams],
|
|
359
|
+
[typeUrlMsgGovAddDenoms, MsgGovAddDenoms],
|
|
360
|
+
[typeUrlMsgGovRemoveCurrencyPairProviders, MsgGovRemoveCurrencyPairProviders],
|
|
361
|
+
[typeUrlMsgGovRemoveCurrencyDeviationThresholds, MsgGovRemoveCurrencyDeviationThresholds],
|
|
362
|
+
[typeUrlMsgGovCancelUpdateParamPlan, MsgGovCancelUpdateParamPlan],
|
|
363
|
+
];
|
|
364
|
+
/** Base denomination tickers for Cheqd network Oracle */
|
|
365
|
+
static baseDenomTickers = {
|
|
366
|
+
CHEQ: 'CHEQ',
|
|
367
|
+
USDC: 'USDC',
|
|
368
|
+
USDT: 'USDT',
|
|
369
|
+
};
|
|
370
|
+
/** Querier extension setup function for Oracle operations */
|
|
371
|
+
static querierExtensionSetup = setupOracleExtension;
|
|
372
|
+
/** Querier instance with Oracle extension capabilities */
|
|
373
|
+
querier;
|
|
374
|
+
/**
|
|
375
|
+
* Constructs a new Oracle module instance.
|
|
376
|
+
*
|
|
377
|
+
* @param signer - Signing client for blockchain transactions
|
|
378
|
+
* @param querier - Querier client with Oracle extension for data retrieval
|
|
379
|
+
*/
|
|
380
|
+
constructor(signer, querier) {
|
|
381
|
+
super(signer, querier);
|
|
382
|
+
this.querier = querier;
|
|
383
|
+
this.methods = {
|
|
384
|
+
aggregateExchangeRatePrevoteTx: this.aggregateExchangeRatePrevoteTx.bind(this),
|
|
385
|
+
aggregateExchangeRateVoteTx: this.aggregateExchangeRateVoteTx.bind(this),
|
|
386
|
+
delegateFeedConsentTx: this.delegateFeedConsentTx.bind(this),
|
|
387
|
+
legacyGovUpdateParamsTx: this.legacyGovUpdateParamsTx.bind(this),
|
|
388
|
+
govUpdateParamsTx: this.govUpdateParamsTx.bind(this),
|
|
389
|
+
govAddDenomsTx: this.govAddDenomsTx.bind(this),
|
|
390
|
+
govRemoveCurrencyPairProvidersTx: this.govRemoveCurrencyPairProvidersTx.bind(this),
|
|
391
|
+
govRemoveCurrencyDeviationThresholdsTx: this.govRemoveCurrencyDeviationThresholdsTx.bind(this),
|
|
392
|
+
govCancelUpdateParamPlanTx: this.govCancelUpdateParamPlanTx.bind(this),
|
|
393
|
+
queryExchangeRates: this.querier[defaultOracleExtensionKey].queryExchangeRates.bind(this),
|
|
394
|
+
queryActiveExchangeRates: this.querier[defaultOracleExtensionKey].queryActiveExchangeRates.bind(this),
|
|
395
|
+
queryFeederDelegation: this.querier[defaultOracleExtensionKey].queryFeederDelegation.bind(this),
|
|
396
|
+
queryMissCounter: this.querier[defaultOracleExtensionKey].queryMissCounter.bind(this),
|
|
397
|
+
querySlashWindow: this.querier[defaultOracleExtensionKey].querySlashWindow.bind(this),
|
|
398
|
+
queryAggregatePrevote: this.querier[defaultOracleExtensionKey].queryAggregatePrevote.bind(this),
|
|
399
|
+
queryAggregatePrevotes: this.querier[defaultOracleExtensionKey].queryAggregatePrevotes.bind(this),
|
|
400
|
+
queryAggregateVote: this.querier[defaultOracleExtensionKey].queryAggregateVote.bind(this),
|
|
401
|
+
queryAggregateVotes: this.querier[defaultOracleExtensionKey].queryAggregateVotes.bind(this),
|
|
402
|
+
queryParams: this.querier[defaultOracleExtensionKey].queryParams.bind(this),
|
|
403
|
+
queryMedians: this.querier[defaultOracleExtensionKey].queryMedians.bind(this),
|
|
404
|
+
queryMedianDeviations: this.querier[defaultOracleExtensionKey].queryMedianDeviations.bind(this),
|
|
405
|
+
queryValidatorRewardSet: this.querier[defaultOracleExtensionKey].queryValidatorRewardSet.bind(this),
|
|
406
|
+
queryEMA: this.querier[defaultOracleExtensionKey].queryEMA.bind(this),
|
|
407
|
+
queryWMA: this.querier[defaultOracleExtensionKey].queryWMA.bind(this),
|
|
408
|
+
querySMA: this.querier[defaultOracleExtensionKey].querySMA.bind(this),
|
|
409
|
+
convertUSDtoCHEQ: this.querier[defaultOracleExtensionKey].convertUSDtoCHEQ.bind(this),
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* Gets the registry types for Oracle message encoding/decoding.
|
|
414
|
+
*
|
|
415
|
+
* @returns Iterable of [typeUrl, GeneratedType] pairs for the registry
|
|
416
|
+
*/
|
|
417
|
+
getRegistryTypes() {
|
|
418
|
+
return OracleModule.registryTypes;
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Gets the querier extension setup for Oracle operations.
|
|
422
|
+
*
|
|
423
|
+
* @returns Query extension setup function for Oracle functionality
|
|
424
|
+
*/
|
|
425
|
+
getQuerierExtensionSetup() {
|
|
426
|
+
return OracleModule.querierExtensionSetup;
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Queries the module parameters from the blockchain.
|
|
430
|
+
*
|
|
431
|
+
* @returns Promise resolving to the QueryParamsResponse containing module parameters
|
|
432
|
+
*/
|
|
433
|
+
async queryParams() {
|
|
434
|
+
return this.querier[defaultOracleExtensionKey].queryParams();
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Queries the exchange rate for a specific denom.
|
|
438
|
+
* @param denom - The denomination to query the exchange rate for
|
|
439
|
+
* @returns Promise resolving to the QueryExchangeRatesResponse containing the exchange rate
|
|
440
|
+
*/
|
|
441
|
+
async queryExchangeRate(denom) {
|
|
442
|
+
return this.querier[defaultOracleExtensionKey].queryExchangeRates(denom);
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Queries all active exchange rate denoms.
|
|
446
|
+
* @returns Promise resolving to the QueryActiveExchangeRatesResponse containing active denoms
|
|
447
|
+
*/
|
|
448
|
+
async queryActiveExchangeRates() {
|
|
449
|
+
return this.querier[defaultOracleExtensionKey].queryActiveExchangeRates();
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Queries the Exponential Moving Average (EMA) for a given denom.
|
|
453
|
+
* @param denom - The denomination to query the EMA for
|
|
454
|
+
* @returns Promise resolving to the QueryEMAResponse containing the EMA price in string Decimal format
|
|
455
|
+
*/
|
|
456
|
+
async queryEMA(denom) {
|
|
457
|
+
const response = await this.querier[defaultOracleExtensionKey].queryEMA(denom);
|
|
458
|
+
return {
|
|
459
|
+
price: Decimal.fromAtomics(BigInt(response.price).toString(), 18).toString(),
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* Queries the Weighted Moving Average (WMA) for a given denom.
|
|
464
|
+
* @param denom - The denomination to query the WMA for
|
|
465
|
+
* @param strategy - Optional WMA strategy, defaults to 'BALANCED'
|
|
466
|
+
* @param weights - Optional custom weights for the WMA calculation
|
|
467
|
+
* @returns Promise resolving to the QueryWMAResponse containing the WMA price in string Decimal format
|
|
468
|
+
*/
|
|
469
|
+
async queryWMA(denom, strategy, weights) {
|
|
470
|
+
const response = await this.querier[defaultOracleExtensionKey].queryWMA(denom, strategy, weights?.map((w) => BigInt(w)));
|
|
471
|
+
return {
|
|
472
|
+
price: Decimal.fromAtomics(BigInt(response.price).toString(), 18).toString(),
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Queries the Simple Moving Average (SMA) for a given denom.
|
|
477
|
+
* @param denom - The denomination to query the SMA for
|
|
478
|
+
* @returns Promise resolving to the QuerySMAResponse containing the SMA price in string Decimal format
|
|
479
|
+
*/
|
|
480
|
+
async querySMA(denom) {
|
|
481
|
+
const response = await this.querier[defaultOracleExtensionKey].querySMA(denom);
|
|
482
|
+
return {
|
|
483
|
+
price: Decimal.fromAtomics(BigInt(response.price).toString(), 18).toString(),
|
|
484
|
+
};
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Converts a USD amount to CHEQ using the specified moving average type.
|
|
488
|
+
* @param usdAmount - The USD amount to convert
|
|
489
|
+
* @param movingAverage - The type of moving average to use for conversion
|
|
490
|
+
* @param wmaStrategy - Optional WMA strategy, defaults to 'BALANCED'
|
|
491
|
+
* @param weights - Optional custom weights for WMA calculation
|
|
492
|
+
* @returns Promise resolving to the ConvertUSDCtoCHEQResponse containing the converted CHEQ amount
|
|
493
|
+
*/
|
|
494
|
+
async convertUSDtoCHEQ(usdAmount, movingAverage, wmaStrategy, weights) {
|
|
495
|
+
return this.querier[defaultOracleExtensionKey].convertUSDtoCHEQ(usdAmount, movingAverage, wmaStrategy, weights?.map((w) => BigInt(w)));
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Broadcasts an aggregate exchange rate prevote transaction.
|
|
499
|
+
*
|
|
500
|
+
* @param payload - Message payload describing the prevote
|
|
501
|
+
* @param address - Address responsible for paying the transaction fees
|
|
502
|
+
* @param fee - Optional fee configuration, defaults to automatic calculation
|
|
503
|
+
* @param memo - Optional transaction memo
|
|
504
|
+
* @param context - Optional SDK context to lazily resolve signer or wallet
|
|
505
|
+
* @returns Promise resolving to the DeliverTxResponse
|
|
506
|
+
*/
|
|
507
|
+
async aggregateExchangeRatePrevoteTx(payload, address, fee, memo = '', context) {
|
|
508
|
+
const encObj = {
|
|
509
|
+
typeUrl: typeUrlMsgAggregateExchangeRatePrevote,
|
|
510
|
+
value: MsgAggregateExchangeRatePrevote.fromPartial(payload),
|
|
511
|
+
};
|
|
512
|
+
return this.broadcastOracleTx(encObj, address, fee, memo, context);
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* Broadcasts an aggregate exchange rate vote transaction.
|
|
516
|
+
*
|
|
517
|
+
* @param payload - Message payload describing the vote
|
|
518
|
+
* @param address - Address responsible for paying the transaction fees
|
|
519
|
+
* @param fee - Optional fee configuration, defaults to automatic calculation
|
|
520
|
+
* @param memo - Optional transaction memo
|
|
521
|
+
* @param context - Optional SDK context to lazily resolve signer or wallet
|
|
522
|
+
* @returns Promise resolving to the DeliverTxResponse
|
|
523
|
+
*/
|
|
524
|
+
async aggregateExchangeRateVoteTx(payload, address, fee, memo = '', context) {
|
|
525
|
+
const encObj = {
|
|
526
|
+
typeUrl: typeUrlMsgAggregateExchangeRateVote,
|
|
527
|
+
value: MsgAggregateExchangeRateVote.fromPartial(payload),
|
|
528
|
+
};
|
|
529
|
+
return this.broadcastOracleTx(encObj, address, fee, memo, context);
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Delegates feed consent between operator and delegate.
|
|
533
|
+
*
|
|
534
|
+
* @param payload - Message payload describing the delegation
|
|
535
|
+
* @param address - Address responsible for paying the transaction fees
|
|
536
|
+
* @param fee - Optional fee configuration, defaults to automatic calculation
|
|
537
|
+
* @param memo - Optional transaction memo
|
|
538
|
+
* @param context - Optional SDK context to lazily resolve signer or wallet
|
|
539
|
+
* @returns Promise resolving to the DeliverTxResponse
|
|
540
|
+
*/
|
|
541
|
+
async delegateFeedConsentTx(payload, address, fee, memo = '', context) {
|
|
542
|
+
const encObj = {
|
|
543
|
+
typeUrl: typeUrlMsgDelegateFeedConsent,
|
|
544
|
+
value: MsgDelegateFeedConsent.fromPartial(payload),
|
|
545
|
+
};
|
|
546
|
+
return this.broadcastOracleTx(encObj, address, fee, memo, context);
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* Submits a legacy governance update params transaction via MsgSubmitProposal.
|
|
550
|
+
*
|
|
551
|
+
* @param payload - Legacy governance update parameters payload
|
|
552
|
+
* @param address - Address responsible for paying the transaction fees
|
|
553
|
+
* @param fee - Optional fee configuration, defaults to automatic calculation
|
|
554
|
+
* @param memo - Optional transaction memo
|
|
555
|
+
* @param context - Optional SDK context to lazily resolve signer or wallet
|
|
556
|
+
* @param proposalOptions - Optional MsgSubmitProposal configuration such as deposit or metadata
|
|
557
|
+
* @returns Promise resolving to the DeliverTxResponse
|
|
558
|
+
*/
|
|
559
|
+
async legacyGovUpdateParamsTx(payload, address, fee, memo = '', context, proposalOptions) {
|
|
560
|
+
const signerAddress = await this.ensureSignerAddress(address, context);
|
|
561
|
+
const proposalMsg = {
|
|
562
|
+
typeUrl: MsgSubmitProposal.typeUrl,
|
|
563
|
+
value: MsgSubmitProposal.fromPartial({
|
|
564
|
+
messages: [
|
|
565
|
+
{
|
|
566
|
+
typeUrl: typeUrlMsgLegacyGovUpdateParams,
|
|
567
|
+
value: MsgLegacyGovUpdateParams.encode(payload).finish(),
|
|
568
|
+
},
|
|
569
|
+
],
|
|
570
|
+
proposer: signerAddress,
|
|
571
|
+
initialDeposit: proposalOptions?.deposit ?? [],
|
|
572
|
+
metadata: proposalOptions?.metadata ?? '',
|
|
573
|
+
title: payload.title ?? '',
|
|
574
|
+
summary: proposalOptions?.summary ?? payload.description ?? '',
|
|
575
|
+
expedited: proposalOptions?.expedited ?? false,
|
|
576
|
+
}),
|
|
577
|
+
};
|
|
578
|
+
return this.broadcastOracleTx(proposalMsg, signerAddress, fee, memo, context);
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* Submits a governance update params transaction via MsgSubmitProposal.
|
|
582
|
+
*
|
|
583
|
+
* @param payload - Governance update parameters payload
|
|
584
|
+
* @param address - Address responsible for paying the transaction fees
|
|
585
|
+
* @param fee - Optional fee configuration, defaults to automatic calculation
|
|
586
|
+
* @param memo - Optional transaction memo
|
|
587
|
+
* @param context - Optional SDK context to lazily resolve signer or wallet
|
|
588
|
+
* @param proposalOptions - Optional MsgSubmitProposal configuration such as deposit or metadata
|
|
589
|
+
* @returns Promise resolving to the DeliverTxResponse
|
|
590
|
+
*/
|
|
591
|
+
async govUpdateParamsTx(payload, address, fee, memo = '', context, proposalOptions) {
|
|
592
|
+
const signerAddress = await this.ensureSignerAddress(address, context);
|
|
593
|
+
const proposalMsg = {
|
|
594
|
+
typeUrl: MsgSubmitProposal.typeUrl,
|
|
595
|
+
value: MsgSubmitProposal.fromPartial({
|
|
596
|
+
messages: [
|
|
597
|
+
{
|
|
598
|
+
typeUrl: typeUrlMsgGovUpdateParams,
|
|
599
|
+
value: MsgGovUpdateParams.encode(payload).finish(),
|
|
600
|
+
},
|
|
601
|
+
],
|
|
602
|
+
proposer: signerAddress,
|
|
603
|
+
initialDeposit: proposalOptions?.deposit ?? [],
|
|
604
|
+
metadata: proposalOptions?.metadata ?? '',
|
|
605
|
+
title: payload.title ?? '',
|
|
606
|
+
summary: proposalOptions?.summary ?? payload.description ?? '',
|
|
607
|
+
expedited: proposalOptions?.expedited ?? false,
|
|
608
|
+
}),
|
|
609
|
+
};
|
|
610
|
+
return this.broadcastOracleTx(proposalMsg, signerAddress, fee, memo, context);
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* Adds new denoms to the oracle registry via MsgSubmitProposal.
|
|
614
|
+
*
|
|
615
|
+
* @param payload - Governance proposal payload that describes the new denoms
|
|
616
|
+
* @param address - Address responsible for paying the transaction fees
|
|
617
|
+
* @param fee - Optional fee configuration, defaults to automatic calculation
|
|
618
|
+
* @param memo - Optional transaction memo
|
|
619
|
+
* @param context - Optional SDK context to lazily resolve signer or wallet
|
|
620
|
+
* @param proposalOptions - Optional MsgSubmitProposal configuration such as deposit or metadata
|
|
621
|
+
* @returns Promise resolving to the DeliverTxResponse
|
|
622
|
+
*/
|
|
623
|
+
async govAddDenomsTx(payload, address, fee, memo = '', context, proposalOptions) {
|
|
624
|
+
const signerAddress = await this.ensureSignerAddress(address, context);
|
|
625
|
+
const proposalMsg = {
|
|
626
|
+
typeUrl: MsgSubmitProposal.typeUrl,
|
|
627
|
+
value: MsgSubmitProposal.fromPartial({
|
|
628
|
+
messages: [
|
|
629
|
+
{
|
|
630
|
+
typeUrl: typeUrlMsgGovAddDenoms,
|
|
631
|
+
value: MsgGovAddDenoms.encode(payload).finish(),
|
|
632
|
+
},
|
|
633
|
+
],
|
|
634
|
+
proposer: signerAddress,
|
|
635
|
+
initialDeposit: proposalOptions?.deposit ?? [],
|
|
636
|
+
metadata: proposalOptions?.metadata ?? '',
|
|
637
|
+
title: payload.title ?? '',
|
|
638
|
+
summary: proposalOptions?.summary ?? payload.description ?? '',
|
|
639
|
+
expedited: proposalOptions?.expedited ?? false,
|
|
640
|
+
}),
|
|
641
|
+
};
|
|
642
|
+
return this.broadcastOracleTx(proposalMsg, signerAddress, fee, memo, context);
|
|
643
|
+
}
|
|
644
|
+
/**
|
|
645
|
+
* Removes currency pair providers from the oracle configuration via MsgSubmitProposal.
|
|
646
|
+
*
|
|
647
|
+
* @param payload - Governance proposal payload describing providers to remove
|
|
648
|
+
* @param address - Address responsible for paying the transaction fees
|
|
649
|
+
* @param fee - Optional fee configuration, defaults to automatic calculation
|
|
650
|
+
* @param memo - Optional transaction memo
|
|
651
|
+
* @param context - Optional SDK context to lazily resolve signer or wallet
|
|
652
|
+
* @param proposalOptions - Optional MsgSubmitProposal configuration such as deposit or metadata
|
|
653
|
+
* @returns Promise resolving to the DeliverTxResponse
|
|
654
|
+
*/
|
|
655
|
+
async govRemoveCurrencyPairProvidersTx(payload, address, fee, memo = '', context, proposalOptions) {
|
|
656
|
+
const signerAddress = await this.ensureSignerAddress(address, context);
|
|
657
|
+
const proposalMsg = {
|
|
658
|
+
typeUrl: MsgSubmitProposal.typeUrl,
|
|
659
|
+
value: MsgSubmitProposal.fromPartial({
|
|
660
|
+
messages: [
|
|
661
|
+
{
|
|
662
|
+
typeUrl: typeUrlMsgGovRemoveCurrencyPairProviders,
|
|
663
|
+
value: MsgGovRemoveCurrencyPairProviders.encode(payload).finish(),
|
|
664
|
+
},
|
|
665
|
+
],
|
|
666
|
+
proposer: signerAddress,
|
|
667
|
+
initialDeposit: proposalOptions?.deposit ?? [],
|
|
668
|
+
metadata: proposalOptions?.metadata ?? '',
|
|
669
|
+
title: payload.title ?? '',
|
|
670
|
+
summary: proposalOptions?.summary ?? payload.description ?? '',
|
|
671
|
+
expedited: proposalOptions?.expedited ?? false,
|
|
672
|
+
}),
|
|
673
|
+
};
|
|
674
|
+
return this.broadcastOracleTx(proposalMsg, signerAddress, fee, memo, context);
|
|
675
|
+
}
|
|
676
|
+
/**
|
|
677
|
+
* Removes currency deviation thresholds via MsgSubmitProposal.
|
|
678
|
+
*
|
|
679
|
+
* @param payload - Governance payload describing currencies to remove
|
|
680
|
+
* @param address - Address responsible for paying the transaction fees
|
|
681
|
+
* @param fee - Optional fee configuration, defaults to automatic calculation
|
|
682
|
+
* @param memo - Optional transaction memo
|
|
683
|
+
* @param context - Optional SDK context to lazily resolve signer or wallet
|
|
684
|
+
* @param proposalOptions - Optional MsgSubmitProposal configuration such as deposit or metadata
|
|
685
|
+
* @returns Promise resolving to the DeliverTxResponse
|
|
686
|
+
*/
|
|
687
|
+
async govRemoveCurrencyDeviationThresholdsTx(payload, address, fee, memo = '', context, proposalOptions) {
|
|
688
|
+
const signerAddress = await this.ensureSignerAddress(address, context);
|
|
689
|
+
const proposalMsg = {
|
|
690
|
+
typeUrl: MsgSubmitProposal.typeUrl,
|
|
691
|
+
value: MsgSubmitProposal.fromPartial({
|
|
692
|
+
messages: [
|
|
693
|
+
{
|
|
694
|
+
typeUrl: typeUrlMsgGovRemoveCurrencyDeviationThresholds,
|
|
695
|
+
value: MsgGovRemoveCurrencyDeviationThresholds.encode(payload).finish(),
|
|
696
|
+
},
|
|
697
|
+
],
|
|
698
|
+
proposer: signerAddress,
|
|
699
|
+
initialDeposit: proposalOptions?.deposit ?? [],
|
|
700
|
+
metadata: proposalOptions?.metadata ?? '',
|
|
701
|
+
title: payload.title ?? '',
|
|
702
|
+
summary: proposalOptions?.summary ?? payload.description ?? '',
|
|
703
|
+
expedited: proposalOptions?.expedited ?? false,
|
|
704
|
+
}),
|
|
705
|
+
};
|
|
706
|
+
return this.broadcastOracleTx(proposalMsg, signerAddress, fee, memo, context);
|
|
707
|
+
}
|
|
708
|
+
/**
|
|
709
|
+
* Cancels a pending parameter update plan via MsgSubmitProposal.
|
|
710
|
+
*
|
|
711
|
+
* @param payload - Governance payload containing cancellation details
|
|
712
|
+
* @param address - Address responsible for paying the transaction fees
|
|
713
|
+
* @param fee - Optional fee configuration, defaults to automatic calculation
|
|
714
|
+
* @param memo - Optional transaction memo
|
|
715
|
+
* @param context - Optional SDK context to lazily resolve signer or wallet
|
|
716
|
+
* @param proposalOptions - Optional MsgSubmitProposal configuration such as deposit or metadata
|
|
717
|
+
* @returns Promise resolving to the DeliverTxResponse
|
|
718
|
+
*/
|
|
719
|
+
async govCancelUpdateParamPlanTx(payload, address, fee, memo = '', context, proposalOptions) {
|
|
720
|
+
const signerAddress = await this.ensureSignerAddress(address, context);
|
|
721
|
+
const proposalMsg = {
|
|
722
|
+
typeUrl: MsgSubmitProposal.typeUrl,
|
|
723
|
+
value: MsgSubmitProposal.fromPartial({
|
|
724
|
+
messages: [
|
|
725
|
+
{
|
|
726
|
+
typeUrl: typeUrlMsgGovCancelUpdateParamPlan,
|
|
727
|
+
value: MsgGovCancelUpdateParamPlan.encode(payload).finish(),
|
|
728
|
+
},
|
|
729
|
+
],
|
|
730
|
+
proposer: signerAddress,
|
|
731
|
+
initialDeposit: proposalOptions?.deposit ?? [],
|
|
732
|
+
metadata: proposalOptions?.metadata ?? '',
|
|
733
|
+
title: payload.title ?? '',
|
|
734
|
+
summary: proposalOptions?.summary ?? payload.description ?? '',
|
|
735
|
+
expedited: proposalOptions?.expedited ?? false,
|
|
736
|
+
}),
|
|
737
|
+
};
|
|
738
|
+
return this.broadcastOracleTx(proposalMsg, signerAddress, fee, memo, context);
|
|
739
|
+
}
|
|
740
|
+
/**
|
|
741
|
+
* Ensures a signer client exists and resolves the address to use for broadcasting.
|
|
742
|
+
*
|
|
743
|
+
* @param address - Address provided by the caller (optional)
|
|
744
|
+
* @param context - Optional SDK context used to resolve signer or wallet
|
|
745
|
+
* @returns Resolved signer address
|
|
746
|
+
*/
|
|
747
|
+
async ensureSignerAddress(address, context) {
|
|
748
|
+
if (!this._signer) {
|
|
749
|
+
assert(context?.sdk?.signer, 'Signer client is required to broadcast oracle transactions');
|
|
750
|
+
this._signer = context.sdk.signer;
|
|
751
|
+
}
|
|
752
|
+
if (address && address.length > 0) {
|
|
753
|
+
return address;
|
|
754
|
+
}
|
|
755
|
+
assert(context?.sdk?.options?.wallet, 'Wallet context is required when no address is provided');
|
|
756
|
+
const accounts = await context.sdk.options.wallet.getAccounts();
|
|
757
|
+
assert(accounts.length > 0, 'No accounts available in the provided wallet');
|
|
758
|
+
return accounts[0].address;
|
|
759
|
+
}
|
|
760
|
+
/**
|
|
761
|
+
* Signs and broadcasts the provided oracle transaction.
|
|
762
|
+
*
|
|
763
|
+
* @param message - EncodeObject representing the oracle message
|
|
764
|
+
* @param address - Address responsible for the transaction fees
|
|
765
|
+
* @param fee - Optional fee configuration, defaults to automatic calculation
|
|
766
|
+
* @param memo - Optional transaction memo
|
|
767
|
+
* @param context - Optional SDK context used to resolve signer or wallet
|
|
768
|
+
* @returns Promise resolving to the DeliverTxResponse
|
|
769
|
+
*/
|
|
770
|
+
async broadcastOracleTx(message, address, fee, memo = '', context) {
|
|
771
|
+
const signerAddress = await this.ensureSignerAddress(address, context);
|
|
772
|
+
return this._signer.signAndBroadcast(signerAddress, [message], fee ?? 'auto', memo);
|
|
773
|
+
}
|
|
774
|
+
/**
|
|
775
|
+
* Parses a decimal price string back into its atomic representation.
|
|
776
|
+
* @param price - Price in decimal string format
|
|
777
|
+
* @returns Promise resolving to the atomic string representation of the price
|
|
778
|
+
*/
|
|
779
|
+
static async parseFromDecimalPrice(price) {
|
|
780
|
+
const decimal = Decimal.fromUserInput(price, 18);
|
|
781
|
+
return decimal.atomics;
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
//# sourceMappingURL=oracle.js.map
|