-
Notifications
You must be signed in to change notification settings - Fork 13
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
eth: add signing function parameter to specify receive address case #90
Conversation
/// Identifies the case of the recipient address given as hexadecimal string. | ||
/// This function exists as a convenience to potentially help clients to determine the case of the | ||
/// recipient address. | ||
pub fn eth_identify_case(recipient_address: &str) -> pb::EthAddressCase { |
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.
ChatGPT suggests this improvement to not allocate a String:
pub fn eth_identify_case(recipient_address: &str) -> pb::EthAddressCase {
if recipient_address.chars().all(|c| c.is_ascii_uppercase()) {
pb::EthAddressCase::Upper
} else if recipient_address.chars().all(|c| c.is_ascii_lowercase()) {
pb::EthAddressCase::Lower
} else {
pb::EthAddressCase::Mixed
}
}
Please also add a test_eth_identify_case()
unit test in the mod tests {
block at the bottom of the file. ChatGPT can probably make this quickly too 😄
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.
fixed, but had to add !c.is_ascii_alphabetic()
since the original one doesn't work with numbers
if recipient_address
.chars()
.all(|c| !c.is_ascii_alphabetic() || c.is_ascii_uppercase())
{
pb::EthAddressCase::Upper
} else if recipient_address
.chars()
.all(|c| !c.is_ascii_alphabetic() || c.is_ascii_lowercase())
{
pb::EthAddressCase::Lower
} else {
pb::EthAddressCase::Mixed
}
Please also add a CHANGELOG in CHANGELOG-npm.md under 0.7.0 and in CHANGELOG-rust.md under 0.6.0 And also please configure your editor to run |
33e2cc5
to
607aeb2
Compare
squash and merge when ready edit: strange, looks like CI fails because of the missing optional argument in the examples/eth.rs want me to add it there? Any idea though why it fails when it's supposed to be optional? |
@Tomasvrba there are no optional args. |
09ad8ba
to
86eaa00
Compare
I may be a rust noob, but this is bad naming and I will die on this hill, Option should be optional :P |
CHANGELOG-npm.md
Outdated
@@ -6,6 +6,7 @@ | |||
- btc: handle error when an input's previous transaction is required but missing | |||
- btc: add support for regtest | |||
- btc: add support for Taproot wallet policies | |||
- eth: add method to help clients identify address case (upper/lower/mixed) |
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.
it's not just that, it also allows clients to specify the address case in the first place when signing a tx.
86eaa00
to
98da3c9
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.
Thanks! Please squash, then I'll merge.
98da3c9
to
5061668
Compare
No description provided.