-
Notifications
You must be signed in to change notification settings - Fork 60
Swap: swap from EVM task #203
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
Conversation
📝 Walkthrough📝 WalkthroughWalkthroughThis pull request introduces modifications to the Hardhat configuration and related task files for the Changes
Possibly related PRs
Suggested reviewers
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🧹 Outside diff range and nitpick comments (2)
examples/swap/tasks/swapFromZetaChain.ts (1)
21-25: Swap function parameter updates: Approved with suggestionThe modifications to the swap function parameters effectively align the function call with the updated task parameters. The use of
args.zrc20andargs.targetimproves clarity. Converting the recipient to an array of bytes enhances cross-chain compatibility.However, parsing
args.withdrawas JSON may be redundant, given that it's defined as a boolean type in the task definition. Consider simplifying this to:args.withdrawThis change would maintain type consistency and reduce unnecessary parsing.
examples/swap/tasks/swapFromEVM.ts (1)
41-41: Clarify the distinction between 'receiver' and 'recipient' parametersBoth
receiver(line 41) andrecipient(line 76) are addresses, which may cause confusion. Ensure that their purposes are clearly documented, and consider renaming one for clarity.Also applies to: 76-76
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
⛔ Files ignored due to path filters (1)
examples/swap/yarn.lockis excluded by!**/yarn.lock,!**/*.lock
📒 Files selected for processing (4)
- examples/swap/hardhat.config.ts (1 hunks)
- examples/swap/package.json (2 hunks)
- examples/swap/tasks/swapFromEVM.ts (1 hunks)
- examples/swap/tasks/swapFromZetaChain.ts (2 hunks)
🧰 Additional context used
🔇 Additional comments (7)
examples/swap/tasks/swapFromZetaChain.ts (4)
1-1: Import statement update: ApprovedThe addition of
typesfrom 'hardhat/config' is a prudent change that enhances type safety and code clarity. This import is utilized effectively in the task definition, contributing to a more robust implementation.
13-15: ZRC20 contract instantiation: ApprovedThe introduction of the ZRC20 contract instantiation is a crucial addition that facilitates direct interaction with the token contract. This change is necessary for the approval process prior to the swap operation. The implementation adheres to best practices by utilizing
ethers.Contract.
32-32: Task name and description update: ApprovedThe modification of the task name to "swap-from-zetachain" and the updated description "Swap tokens from ZetaChain" significantly enhance clarity. These changes provide a more accurate representation of the task's functionality, which will improve usability for developers interacting with the Hardhat task system.
36-44: Task parameter updates: ApprovedThe modifications to the task parameters are well-considered and enhance the overall functionality and usability of the task:
- The addition of the
zrc20parameter provides necessary flexibility for specifying the input token address.- Renaming
targetTokentotargetmaintains consistency with the swap function update.- The
withdrawparameter's transformation into an optional parameter with a default value oftrueand explicittypes.booleantype improves usability while ensuring type safety.These changes collectively contribute to a more robust and developer-friendly task definition.
examples/swap/package.json (2)
60-60: Caution: Update to pre-release version of @zetachain/toolkit.The "@zetachain/toolkit" package has been updated from "13.0.0-rc4" to "13.0.0-rc5". This update involves a change between release candidate versions, which may introduce breaking changes or significant alterations in functionality.
To ensure the stability and compatibility of this update, please execute the following verification steps:
#!/bin/bash # Description: Verify the impact of updating @zetachain/toolkit # Test: Check for breaking changes or new features in the changelog rg --type md -i '(breaking changes?|new features?)' $(fd -t f -e md CHANGELOG) # Test: Verify that all imports from @zetachain/toolkit are still valid rg --type typescript 'from\s+[\'"]@zetachain/toolkit[\'"]' # Test: Run the test suite to catch any potential issues npm testPlease review the results carefully and address any breaking changes or failed tests. Consider documenting any new features or changes in behavior that this update introduces.
31-31: Verify compatibility with updated @zetachain/localnet version.The "@zetachain/localnet" package has been updated from "^3.0.4" to "^3.3.0". While this is a minor version update, it's crucial to ensure that this change doesn't introduce any breaking changes or incompatibilities with the rest of the project.
To verify the impact of this update, please run the following script:
If any breaking changes are found or if the build fails, please review and address them accordingly.
examples/swap/tasks/swapFromEVM.ts (1)
28-29: Ensure 'args.recipient' matches the expected 'bytes' typeThe parameter
args.recipientis likely an address, but the corresponding type is specified asbytes. Ifargs.recipientshould be a byte array, consider encoding it appropriately usingethers.utils.toUtf8Bytesor a similar method.
Task to swap from EVM using
evmDepositAndCallfrom the toolkit.EVM → ZetaChain → EVM:
ZetaChain → EVM:
Summary by CodeRabbit
@zetachain/localnetand@zetachain/toolkitfor improved performance and features.