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(network): Add input method to TransactionResponse #959

Merged
merged 3 commits into from
Jun 25, 2024

Conversation

moricho
Copy link
Contributor

@moricho moricho commented Jun 23, 2024

Motivation

It would be nice to have a method to get input data from TransactionResponse.
During my development, there was a situation in which I wanted to know what method was being called and with what arguments from TransactionResponse.

Solution

Adds input method to TransactionResponse and implements it to TransactionResponse type for each Network

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

@moricho moricho changed the title feat(network): Implement input method to TransactionResponse feat(network): Add input method to TransactionResponse Jun 23, 2024
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.

thanks, this is indeed useful

crates/network/src/lib.rs Outdated Show resolved Hide resolved
crates/network/src/lib.rs Outdated Show resolved Hide resolved
@@ -62,4 +63,8 @@ impl TransactionResponse for alloy_rpc_types_eth::Transaction {
fn gas(&self) -> u128 {
self.gas
}

fn input(&self) -> Bytes {
Copy link
Member

Choose a reason for hiding this comment

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

wdyt @DaniPopes Bytes or &[u8] ?

Copy link
Member

Choose a reason for hiding this comment

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

&Bytes would be the best choice here

Copy link
Member

Choose a reason for hiding this comment

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

I guess we can reasonably assume that every tx always has an input, so that makes sense

@mattsse mattsse merged commit 6ac2635 into alloy-rs:main Jun 25, 2024
22 checks passed
ben186 pushed a commit to ben186/alloy that referenced this pull request Jul 27, 2024
)

* feat(network): Implement `input` method to `TransactionResponse`

* add a doc alias to the `input` method

* chore: use &Bytes

---------

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
@moricho moricho deleted the input-method branch November 4, 2024 07:04
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.

3 participants