Skip to content

Commit

Permalink
docs: update protocol contract docs (#468)
Browse files Browse the repository at this point in the history
Co-authored-by: fadeev <[email protected]>
  • Loading branch information
github-actions[bot] and fadeev authored Sep 30, 2024
1 parent 92a3188 commit f37a376
Show file tree
Hide file tree
Showing 42 changed files with 778 additions and 85 deletions.
9 changes: 8 additions & 1 deletion src/pages/developers/architecture/protocol/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@

We are currently developing Version 2 (V2) of our smart contract architecture. This new version will significantly enhance the developer experience for building Universal Apps.

Developers can already begin testing the new interface by referring to [the V2 Localnet guide](./scripts/localnet//v2_localnet.md).
Developers can already begin testing the new interface by referring to [the V2 Localnet guide](https://github.com/zeta-chain/localnet?tab=readme-ov-file#experimenting-with-the-new-architecture).

### Install dependencies

```shell
$ yarn
$ forge soldeer update
```

### Build

Expand Down
5 changes: 5 additions & 0 deletions src/pages/developers/architecture/protocol/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
- [IGatewayEVMEvents](contracts/evm/interfaces/IGatewayEVM.sol/interface.IGatewayEVMEvents.md)
- [IGatewayEVMErrors](contracts/evm/interfaces/IGatewayEVM.sol/interface.IGatewayEVMErrors.md)
- [IGatewayEVM](contracts/evm/interfaces/IGatewayEVM.sol/interface.IGatewayEVM.md)
- [MessageContext](contracts/evm/interfaces/IGatewayEVM.sol/struct.MessageContext.md)
- [Callable](contracts/evm/interfaces/IGatewayEVM.sol/interface.Callable.md)
- [IZetaConnectorEvents](contracts/evm/interfaces/IZetaConnector.sol/interface.IZetaConnectorEvents.md)
- [IZetaNonEthNew](contracts/evm/interfaces/IZetaNonEthNew.sol/interface.IZetaNonEthNew.md)
- [ERC20Custody](contracts/evm/ERC20Custody.sol/contract.ERC20Custody.md)
Expand All @@ -21,6 +23,7 @@
- [IGatewayZEVMEvents](contracts/zevm/interfaces/IGatewayZEVM.sol/interface.IGatewayZEVMEvents.md)
- [IGatewayZEVMErrors](contracts/zevm/interfaces/IGatewayZEVM.sol/interface.IGatewayZEVMErrors.md)
- [IGatewayZEVM](contracts/zevm/interfaces/IGatewayZEVM.sol/interface.IGatewayZEVM.md)
- [CallOptions](contracts/zevm/interfaces/IGatewayZEVM.sol/struct.CallOptions.md)
- [ISystem](contracts/zevm/interfaces/ISystem.sol/interface.ISystem.md)
- [IWETH9](contracts/zevm/interfaces/IWZETA.sol/interface.IWETH9.md)
- [IZRC20](contracts/zevm/interfaces/IZRC20.sol/interface.IZRC20.md)
Expand All @@ -31,6 +34,8 @@
- [zContract](contracts/zevm/interfaces/UniversalContract.sol/interface.zContract.md)
- [UniversalContract](contracts/zevm/interfaces/UniversalContract.sol/interface.UniversalContract.md)
- [GatewayZEVM](contracts/zevm/GatewayZEVM.sol/contract.GatewayZEVM.md)
- [SystemContractErrors](contracts/zevm/SystemContract.sol/interface.SystemContractErrors.md)
- [SystemContract](contracts/zevm/SystemContract.sol/contract.SystemContract.md)
- [ZRC20Errors](contracts/zevm/ZRC20.sol/interface.ZRC20Errors.md)
- [ZRC20](contracts/zevm/ZRC20.sol/contract.ZRC20.md)
- [RevertOptions](contracts/Revert.sol/struct.RevertOptions.md)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Revertable
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/c157025a39efca61d83e5991d093a94548f342fb/contracts/Revert.sol)
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/3a274ce7bad045a879c73669586611d35509cbce/contracts/Revert.sol)

Interface for contracts that support revertable calls.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# RevertContext
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/c157025a39efca61d83e5991d093a94548f342fb/contracts/Revert.sol)
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/3a274ce7bad045a879c73669586611d35509cbce/contracts/Revert.sol)

Struct containing revert context passed to onRevert.


```solidity
struct RevertContext {
address sender;
address asset;
uint64 amount;
bytes revertMessage;
Expand All @@ -16,6 +17,7 @@ struct RevertContext {

|Name|Type|Description|
|----|----|-----------|
|`sender`|`address`|Address of account that initiated smart contract call.|
|`asset`|`address`|Address of asset, empty if it's gas token.|
|`amount`|`uint64`|Amount specified with the transaction.|
|`revertMessage`|`bytes`|Arbitrary data sent back in onRevert.|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# RevertOptions
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/c157025a39efca61d83e5991d093a94548f342fb/contracts/Revert.sol)
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/3a274ce7bad045a879c73669586611d35509cbce/contracts/Revert.sol)

Struct containing revert options

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ERC20Custody
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/c157025a39efca61d83e5991d093a94548f342fb/contracts/evm/ERC20Custody.sol)
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/3a274ce7bad045a879c73669586611d35509cbce/contracts/evm/ERC20Custody.sol)

**Inherits:**
[IERC20Custody](/contracts/evm/interfaces/IERC20Custody.sol/interface.IERC20Custody.md), ReentrancyGuard, AccessControl, Pausable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# GatewayEVM
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/c157025a39efca61d83e5991d093a94548f342fb/contracts/evm/GatewayEVM.sol)
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/3a274ce7bad045a879c73669586611d35509cbce/contracts/evm/GatewayEVM.sol)

**Inherits:**
Initializable, AccessControlUpgradeable, UUPSUpgradeable, [IGatewayEVM](/contracts/evm/interfaces/IGatewayEVM.sol/interface.IGatewayEVM.md), ReentrancyGuardUpgradeable, PausableUpgradeable
Expand Down Expand Up @@ -107,28 +107,6 @@ function _authorizeUpgrade(address newImplementation) internal override onlyRole
|`newImplementation`|`address`|Address of the new implementation.|


### _execute

*Internal function to execute a call to a destination address.*


```solidity
function _execute(address destination, bytes calldata data) internal returns (bytes memory);
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`destination`|`address`|Address to call.|
|`data`|`bytes`|Calldata to pass to the call.|

**Returns**

|Name|Type|Description|
|----|----|-----------|
|`<none>`|`bytes`|The result of the call.|


### pause

Pause contract.
Expand Down Expand Up @@ -177,13 +155,14 @@ function executeRevert(

### execute

Executes a call to a destination address without ERC20 tokens.
Executes an authenticated call to a destination address without ERC20 tokens.

*This function can only be called by the TSS address and it is payable.*


```solidity
function execute(
MessageContext calldata messageContext,
address destination,
bytes calldata data
)
Expand All @@ -196,6 +175,39 @@ function execute(
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`messageContext`|`MessageContext`|Message context containing sender.|
|`destination`|`address`|Address to call.|
|`data`|`bytes`|Calldata to pass to the call.|

**Returns**

|Name|Type|Description|
|----|----|-----------|
|`<none>`|`bytes`|The result of the call.|


### execute

Executes an arbitrary call to a destination address without ERC20 tokens.

*This function can only be called by the TSS address and it is payable.*


```solidity
function execute(
address destination,
bytes calldata data
)
external
payable
onlyRole(TSS_ROLE)
whenNotPaused
returns (bytes memory);
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`destination`|`address`|Address to call.|
Expand Down Expand Up @@ -478,3 +490,61 @@ function transferToAssetHandler(address token, uint256 amount) private;
|`amount`|`uint256`|Amount of tokens to transfer.|


### _executeArbitraryCall

*Private function to execute an arbitrary call to a destination address.*


```solidity
function _executeArbitraryCall(address destination, bytes calldata data) private returns (bytes memory);
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`destination`|`address`|Address to call.|
|`data`|`bytes`|Calldata to pass to the call.|

**Returns**

|Name|Type|Description|
|----|----|-----------|
|`<none>`|`bytes`|The result of the call.|


### _executeAuthenticatedCall

*Private function to execute an authenticated call to a destination address.*


```solidity
function _executeAuthenticatedCall(
MessageContext calldata messageContext,
address destination,
bytes calldata data
)
private
returns (bytes memory);
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`messageContext`|`MessageContext`|Message context containing sender and arbitrary call flag.|
|`destination`|`address`|Address to call.|
|`data`|`bytes`|Calldata to pass to the call.|

**Returns**

|Name|Type|Description|
|----|----|-----------|
|`<none>`|`bytes`|The result of the call.|


### revertIfOnCallOrOnRevert


```solidity
function revertIfOnCallOrOnRevert(bytes calldata data) private pure;
```

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ZetaConnectorBase
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/c157025a39efca61d83e5991d093a94548f342fb/contracts/evm/ZetaConnectorBase.sol)
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/3a274ce7bad045a879c73669586611d35509cbce/contracts/evm/ZetaConnectorBase.sol)

**Inherits:**
[IZetaConnectorEvents](/contracts/evm/interfaces/IZetaConnector.sol/interface.IZetaConnectorEvents.md), ReentrancyGuard, Pausable, AccessControl
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ZetaConnectorNative
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/c157025a39efca61d83e5991d093a94548f342fb/contracts/evm/ZetaConnectorNative.sol)
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/3a274ce7bad045a879c73669586611d35509cbce/contracts/evm/ZetaConnectorNative.sol)

**Inherits:**
[ZetaConnectorBase](/contracts/evm/ZetaConnectorBase.sol/abstract.ZetaConnectorBase.md)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ZetaConnectorNonNative
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/c157025a39efca61d83e5991d093a94548f342fb/contracts/evm/ZetaConnectorNonNative.sol)
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/3a274ce7bad045a879c73669586611d35509cbce/contracts/evm/ZetaConnectorNonNative.sol)

**Inherits:**
[ZetaConnectorBase](/contracts/evm/ZetaConnectorBase.sol/abstract.ZetaConnectorBase.md)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# IERC20Custody
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/c157025a39efca61d83e5991d093a94548f342fb/contracts/evm/interfaces/IERC20Custody.sol)
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/3a274ce7bad045a879c73669586611d35509cbce/contracts/evm/interfaces/IERC20Custody.sol)

**Inherits:**
[IERC20CustodyEvents](/contracts/evm/interfaces/IERC20Custody.sol/interface.IERC20CustodyEvents.md), [IERC20CustodyErrors](/contracts/evm/interfaces/IERC20Custody.sol/interface.IERC20CustodyErrors.md)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# IERC20CustodyErrors
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/c157025a39efca61d83e5991d093a94548f342fb/contracts/evm/interfaces/IERC20Custody.sol)
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/3a274ce7bad045a879c73669586611d35509cbce/contracts/evm/interfaces/IERC20Custody.sol)

Interface for the errors used in the ERC20 custody contract.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# IERC20CustodyEvents
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/c157025a39efca61d83e5991d093a94548f342fb/contracts/evm/interfaces/IERC20Custody.sol)
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/3a274ce7bad045a879c73669586611d35509cbce/contracts/evm/interfaces/IERC20Custody.sol)

Interface for the events emitted by the ERC20 custody contract.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Callable
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/3a274ce7bad045a879c73669586611d35509cbce/contracts/evm/interfaces/IGatewayEVM.sol)

Interface implemented by contracts receiving authenticated calls.


## Functions
### onCall


```solidity
function onCall(MessageContext calldata context, bytes calldata message) external payable returns (bytes memory);
```

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# IGatewayEVM
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/c157025a39efca61d83e5991d093a94548f342fb/contracts/evm/interfaces/IGatewayEVM.sol)
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/3a274ce7bad045a879c73669586611d35509cbce/contracts/evm/interfaces/IGatewayEVM.sol)

**Inherits:**
[IGatewayEVMErrors](/contracts/evm/interfaces/IGatewayEVM.sol/interface.IGatewayEVMErrors.md), [IGatewayEVMEvents](/contracts/evm/interfaces/IGatewayEVM.sol/interface.IGatewayEVMEvents.md)
Expand Down Expand Up @@ -73,6 +73,38 @@ function execute(address destination, bytes calldata data) external payable retu
|`<none>`|`bytes`|The result of the contract call.|


### execute

Executes a call to a destination address without ERC20 tokens.

*This function can only be called by the TSS address and it is payable.*


```solidity
function execute(
MessageContext calldata messageContext,
address destination,
bytes calldata data
)
external
payable
returns (bytes memory);
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`messageContext`|`MessageContext`|Message context containing sender and arbitrary call flag.|
|`destination`|`address`|Address to call.|
|`data`|`bytes`|Calldata to pass to the call.|

**Returns**

|Name|Type|Description|
|----|----|-----------|
|`<none>`|`bytes`|The result of the call.|


### revertWithERC20

Executes a revertable call to a contract using ERC20 tokens.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# IGatewayEVMErrors
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/c157025a39efca61d83e5991d093a94548f342fb/contracts/evm/interfaces/IGatewayEVM.sol)
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/3a274ce7bad045a879c73669586611d35509cbce/contracts/evm/interfaces/IGatewayEVM.sol)

Interface for the errors used in the GatewayEVM contract.

Expand Down Expand Up @@ -77,3 +77,19 @@ Error when trying to transfer not whitelisted token to custody.
error NotWhitelistedInCustody();
```

### NotAllowedToCallOnCall
Error when trying to call onCall method using arbitrary call.


```solidity
error NotAllowedToCallOnCall();
```

### NotAllowedToCallOnRevert
Error when trying to call onRevert method using arbitrary call.


```solidity
error NotAllowedToCallOnRevert();
```

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# IGatewayEVMEvents
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/c157025a39efca61d83e5991d093a94548f342fb/contracts/evm/interfaces/IGatewayEVM.sol)
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/3a274ce7bad045a879c73669586611d35509cbce/contracts/evm/interfaces/IGatewayEVM.sol)

Interface for the events emitted by the GatewayEVM contract.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# MessageContext
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/3a274ce7bad045a879c73669586611d35509cbce/contracts/evm/interfaces/IGatewayEVM.sol)

Message context passed to execute function.


```solidity
struct MessageContext {
address sender;
}
```

**Properties**

|Name|Type|Description|
|----|----|-----------|
|`sender`|`address`|Sender from omnichain contract.|

Loading

0 comments on commit f37a376

Please sign in to comment.