Skip to content
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

Ton Gateway #588

Merged
merged 10 commits into from
Mar 28, 2025
Merged

Ton Gateway #588

merged 10 commits into from
Mar 28, 2025

Conversation

fadeev
Copy link
Member

@fadeev fadeev commented Mar 24, 2025

First iteration, just to have some docs. Going to be updating it in follow up PRs with additional info.

Summary by CodeRabbit

  • New Features

    • Introduced support for a new blockchain option, enabling deposits and app interactions via TON.
  • Documentation

    • Updated blockchain descriptions for improved clarity, including changes to the Solana entry.
    • Added new documentation for the TON gateway, detailing operations for depositing and withdrawing TON, as well as calling universal applications.

@fadeev fadeev requested review from a team as code owners March 24, 2025 17:14
Copy link

vercel bot commented Mar 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 Mar 28, 2025 7:47am

Copy link
Contributor

coderabbitai bot commented Mar 24, 2025

📝 Walkthrough

Walkthrough

This pull request updates the chain metadata and developer documentation. The metadata JSON modifies the "solana" description by removing the specific mention of "tokens" and adds a new "ton" entry. The documentation for the evm chain is reformatted for clarity, while a new document for the TON gateway is introduced, detailing operations for depositing, depositing-and-calling, and withdrawing TON, including their message structures and gas fee details.

Changes

File(s) Change Summary
…/chains/_meta.json Updated the "solana" entry description (removed specific mention of "tokens") and added a new "ton" entry with its title and description.
…/chains/evm.mdx
…/chains/ton.mdx
In evm.mdx, consolidated text regarding call function revert handling for improved clarity. In ton.mdx, added a new documentation file outlining TON gateway operations, including deposit, deposit-and-call flows, and gas fee details.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant TG as TON Gateway
    participant GC as Gateway Contract
    participant UA as Universal App

    %% Flow for deposit TON operation
    U->>TG: Request deposit TON (op_code=101)
    TG->>GC: Send deposit message (query_id, evm_recipient)
    GC-->>TG: Confirm deposit (mint ZRC-20 TON)
    TG-->>U: Return deposit confirmation

    %% Flow for deposit and call operation
    U->>TG: Request deposit & call (op_code=102, call_data)
    TG->>GC: Send deposit & call message
    GC->>UA: Trigger onCall() with call_data
    UA-->>GC: Process onCall result
    GC-->>TG: Confirm deposit & call
    TG-->>U: Return deposit & call confirmation
Loading

Possibly related PRs

  • State of ZetaChain Functionality table #516: The changes in the main PR, which involve updates to the "solana" entry and the addition of a new "ton" entry in the _meta.json file, are related to the modifications in the retrieved PR that also involve changes to the same _meta.json file, specifically adding a new "functionality" section.
  • Sui Gateway page #585: The changes in the main PR, which involve updates to the "solana" entry and the addition of a "ton" entry in the _meta.json file, are related to the modifications in the retrieved PR that also updates the "solana" entry and adds a "sui" entry in the same file.
  • Gateway: Interacting with Universal Apps #433: The changes in the main PR, which involve updating the "solana" entry and adding a new "ton" entry in the JSON metadata, are related to the modifications in the retrieved PR that also includes updates to the metadata for various blockchain networks, including Solana. Both PRs focus on enhancing the metadata structure for blockchain interactions.

Suggested reviewers

  • hernan-clich
  • bbbeeeee

📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0709f96 and db05ff1.

📒 Files selected for processing (1)
  • src/pages/developers/chains/_meta.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/pages/developers/chains/_meta.json
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build

🪧 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 plan to trigger planning for file edits and PR creation.
  • @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
Copy link
Member Author

fadeev commented Mar 24, 2025

@swift1337 please, take a look and lmk if this is technically accurate. Thanks!

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 (5)
src/pages/developers/chains/evm.mdx (1)

124-127: Clarify Revert Handling Explanation

The updated text for the call function’s revert handling is clear, but you might consider rewording it slightly for enhanced clarity. For example, you could consolidate the explanation into a single sentence that emphasizes that the function fails due to the lack of token transfer for covering gas fees upon revert.

-is because executing a contract call on revert requires tokens to cover gas fees
-on ZetaChain, and the `call` function doesn't transfer any assets. If you need
-to handle reverts, use `depositAndCall` instead and ensure sufficient tokens are
-deposited to cover potential gas fees.
+because executing a contract call after a revert requires tokens to cover gas fees on ZetaChain—which the `call` function does not transfer—the transaction will fail. If you need to handle reverts, please use `depositAndCall` instead and ensure that enough tokens are deposited to cover the potential gas fees.
src/pages/developers/chains/ton.mdx (4)

9-28: Deposit TON Section – Message Structure Clarity

The "Deposit TON" section is well structured and clearly outlines the required internal message format with a custom fc code block. Consider adding a brief note (or a link) to explain the notation used in the code block if it isn’t common knowledge among your readers.

🧰 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: ...he deposited TON. This can be either an externally-owned account (EOA) or a universal app addres...

(HYPHENATED_LY_ADVERB_ADJECTIVE)


29-51: Deposit TON and Call – Operation Guidance

This section accurately details the structure for deposit-and-call operations, including the role of call_data for invoking the onCall function. For further clarity, a short explanation of what contents might be expected in call_data (or a reference to more detailed documentation) could be beneficial.


52-63: Gas Fees Explanation

The gas fees for various operations are clearly listed, which helps users understand the cost implications. As gas fee values can evolve over time, consider referencing a dynamic source or a version note to ensure users can verify the current fees if needed.


23-25: Minor Style Note on Compound Modifiers

A static analysis hint mentioned compound modifiers with adverbs ending in “ly”. While the phrase “externally-owned account (EOA)” is standard, please double-check that no unnecessary hyphenation appears in adjacent or similar phrases. The current usage appears acceptable, but a quick review could prevent future stylistic inconsistencies.

🧰 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: ...he deposited TON. This can be either an externally-owned account (EOA) or a universal app addres...

(HYPHENATED_LY_ADVERB_ADJECTIVE)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7a0c695 and 2bdc8a6.

📒 Files selected for processing (3)
  • src/pages/developers/chains/_meta.json (1 hunks)
  • src/pages/developers/chains/evm.mdx (1 hunks)
  • src/pages/developers/chains/ton.mdx (1 hunks)
🧰 Additional context used
🪛 LanguageTool
src/pages/developers/chains/ton.mdx

[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: ...he deposited TON. This can be either an externally-owned account (EOA) or a universal app addres...

(HYPHENATED_LY_ADVERB_ADJECTIVE)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (2)
src/pages/developers/chains/_meta.json (1)

19-25: Verify Metadata Consistency for Chain Entries

The updated description for the Solana entry and the new Ton entry are correctly formatted and consistent with the overall style of the metadata file. Ensure that the phrasing matches other entries in similar sections for uniformity (for example, check if “deposit from” is intentionally generic compared to “deposit BTC from Bitcoin”).

src/pages/developers/chains/ton.mdx (1)

1-8: Introduction and Supported Operations

The introductory section clearly explains that TON users should leverage the TON gateway to interact with universal applications. The list of supported operations is concise and matches the style of analogous documentation.

@fadeev fadeev linked an issue Mar 24, 2025 that may be closed by this pull request
Co-authored-by: Dmitry S <11892559+swift1337@users.noreply.github.com>
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 (5)
src/pages/developers/chains/ton.mdx (5)

14-20: Deposit Message Structure Detail
The code block using the func identifier precisely defines the message format for TON deposits. It would be helpful to explicitly mention that the query_id field is reserved for future use and should be set to 0 by default. This change would align with previous recommendations.


22-30: Deposit TON Message Clarifications
This section correctly specifies that op_code must be 101 and explains the role of evm_recipient. Consider adding a brief note about the reserved nature of query_id (i.e., it should remain 0) to avoid any ambiguity.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~25-~25: 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: ...he deposited TON. This can be either an externally-owned account (EOA) or a universal app addres...

(HYPHENATED_LY_ADVERB_ADJECTIVE)


24-26: Terminology Consistency
Consider removing the hyphen in "externally-owned account" to adopt the more common form, "externally owned account (EOA)". This adjustment will help maintain consistency with industry-standard documentation.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~25-~25: 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: ...he deposited TON. This can be either an externally-owned account (EOA) or a universal app addres...

(HYPHENATED_LY_ADVERB_ADJECTIVE)


31-35: Deposit and Call Section Overview
The section introducing deposit-and-call operations is clear and informative. For consistency with the deposit section, reiterate that query_id is reserved (typically set to 0) and mention if there are any special conditions regarding the universal app address.


36-42: Deposit-and-Call Message Structure Enhancements
The code block using the fc language label accurately outlines the message structure for deposit-and-call operations. To further enhance clarity, consider noting that:

  • The query_id field should be set to 0 by default.
  • The call_data cell must be encoded using TON’s "snake data" format (see TON guidelines for reference).
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2bdc8a6 and 008b04a.

📒 Files selected for processing (1)
  • src/pages/developers/chains/ton.mdx (1 hunks)
🧰 Additional context used
🪛 LanguageTool
src/pages/developers/chains/ton.mdx

[uncategorized] ~25-~25: 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: ...he deposited TON. This can be either an externally-owned account (EOA) or a universal app addres...

(HYPHENATED_LY_ADVERB_ADJECTIVE)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (5)
src/pages/developers/chains/ton.mdx (5)

1-2: Introduction Clarity and Context
The opening line clearly introduces the TON gateway concept. For enhanced clarity, consider adding a brief note or link to further technical documentation if available.


3-8: Supported Operations Listing
The bulleted list neatly summarizes the supported operations for the TON gateway. Ensure that the terminology (e.g., "universal app" and "account") is consistently used across all documentation pages.


9-13: Deposit TON Section Introduction
The header and introductory text provide a clear description of the deposit process. You might consider including a note about any prerequisites or assumptions (e.g., default network settings) if relevant to users.


44-52: Deposit-and-Call Operation Details
The explanatory text following the code block clearly defines the purpose of each field. For added value, consider providing a short example snippet or a link to an external resource that demonstrates the encoding of call_data in practice.


54-65: Gas Fees Section
The gas fee breakdown is informative and straightforward. Ensure that these values remain updated to reflect any changes in the underlying smart contract parameters or network conditions over time.

fadeev and others added 6 commits March 27, 2025 10:22
Co-authored-by: Dmitry S <11892559+swift1337@users.noreply.github.com>
Co-authored-by: Dmitry S <11892559+swift1337@users.noreply.github.com>
Co-authored-by: Dmitry S <11892559+swift1337@users.noreply.github.com>
@fadeev fadeev requested a review from swift1337 March 27, 2025 07:26
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 (8)
src/pages/developers/chains/ton.mdx (8)

1-3: Introduction Clarity and Context
The opening lines succinctly introduce the TON gateway and its role in interacting with universal applications. Consider expanding briefly on the context or linking to an overview for readers new to TON.


3-7: Bullet List Format
The bulleted list of supported operations is clear and easy to follow. Ensure that the formatting is consistent with other similar documentation pages.


18-19: Technical Details: op_code and query_id
The details specifying that the deposit op_code is 101 and that query_id is reserved (set to 0) are clearly stated. Emphasizing that query_id is reserved for potential future use could further clarify its non-functional role.


21-23: Clarification on evm_recipient Field
The explanation of the evm_recipient field clearly outlines its purpose. Consider revisiting the hyphenation in “externally-owned account”—the current style is acceptable, but for stylistic consistency, you might opt for “externally owned account” if that aligns with your overall documentation guidelines.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~22-~22: 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: ...he deposited TON. This can be either an externally-owned account (EOA) or a universal app addres...

(HYPHENATED_LY_ADVERB_ADJECTIVE)


25-30: TypeScript Example for Deposit Message
The provided TypeScript snippet is concise and demonstrates how to construct the deposit message. Adding inline comments, especially around the usage of beginCell() and storeUint, could enhance clarity for readers less familiar with these APIs.


35-38: Deposit-and-Call Section Overview
The header and introductory text for the deposit-and-call functionality are clear. It might be beneficial to mention any prerequisites or highlight the differences between a simple deposit and a deposit-and-call operation.


44-47: op_code and call_data Details for Deposit-and-Call
The explanation clearly states that the depositAndCall op_code is 102, and it notes that call_data must be a cell encoded in snake data format. Including a brief summary of what “snake data encoding” entails could be a helpful addition for new developers.


54-65: TypeScript Example for Deposit-and-Call Operation
The TypeScript example effectively demonstrates how to build the deposit-and-call message, including the proper use of storeRef for the payload. Consider inserting inline commentary (e.g., a note after storeRef) for extra clarity on handling the cell payload.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 008b04a and 0709f96.

📒 Files selected for processing (1)
  • src/pages/developers/chains/ton.mdx (1 hunks)
🧰 Additional context used
🪛 LanguageTool
src/pages/developers/chains/ton.mdx

[uncategorized] ~22-~22: 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: ...he deposited TON. This can be either an externally-owned account (EOA) or a universal app addres...

(HYPHENATED_LY_ADVERB_ADJECTIVE)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (6)
src/pages/developers/chains/ton.mdx (6)

9-13: Deposit TON Section Introduction
The header and accompanying explanation provide a clear directive on depositing TON. The instructions are concise and lead well into the detailed technical specifications.


14-16: Deposit Message Structure Example
The code snippet using the “func” notation accurately reflects the required structure for the deposit message. This matches previous style suggestions; ensure that this notation remains consistent across related documents.


32-33: Post-Deposit Outcome Explanation
The note indicating that the receiver obtains the ZRC-20 version of TON is succinct. Please verify that the ZRC-20 version link is current and directs users to the appropriate reference.


40-42: Deposit-and-Call Message Structure Example
The code snippet in “func” notation detailing the deposit-and-call message structure is accurate and complete. It neatly includes the additional call_data field, consistent with the intended functionality.


49-52: Clarification of Common Fields
The subsequent explanation on the roles of evm_recipient and call_data is precise and informative. The details provided match the expected behavior of the gateway message structure.


67-68: Concluding Execution Note
The final lines clearly communicate that the onCall function is executed after processing the cross-chain transaction. Ensure that any downstream documentation references this behavior consistently.

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.

A few comments below

@fadeev fadeev requested review from a team as code owners March 28, 2025 07:42
@fadeev fadeev merged commit ad73551 into main Mar 28, 2025
6 checks passed
@fadeev fadeev deleted the ton-docs branch March 28, 2025 08:05
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.

Ton Gateway
3 participants