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(anvil): add anvil examples from ethers-rs #2

Merged
merged 22 commits into from
Mar 21, 2024
Merged

Conversation

zerosnacks
Copy link
Member

Previous PR: alloy-rs/alloy#301

Motivation

To add examples from ethers-rs: anvil

Solution

Includes a new Anvil test (deploy_contract) that was planned in ethers-rs but not added originally. Adds two other very basic tests for forking and local.

I'm currently managing the nonces, gas and gas_price manually which is not ideal. Preferably gas and gas_price are derived automatically. I think it is preferable to add support for nonce management to the examples at a later point.

@zerosnacks zerosnacks marked this pull request as ready for review March 15, 2024 08:40
@zerosnacks zerosnacks changed the title feat(examples): add anvil examples from ethers-rs feat(anvil): add anvil examples from ethers-rs Mar 15, 2024
examples/anvil/examples/local_anvil.rs Outdated Show resolved Hide resolved
examples/anvil/examples/deploy_contract_anvil.rs Outdated Show resolved Hide resolved
Comment on lines +49 to +53
let base_fee = provider.get_gas_price().await?;

// Deploy the contract.
let contract_builder = Counter::deploy_builder(&provider);
let estimate = contract_builder.estimate_gas().await?;
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 want to change the return value from U64 to u64 for all of these to make it easier to use, usually u64 is beneficial

Copy link
Member Author

Choose a reason for hiding this comment

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

Will implement once alloy-rs/alloy#338 is merged

@zerosnacks zerosnacks self-assigned this Mar 18, 2024
examples/anvil/examples/deploy_contract_anvil.rs Outdated Show resolved Hide resolved
examples/anvil/examples/deploy_contract_anvil.rs Outdated Show resolved Hide resolved
Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

lgtm

@zerosnacks zerosnacks merged commit 8999e84 into main Mar 21, 2024
2 checks passed
@zerosnacks zerosnacks deleted the zerosnacks/anvil branch March 21, 2024 16:06
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.

2 participants