Skip to content
This repository has been archived by the owner on Apr 25, 2024. It is now read-only.

feat: lowercase address checking when doing token comparisons #47

Merged
merged 3 commits into from
Mar 6, 2023

Conversation

tinaszheng
Copy link
Contributor

Because Tokens can now have non-checksummed addresses, we need to lowercase addresses before doing comparison checking because we could be comparing one with checksummed addresses to one without. Theoretically they're the same token, so its OK to not do case-sensitive comparisons here

Copy link
Member

@ianlapham ianlapham left a comment

Choose a reason for hiding this comment

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

looks good

Comment on lines 57 to 61
public sortsBefore(other: Token): boolean {
invariant(this.chainId === other.chainId, 'CHAIN_IDS')
invariant(this.address !== other.address, 'ADDRESSES')
invariant(this.address.toLowerCase() !== other.address.toLowerCase(), 'ADDRESSES')
return this.address.toLowerCase() < other.address.toLowerCase()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

might be worth adding a test case for this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so true bestie

@tinaszheng tinaszheng merged commit 6db62cd into main Mar 6, 2023
@tinaszheng tinaszheng deleted the tina/currency-id branch March 6, 2023 21:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants