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 15, 2024
1 parent 2b44f68 commit 1ea5bb3
Show file tree
Hide file tree
Showing 36 changed files with 250 additions and 75 deletions.
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/45df03a49b31cc5722a5bb6453b743fc8ac35d1f/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/45df03a49b31cc5722a5bb6453b743fc8ac35d1f/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/45df03a49b31cc5722a5bb6453b743fc8ac35d1f/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/45df03a49b31cc5722a5bb6453b743fc8ac35d1f/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
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/3a274ce7bad045a879c73669586611d35509cbce/contracts/evm/GatewayEVM.sol)
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/45df03a49b31cc5722a5bb6453b743fc8ac35d1f/contracts/evm/GatewayEVM.sol)

**Inherits:**
Initializable, AccessControlUpgradeable, UUPSUpgradeable, [IGatewayEVM](/contracts/evm/interfaces/IGatewayEVM.sol/interface.IGatewayEVM.md), ReentrancyGuardUpgradeable, PausableUpgradeable
Expand Down Expand Up @@ -73,6 +73,15 @@ 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

Expand Down Expand Up @@ -107,6 +116,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 +454,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 +477,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 +496,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 +565,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/45df03a49b31cc5722a5bb6453b743fc8ac35d1f/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
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/3a274ce7bad045a879c73669586611d35509cbce/contracts/evm/ZetaConnectorNative.sol)
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/45df03a49b31cc5722a5bb6453b743fc8ac35d1f/contracts/evm/ZetaConnectorNative.sol)

**Inherits:**
[ZetaConnectorBase](/contracts/evm/ZetaConnectorBase.sol/abstract.ZetaConnectorBase.md)
Expand All @@ -10,17 +10,19 @@ Implementation of ZetaConnectorBase for native token handling.


## Functions
### constructor
### initialize


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

### withdraw
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/3a274ce7bad045a879c73669586611d35509cbce/contracts/evm/ZetaConnectorNonNative.sol)
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/45df03a49b31cc5722a5bb6453b743fc8ac35d1f/contracts/evm/ZetaConnectorNonNative.sol)

**Inherits:**
[ZetaConnectorBase](/contracts/evm/ZetaConnectorBase.sol/abstract.ZetaConnectorBase.md)
Expand All @@ -15,22 +15,24 @@ Max supply for minting.


```solidity
uint256 public maxSupply = type(uint256).max;
uint256 public maxSupply;
```


## Functions
### constructor
### initialize


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

### setMaxSupply
Expand Down Expand Up @@ -161,7 +163,7 @@ function receiveTokens(uint256 amount) external override whenNotPaused;


```solidity
function _mintTo(address to, uint256 amount, bytes32 internalSendHash) internal;
function _mintTo(address to, uint256 amount, bytes32 internalSendHash) private;
```

## Events
Expand Down
Loading

0 comments on commit 1ea5bb3

Please sign in to comment.