Skip to content

Commit

Permalink
chore: update eth proto to latest
Browse files Browse the repository at this point in the history
  • Loading branch information
cgilbe27 committed Oct 23, 2024
1 parent 2968cbc commit 96014f2
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 15 deletions.
2 changes: 1 addition & 1 deletion nibiru
Submodule nibiru updated 571 files
52 changes: 42 additions & 10 deletions src/sdk/msg/eth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" })
})
})
})
14 changes: 14 additions & 0 deletions src/sdk/msg/eth.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate"
import {
MsgClientImpl,
MsgConvertCoinToEvm,
MsgConvertCoinToEvmResponse,
MsgCreateFunToken,
MsgCreateFunTokenResponse,
MsgEthereumTx,
MsgEthereumTxResponse,
MsgUpdateParams,
Expand All @@ -10,6 +14,12 @@ import {
export interface EthMsgExtension {
ethereumTx: (body: MsgEthereumTx) => Promise<MsgEthereumTxResponse>
updateParams: (body: MsgUpdateParams) => Promise<MsgUpdateParamsResponse>
createFunToken: (
body: MsgCreateFunToken
) => Promise<MsgCreateFunTokenResponse>
convertCoinToEVM: (
body: MsgConvertCoinToEvm
) => Promise<MsgConvertCoinToEvmResponse>
}

export const setupEthMsgExtension = (base: QueryClient): EthMsgExtension => {
Expand All @@ -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)),
}
}
61 changes: 57 additions & 4 deletions src/sdk/query/eth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ describe("setupEpochsExtension", () => {
TraceBlock: jest.fn().mockResolvedValue({
traceBlock: "Test",
}),
TraceCall: jest.fn().mockResolvedValue({
traceCall: "Test",
}),
BaseFee: jest.fn().mockResolvedValue({
baseFee: "Test",
}),
Expand All @@ -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)
})
Expand Down Expand Up @@ -244,7 +248,6 @@ describe("setupEpochsExtension", () => {
limit: 0,
enableMemory: true,
enableReturnData: true,
tracerJsonConfig: "",
},
predecessors: [MsgEthereumTx.fromPartial({})],
blockNumber: new Long(0),
Expand All @@ -267,7 +270,6 @@ describe("setupEpochsExtension", () => {
limit: 0,
enableMemory: true,
enableReturnData: true,
tracerJsonConfig: "",
},
predecessors: [MsgEthereumTx.fromPartial({})],
blockNumber: new Long(0),
Expand Down Expand Up @@ -300,7 +302,6 @@ describe("setupEpochsExtension", () => {
limit: 0,
enableMemory: true,
enableReturnData: true,
tracerJsonConfig: "",
},
blockNumber: new Long(0),
blockHash: "",
Expand All @@ -321,7 +322,6 @@ describe("setupEpochsExtension", () => {
limit: 0,
enableMemory: true,
enableReturnData: true,
tracerJsonConfig: "",
},
blockNumber: new Long(0),
blockHash: "",
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/sdk/query/eth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export interface EthExtension {
estimateGas: (args: EthCallRequest) => Promise<EstimateGasResponse>
traceTx: (args: QueryTraceTxRequest) => Promise<QueryTraceTxResponse>
traceBlock: (args: QueryTraceBlockRequest) => Promise<QueryTraceBlockResponse>
traceCall: (args: QueryTraceTxRequest) => Promise<QueryTraceTxResponse>
baseFee: (args: QueryBaseFeeRequest) => Promise<QueryBaseFeeResponse>
funTokenMapping: (
request: QueryFunTokenMappingRequest
Expand Down Expand Up @@ -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)),

Expand Down

0 comments on commit 96014f2

Please sign in to comment.