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

feat: add sender when calling connected chain contracts from zetachain #355

Merged
merged 17 commits into from
Sep 27, 2024
Prev Previous commit
Next Next commit
make onCall payable
  • Loading branch information
skosito committed Sep 20, 2024
commit 4137b5d0258b16a9dffea6e71e3f5a36c1207bd8
2 changes: 1 addition & 1 deletion v2/contracts/evm/GatewayEVM.sol
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ contract GatewayEVM is
private
returns (bytes memory)
{
return Callable(destination).onCall(messageContext, data);
return Callable(destination).onCall{value: msg.value}(messageContext, data);
}

// @dev prevent calling onCall function reserved for authenticated calls
Expand Down
2 changes: 1 addition & 1 deletion v2/contracts/evm/interfaces/IGatewayEVM.sol
Original file line number Diff line number Diff line change
Expand Up @@ -198,5 +198,5 @@ struct MessageContext {

/// @notice Interface implemented by contracts receiving authenticated calls.
interface Callable {
function onCall(MessageContext calldata context, bytes calldata message) external returns (bytes memory);
function onCall(MessageContext calldata context, bytes calldata message) external payable returns (bytes memory);
}
4 changes: 4 additions & 0 deletions v2/contracts/zevm/GatewayZEVM.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol";

import "forge-std/console.sol";

/// @title GatewayZEVM
/// @notice The GatewayZEVM contract is the endpoint to call smart contracts on omnichain.
/// @dev The contract doesn't hold any funds and should never have active allowances.
Expand Down Expand Up @@ -362,6 +364,7 @@ contract GatewayZEVM is
nonReentrant
whenNotPaused
{
console.log(msg.sender);
_call(receiver, zrc20, message, CallOptions({ gasLimit: gasLimit, isArbitraryCall: true }), revertOptions);
}

Expand All @@ -374,6 +377,7 @@ contract GatewayZEVM is
)
internal
{
console.log(msg.sender);
if (receiver.length == 0) revert ZeroAddress();
if (message.length == 0) revert EmptyMessage();

Expand Down
2 changes: 1 addition & 1 deletion v2/test/utils/GatewayEVMUpgradeTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ contract GatewayEVMUpgradeTest is
internal
returns (bytes memory)
{
return Callable(destination).onCall(messageContext, data);
return Callable(destination).onCall{value: msg.value}(messageContext, data);
}

// @dev prevent calling onCall function reserved for authenticated calls
Expand Down
2 changes: 1 addition & 1 deletion v2/test/utils/ReceiverEVM.sol
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ contract ReceiverEVM is IReceiverEVMEvents, ReentrancyGuard {
emit ReceivedRevert(msg.sender, revertContext);
}

function onCall(MessageContext calldata messageContext, bytes calldata message) external returns (bytes memory) {
function onCall(MessageContext calldata messageContext, bytes calldata message) external payable returns (bytes memory) {
emit ReceivedOnCall();
}

Expand Down