-
Notifications
You must be signed in to change notification settings - Fork 59
feat: add ContractAddress type #159
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
base: main
Are you sure you want to change the base?
Conversation
c57d3e6
to
bea90b3
Compare
bea90b3
to
02d6946
Compare
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.
Some small comments
@gabrielbosio do you have an opinion about the points I highlighted in the issue description? |
It depends if we want to migrate the |
@dorimedini-starkware you are maintaining the sequencer repo? |
no reason I can think of, but this suggested implementation differs from ours in several ways, like:
|
|
all in all I have no issue with this addition; it may take time for us to migrate to this new type though |
@dorimedini-starkware so do you want this crate to also add a |
I guess it would make the transition less painful, so sure. |
@dorimedini-starkware going back to point using derive_more::Display, or manual impl end up being the same. So no worries here Now regarding |
feature = "parity-scale-codec", | ||
derive(parity_scale_codec::Encode, parity_scale_codec::Decode) | ||
)] | ||
pub struct RegularContractAddress(ContractAddress); |
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.
what is this ?
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.
Addresses that are not 0x0 and 0x1. Most users facing application code should never interact with the protocol special addresses. If they do, it is because of a bug.
It can be enforced at the type level this way.
Add a
ContractAddress
wrapper type that guarantee the felt it contains is a valid starknet contract address.Contain some quality of like function for string conversion
Not a breaking change
Discussion:
@xJonathanLEI suggested we add ClassHash too
I chose to exclude addresses 0x0 and 0x1 from the normal ContractAddress flow. You can still build them with the unchecked one. Should we add constant ContractAddress::ZERO and ContractAddress::ONE to make those special case more explicit?
Do we want to allow them at all? Is there a risk to make some API unusable downstream if those value are entierly excluded?