From 769831afaf31ff1b430058ef5dd8cceac82cde13 Mon Sep 17 00:00:00 2001 From: Cameron Gilbert Date: Wed, 28 Feb 2024 13:45:35 -0500 Subject: [PATCH] feat: devgas query (#325) --- src/sdk/query/devgas.ts | 55 +++++++++++++++++++++++++++++++++++++++++ src/sdk/query/index.ts | 1 + src/sdk/query/query.ts | 4 +++ src/sdk/tx/txClient.ts | 2 ++ 4 files changed, 62 insertions(+) create mode 100644 src/sdk/query/devgas.ts diff --git a/src/sdk/query/devgas.ts b/src/sdk/query/devgas.ts new file mode 100644 index 00000000..54621f02 --- /dev/null +++ b/src/sdk/query/devgas.ts @@ -0,0 +1,55 @@ +import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate" +import { + QueryClientImpl, + QueryFeeShareRequest, + QueryFeeShareResponse, + QueryFeeSharesByWithdrawerRequest, + QueryFeeSharesByWithdrawerResponse, + QueryFeeSharesRequest, + QueryFeeSharesResponse, + QueryParamsRequest, + QueryParamsResponse, +} from "../../protojs/nibiru/devgas/v1/query" + +export interface DevgasExtension { + readonly devgas: Readonly<{ + feeShare: (args: QueryFeeShareRequest) => Promise + feeSharesByWithdrawer: ( + args: QueryFeeSharesByWithdrawerRequest + ) => Promise + feeShares: (args: QueryFeeSharesRequest) => Promise + params: (args: QueryParamsRequest) => Promise + }> +} + +export const setupDevgasExtension = (base: QueryClient): DevgasExtension => { + const rpcClient = createProtobufRpcClient(base) + const queryService = new QueryClientImpl(rpcClient) + + return { + devgas: { + feeShare: async (args: QueryFeeShareRequest) => { + const req = QueryFeeShareRequest.fromPartial(args) + const resp = await queryService.FeeShare(req) + return resp + }, + feeSharesByWithdrawer: async ( + args: QueryFeeSharesByWithdrawerRequest + ) => { + const req = QueryFeeSharesByWithdrawerRequest.fromPartial(args) + const resp = await queryService.FeeSharesByWithdrawer(req) + return resp + }, + feeShares: async (args: QueryFeeSharesRequest) => { + const req = QueryFeeSharesRequest.fromPartial(args) + const resp = await queryService.FeeShares(req) + return resp + }, + params: async (args: QueryParamsRequest) => { + const req = QueryParamsRequest.fromPartial(args) + const resp = await queryService.Params(req) + return resp + }, + }, + } +} diff --git a/src/sdk/query/index.ts b/src/sdk/query/index.ts index b7b12019..2f2d83b4 100644 --- a/src/sdk/query/index.ts +++ b/src/sdk/query/index.ts @@ -2,6 +2,7 @@ * @file Automatically generated by barrelsby. */ +export * from "./devgas" export * from "./epochs" export * from "./inflation" export * from "./oracle" diff --git a/src/sdk/query/query.ts b/src/sdk/query/query.ts index c3938a27..fd5169d2 100644 --- a/src/sdk/query/query.ts +++ b/src/sdk/query/query.ts @@ -36,6 +36,8 @@ import { Result, bytesToHex, hexToBytes, + setupDevgasExtension, + DevgasExtension, } from ".." export type NibiruExtensions = StargateQueryClient & @@ -45,6 +47,7 @@ export type NibiruExtensions = StargateQueryClient & InflationExtension & OracleExtension & EpochsExtension & + DevgasExtension & DistributionExtension & GovExtension & StakingExtension & @@ -83,6 +86,7 @@ export class NibiruQuerier extends StargateClient { this.tm = tmClient this.nibiruExtensions = StargateQueryClient.withExtensions( tmClient, + setupDevgasExtension, setupEpochsExtension, setupOracleExtension, setupPerpExtension, diff --git a/src/sdk/tx/txClient.ts b/src/sdk/tx/txClient.ts index 0773b031..98687dc7 100644 --- a/src/sdk/tx/txClient.ts +++ b/src/sdk/tx/txClient.ts @@ -27,6 +27,7 @@ import { setupPerpExtension, setupOracleExtension, setupEpochsExtension, + setupDevgasExtension, } from ".." export const nibiruRegistryTypes: ReadonlyArray<[string, GeneratedType]> = [ @@ -49,6 +50,7 @@ export class NibiruTxClient extends SigningStargateClient { this.wasmClient = wasm this.nibiruExtensions = QueryClient.withExtensions( tmClient, + setupDevgasExtension, setupEpochsExtension, setupOracleExtension, setupPerpExtension,