Skip to content

Commit

Permalink
backport oncrosschain call rename
Browse files Browse the repository at this point in the history
  • Loading branch information
skosito committed Oct 15, 2024
1 parent c3cf7bd commit 7a88fc6
Show file tree
Hide file tree
Showing 31 changed files with 307 additions and 259 deletions.
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 { IGatewayZEVM } from "./interfaces/IGatewayZEVM.sol";
import { INotSupportedMethods, RevertContext, RevertOptions } 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 @@ -303,7 +303,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 @@ -315,7 +315,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 @@ -325,7 +325,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 @@ -340,7 +340,7 @@ contract GatewayZEVM is
if (target == FUNGIBLE_MODULE_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 @@ -349,7 +349,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 @@ -363,7 +363,7 @@ contract GatewayZEVM is
if (target == FUNGIBLE_MODULE_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 @@ -180,7 +180,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 @@ -195,7 +195,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 @@ -209,7 +209,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,14 +23,14 @@ 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;

function onRevert(RevertContext calldata revertContext) external;
}
2 changes: 1 addition & 1 deletion v2/pkg/gatewayevmzevm.t.sol/gatewayevmzevmtest.go

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions v2/pkg/gatewayzevm.sol/gatewayzevm.go

Large diffs are not rendered by default.

Loading

0 comments on commit 7a88fc6

Please sign in to comment.