Skip to content

feat: add vm.getChain(chainAlias) #10226

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

redtrama
Copy link

@redtrama redtrama commented Apr 1, 2025

Early pr to get feedback.
Closes #10198

Solution

I've tried to implement the same way StdCheats handles getChain by alias by:

  • Consulting chainId by their alias(string)
  • if it's not defined on our foundry.toml should return a default rpc
  • Default rpcs are defined into a hashMap

Once the approach is confirmed i can add getChain(chainId)

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

Copy link
Collaborator

@grandizzy grandizzy left a comment

Choose a reason for hiding this comment

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

thank you. please make use of alloy-chains https://github.com/alloy-rs/chains instead declaring chains again

Copy link
Member

Choose a reason for hiding this comment

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

I think we can do without these changes, because maybe this is just alloy_chains::Chain::from_str

Copy link
Author

Choose a reason for hiding this comment

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

When returning rpcUrl in Chain struct, as StdChain does we want to:

  1. return configured rpcUrl in foundry.toml
  2. if it's not existent on foundry.toml return a default rpcUrl

I couldn't find a feature like this in alloy-rs/chains. should i find another way or just skip this feature and just return configured rpc in env?

sorry for the delay

Copy link
Collaborator

Choose a reason for hiding this comment

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

hey @redtrama returning configured rpc sounds good, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

feat: add vm.getChain cheatcodes to get chain info
3 participants