Skip to content

Commit

Permalink
feat: refund gas to should never be set to address(0)
Browse files Browse the repository at this point in the history
  • Loading branch information
reednaa committed Jan 10, 2024
1 parent bb61af1 commit f9bb505
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/IncentivizedMessageEscrow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ abstract contract IncentivizedMessageEscrow is IIncentivizedMessageEscrow, Bytes
bytes calldata message,
IncentiveDescription calldata incentive
) checkBytes65Address(destinationAddress) external payable returns(uint256 gasRefund, bytes32 messageIdentifier) {
if (incentive.refundGasTo == address(0)) revert RefundGasToIsZero();
// Check that the application has set a destination implementation
bytes memory destinationImplementation = implementationAddress[msg.sender][destinationIdentifier];
// Check that the length is not 0.
Expand Down
1 change: 1 addition & 0 deletions src/interfaces/IMessageEscrowErrors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ interface IMessageEscrowErrors {
error InvalidImplementationAddress(); // c970156c
error IncorrectValueProvided(uint128 expected, uint128 actual); // 0b52a60b
error ImplementationAddressAlreadySet(bytes currentImplementation); // dba47850
error RefundGasToIsZero(); // 6a1a6afe
}
20 changes: 20 additions & 0 deletions test/IncentivizedMessageEscrow/escrowMessage/refundGasTo.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import "forge-std/Test.sol";
import { TestCommon } from "../../TestCommon.t.sol";

contract EscrowInformationTest is TestCommon {
function test_error_refund_gas_to_0() public {
IncentiveDescription storage incentive = _INCENTIVE;
incentive.refundGasTo = address(0);
vm.expectRevert();
(, bytes32 messageIdentifier) = escrow.submitMessage{value: _getTotalIncentive(_INCENTIVE)}(
bytes32(uint256(0x123123) + uint256(2**255)),
_DESTINATION_ADDRESS_THIS,
_MESSAGE,
incentive
);
}

}

0 comments on commit f9bb505

Please sign in to comment.