Skip to content

Commit

Permalink
"docs: update protocol contract docs"
Browse files Browse the repository at this point in the history
  • Loading branch information
fadeev authored Oct 18, 2024
1 parent 0775a2a commit a9d0d60
Show file tree
Hide file tree
Showing 42 changed files with 333 additions and 298 deletions.
2 changes: 2 additions & 0 deletions src/pages/developers/architecture/protocol/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@
- [CoinType](contracts/zevm/interfaces/IZRC20.sol/enum.CoinType.md)
- [zContext](contracts/zevm/interfaces/UniversalContract.sol/struct.zContext.md)
- [zContract](contracts/zevm/interfaces/UniversalContract.sol/interface.zContract.md)
- [MessageContext](contracts/zevm/interfaces/UniversalContract.sol/struct.MessageContext.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)
- [INotSupportedMethods](contracts/Errors.sol/interface.INotSupportedMethods.md)
- [RevertOptions](contracts/Revert.sol/struct.RevertOptions.md)
- [RevertContext](contracts/Revert.sol/struct.RevertContext.md)
- [Revertable](contracts/Revert.sol/interface.Revertable.md)
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# INotSupportedMethods
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/main/v2/contracts/Errors.sol)

Interface for contracts that with non supported methods.


## Errors
### ZETANotSupported

```solidity
error ZETANotSupported();
```

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Contents
- [evm](/contracts/evm)
- [zevm](/contracts/zevm)
- [INotSupportedMethods](Errors.sol/interface.INotSupportedMethods.md)
- [RevertOptions](Revert.sol/struct.RevertOptions.md)
- [RevertContext](Revert.sol/struct.RevertContext.md)
- [Revertable](Revert.sol/interface.Revertable.md)
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/3a274ce7bad045a879c73669586611d35509cbce/contracts/Revert.sol)
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/main/v2/contracts/Revert.sol)

Interface for contracts that support revertable calls.

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

Struct containing revert context passed to onRevert.

Expand All @@ -8,7 +8,7 @@ Struct containing revert context passed to onRevert.
struct RevertContext {
address sender;
address asset;
uint64 amount;
uint256 amount;
bytes revertMessage;
}
```
Expand All @@ -19,6 +19,6 @@ struct RevertContext {
|----|----|-----------|
|`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.|
|`amount`|`uint256`|Amount specified with the transaction.|
|`revertMessage`|`bytes`|Arbitrary data sent back in onRevert.|

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/3a274ce7bad045a879c73669586611d35509cbce/contracts/Revert.sol)
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/main/v2/contracts/Revert.sol)

Struct containing revert options

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

**Inherits:**
[IERC20Custody](/contracts/evm/interfaces/IERC20Custody.sol/interface.IERC20Custody.md), ReentrancyGuard, AccessControl, Pausable
Initializable, UUPSUpgradeable, [IERC20Custody](/contracts/evm/interfaces/IERC20Custody.sol/interface.IERC20Custody.md), ReentrancyGuardUpgradeable, AccessControlUpgradeable, PausableUpgradeable

Holds the ERC20 tokens deposited on ZetaChain and includes functionality to call a contract.

Expand All @@ -15,7 +15,7 @@ Gateway contract.


```solidity
IGatewayEVM public immutable gateway;
IGatewayEVM public gateway;
```


Expand Down Expand Up @@ -74,17 +74,32 @@ bytes32 public constant WHITELISTER_ROLE = keccak256("WHITELISTER_ROLE");


## Functions
### constructor
### initialize

Constructor for ERC20Custody.
Initializer for ERC20Custody.

*Set admin as default admin and pauser, and tssAddress as tss role.*


```solidity
constructor(address gateway_, address tssAddress_, address admin_);
function initialize(address gateway_, address tssAddress_, address admin_) public initializer;
```

### _authorizeUpgrade

*Authorizes the upgrade of the contract, sender must be owner.*


```solidity
function _authorizeUpgrade(address newImplementation) internal override onlyRole(DEFAULT_ADMIN_ROLE);
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`newImplementation`|`address`|Address of the new implementation.|


### pause

Pause contract.
Expand All @@ -103,6 +118,21 @@ Unpause contract.
function unpause() external onlyRole(PAUSER_ROLE);
```

### updateTSSAddress

Update tss address


```solidity
function updateTSSAddress(address newTSSAddress) external onlyRole(DEFAULT_ADMIN_ROLE);
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`newTSSAddress`|`address`|new tss address|


### setSupportsLegacy

Unpause contract.
Expand Down Expand Up @@ -234,6 +264,9 @@ function withdrawAndRevert(

Deposits asset to custody and pay fee in zeta erc20.

**Note:**
This method is deprecated.


```solidity
function deposit(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# GatewayEVM
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/3a274ce7bad045a879c73669586611d35509cbce/contracts/evm/GatewayEVM.sol)
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/main/v2/contracts/evm/GatewayEVM.sol)

**Inherits:**
Initializable, AccessControlUpgradeable, UUPSUpgradeable, [IGatewayEVM](/contracts/evm/interfaces/IGatewayEVM.sol/interface.IGatewayEVM.md), ReentrancyGuardUpgradeable, PausableUpgradeable
Initializable, AccessControlUpgradeable, UUPSUpgradeable, [IGatewayEVM](/contracts/evm/interfaces/IGatewayEVM.sol/interface.IGatewayEVM.md), ReentrancyGuardUpgradeable, PausableUpgradeable, [INotSupportedMethods](/contracts/Errors.sol/interface.INotSupportedMethods.md)

The GatewayEVM contract is the endpoint to call smart contracts on external chains.

Expand Down Expand Up @@ -73,9 +73,21 @@ bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
```


### MAX_PAYLOAD_SIZE
Max size of payload + revertOptions revert message.


```solidity
uint256 public constant MAX_PAYLOAD_SIZE = 1024;
```


## Functions
### constructor

**Note:**
constructor


```solidity
constructor();
Expand Down Expand Up @@ -107,6 +119,21 @@ function _authorizeUpgrade(address newImplementation) internal override onlyRole
|`newImplementation`|`address`|Address of the new implementation.|


### updateTSSAddress

Update tss address


```solidity
function updateTSSAddress(address newTSSAddress) external onlyRole(DEFAULT_ADMIN_ROLE);
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`newTSSAddress`|`address`|new tss address|


### pause

Pause contract.
Expand Down Expand Up @@ -430,14 +457,14 @@ function setConnector(address zetaConnector_) external onlyRole(DEFAULT_ADMIN_RO
|`zetaConnector_`|`address`|Address of the connector contract.|


### resetApproval
### _resetApproval

*Resets the approval of a token for a specified address.
This is used to ensure that the approval is set to zero before setting it to a new value.*


```solidity
function resetApproval(address token, address to) private returns (bool);
function _resetApproval(address token, address to) private returns (bool);
```
**Parameters**

Expand All @@ -453,15 +480,15 @@ function resetApproval(address token, address to) private returns (bool);
|`<none>`|`bool`|True if the approval reset was successful, false otherwise.|


### transferFromToAssetHandler
### _transferFromToAssetHandler

*Transfers tokens from the sender to the asset handler.
This function handles the transfer of tokens to either the connector or custody contract based on the asset
type.*


```solidity
function transferFromToAssetHandler(address from, address token, uint256 amount) private;
function _transferFromToAssetHandler(address from, address token, uint256 amount) private;
```
**Parameters**

Expand All @@ -472,15 +499,15 @@ function transferFromToAssetHandler(address from, address token, uint256 amount)
|`amount`|`uint256`|Amount of tokens to transfer.|


### transferToAssetHandler
### _transferToAssetHandler

*Transfers tokens to the asset handler.
This function handles the transfer of tokens to either the connector or custody contract based on the asset
type.*


```solidity
function transferToAssetHandler(address token, uint256 amount) private;
function _transferToAssetHandler(address token, uint256 amount) private;
```
**Parameters**

Expand Down Expand Up @@ -541,10 +568,10 @@ function _executeAuthenticatedCall(
|`<none>`|`bytes`|The result of the call.|


### revertIfOnCallOrOnRevert
### _revertIfOnCallOrOnRevert


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

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

**Inherits:**
[IZetaConnectorEvents](/contracts/evm/interfaces/IZetaConnector.sol/interface.IZetaConnectorEvents.md), ReentrancyGuard, Pausable, AccessControl
Initializable, UUPSUpgradeable, [IZetaConnectorEvents](/contracts/evm/interfaces/IZetaConnector.sol/interface.IZetaConnectorEvents.md), ReentrancyGuardUpgradeable, PausableUpgradeable, AccessControlUpgradeable

Abstract base contract for ZetaConnector.

Expand All @@ -15,7 +15,7 @@ The Gateway contract used for executing cross-chain calls.


```solidity
IGatewayEVM public immutable gateway;
IGatewayEVM public gateway;
```


Expand All @@ -24,7 +24,16 @@ The address of the Zeta token.


```solidity
address public immutable zetaToken;
address public zetaToken;
```


### tssAddress
The address of the TSS (Threshold Signature Scheme) contract.


```solidity
address public tssAddress;
```


Expand Down Expand Up @@ -56,17 +65,55 @@ bytes32 public constant TSS_ROLE = keccak256("TSS_ROLE");


## Functions
### constructor
### initialize

Constructor for ZetaConnectors.
Initializer for ZetaConnectors.

*Set admin as default admin and pauser, and tssAddress as tss role.*


```solidity
constructor(address gateway_, address zetaToken_, address tssAddress_, address admin_);
function initialize(
address gateway_,
address zetaToken_,
address tssAddress_,
address admin_
)
public
virtual
initializer;
```

### _authorizeUpgrade

*Authorizes the upgrade of the contract, sender must be owner.*


```solidity
function _authorizeUpgrade(address newImplementation) internal override onlyRole(DEFAULT_ADMIN_ROLE);
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`newImplementation`|`address`|Address of the new implementation.|


### updateTSSAddress

Update tss address


```solidity
function updateTSSAddress(address newTSSAddress) external onlyRole(DEFAULT_ADMIN_ROLE);
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`newTSSAddress`|`address`|new tss address|


### pause

Pause contract.
Expand Down
Loading

0 comments on commit a9d0d60

Please sign in to comment.