-
Notifications
You must be signed in to change notification settings - Fork 71
refactor: split Token into BaseToken & Token #725
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
Open
mkflow27
wants to merge
17
commits into
main
Choose a base branch
from
split-token
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
8ba9808
refactor: split Token into BaseToken & Token
mkflow27 bce6a97
chore: lint
mkflow27 6636292
refactor: more Token -> BaseToken changes
mkflow27 0cd88f7
refactor: more type refactors Token -> BaseToken
mkflow27 655b6b1
refactor: more Token -> BaseToken refactors
mkflow27 5a1bd5c
chore: lint
mkflow27 e9bae09
refactor: more Token -> BaseToken
mkflow27 fba4dd1
refactor: add NativeToken
mkflow27 e92471e
refactor: complete Token removal
mkflow27 5269593
refactor: use Token & NativeToken (rename BaseToken back to Token)
mkflow27 466a34a
refactor: Token imports
mkflow27 cbdc4fa
refactor: undo more changes
mkflow27 f51af5f
chore: add changeset
mkflow27 202693b
refactor: import from src
mkflow27 4e9a781
refactor: rename function
mkflow27 3a7a569
refactor: use isWrapped helper
mkflow27 8082f25
refactor: use isWrapped helper
mkflow27 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| import { Address } from 'viem'; | ||
| import { InputToken } from '../types'; | ||
|
|
||
| /** | ||
| * BaseToken contains the core functionality for all tokens | ||
| * This class handles the essential token properties and methods | ||
| * without any wrapped token logic | ||
| */ | ||
| export class BaseToken { | ||
| public readonly chainId: number; | ||
| public readonly address: Address; | ||
| public readonly decimals: number; | ||
| public readonly symbol?: string; | ||
| public readonly name?: string; | ||
|
|
||
| public constructor( | ||
| chainId: number, | ||
| address: Address, | ||
| decimals: number, | ||
| symbol?: string, | ||
| name?: string, | ||
| ) { | ||
| this.chainId = chainId; | ||
| // Addresses are always lowercased for speed | ||
| this.address = address.toLowerCase() as Address; | ||
| this.decimals = decimals; | ||
| this.symbol = symbol; | ||
| this.name = name; | ||
| } | ||
|
|
||
| public isEqual(token: BaseToken) { | ||
| return this.chainId === token.chainId && this.address === token.address; | ||
| } | ||
|
|
||
| public isSameAddress(address: Address) { | ||
| return this.address === address.toLowerCase(); | ||
| } | ||
|
|
||
| public toInputToken(): InputToken { | ||
| return { | ||
| address: this.address, | ||
| decimals: this.decimals, | ||
| }; | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can use the new
isWrappedhere?