Skip to content

Commit 0a3b2cc

Browse files
authored
Update utilities.adoc
1 parent 45e8d66 commit 0a3b2cc

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

docs/modules/ROOT/pages/utilities.adoc

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -477,26 +477,30 @@ function example(address target, bytes memory data) internal {
477477
bytes32 result2;
478478
479479
// Ignore return data
480-
success = target.callRaw(data);
480+
success = target.callNoReturn(data);
481481
482482
// Extract single 32-byte value
483-
(success, result1) = target.callReturnBytes32(data);
483+
(success, result1, ) = target.callReturn64Bytes(data);
484484
485485
// Extract two 32-byte values
486-
(success, result1, result2) = target.callReturnBytes32Pair(data);
486+
(success, result1, result2) = target.callReturn64Bytes(data);
487487
}
488488
----
489489

490490
You can also check return data size before processing:
491491

492492
[source,solidity]
493493
----
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));
497503
}
498-
499-
return LowLevelCall.returnDataSize() >= 32;
500504
}
501505
----
502506

0 commit comments

Comments
 (0)