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(rpc-types): accept Address in to builder method for TxReq #505

Merged
merged 1 commit into from
Apr 16, 2024

Conversation

yash-atreya
Copy link
Member

@yash-atreya yash-atreya commented Apr 10, 2024

Motivation

The to builder method for TransactionRequest takes Option<Address> as arg. This is inconsistent with other builder methods.

Solution

Use Address type for arg and wrap it in Some inside the method

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

@DaniPopes
Copy link
Member

to is different because an empty to address is a contract creation no?

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.

this makes it consistent with the other setters

@mattsse
Copy link
Member

mattsse commented Apr 10, 2024

to is different because an empty to address is a contract creation no?

yeah but the builder starts out with None, imo this is the right choice because this is also how the other setters work

@prestwich
Copy link
Member

prestwich commented Apr 11, 2024

not convinced we should default to create instead of erroring if not specifically set to create, as creating with value and empty data is a valid tx that burns user funds. We should probably error on building if to is unset, and provide a shortcut for .create()

@prestwich
Copy link
Member

prestwich commented Apr 11, 2024

i.e. this behavior would burn funds

let mut builder = Default::default().with_value(1 ether);
provider.send_transaction(
   builder
).await;

@prestwich prestwich merged commit 9485213 into alloy-rs:main Apr 16, 2024
18 checks passed
ben186 pushed a commit to ben186/alloy that referenced this pull request Jul 27, 2024
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.

4 participants