Skip to content

Commit

Permalink
returns bytes 4
Browse files Browse the repository at this point in the history
  • Loading branch information
fadeev committed Nov 12, 2024
1 parent 5e05fb0 commit deffb4d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion examples/call/contracts/Connected.sol
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ contract Connected {
function onCall(
MessageContext calldata context,
bytes calldata message
) external payable onlyGateway {
) external payable onlyGateway returns (bytes4) {
emit HelloEvent("Hello on EVM from onCall()", "hey");
return "";
}

function onRevert(
Expand Down
3 changes: 2 additions & 1 deletion examples/nft/contracts/Connected.sol
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ contract Connected is
function onCall(
MessageContext calldata context,
bytes calldata message
) external payable onlyGateway {
) external payable onlyGateway returns (bytes4) {
if (context.sender != counterparty) revert Unauthorized();

(address receiver, uint256 tokenId, string memory uri) = abi.decode(
Expand All @@ -102,6 +102,7 @@ contract Connected is
_safeMint(receiver, tokenId);
_setTokenURI(tokenId, uri);
emit TokenTransferReceived(receiver, tokenId, uri);
return "";
}

function onRevert(RevertContext calldata context) external onlyGateway {
Expand Down
3 changes: 2 additions & 1 deletion examples/token/contracts/Connected.sol
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,15 @@ contract Connected is ERC20, Ownable2Step, Events {
function onCall(
MessageContext calldata context,
bytes calldata message
) external payable onlyGateway {
) external payable onlyGateway returns (bytes4) {
if (context.sender != counterparty) revert Unauthorized();
(address receiver, uint256 amount) = abi.decode(
message,
(address, uint256)
);
_mint(receiver, amount);
emit TokenTransferReceived(receiver, amount);
return "";
}

function onRevert(RevertContext calldata context) external onlyGateway {}
Expand Down

0 comments on commit deffb4d

Please sign in to comment.