From 96014f26dfc4e85bd3b0dd5c1bf1d2dcc799496e Mon Sep 17 00:00:00 2001 From: Cameron Gilbert Date: Wed, 23 Oct 2024 14:37:57 -0400 Subject: [PATCH] chore: update eth proto to latest --- nibiru | 2 +- src/sdk/msg/eth.test.ts | 52 ++++++++++++++++++++++++++------- src/sdk/msg/eth.ts | 14 +++++++++ src/sdk/query/eth.test.ts | 61 ++++++++++++++++++++++++++++++++++++--- src/sdk/query/eth.ts | 4 +++ 5 files changed, 118 insertions(+), 15 deletions(-) diff --git a/nibiru b/nibiru index d71d67dc..3199ae53 160000 --- a/nibiru +++ b/nibiru @@ -1 +1 @@ -Subproject commit d71d67dcf4cd269c7d8d3be5b13a5cd8c4ee27b6 +Subproject commit 3199ae538bc2e1f4bb8d06727d0d10b96c6822a8 diff --git a/src/sdk/msg/eth.test.ts b/src/sdk/msg/eth.test.ts index 50271945..b38f16ae 100644 --- a/src/sdk/msg/eth.test.ts +++ b/src/sdk/msg/eth.test.ts @@ -54,30 +54,62 @@ describe("setupEthMsgExtension", () => { const result = await extension.updateParams({ authority: "", params: { - evmDenom: "", createFuntokenFee: "", - enableCreate: true, - enableCall: true, extraEips: [new Long(0)], - allowUnprotectedTxs: true, - activePrecompiles: [""], evmChannels: [""], }, }) expect(msgUpdateParams).toHaveBeenCalledWith({ authority: "", params: { - evmDenom: "", createFuntokenFee: "", - enableCreate: true, - enableCall: true, extraEips: [new Long(0)], - allowUnprotectedTxs: true, - activePrecompiles: [""], evmChannels: [""], }, }) expect(result).toEqual({ test: "Test" }) }) }) + + describe("createFunToken", () => { + test("should call MsgCreateFunToken and return the response", async () => { + const msgCreateFunToken = jest + .spyOn(query.MsgCreateFunToken, "fromPartial") + .mockReturnValue({} as query.MsgCreateFunToken) + + const extension = setupEthMsgExtension(mockBaseQueryClient) + const result = await extension.createFunToken({ + fromBankDenom: "", + fromErc20: "", + sender: "", + }) + expect(msgCreateFunToken).toHaveBeenCalledWith({ + fromBankDenom: "", + fromErc20: "", + sender: "", + }) + expect(result).toEqual({ test: "Test" }) + }) + }) + + describe("convertCoinToEVM", () => { + test("should call MsgConvertCoinToEvm and return the response", async () => { + const msgConvertCoinToEvm = jest + .spyOn(query.MsgConvertCoinToEvm, "fromPartial") + .mockReturnValue({} as query.MsgConvertCoinToEvm) + + const extension = setupEthMsgExtension(mockBaseQueryClient) + const result = await extension.convertCoinToEVM({ + toEthAddr: "", + bankCoin: { denom: "", amount: "" }, + sender: "", + }) + expect(msgConvertCoinToEvm).toHaveBeenCalledWith({ + toEthAddr: "", + bankCoin: { denom: "", amount: "" }, + sender: "", + }) + expect(result).toEqual({ test: "Test" }) + }) + }) }) diff --git a/src/sdk/msg/eth.ts b/src/sdk/msg/eth.ts index dce30c0c..8f9af639 100644 --- a/src/sdk/msg/eth.ts +++ b/src/sdk/msg/eth.ts @@ -1,6 +1,10 @@ import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate" import { MsgClientImpl, + MsgConvertCoinToEvm, + MsgConvertCoinToEvmResponse, + MsgCreateFunToken, + MsgCreateFunTokenResponse, MsgEthereumTx, MsgEthereumTxResponse, MsgUpdateParams, @@ -10,6 +14,12 @@ import { export interface EthMsgExtension { ethereumTx: (body: MsgEthereumTx) => Promise updateParams: (body: MsgUpdateParams) => Promise + createFunToken: ( + body: MsgCreateFunToken + ) => Promise + convertCoinToEVM: ( + body: MsgConvertCoinToEvm + ) => Promise } export const setupEthMsgExtension = (base: QueryClient): EthMsgExtension => { @@ -20,5 +30,9 @@ export const setupEthMsgExtension = (base: QueryClient): EthMsgExtension => { queryService.EthereumTx(MsgEthereumTx.fromPartial(body)), updateParams: async (body: MsgUpdateParams) => queryService.UpdateParams(MsgUpdateParams.fromPartial(body)), + createFunToken: async (body: MsgCreateFunToken) => + queryService.CreateFunToken(MsgCreateFunToken.fromPartial(body)), + convertCoinToEVM: async (body: MsgConvertCoinToEvm) => + queryService.ConvertCoinToEvm(MsgConvertCoinToEvm.fromPartial(body)), } } diff --git a/src/sdk/query/eth.test.ts b/src/sdk/query/eth.test.ts index d7d40dd7..04eb0630 100644 --- a/src/sdk/query/eth.test.ts +++ b/src/sdk/query/eth.test.ts @@ -36,6 +36,9 @@ describe("setupEpochsExtension", () => { TraceBlock: jest.fn().mockResolvedValue({ traceBlock: "Test", }), + TraceCall: jest.fn().mockResolvedValue({ + traceCall: "Test", + }), BaseFee: jest.fn().mockResolvedValue({ baseFee: "Test", }), @@ -58,6 +61,7 @@ describe("setupEpochsExtension", () => { expect(extension.estimateGas).toBeInstanceOf(Function) expect(extension.traceTx).toBeInstanceOf(Function) expect(extension.traceBlock).toBeInstanceOf(Function) + expect(extension.traceCall).toBeInstanceOf(Function) expect(extension.baseFee).toBeInstanceOf(Function) expect(extension.funTokenMapping).toBeInstanceOf(Function) }) @@ -244,7 +248,6 @@ describe("setupEpochsExtension", () => { limit: 0, enableMemory: true, enableReturnData: true, - tracerJsonConfig: "", }, predecessors: [MsgEthereumTx.fromPartial({})], blockNumber: new Long(0), @@ -267,7 +270,6 @@ describe("setupEpochsExtension", () => { limit: 0, enableMemory: true, enableReturnData: true, - tracerJsonConfig: "", }, predecessors: [MsgEthereumTx.fromPartial({})], blockNumber: new Long(0), @@ -300,7 +302,6 @@ describe("setupEpochsExtension", () => { limit: 0, enableMemory: true, enableReturnData: true, - tracerJsonConfig: "", }, blockNumber: new Long(0), blockHash: "", @@ -321,7 +322,6 @@ describe("setupEpochsExtension", () => { limit: 0, enableMemory: true, enableReturnData: true, - tracerJsonConfig: "", }, blockNumber: new Long(0), blockHash: "", @@ -334,6 +334,59 @@ describe("setupEpochsExtension", () => { }) }) + describe("traceCall", () => { + test("should call QueryTraceTxRequest and return the response", async () => { + const queryTraceTxRequest = jest + .spyOn(query.QueryTraceTxRequest, "fromPartial") + .mockReturnValue({} as query.QueryTraceTxRequest) + + const extension = setupEthExtension(mockBaseQueryClient) + const result = await extension.traceCall({ + msg: { + data: { typeUrl: "", value: new Uint8Array() }, + size: 0, + hash: "", + from: "", + }, + predecessors: [ + { + data: { typeUrl: "", value: new Uint8Array() }, + size: 0, + hash: "", + from: "", + }, + ], + blockHash: "", + blockMaxGas: new Long(0), + proposerAddress: new Uint8Array(), + blockNumber: new Long(0), + chainId: new Long(0), + }) + expect(queryTraceTxRequest).toHaveBeenCalledWith({ + msg: { + data: { typeUrl: "", value: new Uint8Array() }, + size: 0, + hash: "", + from: "", + }, + predecessors: [ + { + data: { typeUrl: "", value: new Uint8Array() }, + size: 0, + hash: "", + from: "", + }, + ], + blockHash: "", + blockMaxGas: new Long(0), + proposerAddress: new Uint8Array(), + blockNumber: new Long(0), + chainId: new Long(0), + }) + expect(result).toEqual({ traceBlock: "Test" }) + }) + }) + describe("baseFee", () => { test("should call QueryBaseFeeRequest and return the response", async () => { const queryBaseFeeRequest = jest diff --git a/src/sdk/query/eth.ts b/src/sdk/query/eth.ts index 262b8a8c..934560b0 100644 --- a/src/sdk/query/eth.ts +++ b/src/sdk/query/eth.ts @@ -39,6 +39,7 @@ export interface EthExtension { estimateGas: (args: EthCallRequest) => Promise traceTx: (args: QueryTraceTxRequest) => Promise traceBlock: (args: QueryTraceBlockRequest) => Promise + traceCall: (args: QueryTraceTxRequest) => Promise baseFee: (args: QueryBaseFeeRequest) => Promise funTokenMapping: ( request: QueryFunTokenMappingRequest @@ -81,6 +82,9 @@ export const setupEthExtension = (base: QueryClient): EthExtension => { traceBlock: async (args: QueryTraceBlockRequest) => queryService.TraceBlock(QueryTraceBlockRequest.fromPartial(args)), + traceCall: async (args: QueryTraceTxRequest) => + queryService.TraceCall(QueryTraceTxRequest.fromPartial(args)), + baseFee: async (args: QueryBaseFeeRequest) => queryService.BaseFee(QueryBaseFeeRequest.fromPartial(args)),