From 17d2631827b1c0476ec0a614084645623ed7d85f Mon Sep 17 00:00:00 2001 From: freeelancer Date: Thu, 25 Jan 2024 21:08:19 +0800 Subject: [PATCH] created feemarketAPI --- src/client/lcd/api/FeemarketAPI.ts | 70 ++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 src/client/lcd/api/FeemarketAPI.ts diff --git a/src/client/lcd/api/FeemarketAPI.ts b/src/client/lcd/api/FeemarketAPI.ts new file mode 100644 index 00000000..77e704b7 --- /dev/null +++ b/src/client/lcd/api/FeemarketAPI.ts @@ -0,0 +1,70 @@ +import { Params } from '@terra-money/terra.proto/feemarket/feemarket/v1/params'; +import { + BaseFeeResponse, + StateResponse, +} from '@terra-money/terra.proto/feemarket/feemarket/v1/query'; +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 = {} + ) { + return this.getReqFromChainID(chainId).get<{ params: Params }>( + `/feemarket/v1/params`, + params + ); + } + + /** + * Query all paginated feemarket states. When fee_denom is not specified, it returns all states, + * otherwise it returns the state of the specific fee_denom. + * + * @tags Query + * @name state + * @summary Query all paginated states of feemarket fee_denoms. + * @request GET:/feemarket/v1/state or GET:/feemarket/v1/state?fee_denom=${feeDenom} + */ + public async state( + chainId: string, + feeDenom?: string, + params?: Partial + ) { + const url = feeDenom + ? `/feemarket/v1/state?fee_denom=${feeDenom}` + : `/feemarket/v1/state`; + + return this.getReqFromChainID(chainId).get(url, params); + } + + /** + * Query the current basefee for fee_denom. + * + * @tags Query + * @name baseFee + * @summary Query the current basefee for fee_denom. + * @request GET:/feemarket/v1/base_fee?fee_denom=${feeDenom} + */ + public async baseFee( + chainId: string, + feeDenom: string, + params?: Partial + ) { + const url = `/feemarket/v1/base_fee?fee_denom=${feeDenom}`; + + return this.getReqFromChainID(chainId).get(url, params); + } +}