diff --git a/examples/router/contracts/Connected.sol b/examples/router/contracts/Connected.sol index f51eee72..c365e81e 100644 --- a/examples/router/contracts/Connected.sol +++ b/examples/router/contracts/Connected.sol @@ -75,13 +75,16 @@ contract Connected is Ownable { if (sender != counterparty) revert Unauthorized(); if (isCall) { + // Handle a call from another connected chain emit OnCallEvent("regular call"); } else { + // Handle revert emit OnCallEvent("revert"); } return ""; } + // onRevert is executed when router's onCall reverts function onRevert( RevertContext calldata context ) external payable onlyGateway { diff --git a/examples/router/contracts/Universal.sol b/examples/router/contracts/Universal.sol index 9e20b1bf..062a0367 100644 --- a/examples/router/contracts/Universal.sol +++ b/examples/router/contracts/Universal.sol @@ -111,6 +111,8 @@ contract Universal is UniversalContract, Ownable { ); } + // onRevert is called when a contract on the destination chain reverts. + // onRevert sends a call back to the source chain function onRevert(RevertContext calldata context) external onlyGateway { ( RevertOptions memory revertOptions, @@ -130,7 +132,7 @@ contract Universal is UniversalContract, Ownable { 0 ); (, uint256 gasFee) = IZRC20(destination).withdrawGasFeeWithGasLimit( - 700000 + onRevertGasLimit ); if (out < gasFee) revert("Insufficient out amount for gas fee"); @@ -140,7 +142,7 @@ contract Universal is UniversalContract, Ownable { out - gasFee, destination, abi.encode(data, receiver, false), - CallOptions(700000, false), + CallOptions(onRevertGasLimit, false), RevertOptions(address(0), false, address(0), "", 0) ); }