Introduce ContractAddress newtype instead of scheme enum#200
Conversation
Not all variants of scheme used all the parameters of the previous `contract_address` function, yet they still needed to be passed.
|
It looks like @thomaseizinger hasn't signed our Contributor License Agreement, yet.
You can read and sign our full Contributor License Agreement at the following URL: https://cla.parity.io Once you've signed, please reply to this thread with Many thanks, Parity Technologies CLA Bot |
|
[clabot:check] |
|
It looks like @thomaseizinger signed our Contributor License Agreement. 👍 Many thanks, Parity Technologies CLA Bot |
Yes, the code hash is used, although it looks weird.
Thanks, the usage is indeed seems more convenient now. But we have code that passes the enum around, so we need to keep it. |
The Would that change work for you?
What are your thoughts on this PR then? Should I add the scheme back and provide a 4th method? In the spirit of providing a useful, general-purpose crate for computing contract addresses for Ethereum, I feel like the need to pass around a creation-scheme is fairly application specific and does not really need to be in this crate? 😬 |
Yes, sounds reasonable.
I agree :) Let's remove the enum. |
This allows us to not return a tuple but just the address.
|
@ordian As discussed, I removed the hashing and the tuple return value :) Let me know, if this PR needs anything else from my side! |
ordian
left a comment
There was a problem hiding this comment.
Could you update the readme (the doc tests unfortunately don't run on CI) and bump version to 0.2 as well?
|
ascjones
left a comment
There was a problem hiding this comment.
A good improvement to the API 👍
|
Published 0.2.0 |
* master: [plain_hasher] Migrate to 2018 edition (#213) [ethbloom] Improve ethbloom (#215) [rlp] fix nested unbounded lists (#203) stabilize parity-bytes in no_std environment (#212) Speed up hex serialization, support Serde `with`, and fix warnings (#208) [ethbloom, ethereum-types,kvdb] migrate to 2018 edition (#205) Introduce `ContractAddress` newtype instead of scheme enum (#200)
Not all variants of scheme used all the parameters of the previous
contract_addressfunction, yet they still needed to be passed.I took a shot at redesigning the interface of this crate to allow for the most convenient usage.
Let me know what you think!
The two methods
from_sender_salt_and_codeandfrom_sender_and_codeboth return a tuple with the computed hash. I don't know how these methods are actually being used, so I don't know if we actually need that return value. It seems a bit odd to me because it looks like the hash is an implementation detail of how to compute the address and should be hidden inside the function.