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

✨ Feat: Add getBlockBy support #1114

Merged
merged 35 commits into from
May 22, 2024

Conversation

roninjin10
Copy link
Collaborator

@roninjin10 roninjin10 commented May 21, 2024

TL;DR

Uncomment more tests in viem public actions
Implement getBlockBy support

What changed?

  • Fixed tests in viemPublicActions

How to test?

Run the tests in viemPublicActions

Why make this change?

To ensure all tests in viemPublicActions pass


Description

Concise description of proposed changes

Testing

Explain the quality checks that have been done on the code changes

Additional Information

Your ENS/address:

Summary by CodeRabbit

  • New Features

    • Added a new CustomCrypto type and customCrypto field to CommonOptions in createChainCommon function.
    • Introduced a MockKzg type with functions for zero-knowledge proofs and commitments.
    • Added methods for converting transactions and blocks to JSON-RPC formats.
  • Bug Fixes

    • Fixed a bug in TransactionResult that caused it to return incorrect values.
  • Dependencies

    • Updated dependency versions for better compatibility and future-proofing.

William Cory and others added 25 commits May 21, 2024 11:31
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link

vercel bot commented May 21, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
tevm-monorepo-tevm ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 22, 2024 7:38am

Copy link

changeset-bot bot commented May 21, 2024

🦋 Changeset detected

Latest commit: a52aa84

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 12 packages
Name Type
@tevm/chains Minor
@tevm/base-client Minor
@tevm/memory-client Minor
@tevm/procedures Minor
tevm Minor
@tevm/actions-types Minor
@tevm/ethers Minor
@tevm/actions Minor
@tevm/decorators Minor
@tevm/opstack Minor
@tevm/http-client Minor
@tevm/server Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

coderabbitai bot commented May 21, 2024

Warning

Rate Limit Exceeded

@roninjin10 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 41 minutes and 14 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.

Commits Files that changed from the base of the PR and between 1183e96 and a52aa84.

Walkthrough

The recent updates across various packages bring significant enhancements, including the addition of generic parameters to types, field renaming for clarity, dependency version updates for compatibility, and the introduction of new utilities and functions. These changes aim to boost type flexibility, maintainability, and overall functionality within the codebase.

Changes

Files/Paths Change Summary
.../BlockResult.ts, .../TransactionResult.ts Added generic parameter TIncludeTransactions to BlockResult, renamed input field to data in TransactionResult.
.../base-client/package.json, .../chains/package.json, .../memory-client/package.json, .../tevm/package.json Updated dependency versions for @tevm/chains and @tevm/common to use caret (^) symbol.
.../procedures/package.json Added new dependency "@tevm/tx": "workspace:1.1.0-next.52".
.../procedures/src/requestProcedure.js Imported new utility functions, modified function signatures for handling Ethereum RPC requests.
.../procedures/src/utils/blockToJsonRpcBlock.js, .../procedures/src/utils/txToJsonRpcTx.js Introduced functions for converting block and transaction objects to JSON-RPC format.
.../memory-client/src/test/viemPublicActions.spec.ts Updated viem functions, added new ENS-related functions for enhanced functionality.
.../changeset/neat-dots-tap.md, .../changeset/rude-lamps-sell.md, .../changeset/soft-panthers-boil.md, .../changeset/wet-ducks-speak.md Introduced additions to JSON-RPC endpoints and verification tests for Viem PublicActions.
.../actions-types/docs/type-aliases/BlockResult.md, .../actions-types/docs/type-aliases/TransactionResult.md Updated type aliases to include new fields and parameters for BlockResult and TransactionResult.
.../chains/docs/README.md Adjusted image tags and hyperlink attributes in the documentation.

In code's realm, where changes weave,
Types and fields now interleave.
Dependencies climb, with caret's grace,
Functions enhance, new paths embrace.
A rabbit hops through lines of lore,
Celebrating updates, forevermore.
🌟👩‍💻🐇


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Collaborator Author

roninjin10 commented May 21, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @roninjin10 and the rest of your teammates on Graphite Graphite

@roninjin10 roninjin10 marked this pull request as ready for review May 21, 2024 22:10
Base automatically changed from 05-21-_package_feat_add_new_tevm_chain_package to main May 21, 2024 22:56
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 4ca4f87 and de5c707.
Files ignored due to path filters (2)
  • packages/memory-client/src/test/__snapshots__/viemPublicActions.spec.ts.snap is excluded by !**/*.snap
  • pnpm-lock.yaml is excluded by !pnpm-lock.yaml
Files selected for processing (11)
  • packages/actions-types/src/common/BlockResult.ts (2 hunks)
  • packages/actions-types/src/common/TransactionResult.ts (1 hunks)
  • packages/base-client/package.json (1 hunks)
  • packages/chains/package.json (1 hunks)
  • packages/memory-client/package.json (1 hunks)
  • packages/memory-client/src/test/viemPublicActions.spec.ts (4 hunks)
  • packages/procedures/package.json (1 hunks)
  • packages/procedures/src/requestProcedure.js (3 hunks)
  • packages/procedures/src/utils/blockToJsonRpcBlock.js (1 hunks)
  • packages/procedures/src/utils/txToJsonRpcTx.js (1 hunks)
  • tevm/package.json (1 hunks)
Files skipped from review due to trivial changes (5)
  • packages/actions-types/src/common/TransactionResult.ts
  • packages/base-client/package.json
  • packages/chains/package.json
  • packages/memory-client/package.json
  • tevm/package.json
Additional comments not posted (3)
packages/actions-types/src/common/BlockResult.ts (1)

Line range hint 8-37: The introduction of a generic parameter to conditionally alter the transactions type enhances type safety and flexibility. Good improvement!

packages/procedures/package.json (1)

68-69: The addition of @tevm/tx as a dependency is consistent with the new transaction-related functionalities introduced in the codebase.

packages/procedures/src/requestProcedure.js (1)

377-433: The implementation of getBlockByHash and getBlockByNumber aligns well with the PR's objectives to enhance block retrieval functionalities. Well done!

Comment on lines +1 to +40
import { bytesToHex, numberToHex } from '@tevm/utils'

/**
* @param {import('@tevm/tx').TypedTransaction | import('@tevm/tx').ImpersonatedTx} tx
* @param {import('@tevm/block').Block} block
* @param {number} [txIndex]
* @returns {import('@tevm/actions-types').TransactionResult}
*/
export const txToJsonRpcTx = (tx, block, txIndex) => {
const txJSON = tx.toJSON()
// TODO make this typing less janky
return /** @type any*/ ({
blockHash: bytesToHex(block.hash()),
blockNumber: numberToHex(block.header.number),
from: /** @type {import('@tevm/utils').Address}*/ (tx.getSenderAddress().toString()),
gas: /** @type {import('@tevm/utils').Hex} **/ (txJSON.gasLimit),
gasPrice: /** @type {import('@tevm/utils').Hex}*/ (txJSON.gasPrice ?? txJSON.maxFeePerGas),
// TODO add this to the type
...{ maxFeePerGas: txJSON.maxFeePerGas },
// TODO add this to the type
...{ maxPriorityFeePerGas: txJSON.maxPriorityFeePerGas },
// TODO add this to the type
...{ type: numberToHex(tx.type) },
...(txJSON.accessList !== undefined ? { accessList: txJSON.accessList } : {}),
hash: bytesToHex(tx.hash()),
data: /** @type {import('@tevm/utils').Hex} */ (txJSON.data),
nonce: /** @type {import('@tevm/utils').Hex}*/ (txJSON.nonce),
// these toString existed in ethereumjs but I don't think are necessary
...(txJSON.to !== undefined ? { to: /** @type {import('@tevm/utils').Address} */ (txJSON.to.toString()) } : {}),
...(txIndex !== undefined ? { transactionIndex: numberToHex(txIndex) } : {}),
...(txJSON.value !== undefined ? { value: txJSON.value } : {}),
...('isImpersonated' in tx ? { isImpersonated: tx.isImpersonated } : {}),
...(txJSON.v !== undefined ? { v: txJSON.v } : {}),
...(txJSON.r !== undefined ? { r: txJSON.r } : {}),
...(txJSON.s !== undefined ? { s: txJSON.s } : {}),
// TODO add this to the type
...{ maxFeePerBlobGas: txJSON.maxFeePerBlobGas },
// TODO add this to the type
...{ blobVersionedHashes: txJSON.blobVersionedHashes },
})
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider completing the type definitions for the transaction fields marked with TODO comments to ensure type safety and maintainability.

Comment on lines +1 to +62
import { bytesToHex, numberToHex, toBytes } from '@tevm/utils'
import { txToJsonRpcTx } from './txToJsonRpcTx.js'

/**
* @param {import('@tevm/block').Block} block
* @param {boolean} includeTransactions
* @returns {Promise<import('@tevm/procedures-types').EthGetBlockByHashJsonRpcResponse['result']>}
*/
export const blockToJsonRpcBlock = async (block, includeTransactions) => {
const json = block.toJSON()
const header = /** @type {import('@tevm/block').JsonHeader}*/ (json.header)
const transactions = block.transactions.map((tx, txIndex) =>
includeTransactions ? txToJsonRpcTx(tx, block, txIndex) : bytesToHex(tx.hash()),
)

/**
* @type {import('@tevm/procedures-types').EthGetBlockByHashJsonRpcResponse['result']}
*/
const out = {
number: /** @type {import('@tevm/utils').Hex}*/ (header.number),
hash: bytesToHex(block.hash()),
parentHash: /** @type {import('@tevm/utils').Hex}*/ (header.parentHash),
// TODO add this to the type
...{ mixHash: header.mixHash },
nonce: /** @type {import('@tevm/utils').Hex}*/ (header.nonce),
sha3Uncles: /** @type {import('@tevm/utils').Hex}*/ (header.uncleHash),
logsBloom: /** @type {import('@tevm/utils').Hex}*/ (header.logsBloom),
transactionsRoot: /** @type {import('@tevm/utils').Hex}*/ (header.transactionsTrie),
stateRoot: /** @type {import('@tevm/utils').Hex}*/ (header.stateRoot),
miner: /** @type {import('@tevm/utils').Address}*/ (header.coinbase),
difficulty: /** @type {import('@tevm/utils').Hex}*/ (header.difficulty),
// TODO we need to actually add this
totalDifficulty: /** @type {import('@tevm/utils').Hex}*/ ('0x0'),
extraData: /** @type {import('@tevm/utils').Hex}*/ (header.extraData),
size: numberToHex(toBytes(JSON.stringify(json)).byteLength),
gasLimit: /** @type {import('@tevm/utils').Hex}*/ (header.gasLimit),
gasUsed: /** @type {import('@tevm/utils').Hex}*/ (header.gasUsed),
timestamp: /** @type {import('@tevm/utils').Hex}*/ (header.timestamp),
uncles: block.uncleHeaders.map((uh) => bytesToHex(uh.hash())),
// TODO fix this type
transactions: /** @type any*/ (transactions),
// TODO add this to the type
...{ baseFeePerGas: header.baseFeePerGas },
...{ receiptsRoot: header.receiptTrie },
...(header.withdrawalsRoot !== undefined
? {
withdrawalsRoot: header.withdrawalsRoot,
withdrawals: json.withdrawals,
}
: {}),
...(header.blobGasUsed !== undefined ? { blobGasUsed: header.blobGasUsed } : {}),
// TODO add this to the type
...{ requestsRoot: header.requestsRoot },
// TODO add this to the type
...{ requests: block.requests?.map((req) => bytesToHex(req.serialize())) },
// TODO add this to the type
...{ excessBlobGas: header.excessBlobGas },
// TODO add this to the type
...{ parentBeaconBlockRoot: header.parentBeaconBlockRoot },
}

return out
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider completing the type definitions for the block fields marked with TODO comments to ensure type safety and maintainability.

Comment on lines 196 to 243
{ timeout: 40_000 },
)
},
getEnsAvatar: async () => {
const kzg = await loadKZG()
const mainnetClient = createMemoryClient({
chainCommon: mainnet,
fork: {
url: getAlchemyUrl('mainnet'),
},
customCrypto: {
kzg,
},
})
it(
'should work',
async () => {
// wait to avoid throttling
await new Promise((resolve) => setTimeout(resolve, 1_000))
expect(await mainnetClient.getEnsAvatar({ name: 'vitalik.eth' })).toBe(
'https://ipfs.io/ipfs/QmSP4nq9fnN9dAiCj42ug9Wa79rqmQerZXZch82VqpiH7U/image.gif',
)
},
{ timeout: 40_000 },
)
},
getEnsAvatar: () => {
getEnsName: async () => {
const kzg = await loadKZG()
const mainnetClient = createMemoryClient({
chainCommon: mainnet,
fork: {
url: getAlchemyUrl('mainnet'),
},
customCrypto: {
kzg,
},
})
it(
'should work',
async () => {
// wait to avoid throttling
await new Promise((resolve) => setTimeout(resolve, 1_000))
expect(await mainnetClient.getEnsName({ address: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045' })).toBe(
'vitalik.eth',
)
},
{ timeout: 40_000 },
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider replacing setTimeout used for throttling with a more robust method or utility function that can handle rate limits more reliably in tests.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between de5c707 and e1241e9.
Files selected for processing (9)
  • .changeset/neat-dots-tap.md (1 hunks)
  • .changeset/rude-lamps-sell.md (1 hunks)
  • .changeset/soft-panthers-boil.md (1 hunks)
  • .changeset/wet-ducks-speak.md (1 hunks)
  • packages/actions-types/docs/type-aliases/BlockResult.md (3 hunks)
  • packages/actions-types/docs/type-aliases/TransactionResult.md (2 hunks)
  • packages/chains/docs/README.md (2 hunks)
  • tevm/docs/actions-types/type-aliases/BlockResult.md (3 hunks)
  • tevm/docs/actions-types/type-aliases/TransactionResult.md (2 hunks)
Files skipped from review due to trivial changes (1)
  • .changeset/neat-dots-tap.md
Additional Context Used
Markdownlint (2)
packages/chains/docs/README.md (2)

9: null
Images should have alternate text (alt text)


41: null
Images should have alternate text (alt text)

Additional comments not posted (9)
.changeset/soft-panthers-boil.md (1)

6-6: The changeset description clearly communicates the fix applied to TransactionResult.

.changeset/wet-ducks-speak.md (1)

6-6: The changeset description clearly communicates the fix applied to BlockResult.

.changeset/rude-lamps-sell.md (1)

6-6: The changeset description clearly communicates the addition of verification tests to Viem PublicActions.

tevm/docs/actions-types/type-aliases/TransactionResult.md (1)

26-26: The documentation accurately reflects the changes made to the TransactionResult type.

packages/actions-types/docs/type-aliases/TransactionResult.md (1)

26-26: The documentation accurately reflects the changes made to the TransactionResult type.

tevm/docs/actions-types/type-aliases/BlockResult.md (2)

7-17: The introduction and type parameters are clearly documented and provide a good understanding of the BlockResult type's purpose and usage.


90-90: The conditional type for the transactions property enhances flexibility and type safety, allowing users to specify the type of transactions they expect based on their needs.

packages/actions-types/docs/type-aliases/BlockResult.md (2)

7-17: The introduction and type parameters are clearly documented and provide a good understanding of the BlockResult type's purpose and usage.


90-90: The conditional type for the transactions property enhances flexibility and type safety, allowing users to specify the type of transactions they expect based on their needs.

@@ -6,8 +6,7 @@
<a href="https://tevm.sh/">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/35039927/218812217-92f0f784-cb85-43b9-9ca6-e2b9effd9eb2.png">
<img alt="TEVM Chains Logo" src="https://user-images.githubusercontent.com/35039927/218812217-92f0f784-cb85-43b9-9ca6-e2b9effd9eb2.png" width="auto" height="300">
<img alt="License Information" src="https://user-images.githubusercontent.com/35039927/231030761-66f5ce58-a4e9-4695-b1fe-255b1bceac92.png" width="200" />
<img src="https://user-images.githubusercontent.com/35039927/218812217-92f0f784-cb85-43b9-9ca6-e2b9effd9eb2.png" width="auto" height="300">
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add alternate text (alt text) to the image for accessibility.

- <img src="https://user-images.githubusercontent.com/35039927/218812217-92f0f784-cb85-43b9-9ca6-e2b9effd9eb2.png" width="auto" height="300">
+ <img src="https://user-images.githubusercontent.com/35039927/218812217-92f0f784-cb85-43b9-9ca6-e2b9effd9eb2.png" alt="TEVM Chains Logo" width="auto" height="300">

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
<img src="https://user-images.githubusercontent.com/35039927/218812217-92f0f784-cb85-43b9-9ca6-e2b9effd9eb2.png" width="auto" height="300">
<img src="https://user-images.githubusercontent.com/35039927/218812217-92f0f784-cb85-43b9-9ca6-e2b9effd9eb2.png" alt="TEVM Chains Logo" width="auto" height="300">

@@ -18,7 +17,7 @@

[![CI](https://github.com/evmts/tevm-monorepo/actions/workflows/e2e.yml/badge.svg)](https://github.com/evmts/tevm-monorepo/actions/workflows/e2e.yml)
[![CI](https://github.com/evmts/tevm-monorepo/actions/workflows/unit.yml/badge.svg)](https://github.com/evmts/tevm-monorepo/actions/workflows/unit.yml)
<a href="https://www.npmjs.com/package/@tevm/chains" target="\_parent">
<a href="https://www.npmjs.com/package/@tevm/chains" target="_parent">
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add alternate text (alt text) to the image for accessibility.

- <img src="https://user-images.githubusercontent.com/35039927/231030761-66f5ce58-a4e9-4695-b1fe-255b1bceac92.png" width="200" />
+ <img src="https://user-images.githubusercontent.com/35039927/231030761-66f5ce58-a4e9-4695-b1fe-255b1bceac92.png" alt="TEVM Chains License" width="200" />

Committable suggestion was skipped due low confidence.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between e1241e9 and 1183e96.
Files ignored due to path filters (1)
  • packages/memory-client/src/test/__snapshots__/viemPublicActions.spec.ts.snap is excluded by !**/*.snap
Files selected for processing (9)
  • .changeset/clever-wasps-fry.md (1 hunks)
  • .changeset/green-coins-camp.md (1 hunks)
  • packages/base-client/src/MockKzg.ts (1 hunks)
  • packages/base-client/src/createBaseClient.js (3 hunks)
  • packages/base-client/src/createMockKzg.js (1 hunks)
  • packages/chains/src/index.ts (3 hunks)
  • packages/memory-client/src/test/viemPublicActions.spec.ts (4 hunks)
  • packages/procedures/.depcheckrc (1 hunks)
  • packages/procedures/src/requestProcedure.js (3 hunks)
Files skipped from review due to trivial changes (2)
  • .changeset/clever-wasps-fry.md
  • packages/procedures/.depcheckrc
Additional comments not posted (15)
.changeset/green-coins-camp.md (1)

1-5: LGTM! Clear description of the patch update for @tevm/base-client.

packages/base-client/src/createMockKzg.js (1)

1-16: LGTM! The mock functions are appropriately defined for testing purposes.

packages/base-client/src/MockKzg.ts (1)

1-9: LGTM! The type definitions for MockKzg are consistent with the implementation.

packages/chains/src/index.ts (1)

Line range hint 30-45: LGTM! The addition of customCrypto as an optional parameter enhances cryptographic customization per chain.

packages/base-client/src/createBaseClient.js (1)

Line range hint 12-138: LGTM! The integration of createMockKzg in the customCrypto configuration is appropriate for testing environments.

packages/memory-client/src/test/viemPublicActions.spec.ts (1)

Line range hint 7-343: LGTM! The new tests in viemPublicActions.spec.ts are well-structured and relevant to the PR objectives.

packages/procedures/src/requestProcedure.js (9)

4-4: Ensure the new utility functions are used appropriately.

The addition of hexToBytes, hexToNumber, and the new utility function imports are correctly placed and seem to be used appropriately in the context of the file.


26-27: Validate the integration of new utility functions.

The import statements for blockToJsonRpcBlock and txToJsonRpcTx are correctly added. Ensure that these functions are used effectively in the corresponding RPC method handlers.


377-390: Review the implementation of eth_getBlockByHash.

The implementation for eth_getBlockByHash correctly retrieves the block using hexToBytes to convert the hash and handles the includeTransactions parameter effectively. The use of blockToJsonRpcBlock to format the response is appropriate.


392-432: Review the implementation of eth_getBlockByNumber.

The method eth_getBlockByNumber is implemented with a clear structure. It handles different types of block identifiers (hex or tag) and correctly uses blockToJsonRpcBlock for formatting the response. The error handling for non-existent blocks is also in place.


434-446: Review the implementation of eth_getBlockTransactionCountByHash.

This method correctly fetches the block and calculates the transaction count. The use of numberToHex for the result ensures the response format aligns with JSON-RPC specifications.


448-477: Review the implementation of eth_getBlockTransactionCountByNumber.

Similar to the hash variant, this method handles the block number input correctly, fetching the block and returning the transaction count in the expected format.


479-525: Review the implementation of eth_getTransactionByHash.

The method handles fetching the transaction by hash appropriately, using the receipts manager and formatting the response with txToJsonRpcTx. Error handling for missing transactions is also correctly implemented.


527-551: Review the implementation of eth_getTransactionByBlockHashAndIndex.

This method effectively retrieves a transaction based on block hash and index, using the utility functions for conversion and response formatting. The error handling and response structure are consistent with JSON-RPC standards.


553-596: Review the implementation of eth_getTransactionByBlockNumberAndIndex.

The implementation for fetching a transaction by block number and index is robust, with appropriate checks and usage of utility functions. The response formatting and error handling are well-handled.

@roninjin10 roninjin10 merged commit 7ba5242 into main May 22, 2024
15 of 16 checks passed
@roninjin10 roninjin10 deleted the 05-21-_sparkles_feat_add_getblockby_support branch May 22, 2024 07:28
roninjin10 pushed a commit that referenced this pull request May 22, 2024
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.

⚠️⚠️⚠️⚠️⚠️⚠️

`main` is currently in **pre mode** so this branch has prereleases
rather than normal releases. If you want to exit prereleases, run
`changeset pre exit` on `main`.

⚠️⚠️⚠️⚠️⚠️⚠️

# Releases
## @tevm/[email protected]

### Minor Changes

- [#1114](#1114)
[`7ba5242`](7ba5242)
Thanks [@roninjin10](https://github.com/roninjin10)! - Added
customCrypto option

## @tevm/[email protected]

### Minor Changes

- [#1114](#1114)
[`7ba5242`](7ba5242)
Thanks [@roninjin10](https://github.com/roninjin10)! - Added new
JSON-RPC endpoints eth_getBlockByHash, eth_getBlockByNumber,
eth_getBlockTransactionCountByHash,
eth_getBlockTransactionCountByNumber, eth_getTransactionByHash,
eth_getTransactionByBlockHashAndIndex,
eth_getTransactionByBlockNumberAndIndex, and eth_blobBaseFee

### Patch Changes

- [#1114](#1114)
[`7ba5242`](7ba5242)
Thanks [@roninjin10](https://github.com/roninjin10)! - Added
verification tests to Viem PublicActions getEnsAvatar, getEnsName,
getEnsResolver, getEnsText, , getTransactions,
getTransactionConfirmations

- Updated dependencies
\[[`7ba5242`](7ba5242),
[`7ba5242`](7ba5242)]:
    -   @tevm/[email protected]
    -   @tevm/[email protected]
    -   @tevm/[email protected]

## @tevm/[email protected]

### Minor Changes

- [#1114](#1114)
[`7ba5242`](7ba5242)
Thanks [@roninjin10](https://github.com/roninjin10)! - Added new
JSON-RPC endpoints eth_getBlockByHash, eth_getBlockByNumber,
eth_getBlockTransactionCountByHash,
eth_getBlockTransactionCountByNumber, eth_getTransactionByHash,
eth_getTransactionByBlockHashAndIndex,
eth_getTransactionByBlockNumberAndIndex, and eth_blobBaseFee

### Patch Changes

-   Updated dependencies \[]:
    -   @tevm/[email protected]

## [email protected]

### Minor Changes

- [#1114](#1114)
[`7ba5242`](7ba5242)
Thanks [@roninjin10](https://github.com/roninjin10)! - Added new
JSON-RPC endpoints eth_getBlockByHash, eth_getBlockByNumber,
eth_getBlockTransactionCountByHash,
eth_getBlockTransactionCountByNumber, eth_getTransactionByHash,
eth_getTransactionByBlockHashAndIndex,
eth_getTransactionByBlockNumberAndIndex, and eth_blobBaseFee

### Patch Changes

- [#1114](#1114)
[`7ba5242`](7ba5242)
Thanks [@roninjin10](https://github.com/roninjin10)! - Added
verification tests to Viem PublicActions getEnsAvatar, getEnsName,
getEnsResolver, getEnsText, , getTransactions,
getTransactionConfirmations

- [#1114](#1114)
[`7ba5242`](7ba5242)
Thanks [@roninjin10](https://github.com/roninjin10)! - Fixed bug in
TransactionResult returning input rather than data

- [#1114](#1114)
[`7ba5242`](7ba5242)
Thanks [@roninjin10](https://github.com/roninjin10)! - Fixed BlockResult
type to be correct when `includeTransactions` is true

- Updated dependencies
\[[`7ba5242`](7ba5242),
[`7ba5242`](7ba5242),
[`7ba5242`](7ba5242),
[`7ba5242`](7ba5242),
[`7ba5242`](7ba5242),
[`7ba5242`](7ba5242)]:
    -   @tevm/[email protected]
    -   @tevm/[email protected]
    -   @tevm/[email protected]
    -   @tevm/[email protected]
    -   @tevm/[email protected]
    -   @tevm/[email protected]
    -   @tevm/[email protected]
    -   @tevm/[email protected]
    -   @tevm/[email protected]
    -   @tevm/[email protected]
    -   @tevm/[email protected]

## @tevm/[email protected]

### Patch Changes

-   Updated dependencies \[]:
    -   @tevm/[email protected]
    -   @tevm/[email protected]
    -   @tevm/[email protected]

## @tevm/[email protected]

### Patch Changes

- Updated dependencies
\[[`7ba5242`](7ba5242),
[`7ba5242`](7ba5242)]:
    -   @tevm/[email protected]

## @tevm/[email protected]

### Patch Changes

- [#1114](#1114)
[`7ba5242`](7ba5242)
Thanks [@roninjin10](https://github.com/roninjin10)! - Fixed bug in
TransactionResult returning input rather than data

- [#1114](#1114)
[`7ba5242`](7ba5242)
Thanks [@roninjin10](https://github.com/roninjin10)! - Fixed BlockResult
type to be correct when `includeTransactions` is true

## @tevm/[email protected]

### Patch Changes

- [#1114](#1114)
[`7ba5242`](7ba5242)
Thanks [@roninjin10](https://github.com/roninjin10)! - Fixed bug with
not passing in customCrypto correctly for non forked mode

- Updated dependencies
\[[`7ba5242`](7ba5242)]:
    -   @tevm/[email protected]

## @tevm/[email protected]

### Patch Changes

- Updated dependencies
\[[`7ba5242`](7ba5242),
[`7ba5242`](7ba5242),
[`7ba5242`](7ba5242)]:
    -   @tevm/[email protected]
    -   @tevm/[email protected]
    -   @tevm/[email protected]
    -   @tevm/[email protected]

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant