Skip to content

Conversation

@fadeev
Copy link
Member

@fadeev fadeev commented Feb 24, 2025

  • Updated addresses to match the ones in localnet
  • Added Sui commands

Summary by CodeRabbit

  • Documentation
    • Updated tutorial instructions to use the latest deployment commands with current gateway and contract addresses.
  • New Features
    • Enhanced the cross-chain swap process with an optional withdrawal feature for improved gas fee management and error handling.

@vercel
Copy link

vercel bot commented Feb 24, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
docs-v2 ✅ Ready (Inspect) Visit Preview Feb 25, 2025 0:55am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 24, 2025

📝 Walkthrough

Walkthrough

This pull request updates the tutorial documentation and the Swap contract. In the tutorials (call.mdx and hello.mdx), deployment commands and contract addresses have been updated to reflect a new gateway and consistent contract addresses for the Connected and Universal contracts. The Swap contract (swap.mdx) has been modified to include a new boolean parameter (withdraw) in the function signatures, with corresponding updates to the control flow that handles gas fee retrieval and error handling.

Changes

File(s) Change Summary
src/pages/developers/tutorials/call.mdx and src/pages/developers/tutorials/hello.mdx Updated deployment commands and contract addresses including the gateway, contract, and receiver addresses for the Connected and Universal contracts.
src/pages/developers/tutorials/swap.mdx Modified Swap contract functions: added a boolean withdraw parameter to handleGasAndSwap and swap, and updated the internal logic to account for gas fees and error handling.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant S as Swap Contract
    U->>S: swap(inputToken, amount, targetToken, recipient, withdrawFlag)
    S->>S: Evaluate handleGasAndSwap(inputToken, amount, targetToken, withdrawFlag)
    alt withdraw is true
        S->>S: Retrieve gas fee and adjust swapAmount
    else
        S->>S: Process swap without fee adjustment
    end
    U->>S: onRevert triggers handleGasAndSwap(withdraw=true)
Loading

Possibly related PRs

Suggested reviewers

  • hernan-clich
  • brewmaster012
  • bbbeeeee

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@fadeev fadeev changed the title Update localnet docs: add Sui commands Feb 27, 2025
@fadeev
Copy link
Member Author

fadeev commented Feb 27, 2025

@hernan-clich please, review.

@fadeev fadeev marked this pull request as ready for review February 27, 2025 14:15
@fadeev fadeev requested review from a team as code owners February 27, 2025 14:15
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

🧹 Nitpick comments (2)
src/pages/developers/tutorials/swap.mdx (2)

253-275: Refined Gas Fee and Swap Logic
The internal logic of handleGasAndSwap has been updated to conditionally calculate the gas fee and adjust the swap amount based on the withdraw flag. This enhancement ensures that sufficient tokens are reserved to cover gas fees when a withdrawal is intended. Consider adding inline comments or emitting events to facilitate debugging of these computations in a live environment.


667-677: Introduction of SUI-Specific Commands for Solana
New commands for “Swapping SUI for Solana SOL” have been added. Note that the example includes a specific mnemonic (grape subway rack mean march bubble carry avoid muffin consider thing street). Please ensure that this is clearly indicated as a test mnemonic and is not used in production. Additionally, verify that the gateway and module addresses are up-to-date and secure.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 39d3a74 and 5232360.

📒 Files selected for processing (3)
  • src/pages/developers/tutorials/call.mdx (6 hunks)
  • src/pages/developers/tutorials/hello.mdx (2 hunks)
  • src/pages/developers/tutorials/swap.mdx (10 hunks)
🔇 Additional comments (15)
src/pages/developers/tutorials/hello.mdx (2)

116-116: Updated Universal Contract Address
The output now shows the Universal contract address as 0x8198f5d8F8CfFE8f9C413d98a0A55aEB8ab9FbB7. Please ensure that this new address is consistently reflected across all related documentation and deployment scripts.


127-128: Consistent Gateway and Receiver in evm-call Command
The npx hardhat evm-call command now uses the updated gateway address (0xA51c1fc2f0D1a1b8494Ed1FE312d7C3a78Ed91C0) and receiver address (0x8198f5d8F8CfFE8f9C413d98a0A55aEB8ab9FbB7). Verify that these values correctly match the intended deployment environment and are in sync with the changes made in the other tutorials.

src/pages/developers/tutorials/call.mdx (6)

424-427: Updated Deployment Command for Connected Contract
The deployment command now uses the new gateway address (0xA51c1fc2f0D1a1b8494Ed1FE312d7C3a78Ed91C0) for the Connected contract. Confirm that this change aligns with the updated infrastructure and that any references in auxiliary documentation or scripts are updated accordingly.


435-436: Revised Universal Contract Deployment Output
The Universal contract’s output now reflects the updated address 0x8198f5d8F8CfFE8f9C413d98a0A55aEB8ab9FbB7. This change is consistent with the modifications made in the hello.mdx file.


439-441: Updated Connected Contract Deployment Output
The Connected contract now deploys with the address 0x0355B7B8cb128fA5692729Ab3AAa199C1753f726. Please double-check that this new address is correctly utilized in subsequent command examples and user instructions throughout the documentation.


454-455: Consistent Address Updates in Connected-Call Command
The npx hardhat connected-call command now references the updated Connected contract address (0x0355B7B8cb128fA5692729Ab3AAa199C1753f726) and the Universal receiver address (0x8198f5d8F8CfFE8f9C413d98a0A55aEB8ab9FbB7). This ensures proper cross-chain interactions.


469-470: Consistent Address Updates in Universal-Call Command
The universal-call command has been updated to use the correct contract address (0x8198f5d8F8CfFE8f9C413d98a0A55aEB8ab9FbB7) and receiver (0x0355B7B8cb128fA5692729Ab3AAa199C1753f726). Please verify that these changes result in seamless cross-chain interactions.


484-485: Address Alignment in Withdraw-and-Call Command
The withdraw-and-call command now consistently uses the updated Universal contract address (0x8198f5d8F8CfFE8f9C413d98a0A55aEB8ab9FbB7) and the Connected contract address (0x0355B7B8cb128fA5692729Ab3AAa199C1753f726). Ensure that the command parameters align with the new deployment configuration.

src/pages/developers/tutorials/swap.mdx (7)

179-181: Updated onCall Parameter Passing in Swap Contract
In the onCall function, the call to handleGasAndSwap has been updated to pass params.target and params.withdraw correctly. This modification is critical for ensuring that the swap logic respects the new withdrawal flag. Make sure that the decoding logic continues to extract parameters correctly from the incoming message.


217-219: Consistent Parameter Update in swap Function
Within the swap function, the withdrawFlag parameter is now forwarded to handleGasAndSwap, aligning function calls with the updated signature. This ensures consistency in how the withdrawal condition is applied during the swap.


248-249: Extended handleGasAndSwap Signature
The signature of handleGasAndSwap now includes the bool withdraw parameter. This change is pivotal for distinguishing between swaps that include a withdrawal operation and those that do not.


502-507: Updated Deployment Command for Swap Contract
The deployment command now includes parameters for --gateway and --uniswap-router, ensuring that the Swap contract is configured with the correct external dependencies for liquidity and gas fee management. Verify that these addresses are correct for the testnet environment as documented.


682-686: Command for Swapping Solana SOL for SUI
The provided command illustrates how to swap Solana SOL for SUI tokens. Confirm that the flag usage (--receiver, --amount, --types, etc.) matches the CLI specification and that the command functions as intended during cross-chain operations.


695-702: Command for Swapping Solana SPL for SUI
The command for swapping Solana SPL tokens for SUI has been added. Ensure that parameters such as the mint information, sender and recipient addresses, and amounts are correctly formatted and conform to the expected input of the tool.


707-714: Command for Swapping SUI for Solana SPL
This command completes the set by enabling swaps from SUI back to Solana SPL tokens. Validate that the module and gateway addresses, as well as the boolean flag usage, are correctly implemented and that the parameters follow the CLI guidelines.

Copy link
Member

@hernan-clich hernan-clich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested ACK ✅

@fadeev fadeev merged commit 49d7ff1 into main Mar 3, 2025
6 checks passed
@fadeev fadeev deleted the update-to-sui-localnet branch March 3, 2025 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants