-
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
Authenticated call updates #504
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
📝 Walkthrough📝 WalkthroughWalkthroughThis pull request introduces several modifications primarily focused on updating titles and descriptions within various 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: 10
🧹 Outside diff range and nitpick comments (25)
src/pages/developers/tutorials/_meta.json (2)
5-5
: Consider providing more specific learning outcomes in the description.The current description "Learn more about universal apps" is quite broad. Consider expanding it to outline specific concepts or skills that users will gain, making it more actionable for newcomers.
- "description": "Learn more about universal apps" + "description": "Learn the fundamentals of universal apps, including smart contract setup, account creation, and faucet usage"
37-40
: Fix grammatical error in description.There's a minor grammatical error in the description.
- "description": "Setup your account, request test tokens from the faucet" + "description": "Set up your account, request test tokens from the faucet"src/pages/developers/_meta.json (1)
Line range hint
1-38
: Consider optimizing the documentation flow.The current section ordering is logical but could be enhanced. Consider moving "Working with Tokens" before "Frontend Tutorials" as it contains fundamental concepts that might be needed for frontend development.
{ "index": { ... }, "apps": { ... }, "evm": { ... }, "chains": { ... }, "tutorials": { ... }, + "tokens": { + "title": "Working with Tokens", + "description": "Overview of the different types of tokens available on ZetaChain and connected blockchains, and how to work with them." + }, "frontend": { ... }, "services": { ... }, - "tokens": { - "title": "Working with Tokens", - "description": "Overview of the different types of tokens available on ZetaChain and connected blockchains, and how to work with them." - }, "architecture": { ... } }src/pages/developers/evm/gas.mdx (1)
36-37
: Add a note about the contract version.Consider adding a note to indicate that this links to the v2 implementation of the ZRC-20 contract, as this helps users understand which version of the contract they're referring to.
To find out the fee amount, call the `withdrawGasFee` function on the [ZRC-20 -contract](https://github.com/zeta-chain/protocol-contracts/blob/3ede272fba5b0c28a25778477b02f0639e5877f3/v2/contracts/zevm/ZRC20.sol) +contract (v2)](https://github.com/zeta-chain/protocol-contracts/blob/3ede272fba5b0c28a25778477b02f0639e5877f3/v2/contracts/zevm/ZRC20.sol)src/pages/developers/tutorials/intro.mdx (3)
13-15
: Fix hyphenation in architectural termThe term should be "hub-and-spoke model" or "hub-spoke model" (without the extra hyphen).
-hub-spoke-model +hub-spoke model🧰 Tools
🪛 LanguageTool
[uncategorized] ~13-~13: Possible missing comma found.
Context: ...etaChain acts as a hub in the hub-spoke-model and developers build universal apps tha...(AI_HYDRA_LEO_MISSING_COMMA)
9-16
: Consider adding a diagramThe hub-spoke architecture explanation would benefit from a visual representation showing the Gateway implementations across different chains.
🧰 Tools
🪛 LanguageTool
[uncategorized] ~13-~13: Possible missing comma found.
Context: ...etaChain acts as a hub in the hub-spoke-model and developers build universal apps tha...(AI_HYDRA_LEO_MISSING_COMMA)
1-41
: Consider additional documentation enhancementsWhile the content is well-structured and informative, consider these improvements:
- Add a table of contents for better navigation
- Include code examples demonstrating the concepts
- Add links to related documentation for deeper dives into specific topics
🧰 Tools
🪛 LanguageTool
[uncategorized] ~13-~13: Possible missing comma found.
Context: ...etaChain acts as a hub in the hub-spoke-model and developers build universal apps tha...(AI_HYDRA_LEO_MISSING_COMMA)
[typographical] ~41-~41: It seems that a comma is missing.
Context: ... call in ZRC-20 token. To cover the gas fee a universal app can swap tokens(IN_ORDER_TO_VB_COMMA)
src/pages/developers/tutorials/testnet.mdx (4)
14-28
: Add context about the 'hello' example project.While the setup instructions are clear, consider adding a brief description of what the 'hello' example demonstrates to help users understand what they're setting up.
Change directory to any of the examples, like `hello` and install dependencies: + +The `hello` example demonstrates [brief description of what it does].
58-59
: Improve grammar in the automatic import description.-It first attempts to automatically import the private key +It first attempts to import the private key automatically🧰 Tools
🪛 LanguageTool
[style] ~58-~58: Style-wise, it’s not ideal to insert an adverb (‘automatically’) in the middle of an infinitive construction (‘to import’). Try moving the adverb to avoid split infinitives.
Context: ...the process is as follows: 1. It first attempts to automatically import the private key from the~/.config/solana/id.json
...(SPLIT_INFINITIVE)
39-40
: Add security warning about private key storage.Consider adding a security note about the sensitivity of the
.env
file and proper handling of private keys.wallet information in the terminal, and saves the private key to a `.env` file, -making it accessible to Hardhat. +making it accessible to Hardhat. Note: Keep your `.env` file secure and never +commit it to version control.
109-109
: Fix grammar and spelling issues.-receive native ZETA tokens on ZetaChain testnet +receive native ZETA tokens on the ZetaChain testnet -blockchains like Ethereun, BNB and Bitcoin testnets +blockchains like Ethereum, BNB and Bitcoin testnetsAlso applies to: 134-134
🧰 Tools
🪛 LanguageTool
[uncategorized] ~109-~109: You might be missing the article “the” here.
Context: ... you will receive native ZETA tokens on ZetaChain testnet. It may take a few minutes for ...(AI_EN_LECTOR_MISSING_DETERMINER_THE)
src/pages/developers/apps/intro.mdx (2)
Line range hint
3-3
: Remove unused Alert importThe
Alert
component is imported but not used in the document after the removal of the Gateway interface alert.-import { Alert } from "~/components/shared";
🧰 Tools
🪛 LanguageTool
[typographical] ~53-~53: It appears that a comma is missing.
Context: ...s when calling universal apps. In this example an Ethereum user sends 1 ETH and a mess...(DURING_THAT_TIME_COMMA)
Line range hint
1-180
: Consider restoring Gateway interface informationThe removal of the alert about the Gateway interface might impact user awareness of important upcoming changes. Consider:
- Adding this information in a less intrusive way, perhaps as a note or callout
- Including it in the "Calling Universal Apps" section where Gateway contracts are discussed
🧰 Tools
🪛 LanguageTool
[typographical] ~53-~53: It appears that a comma is missing.
Context: ...s when calling universal apps. In this example an Ethereum user sends 1 ETH and a mess...(DURING_THAT_TIME_COMMA)
src/pages/developers/tutorials/hello.mdx (4)
1-2
: Improve grammatical structure of the introductionConsider adding a comma after "In this tutorial" for better readability.
-In this tutorial you will create a simple universal app deployed on ZetaChain, +In this tutorial, you will create a simple universal app deployed on ZetaChain,🧰 Tools
🪛 LanguageTool
[typographical] ~1-~1: It appears that a comma is missing.
Context: In this tutorial you will create a simple universal app ...(DURING_THAT_TIME_COMMA)
31-35
: Add NatSpec documentation to the contract and eventConsider adding comprehensive NatSpec documentation to improve code maintainability and developer experience.
+/// @title Universal Contract Example +/// @notice A simple universal contract that emits events when called from connected chains +/// @dev Inherits from UniversalContract and uses Gateway for cross-chain communication contract Universal is UniversalContract { GatewayZEVM public immutable gateway; - event HelloEvent(string, string); + /// @notice Emitted when the contract receives a cross-chain call + /// @param prefix The greeting prefix + /// @param name The name received in the message + event HelloEvent(string indexed prefix, string name);
102-107
: Add error handling guidance to deployment instructionsConsider adding a section about common deployment issues and their solutions, such as:
- Network connectivity issues
- Insufficient funds
- Gateway address verification
155-163
: Add verification steps for successful cross-chain callsConsider adding steps to verify the successful execution:
- How to query and verify the emitted events
- Expected transaction status and confirmation times
- Troubleshooting steps if the transaction fails
src/pages/developers/chains/zetachain.mdx (4)
7-8
: Improve clarity and remove redundancy in the bullet pointThe current text has redundant wording and could be clearer. Consider this revision:
-- withdrawing ZETA tokens to connected chains withdrawing tokens to and making a - contract call on connected chains ++ withdrawing ZETA tokens to connected chains and making contract calls
13-17
: Enhance function documentation completenessWhile the documentation explains most parameters, it should also:
- Document the
revertOptions
parameter in this section (currently only explained in a later section)- Specify the function's return value and behavior
46-46
: Improve function signature readabilityConsider breaking the long function signature into multiple lines for better readability:
-function withdrawAndCall(bytes memory receiver, uint256 amount, address zrc20, bytes calldata message, CallOptions calldata callOptions, RevertOptions calldata revertOptions) +function withdrawAndCall( + bytes memory receiver, + uint256 amount, + address zrc20, + bytes calldata message, + CallOptions calldata callOptions, + RevertOptions calldata revertOptions +)
Line range hint
1-1
: Add practical examples for common use casesConsider enhancing the documentation with:
- Complete code examples for common scenarios
- Step-by-step tutorials for both arbitrary and authenticated calls
- Example implementations of the Revertable interface
This would help developers better understand the practical application of these concepts.
🧰 Tools
🪛 LanguageTool
[uncategorized] ~20-~20: Although a hyphen is possible, it is not necessary in a compound modifier in which the first word is an adverb that ends in ‘ly’.
Context: ...ernal; ``` Thereceiver
is either an externally-owned account (EOA) or a contract on a connec...(HYPHENATED_LY_ADVERB_ADJECTIVE)
src/pages/developers/tutorials/call.mdx (2)
225-227
: Fix grammatical issues in the documentationReplace instances of "withdraw fee" with "withdrawal fee" for correct grammar.
-tokens to pay the withdraw fee +tokens to pay the withdrawal fee -to cover the withdraw fee +to cover the withdrawal fee🧰 Tools
🪛 LanguageTool
[grammar] ~225-~225: The word ‘withdraw’ is not a noun. Did you mean “withdrawal”?
Context: ... amount of gas ZRC-20 tokens to pay the withdraw fee. In a production-ready contract the...(PREPOSITION_VERB)
[uncategorized] ~226-~226: Possible missing comma found.
Context: ...the withdraw fee. In a production-ready contract the contract might need to swap a fract...(AI_HYDRA_LEO_MISSING_COMMA)
[grammar] ~227-~227: The word ‘withdraw’ is not a noun. Did you mean “withdrawal”?
Context: ... the token being withdrawn to cover the withdraw fee. ### Withdrawing Tokens and Making...(PREPOSITION_VERB)
68-90
: Optimize gas usage in withdraw functionThe function can be optimized by caching the result of
zrc20 == gasZRC20
check and combining the approval operations.function withdraw( bytes memory receiver, uint256 amount, address zrc20, RevertOptions memory revertOptions ) external { (address gasZRC20, uint256 gasFee) = IZRC20(zrc20).withdrawGasFee(); - uint256 target = zrc20 == gasZRC20 ? amount + gasFee : amount; + bool isGasToken = zrc20 == gasZRC20; + uint256 target = isGasToken ? amount + gasFee : amount; if (!IZRC20(zrc20).transferFrom(msg.sender, address(this), target)) revert TransferFailed(); - IZRC20(zrc20).approve(address(gateway), target); - if (zrc20 != gasZRC20) { + if (!IZRC20(zrc20).approve(address(gateway), target)) + revert ApprovalFailed(); + if (!isGasToken) { if (!IZRC20(gasZRC20).transferFrom(msg.sender, address(this), gasFee)) revert TransferFailed(); - IZRC20(gasZRC20).approve(address(gateway), gasFee); + if (!IZRC20(gasZRC20).approve(address(gateway), gasFee)) + revert ApprovalFailed(); } gateway.withdraw(receiver, amount, zrc20, revertOptions); }src/pages/developers/tutorials/nft.mdx (2)
Line range hint
145-178
: Add reentrancy protection to transferCrossChain.The function makes external calls after state changes, which could be vulnerable to reentrancy attacks.
+ modifier nonReentrant { + require(!locked, "Reentrant call"); + locked = true; + _; + locked = false; + } - function transferCrossChain( + function transferCrossChain( uint256 tokenId, address receiver, address destination - ) public { + ) public nonReentrant {
651-654
: Add verification steps after deployment.Consider adding steps to verify the deployed contracts and their configurations:
- Verify contract source code on block explorers
- Validate counterparty settings
- Test basic operations before proceeding with transfers
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (14)
src/pages/developers/_meta.json
(1 hunks)src/pages/developers/apps/_meta.json
(1 hunks)src/pages/developers/apps/intro.mdx
(2 hunks)src/pages/developers/chains/_meta.json
(1 hunks)src/pages/developers/chains/zetachain.mdx
(2 hunks)src/pages/developers/evm/_meta.json
(1 hunks)src/pages/developers/evm/gas.mdx
(1 hunks)src/pages/developers/tokens/zrc20.mdx
(0 hunks)src/pages/developers/tutorials/_meta.json
(2 hunks)src/pages/developers/tutorials/call.mdx
(1 hunks)src/pages/developers/tutorials/hello.mdx
(3 hunks)src/pages/developers/tutorials/intro.mdx
(1 hunks)src/pages/developers/tutorials/nft.mdx
(11 hunks)src/pages/developers/tutorials/testnet.mdx
(1 hunks)
💤 Files with no reviewable changes (1)
- src/pages/developers/tokens/zrc20.mdx
✅ Files skipped from review due to trivial changes (3)
- src/pages/developers/apps/_meta.json
- src/pages/developers/chains/_meta.json
- src/pages/developers/evm/_meta.json
🧰 Additional context used
🪛 LanguageTool
src/pages/developers/chains/zetachain.mdx
[uncategorized] ~49-~49: Use a comma before “and” if it connects two independent clauses (unless they are closely connected and short).
Context: ...rtOptions) ``` The tokens are withdrawn and a call is made to a contract on the con...
(COMMA_COMPOUND_SENTENCE_2)
[uncategorized] ~63-~63: Possible missing comma found.
Context: ...stination chain. In the context of this function zrc20
address acts as an identifier f...
(AI_HYDRA_LEO_MISSING_COMMA)
src/pages/developers/tutorials/call.mdx
[grammar] ~225-~225: The word ‘withdraw’ is not a noun. Did you mean “withdrawal”?
Context: ... amount of gas ZRC-20 tokens to pay the withdraw fee. In a production-ready contract the...
(PREPOSITION_VERB)
[uncategorized] ~226-~226: Possible missing comma found.
Context: ...the withdraw fee. In a production-ready contract the contract might need to swap a fract...
(AI_HYDRA_LEO_MISSING_COMMA)
[grammar] ~227-~227: The word ‘withdraw’ is not a noun. Did you mean “withdrawal”?
Context: ... the token being withdrawn to cover the withdraw fee. ### Withdrawing Tokens and Making...
(PREPOSITION_VERB)
src/pages/developers/tutorials/hello.mdx
[typographical] ~1-~1: It appears that a comma is missing.
Context: In this tutorial you will create a simple universal app ...
(DURING_THAT_TIME_COMMA)
[uncategorized] ~66-~66: Loose punctuation mark.
Context: ...oming data, which includes: - context
: A MessageContext
struct containing: ...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~69-~69: Loose punctuation mark.
Context: ...-chain call originated. - sender
: The address (EOA or contract) that init...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~71-~71: Loose punctuation mark.
Context: ...on the connected chain. - origin
: deprecated. - zrc20
: The address of t...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~72-~72: Loose punctuation mark.
Context: ...ain. - origin
: deprecated. - zrc20
: The address of the ZRC-20 token represe...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~74-~74: Loose punctuation mark.
Context: ...sset from the source chain. - amount
: The number of tokens transferred. - `me...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~75-~75: Loose punctuation mark.
Context: ...umber of tokens transferred. - message
: The encoded data payload. In this exam...
(UNLIKELY_OPENING_PUNCTUATION)
[style] ~80-~80: To form a complete sentence, be sure to include a subject.
Context: ... variable and emits an event. onCall
should only be called by the Gateway to ensure...
(MISSING_IT_THERE)
src/pages/developers/tutorials/intro.mdx
[uncategorized] ~13-~13: Possible missing comma found.
Context: ...etaChain acts as a hub in the hub-spoke-model and developers build universal apps tha...
(AI_HYDRA_LEO_MISSING_COMMA)
[typographical] ~41-~41: It seems that a comma is missing.
Context: ... call in ZRC-20 token. To cover the gas fee a universal app can swap tokens
(IN_ORDER_TO_VB_COMMA)
src/pages/developers/tutorials/testnet.mdx
[style] ~58-~58: Style-wise, it’s not ideal to insert an adverb (‘automatically’) in the middle of an infinitive construction (‘to import’). Try moving the adverb to avoid split infinitives.
Context: ...the process is as follows: 1. It first attempts to automatically import the private key from the ~/.config/solana/id.json
...
(SPLIT_INFINITIVE)
[uncategorized] ~109-~109: You might be missing the article “the” here.
Context: ... you will receive native ZETA tokens on ZetaChain testnet. It may take a few minutes for ...
(AI_EN_LECTOR_MISSING_DETERMINER_THE)
🔇 Additional comments (8)
src/pages/developers/tutorials/_meta.json (3)
8-11
: LGTM! Clear progression for newcomers.
The title change and new description create a more intuitive learning path, starting with fundamentals and progressing to hands-on development.
33-36
: LGTM! Title change improves clarity.
The updated title better reflects the section's focus on environment setup.
12-15
: Verify content distribution between tutorials.
Since "Message Passing" was removed from the "hello" section and is now mentioned in this new section, ensure there's no duplicate content or gaps in the learning progression between these tutorials.
✅ Verification successful
The previous command didn't yield results, suggesting the files might not exist yet or be in a different location. Let's verify the tutorial files' existence and content to provide accurate feedback about potential content overlap.
Content distribution is appropriate with no overlap concerns.
After reviewing both tutorial files, the content distribution is well-structured and distinct:
- The "hello" tutorial focuses on building a basic universal app that handles simple cross-chain messages and events
- The "call" tutorial builds upon this foundation by covering advanced topics:
- Cross-chain contract calls
- Token deposits and withdrawals
- Gateway interactions
- Complex message passing patterns
The removal of "Message Passing" from the hello section's title actually improves the learning progression, as basic message handling is now introduced in the simpler hello tutorial before diving into comprehensive message passing patterns in the call tutorial.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Check content overlap between hello and call tutorials
rg -A 5 "message passing" src/pages/developers/tutorials/hello.mdx src/pages/developers/tutorials/call.mdx
Length of output: 108
Script:
#!/bin/bash
# Let's check if the files exist first and their content
fd "hello.mdx|call.mdx" src/pages/developers/tutorials/
# If files exist, let's check their content for any mentions of message passing or related terms
fd "hello.mdx|call.mdx" src/pages/developers/tutorials/ -x cat {}
Length of output: 24978
src/pages/developers/evm/gas.mdx (1)
36-36
: Verify the contract implementation at the specified commit.
The link has been updated to point to a specific commit in the v2 contracts.
Let's verify that the contract at this commit contains the referenced withdrawGasFee
function:
✅ Verification successful
Contract implementation verified successfully
The ZRC20 contract at the specified commit contains both withdrawGasFee()
and withdrawGasFeeWithGasLimit(gasLimit)
functions, maintaining compatibility with the documentation.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify the ZRC20 contract implementation
# Expected: The contract should contain the withdrawGasFee function
# Fetch and check the contract content
curl -s "https://raw.githubusercontent.com/zeta-chain/protocol-contracts/3ede272fba5b0c28a25778477b02f0639e5877f3/v2/contracts/zevm/ZRC20.sol" | grep -A 5 "function withdrawGasFee"
Length of output: 911
src/pages/developers/tutorials/intro.mdx (1)
1-7
: LGTM: Clear and concise introduction
The introduction effectively explains the core concept of universal apps and their capabilities.
src/pages/developers/tutorials/testnet.mdx (2)
1-13
: LGTM! Clear and comprehensive prerequisites section.
The introduction and prerequisites are well-structured and provide all necessary information for users to get started.
69-97
: LGTM! Comprehensive balance querying documentation.
The balance querying section provides clear instructions with all necessary options and supported token types.
src/pages/developers/tutorials/nft.mdx (1)
57-57
: LGTM: Clear availability notice.
The alert effectively communicates the Gateway's current availability limitations.
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: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
src/pages/developers/tutorials/nft.mdx
(10 hunks)
🔇 Additional comments (2)
src/pages/developers/tutorials/nft.mdx (2)
128-128
: 🛠️ Refactor suggestion
Enhance gas limit validation.
The gas limit validation only checks for non-zero values. Consider adding an upper bound check to prevent excessive gas consumption.
- if (gas == 0) revert InvalidGasLimit();
+ if (gas == 0 || gas > 1_000_000) revert InvalidGasLimit();
Likely invalid or redundant comment.
689-689
: Verify gateway address for deployment commands.
Based on the analysis of the codebase, there are multiple tutorials using different gateway addresses for different networks (zeta_testnet: 0x6c533f7f..., base_sepolia: 0x0c487a76..., localhost: 0x5FC8d326...), but there's no validation mechanism to ensure the correct gateway address is used for each network.
✅ Verification successful
Let me gather more information about the gateway addresses and network configurations to ensure they are consistent across the tutorials.
Gateway addresses are correctly mapped to their respective networks
Based on the comprehensive analysis of the codebase, the gateway addresses are consistently used across all tutorial files:
0x6c533f7fe93fae114d0954697069df33c9b74fd7
forzeta_testnet
0x0c487a766110c85d301d96e33579c5b317fa4995
forbase_sepolia
andbsc_testnet
0x5FC8d32690cc91D4c39d9d3abcBD16989F875707
forlocalhost
(Universal contract)0x610178dA211FEF7D417bC0e6FeD39F05609AD788
forlocalhost
(Connected contract)
The gateway addresses are properly documented in the tutorials and consistently used across different contract deployments for their respective networks.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Verify gateway address matches network
NETWORK="zeta_testnet"
GATEWAY="0x6c533f7fe93fae114d0954697069df33c9b74fd7"
# Search for gateway address references
rg -l "gateway.*$GATEWAY"
# Look for any network configuration or validation logic
rg -i "network.*gateway|gateway.*network" src/pages/developers/tutorials/*.mdx
Length of output: 2277
Script:
#!/bin/bash
# Search for any network configuration files or hardhat config
fd -e js -e json "hardhat.config"
# Look for any documentation about gateway addresses
fd -e md -e mdx "gateway" src/pages/developers
# Check if there are any constants or configuration files defining these addresses
rg -i "const.*gateway|gateway.*="
Length of output: 3389
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: 5
🧹 Outside diff range and nitpick comments (8)
src/pages/developers/chains/evm.mdx (5)
6-10
: LGTM! Consider grouping related features.The bullet points clearly outline the supported features. Consider grouping related functionalities together:
- - Depositing gas tokens to a universal app or an account on ZetaChain. - - Depositing supported ERC-20 tokens (including ZETA tokens). - - Depositing gas tokens and calling a universal app. - - Depositing supported ERC-20 tokens and calling a universal app. - - Calling a universal app. + - Basic deposits: + - Depositing gas tokens to a universal app or an account on ZetaChain + - Depositing supported ERC-20 tokens (including ZETA tokens) + - Deposits with contract interaction: + - Depositing gas tokens and calling a universal app + - Depositing supported ERC-20 tokens and calling a universal app + - Direct interaction: + - Calling a universal app🧰 Tools
🪛 LanguageTool
[style] ~8-~8: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...RC-20 tokens (including ZETA tokens). - Depositing gas tokens and calling a universal app....(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~9-~9: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...s tokens and calling a universal app. - Depositing supported ERC-20 tokens and calling a u...(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
24-28
: Minor improvements for clarity and style.
- Remove the hyphen in "externally-owned" as it's not required when the first word is an adverb.
- Consider adding a note about gas fees for clarity.
- The `receiver` can be either an externally-owned account (EOA) or a universal + The `receiver` can be either an externally owned account (EOA) or a universal app address on ZetaChain. Even if the receiver is a universal app contract with the standard `receive` function, the `deposit` function will not trigger a contract call. If you want to deposit and call a universal app, use the - `depositAndCall` function instead. + `depositAndCall` function instead. Note that gas fees on ZetaChain will be + deducted from the deposited amount.🧰 Tools
🪛 LanguageTool
[uncategorized] ~24-~24: Although a hyphen is possible, it is not necessary in a compound modifier in which the first word is an adverb that ends in ‘ly’.
Context: ...Chain. Thereceiver
can be either an externally-owned account (EOA) or a universal app addres...(HYPHENATED_LY_ADVERB_ADJECTIVE)
Line range hint
64-78
: Enhance code example with documentation.The contract example would benefit from documentation comments explaining its purpose and implementation requirements.
pragma solidity 0.8.26; import "@zetachain/protocol-contracts/contracts/zevm/interfaces/UniversalContract.sol"; +/// @title Universal Application Contract +/// @notice Base contract for implementing cross-chain applications on ZetaChain +/// @dev Inherit this contract to handle cross-chain messages and token transfers contract UniversalApp is UniversalContract { + /// @notice Handles incoming cross-chain messages and token transfers + /// @param context Information about the message sender and source chain + /// @param zrc20 The ZRC-20 token address of the transferred tokens + /// @param amount The amount of tokens transferred + /// @param message Additional data passed with the call function onCall( MessageContext calldata context, address zrc20, uint256 amount, bytes calldata message ) external virtual override { // ... } }🧰 Tools
🪛 LanguageTool
[style] ~8-~8: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...RC-20 tokens (including ZETA tokens). - Depositing gas tokens and calling a universal app....(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~9-~9: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...s tokens and calling a universal app. - Depositing supported ERC-20 tokens and calling a u...(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[uncategorized] ~24-~24: Although a hyphen is possible, it is not necessary in a compound modifier in which the first word is an adverb that ends in ‘ly’.
Context: ...Chain. Thereceiver
can be either an externally-owned account (EOA) or a universal app addres...(HYPHENATED_LY_ADVERB_ADJECTIVE)
108-109
: Highlight protocol limitation more prominently.Consider making the single-asset limitation more visible by using a warning or note block:
-In the current version of the protocol, only one ERC-20 asset can be deposited -at a time. +> ⚠️ **Protocol Limitation**: The current version only supports depositing one +> ERC-20 asset per transaction. Multiple asset deposits in a single transaction +> are not supported.
130-131
: Add brief context for revert transactions.Consider adding a brief summary before linking to the detailed documentation:
+The Gateway contract supports configurable behavior when transactions revert, +allowing you to specify fallback actions and destinations for failed +transactions. + For information on `RevertOptions`, refer to the [ZetaChain "Revert Transactions" documentation](/developers/chains/zetachain#revert-transactions).src/pages/developers/chains/zetachain.mdx (3)
26-29
: Add code example for address conversionThe explanation about converting
address
tobytes
for EVM chains would benefit from a practical example.Add this example after the explanation:
address being chain-agnostic. When withdrawing to an EVM chain, ensure you convert `address` to `bytes`. + ```solidity + // Example of converting an EVM address to bytes + address evmAddress = 0x742d35Cc6634C0532925a3b844Bc454e4438f44e; + bytes memory receiver = abi.encode(evmAddress); + ```
102-110
: Add code example for message generationThe hexadecimal example would be more useful with accompanying code showing how to generate it.
Add this example before the current hex example:
For example: + ```solidity + // Function: hello(string) + bytes4 selector = bytes4(keccak256("hello(string)")); + bytes memory args = abi.encode("alice"); + bytes memory message = bytes.concat(selector, args); + ``` +
Line range hint
136-153
: Add implementation example for Revertable interfaceThe interface explanation would benefit from a practical implementation example.
Add this example after the current explanation:
This interface allows contracts to handle reverts dynamically, using the information provided in the `RevertContext`. + ```solidity + contract MyRevertableContract is Revertable { + function onRevert(RevertContext calldata context) external override { + // Handle the reverted assets + if (context.asset != address(0)) { + // Handle token revert + IERC20(context.asset).transfer(msg.sender, context.amount); + } + + // Handle the revert message + emit RevertHandled(context.revertMessage); + } + } + ```🧰 Tools
🪛 LanguageTool
[uncategorized] ~127-~127: Loose punctuation mark.
Context: ...rtGasLimit; } ``` -revertAddress
: The address to return assets to if the ...(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~129-~129: Loose punctuation mark.
Context: ...nsaction reverts. -callOnRevert
: A flag indicating whether to call the `...(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~131-~131: Loose punctuation mark.
Context: ...herevertAddress
. -abortAddress
: The address to receive funds on ZetaCha...(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~133-~133: Loose punctuation mark.
Context: ...t currently used). -revertMessage
: Context passed to theonRevert
functi...(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~134-~134: Loose punctuation mark.
Context: ...vertfunction. - **
onRevertGasLimit**: Gas limit for executing the
onRevert` ...(UNLIKELY_OPENING_PUNCTUATION)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
src/pages/developers/chains/evm.mdx
(2 hunks)src/pages/developers/chains/zetachain.mdx
(3 hunks)
🧰 Additional context used
🪛 LanguageTool
src/pages/developers/chains/evm.mdx
[style] ~8-~8: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...RC-20 tokens (including ZETA tokens). - Depositing gas tokens and calling a universal app....
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~9-~9: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...s tokens and calling a universal app. - Depositing supported ERC-20 tokens and calling a u...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[uncategorized] ~24-~24: Although a hyphen is possible, it is not necessary in a compound modifier in which the first word is an adverb that ends in ‘ly’.
Context: ...Chain. The receiver
can be either an externally-owned account (EOA) or a universal app addres...
(HYPHENATED_LY_ADVERB_ADJECTIVE)
[uncategorized] ~82-~82: Loose punctuation mark.
Context: ... parameters are as follows: - message
: the value of the payload
. - amount
:...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~83-~83: Loose punctuation mark.
Context: ...: the value of the payload
. - amount
: the amount of deposited tokens. - `zrc2...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~84-~84: Loose punctuation mark.
Context: ...he amount of deposited tokens. - zrc20
: the ZRC-20 address of the deposited tok...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~86-~86: Loose punctuation mark.
Context: ...ct address of ZRC-20 ETH). - context
: - context.sender
: the sender addres...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~89-~89: Loose punctuation mark.
Context: ...lled the Gateway). - context.chainID
: the chain ID of the connected chain fro...
(UNLIKELY_OPENING_PUNCTUATION)
[grammar] ~125-~125: The verb “revert” needs to be in the to-infinitive form.
Context: ...all function is a no-asset call. If you need revert handling, consider using `depositAndCal...
(MISSING_TO_BEFORE_A_VERB)
src/pages/developers/chains/zetachain.mdx
[style] ~8-~8: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...wing ZETA tokens to connected chains. - Withdrawing tokens and making a contract call on co...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[uncategorized] ~20-~20: Although a hyphen is possible, it is not necessary in a compound modifier in which the first word is an adverb that ends in ‘ly’.
Context: ...l; ``` The receiver
can be either an externally-owned account (EOA) or a contract on a connec...
(HYPHENATED_LY_ADVERB_ADJECTIVE)
[uncategorized] ~77-~77: Loose punctuation mark.
Context: ...isArbitraryCall; } ``` - gasLimit
: The maximum gas the cross-chain contrac...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~79-~79: Loose punctuation mark.
Context: ...saction reverts. - isArbitraryCall
: Determines whether the call is "arbitra...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~127-~127: Loose punctuation mark.
Context: ...rtGasLimit; } ``` - revertAddress
: The address to return assets to if the ...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~129-~129: Loose punctuation mark.
Context: ...nsaction reverts. - callOnRevert
: A flag indicating whether to call the `...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~131-~131: Loose punctuation mark.
Context: ...he revertAddress
. - abortAddress
: The address to receive funds on ZetaCha...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~133-~133: Loose punctuation mark.
Context: ...t currently used). - revertMessage
: Context passed to the onRevert
functi...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~134-~134: Loose punctuation mark.
Context: ...vert function. - **
onRevertGasLimit**: Gas limit for executing the
onRevert` ...
(UNLIKELY_OPENING_PUNCTUATION)
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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
🧹 Outside diff range and nitpick comments (2)
src/pages/developers/chains/evm.mdx (2)
21-28
: Add gas estimation guidance for cross-chain transactions.The documentation should include information about gas estimation for cross-chain transactions, as they may require different gas amounts than regular transactions.
The `deposit` function is payable, meaning it accepts native gas tokens (e.g., -ETH on Ethereum), which will then be sent to a `receiver` on ZetaChain. +ETH on Ethereum), which will then be sent to a `receiver` on ZetaChain. Note +that cross-chain transactions may require more gas than regular transactions +due to the additional overhead of cross-chain message processing.🧰 Tools
🪛 LanguageTool
[uncategorized] ~24-~24: Although a hyphen is possible, it is not necessary in a compound modifier in which the first word is an adverb that ends in ‘ly’.
Context: ...Chain. Thereceiver
can be either an externally-owned account (EOA) or a universal app addres...(HYPHENATED_LY_ADVERB_ADJECTIVE)
108-109
: Add context for single asset limitation.Consider explaining why this limitation exists and if there are any workarounds for cases where multiple assets need to be transferred.
In the current version of the protocol, only one ERC-20 asset can be deposited -at a time. +at a time. For scenarios requiring multiple asset transfers, consider using +separate transactions or implementing a batching mechanism at the application level.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
src/pages/developers/chains/evm.mdx
(2 hunks)
🧰 Additional context used
🪛 LanguageTool
src/pages/developers/chains/evm.mdx
[style] ~8-~8: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...RC-20 tokens (including ZETA tokens). - Depositing gas tokens and calling a universal app....
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~9-~9: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...s tokens and calling a universal app. - Depositing supported ERC-20 tokens and calling a u...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[uncategorized] ~24-~24: Although a hyphen is possible, it is not necessary in a compound modifier in which the first word is an adverb that ends in ‘ly’.
Context: ...Chain. The receiver
can be either an externally-owned account (EOA) or a universal app addres...
(HYPHENATED_LY_ADVERB_ADJECTIVE)
[uncategorized] ~82-~82: Loose punctuation mark.
Context: ... parameters are as follows: - message
: the value of the payload
. - amount
:...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~83-~83: Loose punctuation mark.
Context: ...: the value of the payload
. - amount
: the amount of deposited tokens. - `zrc2...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~84-~84: Loose punctuation mark.
Context: ...he amount of deposited tokens. - zrc20
: the ZRC-20 address of the deposited tok...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~86-~86: Loose punctuation mark.
Context: ...ct address of ZRC-20 ETH). - context
: - context.sender
: the sender addres...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~89-~89: Loose punctuation mark.
Context: ...lled the Gateway). - context.chainID
: the chain ID of the connected chain fro...
(UNLIKELY_OPENING_PUNCTUATION)
🔇 Additional comments (4)
src/pages/developers/chains/evm.mdx (4)
1-10
: LGTM! Clear and well-structured introduction.
The introduction effectively outlines the gateway's capabilities with a clean, bulleted format.
🧰 Tools
🪛 LanguageTool
[style] ~8-~8: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...RC-20 tokens (including ZETA tokens). - Depositing gas tokens and calling a universal app....
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~9-~9: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...s tokens and calling a universal app. - Depositing supported ERC-20 tokens and calling a u...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
46-47
: Add prerequisite information about token approval.
Referencing previous review comment about adding token approval information, which is still applicable.
122-127
: LGTM! Clear explanation of revert handling limitations.
The updated explanation effectively communicates the limitations and provides clear guidance on using depositAndCall
as an alternative.
131-132
: LGTM! Good cross-reference to detailed documentation.
The link to additional documentation about revert transactions is helpful and appropriate.
@bbbeeeee @brewmaster012 @zeta-chain/fullstack please, review. |
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.
Left a small comment about pointing to main
Co-authored-by: Guillermo Maiolo <[email protected]>
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 and nitpick comments (5)
src/pages/developers/tutorials/hello.mdx (5)
1-2
: Improve grammar in the introductionConsider adding a comma after the introductory clause for better readability.
-In this tutorial you will create a simple universal app deployed on ZetaChain, +In this tutorial, you will create a simple universal app deployed on ZetaChain,🧰 Tools
🪛 LanguageTool
[typographical] ~1-~1: It appears that a comma is missing.
Context: In this tutorial you will create a simple universal app ...(DURING_THAT_TIME_COMMA)
39-43
: Add NatSpec documentation and enhance event structureConsider adding NatSpec documentation and improving the event structure to include more context.
+/// @title Universal Contract Example +/// @notice A simple universal contract that emits events when called from connected chains +/// @dev Inherits from UniversalContract interface contract Universal is UniversalContract { GatewayZEVM public immutable gateway; - event HelloEvent(string, string); + event HelloEvent( + address indexed sender, + uint256 indexed chainId, + string prefix, + string name + );
Line range hint
53-60
: Add input validation and enhance event emissionThe
onCall
function should validate the input message and include more context in the event.function onCall( MessageContext calldata context, address zrc20, uint256 amount, bytes calldata message ) external override onlyGateway { + require(message.length > 0, "Empty message"); string memory name = abi.decode(message, (string)); - emit HelloEvent("Hello: ", name); + emit HelloEvent(context.sender, context.chainID, "Hello: ", name); }🧰 Tools
🪛 LanguageTool
[uncategorized] ~74-~74: Loose punctuation mark.
Context: ...oming data, which includes: -context
: AMessageContext
struct containing: ...(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~77-~77: Loose punctuation mark.
Context: ...-chain call originated. -sender
: The address (EOA or contract) that init...(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~79-~79: Loose punctuation mark.
Context: ...on the connected chain. -origin
: deprecated. -zrc20
: The address of t...(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~80-~80: Loose punctuation mark.
Context: ...ain. -origin
: deprecated. -zrc20
: The address of the ZRC-20 token represe...(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~82-~82: Loose punctuation mark.
Context: ...sset from the source chain. -amount
: The number of tokens transferred. - `me...(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~83-~83: Loose punctuation mark.
Context: ...umber of tokens transferred. -message
: The encoded data payload. In this exam...(UNLIKELY_OPENING_PUNCTUATION)
[style] ~88-~88: To form a complete sentence, be sure to include a subject.
Context: ... variable and emits an event.onCall
should only be called by the Gateway to ensure...(MISSING_IT_THERE)
92-155
: Enhance deployment documentation with prerequisites and troubleshootingConsider adding:
- Minimum required token amounts for deployment
- Common error scenarios and their solutions
- Gas estimation guidelines
Would you like me to help generate the additional documentation sections?
158-178
: Enhance testing documentation with verification stepsThe testing section should include:
- How to verify successful transaction completion
- How to interpret the event logs
- Expected response formats from the API endpoint
Would you like me to help generate the additional verification steps?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
⛔ Files ignored due to path filters (1)
public/img/docs/tutorials-nft.png
is excluded by!**/*.png
📒 Files selected for processing (2)
src/pages/developers/tutorials/hello.mdx
(3 hunks)src/pages/developers/tutorials/nft.mdx
(10 hunks)
🧰 Additional context used
🪛 LanguageTool
src/pages/developers/tutorials/hello.mdx
[typographical] ~1-~1: It appears that a comma is missing.
Context: In this tutorial you will create a simple universal app ...
(DURING_THAT_TIME_COMMA)
[uncategorized] ~74-~74: Loose punctuation mark.
Context: ...oming data, which includes: - context
: A MessageContext
struct containing: ...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~77-~77: Loose punctuation mark.
Context: ...-chain call originated. - sender
: The address (EOA or contract) that init...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~79-~79: Loose punctuation mark.
Context: ...on the connected chain. - origin
: deprecated. - zrc20
: The address of t...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~80-~80: Loose punctuation mark.
Context: ...ain. - origin
: deprecated. - zrc20
: The address of the ZRC-20 token represe...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~82-~82: Loose punctuation mark.
Context: ...sset from the source chain. - amount
: The number of tokens transferred. - `me...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~83-~83: Loose punctuation mark.
Context: ...umber of tokens transferred. - message
: The encoded data payload. In this exam...
(UNLIKELY_OPENING_PUNCTUATION)
[style] ~88-~88: To form a complete sentence, be sure to include a subject.
Context: ... variable and emits an event. onCall
should only be called by the Gateway to ensure...
(MISSING_IT_THERE)
🔇 Additional comments (6)
src/pages/developers/tutorials/nft.mdx (6)
57-59
: LGTM: Clear environment limitation notice.
The added alert and diagram effectively communicate the Gateway availability constraints and the system architecture.
82-82
: LGTM: Enhanced ownership security.
The upgrade from Ownable
to Ownable2Step
improves security by requiring a two-step process for ownership transfers.
Also applies to: 95-95
227-235
:
Protect against potential reentrancy in onCall.
The token swap and subsequent operations should follow the checks-effects-interactions pattern.
+ uint256 swapAmount = amount;
uint256 out = SwapHelperLib.swapExactTokensForTokens(
uniswapRouter,
zrc20,
- amount,
+ swapAmount,
destination,
0
);
Likely invalid or redundant comment.
500-503
:
Protect against reentrancy in gas token transfer.
The gas token transfer should follow the checks-effects-interactions pattern.
if (gasAmount > 0) {
+ uint256 amountToSend = gasAmount;
+ gasAmount = 0;
- (bool success, ) = sender.call{value: gasAmount}("");
+ (bool success, ) = sender.call{value: amountToSend}("");
if (!success) revert GasTokenTransferFailed();
}
Likely invalid or redundant comment.
130-133
: 🛠️ Refactor suggestion
Enhance gas limit validation.
The current gas limit validation only checks for non-zero values. Consider adding an upper bound check to prevent excessive gas consumption.
- if (gas == 0) revert InvalidGasLimit();
+ if (gas == 0 || gas > 1_000_000) revert InvalidGasLimit();
gateway = GatewayZEVM(gatewayAddress);
uniswapRouter = uniswapRouterAddress;
gasLimit = gas;
Likely invalid or redundant comment.
691-691
: Verify gateway address for deployment commands.
The hardcoded gateway address should be verified for security. Let's check if this is the correct address for the testnet.
✅ Verification successful
Gateway address for zeta_testnet deployment is consistent across tutorials
The gateway address 0x6c533f7fe93fae114d0954697069df33c9b74fd7
is consistently used across multiple tutorial files (nft.mdx, call.mdx, swap.mdx, hello.mdx) specifically for the zeta_testnet network. This consistency, along with the presence of gateway-related contract interfaces and administrative update mechanisms in the codebase, suggests this is the correct production gateway address for the testnet environment.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify gateway address matches network
NETWORK="zeta_testnet"
GATEWAY="0x6c533f7fe93fae114d0954697069df33c9b74fd7"
# Search for gateway address references
rg -l "gateway.*$GATEWAY"
# Look for any network configuration or validation logic
rg -i "network.*gateway|gateway.*network" src/pages/developers/
Length of output: 2081
Script:
#!/bin/bash
# Let's verify if there's any documentation or configuration files that validate these gateway addresses
fd -e md -e mdx -e json -e yaml -e yml | xargs rg "0x6c533f7fe93fae114d0954697069df33c9b74fd7.*testnet|testnet.*0x6c533f7fe93fae114d0954697069df33c9b74fd7"
# Also check for any network configuration files
fd "hardhat.config|network.config" | xargs cat
# Look for any gateway address validation or configuration patterns
rg -A 3 "gateway.*address|GATEWAY.*ADDRESS"
Length of output: 5221
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: 2
🧹 Outside diff range and nitpick comments (13)
src/pages/developers/tutorials/hello.mdx (5)
1-2
: Improve clarity and grammar in the introductionThe introduction needs grammatical fixes and clarity improvements.
-In this tutorial you will create a simple universal app deployed on ZetaChain, -which emits when called from a connected chain. +In this tutorial, you will create a simple universal app deployed on ZetaChain +that emits events when called from a connected chain.🧰 Tools
🪛 LanguageTool
[typographical] ~1-~1: It appears that a comma is missing.
Context: In this tutorial you will create a simple universal app ...(DURING_THAT_TIME_COMMA)
42-42
: Enhance event structure for better observabilityThe
HelloEvent
could be more informative by including additional context.-event HelloEvent(string, string); +event HelloEvent(uint256 indexed chainID, address indexed sender, string message); -emit HelloEvent("Hello: ", name); +emit HelloEvent(context.chainID, context.sender, name);Also applies to: 61-61
80-80
: Clarify deprecation noticeThe
origin
parameter is marked as deprecated without explanation.Consider adding a brief explanation of why it's deprecated and what to use instead.
🧰 Tools
🪛 LanguageTool
[uncategorized] ~80-~80: Loose punctuation mark.
Context: ...on the connected chain. -origin
: deprecated. -zrc20
: The address of t...(UNLIKELY_OPENING_PUNCTUATION)
149-156
: Add contract verification stepsThe deployment instructions should include steps to verify the contract on the blockchain explorer.
Consider adding:
- Instructions for verifying the contract source code
- Steps to validate the constructor arguments (Gateway address)
- Links to relevant block explorers
177-179
: Enhance transaction tracking guidanceThe transaction tracking section could be more robust.
Consider adding:
- Alternative methods to track transactions
- Common error scenarios and troubleshooting steps
- Expected response format from the API
- Timeout and retry recommendations for cross-chain transactions
src/pages/developers/tutorials/swap-any.mdx (3)
76-79
: Consider adding initialization eventWhile the constructor correctly validates addresses, consider adding an initialization event for better transparency and off-chain tracking.
+ event ContractInitialized(address indexed gateway, address indexed router); constructor(address payable gatewayAddress, address uniswapRouterAddress) { if (gatewayAddress == address(0) || uniswapRouterAddress == address(0)) revert InvalidAddress(); uniswapRouter = uniswapRouterAddress; gateway = GatewayZEVM(gatewayAddress); + emit ContractInitialized(gatewayAddress, uniswapRouterAddress); }
Line range hint
148-152
: Add slippage protection and deadline checksThe swap operations lack crucial safety measures:
- Minimum output amount is hardcoded to 0, which makes the transaction vulnerable to sandwich attacks
- Missing deadline parameter could lead to pending transactions being executed at unfavorable prices
uint256 outputAmount = SwapHelperLib.swapExactTokensForTokens( uniswapRouter, inputToken, swapAmount, targetToken, - 0 + minOutputAmount, // Add parameter for minimum output + block.timestamp + 300 // Add 5-minute deadline );Also applies to: 159-162
208-210
: Consider adding revert eventThe empty
onRevert
function should emit an event for better observability of failed cross-chain transactions.+ event CrossChainRevert(bytes32 indexed txHash, address indexed sourceAddress, uint256 sourceChainId); function onRevert( RevertContext calldata revertContext ) external onlyGateway { + emit CrossChainRevert(revertContext.txHash, revertContext.sourceAddress, revertContext.sourceChainId); }src/pages/developers/tutorials/swap.mdx (2)
93-96
: Consider optimizing the address validation.The current implementation uses two separate checks. Consider combining them for gas efficiency.
-if (gatewayAddress == address(0) || uniswapRouterAddress == address(0)) +if ((uint160(gatewayAddress) | uint160(uniswapRouterAddress)) == 0) revert InvalidAddress();
184-186
: Document the empty implementation.Consider adding a comment explaining why the
onRevert
function is intentionally left empty.+ /// @notice This function is required by the UniversalContract interface but has no implementation + /// as this contract doesn't need to handle revert scenarios function onRevert( RevertContext calldata revertContext ) external onlyGateway {}src/pages/developers/tutorials/call.mdx (3)
70-85
: Consider extracting common token transfer and approval logicThe token transfer and approval logic is duplicated across
call
,withdraw
, andwithdrawAndCall
functions. Consider extracting this into a private helper function to improve maintainability and reduce the risk of inconsistencies.+ function _handleTokenTransfer( + address token, + uint256 amount, + address sender + ) private { + if (!IZRC20(token).transferFrom(sender, address(this), amount)) + revert TransferFailed(); + IZRC20(token).approve(address(gateway), amount); + }Also applies to: 114-148
233-235
: Fix grammar in commentsThe word "withdraw" is incorrectly used as a noun in these comments. It should be "withdrawal".
-tokens to pay the withdraw fee. In a +tokens to pay the withdrawal fee. In a -withdrawn to cover the withdraw fee. +withdrawn to cover the withdrawal fee.🧰 Tools
🪛 LanguageTool
[grammar] ~233-~233: The word ‘withdraw’ is not a noun. Did you mean “withdrawal”?
Context: ... amount of gas ZRC-20 tokens to pay the withdraw fee. In a production-ready contract the...(PREPOSITION_VERB)
[grammar] ~235-~235: The word ‘withdraw’ is not a noun. Did you mean “withdrawal”?
Context: ... the token being withdrawn to cover the withdraw fee. ### Withdrawing Tokens and Making...(PREPOSITION_VERB)
87-112
: Optimize token approvalsThe function makes separate approve calls for tokens and gas fees. Consider combining these into a single approval when possible to save gas.
- IZRC20(zrc20).approve(address(gateway), target); - if (zrc20 != gasZRC20) { - if ( - !IZRC20(gasZRC20).transferFrom( - msg.sender, - address(this), - gasFee - ) - ) { - revert TransferFailed(); - } - IZRC20(gasZRC20).approve(address(gateway), gasFee); - } + uint256 totalApproval = target; + if (zrc20 != gasZRC20) { + if (!IZRC20(gasZRC20).transferFrom(msg.sender, address(this), gasFee)) { + revert TransferFailed(); + } + IZRC20(gasZRC20).approve(address(gateway), gasFee); + } else { + totalApproval = target + gasFee; + } + IZRC20(zrc20).approve(address(gateway), totalApproval);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (5)
src/pages/developers/tutorials/call.mdx
(1 hunks)src/pages/developers/tutorials/hello.mdx
(3 hunks)src/pages/developers/tutorials/nft.mdx
(9 hunks)src/pages/developers/tutorials/swap-any.mdx
(5 hunks)src/pages/developers/tutorials/swap.mdx
(5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/pages/developers/tutorials/nft.mdx
🧰 Additional context used
🪛 LanguageTool
src/pages/developers/tutorials/call.mdx
[grammar] ~233-~233: The word ‘withdraw’ is not a noun. Did you mean “withdrawal”?
Context: ... amount of gas ZRC-20 tokens to pay the withdraw fee. In a production-ready contract the...
(PREPOSITION_VERB)
[grammar] ~235-~235: The word ‘withdraw’ is not a noun. Did you mean “withdrawal”?
Context: ... the token being withdrawn to cover the withdraw fee. ### Withdrawing Tokens and Making...
(PREPOSITION_VERB)
src/pages/developers/tutorials/hello.mdx
[typographical] ~1-~1: It appears that a comma is missing.
Context: In this tutorial you will create a simple universal app ...
(DURING_THAT_TIME_COMMA)
[uncategorized] ~75-~75: Loose punctuation mark.
Context: ...oming data, which includes: - context
: A MessageContext
struct containing: ...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~78-~78: Loose punctuation mark.
Context: ...-chain call originated. - sender
: The address (EOA or contract) that init...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~80-~80: Loose punctuation mark.
Context: ...on the connected chain. - origin
: deprecated. - zrc20
: The address of t...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~81-~81: Loose punctuation mark.
Context: ...ain. - origin
: deprecated. - zrc20
: The address of the ZRC-20 token represe...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~83-~83: Loose punctuation mark.
Context: ...sset from the source chain. - amount
: The number of tokens transferred. - `me...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~84-~84: Loose punctuation mark.
Context: ...umber of tokens transferred. - message
: The encoded data payload. In this exam...
(UNLIKELY_OPENING_PUNCTUATION)
[style] ~89-~89: To form a complete sentence, be sure to include a subject.
Context: ... variable and emits an event. onCall
should only be called by the Gateway to ensure...
(MISSING_IT_THERE)
🔇 Additional comments (6)
src/pages/developers/tutorials/swap-any.mdx (2)
64-64
: Well-structured security implementation!
The implementation shows good practices:
- Use of
immutable
for gas optimization - Custom errors for better error handling
- Proper access control with
onlyGateway
modifier
Also applies to: 68-74
94-94
: Excellent security enhancement!
The addition of onlyGateway
modifier is crucial for preventing unauthorized access to the onCall
function.
src/pages/developers/tutorials/swap.mdx (3)
81-91
: LGTM! Well-structured state variables and access control.
The implementation follows best practices:
- Using
immutable
for the router address optimizes gas usage - The
onlyGateway
modifier provides proper access control - Custom errors are well-defined and specific
110-110
: LGTM! Enhanced security with access control.
The addition of the onlyGateway
modifier ensures that only the gateway contract can trigger cross-chain swaps.
Line range hint 146-159
: Verify swap paths coverage.
The swap implementation looks correct, but let's verify that all possible token swap paths are properly handled.
✅ Verification successful
Swap paths implementation verified successfully
Based on the analysis of the swap implementations in both swap.mdx
and swap-any.mdx
, the swap paths are properly handled through:
- Direct token-to-token swaps using
SwapHelperLib.swapExactTokensForTokens
- Gas fee token swaps using
SwapHelperLib.swapTokensForExactTokens
- Proper amount calculations for both main swap and gas fee swap paths
The implementation correctly handles:
- Gas token path: input token → gas token
- Main swap path: input token → target token
- Appropriate amount adjustments for both paths
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for all possible swap paths in the codebase
# Look for test cases covering different swap scenarios
# Search for test files
fd -e sol -e js -e ts "test|spec" | while read -r file; do
echo "=== Analyzing $file ==="
# Look for test cases covering different swap paths
rg -A 5 "swapTokensForExactTokens|swapExactTokensForTokens" "$file"
done
Length of output: 50
Script:
#!/bin/bash
# Let's try a different approach to analyze swap implementations and test coverage
# First, let's find all files containing swap-related code
echo "=== Files with swap implementations ==="
rg -l "swapExactTokensForTokens|swapTokensForExactTokens|SwapHelperLib"
# Then, let's examine the SwapHelperLib implementation
echo -e "\n=== SwapHelperLib implementation ==="
ast-grep --pattern 'library SwapHelperLib {
$$$
}'
# Look for swap function implementations
echo -e "\n=== Swap function implementations ==="
rg -A 10 "function.*swap.*\("
# Check for swap-related interfaces
echo -e "\n=== Swap interfaces ==="
ast-grep --pattern 'interface $_ {
$$$
function swap$_($$$) $$$;
$$$
}'
Length of output: 5842
Script:
#!/bin/bash
# Let's examine the SwapHelperLib implementation and swap paths in the tutorial files
# Check SwapHelperLib implementation in swap.mdx
echo "=== SwapHelperLib in swap.mdx ==="
rg -A 15 "library SwapHelperLib" "src/pages/developers/tutorials/swap.mdx"
# Check SwapHelperLib implementation in swap-any.mdx
echo -e "\n=== SwapHelperLib in swap-any.mdx ==="
rg -A 15 "library SwapHelperLib" "src/pages/developers/tutorials/swap-any.mdx"
# Look for actual swap path implementations
echo -e "\n=== Swap path implementations ==="
rg -A 10 "swapExactTokensForTokens.*\(" "src/pages/developers/tutorials/swap*.mdx"
# Check for path array constructions
echo -e "\n=== Swap path constructions ==="
rg -B 5 -A 5 "path.*\[.*\].*swap" "src/pages/developers/tutorials/swap*.mdx"
Length of output: 809
Script:
#!/bin/bash
# Let's try a more precise approach to examine the swap implementations
# Check the specific swap implementation in swap.mdx
echo "=== Swap implementation in swap.mdx ==="
rg -B 10 -A 20 "SwapHelperLib\.swapExactTokensForTokens" "src/pages/developers/tutorials/swap.mdx"
# Check the specific swap implementation in swap-any.mdx
echo -e "\n=== Swap implementation in swap-any.mdx ==="
rg -B 10 -A 20 "SwapHelperLib\.swapExactTokensForTokens" "src/pages/developers/tutorials/swap-any.mdx"
# Look for any router interface or implementation
echo -e "\n=== Router interface/implementation ==="
rg -A 10 "interface.*Router|contract.*Router"
# Check for any path calculations or array constructions
echo -e "\n=== Path calculations ==="
rg -B 5 -A 5 "path.*=.*\[|getAmountsOut|getAmountsIn" "src/pages/developers/tutorials/swap.mdx" "src/pages/developers/tutorials/swap-any.mdx"
Length of output: 11737
src/pages/developers/tutorials/call.mdx (1)
7-550
: Documentation is comprehensive and well-structured
The tutorial provides clear explanations, examples, and deployment instructions for both localnet and testnet environments.
🧰 Tools
🪛 LanguageTool
[grammar] ~233-~233: The word ‘withdraw’ is not a noun. Did you mean “withdrawal”?
Context: ... amount of gas ZRC-20 tokens to pay the withdraw fee. In a production-ready contract the...
(PREPOSITION_VERB)
[grammar] ~235-~235: The word ‘withdraw’ is not a noun. Did you mean “withdrawal”?
Context: ... the token being withdrawn to cover the withdraw fee. ### Withdrawing Tokens and Making...
(PREPOSITION_VERB)
Updated tutorials to match examples in zeta-chain/example-contracts#218
Summary by CodeRabbit
Release Notes
New Features
Bug Fixes
Documentation