-
Notifications
You must be signed in to change notification settings - Fork 119
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
Refactor out transcode as a separate library #597
Conversation
User @fbielejec, please sign the CLA 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.
LGTM!
/// Decode hex string with or without 0x prefix | ||
pub fn decode_hex(input: &str) -> Result<Vec<u8>, hex::FromHexError> { | ||
if input.starts_with("0x") { | ||
hex::decode(input.trim_start_matches("0x")) |
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.
You don't need the if here. You can call this function regardless of if the string is prefixed with an 0x or not.
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.
Happy to approve a small PR which refactors this
This PR refactors the bits responsible for encoding contract creator and message calls into a separate library.
It's intention is to facilitate building various tools for interacting with contracts.
One possible use case is creating automated end-to-end tests written in Rust, declarative DSL based tools for describing pipelines for deploying / updating non-trivial smart contract suites (think Truffle / Hardhat) etc.
For that reason the Licence is Apache (although I have cargo-culted the contract-metadata library in that respect, GPL with ClasspathException would likely also be permissive enough - Although I'm Not A Lawyer).