Skip to content
This repository was archived by the owner on Aug 4, 2025. It is now read-only.

Commit 6ee1d6a

Browse files
committed
improve inbox call efficiency
1 parent 1671900 commit 6ee1d6a

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

contracts/src/RIP7755Inbox.sol

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
pragma solidity 0.8.24;
33

44
import {IEntryPoint} from "account-abstraction/interfaces/IEntryPoint.sol";
5-
import {Address} from "openzeppelin-contracts/contracts/utils/Address.sol";
65
import {CAIP10} from "openzeppelin-contracts/contracts/utils/CAIP10.sol";
76
import {CAIP2} from "openzeppelin-contracts/contracts/utils/CAIP2.sol";
87
import {Strings} from "openzeppelin-contracts/contracts/utils/Strings.sol";
@@ -18,7 +17,6 @@ import {Paymaster} from "./Paymaster.sol";
1817
/// @notice An inbox contract within RIP-7755. This contract's sole purpose is to route requested transactions on
1918
/// destination chains and store record of their fulfillment.
2019
contract RIP7755Inbox is ERC7786Base, Paymaster {
21-
using Address for address payable;
2220
using Strings for string;
2321

2422
struct MainStorage {
@@ -152,7 +150,7 @@ contract RIP7755Inbox is ERC7786Base, Paymaster {
152150
uint256 valueSent;
153151

154152
for (uint256 i; i < messages.length; i++) {
155-
address payable to = payable(messages[i].receiver.parseAddress());
153+
address to = messages[i].receiver.parseAddress();
156154
uint256 value = _locateAttributeValue(messages[i].attributes);
157155
_call(to, messages[i].payload, value);
158156

@@ -166,11 +164,16 @@ contract RIP7755Inbox is ERC7786Base, Paymaster {
166164
}
167165
}
168166

169-
function _call(address payable to, bytes memory data, uint256 value) private {
170-
if (data.length == 0) {
171-
to.sendValue(value);
172-
} else {
173-
to.functionCallWithValue(data, value);
167+
function _call(address to, bytes memory data, uint256 value) private {
168+
bytes memory result;
169+
/// @solidity memory-safe-assembly
170+
assembly {
171+
result := mload(0x40)
172+
if iszero(call(gas(), to, value, add(data, 0x20), mload(data), codesize(), 0x00)) {
173+
// Bubble up the revert if the call reverts.
174+
returndatacopy(result, 0x00, returndatasize())
175+
revert(result, returndatasize())
176+
}
174177
}
175178
}
176179

0 commit comments

Comments
 (0)