From 8867b39f8f81544c479519785c5784de0e990c67 Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Thu, 20 Mar 2025 21:51:30 +0300 Subject: [PATCH] Sui Gateway page --- next-env.d.ts | 1 - src/pages/developers/chains/_meta.json | 6 +- src/pages/developers/chains/sui.mdx | 96 ++++++++++++++++++++++++++ 3 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 src/pages/developers/chains/sui.mdx diff --git a/next-env.d.ts b/next-env.d.ts index fd36f9494..4f11a03dc 100644 --- a/next-env.d.ts +++ b/next-env.d.ts @@ -1,6 +1,5 @@ /// /// -/// // NOTE: This file should not be edited // see https://nextjs.org/docs/basic-features/typescript for more information. diff --git a/src/pages/developers/chains/_meta.json b/src/pages/developers/chains/_meta.json index ac60439d8..ae84787d0 100644 --- a/src/pages/developers/chains/_meta.json +++ b/src/pages/developers/chains/_meta.json @@ -17,7 +17,11 @@ }, "solana": { "title": "Solana", - "description": "Make calls to universal apps and deposit SOL from Solana" + "description": "Make calls to universal apps and deposit tokens from Solana" + }, + "sui": { + "title": "Sui", + "description": "Make calls to universal apps and deposit tokens from Sui" }, "bitcoin": { "title": "Bitcoin", diff --git a/src/pages/developers/chains/sui.mdx b/src/pages/developers/chains/sui.mdx new file mode 100644 index 000000000..54cf5cfe1 --- /dev/null +++ b/src/pages/developers/chains/sui.mdx @@ -0,0 +1,96 @@ +# Sui Gateway + +To interact with universal applications from Sui chain, use the Sui Gateway. + +For step-by-step examples of using the Sui gateway, see the [Sui +tutorial](/developers/tutorials/sui/). + +The Sui Gateway supports: + +- Depositing native SUI and other coins to a universal app or an account on + ZetaChain +- Depositing coins and calling a universal app + +## Deposit Coins + +To deposit coins to an EOA or a universal contract on ZetaChain, use the +`deposit` function: + +```move +public entry fun deposit( + gateway: &mut Gateway, + coins: Coin, + receiver: String, + ctx: &mut TxContext, +) +``` + +The `deposit` function accepts any whitelisted coin type `T` (including native +SUI), which will be sent to the specified `receiver` on ZetaChain. + +The `receiver` parameter should be a valid EVM-style address (0x-prefixed hex +string) representing either an externally-owned account (EOA) or a universal app +address on ZetaChain. Even if the receiver is a universal app contract, the +`deposit` function will not trigger a contract call. If you want to deposit and +call a universal app, use the `deposit_and_call` function instead. + +After the deposit is processed, the receiver receives the ZRC-20 version of the +deposited token on ZetaChain. + +## Deposit Coins and Call a Universal App + +To deposit coins and call a universal app contract, use the `deposit_and_call` +function: + +```move +public entry fun deposit_and_call( + gateway: &mut Gateway, + coins: Coin, + receiver: String, + payload: vector, + ctx: &mut TxContext, +) +``` + +The `receiver` must be the address of a universal app contract on ZetaChain. The +`payload` parameter will be passed to the `onCall` function of the universal app +contract. + +The maximum payload size is 1024 bytes. The transaction will fail if the payload +exceeds this limit. + +## Administrative Functions + +The Sui Gateway includes several administrative functions that require special +capability objects: + +- `whitelist` - Enables deposits for a new coin type (requires + `WhitelistCap`) +- `withdraw` - Called by the TSS address when tokens are withdrawn from + ZetaChain to Sui. This function requires a special capability object + (`WithdrawCap`) that is only held by the TSS nodes. The `nonce` parameter + prevents replay attacks by ensuring each withdrawal is processed exactly once. +- `unwhitelist` - Disables deposits for a coin type (requires `AdminCap`) +- `pause` - Temporarily disables all deposits (requires `AdminCap`) +- `unpause` - Re-enables deposits (requires `AdminCap`) +- `issue_withdraw_and_whitelist_cap` - Rotates the TSS capabilities (requires + `AdminCap`) + +## Events + +The Gateway emits several events that can be monitored: + +- `DepositEvent` - Emitted when coins are deposited +- `DepositAndCallEvent` - Emitted when coins are deposited with a contract call +- `WithdrawEvent` - Emitted when coins are withdrawn +- `NonceIncreaseEvent` - Emitted when the withdrawal nonce is increased + +## View Functions + +The Gateway provides several read-only functions: + +- `nonce()` - Returns the current withdrawal nonce +- `vault_balance()` - Returns the balance of a specific coin type in the + gateway +- `is_whitelisted()` - Checks if a coin type is enabled for deposits +- `is_paused()` - Checks if deposits are currently paused