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 Nov 2, 2024
1 parent 925fe5b commit 6ed66e0
Show file tree
Hide file tree
Showing 15 changed files with 142 additions and 105 deletions.
8 changes: 7 additions & 1 deletion src/pages/developers/architecture/protocol/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,18 @@ $ forge snapshot
$ anvil
```

### Deploy using script
### Deploy

```shell
$ forge script script/<DeployScript>.s.sol:<DeployScript> --rpc-url <your_rpc_url> --private-key <your_private_key>
```

##### More detailed instructions

To view detailed instructions on how to deploy the contracts, please refer to the [Deployment Guide](./scripts/deploy/readme.md).

This guide covers all steps required to deploy the contracts, including environment setup, commands, and best practices.

### Cast

```shell
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ Interface for contracts that with non supported methods.
error ZETANotSupported();
```

### CallOnRevertNotSupported

```solidity
error CallOnRevertNotSupported();
```

Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ WithdrawAndCall transfers tokens to Gateway and call a contract through the Gate

```solidity
function withdrawAndCall(
MessageContext calldata messageContext,
address to,
address token,
uint256 amount,
Expand All @@ -222,6 +223,7 @@ function withdrawAndCall(

|Name|Type|Description|
|----|----|-----------|
|`messageContext`|`MessageContext`|Message context containing sender.|
|`to`|`address`|Address of the contract to call.|
|`token`|`address`|Address of the ERC20 token.|
|`amount`|`uint256`|Amount of tokens to withdraw.|
Expand Down Expand Up @@ -264,9 +266,6 @@ 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
Expand Up @@ -85,9 +85,6 @@ uint256 public constant MAX_PAYLOAD_SIZE = 1024;
## Functions
### constructor

**Note:**
constructor


```solidity
constructor();
Expand Down Expand Up @@ -167,9 +164,9 @@ function executeRevert(
)
public
payable
nonReentrant
onlyRole(TSS_ROLE)
whenNotPaused
nonReentrant;
whenNotPaused;
```
**Parameters**

Expand All @@ -182,7 +179,7 @@ function executeRevert(

### execute

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

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

Expand All @@ -195,40 +192,7 @@ function execute(
)
external
payable
onlyRole(TSS_ROLE)
whenNotPaused
nonReentrant
returns (bytes memory);
```
**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);
Expand All @@ -237,6 +201,7 @@ function execute(

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

Expand All @@ -257,20 +222,22 @@ It uses the ERC20 allowance system, resetting gateway allowance at the end.*

```solidity
function executeWithERC20(
MessageContext calldata messageContext,
address token,
address to,
uint256 amount,
bytes calldata data
)
public
nonReentrant
onlyRole(ASSET_HANDLER_ROLE)
whenNotPaused
nonReentrant;
whenNotPaused;
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`messageContext`|`MessageContext`|Message context containing sender.|
|`token`|`address`|Address of the ERC20 token.|
|`to`|`address`|Address of the contract to call.|
|`amount`|`uint256`|Amount of tokens to transfer.|
Expand All @@ -293,9 +260,9 @@ function revertWithERC20(
RevertContext calldata revertContext
)
external
nonReentrant
onlyRole(ASSET_HANDLER_ROLE)
whenNotPaused
nonReentrant;
whenNotPaused;
```
**Parameters**

Expand All @@ -314,7 +281,7 @@ Deposits ETH to the TSS address.


```solidity
function deposit(address receiver, RevertOptions calldata revertOptions) external payable whenNotPaused nonReentrant;
function deposit(address receiver, RevertOptions calldata revertOptions) external payable whenNotPaused;
```
**Parameters**

Expand All @@ -337,8 +304,7 @@ function deposit(
RevertOptions calldata revertOptions
)
external
whenNotPaused
nonReentrant;
whenNotPaused;
```
**Parameters**

Expand All @@ -363,8 +329,7 @@ function depositAndCall(
)
external
payable
whenNotPaused
nonReentrant;
whenNotPaused;
```
**Parameters**

Expand All @@ -389,8 +354,7 @@ function depositAndCall(
RevertOptions calldata revertOptions
)
external
whenNotPaused
nonReentrant;
whenNotPaused;
```
**Parameters**

Expand All @@ -409,14 +373,7 @@ Calls an omnichain smart contract without asset transfer.


```solidity
function call(
address receiver,
bytes calldata payload,
RevertOptions calldata revertOptions
)
external
whenNotPaused
nonReentrant;
function call(address receiver, bytes calldata payload, RevertOptions calldata revertOptions) external whenNotPaused;
```
**Parameters**

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,21 @@ Withdraw tokens and call a contract through Gateway.


```solidity
function withdrawAndCall(address to, uint256 amount, bytes calldata data, bytes32 internalSendHash) external virtual;
function withdrawAndCall(
MessageContext calldata messageContext,
address to,
uint256 amount,
bytes calldata data,
bytes32 internalSendHash
)
external
virtual;
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`messageContext`|`MessageContext`|Message context containing sender.|
|`to`|`address`|The address to withdraw tokens to.|
|`amount`|`uint256`|The amount of tokens to withdraw.|
|`data`|`bytes`|The calldata to pass to the contract call.|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ Withdraw tokens and call a contract through Gateway.

```solidity
function withdrawAndCall(
MessageContext calldata messageContext,
address to,
uint256 amount,
bytes calldata data,
Expand All @@ -77,6 +78,7 @@ function withdrawAndCall(

|Name|Type|Description|
|----|----|-----------|
|`messageContext`|`MessageContext`|Message context containing sender.|
|`to`|`address`|The address to withdraw tokens to.|
|`amount`|`uint256`|The amount of tokens to withdraw.|
|`data`|`bytes`|The calldata to pass to the contract call.|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ Withdraw tokens and call a contract through Gateway.

```solidity
function withdrawAndCall(
MessageContext calldata messageContext,
address to,
uint256 amount,
bytes calldata data,
Expand All @@ -104,6 +105,7 @@ function withdrawAndCall(

|Name|Type|Description|
|----|----|-----------|
|`messageContext`|`MessageContext`|Message context containing sender.|
|`to`|`address`|The address to withdraw tokens to.|
|`amount`|`uint256`|The amount of tokens to withdraw.|
|`data`|`bytes`|The calldata to pass to the contract call.|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,20 @@ WithdrawAndCall transfers tokens to Gateway and call a contract through the Gate


```solidity
function withdrawAndCall(address token, address to, uint256 amount, bytes calldata data) external;
function withdrawAndCall(
MessageContext calldata messageContext,
address token,
address to,
uint256 amount,
bytes calldata data
)
external;
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`messageContext`|`MessageContext`|Message context containing sender.|
|`token`|`address`|Address of the ERC20 token.|
|`to`|`address`|Address of the contract to call.|
|`amount`|`uint256`|Amount of tokens to withdraw.|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,20 @@ Executes a call to a contract using ERC20 tokens.


```solidity
function executeWithERC20(address token, address to, uint256 amount, bytes calldata data) external;
function executeWithERC20(
MessageContext calldata messageContext,
address token,
address to,
uint256 amount,
bytes calldata data
)
external;
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`messageContext`|`MessageContext`|Message context containing sender and arbitrary call flag.|
|`token`|`address`|The address of the ERC20 token.|
|`to`|`address`|The address of the contract to call.|
|`amount`|`uint256`|The amount of tokens to transfer.|
Expand Down Expand Up @@ -51,28 +59,6 @@ function executeRevert(
|`revertContext`|`RevertContext`|Revert context to pass to onRevert.|


### execute

Executes a call to a contract.


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

|Name|Type|Description|
|----|----|-----------|
|`destination`|`address`|The address of the contract to call.|
|`data`|`bytes`|The calldata to pass to the contract call.|

**Returns**

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


### execute

Executes a call to a destination address without ERC20 tokens.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,32 @@ event Deposited(

**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`sender`|`address`|The address of the sender.|
|`receiver`|`address`|The address of the receiver.|
|`amount`|`uint256`|The amount of ETH or tokens deposited.|
|`asset`|`address`|The address of the ERC20 token (zero address if ETH).|
|`payload`|`bytes`|The calldata passed with the deposit. No longer used. Kept to maintain compatibility.|
|`revertOptions`|`RevertOptions`|Revert options.|

### DepositedAndCalled
Emitted when a deposit and call is made.


```solidity
event DepositedAndCalled(
address indexed sender,
address indexed receiver,
uint256 amount,
address asset,
bytes payload,
RevertOptions revertOptions
);
```

**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`sender`|`address`|The address of the sender.|
Expand Down
Loading

0 comments on commit 6ed66e0

Please sign in to comment.