-
Notifications
You must be signed in to change notification settings - Fork 195
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
refactor: token-metadata #458
Conversation
WalkthroughThe recent updates introduce a new class, Changes
TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Actionable comments posted: 1
Review Status
Configuration used: CodeRabbit UI
Files selected for processing (3)
- packages/token-metadata/src/TokenFactoryStatic.ts (1 hunks)
- packages/token-metadata/src/index.ts (1 hunks)
- packages/token-metadata/src/types.ts (2 hunks)
Additional comments not posted (5)
packages/token-metadata/src/index.ts (2)
3-3
: The import ofTokenFactoryStatic
is correctly added to facilitate its export. Good job ensuring that new functionalities are accessible.
13-18
: The updated export structure, including the addition ofTokenFactoryStatic
, enhances the package's usability. The reordering of exports also improves clarity.packages/token-metadata/src/TokenFactoryStatic.ts (1)
31-48
: The metadata retrieval methods are well-implemented. Consider adding documentation to clarify the fallback behavior ingetMetaBySymbol
for better maintainability.packages/token-metadata/src/types.ts (2)
8-8
: The addition of theSymbol
enum value toTokenType
is a good enhancement, broadening the scope of token types that can be represented.
221-238
: The introduction of theTokenStatic
interface significantly enriches the token metadata model, accommodating a wide range of token characteristics. Well done on this comprehensive addition.
constructor(registry: TokenStatic[]) { | ||
this.registry = registry | ||
this.tokensByDenom = registry.reduce((list, token) => { | ||
const denom = token.denom.toLowerCase() | ||
|
||
if (list[denom]) { | ||
return list | ||
} | ||
|
||
return { ...list, [denom]: token } | ||
}, {} as Record<string, TokenStatic>) | ||
|
||
this.tokensBySymbol = registry.reduce((list, token) => { | ||
const symbol = token.symbol.toLowerCase() | ||
|
||
return { ...list, [symbol]: [...(list[symbol] || []), token] } | ||
}, {} as Record<string, TokenStatic[]>) |
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.
Consider refining the population logic for tokensByDenom
to accommodate multiple tokens with the same denomination but different attributes. This ensures a more comprehensive registry.
Summary by CodeRabbit