Skip to content

Commit

Permalink
Merge pull request #326 from NibiruChain/develop
Browse files Browse the repository at this point in the history
feat: devgas query (#325)
  • Loading branch information
cgilbe27 authored Feb 28, 2024
2 parents e6ee1dd + 87e787a commit b239919
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 0 deletions.
55 changes: 55 additions & 0 deletions src/sdk/query/devgas.ts
Original file line number Diff line number Diff line change
@@ -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<QueryFeeShareResponse>
feeSharesByWithdrawer: (
args: QueryFeeSharesByWithdrawerRequest
) => Promise<QueryFeeSharesByWithdrawerResponse>
feeShares: (args: QueryFeeSharesRequest) => Promise<QueryFeeSharesResponse>
params: (args: QueryParamsRequest) => Promise<QueryParamsResponse>
}>
}

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
},
},
}
}
1 change: 1 addition & 0 deletions src/sdk/query/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* @file Automatically generated by barrelsby.
*/

export * from "./devgas"
export * from "./epochs"
export * from "./inflation"
export * from "./oracle"
Expand Down
4 changes: 4 additions & 0 deletions src/sdk/query/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ import {
Result,
bytesToHex,
hexToBytes,
setupDevgasExtension,
DevgasExtension,
} from ".."

export type NibiruExtensions = StargateQueryClient &
Expand All @@ -45,6 +47,7 @@ export type NibiruExtensions = StargateQueryClient &
InflationExtension &
OracleExtension &
EpochsExtension &
DevgasExtension &
DistributionExtension &
GovExtension &
StakingExtension &
Expand Down Expand Up @@ -83,6 +86,7 @@ export class NibiruQuerier extends StargateClient {
this.tm = tmClient
this.nibiruExtensions = StargateQueryClient.withExtensions(
tmClient,
setupDevgasExtension,
setupEpochsExtension,
setupOracleExtension,
setupPerpExtension,
Expand Down
2 changes: 2 additions & 0 deletions src/sdk/tx/txClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
setupPerpExtension,
setupOracleExtension,
setupEpochsExtension,
setupDevgasExtension,
} from ".."

export const nibiruRegistryTypes: ReadonlyArray<[string, GeneratedType]> = [
Expand All @@ -49,6 +50,7 @@ export class NibiruTxClient extends SigningStargateClient {
this.wasmClient = wasm
this.nibiruExtensions = QueryClient.withExtensions(
tmClient,
setupDevgasExtension,
setupEpochsExtension,
setupOracleExtension,
setupPerpExtension,
Expand Down

1 comment on commit b239919

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines Statements Branches Functions
Coverage: 89%
91.2% (1265/1387) 86.28% (541/627) 78.28% (310/396)

Please sign in to comment.