Skip to content

Commit

Permalink
fix: build
Browse files Browse the repository at this point in the history
  • Loading branch information
cgilbe27 committed Aug 7, 2024
1 parent 35eb2d8 commit 79fcd49
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 34 deletions.
26 changes: 13 additions & 13 deletions src/sdk/query/eth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ describe("setupEpochsExtension", () => {

jest.spyOn(query, "QueryClientImpl").mockReturnValue({
EthAccount: jest.fn().mockResolvedValue({ ethAccount: "Test" }),
NibiruAccount: jest.fn().mockResolvedValue({
nibiruAccount: "Test",
}),
ValidatorAccount: jest.fn().mockResolvedValue({
validatorAccount: "Test",
}),
Expand Down Expand Up @@ -42,14 +39,16 @@ describe("setupEpochsExtension", () => {
BaseFee: jest.fn().mockResolvedValue({
baseFee: "Test",
}),
FunTokenMapping: jest.fn().mockResolvedValue({
baseFee: "Test",
}),
} as unknown as query.QueryClientImpl)

test("should setup extension correctly", () => {
const extension = setupEthExtension(mockBaseQueryClient)

expect(extension).toBeDefined()
expect(extension.ethAccount).toBeInstanceOf(Function)
expect(extension.nibiruAccount).toBeInstanceOf(Function)
expect(extension.validatorAccount).toBeInstanceOf(Function)
expect(extension.balance).toBeInstanceOf(Function)
expect(extension.storage).toBeInstanceOf(Function)
Expand All @@ -60,6 +59,7 @@ describe("setupEpochsExtension", () => {
expect(extension.traceTx).toBeInstanceOf(Function)
expect(extension.traceBlock).toBeInstanceOf(Function)
expect(extension.baseFee).toBeInstanceOf(Function)
expect(extension.funTokenMapping).toBeInstanceOf(Function)
})

describe("ethAccount", () => {
Expand All @@ -79,18 +79,18 @@ describe("setupEpochsExtension", () => {
})
})

describe("nibiruAccount", () => {
test("should call QueryNibiruAccountRequest and return the response", async () => {
const queryNibiruAccountRequest = jest
.spyOn(query.QueryNibiruAccountRequest, "fromPartial")
.mockReturnValue({} as query.QueryNibiruAccountRequest)
describe("funTokenMapping", () => {
test("should call QueryFunTokenMappingRequest and return the response", async () => {
const queryFunTokenMappingRequest = jest
.spyOn(query.QueryFunTokenMappingRequest, "fromPartial")
.mockReturnValue({} as query.QueryFunTokenMappingRequest)

const extension = setupEthExtension(mockBaseQueryClient)
const result = await extension.nibiruAccount({
address: "",
const result = await extension.funTokenMapping({
token: "",
})
expect(queryNibiruAccountRequest).toHaveBeenCalledWith({
address: "",
expect(queryFunTokenMappingRequest).toHaveBeenCalledWith({
token: "",
})
expect(result).toEqual({ nibiruAccount: "Test" })
})
Expand Down
18 changes: 10 additions & 8 deletions src/sdk/query/eth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import {
QueryCodeResponse,
QueryEthAccountRequest,
QueryEthAccountResponse,
QueryNibiruAccountRequest,
QueryNibiruAccountResponse,
QueryFunTokenMappingRequest,
QueryFunTokenMappingResponse,
QueryParamsRequest,
QueryParamsResponse,
QueryStorageRequest,
Expand All @@ -28,9 +28,6 @@ import { MsgEthereumTxResponse } from "../../protojs/eth/evm/v1/tx"

export interface EthExtension {
ethAccount: (args: QueryEthAccountRequest) => Promise<QueryEthAccountResponse>
nibiruAccount: (
args: QueryNibiruAccountRequest
) => Promise<QueryNibiruAccountResponse>
validatorAccount: (
args: QueryValidatorAccountRequest
) => Promise<QueryValidatorAccountResponse>
Expand All @@ -43,6 +40,9 @@ export interface EthExtension {
traceTx: (args: QueryTraceTxRequest) => Promise<QueryTraceTxResponse>
traceBlock: (args: QueryTraceBlockRequest) => Promise<QueryTraceBlockResponse>
baseFee: (args: QueryBaseFeeRequest) => Promise<QueryBaseFeeResponse>
funTokenMapping: (
request: QueryFunTokenMappingRequest
) => Promise<QueryFunTokenMappingResponse>
}

export const setupEthExtension = (base: QueryClient): EthExtension => {
Expand All @@ -52,9 +52,6 @@ export const setupEthExtension = (base: QueryClient): EthExtension => {
ethAccount: async (args: QueryEthAccountRequest) =>
queryService.EthAccount(QueryEthAccountRequest.fromPartial(args)),

nibiruAccount: async (args: QueryNibiruAccountRequest) =>
queryService.NibiruAccount(QueryNibiruAccountRequest.fromPartial(args)),

validatorAccount: async (args: QueryValidatorAccountRequest) =>
queryService.ValidatorAccount(
QueryValidatorAccountRequest.fromPartial(args)
Expand Down Expand Up @@ -86,5 +83,10 @@ export const setupEthExtension = (base: QueryClient): EthExtension => {

baseFee: async (args: QueryBaseFeeRequest) =>
queryService.BaseFee(QueryBaseFeeRequest.fromPartial(args)),

funTokenMapping: async (args: QueryFunTokenMappingRequest) =>
queryService.FunTokenMapping(
QueryFunTokenMappingRequest.fromPartial(args)
),
}
}
13 changes: 0 additions & 13 deletions src/sdk/query/query.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,6 @@ import {
newSignerFromMnemonic,
NibiruTxClient,
setupNibiruExtension,
setupDevgasExtension,
setupDevgasMsgExtension,
setupEpochsExtension,
setupEthExtension,
setupEthMsgExtension,
setupInflationExtension,
setupInflationMsgExtension,
setupOracleExtension,
setupOracleMsgExtension,
setupSudoExtension,
setupSudoMsgExtension,
setupTokenFactoryExtension,
setupTokenFactoryMsgExtension,
} from ".."

interface BlockResp {
Expand Down

0 comments on commit 79fcd49

Please sign in to comment.