Merge branch 'solc-0.7' into solc-0.8
This commit is contained in:
32
contracts/mocks/ClonesMock.sol
Normal file
32
contracts/mocks/ClonesMock.sol
Normal file
@ -0,0 +1,32 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
pragma solidity >=0.6.0 <0.9.0;
|
||||
|
||||
import "../proxy/Clones.sol";
|
||||
import "../utils/Address.sol";
|
||||
|
||||
contract ClonesMock {
|
||||
using Address for address;
|
||||
using Clones for address;
|
||||
|
||||
event NewInstance(address instance);
|
||||
|
||||
function clone(address master, bytes calldata initdata) public payable {
|
||||
_initAndEmit(master.clone(), initdata);
|
||||
}
|
||||
|
||||
function cloneDeterministic(address master, bytes32 salt, bytes calldata initdata) public payable {
|
||||
_initAndEmit(master.cloneDeterministic(salt), initdata);
|
||||
}
|
||||
|
||||
function predictDeterministicAddress(address master, bytes32 salt) public view returns (address predicted) {
|
||||
return master.predictDeterministicAddress(salt);
|
||||
}
|
||||
|
||||
function _initAndEmit(address instance, bytes memory initdata) private {
|
||||
if (initdata.length > 0) {
|
||||
instance.functionCallWithValue(initdata, msg.value);
|
||||
}
|
||||
emit NewInstance(instance);
|
||||
}
|
||||
}
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
pragma solidity ^0.8.0;
|
||||
|
||||
import "../GSN/Context.sol";
|
||||
import "../utils/Context.sol";
|
||||
|
||||
contract ContextMock is Context {
|
||||
event Sender(address sender);
|
||||
|
||||
@ -18,4 +18,8 @@ contract ERC165CheckerMock {
|
||||
function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) public view returns (bool) {
|
||||
return account.supportsAllInterfaces(interfaceIds);
|
||||
}
|
||||
|
||||
function getSupportedInterfaces(address account, bytes4[] memory interfaceIds) public view returns (bool[] memory) {
|
||||
return account.getSupportedInterfaces(interfaceIds);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,10 +2,12 @@
|
||||
|
||||
pragma solidity ^0.8.0;
|
||||
|
||||
import "../GSN/Context.sol";
|
||||
import "../utils/Context.sol";
|
||||
import "../token/ERC777/ERC777.sol";
|
||||
|
||||
contract ERC777Mock is Context, ERC777 {
|
||||
event BeforeTokenTransfer();
|
||||
|
||||
constructor(
|
||||
address initialHolder,
|
||||
uint256 initialBalance,
|
||||
@ -28,4 +30,8 @@ contract ERC777Mock is Context, ERC777 {
|
||||
function approveInternal(address holder, address spender, uint256 value) public {
|
||||
_approve(holder, spender, value);
|
||||
}
|
||||
|
||||
function _beforeTokenTransfer(address, address, address, uint256) internal override {
|
||||
emit BeforeTokenTransfer();
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
pragma solidity ^0.8.0;
|
||||
|
||||
import "../GSN/Context.sol";
|
||||
import "../utils/Context.sol";
|
||||
import "../token/ERC777/IERC777.sol";
|
||||
import "../token/ERC777/IERC777Sender.sol";
|
||||
import "../token/ERC777/IERC777Recipient.sol";
|
||||
@ -34,6 +34,9 @@ contract ERC777SenderRecipientMock is Context, IERC777Sender, IERC777Recipient,
|
||||
uint256 toBalance
|
||||
);
|
||||
|
||||
// Emitted in ERC777Mock. Here for easier decoding
|
||||
event BeforeTokenTransfer();
|
||||
|
||||
bool private _shouldRevertSend;
|
||||
bool private _shouldRevertReceive;
|
||||
|
||||
|
||||
@ -34,7 +34,15 @@ contract EnumerableMapMock {
|
||||
}
|
||||
|
||||
|
||||
function tryGet(uint256 key) public view returns (bool, address) {
|
||||
return _map.tryGet(key);
|
||||
}
|
||||
|
||||
function get(uint256 key) public view returns (address) {
|
||||
return _map.get(key);
|
||||
}
|
||||
|
||||
function getWithMessage(uint256 key, string calldata errorMessage) public view returns (address) {
|
||||
return _map.get(key, errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@ contract GSNRecipientMock is ContextMock, GSNRecipient {
|
||||
|
||||
function acceptRelayedCall(address, address, bytes calldata, uint256, uint256, uint256, uint256, bytes calldata, uint256)
|
||||
external
|
||||
view
|
||||
pure
|
||||
override
|
||||
returns (uint256, bytes memory)
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
pragma solidity ^0.8.0;
|
||||
|
||||
import "../GSN/Context.sol";
|
||||
import "../utils/Context.sol";
|
||||
contract ReentrancyAttack is Context {
|
||||
function callSender(bytes4 data) public {
|
||||
// solhint-disable-next-line avoid-low-level-calls
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
pragma solidity ^0.8.0;
|
||||
|
||||
import "../GSN/Context.sol";
|
||||
import "../utils/Context.sol";
|
||||
import "../token/ERC20/IERC20.sol";
|
||||
import "../token/ERC20/SafeERC20.sol";
|
||||
|
||||
|
||||
@ -5,6 +5,34 @@ pragma solidity ^0.8.0;
|
||||
import "../math/SafeMath.sol";
|
||||
|
||||
contract SafeMathMock {
|
||||
function tryAdd(uint256 a, uint256 b) public pure returns (bool flag, uint256 value) {
|
||||
return SafeMath.tryAdd(a, b);
|
||||
}
|
||||
|
||||
function trySub(uint256 a, uint256 b) public pure returns (bool flag, uint256 value) {
|
||||
return SafeMath.trySub(a, b);
|
||||
}
|
||||
|
||||
function tryMul(uint256 a, uint256 b) public pure returns (bool flag, uint256 value) {
|
||||
return SafeMath.tryMul(a, b);
|
||||
}
|
||||
|
||||
function tryDiv(uint256 a, uint256 b) public pure returns (bool flag, uint256 value) {
|
||||
return SafeMath.tryDiv(a, b);
|
||||
}
|
||||
|
||||
function tryMod(uint256 a, uint256 b) public pure returns (bool flag, uint256 value) {
|
||||
return SafeMath.tryMod(a, b);
|
||||
}
|
||||
|
||||
function add(uint256 a, uint256 b) public pure returns (uint256) {
|
||||
return SafeMath.add(a, b);
|
||||
}
|
||||
|
||||
function sub(uint256 a, uint256 b) public pure returns (uint256) {
|
||||
return SafeMath.sub(a, b);
|
||||
}
|
||||
|
||||
function mul(uint256 a, uint256 b) public pure returns (uint256) {
|
||||
return SafeMath.mul(a, b);
|
||||
}
|
||||
@ -13,15 +41,65 @@ contract SafeMathMock {
|
||||
return SafeMath.div(a, b);
|
||||
}
|
||||
|
||||
function sub(uint256 a, uint256 b) public pure returns (uint256) {
|
||||
return SafeMath.sub(a, b);
|
||||
}
|
||||
|
||||
function add(uint256 a, uint256 b) public pure returns (uint256) {
|
||||
return SafeMath.add(a, b);
|
||||
}
|
||||
|
||||
function mod(uint256 a, uint256 b) public pure returns (uint256) {
|
||||
return SafeMath.mod(a, b);
|
||||
}
|
||||
|
||||
function subWithMessage(uint256 a, uint256 b, string memory errorMessage) public pure returns (uint256) {
|
||||
return SafeMath.sub(a, b, errorMessage);
|
||||
}
|
||||
|
||||
function divWithMessage(uint256 a, uint256 b, string memory errorMessage) public pure returns (uint256) {
|
||||
return SafeMath.div(a, b, errorMessage);
|
||||
}
|
||||
|
||||
function modWithMessage(uint256 a, uint256 b, string memory errorMessage) public pure returns (uint256) {
|
||||
return SafeMath.mod(a, b, errorMessage);
|
||||
}
|
||||
|
||||
function addMemoryCheck() public pure returns (uint256 mem) {
|
||||
uint256 length = 32;
|
||||
// solhint-disable-next-line no-inline-assembly
|
||||
assembly { mem := mload(0x40) }
|
||||
for (uint256 i = 0; i < length; ++i) { SafeMath.add(1, 1); }
|
||||
// solhint-disable-next-line no-inline-assembly
|
||||
assembly { mem := sub(mload(0x40), mem) }
|
||||
}
|
||||
|
||||
function subMemoryCheck() public pure returns (uint256 mem) {
|
||||
uint256 length = 32;
|
||||
// solhint-disable-next-line no-inline-assembly
|
||||
assembly { mem := mload(0x40) }
|
||||
for (uint256 i = 0; i < length; ++i) { SafeMath.sub(1, 1); }
|
||||
// solhint-disable-next-line no-inline-assembly
|
||||
assembly { mem := sub(mload(0x40), mem) }
|
||||
}
|
||||
|
||||
function mulMemoryCheck() public pure returns (uint256 mem) {
|
||||
uint256 length = 32;
|
||||
// solhint-disable-next-line no-inline-assembly
|
||||
assembly { mem := mload(0x40) }
|
||||
for (uint256 i = 0; i < length; ++i) { SafeMath.mul(1, 1); }
|
||||
// solhint-disable-next-line no-inline-assembly
|
||||
assembly { mem := sub(mload(0x40), mem) }
|
||||
}
|
||||
|
||||
function divMemoryCheck() public pure returns (uint256 mem) {
|
||||
uint256 length = 32;
|
||||
// solhint-disable-next-line no-inline-assembly
|
||||
assembly { mem := mload(0x40) }
|
||||
for (uint256 i = 0; i < length; ++i) { SafeMath.div(1, 1); }
|
||||
// solhint-disable-next-line no-inline-assembly
|
||||
assembly { mem := sub(mload(0x40), mem) }
|
||||
}
|
||||
|
||||
function modMemoryCheck() public pure returns (uint256 mem) {
|
||||
uint256 length = 32;
|
||||
// solhint-disable-next-line no-inline-assembly
|
||||
assembly { mem := mload(0x40) }
|
||||
for (uint256 i = 0; i < length; ++i) { SafeMath.mod(1, 1); }
|
||||
// solhint-disable-next-line no-inline-assembly
|
||||
assembly { mem := sub(mload(0x40), mem) }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user