-
Notifications
You must be signed in to change notification settings - Fork 272
Conversation
I removed node 6 from the travis config, as a test was failing because of that. I'm pretty sure we don't support node 6 anymore as its EOL has already happened. Let me know if i'm wrong and I'll revert that change. |
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.
Looks good thanks, just a few minor points
src/account.ts
Outdated
address = ethjsUtil.stripHexPrefix(address).toLowerCase() | ||
const hash = keccak(address).toString('hex') | ||
|
||
const prefix = chainId !== undefined ? chainId.toString() + '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.
The documentation makes it clear, but if someone seeing chainId
as the second parameter provides an Ethereum chainId (e.g. 1
) then the checksum will fail.
One alternative is to provide a second function toEIP1991ChecksumAddress
(maybe with a better name 😄).
I don't have a strong opinon however. @holgerd77 what do you think?
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.
That's a good point.
I made it this way to keep it similar to other implementations, like web3.js' one
Another alternative is to rename the second param to something like eip1191ChainId
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.
I would have a tendency to the renamed parameter. @alcuadrado can you also add "(prefixed with chainId)" and "(no prefix)" or some similar text after the respective EIP mentions in the JSDocs? Think this will also make things more clear, I often find these plain EIP mentions in our docs not very helpful if one is not totally in the EIP specs.
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.
One can also add some "Be are that checksums will be different" or so sentence.
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.
Are -> aware
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.
I changed the param name and updated the doc.
it("Should return false for invalid cases", function () { | ||
// If we set the chain id, an EIP55 encoded address should be invalid | ||
for (let i = 0; i < eip55ChecksumAddresses.length; i++) { | ||
assert.equal(ethUtils.isValidChecksumAddress(eip55ChecksumAddresses[i], 1), false) |
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.
Ah yeah this is the test case I was thinking about :)
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
Travis got stuck, so I pushed the same code again. Can you reapprove @s1na? Thanks! |
@holgerd77 @alcuadrado @s1na can we get a new version published? thanks/ |
@kumavis Yes - sorry, wasn't aware that actually didn't yet release all the latest changes for such a long time. Will prepare something within the next days, hopefully this, eventually next week. |
This PR implements EIP-1191 address checksum algorithm.
Fixes #201