-
Notifications
You must be signed in to change notification settings - Fork 54
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
Introduce AccountIdBuilder
#1045
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Thank you! I left a couple of small comments inline.
objects/src/accounts/account_id.rs
Outdated
#[cfg(any(feature = "testing", test))] | ||
#[macro_export] | ||
macro_rules! account_id_dummy { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit (feel free to ignore): dummy_account_id
feels a bit more natural as the name here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels a bit strange that its a macro. We could implement rand
's Distribution but that wouldn't handle type and storage mode variations.
Alternatively we could also have a builder but that is significantly more implementation code. (just thinking out loud, not recommending this).
I think this would make sense for
Thanks for the suggestion. I considered that as well, but the builder seemed like too much boilerplate for just this functionality. Originally I also wanted to get rid of Maybe the builder would make more sense ultimately. If we introduce another I imagine something simple like: AccountIdBuilder::new(&mut rng).storage_mode(AccountStorageMode::Private).build();
AccountIdBuilder::new(&mut rng).build(); Seems short enough to easily read in tests. Alternatively we can also pass the rng to |
Passing it to .build_with_rng(&mut rng)
.build_with_seed(..)
.build_with_thread_rng(..) Though there are several APIs one could shuffle these into. Likely this isn't the only place we might want this style of thing 🤷 |
Went with the I did not add a |
account_id_dummy!
macroAccountIdBuilder
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Thank you!
Couple of small fixes following from the account ID refactor (#982).
The biggest addition is the
account_id_dummy!
macro, hence the PR title and changelog entry.The changes are:
AccountIdBuilder
to simplifyAccountId
generation to address ExtendAccountId
to twoFelt
s and refactor creation process #982 (comment) cc @Mirko-von-Leipzig.From
impls onAccountType
andAccountStorageMode
. This functionality is essentially covered by methods onAccountId
already.