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

[Suggestion] Change nonce field to be u64 compatible #335

Closed
zerosnacks opened this issue Mar 18, 2024 · 2 comments · Fixed by #341
Closed

[Suggestion] Change nonce field to be u64 compatible #335

zerosnacks opened this issue Mar 18, 2024 · 2 comments · Fixed by #341
Assignees
Labels
enhancement New feature or request

Comments

@zerosnacks
Copy link
Member

zerosnacks commented Mar 18, 2024

Component

provider, pubsub

Describe the feature you would like

Instead of .nonce(U64::from(1)) we would want to be able to do just .nonce(1).

See: alloy-rs/examples#2 (comment)
See: alloy-rs/examples#2 (comment)
See: alloy-rs/examples#8 (comment)

There are likely also other places where similar user facing values are desired to be native types:

  • chain_id
  • transaction_type
  • etc..

See: alloy-rs/examples#2 (comment)

Additional context

Once implemented make sure to fix in examples: alloy-rs/examples#2

There is some complexity around this, FWD from @prestwich in alloy-rs/examples#8 (comment):

rpc types must store nonce as U64 (or use a serde(with = ...)) to be on-spec so this probably propagates outward from there 😮‍💨 we should settle on a specific type for these and audit codeplace for compliance. prefer u64 in all non-rpc structs

@mattsse
Copy link
Member

mattsse commented Mar 19, 2024

yeah, we def want this, because usually the input is primitive u64, and it's easier to go form U64 to u64

@zerosnacks
Copy link
Member Author

zerosnacks commented Mar 19, 2024

yeah, we def want this, because usually the input is primitive u64, and it's easier to go form U64 to u64

Added an initial implementation here: #341, uses the u64_hex_or_decimal / u64_hex_or_decimal_opt functions to handle the RPC structs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants