-
Notifications
You must be signed in to change notification settings - Fork 11.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add wrapper function for low level calls (#2264)
* feat: add wrapper function for low level calls * add error message parameter * adding unit tests and required mocks * implement error message on SafeERC20 * fixed variable name in tests * Add missing tests * Improve docs. * Add functionCallWithValue * Add functionCallWithValue * Skip balance check on non-value functionCall variants * Increase out of gas test timeout * Fix compile errors * Apply suggestions from code review Co-authored-by: Francisco Giordano <frangio.1@gmail.com> * Add missing tests * Add changelog entry Co-authored-by: Nicolás Venturo <nicolas.venturo@gmail.com> Co-authored-by: Francisco Giordano <frangio.1@gmail.com>
- Loading branch information
1 parent
d9fa59f
commit 8b58fc7
Showing
8 changed files
with
329 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.6.0; | ||
|
||
contract CallReceiverMock { | ||
|
||
event MockFunctionCalled(); | ||
|
||
uint256[] private _array; | ||
|
||
function mockFunction() public payable returns (string memory) { | ||
emit MockFunctionCalled(); | ||
|
||
return "0x1234"; | ||
} | ||
|
||
function mockFunctionNonPayable() public returns (string memory) { | ||
emit MockFunctionCalled(); | ||
|
||
return "0x1234"; | ||
} | ||
|
||
function mockFunctionRevertsNoReason() public payable { | ||
revert(); | ||
} | ||
|
||
function mockFunctionRevertsReason() public payable { | ||
revert("CallReceiverMock: reverting"); | ||
} | ||
|
||
function mockFunctionThrows() public payable { | ||
assert(false); | ||
} | ||
|
||
function mockFunctionOutOfGas() public payable { | ||
for (uint256 i = 0; ; ++i) { | ||
_array.push(i); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.