-
Notifications
You must be signed in to change notification settings - Fork 61
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
Swap from ZetaChain tutorial #393
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThe updates increase the estimated reading time for the "Swap Any Token" tutorial from 20 to 60 minutes and introduce significant changes to the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant SwapToAnyToken
participant ZetaChain
participant ExternalContract
User->>SwapToAnyToken: Initiate swap (swap function)
SwapToAnyToken->>ZetaChain: Perform token swap
ZetaChain-->>SwapToAnyToken: Swap result
SwapToAnyToken->>User: Token swap complete
User->>SwapToAnyToken: Initiate cross-chain call (onCrossChainCall)
SwapToAnyToken->>ExternalContract: Call contract
ExternalContract-->>SwapToAnyToken: Response
SwapToAnyToken->>SwapToAnyToken: Execute swapAndWithdraw
SwapToAnyToken->>User: Process withdrawal (if applicable)
Poem
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 as PR comments)
Additionally, you can add 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: 0
Outside diff range, codebase verification and nitpick comments (6)
src/pages/developers/tutorials/swap-any.mdx (5)
168-168
: Grammar correction: Use "withdrawal" instead of "withdraw".The word 'withdraw' is not a noun. The correct term is 'withdrawal'.
- all values: target token, recipient and the withdraw flag. + all values: target token, recipient and the withdrawal flag.Tools
LanguageTool
[grammar] ~168-~168: The word ‘withdraw’ is not a noun. Did you mean “withdrawal”?
Context: ...values: target token, recipient and the withdraw flag. Next, addparams.withdraw
as t...(PREPOSITION_VERB)
180-181
: Grammar and article correction: Use "withdrawal" and add missing articles.The word 'withdraw' is not a noun. The correct term is 'withdrawal'. Also, add missing articles for clarity.
- If a user withdraws token, subtract the withdraw fee in input token amount. + If a user withdraws the token, subtract the withdrawal fee from the input token amount.Tools
LanguageTool
[uncategorized] ~180-~180: Possible missing article found.
Context: ...ctTokensForTokens`. If a user withdraws token, subtract the withdraw fee in input tok...(AI_HYDRA_LEO_MISSING_A)
[grammar] ~181-~181: The word ‘withdraw’ is not a noun. Did you mean “withdrawal”?
Context: ...If a user withdraws token, subtract the withdraw fee in input token amount. Finally, ad...(PREPOSITION_VERB)
[uncategorized] ~181-~181: The preposition “from” seems more likely in this position.
Context: ...hdraws token, subtract the withdraw fee in input token amount. Finally, add a con...(AI_EN_LECTOR_REPLACEMENT_PREPOSITION)
[uncategorized] ~181-~181: You might be missing the article “the” here.
Context: ...aws token, subtract the withdraw fee in input token amount. Finally, add a condition...(AI_EN_LECTOR_MISSING_DETERMINER_THE)
185-185
: Grammar correction: Add missing comma.Add a comma after 'token' for clarity.
- If a user doesn't want to withdraw a token you need to consider two scenarios: + If a user doesn't want to withdraw a token, you need to consider two scenarios:Tools
LanguageTool
[uncategorized] ~185-~185: Possible missing comma found.
Context: ...n. If a user doesn't want to withdraw a token you need to consider two scenarios: - ...(AI_HYDRA_LEO_MISSING_COMMA)
198-199
: Grammar correction: Add missing comma.Add a comma after 'tokens' for clarity.
- tokens they have on ZetaChain for other tokens and optionally also withdraw them. + tokens they have on ZetaChain for other tokens, and optionally also withdraw them.Tools
LanguageTool
[uncategorized] ~198-~198: Possible missing comma found.
Context: ...tokens they have on ZetaChain for other tokens and optionally also withdraw them. For ...(AI_HYDRA_LEO_MISSING_COMMA)
[uncategorized] ~199-~199: Use a comma before ‘and’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...or example, when a user has a ZRC-20 ETH and they want to swap it for ZRC-20 BTC (wi...(COMMA_COMPOUND_SENTENCE)
225-225
: Grammar correction: Add missing comma.Add a comma after 'asset' for clarity.
- asset already on ZetaChain for a different asset optionally withdrawing it. + asset already on ZetaChain for a different asset, optionally withdrawing it.Tools
LanguageTool
[uncategorized] ~225-~225: A comma might be missing here.
Context: ...et already on ZetaChain for a different asset optionally withdrawing it. ``` import ...(AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)
src/pages/developers/tutorials/swap.mdx (1)
188-189
: Grammar correction: Add missing comma.Add a comma after 'function' for clarity.
- function called `swapAndWithdraw`. Use the `withdrawGasFee` method + function called `swapAndWithdraw`. Use the `withdrawGasFee` method,
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- src/pages/developers/tutorials/_meta.json (1 hunks)
- src/pages/developers/tutorials/swap-any.mdx (6 hunks)
- src/pages/developers/tutorials/swap.mdx (3 hunks)
Additional context used
LanguageTool
src/pages/developers/tutorials/swap-any.mdx
[grammar] ~168-~168: The word ‘withdraw’ is not a noun. Did you mean “withdrawal”?
Context: ...values: target token, recipient and the withdraw flag. Next, addparams.withdraw
as t...(PREPOSITION_VERB)
[uncategorized] ~180-~180: Possible missing article found.
Context: ...ctTokensForTokens`. If a user withdraws token, subtract the withdraw fee in input tok...(AI_HYDRA_LEO_MISSING_A)
[grammar] ~181-~181: The word ‘withdraw’ is not a noun. Did you mean “withdrawal”?
Context: ...If a user withdraws token, subtract the withdraw fee in input token amount. Finally, ad...(PREPOSITION_VERB)
[uncategorized] ~181-~181: The preposition “from” seems more likely in this position.
Context: ...hdraws token, subtract the withdraw fee in input token amount. Finally, add a con...(AI_EN_LECTOR_REPLACEMENT_PREPOSITION)
[uncategorized] ~181-~181: You might be missing the article “the” here.
Context: ...aws token, subtract the withdraw fee in input token amount. Finally, add a condition...(AI_EN_LECTOR_MISSING_DETERMINER_THE)
[uncategorized] ~185-~185: Possible missing comma found.
Context: ...n. If a user doesn't want to withdraw a token you need to consider two scenarios: - ...(AI_HYDRA_LEO_MISSING_COMMA)
[uncategorized] ~198-~198: Possible missing comma found.
Context: ...tokens they have on ZetaChain for other tokens and optionally also withdraw them. For ...(AI_HYDRA_LEO_MISSING_COMMA)
[uncategorized] ~199-~199: Use a comma before ‘and’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...or example, when a user has a ZRC-20 ETH and they want to swap it for ZRC-20 BTC (wi...(COMMA_COMPOUND_SENTENCE)
[uncategorized] ~225-~225: A comma might be missing here.
Context: ...et already on ZetaChain for a different asset optionally withdrawing it. ``` import ...(AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)
Additional comments not posted (9)
src/pages/developers/tutorials/_meta.json (1)
19-19
: Update to reading time is appropriate.The change reflects an increase in the estimated reading time for the "Swap Any Token" tutorial from 20 minutes to 60 minutes, which aligns with the significant changes introduced in the tutorial.
src/pages/developers/tutorials/swap-any.mdx (6)
50-50
: Addition ofreceive
function is appropriate.The
receive
function allows the contract to accept Ether, which is necessary for handling external payments.
Line range hint
51-90
:
Refactoring ofonCrossChainCall
function is appropriate.The function now includes additional parameters and a call to
swapAndWithdraw
, enhancing the functionality and clarity of the token swapping process.
Line range hint
92-137
:
Modification ofswapAndWithdraw
function is appropriate.The function now handles token swaps and withdrawals based on conditions, improving the flexibility and functionality of the contract.
141-151
: Addition of newswap
function is appropriate.The new public
swap
function allows users to swap tokens on ZetaChain, enhancing the contract's usability.
221-221
: Addition of optionalwithdraw
parameter is appropriate.The optional parameter enhances the functionality of the
Interact
task by allowing users to specify whether they want to withdraw the target token to the destination chain.
223-276
: Addition ofSwap
task is appropriate.The new task allows users to interact with the
SwapToAnyToken
contract on ZetaChain, enhancing the tutorial's functionality.Tools
LanguageTool
[uncategorized] ~225-~225: A comma might be missing here.
Context: ...et already on ZetaChain for a different asset optionally withdrawing it. ``` import ...(AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)
src/pages/developers/tutorials/swap.mdx (2)
124-125
: Refactoring ofswapAndWithdraw
function is appropriate.The function now consolidates the token swapping and withdrawal steps, improving code organization and readability.
127-156
: Modification ofswapAndWithdraw
function is appropriate.The function now handles token swaps and withdrawals based on conditions, improving the flexibility and functionality of the contract.
zeta-chain/example-contracts#186
Summary by CodeRabbit
New Features
swap
function for users to swap tokens on ZetaChain.Swap
task for easier interaction with theSwapToAnyToken
contract.Enhancements
SwapToAnyToken.sol
contract with enhanced token swap and withdrawal functionality.