diff --git a/src/ORMP.sol b/src/ORMP.sol index 15f4f47..117fdd5 100644 --- a/src/ORMP.sol +++ b/src/ORMP.sol @@ -37,8 +37,9 @@ contract ORMP is ReentrancyGuard, Channel { /// @param toChainId The Message destination chain id. /// @param to User application contract address which receive the message. /// @param encoded The calldata which encoded by ABI Encoding. + /// @param refund Return extra fee to refund address. /// @param params General extensibility for relayer to custom functionality. - function send(uint256 toChainId, address to, bytes calldata encoded, bytes calldata params) + function send(uint256 toChainId, address to, bytes calldata encoded, address refund, bytes calldata params) external payable sendNonReentrant @@ -58,8 +59,8 @@ contract ORMP is ReentrancyGuard, Channel { //refund if (msg.value > relayerFee + oracleFee) { - uint256 refund = msg.value - (relayerFee + oracleFee); - (bool success,) = ua.call{value: refund}(""); + uint256 refundFee = msg.value - (relayerFee + oracleFee); + (bool success,) = refund.call{value: refundFee}(""); require(success, "!refund"); } diff --git a/src/interfaces/IORMP.sol b/src/interfaces/IORMP.sol index 9cae3f1..a2b559a 100644 --- a/src/interfaces/IORMP.sol +++ b/src/interfaces/IORMP.sol @@ -25,9 +25,10 @@ interface IORMP { /// @param toChainId The Message destination chain id. /// @param to User application contract address which receive the message. /// @param encoded The calldata which encoded by ABI Encoding. + /// @param refund Return extra fee to refund address. /// @param params General extensibility for relayer to custom functionality. /// @return Return the hash of the message as message id. - function send(uint256 toChainId, address to, bytes calldata encoded, bytes calldata params) + function send(uint256 toChainId, address to, bytes calldata encoded, address refund, bytes calldata params) external payable returns (bytes32); @@ -37,7 +38,7 @@ interface IORMP { // @param to User application contract address which receive the message. /// @param encoded The calldata which encoded by ABI Encoding. /// @param params General extensibility for relayer to custom functionality. - function fee(uint256 toChainId, address, /*to*/ bytes calldata encoded, bytes calldata params) + function fee(uint256 toChainId, address to, bytes calldata encoded, bytes calldata params) external view returns (uint256); diff --git a/test/ORMP.t.sol b/test/ORMP.t.sol index c3451fd..5720e45 100644 --- a/test/ORMP.t.sol +++ b/test/ORMP.t.sol @@ -41,7 +41,7 @@ contract ORMPTest is Test, Verifier { function perform_send() public { uint256 f = ormp.fee(2, self, "", ""); - ormp.send{value: f}(2, self, "", ""); + ormp.send{value: f}(2, self, "", self, ""); proof = Proof({blockNumber: block.number, messageIndex: ormp.messageCount() - 1, messageProof: ormp.prove()}); vm.chainId(2); } diff --git a/test/bench/ORMP.b.sol b/test/bench/ORMP.b.sol index 03fab34..d61dd5b 100644 --- a/test/bench/ORMP.b.sol +++ b/test/bench/ORMP.b.sol @@ -80,6 +80,6 @@ contract ORMPBenchmarkTest is Test { function perform_send(uint256 fromChainId, uint256 toChainId, bytes calldata encoded) public { vm.createSelectFork(fromChainId.toChainName()); uint256 f = ormp.fee(toChainId, self, encoded, abi.encode(uint256(0))); - ormp.send{value: f}(toChainId, self, encoded, abi.encode(uint256(0))); + ormp.send{value: f}(toChainId, self, encoded, self, abi.encode(uint256(0))); } }