Skip to content

Commit

Permalink
fix #64 (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
hujw77 authored Oct 31, 2023
1 parent c6ceb60 commit ec8fcb4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
7 changes: 4 additions & 3 deletions src/ORMP.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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");
}

Expand Down
5 changes: 3 additions & 2 deletions src/interfaces/IORMP.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/ORMP.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion test/bench/ORMP.b.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}
}

0 comments on commit ec8fcb4

Please sign in to comment.