diff --git a/package-lock.json b/package-lock.json index dad8ad31..17391e0b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,16 +1,16 @@ { "name": "@terra-money/feather.js", - "version": "2.0.4", + "version": "2.1.0-beta.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@terra-money/feather.js", - "version": "2.0.3", + "version": "2.1.0-beta.1", "license": "MIT", "dependencies": { "@terra-money/legacy.proto": "npm:@terra-money/terra.proto@^0.1.7", - "@terra-money/terra.proto": "^4.0.4", + "@terra-money/terra.proto": "^4.0.10", "assert": "^2.0.0", "axios": "^0.27.2", "bech32": "^2.0.0", @@ -1291,9 +1291,9 @@ "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==" }, "node_modules/@terra-money/terra.proto": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@terra-money/terra.proto/-/terra.proto-4.0.4.tgz", - "integrity": "sha512-Xju3ObFvMWXCDpeOXwa+WpmcbvUFOgJ4shSSfbgocnX5q3250aTaIAaycxkArUtg1QoqV4B5qoboRAplMHYDZw==", + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/@terra-money/terra.proto/-/terra.proto-4.0.10.tgz", + "integrity": "sha512-cSTGri/X7r+RjTHKQ40lUDM7+lwWIiodLmBvuCUWMH8svji0D45StZTVGfaQ5wCnPr7KcDbZTERzyLKiSwsBqg==", "dependencies": { "@improbable-eng/grpc-web": "^0.14.1", "browser-headers": "^0.4.1", diff --git a/package.json b/package.json index e4a19257..169e0dbd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@terra-money/feather.js", - "version": "2.0.4", + "version": "2.1.0-beta.1", "description": "The JavaScript SDK for Terra and Feather chains", "license": "MIT", "author": "Terraform Labs, PTE.", @@ -86,7 +86,7 @@ }, "dependencies": { "@terra-money/legacy.proto": "npm:@terra-money/terra.proto@^0.1.7", - "@terra-money/terra.proto": "^4.0.4", + "@terra-money/terra.proto": "^4.0.10", "assert": "^2.0.0", "axios": "^0.27.2", "bech32": "^2.0.0", diff --git a/src/client/lcd/LCDClient.ts b/src/client/lcd/LCDClient.ts index 6185bbbc..7bc7f736 100644 --- a/src/client/lcd/LCDClient.ts +++ b/src/client/lcd/LCDClient.ts @@ -27,6 +27,7 @@ import { FeeshareAPI } from './api/FeeshareAPI'; import { GovV1API } from './api/GovV1API'; import { ICAv1API } from './api/ICAv1API'; import { ICQv1API } from './api/ICQv1API'; +import { FeemarketAPI } from './api/FeemarketAPI'; export type AxiosConfig = { /** @@ -135,6 +136,7 @@ export class LCDClient { public ibcTransfer: IbcTransferAPI; public pob: PobAPI; public feeshare: FeeshareAPI; + public feemarket: FeemarketAPI; public utils: LCDUtils; /** @@ -185,6 +187,7 @@ export class LCDClient { this.tx = new TxAPI(this); this.pob = new PobAPI(this); this.feeshare = new FeeshareAPI(this); + this.feemarket = new FeemarketAPI(this); this.utils = new LCDUtils(this); } diff --git a/src/client/lcd/api/Feemarket.API.spec.ts b/src/client/lcd/api/Feemarket.API.spec.ts new file mode 100644 index 00000000..423e9199 --- /dev/null +++ b/src/client/lcd/api/Feemarket.API.spec.ts @@ -0,0 +1,83 @@ +import Decimal from 'decimal.js'; +import { + FeemarketDenomParams, + FeemarketParams, + FeemarketState, +} from '../../../core/feemarket'; +import { LCDClient } from '../LCDClient'; +import { FeemarketAPI } from './FeemarketAPI'; + +const lcd = new LCDClient({ + 'pisco-1': { + chainID: 'pisco-1', + gasAdjustment: 1.5, + gasPrices: { + uluna: 0.02, + }, + lcd: 'http://localhost:1317/', + prefix: 'terra', + }, +}); +const feemarket = new FeemarketAPI(lcd); + +describe('FeemarketAPI', () => { + it('asset the module params', async () => { + const res = await feemarket.params('pisco-1'); + + expect(res).toStrictEqual( + new FeemarketParams( + new Decimal(0), + new Decimal(1), + new Decimal(0), + new Decimal(0.125), + new Decimal(0.125), + new Decimal(15000000), + new Decimal(30000000), + new Decimal(1), + true, + 'uluna' + ) + ); + + expect(res.toData()).toEqual({ + alpha: '0', + beta: '1', + theta: '0', + min_learning_rate: '0.125', + max_learning_rate: '0.125', + target_block_utilization: '15000000', + max_block_utilization: '30000000', + window: '1', + enabled: true, + default_fee_denom: 'uluna', + }); + }); + + it('asset the module state', async () => { + const res = await feemarket.state('pisco-1'); + expect(res).toStrictEqual( + new FeemarketState(new Decimal(0.125), [new Decimal(0)], new Decimal(0)) + ); + expect(res.toData()).toEqual({ + learning_rate: '0.125', + window: ['0'], + index: '0', + }); + }); + + it('get fee denom params', async () => { + const res = await feemarket.feeDenomParam('pisco-1', 'uluna'); + expect(res).toStrictEqual([ + new FeemarketDenomParams( + 'uluna', + new Decimal('0.0015'), + new Decimal('0.0015') + ), + ]); + expect(res[0].toData()).toEqual({ + fee_denom: 'uluna', + min_base_fee: '0.0015', + base_fee: '0.0015', + }); + }); +}); diff --git a/src/client/lcd/api/FeemarketAPI.ts b/src/client/lcd/api/FeemarketAPI.ts new file mode 100644 index 00000000..a722129b --- /dev/null +++ b/src/client/lcd/api/FeemarketAPI.ts @@ -0,0 +1,67 @@ +import { + FeemarketDenomParams, + FeemarketParams, + FeemarketState, +} from '../../../core/feemarket'; +import { APIParams, PaginationOptions } from '../APIRequester'; +import { LCDClient } from '../LCDClient'; +import { BaseAPI } from './BaseAPI'; + +export class FeemarketAPI extends BaseAPI { + constructor(public lcd: LCDClient) { + super(lcd.apiRequesters, lcd.config); + } + + /** + * Query the feemarket module params. + * + * @tags Query + * @name params + * @request GET:/feemarket/v1/params + */ + public async params( + chainId: string, + params: Partial = {} + ): Promise { + const res = await this.getReqFromChainID(chainId).get<{ + params: FeemarketParams.Data; + }>(`/feemarket/v1/params`, params); + + return FeemarketParams.fromData(res.params); + } + + /** + * Query feemarket state. + * + * @tags Query + * @name state + * @request GET:/feemarket/v1/state + */ + public async state(chainId: string, params: Partial = {}) { + const res = await this.getReqFromChainID(chainId).get<{ + state: FeemarketState.Data; + }>(`/feemarket/v1/state`, params); + + return FeemarketState.fromData(res.state); + } + + /** + * Query the current feeDenomParam for fee_denom. + * + * @tags Query + * @name feeDenomParam + * @summary Query the current feeDenomParam for fee_denom. + * @request GET:/feemarket/v1/fee_denom_param/${feeDenom} or GET:/feemarket/v1/fee_denom_param/ + */ + public async feeDenomParam( + chainId: string, + feeDenom: string, + params?: Partial + ): Promise> { + const res = await this.getReqFromChainID(chainId).get<{ + fee_denom_params: Array; + }>(`/feemarket/v1/fee_denom_param/${feeDenom}`, params); + + return res.fee_denom_params.map(x => FeemarketDenomParams.fromData(x)); + } +} diff --git a/src/core/alliance/proposals/v1/MsgCreateAlliance.ts b/src/core/alliance/proposals/v1/MsgCreateAlliance.ts index cebf11e3..806e0d73 100644 --- a/src/core/alliance/proposals/v1/MsgCreateAlliance.ts +++ b/src/core/alliance/proposals/v1/MsgCreateAlliance.ts @@ -124,6 +124,7 @@ export class MsgCreateAlliance extends JSONSerializable< rewardChangeInterval, rewardWeightRange, } = this; + return MsgCreateAlliance_pb.fromPartial({ authority, denom, diff --git a/src/core/feemarket/index.ts b/src/core/feemarket/index.ts new file mode 100644 index 00000000..70bc721f --- /dev/null +++ b/src/core/feemarket/index.ts @@ -0,0 +1,6 @@ +export * from './v1/models/FeemarketParams'; +export * from './v1/proposals/MsgFeeDenomParam'; +export * from './v1/proposals/MsgRemoveFeeDenomParam'; +export * from './v1/proposals/MsgParams'; +export * from './v1/models/FeemarketState'; +export * from './v1/models/FeemarketDenomParams'; diff --git a/src/core/feemarket/v1/models/FeemarketDenomParams.ts b/src/core/feemarket/v1/models/FeemarketDenomParams.ts new file mode 100644 index 00000000..3ac2078f --- /dev/null +++ b/src/core/feemarket/v1/models/FeemarketDenomParams.ts @@ -0,0 +1,103 @@ +import { FeeDenomParam as FeeDenomParam_pb } from '@terra-money/terra.proto/feemarket/feemarket/v1/genesis'; +import { Denom } from 'core/Denom'; +import Decimal from 'decimal.js'; +import { JSONSerializable } from '../../../../util/json'; + +export class FeemarketDenomParams extends JSONSerializable< + FeemarketDenomParams.Amino, + FeemarketDenomParams.Data, + FeemarketDenomParams.Proto +> { + constructor( + public feeDenom: Denom, + public minBaseFee: Decimal, + public baseFee: Decimal + ) { + super(); + } + + public static fromAmino( + data: FeemarketDenomParams.Amino + ): FeemarketDenomParams { + const { + value: { fee_denom, min_base_fee, base_fee }, + } = data; + + return new FeemarketDenomParams( + fee_denom, + new Decimal(min_base_fee), + new Decimal(base_fee) + ); + } + + public toAmino(): FeemarketDenomParams.Amino { + const { feeDenom, minBaseFee, baseFee } = this; + + return { + value: { + fee_denom: feeDenom, + min_base_fee: minBaseFee.toString(), + base_fee: baseFee.toString(), + }, + }; + } + + public static fromData( + data: FeemarketDenomParams.Data, + _?: boolean + ): FeemarketDenomParams { + _; + const { fee_denom, min_base_fee, base_fee } = data; + return new FeemarketDenomParams( + fee_denom, + new Decimal(min_base_fee), + new Decimal(base_fee) + ); + } + + public toData(_?: boolean): FeemarketDenomParams.Data { + _; + const { feeDenom, minBaseFee, baseFee } = this; + return { + fee_denom: feeDenom, + min_base_fee: minBaseFee.toString(), + base_fee: baseFee.toString(), + }; + } + + public static fromProto( + proto: FeemarketDenomParams.Proto + ): FeemarketDenomParams { + return new FeemarketDenomParams( + proto.feeDenom, + new Decimal(proto.minBaseFee), + new Decimal(proto.baseFee) + ); + } + + public toProto(): FeemarketDenomParams.Proto { + const { feeDenom, minBaseFee, baseFee } = this; + return { + feeDenom, + minBaseFee: minBaseFee.toString(), + baseFee: baseFee.toString(), + }; + } +} + +export namespace FeemarketDenomParams { + export interface Amino { + value: { + fee_denom: string; + min_base_fee: string; + base_fee: string; + }; + } + + export interface Data { + fee_denom: string; + min_base_fee: string; + base_fee: string; + } + export type Proto = FeeDenomParam_pb; +} diff --git a/src/core/feemarket/v1/models/FeemarketParams.ts b/src/core/feemarket/v1/models/FeemarketParams.ts new file mode 100644 index 00000000..c3d924a6 --- /dev/null +++ b/src/core/feemarket/v1/models/FeemarketParams.ts @@ -0,0 +1,218 @@ +import Long from 'long'; +import { JSONSerializable } from '../../../../util/json'; +import { Params as Params_pb } from '@terra-money/terra.proto/feemarket/feemarket/v1/params'; +import Decimal from 'decimal.js'; + +export class FeemarketParams extends JSONSerializable< + FeemarketParams.Amino, + FeemarketParams.Data, + FeemarketParams.Proto +> { + constructor( + public alpha: Decimal, + public beta: Decimal, + public theta: Decimal, + public minLearningRate: Decimal, + public maxLearningRate: Decimal, + public targetBlockUtilization: Decimal, + public maxBlockUtilization: Decimal, + public window: Decimal, + public enabled: boolean, + public defaultFeeDenom: string + ) { + super(); + } + + public static fromAmino(data: FeemarketParams.Amino): FeemarketParams { + const { + value: { + alpha, + beta, + theta, + min_learning_rate, + max_learning_rate, + target_block_utilization, + max_block_utilization, + window, + enabled, + default_fee_denom, + }, + } = data; + + return new FeemarketParams( + new Decimal(alpha), + new Decimal(beta), + new Decimal(theta), + new Decimal(min_learning_rate), + new Decimal(max_learning_rate), + new Decimal(target_block_utilization), + new Decimal(max_block_utilization), + new Decimal(window), + enabled, + default_fee_denom + ); + } + + public toAmino(): FeemarketParams.Amino { + const { + alpha, + beta, + theta, + minLearningRate, + maxLearningRate, + targetBlockUtilization, + maxBlockUtilization, + window, + enabled, + defaultFeeDenom, + } = this; + return { + value: { + alpha: alpha.toString(), + beta: beta.toString(), + theta: theta.toString(), + min_learning_rate: minLearningRate.toString(), + max_learning_rate: maxLearningRate.toString(), + target_block_utilization: targetBlockUtilization.toString(), + max_block_utilization: maxBlockUtilization.toString(), + window: window.toString(), + enabled, + default_fee_denom: defaultFeeDenom, + }, + }; + } + + public static fromData( + proto: FeemarketParams.Data, + _?: boolean + ): FeemarketParams { + _; + const { + alpha, + beta, + theta, + min_learning_rate, + max_learning_rate, + target_block_utilization, + max_block_utilization, + window, + enabled, + default_fee_denom, + } = proto; + return new FeemarketParams( + new Decimal(alpha), + new Decimal(beta), + new Decimal(theta), + new Decimal(min_learning_rate), + new Decimal(max_learning_rate), + new Decimal(target_block_utilization), + new Decimal(max_block_utilization), + new Decimal(window), + enabled, + default_fee_denom + ); + } + + public toData(_?: boolean): FeemarketParams.Data { + _; + const { + alpha, + beta, + theta, + minLearningRate, + maxLearningRate, + targetBlockUtilization, + maxBlockUtilization, + window, + enabled, + defaultFeeDenom, + } = this; + return { + alpha: alpha.toString(), + beta: beta.toString(), + theta: theta.toString(), + min_learning_rate: minLearningRate.toString(), + max_learning_rate: maxLearningRate.toString(), + target_block_utilization: targetBlockUtilization.toString(), + max_block_utilization: maxBlockUtilization.toString(), + window: window.toString(), + enabled: enabled, + default_fee_denom: defaultFeeDenom, + }; + } + + public static fromProto(proto: FeemarketParams.Proto): FeemarketParams { + return new FeemarketParams( + new Decimal(proto.alpha), + new Decimal(proto.beta), + new Decimal(proto.theta), + new Decimal(proto.minLearningRate), + new Decimal(proto.maxLearningRate), + new Decimal(proto.targetBlockUtilization.toString()), + new Decimal(proto.maxBlockUtilization.toString()), + new Decimal(proto.window.toString()), + proto.enabled, + proto.defaultFeeDenom + ); + } + + public toProto(): FeemarketParams.Proto { + const { + alpha, + beta, + theta, + minLearningRate, + maxLearningRate, + targetBlockUtilization, + maxBlockUtilization, + window, + enabled, + defaultFeeDenom, + } = this; + return Params_pb.fromPartial({ + alpha: alpha.toString(), + beta: beta.toString(), + theta: theta.toString(), + minLearningRate: minLearningRate.toString(), + maxLearningRate: maxLearningRate.toString(), + targetBlockUtilization: Long.fromString( + targetBlockUtilization.toString() + ), + maxBlockUtilization: Long.fromString(maxBlockUtilization.toString()), + window: Long.fromString(window.toString()), + enabled, + defaultFeeDenom, + }); + } +} + +export namespace FeemarketParams { + export interface Amino { + value: { + alpha: string; + beta: string; + theta: string; + min_learning_rate: string; + max_learning_rate: string; + target_block_utilization: string; + max_block_utilization: string; + window: string; + enabled: boolean; + default_fee_denom: string; + }; + } + + export interface Data { + alpha: string; + beta: string; + theta: string; + min_learning_rate: string; + max_learning_rate: string; + target_block_utilization: string; + max_block_utilization: string; + window: string; + enabled: boolean; + default_fee_denom: string; + } + export type Proto = Params_pb; +} diff --git a/src/core/feemarket/v1/models/FeemarketState.ts b/src/core/feemarket/v1/models/FeemarketState.ts new file mode 100644 index 00000000..fc9f01ea --- /dev/null +++ b/src/core/feemarket/v1/models/FeemarketState.ts @@ -0,0 +1,98 @@ +import Long from 'long'; +import { JSONSerializable } from '../../../../util/json'; +import { State as State_pb } from '@terra-money/terra.proto/feemarket/feemarket/v1/genesis'; +import Decimal from 'decimal.js'; + +export class FeemarketState extends JSONSerializable< + FeemarketState.Amino, + FeemarketState.Data, + FeemarketState.Proto +> { + constructor( + public learningRate: Decimal, + public window: Decimal[], + public index: Decimal + ) { + super(); + } + + public static fromAmino(data: FeemarketState.Amino): FeemarketState { + const { + value: { learning_rate, window, index }, + } = data; + + return new FeemarketState( + new Decimal(learning_rate), + window.map(w => new Decimal(w)), + new Decimal(index) + ); + } + + public toAmino(): FeemarketState.Amino { + const { learningRate, window, index } = this; + return { + value: { + learning_rate: learningRate.toString(), + window: window.map(w => w.toString()), + index: index.toString(), + }, + }; + } + + public static fromData( + proto: FeemarketState.Data, + _?: boolean + ): FeemarketState { + _; + const { learning_rate, window, index } = proto; + return new FeemarketState( + new Decimal(learning_rate), + window.map(w => new Decimal(w)), + new Decimal(index) + ); + } + + public toData(_?: boolean): FeemarketState.Data { + _; + const { learningRate, window, index } = this; + return { + learning_rate: learningRate.toString(), + window: window.map(w => w.toString()), + index: index.toString(), + }; + } + + public static fromProto(proto: FeemarketState.Proto): FeemarketState { + return new FeemarketState( + new Decimal(proto.learningRate), + proto.window.map(x => new Decimal(x.toString())), + new Decimal(proto.index.toString()) + ); + } + + public toProto(): FeemarketState.Proto { + const { learningRate, window, index } = this; + return State_pb.fromPartial({ + learningRate: learningRate.toString(), + window: window.map(x => Long.fromString(x.toString())), + index: Long.fromString(index.toString()), + }); + } +} + +export namespace FeemarketState { + export interface Amino { + value: { + learning_rate: string; + window: string[]; + index: string; + }; + } + + export interface Data { + learning_rate: string; + window: string[]; + index: string; + } + export type Proto = State_pb; +} diff --git a/src/core/feemarket/v1/proposals/MsgFeeDenomParam.ts b/src/core/feemarket/v1/proposals/MsgFeeDenomParam.ts new file mode 100644 index 00000000..d911e932 --- /dev/null +++ b/src/core/feemarket/v1/proposals/MsgFeeDenomParam.ts @@ -0,0 +1,89 @@ +import { JSONSerializable } from '../../../../util/json'; +import { AccAddress } from '../../../bech32'; +import { Any } from '@terra-money/terra.proto/google/protobuf/any'; +import { MsgFeeDenomParam as MsgFeeDenomParam_pb } from '@terra-money/terra.proto/feemarket/feemarket/v1/tx'; + +export class MsgFeeDenomParam extends JSONSerializable< + MsgFeeDenomParam.Amino, + MsgFeeDenomParam.Data, + MsgFeeDenomParam.Proto +> { + constructor( + public feeDenom: string, + public minBaseFee: string, + public authority: AccAddress + ) { + super(); + } + + public static fromAmino(data: MsgFeeDenomParam.Amino): MsgFeeDenomParam { + data; + throw new Error('not implemented'); + } + + public toAmino(): MsgFeeDenomParam.Amino { + throw new Error('not implemented'); + } + + public static fromData(proto: MsgFeeDenomParam.Data): MsgFeeDenomParam { + const { fee_denom, min_base_fee, authority } = proto; + return new MsgFeeDenomParam(fee_denom, min_base_fee, authority); + } + + public toData(): MsgFeeDenomParam.Data { + const { feeDenom, minBaseFee, authority } = this; + return { + '@type': '/feemarket.feemarket.v1.MsgFeeDenomParam', + fee_denom: feeDenom, + min_base_fee: minBaseFee, + authority: authority, + }; + } + + public static fromProto(proto: MsgFeeDenomParam.Proto): MsgFeeDenomParam { + return new MsgFeeDenomParam( + proto.feeDenom, + proto.minBaseFee, + proto.authority + ); + } + + public toProto(): MsgFeeDenomParam.Proto { + const { feeDenom, minBaseFee, authority } = this; + return MsgFeeDenomParam_pb.fromPartial({ + feeDenom, + minBaseFee, + authority, + }); + } + + public packAny(): Any { + return Any.fromPartial({ + typeUrl: '/feemarket.feemarket.v1.MsgFeeDenomParam', + value: MsgFeeDenomParam_pb.encode(this.toProto()).finish(), + }); + } + + public static unpackAny(msgAny: Any): MsgFeeDenomParam { + return MsgFeeDenomParam.fromProto(MsgFeeDenomParam_pb.decode(msgAny.value)); + } +} + +export namespace MsgFeeDenomParam { + export interface Amino { + type: 'feemarket/MsgFeeDenomParam'; + value: { + fee_denom: string; + min_base_fee: string; + authority: AccAddress; + }; + } + + export interface Data { + '@type': '/feemarket.feemarket.v1.MsgFeeDenomParam'; + fee_denom: string; + min_base_fee: string; + authority: AccAddress; + } + export type Proto = MsgFeeDenomParam_pb; +} diff --git a/src/core/feemarket/v1/proposals/MsgParams.ts b/src/core/feemarket/v1/proposals/MsgParams.ts new file mode 100644 index 00000000..e50aff4b --- /dev/null +++ b/src/core/feemarket/v1/proposals/MsgParams.ts @@ -0,0 +1,82 @@ +import { JSONSerializable } from '../../../../util/json'; +import { AccAddress } from '../../../bech32'; +import { Any } from '@terra-money/terra.proto/google/protobuf/any'; +import { MsgParams as MsgParams_pb } from '@terra-money/terra.proto/feemarket/feemarket/v1/tx'; +import { FeemarketParams } from '../models/FeemarketParams'; +import { Params as Params_pb } from '@terra-money/terra.proto/feemarket/feemarket/v1/params'; + +export class MsgParams extends JSONSerializable< + MsgParams.Amino, + MsgParams.Data, + MsgParams.Proto +> { + constructor(public params: FeemarketParams, public authority: AccAddress) { + super(); + } + + public static fromAmino(data: MsgParams.Amino): MsgParams { + data; + throw new Error('not implemented'); + } + + public toAmino(): MsgParams.Amino { + throw new Error('not implemented'); + } + + public static fromData(proto: MsgParams.Data): MsgParams { + const { params, authority } = proto; + return new MsgParams(FeemarketParams.fromData(params), authority); + } + + public toData(): MsgParams.Data { + const { params, authority } = this; + return { + '@type': '/feemarket.feemarket.v1.MsgParams', + params: params.toData(), + authority: authority, + }; + } + + public static fromProto(proto: MsgParams.Proto): MsgParams { + return new MsgParams( + FeemarketParams.fromProto(proto.params as Params_pb), + proto.authority + ); + } + + public toProto(): MsgParams.Proto { + const { params, authority } = this; + return MsgParams_pb.fromPartial({ + params: params.toProto(), + authority, + }); + } + + public packAny(): Any { + return Any.fromPartial({ + typeUrl: '/feemarket.feemarket.v1.MsgParams', + value: MsgParams_pb.encode(this.toProto()).finish(), + }); + } + + public static unpackAny(msgAny: Any): MsgParams { + return MsgParams.fromProto(MsgParams_pb.decode(msgAny.value)); + } +} + +export namespace MsgParams { + export interface Amino { + type: 'feemarket/MsgParams'; + value: { + params: FeemarketParams.Amino; + authority: AccAddress; + }; + } + + export interface Data { + '@type': '/feemarket.feemarket.v1.MsgParams'; + params: FeemarketParams.Data; + authority: AccAddress; + } + export type Proto = MsgParams_pb; +} diff --git a/src/core/feemarket/v1/proposals/MsgRemoveFeeDenomParam.ts b/src/core/feemarket/v1/proposals/MsgRemoveFeeDenomParam.ts new file mode 100644 index 00000000..f235a5bb --- /dev/null +++ b/src/core/feemarket/v1/proposals/MsgRemoveFeeDenomParam.ts @@ -0,0 +1,85 @@ +import { JSONSerializable } from '../../../../util/json'; +import { AccAddress } from '../../../bech32'; +import { Any } from '@terra-money/terra.proto/google/protobuf/any'; +import { MsgRemoveFeeDenomParam as MsgRemoveFeeDenomParam_pb } from '@terra-money/terra.proto/feemarket/feemarket/v1/tx'; + +export class MsgRemoveFeeDenomParam extends JSONSerializable< + MsgRemoveFeeDenomParam.Amino, + MsgRemoveFeeDenomParam.Data, + MsgRemoveFeeDenomParam.Proto +> { + constructor(public feeDenom: string, public authority: AccAddress) { + super(); + } + + public static fromAmino( + data: MsgRemoveFeeDenomParam.Amino + ): MsgRemoveFeeDenomParam { + data; + throw new Error('not implemented'); + } + + public toAmino(): MsgRemoveFeeDenomParam.Amino { + throw new Error('not implemented'); + } + + public static fromData( + proto: MsgRemoveFeeDenomParam.Data + ): MsgRemoveFeeDenomParam { + const { fee_denom, authority } = proto; + return new MsgRemoveFeeDenomParam(fee_denom, authority); + } + + public toData(): MsgRemoveFeeDenomParam.Data { + const { feeDenom, authority } = this; + return { + '@type': '/feemarket.feemarket.v1.MsgRemoveFeeDenomParam', + fee_denom: feeDenom, + authority: authority, + }; + } + + public static fromProto( + proto: MsgRemoveFeeDenomParam.Proto + ): MsgRemoveFeeDenomParam { + return new MsgRemoveFeeDenomParam(proto.feeDenom, proto.authority); + } + + public toProto(): MsgRemoveFeeDenomParam.Proto { + const { feeDenom, authority } = this; + return MsgRemoveFeeDenomParam_pb.fromPartial({ + feeDenom, + authority, + }); + } + + public packAny(): Any { + return Any.fromPartial({ + typeUrl: '/feemarket.feemarket.v1.MsgRemoveFeeDenomParam', + value: MsgRemoveFeeDenomParam_pb.encode(this.toProto()).finish(), + }); + } + + public static unpackAny(msgAny: Any): MsgRemoveFeeDenomParam { + return MsgRemoveFeeDenomParam.fromProto( + MsgRemoveFeeDenomParam_pb.decode(msgAny.value) + ); + } +} + +export namespace MsgRemoveFeeDenomParam { + export interface Amino { + type: 'feemarket/MsgRemoveFeeDenomParam'; + value: { + fee_denom: string; + authority: AccAddress; + }; + } + + export interface Data { + '@type': '/feemarket.feemarket.v1.MsgRemoveFeeDenomParam'; + fee_denom: string; + authority: AccAddress; + } + export type Proto = MsgRemoveFeeDenomParam_pb; +} diff --git a/src/core/gov/v1/Proposal.ts b/src/core/gov/v1/Proposal.ts index f371fd06..b8dc7638 100644 --- a/src/core/gov/v1/Proposal.ts +++ b/src/core/gov/v1/Proposal.ts @@ -38,6 +38,11 @@ import { MsgCreateAlliance, MsgDeleteAlliance, } from '../../../core/alliance/proposals'; +import { + MsgParams, + MsgFeeDenomParam, + MsgRemoveFeeDenomParam, +} from '../../../core/feemarket'; import { AccAddress } from 'core/bech32'; /** @@ -326,7 +331,10 @@ export namespace Proposal { | SudoContractProposal | UnpinCodesProposal | UpdateAdminProposal - | UpdateInstantiateConfigProposal; + | UpdateInstantiateConfigProposal + | MsgParams + | MsgFeeDenomParam + | MsgRemoveFeeDenomParam; export namespace Message { export type Amino = @@ -352,6 +360,9 @@ export namespace Proposal { | UnpinCodesProposal.Amino | UpdateAdminProposal.Amino | UpdateInstantiateConfigProposal.Amino + | MsgParams.Amino + | MsgFeeDenomParam.Amino + | MsgRemoveFeeDenomParam.Amino | any; export type Data = @@ -377,6 +388,9 @@ export namespace Proposal { | UnpinCodesProposal.Data | UpdateAdminProposal.Data | UpdateInstantiateConfigProposal.Data + | MsgParams.Data + | MsgFeeDenomParam.Data + | MsgRemoveFeeDenomParam.Data | any; export type Proto = @@ -402,6 +416,9 @@ export namespace Proposal { | UnpinCodesProposal.Proto | UpdateAdminProposal.Proto | UpdateInstantiateConfigProposal.Proto + | MsgParams.Proto + | MsgFeeDenomParam.Proto + | MsgRemoveFeeDenomParam.Proto | undefined; export function fromAmino( @@ -458,6 +475,12 @@ export namespace Proposal { return MsgUpdateAlliance.fromAmino(amino, isClassic); case 'alliance/MsgDeleteAlliance': return MsgDeleteAlliance.fromAmino(amino, isClassic); + case 'feemarket/MsgParams': + return MsgParams.fromAmino(amino); + case 'feemarket/MsgFeeDenomParam': + return MsgFeeDenomParam.fromAmino(amino); + case 'feemarket/MsgRemoveFeeDenomParam': + return MsgRemoveFeeDenomParam.fromAmino(amino); default: return amino; } @@ -509,6 +532,12 @@ export namespace Proposal { return MsgUpdateAlliance.fromData(data, isClassic); case '/alliance.alliance.MsgDeleteAlliance': return MsgDeleteAlliance.fromData(data, isClassic); + case '/feemarket.feemarket.v1.MsgParams': + return MsgParams.fromData(data); + case '/feemarket.feemarket.v1.MsgFeeDenomParam': + return MsgFeeDenomParam.fromData(data); + case '/feemarket.feemarket.v1.MsgRemoveFeeDenomParam': + return MsgRemoveFeeDenomParam.fromData(data); default: return data; } @@ -564,6 +593,12 @@ export namespace Proposal { return MsgUpdateAlliance.unpackAny(anyProto, isClassic); case '/alliance.alliance.MsgDeleteAlliance': return MsgDeleteAlliance.unpackAny(anyProto, isClassic); + case '/feemarket.feemarket.v1.MsgParams': + return MsgParams.unpackAny(anyProto); + case '/feemarket.feemarket.v1.MsgFeeDenomParam': + return MsgFeeDenomParam.unpackAny(anyProto); + case '/feemarket.feemarket.v1.MsgRemoveFeeDenomParam': + return MsgRemoveFeeDenomParam.unpackAny(anyProto); default: return undefined; }