Skip to content
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

Implement the formatting method to return a mixed-case EIP 55 string #43

Merged
merged 5 commits into from Jan 22, 2019

Conversation

@earlbread
Copy link
Member

earlbread commented Jan 19, 2019

This Implements the formatting method to return a mixed-case EIP 55 string(#33).

Copy link
Member

longfin left a comment

Thank you for patch! I've made some comments.

[Pure]
public string ToChecksumAddress()
{
var hex = ToHex();

This comment has been minimized.

Copy link
@longfin

longfin Jan 21, 2019

Member

it is more readable to write the type explicitly If the type of the variable isn't obvious with new.

This comment has been minimized.

Copy link
@earlbread

earlbread Jan 21, 2019

Author Member

Thank you, I'll fix it.

public string ToChecksumAddress()
{
var hex = ToHex();
var bytes = Encoding.ASCII.GetBytes(hex);

This comment has been minimized.

Copy link
@longfin

longfin Jan 21, 2019

Member

Instead of re-parsing, we can call ToByteArray() here.

This comment has been minimized.

Copy link
@earlbread

earlbread Jan 21, 2019

Author Member

I think the results are different. the bytes in the code is 40 bytes and the result of ToByteArray() is 20 bytes.

This comment has been minimized.

Copy link
@longfin

longfin Jan 21, 2019

Member

My bad, I've mistaken.

@dahlia dahlia added this to the 0.1.0 milestone Jan 21, 2019
Copy link
Member

dahlia left a comment

Thanks for your first contribution! I left a comment.

/// <returns>A <c>0x</c>-prefixed Mixed-case checksum address of 42
/// letters that represent this <see cref="Address"/>.</returns>
[Pure]
public string ToChecksumAddress()

This comment has been minimized.

Copy link
@dahlia

dahlia Jan 21, 2019

Member

I believe mixed-case hexadecimals should be encouraged and the default. In other words, ToHex() method should return a mixed-case hexadecimals unless it's explicitly off, e.g., ToHex(checksum: false). (Or such option maybe unnecessary from the outset, because calling .ToLower() is trivial.) The same goes for ToString().

@longfin @kijun Opinions?

This comment has been minimized.

Copy link
@longfin

longfin Jan 21, 2019

Member

Good point, I agree.

This comment has been minimized.

Copy link
@earlbread

earlbread Jan 21, 2019

Author Member

I agree. I'll fix ToHex() method instead of creating ToChecksumAddress()

@earlbread earlbread force-pushed the earlbread:eip55 branch from 0d065fb to ccd20ab Jan 22, 2019
@earlbread

This comment has been minimized.

Copy link
Member Author

earlbread commented Jan 22, 2019

I applied code reviews and rebased the branch.

Copy link
Member

dahlia left a comment

I left only few trivial comments. Thanks!

string hashHex = ByteUtil.Hex(hash);
string address = string.Empty;

for (var i = 0; i < hex.Length; i++)

This comment has been minimized.

Copy link
@dahlia

dahlia Jan 22, 2019

Member

As string implements IEnumerable<char>, this can be adjusted to use foreach instead.

This comment has been minimized.

Copy link
@longfin

longfin Jan 22, 2019

Member

It seems to use i as the index of hexHash.

This comment has been minimized.

Copy link
@dahlia

dahlia Jan 22, 2019

Member

@longfin Fair enough. This should be as is. @earlbread Nevermind!

/// Gets a hexadecimal string of 40 letters that represent this
/// <see cref="Address"/>.
/// Gets a mixed-case hexadecimal string of 40 letters that represent
/// this <see cref="Address"/>.
/// </summary>

This comment has been minimized.

Copy link
@dahlia

dahlia Jan 22, 2019

Member

Could you append a mention that a returned hexadecimal string follows EIP 55?

This comment has been minimized.

Copy link
@earlbread

earlbread Jan 22, 2019

Author Member

I rebased on master and added a mention about EIP 55!

@dahlia

This comment has been minimized.

Copy link
Member

dahlia commented Jan 22, 2019

Note that a build error during pushing docs was fixed by PR #45. You should rebase this PR on the current master again (20386c5 at least).

@earlbread earlbread force-pushed the earlbread:eip55 branch from ccd20ab to 0e04450 Jan 22, 2019
@dahlia
dahlia approved these changes Jan 22, 2019
@dahlia dahlia merged commit b18c0ca into planetarium:master Jan 22, 2019
1 check passed
1 check passed
planetarium.libplanet.net Build #20190122.14 succeeded
Details
@dahlia

This comment has been minimized.

Copy link
Member

dahlia commented Jan 22, 2019

Thanks for your contribution!

@earlbread earlbread deleted the earlbread:eip55 branch Jan 22, 2019
@dahlia dahlia referenced this pull request Jan 23, 2019
2 of 2 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.