Skip to content

Commit

Permalink
keep the same interface
Browse files Browse the repository at this point in the history
  • Loading branch information
hujw77 committed Mar 13, 2024
1 parent b1b6a58 commit b3ad0aa
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 16 deletions.
16 changes: 9 additions & 7 deletions src/ORMP.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,14 @@ contract ORMP is ReentrancyGuard, Channel {
/// @param gasLimit Gas limit for destination user application used.
/// @param encoded The calldata which encoded by ABI Encoding.
/// @param refund Return extra fee to refund address.
function send(uint256 toChainId, address to, uint256 gasLimit, bytes calldata encoded, address refund)
external
payable
sendNonReentrant
returns (bytes32)
{
function send(
uint256 toChainId,
address to,
uint256 gasLimit,
bytes calldata encoded,
address refund,
bytes calldata
) external payable sendNonReentrant returns (bytes32) {
// user application address.
address ua = msg.sender;
// send message by channel, return the hash of the message as id.
Expand Down Expand Up @@ -89,7 +91,7 @@ contract ORMP is ReentrancyGuard, Channel {
// @param ua User application contract address which send the message.
/// @param gasLimit Gas limit for destination user application used.
/// @param encoded The calldata which encoded by ABI Encoding.
function fee(uint256 toChainId, address ua, uint256 gasLimit, bytes calldata encoded)
function fee(uint256 toChainId, address ua, uint256 gasLimit, bytes calldata encoded, bytes calldata)
external
view
returns (uint256)
Expand Down
16 changes: 11 additions & 5 deletions src/interfaces/IORMP.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,23 @@ interface IORMP {
/// @param encoded The calldata which encoded by ABI Encoding.
/// @param refund Return extra fee to refund address.
/// @return Return the hash of the message as message id.
function send(uint256 toChainId, address to, uint256 gasLimit, bytes calldata encoded, address refund)
external
payable
returns (bytes32);
/// @param params General extensibility for relayer to custom functionality.
function send(
uint256 toChainId,
address to,
uint256 gasLimit,
bytes calldata encoded,
address refund,
bytes calldata params
) external payable returns (bytes32);

/// @notice Get a quote in source native gas, for the amount that send() requires to pay for message delivery.
/// @param toChainId The Message destination chain id.
// @param ua User application contract address which send the message.
/// @param gasLimit Gas limit for destination user application used.
/// @param encoded The calldata which encoded by ABI Encoding.
function fee(uint256 toChainId, address ua, uint256 gasLimit, bytes calldata encoded)
/// @param params General extensibility for relayer to custom functionality.
function fee(uint256 toChainId, address ua, uint256 gasLimit, bytes calldata encoded, bytes calldata params)
external
view
returns (uint256);
Expand Down
4 changes: 2 additions & 2 deletions test/ORMP.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ contract ORMPTest is Test, Verifier {
}

function perform_send() public {
uint256 f = ormp.fee(2, self, 0, "");
ormp.send{value: f}(2, self, 0, "", self);
uint256 f = ormp.fee(2, self, 0, "", "");
ormp.send{value: f}(2, self, 0, "", self, "");
proof = Proof({blockNumber: block.number, messageIndex: ormp.messageCount() - 1, messageProof: ormp.prove()});
vm.chainId(2);
}
Expand Down
4 changes: 2 additions & 2 deletions test/bench/ORMP.b.sol
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ 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, 0, encoded);
ormp.send{value: f}(toChainId, self, 0, encoded, self);
uint256 f = ormp.fee(toChainId, self, 0, encoded, "");
ormp.send{value: f}(toChainId, self, 0, encoded, self, "");
}
}

0 comments on commit b3ad0aa

Please sign in to comment.