Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: rename onCrosschainCall and zContext #349

Merged
merged 8 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions v2/contracts/zevm/GatewayZEVM.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { CallOptions, IGatewayZEVM } from "./interfaces/IGatewayZEVM.sol";
import { RevertContext, RevertOptions, Revertable } from "../../contracts/Revert.sol";
import "./interfaces/IWZETA.sol";
import { IZRC20 } from "./interfaces/IZRC20.sol";
import { UniversalContract, zContext } from "./interfaces/UniversalContract.sol";
import { MessageContext, UniversalContract } from "./interfaces/UniversalContract.sol";
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
Expand Down Expand Up @@ -422,7 +422,7 @@ contract GatewayZEVM is
/// @param target The target contract to call.
/// @param message The calldata to pass to the contract call.
function execute(
zContext calldata context,
MessageContext calldata context,
address zrc20,
uint256 amount,
address target,
Expand All @@ -434,7 +434,7 @@ contract GatewayZEVM is
{
if (zrc20 == address(0) || target == address(0)) revert ZeroAddress();

UniversalContract(target).onCrossChainCall(context, zrc20, amount, message);
UniversalContract(target).onCall(context, zrc20, amount, message);
}

/// @notice Deposit foreign coins into ZRC20 and call a user-specified contract on ZEVM.
Expand All @@ -444,7 +444,7 @@ contract GatewayZEVM is
/// @param target The target contract to call.
/// @param message The calldata to pass to the contract call.
function depositAndCall(
zContext calldata context,
MessageContext calldata context,
address zrc20,
uint256 amount,
address target,
Expand All @@ -459,7 +459,7 @@ contract GatewayZEVM is
if (target == PROTOCOL_ADDRESS || target == address(this)) revert InvalidTarget();

if (!IZRC20(zrc20).deposit(target, amount)) revert ZRC20DepositFailed();
UniversalContract(target).onCrossChainCall(context, zrc20, amount, message);
UniversalContract(target).onCall(context, zrc20, amount, message);
}

/// @notice Deposit ZETA and call a user-specified contract on ZEVM.
Expand All @@ -468,7 +468,7 @@ contract GatewayZEVM is
/// @param target The target contract to call.
/// @param message The calldata to pass to the contract call.
function depositAndCall(
zContext calldata context,
MessageContext calldata context,
uint256 amount,
address target,
bytes calldata message
Expand All @@ -482,7 +482,7 @@ contract GatewayZEVM is
if (target == PROTOCOL_ADDRESS || target == address(this)) revert InvalidTarget();

_transferZETA(amount, target);
UniversalContract(target).onCrossChainCall(context, zetaToken, amount, message);
UniversalContract(target).onCall(context, zetaToken, amount, message);
}

/// @notice Revert a user-specified contract on ZEVM.
Expand Down
6 changes: 3 additions & 3 deletions v2/contracts/zevm/interfaces/IGatewayZEVM.sol
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ interface IGatewayZEVM is IGatewayZEVMErrors, IGatewayZEVMEvents {
/// @param target The target contract to call.
/// @param message The calldata to pass to the contract call.
function execute(
zContext calldata context,
MessageContext calldata context,
address zrc20,
uint256 amount,
address target,
Expand All @@ -244,7 +244,7 @@ interface IGatewayZEVM is IGatewayZEVMErrors, IGatewayZEVMEvents {
/// @param target The target contract to call.
/// @param message The calldata to pass to the contract call.
function depositAndCall(
zContext calldata context,
MessageContext calldata context,
address zrc20,
uint256 amount,
address target,
Expand All @@ -258,7 +258,7 @@ interface IGatewayZEVM is IGatewayZEVMErrors, IGatewayZEVMEvents {
/// @param target The target contract to call.
/// @param message The calldata to pass to the contract call.
function depositAndCall(
zContext calldata context,
MessageContext calldata context,
uint256 amount,
address target,
bytes calldata message
Expand Down
16 changes: 9 additions & 7 deletions v2/contracts/zevm/interfaces/UniversalContract.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ pragma solidity 0.8.26;

import { RevertContext } from "../../../contracts/Revert.sol";

/// @custom:deprecated should be removed once v2 SystemContract is not used anymore.
/// MessageContext should be used
struct zContext {
bytes origin;
address sender;
Expand All @@ -21,12 +23,12 @@ interface zContract {
external;
}

struct MessageContext {
bytes origin;
address sender;
uint256 chainID;
}

interface UniversalContract {
function onCrossChainCall(
zContext calldata context,
address zrc20,
uint256 amount,
bytes calldata message
)
external;
function onCall(MessageContext calldata context, address zrc20, uint256 amount, bytes calldata message) external;
}
1 change: 1 addition & 0 deletions v2/docs/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
- [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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix the indentation to match the surrounding entries.

The static analysis tool flagged an indentation issue:

32-32: Expected: 4; Actual: 6
Unordered list indentation

To fix the indentation, apply this diff:

-      - [MessageContext](contracts/zevm/interfaces/UniversalContract.sol/struct.MessageContext.md)
+    - [MessageContext](contracts/zevm/interfaces/UniversalContract.sol/struct.MessageContext.md)
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- [MessageContext](contracts/zevm/interfaces/UniversalContract.sol/struct.MessageContext.md)
- [MessageContext](contracts/zevm/interfaces/UniversalContract.sol/struct.MessageContext.md)
Tools
Markdownlint

32-32: Expected: 4; Actual: 6
Unordered list indentation

(MD007, ul-indent)

- [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)
Expand Down
2 changes: 1 addition & 1 deletion v2/docs/src/contracts/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/45df03a49b31cc5722a5bb6453b743fc8ac35d1f/contracts/Revert.sol)
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/317e9a168aa19dc31b1217eef2a50dbf71ae4d80/contracts/Revert.sol)

Interface for contracts that support revertable calls.

Expand Down
2 changes: 1 addition & 1 deletion v2/docs/src/contracts/Revert.sol/struct.RevertContext.md
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/45df03a49b31cc5722a5bb6453b743fc8ac35d1f/contracts/Revert.sol)
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/317e9a168aa19dc31b1217eef2a50dbf71ae4d80/contracts/Revert.sol)

Struct containing revert context passed to onRevert.

Expand Down
2 changes: 1 addition & 1 deletion v2/docs/src/contracts/Revert.sol/struct.RevertOptions.md
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/45df03a49b31cc5722a5bb6453b743fc8ac35d1f/contracts/Revert.sol)
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/317e9a168aa19dc31b1217eef2a50dbf71ae4d80/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/45df03a49b31cc5722a5bb6453b743fc8ac35d1f/contracts/evm/ERC20Custody.sol)
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/317e9a168aa19dc31b1217eef2a50dbf71ae4d80/contracts/evm/ERC20Custody.sol)

**Inherits:**
Initializable, UUPSUpgradeable, [IERC20Custody](/contracts/evm/interfaces/IERC20Custody.sol/interface.IERC20Custody.md), ReentrancyGuardUpgradeable, AccessControlUpgradeable, PausableUpgradeable
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/45df03a49b31cc5722a5bb6453b743fc8ac35d1f/contracts/evm/GatewayEVM.sol)
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/317e9a168aa19dc31b1217eef2a50dbf71ae4d80/contracts/evm/GatewayEVM.sol)

**Inherits:**
Initializable, AccessControlUpgradeable, UUPSUpgradeable, [IGatewayEVM](/contracts/evm/interfaces/IGatewayEVM.sol/interface.IGatewayEVM.md), ReentrancyGuardUpgradeable, PausableUpgradeable
Expand Down
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/45df03a49b31cc5722a5bb6453b743fc8ac35d1f/contracts/evm/ZetaConnectorBase.sol)
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/317e9a168aa19dc31b1217eef2a50dbf71ae4d80/contracts/evm/ZetaConnectorBase.sol)

**Inherits:**
Initializable, UUPSUpgradeable, [IZetaConnectorEvents](/contracts/evm/interfaces/IZetaConnector.sol/interface.IZetaConnectorEvents.md), ReentrancyGuardUpgradeable, PausableUpgradeable, AccessControlUpgradeable
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/45df03a49b31cc5722a5bb6453b743fc8ac35d1f/contracts/evm/ZetaConnectorNative.sol)
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/317e9a168aa19dc31b1217eef2a50dbf71ae4d80/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/45df03a49b31cc5722a5bb6453b743fc8ac35d1f/contracts/evm/ZetaConnectorNonNative.sol)
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/317e9a168aa19dc31b1217eef2a50dbf71ae4d80/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/45df03a49b31cc5722a5bb6453b743fc8ac35d1f/contracts/evm/interfaces/IERC20Custody.sol)
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/317e9a168aa19dc31b1217eef2a50dbf71ae4d80/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/45df03a49b31cc5722a5bb6453b743fc8ac35d1f/contracts/evm/interfaces/IERC20Custody.sol)
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/317e9a168aa19dc31b1217eef2a50dbf71ae4d80/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/45df03a49b31cc5722a5bb6453b743fc8ac35d1f/contracts/evm/interfaces/IERC20Custody.sol)
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/317e9a168aa19dc31b1217eef2a50dbf71ae4d80/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
@@ -1,5 +1,5 @@
# Callable
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/45df03a49b31cc5722a5bb6453b743fc8ac35d1f/contracts/evm/interfaces/IGatewayEVM.sol)
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/317e9a168aa19dc31b1217eef2a50dbf71ae4d80/contracts/evm/interfaces/IGatewayEVM.sol)

Interface implemented by contracts receiving authenticated calls.

Expand Down
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/45df03a49b31cc5722a5bb6453b743fc8ac35d1f/contracts/evm/interfaces/IGatewayEVM.sol)
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/317e9a168aa19dc31b1217eef2a50dbf71ae4d80/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
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/45df03a49b31cc5722a5bb6453b743fc8ac35d1f/contracts/evm/interfaces/IGatewayEVM.sol)
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/317e9a168aa19dc31b1217eef2a50dbf71ae4d80/contracts/evm/interfaces/IGatewayEVM.sol)

Interface for the errors used in the GatewayEVM contract.

Expand Down
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/45df03a49b31cc5722a5bb6453b743fc8ac35d1f/contracts/evm/interfaces/IGatewayEVM.sol)
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/317e9a168aa19dc31b1217eef2a50dbf71ae4d80/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
@@ -1,5 +1,5 @@
# MessageContext
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/45df03a49b31cc5722a5bb6453b743fc8ac35d1f/contracts/evm/interfaces/IGatewayEVM.sol)
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/317e9a168aa19dc31b1217eef2a50dbf71ae4d80/contracts/evm/interfaces/IGatewayEVM.sol)

Message context passed to execute function.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# IZetaConnectorEvents
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/45df03a49b31cc5722a5bb6453b743fc8ac35d1f/contracts/evm/interfaces/IZetaConnector.sol)
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/317e9a168aa19dc31b1217eef2a50dbf71ae4d80/contracts/evm/interfaces/IZetaConnector.sol)

Interface for the events emitted by the ZetaConnector contracts.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# IZetaNonEthNew
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/45df03a49b31cc5722a5bb6453b743fc8ac35d1f/contracts/evm/interfaces/IZetaNonEthNew.sol)
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/317e9a168aa19dc31b1217eef2a50dbf71ae4d80/contracts/evm/interfaces/IZetaNonEthNew.sol)

**Inherits:**
IERC20
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# GatewayZEVM
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/45df03a49b31cc5722a5bb6453b743fc8ac35d1f/contracts/zevm/GatewayZEVM.sol)
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/317e9a168aa19dc31b1217eef2a50dbf71ae4d80/contracts/zevm/GatewayZEVM.sol)

**Inherits:**
[IGatewayZEVM](/contracts/zevm/interfaces/IGatewayZEVM.sol/interface.IGatewayZEVM.md), Initializable, AccessControlUpgradeable, UUPSUpgradeable, ReentrancyGuardUpgradeable, PausableUpgradeable
Expand Down Expand Up @@ -441,7 +441,7 @@ Execute a user-specified contract on ZEVM.

```solidity
function execute(
zContext calldata context,
MessageContext calldata context,
address zrc20,
uint256 amount,
address target,
Expand All @@ -455,7 +455,7 @@ function execute(

|Name|Type|Description|
|----|----|-----------|
|`context`|`zContext`|The context of the cross-chain call.|
|`context`|`MessageContext`|The context of the cross-chain call.|
|`zrc20`|`address`|The address of the ZRC20 token.|
|`amount`|`uint256`|The amount of tokens to transfer.|
|`target`|`address`|The target contract to call.|
Expand All @@ -469,7 +469,7 @@ Deposit foreign coins into ZRC20 and call a user-specified contract on ZEVM.

```solidity
function depositAndCall(
zContext calldata context,
MessageContext calldata context,
address zrc20,
uint256 amount,
address target,
Expand All @@ -483,7 +483,7 @@ function depositAndCall(

|Name|Type|Description|
|----|----|-----------|
|`context`|`zContext`|The context of the cross-chain call.|
|`context`|`MessageContext`|The context of the cross-chain call.|
|`zrc20`|`address`|The address of the ZRC20 token.|
|`amount`|`uint256`|The amount of tokens to transfer.|
|`target`|`address`|The target contract to call.|
Expand All @@ -497,7 +497,7 @@ Deposit ZETA and call a user-specified contract on ZEVM.

```solidity
function depositAndCall(
zContext calldata context,
MessageContext calldata context,
uint256 amount,
address target,
bytes calldata message
Expand All @@ -510,7 +510,7 @@ function depositAndCall(

|Name|Type|Description|
|----|----|-----------|
|`context`|`zContext`|The context of the cross-chain call.|
|`context`|`MessageContext`|The context of the cross-chain call.|
|`amount`|`uint256`|The amount of tokens to transfer.|
|`target`|`address`|The target contract to call.|
|`message`|`bytes`|The calldata to pass to the contract call.|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# SystemContract
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/45df03a49b31cc5722a5bb6453b743fc8ac35d1f/contracts/zevm/SystemContract.sol)
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/317e9a168aa19dc31b1217eef2a50dbf71ae4d80/contracts/zevm/SystemContract.sol)

**Inherits:**
[SystemContractErrors](/contracts/zevm/SystemContract.sol/interface.SystemContractErrors.md)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# SystemContractErrors
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/45df03a49b31cc5722a5bb6453b743fc8ac35d1f/contracts/zevm/SystemContract.sol)
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/317e9a168aa19dc31b1217eef2a50dbf71ae4d80/contracts/zevm/SystemContract.sol)

*Custom errors for SystemContract*

Expand Down
2 changes: 1 addition & 1 deletion v2/docs/src/contracts/zevm/ZRC20.sol/contract.ZRC20.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ZRC20
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/45df03a49b31cc5722a5bb6453b743fc8ac35d1f/contracts/zevm/ZRC20.sol)
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/317e9a168aa19dc31b1217eef2a50dbf71ae4d80/contracts/zevm/ZRC20.sol)

**Inherits:**
[IZRC20Metadata](/contracts/zevm/interfaces/IZRC20.sol/interface.IZRC20Metadata.md), [ZRC20Errors](/contracts/zevm/ZRC20.sol/interface.ZRC20Errors.md), [ZRC20Events](/contracts/zevm/interfaces/IZRC20.sol/interface.ZRC20Events.md)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ZRC20Errors
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/45df03a49b31cc5722a5bb6453b743fc8ac35d1f/contracts/zevm/ZRC20.sol)
[Git Source](https://github.com/zeta-chain/protocol-contracts/blob/317e9a168aa19dc31b1217eef2a50dbf71ae4d80/contracts/zevm/ZRC20.sol)

*Custom errors for ZRC20*

Expand Down
Loading
Loading