@@ -477,26 +477,30 @@ function example(address target, bytes memory data) internal {
477
477
bytes32 result2;
478
478
479
479
// Ignore return data
480
- success = target.callRaw (data);
480
+ success = target.callNoReturn (data);
481
481
482
482
// Extract single 32-byte value
483
- (success, result1) = target.callReturnBytes32 (data);
483
+ (success, result1, ) = target.callReturn64Bytes (data);
484
484
485
485
// Extract two 32-byte values
486
- (success, result1, result2) = target.callReturnBytes32Pair (data);
486
+ (success, result1, result2) = target.callReturn64Bytes (data);
487
487
}
488
488
----
489
489
490
490
You can also check return data size before processing:
491
491
492
492
[source,solidity]
493
493
----
494
- function checkReturnSize(address target, bytes memory data) internal returns (bool) {
495
- if (!target.callRaw(data)) {
496
- return false;
494
+ function checkReturnSize(address target, bytes memory data) internal returns (uint256 value, uint256 otherValue) {
495
+ (bool success, bytes32 result1, bytes32 result2) = target.callReturn64Bytes(data);
496
+
497
+ if (!success || LowLevelCall.returnDataSize() < 32) {
498
+ return (0, 0);
499
+ } else if (LowLevelCall.returnDataSize() < 64) {
500
+ return (uint256(result1), 0);
501
+ } else {
502
+ return (uint256(result1), uint256(result2));
497
503
}
498
-
499
- return LowLevelCall.returnDataSize() >= 32;
500
504
}
501
505
----
502
506
0 commit comments