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

Added support for eip-1191 #339

Merged
merged 1 commit into from
Apr 21, 2020
Merged

Conversation

jonathansmirnoff
Copy link
Contributor

@jonathansmirnoff jonathansmirnoff commented Apr 16, 2020

It was implemented EIP-1191. By default for every network it will be used EIP-55.
It was necessary to update the version of Kethereum to support this PR. Also it was fixed chainId of RSK Network.

This PR is related to #305.

Please @ligi let me know what you think about these changes.

@jonathansmirnoff jonathansmirnoff marked this pull request as draft April 16, 2020 15:20
Copy link
Member

@ligi ligi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It needs to be a different address field as mentioned here: #305 (comment)
otherwise this can break upstream projects.

@jonathansmirnoff
Copy link
Contributor Author

@ligi thanks for your answer, I thought that you asked me to not modified the token json file. So I need more clarification about the solution that you prefer:

  • Add a new field to the json token file: address_eip1191, then I will need to change Token.kt. This field will be optional.
  • TokenChecker.kt will recibe always the chainId. If the token to be checked has the address_eip1191 it will validated it throw the eip1191.

Are you agreed with this?

@ligi
Copy link
Member

ligi commented Apr 16, 2020

  • Add a new field to the json token file: address_eip1191, then I will need to change Token.kt. This field will be optional.

yes

TokenChecker.kt will recibe always the chainId. If the token to be checked has the address_eip1191 it will validated it throw the eip1191.

yes

Are you agreed with this?

yes

@jonathansmirnoff
Copy link
Contributor Author

@ligi I did the changes that we have talked about. Please check them. Thanks!

!address.hasValidERC55Checksum()
address_eip1191 != null && !(address_eip1191.isValid()) -> throw InvalidAddress(address)

(!address.hasValidERC55Checksum() && address_eip1191 == null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also throw an error when the address_eip1191 is non null. We need to make sure that the address field is always valid

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did because we need the name of the file has the checksum following the eip1191 when it is appropriate. This allow us to have a better integration with Ledger and Trezor wallets for the different tokens that are in RSK.

Maybe something that we can do is this:

  • if address_eip1191 is empty or null, it will be validated using erc55 rules the address field. (as it is working today)
  • if address_eip1191 has a value, it will be validate with erc1191 rules and also the address field. So basically the two fields has to be the same.

Another option is to modify the file name validation and allow to check the file name by address_eip1191 if it is appropriate.

Let me know what are your thought about this. Thanks!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unfortunately this will not work - we cannot break the guarantees that the address field brings.
To have better TREZOR integration you need to change it on the TREZOR side - meaning there the check if the address_eip1191 field is there and if it is use it instead of the address field.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, let's do what you have suggested. I will do the modifications and update the PR.

@ligi
Copy link
Member

ligi commented Apr 16, 2020

Just this one point - otherwise the PR looks good to me

@ligi
Copy link
Member

ligi commented Apr 17, 2020

there are currently failing tests after this change - can you have a look? All tests need to pass before I can merge

@jonathansmirnoff
Copy link
Contributor Author

jonathansmirnoff commented Apr 17, 2020

there are currently failing tests after this change - can you have a look? All tests need to pass before I can merge

Yes, sure I will review.

Copy link
Member

@ligi ligi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for me the tests still fail - even with a clean:

✗ ~/g/e/tokens (pr/339 *$) ./gradlew clean test                                                                                                                       23:25:01

> Task :test FAILED

TheTokenChecker > shouldPassForValidTokenEip1191 FAILED
    java.lang.IllegalStateException at TheTokenChecker.kt:117

TheTokenChecker > shouldFailForInvalidChecksumEip1191 FAILED
    java.lang.Exception at ExpectException.java:28
        Caused by: java.lang.IllegalStateException at TheTokenChecker.kt:117

15 tests completed, 2 failed

@jonathansmirnoff
Copy link
Contributor Author

for me the tests still fail - even with a clean:

✗ ~/g/e/tokens (pr/339 *$) ./gradlew clean test                                                                                                                       23:25:01

> Task :test FAILED

TheTokenChecker > shouldPassForValidTokenEip1191 FAILED
    java.lang.IllegalStateException at TheTokenChecker.kt:117

TheTokenChecker > shouldFailForInvalidChecksumEip1191 FAILED
    java.lang.Exception at ExpectException.java:28
        Caused by: java.lang.IllegalStateException at TheTokenChecker.kt:117

15 tests completed, 2 failed

I remember that I had the same issue. I fixed it removing the build and .gradle folder. I think this because kethereum version was updated and now it is used new functions.
I will try to do a rebase to get the last changes of the repo.

@jonathansmirnoff jonathansmirnoff marked this pull request as draft April 20, 2020 12:59
@jonathansmirnoff jonathansmirnoff marked this pull request as ready for review April 20, 2020 13:06
@jonathansmirnoff jonathansmirnoff marked this pull request as draft April 20, 2020 13:42
@jonathansmirnoff jonathansmirnoff marked this pull request as ready for review April 20, 2020 15:54
@jonathansmirnoff
Copy link
Contributor Author

I cloned again my repo and did ./gradlew clean test it worked fine:

./gradlew clean test 
Starting a Gradle Daemon (subsequent builds will be faster)

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.3/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 25s
5 actionable tasks: 4 executed, 1 up-to-date

@ligi
Copy link
Member

ligi commented Apr 20, 2020

I guess you ran these tests on a non case sensitive OS ..-)

@jonathansmirnoff
Copy link
Contributor Author

@ligi I could fix the issue :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants