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

[Feature] Add FixedBytes and aliases macros #109

Closed
DaniPopes opened this issue Jun 12, 2023 · 4 comments · Fixed by #156
Closed

[Feature] Add FixedBytes and aliases macros #109

DaniPopes opened this issue Jun 12, 2023 · 4 comments · Fixed by #156
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@DaniPopes
Copy link
Member

DaniPopes commented Jun 12, 2023

Component

No response

Describe the feature you would like

Exported macro_rules! that wrap hex_literal::hex! with $crate::<type> constructors. Also re-export hex! itself

Additional context

No response

@DaniPopes DaniPopes added enhancement New feature or request good first issue Good for newcomers labels Jun 12, 2023
@startup-dreamer
Copy link

I would like to work on this @DaniPopes could you please provide additional direction on this.

@prestwich
Copy link
Member

prestwich commented Jun 26, 2023

we'd like a wrapper around hex! that also instantiates a alloy_primitives::FixedBytes so that users can declare a fixed bytes inline easily

  • the macro should live in alloy_primitives and be exported
  • the macro should have thorough documentation
  • the internals of the macro are something like $crate::FixedBytes( hex! { ... } )
  • there should be a similar macro for address! that uses $crate::Address and for any other newtype in the primitives crate

sample code:

let my_bytes: FixedBytes<4> = bytes! { "1234 abcd" };
let output = bytes!{ "12 34" } & bytes!{ "ab cd" };

const DOMAIN_HASH: FixedBytes<32> = bytes! { 
    "a191312024065f51f1eb9e5ffc5795890db9e0a5bc0eacb250d5034d1e990302" 
};

@DaniPopes
Copy link
Member Author

Sorry @startup-dreamer I already had an implementation this morning, you can check out other issues tagged with good first issue if you want to take on another issue.

@startup-dreamer
Copy link

No worries, I will work on some other issue.

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

Successfully merging a pull request may close this issue.

3 participants