Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fix bug in zod validators #889

Merged
merged 1 commit into from
Jan 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions extensions/viem/src/tevmViemExtension.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const tevmViemExtension = () => {
*/
const request = async (req) => {
try {
const result = await client.request(/** @type any*/ (req))
const result = await client.request(/** @type any*/(req))
return /** @type any */ ({
jsonrpc: '2.0',
method: req.method,
Expand Down Expand Up @@ -103,7 +103,7 @@ export const tevmViemExtension = () => {
...getCallArgs(params),
deployedBytecode: params.deployedBytecode,
data: encodeFunctionData(
/** @type any*/ ({
/** @type any*/({
abi: params.abi,
functionName: params.functionName,
args: params.args,
Expand All @@ -114,7 +114,7 @@ export const tevmViemExtension = () => {
)
)
out.data = decodeFunctionResult(
/** @type any*/ ({
/** @type any*/({
data: out.rawData,
abi: params.abi,
functionName: params.functionName,
Expand Down Expand Up @@ -253,7 +253,7 @@ export const tevmViemExtension = () => {
const out = await call({
...params,
data: encodeFunctionData(
/** @type any*/ ({
/** @type any*/({
abi: params.abi,
functionName: params.functionName,
args: params.args,
Expand All @@ -262,7 +262,7 @@ export const tevmViemExtension = () => {
})

const data = decodeFunctionResult(
/** @type any*/ ({
/** @type any*/({
data: out.rawData,
abi: params.abi,
functionName: params.functionName,
Expand Down
4 changes: 2 additions & 2 deletions packages/memory-client/src/createMemoryClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ export const createMemoryClient = async (options = {}) => {
header: common.genesis(),
...(common.isActivatedEIP(4895)
? {
withdrawals:
withdrawals:
/** @type {Array<import('@ethereumjs/util').WithdrawalData>}*/ ([]),
}
}
: {}),
},
{ common, setHardfork: false, skipConsensusFormatValidation: true },
Comment on lines 100 to 108
Copy link
Contributor

Choose a reason for hiding this comment

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

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [9-9]

The documentation for the createMemoryClient function is well-written, providing a clear example of how to use the function. Consider adding more details about the parameters accepted by the function and the structure of the returned MemoryClient object for improved clarity.


📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [33-33]

The TODO comment about using the tevm/jsonrpc package instead of viem indicates a future improvement. It's important to track this as a task in your project management tool to ensure it doesn't get overlooked.

Would you like me to open a GitHub issue to track the replacement of viem with tevm/jsonrpc?

Expand Down
60 changes: 30 additions & 30 deletions packages/procedures/src/eth/ethCallProcedure.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,34 @@ import { callProcedure } from '../index.js'
* @returns {import('@tevm/procedures-types').EthCallJsonRpcProcedure}
*/
export const ethCallProcedure = (evm) => async (req) => {
const [tx, blockTag] = req.params
const { data, from, to, gas, gasPrice, value } = tx
const response = await callProcedure(evm)({
...(req.id !== undefined ? { id: req.id } : {}),
jsonrpc: req.jsonrpc,
method: 'tevm_call',
params: {
...(gasPrice !== undefined ? { gasPrice } : {}),
...(data !== undefined ? { data } : {}),
...(gas !== undefined ? { gas } : {}),
...(value !== undefined ? { value } : {}),
...(to !== undefined ? { to } : {}),
...(from !== undefined ? { from } : {}),
...(blockTag !== undefined ? { blockTag } : {}),
},
})
if (!response.result) {
return {
jsonrpc: req.jsonrpc,
method: 'eth_call',
error: response.error,
...(req.id !== undefined ? { id: req.id } : {}),
}
}
return {
jsonrpc: req.jsonrpc,
method: 'eth_call',
result: response.result.rawData,
...(req.id !== undefined ? { id: req.id } : {}),
}
const [tx, blockTag] = req.params
const { data, from, to, gas, gasPrice, value } = tx
const response = await callProcedure(evm)({
...(req.id !== undefined ? { id: req.id } : {}),
jsonrpc: req.jsonrpc,
method: 'tevm_call',
params: {
...(gasPrice !== undefined ? { gasPrice } : {}),
...(data !== undefined ? { data } : {}),
...(gas !== undefined ? { gas } : {}),
...(value !== undefined ? { value } : {}),
...(to !== undefined ? { to } : {}),
...(from !== undefined ? { from } : {}),
...(blockTag !== undefined ? { blockTag } : {}),
},
})
if (!response.result) {
return {
jsonrpc: req.jsonrpc,
method: 'eth_call',
error: response.error,
...(req.id !== undefined ? { id: req.id } : {}),
}
}
return {
jsonrpc: req.jsonrpc,
method: 'eth_call',
result: response.result.rawData,
...(req.id !== undefined ? { id: req.id } : {}),
}
}
Loading