refactor(polyibc): automate message encode object types#309
refactor(polyibc): automate message encode object types#309VolodymyrBg wants to merge 1 commit intopolymerdao:mainfrom
Conversation
Introduced a CreateMsgEncodeObject type utility to reduce code duplication and improve maintainability of IBC message type definitions. This addresses the TODO comment by providing a more automated way to define message encode objects. Changes made: - Added CreateMsgEncodeObject type utility - Converted interface declarations to type aliases - Simplified message type definitions
WalkthroughThe pull request introduces a refactoring of message encoding object types in the Changes
Poem
Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
app/api/utils/cosmos/polyibc.ts (2)
48-49: Enhance type safety and documentation of the helper type.Consider improving the type definition by:
- Constraining the generic parameter to only allow valid message types from the registry
- Adding more detailed JSDoc documentation explaining the purpose and usage
- // Helper type for creating message encode objects + /** + * Helper type for creating message encode objects with type-safe URLs. + * @template T - The message type URL, must be a key in txMsgTypesRegistry + */ - type CreateMsgEncodeObject<T extends string> = txMsgEncodeObject<T> + type CreateMsgEncodeObject<T extends keyof typeof txMsgTypesRegistry & string> = txMsgEncodeObject<T>
66-66: Remove the outdated TODO comment.This TODO comment has been addressed by the current PR through the introduction of the
CreateMsgEncodeObjecthelper type, which automates the creation of message encode object types.- // TODO: is there a way to automate these?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
app/api/utils/cosmos/polyibc.ts(1 hunks)
🔇 Additional comments (1)
app/api/utils/cosmos/polyibc.ts (1)
51-64: LGTM! Clean and consistent type definitions.The type definitions are well-organized, type-safe, and consistently use the new helper type. The grouping of related message types improves readability.
Introduced a CreateMsgEncodeObject type utility to reduce code duplication and improve maintainability of IBC message type definitions. This addresses the TODO comment by providing a more automated way to define message encode objects.
Changes made:
Summary by CodeRabbit
CreateMsgEncodeObjectto streamline message type creation