diff --git a/contracts/src/RIP7755Inbox.sol b/contracts/src/RIP7755Inbox.sol index 580242c..cbd0c37 100644 --- a/contracts/src/RIP7755Inbox.sol +++ b/contracts/src/RIP7755Inbox.sol @@ -28,7 +28,7 @@ contract RIP7755Inbox { /// @dev Block timestamp when fulfilled uint96 timestamp; /// @dev Msg.sender of fulfillment call - address filler; + address fulfiller; } // Main storage location used as the base for the fulfillmentInfo mapping following EIP-7201. (keccak256("RIP-7755")) @@ -87,7 +87,7 @@ contract RIP7755Inbox { revert CallAlreadyFulfilled(); } - _setFulfillmentInfo(requestHash, FulfillmentInfo({timestamp: uint96(block.timestamp), filler: fulfiller})); + _setFulfillmentInfo(requestHash, FulfillmentInfo({timestamp: uint96(block.timestamp), fulfiller: fulfiller})); _sendCallsAndValidateMsgValue(request); diff --git a/contracts/src/RIP7755Outbox.sol b/contracts/src/RIP7755Outbox.sol index e9fde2b..70d7372 100644 --- a/contracts/src/RIP7755Outbox.sol +++ b/contracts/src/RIP7755Outbox.sol @@ -50,6 +50,11 @@ abstract contract RIP7755Outbox { /// @param request The requested cross chain call event CrossChainCallRequested(bytes32 indexed requestHash, CrossChainRequest request); + /// @notice Event emitted when a cross chain call is successfully completed + /// @param requestHash The keccak256 hash of a `CrossChainRequest` + /// @param submitter The address of the fulfiller that successfully completed the cross chain call + event CrossChainCallCompleted(bytes32 indexed requestHash, address submitter); + /// @notice Event emitted when an expired cross chain call request is canceled /// @param requestHash The keccak256 hash of a `CrossChainRequest` event CrossChainCallCanceled(bytes32 indexed requestHash); @@ -129,6 +134,8 @@ abstract contract RIP7755Outbox { _requestStatus[requestHash] = CrossChainCallStatus.Completed; _sendReward(request, payTo); + + emit CrossChainCallCompleted(requestHash, msg.sender); } /// @notice Cancels a pending request that has expired @@ -249,7 +256,7 @@ abstract contract RIP7755Outbox { returns (RIP7755Inbox.FulfillmentInfo memory) { RIP7755Inbox.FulfillmentInfo memory fulfillmentInfo; - fulfillmentInfo.filler = address(uint160((uint256(inboxContractStorageValue) >> 96) & type(uint160).max)); + fulfillmentInfo.fulfiller = address(uint160((uint256(inboxContractStorageValue) >> 96) & type(uint160).max)); fulfillmentInfo.timestamp = uint96(uint256(inboxContractStorageValue)); return fulfillmentInfo; } diff --git a/contracts/test/HashiProver.t.sol b/contracts/test/HashiProver.t.sol index 21f4fef..f470c8a 100644 --- a/contracts/test/HashiProver.t.sol +++ b/contracts/test/HashiProver.t.sol @@ -145,10 +145,6 @@ contract HashiProverTest is Test { }); } - function _initFulfillmentInfo() private view returns (RIP7755Inbox.FulfillmentInfo memory) { - return RIP7755Inbox.FulfillmentInfo({timestamp: 1730125190, filler: FILLER}); - } - function _deriveStorageKey(CrossChainRequest memory request) private pure returns (bytes memory) { bytes32 requestHash = keccak256(abi.encode(request)); return abi.encode(keccak256(abi.encodePacked(requestHash, _VERIFIER_STORAGE_LOCATION))); diff --git a/contracts/test/RIP7755Inbox.t.sol b/contracts/test/RIP7755Inbox.t.sol index ba564e4..8f4f205 100644 --- a/contracts/test/RIP7755Inbox.t.sol +++ b/contracts/test/RIP7755Inbox.t.sol @@ -63,7 +63,7 @@ contract RIP7755InboxTest is Test { bytes32 requestHash = inbox.hashRequest(request); RIP7755Inbox.FulfillmentInfo memory info = inbox.getFulfillmentInfo(requestHash); - assertEq(info.filler, FULFILLER); + assertEq(info.fulfiller, FULFILLER); assertEq(info.timestamp, block.timestamp); } @@ -152,7 +152,7 @@ contract RIP7755InboxTest is Test { bytes32 requestHash = inbox.hashRequest(request); RIP7755Inbox.FulfillmentInfo memory info = inbox.getFulfillmentInfo(requestHash); - assertEq(info.filler, FULFILLER); + assertEq(info.fulfiller, FULFILLER); assertEq(info.timestamp, block.timestamp); } @@ -167,7 +167,7 @@ contract RIP7755InboxTest is Test { bytes32 requestHash = inbox.hashRequest(request); RIP7755Inbox.FulfillmentInfo memory info = inbox.getFulfillmentInfo(requestHash); - assertEq(info.filler, FULFILLER); + assertEq(info.fulfiller, FULFILLER); assertEq(info.timestamp, block.timestamp); } diff --git a/contracts/test/RIP7755Outbox.t.sol b/contracts/test/RIP7755Outbox.t.sol index 925dea7..3e9943b 100644 --- a/contracts/test/RIP7755Outbox.t.sol +++ b/contracts/test/RIP7755Outbox.t.sol @@ -23,6 +23,7 @@ contract RIP7755OutboxTest is Test { bytes32 private constant _NATIVE_ASSET = 0x000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee; event CrossChainCallRequested(bytes32 indexed requestHash, CrossChainRequest request); + event CrossChainCallCompleted(bytes32 indexed requestHash, address submitter); event CrossChainCallCanceled(bytes32 indexed callHash); function setUp() public { @@ -218,6 +219,20 @@ contract RIP7755OutboxTest is Test { outbox.claimReward(request, storageProofData, FILLER); } + function test_claimReward_emitsEvent(uint256 rewardAmount) + external + fundAlice(rewardAmount) + { + CrossChainRequest memory request = _submitRequest(rewardAmount); + bytes memory storageProofData = abi.encode(true); + bytes32 requestHash = outbox.hashRequest(request); + + vm.prank(FILLER); + vm.expectEmit(true, false, false, true); + emit CrossChainCallCompleted(requestHash, FILLER); + outbox.claimReward(request, storageProofData, FILLER); + } + function test_claimReward_storesCompletedStatus_pendingState(uint256 rewardAmount) external fundAlice(rewardAmount)