-
Notifications
You must be signed in to change notification settings - Fork 10
feat(sdk): add simplified token transfer API #96
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
aelmanaa
wants to merge
2
commits into
main
Choose a base branch
from
feat/token-transfer-api
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.
Conversation
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
Add tokenTransfer() factory function for single-token transfers without manual extraArgs/data configuration. Chain-specific defaults are applied automatically based on destination chain family. - Add tokenTransfer() and message() factory functions - Add type guards isTokenTransfer() and isFullMessage() - Extend getFee and sendMessage to accept MessageInput union - Add comprehensive tests for message types, defaults, and normalizer
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
👋 aelmanaa, thanks for creating this pull request! To help reviewers, please consider creating future PRs as drafts first. This allows you to self-review and make any final changes before notifying the team. Once you're ready, you can mark it as "Ready for review" to request feedback. Thanks! |
Coverage Report |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This pull request introduces a major simplification and standardization to the SDK's token transfer API, making it easier to use and less error-prone. The core improvement is the introduction of a
tokenTransfer()factory for single-token transfers, which allows users to create transfer messages without manually specifyingextraArgsordata. The changes also include robust normalization logic to ensure all message types are handled consistently across supported chains, and comprehensive tests for these new utilities. Additionally, the SDK's public API is expanded to expose these new types and helper functions.SDK API Simplification and Normalization:
tokenTransfer()andmessage()factory functions, along with new types (MessageInput,TokenTransferMessage, etc.), to simplify and standardize message creation for token transfers and full messages. These are now exported from the SDK's entry point (ccip-sdk/src/index.ts).normalizeMessageutility, which converts bothtokenTransfer()andmessage()inputs into a normalized internal format, automatically applying sensible defaults forextraArgsdepending on the destination chain. This is now used throughout the chain implementations (EVM, Aptos) to ensure consistent behavior. [1] [2] [3] [4] [5] [6]getDefaultExtraArgsutility to centralize and document the defaultextraArgsfor each supported chain family, ensuring correct and maintainable defaults for token-only transfers.Type and Documentation Improvements:
SendMessageOptsinchain.tsto accept bothtokenTransfer()and fullmessage()formats, improving type safety and developer experience. Added detailed usage examples and documentation.Testing and Validation:
getDefaultExtraArgsandnormalizeMessageutilities, covering all supported chain families and edge cases (immutability, field population, etc.). [1] [2]Changelog and Versioning:
Summary of most important changes:
SDK API Simplification
tokenTransfer()andmessage()factory functions and types for easier, safer message creation; exported these from the SDK entry point.SendMessageOptsto accept both simplified and full message formats, with improved documentation and examples.Normalization and Defaults
normalizeMessageutility and integrated it into EVM and Aptos chain implementations to ensure all messages are normalized with proper defaults for each chain. [1] [2] [3] [4] [5] [6]getDefaultExtraArgsto centralize and document defaultextraArgslogic for all supported chain families.Testing
getDefaultExtraArgsandnormalizeMessage, ensuring correct defaults and normalization for all chains and message types. [1] [2]Changelog/Versioning