Commit 8a436ac2 by Francisco Giordano

make contracts upgrade safe

parent de99bccb
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "../Initializable.sol";
/* /*
* @dev Provides information about the current execution context, including the * @dev Provides information about the current execution context, including the
...@@ -12,7 +13,16 @@ pragma solidity ^0.6.0; ...@@ -12,7 +13,16 @@ pragma solidity ^0.6.0;
* *
* This contract is only required for intermediate, library-like contracts. * This contract is only required for intermediate, library-like contracts.
*/ */
abstract contract Context { abstract contract ContextUpgradeSafe is Initializable {
function __Context_init() internal initializer {
__Context_init_unchained();
}
function __Context_init_unchained() internal initializer {
}
function _msgSender() internal view virtual returns (address payable) { function _msgSender() internal view virtual returns (address payable) {
return msg.sender; return msg.sender;
} }
...@@ -21,4 +31,6 @@ abstract contract Context { ...@@ -21,4 +31,6 @@ abstract contract Context {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data; return msg.data;
} }
uint256[50] private __gap;
} }
...@@ -5,6 +5,7 @@ pragma solidity ^0.6.0; ...@@ -5,6 +5,7 @@ pragma solidity ^0.6.0;
import "./IRelayRecipient.sol"; import "./IRelayRecipient.sol";
import "./IRelayHub.sol"; import "./IRelayHub.sol";
import "./Context.sol"; import "./Context.sol";
import "../Initializable.sol";
/** /**
* @dev Base GSN recipient contract: includes the {IRelayRecipient} interface * @dev Base GSN recipient contract: includes the {IRelayRecipient} interface
...@@ -17,9 +18,20 @@ import "./Context.sol"; ...@@ -17,9 +18,20 @@ import "./Context.sol";
* information on how to use the pre-built {GSNRecipientSignature} and * information on how to use the pre-built {GSNRecipientSignature} and
* {GSNRecipientERC20Fee}, or how to write your own. * {GSNRecipientERC20Fee}, or how to write your own.
*/ */
abstract contract GSNRecipient is IRelayRecipient, Context { abstract contract GSNRecipientUpgradeSafe is Initializable, IRelayRecipient, ContextUpgradeSafe {
function __GSNRecipient_init() internal initializer {
__Context_init_unchained();
__GSNRecipient_init_unchained();
}
function __GSNRecipient_init_unchained() internal initializer {
_relayHub = 0xD216153c06E857cD7f72665E0aF1d7D82172F494;
}
// Default RelayHub address, deployed on mainnet and all testnets at the same address // Default RelayHub address, deployed on mainnet and all testnets at the same address
address private _relayHub = 0xD216153c06E857cD7f72665E0aF1d7D82172F494; address private _relayHub ;
uint256 constant private _RELAYED_CALL_ACCEPTED = 0; uint256 constant private _RELAYED_CALL_ACCEPTED = 0;
uint256 constant private _RELAYED_CALL_REJECTED = 11; uint256 constant private _RELAYED_CALL_REJECTED = 11;
...@@ -227,4 +239,6 @@ abstract contract GSNRecipient is IRelayRecipient, Context { ...@@ -227,4 +239,6 @@ abstract contract GSNRecipient is IRelayRecipient, Context {
return actualData; return actualData;
} }
uint256[49] private __gap;
} }
...@@ -7,6 +7,7 @@ import "../math/SafeMath.sol"; ...@@ -7,6 +7,7 @@ import "../math/SafeMath.sol";
import "../access/Ownable.sol"; import "../access/Ownable.sol";
import "../token/ERC20/SafeERC20.sol"; import "../token/ERC20/SafeERC20.sol";
import "../token/ERC20/ERC20.sol"; import "../token/ERC20/ERC20.sol";
import "../Initializable.sol";
/** /**
* @dev A xref:ROOT:gsn-strategies.adoc#gsn-strategies[GSN strategy] that charges transaction fees in a special purpose ERC20 * @dev A xref:ROOT:gsn-strategies.adoc#gsn-strategies[GSN strategy] that charges transaction fees in a special purpose ERC20
...@@ -17,7 +18,7 @@ import "../token/ERC20/ERC20.sol"; ...@@ -17,7 +18,7 @@ import "../token/ERC20/ERC20.sol";
* whose only minter is the recipient, so the strategy must be implemented in a derived contract, making use of the * whose only minter is the recipient, so the strategy must be implemented in a derived contract, making use of the
* internal {_mint} function. * internal {_mint} function.
*/ */
contract GSNRecipientERC20Fee is GSNRecipient { contract GSNRecipientERC20FeeUpgradeSafe is Initializable, GSNRecipientUpgradeSafe {
using SafeERC20 for __unstable__ERC20Owned; using SafeERC20 for __unstable__ERC20Owned;
using SafeMath for uint256; using SafeMath for uint256;
...@@ -30,10 +31,21 @@ contract GSNRecipientERC20Fee is GSNRecipient { ...@@ -30,10 +31,21 @@ contract GSNRecipientERC20Fee is GSNRecipient {
/** /**
* @dev The arguments to the constructor are the details that the gas payment token will have: `name` and `symbol`. `decimals` is hard-coded to 18. * @dev The arguments to the constructor are the details that the gas payment token will have: `name` and `symbol`. `decimals` is hard-coded to 18.
*/ */
constructor(string memory name, string memory symbol) public {
function __GSNRecipientERC20Fee_init(string memory name, string memory symbol) internal initializer {
__Context_init_unchained();
__GSNRecipient_init_unchained();
__GSNRecipientERC20Fee_init_unchained(name, symbol);
}
function __GSNRecipientERC20Fee_init_unchained(string memory name, string memory symbol) internal initializer {
_token = new __unstable__ERC20Owned(name, symbol); _token = new __unstable__ERC20Owned(name, symbol);
} }
/** /**
* @dev Returns the gas payment token. * @dev Returns the gas payment token.
*/ */
...@@ -104,6 +116,8 @@ contract GSNRecipientERC20Fee is GSNRecipient { ...@@ -104,6 +116,8 @@ contract GSNRecipientERC20Fee is GSNRecipient {
// After the relayed call has been executed and the actual charge estimated, the excess pre-charge is returned // After the relayed call has been executed and the actual charge estimated, the excess pre-charge is returned
_token.safeTransfer(from, maxPossibleCharge.sub(actualCharge)); _token.safeTransfer(from, maxPossibleCharge.sub(actualCharge));
} }
uint256[49] private __gap;
} }
/** /**
...@@ -113,10 +127,26 @@ contract GSNRecipientERC20Fee is GSNRecipient { ...@@ -113,10 +127,26 @@ contract GSNRecipientERC20Fee is GSNRecipient {
* outside of this context. * outside of this context.
*/ */
// solhint-disable-next-line contract-name-camelcase // solhint-disable-next-line contract-name-camelcase
contract __unstable__ERC20Owned is ERC20, Ownable { contract __unstable__ERC20Owned is Initializable, ERC20UpgradeSafe, OwnableUpgradeSafe {
uint256 private constant _UINT256_MAX = 2**256 - 1; uint256 private constant _UINT256_MAX = 2**256 - 1;
constructor(string memory name, string memory symbol) public ERC20(name, symbol) { }
constructor(string memory name, string memory symbol) public {
____unstable__ERC20Owned_init(name, symbol);
}
function ____unstable__ERC20Owned_init(string memory name, string memory symbol) internal initializer {
__Context_init_unchained();
__ERC20_init_unchained(name, symbol);
__Ownable_init_unchained();
____unstable__ERC20Owned_init_unchained(name, symbol);
}
function ____unstable__ERC20Owned_init_unchained(string memory name, string memory symbol) internal initializer {
}
// The owner (GSNRecipientERC20Fee) can mint tokens // The owner (GSNRecipientERC20Fee) can mint tokens
function mint(address account, uint256 amount) public onlyOwner { function mint(address account, uint256 amount) public onlyOwner {
...@@ -149,4 +179,6 @@ contract __unstable__ERC20Owned is ERC20, Ownable { ...@@ -149,4 +179,6 @@ contract __unstable__ERC20Owned is ERC20, Ownable {
return super.transferFrom(sender, recipient, amount); return super.transferFrom(sender, recipient, amount);
} }
} }
uint256[50] private __gap;
} }
...@@ -4,6 +4,7 @@ pragma solidity ^0.6.0; ...@@ -4,6 +4,7 @@ pragma solidity ^0.6.0;
import "./GSNRecipient.sol"; import "./GSNRecipient.sol";
import "../cryptography/ECDSA.sol"; import "../cryptography/ECDSA.sol";
import "../Initializable.sol";
/** /**
* @dev A xref:ROOT:gsn-strategies.adoc#gsn-strategies[GSN strategy] that allows relayed transactions through when they are * @dev A xref:ROOT:gsn-strategies.adoc#gsn-strategies[GSN strategy] that allows relayed transactions through when they are
...@@ -11,7 +12,7 @@ import "../cryptography/ECDSA.sol"; ...@@ -11,7 +12,7 @@ import "../cryptography/ECDSA.sol";
* performs validations off-chain. Note that nothing is charged to the user in this scheme. Thus, the server should make * performs validations off-chain. Note that nothing is charged to the user in this scheme. Thus, the server should make
* sure to account for this in their economic and threat model. * sure to account for this in their economic and threat model.
*/ */
contract GSNRecipientSignature is GSNRecipient { contract GSNRecipientSignatureUpgradeSafe is Initializable, GSNRecipientUpgradeSafe {
using ECDSA for bytes32; using ECDSA for bytes32;
address private _trustedSigner; address private _trustedSigner;
...@@ -23,11 +24,22 @@ contract GSNRecipientSignature is GSNRecipient { ...@@ -23,11 +24,22 @@ contract GSNRecipientSignature is GSNRecipient {
/** /**
* @dev Sets the trusted signer that is going to be producing signatures to approve relayed calls. * @dev Sets the trusted signer that is going to be producing signatures to approve relayed calls.
*/ */
constructor(address trustedSigner) public {
function __GSNRecipientSignature_init(address trustedSigner) internal initializer {
__Context_init_unchained();
__GSNRecipient_init_unchained();
__GSNRecipientSignature_init_unchained(trustedSigner);
}
function __GSNRecipientSignature_init_unchained(address trustedSigner) internal initializer {
require(trustedSigner != address(0), "GSNRecipientSignature: trusted signer is the zero address"); require(trustedSigner != address(0), "GSNRecipientSignature: trusted signer is the zero address");
_trustedSigner = trustedSigner; _trustedSigner = trustedSigner;
} }
/** /**
* @dev Ensures that only transactions with a trusted signature can be relayed through the GSN. * @dev Ensures that only transactions with a trusted signature can be relayed through the GSN.
*/ */
...@@ -69,4 +81,6 @@ contract GSNRecipientSignature is GSNRecipient { ...@@ -69,4 +81,6 @@ contract GSNRecipientSignature is GSNRecipient {
function _preRelayedCall(bytes memory) internal virtual override returns (bytes32) { } function _preRelayedCall(bytes memory) internal virtual override returns (bytes32) { }
function _postRelayedCall(bytes memory, bool, uint256, bytes32) internal virtual override { } function _postRelayedCall(bytes memory, bool, uint256, bytes32) internal virtual override { }
uint256[49] private __gap;
} }
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.24 <0.7.0;
/**
* @title Initializable
*
* @dev Helper contract to support initializer functions. To use it, replace
* the constructor with a function that has the `initializer` modifier.
* WARNING: Unlike constructors, initializer functions must be manually
* invoked. This applies both to deploying an Initializable contract, as well
* as extending an Initializable contract via inheritance.
* WARNING: When used with inheritance, manual care must be taken to not invoke
* a parent initializer twice, or ensure that all initializers are idempotent,
* because this is not dealt with automatically as with constructors.
*/
contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
*/
bool private initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private initializing;
/**
* @dev Modifier to use in the initializer function of a contract.
*/
modifier initializer() {
require(initializing || isConstructor() || !initialized, "Contract instance has already been initialized");
bool isTopLevelCall = !initializing;
if (isTopLevelCall) {
initializing = true;
initialized = true;
}
_;
if (isTopLevelCall) {
initializing = false;
}
}
/// @dev Returns true if and only if the function is running in the constructor
function isConstructor() private view returns (bool) {
// extcodesize checks the size of the code stored in an address, and
// address returns the current address. Since the code is still not
// deployed when running a constructor, any checks on its code size will
// yield zero, making it an effective way to detect if a contract is
// under construction or not.
address self = address(this);
uint256 cs;
assembly { cs := extcodesize(self) }
return cs == 0;
}
// Reserved storage space to allow for layout changes in the future.
uint256[50] private ______gap;
}
...@@ -5,6 +5,7 @@ pragma solidity ^0.6.0; ...@@ -5,6 +5,7 @@ pragma solidity ^0.6.0;
import "../utils/EnumerableSet.sol"; import "../utils/EnumerableSet.sol";
import "../utils/Address.sol"; import "../utils/Address.sol";
import "../GSN/Context.sol"; import "../GSN/Context.sol";
import "../Initializable.sol";
/** /**
* @dev Contract module that allows children to implement role-based access * @dev Contract module that allows children to implement role-based access
...@@ -41,7 +42,17 @@ import "../GSN/Context.sol"; ...@@ -41,7 +42,17 @@ import "../GSN/Context.sol";
* grant and revoke this role. Extra precautions should be taken to secure * grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it. * accounts that have been granted it.
*/ */
abstract contract AccessControl is Context { abstract contract AccessControlUpgradeSafe is Initializable, ContextUpgradeSafe {
function __AccessControl_init() internal initializer {
__Context_init_unchained();
__AccessControl_init_unchained();
}
function __AccessControl_init_unchained() internal initializer {
}
using EnumerableSet for EnumerableSet.AddressSet; using EnumerableSet for EnumerableSet.AddressSet;
using Address for address; using Address for address;
...@@ -214,4 +225,6 @@ abstract contract AccessControl is Context { ...@@ -214,4 +225,6 @@ abstract contract AccessControl is Context {
emit RoleRevoked(role, account, _msgSender()); emit RoleRevoked(role, account, _msgSender());
} }
} }
uint256[49] private __gap;
} }
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "../GSN/Context.sol"; import "../GSN/Context.sol";
import "../Initializable.sol";
/** /**
* @dev Contract module which provides a basic access control mechanism, where * @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to * there is an account (an owner) that can be granted exclusive access to
...@@ -15,7 +16,7 @@ import "../GSN/Context.sol"; ...@@ -15,7 +16,7 @@ import "../GSN/Context.sol";
* `onlyOwner`, which can be applied to your functions to restrict their use to * `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner. * the owner.
*/ */
contract Ownable is Context { contract OwnableUpgradeSafe is Initializable, ContextUpgradeSafe {
address private _owner; address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
...@@ -23,12 +24,22 @@ contract Ownable is Context { ...@@ -23,12 +24,22 @@ contract Ownable is Context {
/** /**
* @dev Initializes the contract setting the deployer as the initial owner. * @dev Initializes the contract setting the deployer as the initial owner.
*/ */
constructor () internal {
function __Ownable_init() internal initializer {
__Context_init_unchained();
__Ownable_init_unchained();
}
function __Ownable_init_unchained() internal initializer {
address msgSender = _msgSender(); address msgSender = _msgSender();
_owner = msgSender; _owner = msgSender;
emit OwnershipTransferred(address(0), msgSender); emit OwnershipTransferred(address(0), msgSender);
} }
/** /**
* @dev Returns the address of the current owner. * @dev Returns the address of the current owner.
*/ */
...@@ -65,4 +76,6 @@ contract Ownable is Context { ...@@ -65,4 +76,6 @@ contract Ownable is Context {
emit OwnershipTransferred(_owner, newOwner); emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner; _owner = newOwner;
} }
uint256[49] private __gap;
} }
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "./IERC165.sol"; import "./IERC165.sol";
import "../Initializable.sol";
/** /**
* @dev Implementation of the {IERC165} interface. * @dev Implementation of the {IERC165} interface.
...@@ -10,7 +11,7 @@ import "./IERC165.sol"; ...@@ -10,7 +11,7 @@ import "./IERC165.sol";
* Contracts may inherit from this and call {_registerInterface} to declare * Contracts may inherit from this and call {_registerInterface} to declare
* their support of an interface. * their support of an interface.
*/ */
contract ERC165 is IERC165 { contract ERC165UpgradeSafe is Initializable, IERC165 {
/* /*
* bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7 * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7
*/ */
...@@ -21,12 +22,21 @@ contract ERC165 is IERC165 { ...@@ -21,12 +22,21 @@ contract ERC165 is IERC165 {
*/ */
mapping(bytes4 => bool) private _supportedInterfaces; mapping(bytes4 => bool) private _supportedInterfaces;
constructor () internal {
function __ERC165_init() internal initializer {
__ERC165_init_unchained();
}
function __ERC165_init_unchained() internal initializer {
// Derived contracts need only register support for their own interfaces, // Derived contracts need only register support for their own interfaces,
// we register support for ERC165 itself here // we register support for ERC165 itself here
_registerInterface(_INTERFACE_ID_ERC165); _registerInterface(_INTERFACE_ID_ERC165);
} }
/** /**
* @dev See {IERC165-supportsInterface}. * @dev See {IERC165-supportsInterface}.
* *
...@@ -51,4 +61,6 @@ contract ERC165 is IERC165 { ...@@ -51,4 +61,6 @@ contract ERC165 is IERC165 {
require(interfaceId != 0xffffffff, "ERC165: invalid interface id"); require(interfaceId != 0xffffffff, "ERC165: invalid interface id");
_supportedInterfaces[interfaceId] = true; _supportedInterfaces[interfaceId] = true;
} }
uint256[49] private __gap;
} }
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "./IERC1820Implementer.sol"; import "./IERC1820Implementer.sol";
import "../Initializable.sol";
/** /**
* @dev Implementation of the {IERC1820Implementer} interface. * @dev Implementation of the {IERC1820Implementer} interface.
...@@ -12,7 +13,16 @@ import "./IERC1820Implementer.sol"; ...@@ -12,7 +13,16 @@ import "./IERC1820Implementer.sol";
* {IERC1820Registry-setInterfaceImplementer} should then be called for the * {IERC1820Registry-setInterfaceImplementer} should then be called for the
* registration to be complete. * registration to be complete.
*/ */
contract ERC1820Implementer is IERC1820Implementer { contract ERC1820ImplementerUpgradeSafe is Initializable, IERC1820Implementer {
function __ERC1820Implementer_init() internal initializer {
__ERC1820Implementer_init_unchained();
}
function __ERC1820Implementer_init_unchained() internal initializer {
}
bytes32 constant private _ERC1820_ACCEPT_MAGIC = keccak256(abi.encodePacked("ERC1820_ACCEPT_MAGIC")); bytes32 constant private _ERC1820_ACCEPT_MAGIC = keccak256(abi.encodePacked("ERC1820_ACCEPT_MAGIC"));
mapping(bytes32 => mapping(address => bool)) private _supportedInterfaces; mapping(bytes32 => mapping(address => bool)) private _supportedInterfaces;
...@@ -34,4 +44,6 @@ contract ERC1820Implementer is IERC1820Implementer { ...@@ -34,4 +44,6 @@ contract ERC1820Implementer is IERC1820Implementer {
function _registerInterfaceForAddress(bytes32 interfaceHash, address account) internal virtual { function _registerInterfaceForAddress(bytes32 interfaceHash, address account) internal virtual {
_supportedInterfaces[interfaceHash][account] = true; _supportedInterfaces[interfaceHash][account] = true;
} }
uint256[49] private __gap;
} }
...@@ -3,13 +3,31 @@ ...@@ -3,13 +3,31 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "../access/AccessControl.sol"; import "../access/AccessControl.sol";
import "../Initializable.sol";
contract AccessControlMockUpgradeSafe is Initializable, AccessControlUpgradeSafe {
constructor() public {
__AccessControlMock_init();
}
function __AccessControlMock_init() internal initializer {
__Context_init_unchained();
__AccessControl_init_unchained();
__AccessControlMock_init_unchained();
}
function __AccessControlMock_init_unchained() internal initializer {
contract AccessControlMock is AccessControl {
constructor() public {
_setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
} }
function setRoleAdmin(bytes32 roleId, bytes32 adminRoleId) public { function setRoleAdmin(bytes32 roleId, bytes32 adminRoleId) public {
_setRoleAdmin(roleId, adminRoleId); _setRoleAdmin(roleId, adminRoleId);
} }
uint256[50] private __gap;
} }
...@@ -3,8 +3,22 @@ ...@@ -3,8 +3,22 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "../utils/Address.sol"; import "../utils/Address.sol";
import "../Initializable.sol";
contract AddressImplUpgradeSafe is Initializable {
constructor() public {
__AddressImpl_init();
}
function __AddressImpl_init() internal initializer {
__AddressImpl_init_unchained();
}
function __AddressImpl_init_unchained() internal initializer {
}
contract AddressImpl {
event CallReturnValue(string data); event CallReturnValue(string data);
function isContract(address account) external view returns (bool) { function isContract(address account) external view returns (bool) {
...@@ -29,4 +43,6 @@ contract AddressImpl { ...@@ -29,4 +43,6 @@ contract AddressImpl {
// sendValue's tests require the contract to hold Ether // sendValue's tests require the contract to hold Ether
receive () external payable { } receive () external payable { }
uint256[50] private __gap;
} }
...@@ -3,17 +3,33 @@ ...@@ -3,17 +3,33 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "../utils/Arrays.sol"; import "../utils/Arrays.sol";
import "../Initializable.sol";
contract ArraysImpl { contract ArraysMockUpgradeSafe is Initializable {
using Arrays for uint256[]; using Arrays for uint256[];
uint256[] private _array; uint256[] private _array;
constructor (uint256[] memory array) public {
constructor(uint256[] memory array) public {
__ArraysMock_init(array);
}
function __ArraysMock_init(uint256[] memory array) internal initializer {
__ArraysMock_init_unchained(array);
}
function __ArraysMock_init_unchained(uint256[] memory array) internal initializer {
_array = array; _array = array;
} }
function findUpperBound(uint256 element) external view returns (uint256) { function findUpperBound(uint256 element) external view returns (uint256) {
return _array.findUpperBound(element); return _array.findUpperBound(element);
} }
uint256[49] private __gap;
} }
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "../Initializable.sol";
contract CallReceiverMockUpgradeSafe is Initializable {
constructor() public {
__CallReceiverMock_init();
}
function __CallReceiverMock_init() internal initializer {
__CallReceiverMock_init_unchained();
}
function __CallReceiverMock_init_unchained() internal initializer {
}
contract CallReceiverMock {
event MockFunctionCalled(); event MockFunctionCalled();
...@@ -37,4 +51,6 @@ contract CallReceiverMock { ...@@ -37,4 +51,6 @@ contract CallReceiverMock {
_array.push(i); _array.push(i);
} }
} }
uint256[49] private __gap;
} }
...@@ -3,9 +3,27 @@ ...@@ -3,9 +3,27 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "../payment/escrow/ConditionalEscrow.sol"; import "../payment/escrow/ConditionalEscrow.sol";
import "../Initializable.sol";
// mock class using ConditionalEscrow // mock class using ConditionalEscrow
contract ConditionalEscrowMock is ConditionalEscrow { contract ConditionalEscrowMockUpgradeSafe is Initializable, ConditionalEscrowUpgradeSafe {
constructor() public {
__ConditionalEscrowMock_init();
}
function __ConditionalEscrowMock_init() internal initializer {
__Context_init_unchained();
__Ownable_init_unchained();
__Escrow_init_unchained();
__ConditionalEscrow_init_unchained();
__ConditionalEscrowMock_init_unchained();
}
function __ConditionalEscrowMock_init_unchained() internal initializer {
}
mapping(address => bool) private _allowed; mapping(address => bool) private _allowed;
function setAllowed(address payee, bool allowed) public { function setAllowed(address payee, bool allowed) public {
...@@ -15,4 +33,6 @@ contract ConditionalEscrowMock is ConditionalEscrow { ...@@ -15,4 +33,6 @@ contract ConditionalEscrowMock is ConditionalEscrow {
function withdrawalAllowed(address payee) public view override returns (bool) { function withdrawalAllowed(address payee) public view override returns (bool) {
return _allowed[payee]; return _allowed[payee];
} }
uint256[49] private __gap;
} }
...@@ -3,8 +3,23 @@ ...@@ -3,8 +3,23 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "../GSN/Context.sol"; import "../GSN/Context.sol";
import "../Initializable.sol";
contract ContextMockUpgradeSafe is Initializable, ContextUpgradeSafe {
constructor() public {
__ContextMock_init();
}
function __ContextMock_init() internal initializer {
__Context_init_unchained();
__ContextMock_init_unchained();
}
function __ContextMock_init_unchained() internal initializer {
}
contract ContextMock is Context {
event Sender(address sender); event Sender(address sender);
function msgSender() public { function msgSender() public {
...@@ -16,14 +31,31 @@ contract ContextMock is Context { ...@@ -16,14 +31,31 @@ contract ContextMock is Context {
function msgData(uint256 integerValue, string memory stringValue) public { function msgData(uint256 integerValue, string memory stringValue) public {
emit Data(_msgData(), integerValue, stringValue); emit Data(_msgData(), integerValue, stringValue);
} }
uint256[50] private __gap;
} }
contract ContextMockCaller { contract ContextMockCallerUpgradeSafe is Initializable {
function callSender(ContextMock context) public { constructor() public {
__ContextMockCaller_init();
}
function __ContextMockCaller_init() internal initializer {
__ContextMockCaller_init_unchained();
}
function __ContextMockCaller_init_unchained() internal initializer {
}
function callSender(ContextMockUpgradeSafe context) public {
context.msgSender(); context.msgSender();
} }
function callData(ContextMock context, uint256 integerValue, string memory stringValue) public { function callData(ContextMockUpgradeSafe context, uint256 integerValue, string memory stringValue) public {
context.msgData(integerValue, stringValue); context.msgData(integerValue, stringValue);
} }
uint256[50] private __gap;
} }
...@@ -3,8 +3,22 @@ ...@@ -3,8 +3,22 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "../utils/Counters.sol"; import "../utils/Counters.sol";
import "../Initializable.sol";
contract CountersMockUpgradeSafe is Initializable {
constructor() public {
__CountersMock_init();
}
function __CountersMock_init() internal initializer {
__CountersMock_init_unchained();
}
function __CountersMock_init_unchained() internal initializer {
}
contract CountersImpl {
using Counters for Counters.Counter; using Counters for Counters.Counter;
Counters.Counter private _counter; Counters.Counter private _counter;
...@@ -20,4 +34,6 @@ contract CountersImpl { ...@@ -20,4 +34,6 @@ contract CountersImpl {
function decrement() public { function decrement() public {
_counter.decrement(); _counter.decrement();
} }
uint256[49] private __gap;
} }
...@@ -4,15 +4,29 @@ pragma solidity ^0.6.0; ...@@ -4,15 +4,29 @@ pragma solidity ^0.6.0;
import "../utils/Create2.sol"; import "../utils/Create2.sol";
import "../introspection/ERC1820Implementer.sol"; import "../introspection/ERC1820Implementer.sol";
import "../Initializable.sol";
contract Create2MockUpgradeSafe is Initializable {
constructor() public {
__Create2Mock_init();
}
function __Create2Mock_init() internal initializer {
__Create2Mock_init_unchained();
}
function __Create2Mock_init_unchained() internal initializer {
}
contract Create2Impl {
function deploy(uint256 value, bytes32 salt, bytes memory code) public { function deploy(uint256 value, bytes32 salt, bytes memory code) public {
Create2.deploy(value, salt, code); Create2.deploy(value, salt, code);
} }
function deployERC1820Implementer(uint256 value, bytes32 salt) public { function deployERC1820Implementer(uint256 value, bytes32 salt) public {
// solhint-disable-next-line indent // solhint-disable-next-line indent
Create2.deploy(value, salt, type(ERC1820Implementer).creationCode); Create2.deploy(value, salt, type(ERC1820ImplementerUpgradeSafe).creationCode);
} }
function computeAddress(bytes32 salt, bytes32 codeHash) public view returns (address) { function computeAddress(bytes32 salt, bytes32 codeHash) public view returns (address) {
...@@ -24,4 +38,6 @@ contract Create2Impl { ...@@ -24,4 +38,6 @@ contract Create2Impl {
} }
receive() payable external {} receive() payable external {}
uint256[50] private __gap;
} }
...@@ -3,8 +3,22 @@ ...@@ -3,8 +3,22 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "../cryptography/ECDSA.sol"; import "../cryptography/ECDSA.sol";
import "../Initializable.sol";
contract ECDSAMockUpgradeSafe is Initializable {
constructor() public {
__ECDSAMock_init();
}
function __ECDSAMock_init() internal initializer {
__ECDSAMock_init_unchained();
}
function __ECDSAMock_init_unchained() internal initializer {
}
contract ECDSAMock {
using ECDSA for bytes32; using ECDSA for bytes32;
function recover(bytes32 hash, bytes memory signature) public pure returns (address) { function recover(bytes32 hash, bytes memory signature) public pure returns (address) {
...@@ -14,4 +28,6 @@ contract ECDSAMock { ...@@ -14,4 +28,6 @@ contract ECDSAMock {
function toEthSignedMessageHash(bytes32 hash) public pure returns (bytes32) { function toEthSignedMessageHash(bytes32 hash) public pure returns (bytes32) {
return hash.toEthSignedMessageHash(); return hash.toEthSignedMessageHash();
} }
uint256[50] private __gap;
} }
...@@ -3,11 +3,31 @@ ...@@ -3,11 +3,31 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "../token/ERC1155/ERC1155Burnable.sol"; import "../token/ERC1155/ERC1155Burnable.sol";
import "../Initializable.sol";
contract ERC1155BurnableMockUpgradeSafe is Initializable, ERC1155BurnableUpgradeSafe {
constructor(string memory uri) public {
__ERC1155BurnableMock_init(uri);
}
function __ERC1155BurnableMock_init(string memory uri) internal initializer {
__Context_init_unchained();
__ERC165_init_unchained();
__ERC1155_init_unchained(uri);
__ERC1155Burnable_init_unchained();
__ERC1155BurnableMock_init_unchained(uri);
}
function __ERC1155BurnableMock_init_unchained(string memory uri) internal initializer {
}
contract ERC1155BurnableMock is ERC1155Burnable {
constructor(string memory uri) public ERC1155(uri) { }
function mint(address to, uint256 id, uint256 value, bytes memory data) public { function mint(address to, uint256 id, uint256 value, bytes memory data) public {
_mint(to, id, value, data); _mint(to, id, value, data);
} }
uint256[50] private __gap;
} }
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
import "../token/ERC1155/ERC1155Holder.sol";
import "../Initializable.sol";
contract ERC1155HolderMockUpgradeSafe is Initializable, ERC1155HolderUpgradeSafe {
constructor() public {
__ERC1155HolderMock_init();
}
function __ERC1155HolderMock_init() internal initializer {
__ERC165_init_unchained();
__ERC1155Receiver_init_unchained();
__ERC1155Holder_init_unchained();
__ERC1155HolderMock_init_unchained();
}
function __ERC1155HolderMock_init_unchained() internal initializer {
}
uint256[50] private __gap;
}
...@@ -3,16 +3,33 @@ ...@@ -3,16 +3,33 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "../token/ERC1155/ERC1155.sol"; import "../token/ERC1155/ERC1155.sol";
import "../Initializable.sol";
/** /**
* @title ERC1155Mock * @title ERC1155Mock
* This mock just publicizes internal functions for testing purposes * This mock just publicizes internal functions for testing purposes
*/ */
contract ERC1155Mock is ERC1155 { contract ERC1155MockUpgradeSafe is Initializable, ERC1155UpgradeSafe {
constructor (string memory uri) public ERC1155(uri) {
constructor(string memory uri) public {
__ERC1155Mock_init(uri);
}
function __ERC1155Mock_init(string memory uri) internal initializer {
__Context_init_unchained();
__ERC165_init_unchained();
__ERC1155_init_unchained(uri);
__ERC1155Mock_init_unchained(uri);
}
function __ERC1155Mock_init_unchained(string memory uri) internal initializer {
// solhint-disable-previous-line no-empty-blocks // solhint-disable-previous-line no-empty-blocks
} }
function setURI(string memory newuri) public { function setURI(string memory newuri) public {
_setURI(newuri); _setURI(newuri);
} }
...@@ -32,4 +49,6 @@ contract ERC1155Mock is ERC1155 { ...@@ -32,4 +49,6 @@ contract ERC1155Mock is ERC1155 {
function burnBatch(address owner, uint256[] memory ids, uint256[] memory values) public { function burnBatch(address owner, uint256[] memory ids, uint256[] memory values) public {
_burnBatch(owner, ids, values); _burnBatch(owner, ids, values);
} }
uint256[50] private __gap;
} }
...@@ -4,9 +4,29 @@ pragma solidity ^0.6.0; ...@@ -4,9 +4,29 @@ pragma solidity ^0.6.0;
import "./ERC1155Mock.sol"; import "./ERC1155Mock.sol";
import "../token/ERC1155/ERC1155Pausable.sol"; import "../token/ERC1155/ERC1155Pausable.sol";
import "../Initializable.sol";
contract ERC1155PausableMockUpgradeSafe is Initializable, ERC1155MockUpgradeSafe, ERC1155PausableUpgradeSafe {
constructor(string memory uri) public ERC1155MockUpgradeSafe(uri) {
__ERC1155PausableMock_init(uri);
}
function __ERC1155PausableMock_init(string memory uri) internal initializer {
__Context_init_unchained();
__ERC165_init_unchained();
__ERC1155_init_unchained(uri);
__ERC1155Mock_init_unchained(uri);
__Pausable_init_unchained();
__ERC1155Pausable_init_unchained();
__ERC1155PausableMock_init_unchained(uri);
}
function __ERC1155PausableMock_init_unchained(string memory uri) internal initializer {
}
contract ERC1155PausableMock is ERC1155Mock, ERC1155Pausable {
constructor(string memory uri) public ERC1155Mock(uri) { }
function pause() external { function pause() external {
_pause(); _pause();
...@@ -24,8 +44,10 @@ contract ERC1155PausableMock is ERC1155Mock, ERC1155Pausable { ...@@ -24,8 +44,10 @@ contract ERC1155PausableMock is ERC1155Mock, ERC1155Pausable {
uint256[] memory amounts, uint256[] memory amounts,
bytes memory data bytes memory data
) )
internal virtual override(ERC1155, ERC1155Pausable) internal virtual override(ERC1155UpgradeSafe, ERC1155PausableUpgradeSafe)
{ {
super._beforeTokenTransfer(operator, from, to, ids, amounts, data); super._beforeTokenTransfer(operator, from, to, ids, amounts, data);
} }
uint256[50] private __gap;
} }
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
import "../presets/ERC1155PresetMinterPauser.sol";
import "../Initializable.sol";
contract ERC1155PresetMinterPauserMockUpgradeSafe is Initializable, ERC1155PresetMinterPauserUpgradeSafe {
constructor(string memory uri) public {
__ERC1155PresetMinterPauserMock_init(uri);
}
function __ERC1155PresetMinterPauserMock_init(string memory uri) internal initializer {
__Context_init_unchained();
__AccessControl_init_unchained();
__ERC165_init_unchained();
__ERC1155_init_unchained(uri);
__ERC1155Burnable_init_unchained();
__Pausable_init_unchained();
__ERC1155Pausable_init_unchained();
__ERC1155PresetMinterPauser_init_unchained(uri);
__ERC1155PresetMinterPauserMock_init_unchained(uri);
}
function __ERC1155PresetMinterPauserMock_init_unchained(string memory uri) internal initializer {
}
uint256[50] private __gap;
}
...@@ -4,8 +4,9 @@ pragma solidity ^0.6.0; ...@@ -4,8 +4,9 @@ pragma solidity ^0.6.0;
import "../token/ERC1155/IERC1155Receiver.sol"; import "../token/ERC1155/IERC1155Receiver.sol";
import "./ERC165Mock.sol"; import "./ERC165Mock.sol";
import "../Initializable.sol";
contract ERC1155ReceiverMock is IERC1155Receiver, ERC165Mock { contract ERC1155ReceiverMockUpgradeSafe is Initializable, IERC1155Receiver, ERC165MockUpgradeSafe {
bytes4 private _recRetval; bytes4 private _recRetval;
bool private _recReverts; bool private _recReverts;
bytes4 private _batRetval; bytes4 private _batRetval;
...@@ -14,20 +15,43 @@ contract ERC1155ReceiverMock is IERC1155Receiver, ERC165Mock { ...@@ -14,20 +15,43 @@ contract ERC1155ReceiverMock is IERC1155Receiver, ERC165Mock {
event Received(address operator, address from, uint256 id, uint256 value, bytes data, uint256 gas); event Received(address operator, address from, uint256 id, uint256 value, bytes data, uint256 gas);
event BatchReceived(address operator, address from, uint256[] ids, uint256[] values, bytes data, uint256 gas); event BatchReceived(address operator, address from, uint256[] ids, uint256[] values, bytes data, uint256 gas);
constructor (
constructor(
bytes4 recRetval, bytes4 recRetval,
bool recReverts, bool recReverts,
bytes4 batRetval, bytes4 batRetval,
bool batReverts bool batReverts
) ) public {
public __ERC1155ReceiverMock_init(recRetval, recReverts, batRetval, batReverts);
{ }
function __ERC1155ReceiverMock_init(
bytes4 recRetval,
bool recReverts,
bytes4 batRetval,
bool batReverts
) internal initializer {
__ERC165_init_unchained();
__ERC165Mock_init_unchained();
__ERC1155ReceiverMock_init_unchained(recRetval, recReverts, batRetval, batReverts);
}
function __ERC1155ReceiverMock_init_unchained(
bytes4 recRetval,
bool recReverts,
bytes4 batRetval,
bool batReverts
) internal initializer {
_recRetval = recRetval; _recRetval = recRetval;
_recReverts = recReverts; _recReverts = recReverts;
_batRetval = batRetval; _batRetval = batRetval;
_batReverts = batReverts; _batReverts = batReverts;
} }
function onERC1155Received( function onERC1155Received(
address operator, address operator,
address from, address from,
...@@ -59,4 +83,6 @@ contract ERC1155ReceiverMock is IERC1155Receiver, ERC165Mock { ...@@ -59,4 +83,6 @@ contract ERC1155ReceiverMock is IERC1155Receiver, ERC165Mock {
emit BatchReceived(operator, from, ids, values, data, gasleft()); emit BatchReceived(operator, from, ids, values, data, gasleft());
return _batRetval; return _batRetval;
} }
uint256[49] private __gap;
} }
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "../../introspection/IERC165.sol"; import "../../introspection/IERC165.sol";
import "../../Initializable.sol";
/** /**
* https://eips.ethereum.org/EIPS/eip-214#specification * https://eips.ethereum.org/EIPS/eip-214#specification
...@@ -14,7 +15,7 @@ import "../../introspection/IERC165.sol"; ...@@ -14,7 +15,7 @@ import "../../introspection/IERC165.sol";
* therefore, because this contract is staticcall'd we need to not emit events (which is how solidity-coverage works) * therefore, because this contract is staticcall'd we need to not emit events (which is how solidity-coverage works)
* solidity-coverage ignores the /mocks folder, so we duplicate its implementation here to avoid instrumenting it * solidity-coverage ignores the /mocks folder, so we duplicate its implementation here to avoid instrumenting it
*/ */
contract SupportsInterfaceWithLookupMock is IERC165 { contract SupportsInterfaceWithLookupMockUpgradeSafe is Initializable, IERC165 {
/* /*
* bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7 * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7
*/ */
...@@ -29,10 +30,23 @@ contract SupportsInterfaceWithLookupMock is IERC165 { ...@@ -29,10 +30,23 @@ contract SupportsInterfaceWithLookupMock is IERC165 {
* @dev A contract implementing SupportsInterfaceWithLookup * @dev A contract implementing SupportsInterfaceWithLookup
* implement ERC165 itself. * implement ERC165 itself.
*/ */
constructor () public {
constructor() public {
__SupportsInterfaceWithLookupMock_init();
}
function __SupportsInterfaceWithLookupMock_init() internal initializer {
__SupportsInterfaceWithLookupMock_init_unchained();
}
function __SupportsInterfaceWithLookupMock_init_unchained() internal initializer {
_registerInterface(INTERFACE_ID_ERC165); _registerInterface(INTERFACE_ID_ERC165);
} }
/** /**
* @dev Implement supportsInterface(bytes4) using a lookup table. * @dev Implement supportsInterface(bytes4) using a lookup table.
*/ */
...@@ -47,12 +61,30 @@ contract SupportsInterfaceWithLookupMock is IERC165 { ...@@ -47,12 +61,30 @@ contract SupportsInterfaceWithLookupMock is IERC165 {
require(interfaceId != 0xffffffff, "ERC165InterfacesSupported: invalid interface id"); require(interfaceId != 0xffffffff, "ERC165InterfacesSupported: invalid interface id");
_supportedInterfaces[interfaceId] = true; _supportedInterfaces[interfaceId] = true;
} }
uint256[49] private __gap;
} }
contract ERC165InterfacesSupported is SupportsInterfaceWithLookupMock { contract ERC165InterfacesSupportedUpgradeSafe is Initializable, SupportsInterfaceWithLookupMockUpgradeSafe {
constructor (bytes4[] memory interfaceIds) public {
constructor(bytes4[] memory interfaceIds) public {
__ERC165InterfacesSupported_init(interfaceIds);
}
function __ERC165InterfacesSupported_init(bytes4[] memory interfaceIds) internal initializer {
__SupportsInterfaceWithLookupMock_init_unchained();
__ERC165InterfacesSupported_init_unchained(interfaceIds);
}
function __ERC165InterfacesSupported_init_unchained(bytes4[] memory interfaceIds) internal initializer {
for (uint256 i = 0; i < interfaceIds.length; i++) { for (uint256 i = 0; i < interfaceIds.length; i++) {
_registerInterface(interfaceIds[i]); _registerInterface(interfaceIds[i]);
} }
} }
uint256[50] private __gap;
} }
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "../../Initializable.sol";
contract ERC165NotSupported { } contract ERC165NotSupportedUpgradeSafe is Initializable {
constructor() public {
__ERC165NotSupported_init();
}
function __ERC165NotSupported_init() internal initializer {
__ERC165NotSupported_init_unchained();
}
function __ERC165NotSupported_init_unchained() internal initializer {
}
uint256[50] private __gap;
}
...@@ -3,8 +3,22 @@ ...@@ -3,8 +3,22 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "../introspection/ERC165Checker.sol"; import "../introspection/ERC165Checker.sol";
import "../Initializable.sol";
contract ERC165CheckerMockUpgradeSafe is Initializable {
constructor() public {
__ERC165CheckerMock_init();
}
function __ERC165CheckerMock_init() internal initializer {
__ERC165CheckerMock_init_unchained();
}
function __ERC165CheckerMock_init_unchained() internal initializer {
}
contract ERC165CheckerMock {
using ERC165Checker for address; using ERC165Checker for address;
function supportsERC165(address account) public view returns (bool) { function supportsERC165(address account) public view returns (bool) {
...@@ -18,4 +32,6 @@ contract ERC165CheckerMock { ...@@ -18,4 +32,6 @@ contract ERC165CheckerMock {
function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) public view returns (bool) { function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) public view returns (bool) {
return account.supportsAllInterfaces(interfaceIds); return account.supportsAllInterfaces(interfaceIds);
} }
uint256[50] private __gap;
} }
...@@ -3,9 +3,26 @@ ...@@ -3,9 +3,26 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "../introspection/ERC165.sol"; import "../introspection/ERC165.sol";
import "../Initializable.sol";
contract ERC165MockUpgradeSafe is Initializable, ERC165UpgradeSafe {
constructor() public {
__ERC165Mock_init();
}
function __ERC165Mock_init() internal initializer {
__ERC165_init_unchained();
__ERC165Mock_init_unchained();
}
function __ERC165Mock_init_unchained() internal initializer {
}
contract ERC165Mock is ERC165 {
function registerInterface(bytes4 interfaceId) public { function registerInterface(bytes4 interfaceId) public {
_registerInterface(interfaceId); _registerInterface(interfaceId);
} }
uint256[50] private __gap;
} }
...@@ -3,9 +3,26 @@ ...@@ -3,9 +3,26 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "../introspection/ERC1820Implementer.sol"; import "../introspection/ERC1820Implementer.sol";
import "../Initializable.sol";
contract ERC1820ImplementerMockUpgradeSafe is Initializable, ERC1820ImplementerUpgradeSafe {
constructor() public {
__ERC1820ImplementerMock_init();
}
function __ERC1820ImplementerMock_init() internal initializer {
__ERC1820Implementer_init_unchained();
__ERC1820ImplementerMock_init_unchained();
}
function __ERC1820ImplementerMock_init_unchained() internal initializer {
}
contract ERC1820ImplementerMock is ERC1820Implementer {
function registerInterfaceForAddress(bytes32 interfaceHash, address account) public { function registerInterfaceForAddress(bytes32 interfaceHash, address account) public {
_registerInterfaceForAddress(interfaceHash, account); _registerInterfaceForAddress(interfaceHash, account);
} }
uint256[50] private __gap;
} }
...@@ -3,14 +3,43 @@ ...@@ -3,14 +3,43 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "../token/ERC20/ERC20Burnable.sol"; import "../token/ERC20/ERC20Burnable.sol";
import "../Initializable.sol";
contract ERC20BurnableMock is ERC20Burnable { contract ERC20BurnableMockUpgradeSafe is Initializable, ERC20BurnableUpgradeSafe {
constructor (
constructor(
string memory name,
string memory symbol,
address initialAccount,
uint256 initialBalance
) public {
__ERC20BurnableMock_init(name, symbol, initialAccount, initialBalance);
}
function __ERC20BurnableMock_init(
string memory name,
string memory symbol,
address initialAccount,
uint256 initialBalance
) internal initializer {
__Context_init_unchained();
__ERC20_init_unchained(name, symbol);
__ERC20Burnable_init_unchained();
__ERC20BurnableMock_init_unchained(name, symbol, initialAccount, initialBalance);
}
function __ERC20BurnableMock_init_unchained(
string memory name, string memory name,
string memory symbol, string memory symbol,
address initialAccount, address initialAccount,
uint256 initialBalance uint256 initialBalance
) public ERC20(name, symbol) { ) internal initializer {
_mint(initialAccount, initialBalance); _mint(initialAccount, initialBalance);
} }
uint256[50] private __gap;
} }
...@@ -3,13 +3,30 @@ ...@@ -3,13 +3,30 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "../token/ERC20/ERC20Capped.sol"; import "../token/ERC20/ERC20Capped.sol";
import "../Initializable.sol";
contract ERC20CappedMockUpgradeSafe is Initializable, ERC20CappedUpgradeSafe {
constructor(string memory name, string memory symbol, uint256 cap) public {
__ERC20CappedMock_init(name, symbol, cap);
}
function __ERC20CappedMock_init(string memory name, string memory symbol, uint256 cap) internal initializer {
__Context_init_unchained();
__ERC20_init_unchained(name, symbol);
__ERC20Capped_init_unchained(cap);
__ERC20CappedMock_init_unchained(name, symbol, cap);
}
function __ERC20CappedMock_init_unchained(string memory name, string memory symbol, uint256 cap) internal initializer {
}
contract ERC20CappedMock is ERC20Capped {
constructor (string memory name, string memory symbol, uint256 cap)
public ERC20(name, symbol) ERC20Capped(cap)
{ }
function mint(address to, uint256 tokenId) public { function mint(address to, uint256 tokenId) public {
_mint(to, tokenId); _mint(to, tokenId);
} }
uint256[50] private __gap;
} }
...@@ -3,9 +3,27 @@ ...@@ -3,9 +3,27 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "../token/ERC20/ERC20.sol"; import "../token/ERC20/ERC20.sol";
import "../Initializable.sol";
contract ERC20DecimalsMockUpgradeSafe is Initializable, ERC20UpgradeSafe {
constructor(string memory name, string memory symbol, uint8 decimals) public {
__ERC20DecimalsMock_init(name, symbol, decimals);
}
function __ERC20DecimalsMock_init(string memory name, string memory symbol, uint8 decimals) internal initializer {
__Context_init_unchained();
__ERC20_init_unchained(name, symbol);
__ERC20DecimalsMock_init_unchained(name, symbol, decimals);
}
function __ERC20DecimalsMock_init_unchained(string memory name, string memory symbol, uint8 decimals) internal initializer {
contract ERC20DecimalsMock is ERC20 {
constructor (string memory name, string memory symbol, uint8 decimals) public ERC20(name, symbol) {
_setupDecimals(decimals); _setupDecimals(decimals);
} }
uint256[50] private __gap;
} }
...@@ -3,18 +3,44 @@ ...@@ -3,18 +3,44 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "../token/ERC20/ERC20.sol"; import "../token/ERC20/ERC20.sol";
import "../Initializable.sol";
// mock class using ERC20 // mock class using ERC20
contract ERC20Mock is ERC20 { contract ERC20MockUpgradeSafe is Initializable, ERC20UpgradeSafe {
constructor (
constructor(
string memory name,
string memory symbol,
address initialAccount,
uint256 initialBalance
) public payable {
__ERC20Mock_init(name, symbol, initialAccount, initialBalance);
}
function __ERC20Mock_init(
string memory name,
string memory symbol,
address initialAccount,
uint256 initialBalance
) internal initializer {
__Context_init_unchained();
__ERC20_init_unchained(name, symbol);
__ERC20Mock_init_unchained(name, symbol, initialAccount, initialBalance);
}
function __ERC20Mock_init_unchained(
string memory name, string memory name,
string memory symbol, string memory symbol,
address initialAccount, address initialAccount,
uint256 initialBalance uint256 initialBalance
) public payable ERC20(name, symbol) { ) internal initializer {
_mint(initialAccount, initialBalance); _mint(initialAccount, initialBalance);
} }
function mint(address account, uint256 amount) public { function mint(address account, uint256 amount) public {
_mint(account, amount); _mint(account, amount);
} }
...@@ -30,4 +56,6 @@ contract ERC20Mock is ERC20 { ...@@ -30,4 +56,6 @@ contract ERC20Mock is ERC20 {
function approveInternal(address owner, address spender, uint256 value) public { function approveInternal(address owner, address spender, uint256 value) public {
_approve(owner, spender, value); _approve(owner, spender, value);
} }
uint256[50] private __gap;
} }
...@@ -3,18 +3,46 @@ ...@@ -3,18 +3,46 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "../token/ERC20/ERC20Pausable.sol"; import "../token/ERC20/ERC20Pausable.sol";
import "../Initializable.sol";
// mock class using ERC20Pausable // mock class using ERC20Pausable
contract ERC20PausableMock is ERC20Pausable { contract ERC20PausableMockUpgradeSafe is Initializable, ERC20PausableUpgradeSafe {
constructor (
constructor(
string memory name,
string memory symbol,
address initialAccount,
uint256 initialBalance
) public {
__ERC20PausableMock_init(name, symbol, initialAccount, initialBalance);
}
function __ERC20PausableMock_init(
string memory name,
string memory symbol,
address initialAccount,
uint256 initialBalance
) internal initializer {
__Context_init_unchained();
__ERC20_init_unchained(name, symbol);
__Pausable_init_unchained();
__ERC20Pausable_init_unchained();
__ERC20PausableMock_init_unchained(name, symbol, initialAccount, initialBalance);
}
function __ERC20PausableMock_init_unchained(
string memory name, string memory name,
string memory symbol, string memory symbol,
address initialAccount, address initialAccount,
uint256 initialBalance uint256 initialBalance
) public ERC20(name, symbol) { ) internal initializer {
_mint(initialAccount, initialBalance); _mint(initialAccount, initialBalance);
} }
function pause() external { function pause() external {
_pause(); _pause();
} }
...@@ -30,4 +58,6 @@ contract ERC20PausableMock is ERC20Pausable { ...@@ -30,4 +58,6 @@ contract ERC20PausableMock is ERC20Pausable {
function burn(address from, uint256 amount) public { function burn(address from, uint256 amount) public {
_burn(from, amount); _burn(from, amount);
} }
uint256[50] private __gap;
} }
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
import '../presets/ERC20PresetMinterPauser.sol';
import "../Initializable.sol";
contract ERC20PresetMinterPauserMockUpgradeSafe is Initializable, ERC20PresetMinterPauserUpgradeSafe {
constructor(string memory name, string memory symbol) public payable {
__ERC20PresetMinterPauserMock_init(name, symbol);
}
function __ERC20PresetMinterPauserMock_init(string memory name, string memory symbol) internal initializer {
__Context_init_unchained();
__AccessControl_init_unchained();
__ERC20_init_unchained(name, symbol);
__ERC20Burnable_init_unchained();
__Pausable_init_unchained();
__ERC20Pausable_init_unchained();
__ERC20PresetMinterPauser_init_unchained(name, symbol);
__ERC20PresetMinterPauserMock_init_unchained(name, symbol);
}
function __ERC20PresetMinterPauserMock_init_unchained(string memory name, string memory symbol) internal initializer {
}
uint256[50] private __gap;
}
...@@ -3,18 +3,45 @@ ...@@ -3,18 +3,45 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "../token/ERC20/ERC20Snapshot.sol"; import "../token/ERC20/ERC20Snapshot.sol";
import "../Initializable.sol";
contract ERC20SnapshotMock is ERC20Snapshot { contract ERC20SnapshotMockUpgradeSafe is Initializable, ERC20SnapshotUpgradeSafe {
constructor( constructor(
string memory name, string memory name,
string memory symbol, string memory symbol,
address initialAccount, address initialAccount,
uint256 initialBalance uint256 initialBalance
) public ERC20(name, symbol) { ) public {
__ERC20SnapshotMock_init(name, symbol, initialAccount, initialBalance);
}
function __ERC20SnapshotMock_init(
string memory name,
string memory symbol,
address initialAccount,
uint256 initialBalance
) internal initializer {
__Context_init_unchained();
__ERC20_init_unchained(name, symbol);
__ERC20Snapshot_init_unchained();
__ERC20SnapshotMock_init_unchained(name, symbol, initialAccount, initialBalance);
}
function __ERC20SnapshotMock_init_unchained(
string memory name,
string memory symbol,
address initialAccount,
uint256 initialBalance
) internal initializer {
_mint(initialAccount, initialBalance); _mint(initialAccount, initialBalance);
} }
function snapshot() public { function snapshot() public {
_snapshot(); _snapshot();
} }
...@@ -26,4 +53,6 @@ contract ERC20SnapshotMock is ERC20Snapshot { ...@@ -26,4 +53,6 @@ contract ERC20SnapshotMock is ERC20Snapshot {
function burn(address account, uint256 amount) public { function burn(address account, uint256 amount) public {
_burn(account, amount); _burn(account, amount);
} }
uint256[50] private __gap;
} }
...@@ -3,11 +3,31 @@ ...@@ -3,11 +3,31 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "../token/ERC721/ERC721Burnable.sol"; import "../token/ERC721/ERC721Burnable.sol";
import "../Initializable.sol";
contract ERC721BurnableMockUpgradeSafe is Initializable, ERC721BurnableUpgradeSafe {
constructor(string memory name, string memory symbol) public {
__ERC721BurnableMock_init(name, symbol);
}
function __ERC721BurnableMock_init(string memory name, string memory symbol) internal initializer {
__Context_init_unchained();
__ERC165_init_unchained();
__ERC721_init_unchained(name, symbol);
__ERC721Burnable_init_unchained();
__ERC721BurnableMock_init_unchained(name, symbol);
}
function __ERC721BurnableMock_init_unchained(string memory name, string memory symbol) internal initializer {
}
contract ERC721BurnableMock is ERC721Burnable {
constructor(string memory name, string memory symbol) public ERC721(name, symbol) { }
function mint(address to, uint256 tokenId) public { function mint(address to, uint256 tokenId) public {
_mint(to, tokenId); _mint(to, tokenId);
} }
uint256[50] private __gap;
} }
...@@ -5,27 +5,44 @@ pragma solidity ^0.6.0; ...@@ -5,27 +5,44 @@ pragma solidity ^0.6.0;
import "../token/ERC721/ERC721.sol"; import "../token/ERC721/ERC721.sol";
import "../GSN/GSNRecipient.sol"; import "../GSN/GSNRecipient.sol";
import "../GSN/GSNRecipientSignature.sol"; import "../GSN/GSNRecipientSignature.sol";
import "../Initializable.sol";
/** /**
* @title ERC721GSNRecipientMock * @title ERC721GSNRecipientMock
* A simple ERC721 mock that has GSN support enabled * A simple ERC721 mock that has GSN support enabled
*/ */
contract ERC721GSNRecipientMock is ERC721, GSNRecipient, GSNRecipientSignature { contract ERC721GSNRecipientMockUpgradeSafe is Initializable, ERC721UpgradeSafe, GSNRecipientUpgradeSafe, GSNRecipientSignatureUpgradeSafe {
constructor(string memory name, string memory symbol, address trustedSigner)
public constructor(string memory name, string memory symbol, address trustedSigner) public {
ERC721(name, symbol) __ERC721GSNRecipientMock_init(name, symbol, trustedSigner);
GSNRecipientSignature(trustedSigner) }
{ }
function __ERC721GSNRecipientMock_init(string memory name, string memory symbol, address trustedSigner) internal initializer {
__Context_init_unchained();
__ERC165_init_unchained();
__ERC721_init_unchained(name, symbol);
__GSNRecipient_init_unchained();
__GSNRecipientSignature_init_unchained(trustedSigner);
__ERC721GSNRecipientMock_init_unchained(name, symbol, trustedSigner);
}
function __ERC721GSNRecipientMock_init_unchained(string memory name, string memory symbol, address trustedSigner) internal initializer {
}
function mint(uint256 tokenId) public { function mint(uint256 tokenId) public {
_mint(_msgSender(), tokenId); _mint(_msgSender(), tokenId);
} }
function _msgSender() internal view override(Context, GSNRecipient) returns (address payable) { function _msgSender() internal view override(ContextUpgradeSafe, GSNRecipientUpgradeSafe) returns (address payable) {
return GSNRecipient._msgSender(); return GSNRecipientUpgradeSafe._msgSender();
} }
function _msgData() internal view override(Context, GSNRecipient) returns (bytes memory) { function _msgData() internal view override(ContextUpgradeSafe, GSNRecipientUpgradeSafe) returns (bytes memory) {
return GSNRecipient._msgData(); return GSNRecipientUpgradeSafe._msgData();
} }
uint256[50] private __gap;
} }
...@@ -3,13 +3,30 @@ ...@@ -3,13 +3,30 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "../token/ERC721/ERC721.sol"; import "../token/ERC721/ERC721.sol";
import "../Initializable.sol";
/** /**
* @title ERC721Mock * @title ERC721Mock
* This mock just provides a public safeMint, mint, and burn functions for testing purposes * This mock just provides a public safeMint, mint, and burn functions for testing purposes
*/ */
contract ERC721Mock is ERC721 { contract ERC721MockUpgradeSafe is Initializable, ERC721UpgradeSafe {
constructor (string memory name, string memory symbol) public ERC721(name, symbol) { }
constructor(string memory name, string memory symbol) public {
__ERC721Mock_init(name, symbol);
}
function __ERC721Mock_init(string memory name, string memory symbol) internal initializer {
__Context_init_unchained();
__ERC165_init_unchained();
__ERC721_init_unchained(name, symbol);
__ERC721Mock_init_unchained(name, symbol);
}
function __ERC721Mock_init_unchained(string memory name, string memory symbol) internal initializer {
}
function exists(uint256 tokenId) public view returns (bool) { function exists(uint256 tokenId) public view returns (bool) {
return _exists(tokenId); return _exists(tokenId);
...@@ -38,4 +55,6 @@ contract ERC721Mock is ERC721 { ...@@ -38,4 +55,6 @@ contract ERC721Mock is ERC721 {
function burn(uint256 tokenId) public { function burn(uint256 tokenId) public {
_burn(tokenId); _burn(tokenId);
} }
uint256[50] private __gap;
} }
...@@ -3,13 +3,32 @@ ...@@ -3,13 +3,32 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "../token/ERC721/ERC721Pausable.sol"; import "../token/ERC721/ERC721Pausable.sol";
import "../Initializable.sol";
/** /**
* @title ERC721PausableMock * @title ERC721PausableMock
* This mock just provides a public mint, burn and exists functions for testing purposes * This mock just provides a public mint, burn and exists functions for testing purposes
*/ */
contract ERC721PausableMock is ERC721Pausable { contract ERC721PausableMockUpgradeSafe is Initializable, ERC721PausableUpgradeSafe {
constructor (string memory name, string memory symbol) public ERC721(name, symbol) { }
constructor(string memory name, string memory symbol) public {
__ERC721PausableMock_init(name, symbol);
}
function __ERC721PausableMock_init(string memory name, string memory symbol) internal initializer {
__Context_init_unchained();
__ERC165_init_unchained();
__ERC721_init_unchained(name, symbol);
__Pausable_init_unchained();
__ERC721Pausable_init_unchained();
__ERC721PausableMock_init_unchained(name, symbol);
}
function __ERC721PausableMock_init_unchained(string memory name, string memory symbol) internal initializer {
}
function mint(address to, uint256 tokenId) public { function mint(address to, uint256 tokenId) public {
super._mint(to, tokenId); super._mint(to, tokenId);
...@@ -30,4 +49,6 @@ contract ERC721PausableMock is ERC721Pausable { ...@@ -30,4 +49,6 @@ contract ERC721PausableMock is ERC721Pausable {
function unpause() external { function unpause() external {
_unpause(); _unpause();
} }
uint256[50] private __gap;
} }
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
import '../presets/ERC721PresetMinterPauserAutoId.sol';
import "../Initializable.sol";
contract ERC721PresetMinterPauserAutoIdMockUpgradeSafe is Initializable, ERC721PresetMinterPauserAutoIdUpgradeSafe {
constructor(string memory name, string memory symbol, string memory baseURI) public payable {
__ERC721PresetMinterPauserAutoIdMock_init(name, symbol, baseURI);
}
function __ERC721PresetMinterPauserAutoIdMock_init(string memory name, string memory symbol, string memory baseURI) internal initializer {
__Context_init_unchained();
__AccessControl_init_unchained();
__ERC165_init_unchained();
__ERC721_init_unchained(name, symbol);
__ERC721Burnable_init_unchained();
__Pausable_init_unchained();
__ERC721Pausable_init_unchained();
__ERC721PresetMinterPauserAutoId_init_unchained(name, symbol, baseURI);
__ERC721PresetMinterPauserAutoIdMock_init_unchained(name, symbol, baseURI);
}
function __ERC721PresetMinterPauserAutoIdMock_init_unchained(string memory name, string memory symbol, string memory baseURI) internal initializer {
}
uint256[50] private __gap;
}
...@@ -3,18 +3,32 @@ ...@@ -3,18 +3,32 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "../token/ERC721/IERC721Receiver.sol"; import "../token/ERC721/IERC721Receiver.sol";
import "../Initializable.sol";
contract ERC721ReceiverMock is IERC721Receiver { contract ERC721ReceiverMockUpgradeSafe is Initializable, IERC721Receiver {
bytes4 private _retval; bytes4 private _retval;
bool private _reverts; bool private _reverts;
event Received(address operator, address from, uint256 tokenId, bytes data, uint256 gas); event Received(address operator, address from, uint256 tokenId, bytes data, uint256 gas);
constructor (bytes4 retval, bool reverts) public {
constructor(bytes4 retval, bool reverts) public {
__ERC721ReceiverMock_init(retval, reverts);
}
function __ERC721ReceiverMock_init(bytes4 retval, bool reverts) internal initializer {
__ERC721ReceiverMock_init_unchained(retval, reverts);
}
function __ERC721ReceiverMock_init_unchained(bytes4 retval, bool reverts) internal initializer {
_retval = retval; _retval = retval;
_reverts = reverts; _reverts = reverts;
} }
function onERC721Received(address operator, address from, uint256 tokenId, bytes memory data) function onERC721Received(address operator, address from, uint256 tokenId, bytes memory data)
public override returns (bytes4) public override returns (bytes4)
{ {
...@@ -22,4 +36,6 @@ contract ERC721ReceiverMock is IERC721Receiver { ...@@ -22,4 +36,6 @@ contract ERC721ReceiverMock is IERC721Receiver {
emit Received(operator, from, tokenId, data, gasleft()); emit Received(operator, from, tokenId, data, gasleft());
return _retval; return _retval;
} }
uint256[49] private __gap;
} }
...@@ -4,18 +4,46 @@ pragma solidity ^0.6.0; ...@@ -4,18 +4,46 @@ pragma solidity ^0.6.0;
import "../GSN/Context.sol"; import "../GSN/Context.sol";
import "../token/ERC777/ERC777.sol"; import "../token/ERC777/ERC777.sol";
import "../Initializable.sol";
contract ERC777MockUpgradeSafe is Initializable, ContextUpgradeSafe, ERC777UpgradeSafe {
contract ERC777Mock is Context, ERC777 {
constructor( constructor(
address initialHolder, address initialHolder,
uint256 initialBalance, uint256 initialBalance,
string memory name, string memory name,
string memory symbol, string memory symbol,
address[] memory defaultOperators address[] memory defaultOperators
) public ERC777(name, symbol, defaultOperators) { ) public {
__ERC777Mock_init(initialHolder, initialBalance, name, symbol, defaultOperators);
}
function __ERC777Mock_init(
address initialHolder,
uint256 initialBalance,
string memory name,
string memory symbol,
address[] memory defaultOperators
) internal initializer {
__Context_init_unchained();
__ERC777_init_unchained(name, symbol, defaultOperators);
__ERC777Mock_init_unchained(initialHolder, initialBalance, name, symbol, defaultOperators);
}
function __ERC777Mock_init_unchained(
address initialHolder,
uint256 initialBalance,
string memory name,
string memory symbol,
address[] memory defaultOperators
) internal initializer {
_mint(initialHolder, initialBalance, "", ""); _mint(initialHolder, initialBalance, "", "");
} }
function mintInternal ( function mintInternal (
address to, address to,
uint256 amount, uint256 amount,
...@@ -28,4 +56,6 @@ contract ERC777Mock is Context, ERC777 { ...@@ -28,4 +56,6 @@ contract ERC777Mock is Context, ERC777 {
function approveInternal(address holder, address spender, uint256 value) public { function approveInternal(address holder, address spender, uint256 value) public {
_approve(holder, spender, value); _approve(holder, spender, value);
} }
uint256[50] private __gap;
} }
...@@ -8,8 +8,25 @@ import "../token/ERC777/IERC777Sender.sol"; ...@@ -8,8 +8,25 @@ import "../token/ERC777/IERC777Sender.sol";
import "../token/ERC777/IERC777Recipient.sol"; import "../token/ERC777/IERC777Recipient.sol";
import "../introspection/IERC1820Registry.sol"; import "../introspection/IERC1820Registry.sol";
import "../introspection/ERC1820Implementer.sol"; import "../introspection/ERC1820Implementer.sol";
import "../Initializable.sol";
contract ERC777SenderRecipientMockUpgradeSafe is Initializable, ContextUpgradeSafe, IERC777Sender, IERC777Recipient, ERC1820ImplementerUpgradeSafe {
constructor() public {
__ERC777SenderRecipientMock_init();
}
function __ERC777SenderRecipientMock_init() internal initializer {
__Context_init_unchained();
__ERC1820Implementer_init_unchained();
__ERC777SenderRecipientMock_init_unchained();
}
function __ERC777SenderRecipientMock_init_unchained() internal initializer {
_erc1820 = IERC1820Registry(0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24);
}
contract ERC777SenderRecipientMock is Context, IERC777Sender, IERC777Recipient, ERC1820Implementer {
event TokensToSendCalled( event TokensToSendCalled(
address operator, address operator,
address from, address from,
...@@ -37,7 +54,7 @@ contract ERC777SenderRecipientMock is Context, IERC777Sender, IERC777Recipient, ...@@ -37,7 +54,7 @@ contract ERC777SenderRecipientMock is Context, IERC777Sender, IERC777Recipient,
bool private _shouldRevertSend; bool private _shouldRevertSend;
bool private _shouldRevertReceive; bool private _shouldRevertReceive;
IERC1820Registry private _erc1820 = IERC1820Registry(0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24); IERC1820Registry private _erc1820 ;
bytes32 constant private _TOKENS_SENDER_INTERFACE_HASH = keccak256("ERC777TokensSender"); bytes32 constant private _TOKENS_SENDER_INTERFACE_HASH = keccak256("ERC777TokensSender");
bytes32 constant private _TOKENS_RECIPIENT_INTERFACE_HASH = keccak256("ERC777TokensRecipient"); bytes32 constant private _TOKENS_RECIPIENT_INTERFACE_HASH = keccak256("ERC777TokensRecipient");
...@@ -146,5 +163,7 @@ contract ERC777SenderRecipientMock is Context, IERC777Sender, IERC777Recipient, ...@@ -146,5 +163,7 @@ contract ERC777SenderRecipientMock is Context, IERC777Sender, IERC777Recipient,
function burn(IERC777 token, uint256 amount, bytes memory data) public { function burn(IERC777 token, uint256 amount, bytes memory data) public {
token.burn(amount, data); token.burn(amount, data);
} }
uint256[49] private __gap;
} }
...@@ -3,8 +3,22 @@ ...@@ -3,8 +3,22 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "../utils/EnumerableMap.sol"; import "../utils/EnumerableMap.sol";
import "../Initializable.sol";
contract EnumerableMapMockUpgradeSafe is Initializable {
constructor() public {
__EnumerableMapMock_init();
}
function __EnumerableMapMock_init() internal initializer {
__EnumerableMapMock_init_unchained();
}
function __EnumerableMapMock_init_unchained() internal initializer {
}
contract EnumerableMapMock {
using EnumerableMap for EnumerableMap.UintToAddressMap; using EnumerableMap for EnumerableMap.UintToAddressMap;
event OperationResult(bool result); event OperationResult(bool result);
...@@ -37,4 +51,6 @@ contract EnumerableMapMock { ...@@ -37,4 +51,6 @@ contract EnumerableMapMock {
function get(uint256 key) public view returns (address) { function get(uint256 key) public view returns (address) {
return _map.get(key); return _map.get(key);
} }
uint256[48] private __gap;
} }
...@@ -3,9 +3,23 @@ ...@@ -3,9 +3,23 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "../utils/EnumerableSet.sol"; import "../utils/EnumerableSet.sol";
import "../Initializable.sol";
// AddressSet // AddressSet
contract EnumerableAddressSetMock { contract EnumerableAddressSetMockUpgradeSafe is Initializable {
constructor() public {
__EnumerableAddressSetMock_init();
}
function __EnumerableAddressSetMock_init() internal initializer {
__EnumerableAddressSetMock_init_unchained();
}
function __EnumerableAddressSetMock_init_unchained() internal initializer {
}
using EnumerableSet for EnumerableSet.AddressSet; using EnumerableSet for EnumerableSet.AddressSet;
event OperationResult(bool result); event OperationResult(bool result);
...@@ -33,10 +47,25 @@ contract EnumerableAddressSetMock { ...@@ -33,10 +47,25 @@ contract EnumerableAddressSetMock {
function at(uint256 index) public view returns (address) { function at(uint256 index) public view returns (address) {
return _set.at(index); return _set.at(index);
} }
uint256[48] private __gap;
} }
// UintSet // UintSet
contract EnumerableUintSetMock { contract EnumerableUintSetMockUpgradeSafe is Initializable {
constructor() public {
__EnumerableUintSetMock_init();
}
function __EnumerableUintSetMock_init() internal initializer {
__EnumerableUintSetMock_init_unchained();
}
function __EnumerableUintSetMock_init_unchained() internal initializer {
}
using EnumerableSet for EnumerableSet.UintSet; using EnumerableSet for EnumerableSet.UintSet;
event OperationResult(bool result); event OperationResult(bool result);
...@@ -64,4 +93,6 @@ contract EnumerableUintSetMock { ...@@ -64,4 +93,6 @@ contract EnumerableUintSetMock {
function at(uint256 index) public view returns (uint256) { function at(uint256 index) public view returns (uint256) {
return _set.at(index); return _set.at(index);
} }
}
\ No newline at end of file uint256[48] private __gap;
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
import '../payment/escrow/Escrow.sol';
import "../Initializable.sol";
contract EscrowMockUpgradeSafe is Initializable, EscrowUpgradeSafe {
constructor() public {
__EscrowMock_init();
}
function __EscrowMock_init() internal initializer {
__Context_init_unchained();
__Ownable_init_unchained();
__Escrow_init_unchained();
__EscrowMock_init_unchained();
}
function __EscrowMock_init_unchained() internal initializer {
}
uint256[50] private __gap;
}
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "../Initializable.sol";
contract EtherReceiverMockUpgradeSafe is Initializable {
constructor() public {
__EtherReceiverMock_init();
}
function __EtherReceiverMock_init() internal initializer {
__EtherReceiverMock_init_unchained();
}
function __EtherReceiverMock_init_unchained() internal initializer {
}
contract EtherReceiverMock {
bool private _acceptEther; bool private _acceptEther;
function setAcceptEther(bool acceptEther) public { function setAcceptEther(bool acceptEther) public {
...@@ -14,4 +28,6 @@ contract EtherReceiverMock { ...@@ -14,4 +28,6 @@ contract EtherReceiverMock {
revert(); revert();
} }
} }
uint256[49] private __gap;
} }
...@@ -4,9 +4,26 @@ pragma solidity ^0.6.0; ...@@ -4,9 +4,26 @@ pragma solidity ^0.6.0;
import "../GSN/GSNRecipient.sol"; import "../GSN/GSNRecipient.sol";
import "../GSN/GSNRecipientERC20Fee.sol"; import "../GSN/GSNRecipientERC20Fee.sol";
import "../Initializable.sol";
contract GSNRecipientERC20FeeMockUpgradeSafe is Initializable, GSNRecipientUpgradeSafe, GSNRecipientERC20FeeUpgradeSafe {
constructor(string memory name, string memory symbol) public {
__GSNRecipientERC20FeeMock_init(name, symbol);
}
function __GSNRecipientERC20FeeMock_init(string memory name, string memory symbol) internal initializer {
__Context_init_unchained();
__GSNRecipient_init_unchained();
__GSNRecipientERC20Fee_init_unchained(name, symbol);
__GSNRecipientERC20FeeMock_init_unchained(name, symbol);
}
function __GSNRecipientERC20FeeMock_init_unchained(string memory name, string memory symbol) internal initializer {
}
contract GSNRecipientERC20FeeMock is GSNRecipient, GSNRecipientERC20Fee {
constructor(string memory name, string memory symbol) public GSNRecipientERC20Fee(name, symbol) { }
function mint(address account, uint256 amount) public { function mint(address account, uint256 amount) public {
_mint(account, amount); _mint(account, amount);
...@@ -17,4 +34,6 @@ contract GSNRecipientERC20FeeMock is GSNRecipient, GSNRecipientERC20Fee { ...@@ -17,4 +34,6 @@ contract GSNRecipientERC20FeeMock is GSNRecipient, GSNRecipientERC20Fee {
function mockFunction() public { function mockFunction() public {
emit MockFunctionCalled(token().balanceOf(_msgSender())); emit MockFunctionCalled(token().balanceOf(_msgSender()));
} }
uint256[50] private __gap;
} }
...@@ -4,9 +4,26 @@ pragma solidity ^0.6.0; ...@@ -4,9 +4,26 @@ pragma solidity ^0.6.0;
import "./ContextMock.sol"; import "./ContextMock.sol";
import "../GSN/GSNRecipient.sol"; import "../GSN/GSNRecipient.sol";
import "../Initializable.sol";
// By inheriting from GSNRecipient, Context's internal functions are overridden automatically // By inheriting from GSNRecipient, Context's internal functions are overridden automatically
contract GSNRecipientMock is ContextMock, GSNRecipient { contract GSNRecipientMockUpgradeSafe is Initializable, ContextMockUpgradeSafe, GSNRecipientUpgradeSafe {
constructor() public {
__GSNRecipientMock_init();
}
function __GSNRecipientMock_init() internal initializer {
__Context_init_unchained();
__ContextMock_init_unchained();
__GSNRecipient_init_unchained();
__GSNRecipientMock_init_unchained();
}
function __GSNRecipientMock_init_unchained() internal initializer {
}
function withdrawDeposits(uint256 amount, address payable payee) public { function withdrawDeposits(uint256 amount, address payable payee) public {
_withdrawDeposits(amount, payee); _withdrawDeposits(amount, payee);
} }
...@@ -28,11 +45,13 @@ contract GSNRecipientMock is ContextMock, GSNRecipient { ...@@ -28,11 +45,13 @@ contract GSNRecipientMock is ContextMock, GSNRecipient {
return _upgradeRelayHub(newRelayHub); return _upgradeRelayHub(newRelayHub);
} }
function _msgSender() internal override(Context, GSNRecipient) view virtual returns (address payable) { function _msgSender() internal override(ContextUpgradeSafe, GSNRecipientUpgradeSafe) view virtual returns (address payable) {
return GSNRecipient._msgSender(); return GSNRecipientUpgradeSafe._msgSender();
} }
function _msgData() internal override(Context, GSNRecipient) view virtual returns (bytes memory) { function _msgData() internal override(ContextUpgradeSafe, GSNRecipientUpgradeSafe) view virtual returns (bytes memory) {
return GSNRecipient._msgData(); return GSNRecipientUpgradeSafe._msgData();
} }
uint256[50] private __gap;
} }
...@@ -4,13 +4,32 @@ pragma solidity ^0.6.0; ...@@ -4,13 +4,32 @@ pragma solidity ^0.6.0;
import "../GSN/GSNRecipient.sol"; import "../GSN/GSNRecipient.sol";
import "../GSN/GSNRecipientSignature.sol"; import "../GSN/GSNRecipientSignature.sol";
import "../Initializable.sol";
contract GSNRecipientSignatureMockUpgradeSafe is Initializable, GSNRecipientUpgradeSafe, GSNRecipientSignatureUpgradeSafe {
constructor(address trustedSigner) public {
__GSNRecipientSignatureMock_init(trustedSigner);
}
function __GSNRecipientSignatureMock_init(address trustedSigner) internal initializer {
__Context_init_unchained();
__GSNRecipient_init_unchained();
__GSNRecipientSignature_init_unchained(trustedSigner);
__GSNRecipientSignatureMock_init_unchained(trustedSigner);
}
function __GSNRecipientSignatureMock_init_unchained(address trustedSigner) internal initializer {
}
contract GSNRecipientSignatureMock is GSNRecipient, GSNRecipientSignature {
constructor(address trustedSigner) public GSNRecipientSignature(trustedSigner) { }
event MockFunctionCalled(); event MockFunctionCalled();
function mockFunction() public { function mockFunction() public {
emit MockFunctionCalled(); emit MockFunctionCalled();
} }
uint256[50] private __gap;
} }
...@@ -3,8 +3,22 @@ ...@@ -3,8 +3,22 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "../math/Math.sol"; import "../math/Math.sol";
import "../Initializable.sol";
contract MathMockUpgradeSafe is Initializable {
constructor() public {
__MathMock_init();
}
function __MathMock_init() internal initializer {
__MathMock_init_unchained();
}
function __MathMock_init_unchained() internal initializer {
}
contract MathMock {
function max(uint256 a, uint256 b) public pure returns (uint256) { function max(uint256 a, uint256 b) public pure returns (uint256) {
return Math.max(a, b); return Math.max(a, b);
} }
...@@ -16,4 +30,6 @@ contract MathMock { ...@@ -16,4 +30,6 @@ contract MathMock {
function average(uint256 a, uint256 b) public pure returns (uint256) { function average(uint256 a, uint256 b) public pure returns (uint256) {
return Math.average(a, b); return Math.average(a, b);
} }
uint256[50] private __gap;
} }
...@@ -3,9 +3,25 @@ ...@@ -3,9 +3,25 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import { MerkleProof } from "../cryptography/MerkleProof.sol"; import { MerkleProof } from "../cryptography/MerkleProof.sol";
import "../Initializable.sol";
contract MerkleProofWrapperUpgradeSafe is Initializable {
constructor() public {
__MerkleProofWrapper_init();
}
function __MerkleProofWrapper_init() internal initializer {
__MerkleProofWrapper_init_unchained();
}
function __MerkleProofWrapper_init_unchained() internal initializer {
}
contract MerkleProofWrapper {
function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) public pure returns (bool) { function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) public pure returns (bool) {
return MerkleProof.verify(proof, root, leaf); return MerkleProof.verify(proof, root, leaf);
} }
uint256[50] private __gap;
} }
...@@ -3,5 +3,23 @@ ...@@ -3,5 +3,23 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "../access/Ownable.sol"; import "../access/Ownable.sol";
import "../Initializable.sol";
contract OwnableMock is Ownable { } contract OwnableMockUpgradeSafe is Initializable, OwnableUpgradeSafe {
constructor() public {
__OwnableMock_init();
}
function __OwnableMock_init() internal initializer {
__Context_init_unchained();
__Ownable_init_unchained();
__OwnableMock_init_unchained();
}
function __OwnableMock_init_unchained() internal initializer {
}
uint256[50] private __gap;
}
...@@ -3,16 +3,32 @@ ...@@ -3,16 +3,32 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "../utils/Pausable.sol"; import "../utils/Pausable.sol";
import "../Initializable.sol";
contract PausableMock is Pausable { contract PausableMockUpgradeSafe is Initializable, PausableUpgradeSafe {
bool public drasticMeasureTaken; bool public drasticMeasureTaken;
uint256 public count; uint256 public count;
constructor () public {
constructor() public {
__PausableMock_init();
}
function __PausableMock_init() internal initializer {
__Context_init_unchained();
__Pausable_init_unchained();
__PausableMock_init_unchained();
}
function __PausableMock_init_unchained() internal initializer {
drasticMeasureTaken = false; drasticMeasureTaken = false;
count = 0; count = 0;
} }
function normalProcess() external whenNotPaused { function normalProcess() external whenNotPaused {
count++; count++;
} }
...@@ -28,4 +44,6 @@ contract PausableMock is Pausable { ...@@ -28,4 +44,6 @@ contract PausableMock is Pausable {
function unpause() external { function unpause() external {
_unpause(); _unpause();
} }
uint256[48] private __gap;
} }
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
import '../payment/PaymentSplitter.sol';
import "../Initializable.sol";
contract PaymentSplitterMockUpgradeSafe is Initializable, PaymentSplitterUpgradeSafe {
constructor(address[] memory payees, uint256[] memory shares) public payable {
__PaymentSplitterMock_init(payees, shares);
}
function __PaymentSplitterMock_init(address[] memory payees, uint256[] memory shares) internal initializer {
__Context_init_unchained();
__PaymentSplitter_init_unchained(payees, shares);
__PaymentSplitterMock_init_unchained(payees, shares);
}
function __PaymentSplitterMock_init_unchained(address[] memory payees, uint256[] memory shares) internal initializer {
}
uint256[50] private __gap;
}
...@@ -3,13 +3,30 @@ ...@@ -3,13 +3,30 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "../payment/PullPayment.sol"; import "../payment/PullPayment.sol";
import "../Initializable.sol";
// mock class using PullPayment // mock class using PullPayment
contract PullPaymentMock is PullPayment { contract PullPaymentMockUpgradeSafe is Initializable, PullPaymentUpgradeSafe {
constructor () public payable { }
constructor() public payable {
__PullPaymentMock_init();
}
function __PullPaymentMock_init() internal initializer {
__PullPayment_init_unchained();
__PullPaymentMock_init_unchained();
}
function __PullPaymentMock_init_unchained() internal initializer {
}
// test helper function to call asyncTransfer // test helper function to call asyncTransfer
function callTransfer(address dest, uint256 amount) public { function callTransfer(address dest, uint256 amount) public {
_asyncTransfer(dest, amount); _asyncTransfer(dest, amount);
} }
uint256[50] private __gap;
} }
...@@ -3,10 +3,27 @@ ...@@ -3,10 +3,27 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "../GSN/Context.sol"; import "../GSN/Context.sol";
contract ReentrancyAttack is Context { import "../Initializable.sol";
contract ReentrancyAttackUpgradeSafe is Initializable, ContextUpgradeSafe {
constructor() public {
__ReentrancyAttack_init();
}
function __ReentrancyAttack_init() internal initializer {
__Context_init_unchained();
__ReentrancyAttack_init_unchained();
}
function __ReentrancyAttack_init_unchained() internal initializer {
}
function callSender(bytes4 data) public { function callSender(bytes4 data) public {
// solhint-disable-next-line avoid-low-level-calls // solhint-disable-next-line avoid-low-level-calls
(bool success,) = _msgSender().call(abi.encodeWithSelector(data)); (bool success,) = _msgSender().call(abi.encodeWithSelector(data));
require(success, "ReentrancyAttack: failed call"); require(success, "ReentrancyAttack: failed call");
} }
uint256[50] private __gap;
} }
...@@ -4,14 +4,29 @@ pragma solidity ^0.6.0; ...@@ -4,14 +4,29 @@ pragma solidity ^0.6.0;
import "../utils/ReentrancyGuard.sol"; import "../utils/ReentrancyGuard.sol";
import "./ReentrancyAttack.sol"; import "./ReentrancyAttack.sol";
import "../Initializable.sol";
contract ReentrancyMock is ReentrancyGuard { contract ReentrancyMockUpgradeSafe is Initializable, ReentrancyGuardUpgradeSafe {
uint256 public counter; uint256 public counter;
constructor () public {
constructor() public {
__ReentrancyMock_init();
}
function __ReentrancyMock_init() internal initializer {
__ReentrancyGuard_init_unchained();
__ReentrancyMock_init_unchained();
}
function __ReentrancyMock_init_unchained() internal initializer {
counter = 0; counter = 0;
} }
function callback() external nonReentrant { function callback() external nonReentrant {
_count(); _count();
} }
...@@ -32,7 +47,7 @@ contract ReentrancyMock is ReentrancyGuard { ...@@ -32,7 +47,7 @@ contract ReentrancyMock is ReentrancyGuard {
} }
} }
function countAndCall(ReentrancyAttack attacker) public nonReentrant { function countAndCall(ReentrancyAttackUpgradeSafe attacker) public nonReentrant {
_count(); _count();
bytes4 func = bytes4(keccak256("callback()")); bytes4 func = bytes4(keccak256("callback()"));
attacker.callSender(func); attacker.callSender(func);
...@@ -41,4 +56,6 @@ contract ReentrancyMock is ReentrancyGuard { ...@@ -41,4 +56,6 @@ contract ReentrancyMock is ReentrancyGuard {
function _count() private { function _count() private {
counter += 1; counter += 1;
} }
uint256[49] private __gap;
} }
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
import '../payment/escrow/RefundEscrow.sol';
import "../Initializable.sol";
contract RefundEscrowMockUpgradeSafe is Initializable, RefundEscrowUpgradeSafe {
constructor(address payable beneficiary) public payable {
__RefundEscrowMock_init(beneficiary);
}
function __RefundEscrowMock_init(address payable beneficiary) internal initializer {
__Context_init_unchained();
__Ownable_init_unchained();
__Escrow_init_unchained();
__ConditionalEscrow_init_unchained();
__RefundEscrow_init_unchained(beneficiary);
__RefundEscrowMock_init_unchained(beneficiary);
}
function __RefundEscrowMock_init_unchained(address payable beneficiary) internal initializer {
}
uint256[50] private __gap;
}
...@@ -3,8 +3,22 @@ ...@@ -3,8 +3,22 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "../utils/SafeCast.sol"; import "../utils/SafeCast.sol";
import "../Initializable.sol";
contract SafeCastMockUpgradeSafe is Initializable {
constructor() public {
__SafeCastMock_init();
}
function __SafeCastMock_init() internal initializer {
__SafeCastMock_init_unchained();
}
function __SafeCastMock_init_unchained() internal initializer {
}
contract SafeCastMock {
using SafeCast for uint; using SafeCast for uint;
using SafeCast for int; using SafeCast for int;
...@@ -55,4 +69,6 @@ contract SafeCastMock { ...@@ -55,4 +69,6 @@ contract SafeCastMock {
function toInt8(int a) public pure returns (int8) { function toInt8(int a) public pure returns (int8) {
return a.toInt8(); return a.toInt8();
} }
uint256[50] private __gap;
} }
...@@ -5,8 +5,23 @@ pragma solidity ^0.6.0; ...@@ -5,8 +5,23 @@ pragma solidity ^0.6.0;
import "../GSN/Context.sol"; import "../GSN/Context.sol";
import "../token/ERC20/IERC20.sol"; import "../token/ERC20/IERC20.sol";
import "../token/ERC20/SafeERC20.sol"; import "../token/ERC20/SafeERC20.sol";
import "../Initializable.sol";
contract ERC20ReturnFalseMockUpgradeSafe is Initializable, ContextUpgradeSafe {
constructor() public {
__ERC20ReturnFalseMock_init();
}
function __ERC20ReturnFalseMock_init() internal initializer {
__Context_init_unchained();
__ERC20ReturnFalseMock_init_unchained();
}
function __ERC20ReturnFalseMock_init_unchained() internal initializer {
}
contract ERC20ReturnFalseMock is Context {
uint256 private _allowance; uint256 private _allowance;
// IERC20's functions are not pure, but these mock implementations are: to prevent Solidity from issuing warnings, // IERC20's functions are not pure, but these mock implementations are: to prevent Solidity from issuing warnings,
...@@ -32,9 +47,25 @@ contract ERC20ReturnFalseMock is Context { ...@@ -32,9 +47,25 @@ contract ERC20ReturnFalseMock is Context {
require(_dummy == 0); // Duummy read from a state variable so that the function is view require(_dummy == 0); // Duummy read from a state variable so that the function is view
return 0; return 0;
} }
uint256[48] private __gap;
} }
contract ERC20ReturnTrueMock is Context { contract ERC20ReturnTrueMockUpgradeSafe is Initializable, ContextUpgradeSafe {
constructor() public {
__ERC20ReturnTrueMock_init();
}
function __ERC20ReturnTrueMock_init() internal initializer {
__Context_init_unchained();
__ERC20ReturnTrueMock_init_unchained();
}
function __ERC20ReturnTrueMock_init_unchained() internal initializer {
}
mapping (address => uint256) private _allowances; mapping (address => uint256) private _allowances;
// IERC20's functions are not pure, but these mock implementations are: to prevent Solidity from issuing warnings, // IERC20's functions are not pure, but these mock implementations are: to prevent Solidity from issuing warnings,
...@@ -63,9 +94,25 @@ contract ERC20ReturnTrueMock is Context { ...@@ -63,9 +94,25 @@ contract ERC20ReturnTrueMock is Context {
function allowance(address owner, address) public view returns (uint256) { function allowance(address owner, address) public view returns (uint256) {
return _allowances[owner]; return _allowances[owner];
} }
uint256[48] private __gap;
} }
contract ERC20NoReturnMock is Context { contract ERC20NoReturnMockUpgradeSafe is Initializable, ContextUpgradeSafe {
constructor() public {
__ERC20NoReturnMock_init();
}
function __ERC20NoReturnMock_init() internal initializer {
__Context_init_unchained();
__ERC20NoReturnMock_init_unchained();
}
function __ERC20NoReturnMock_init_unchained() internal initializer {
}
mapping (address => uint256) private _allowances; mapping (address => uint256) private _allowances;
// IERC20's functions are not pure, but these mock implementations are: to prevent Solidity from issuing warnings, // IERC20's functions are not pure, but these mock implementations are: to prevent Solidity from issuing warnings,
...@@ -91,17 +138,33 @@ contract ERC20NoReturnMock is Context { ...@@ -91,17 +138,33 @@ contract ERC20NoReturnMock is Context {
function allowance(address owner, address) public view returns (uint256) { function allowance(address owner, address) public view returns (uint256) {
return _allowances[owner]; return _allowances[owner];
} }
uint256[48] private __gap;
} }
contract SafeERC20Wrapper is Context { contract SafeERC20MockUpgradeSafe is Initializable, ContextUpgradeSafe {
using SafeERC20 for IERC20; using SafeERC20 for IERC20;
IERC20 private _token; IERC20 private _token;
constructor (IERC20 token) public {
constructor(IERC20 token) public {
__SafeERC20Mock_init(token);
}
function __SafeERC20Mock_init(IERC20 token) internal initializer {
__Context_init_unchained();
__SafeERC20Mock_init_unchained(token);
}
function __SafeERC20Mock_init_unchained(IERC20 token) internal initializer {
_token = token; _token = token;
} }
function transfer() public { function transfer() public {
_token.safeTransfer(address(0), 0); _token.safeTransfer(address(0), 0);
} }
...@@ -123,10 +186,12 @@ contract SafeERC20Wrapper is Context { ...@@ -123,10 +186,12 @@ contract SafeERC20Wrapper is Context {
} }
function setAllowance(uint256 allowance_) public { function setAllowance(uint256 allowance_) public {
ERC20ReturnTrueMock(address(_token)).setAllowance(allowance_); ERC20ReturnTrueMockUpgradeSafe(address(_token)).setAllowance(allowance_);
} }
function allowance() public view returns (uint256) { function allowance() public view returns (uint256) {
return _token.allowance(address(0), address(0)); return _token.allowance(address(0), address(0));
} }
uint256[49] private __gap;
} }
...@@ -3,8 +3,22 @@ ...@@ -3,8 +3,22 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "../math/SafeMath.sol"; import "../math/SafeMath.sol";
import "../Initializable.sol";
contract SafeMathMockUpgradeSafe is Initializable {
constructor() public {
__SafeMathMock_init();
}
function __SafeMathMock_init() internal initializer {
__SafeMathMock_init_unchained();
}
function __SafeMathMock_init_unchained() internal initializer {
}
contract SafeMathMock {
function mul(uint256 a, uint256 b) public pure returns (uint256) { function mul(uint256 a, uint256 b) public pure returns (uint256) {
return SafeMath.mul(a, b); return SafeMath.mul(a, b);
} }
...@@ -24,4 +38,6 @@ contract SafeMathMock { ...@@ -24,4 +38,6 @@ contract SafeMathMock {
function mod(uint256 a, uint256 b) public pure returns (uint256) { function mod(uint256 a, uint256 b) public pure returns (uint256) {
return SafeMath.mod(a, b); return SafeMath.mod(a, b);
} }
uint256[50] private __gap;
} }
...@@ -3,8 +3,22 @@ ...@@ -3,8 +3,22 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "../math/SignedSafeMath.sol"; import "../math/SignedSafeMath.sol";
import "../Initializable.sol";
contract SignedSafeMathMockUpgradeSafe is Initializable {
constructor() public {
__SignedSafeMathMock_init();
}
function __SignedSafeMathMock_init() internal initializer {
__SignedSafeMathMock_init_unchained();
}
function __SignedSafeMathMock_init_unchained() internal initializer {
}
contract SignedSafeMathMock {
function mul(int256 a, int256 b) public pure returns (int256) { function mul(int256 a, int256 b) public pure returns (int256) {
return SignedSafeMath.mul(a, b); return SignedSafeMath.mul(a, b);
} }
...@@ -20,4 +34,6 @@ contract SignedSafeMathMock { ...@@ -20,4 +34,6 @@ contract SignedSafeMathMock {
function add(int256 a, int256 b) public pure returns (int256) { function add(int256 a, int256 b) public pure returns (int256) {
return SignedSafeMath.add(a, b); return SignedSafeMath.add(a, b);
} }
uint256[50] private __gap;
} }
...@@ -3,9 +3,25 @@ ...@@ -3,9 +3,25 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "../utils/Strings.sol"; import "../utils/Strings.sol";
import "../Initializable.sol";
contract StringsMockUpgradeSafe is Initializable {
constructor() public {
__StringsMock_init();
}
function __StringsMock_init() internal initializer {
__StringsMock_init_unchained();
}
function __StringsMock_init_unchained() internal initializer {
}
contract StringsMock {
function fromUint256(uint256 value) public pure returns (string memory) { function fromUint256(uint256 value) public pure returns (string memory) {
return Strings.toString(value); return Strings.toString(value);
} }
uint256[50] private __gap;
} }
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
import '../token/ERC20/TokenTimelock.sol';
import "../Initializable.sol";
contract TokenTimelockMockUpgradeSafe is Initializable, TokenTimelockUpgradeSafe {
constructor(IERC20 token, address beneficiary, uint256 releaseTime) public {
__TokenTimelockMock_init(token, beneficiary, releaseTime);
}
function __TokenTimelockMock_init(IERC20 token, address beneficiary, uint256 releaseTime) internal initializer {
__TokenTimelock_init_unchained(token, beneficiary, releaseTime);
__TokenTimelockMock_init_unchained(token, beneficiary, releaseTime);
}
function __TokenTimelockMock_init_unchained(IERC20 token, address beneficiary, uint256 releaseTime) internal initializer {
}
uint256[50] private __gap;
}
...@@ -4,6 +4,7 @@ pragma solidity ^0.6.0; ...@@ -4,6 +4,7 @@ pragma solidity ^0.6.0;
import "../GSN/Context.sol"; import "../GSN/Context.sol";
import "../math/SafeMath.sol"; import "../math/SafeMath.sol";
import "../Initializable.sol";
/** /**
* @title PaymentSplitter * @title PaymentSplitter
...@@ -18,7 +19,7 @@ import "../math/SafeMath.sol"; ...@@ -18,7 +19,7 @@ import "../math/SafeMath.sol";
* accounts but kept in this contract, and the actual transfer is triggered as a separate step by calling the {release} * accounts but kept in this contract, and the actual transfer is triggered as a separate step by calling the {release}
* function. * function.
*/ */
contract PaymentSplitter is Context { contract PaymentSplitterUpgradeSafe is Initializable, ContextUpgradeSafe {
using SafeMath for uint256; using SafeMath for uint256;
event PayeeAdded(address account, uint256 shares); event PayeeAdded(address account, uint256 shares);
...@@ -39,7 +40,15 @@ contract PaymentSplitter is Context { ...@@ -39,7 +40,15 @@ contract PaymentSplitter is Context {
* All addresses in `payees` must be non-zero. Both arrays must have the same non-zero length, and there must be no * All addresses in `payees` must be non-zero. Both arrays must have the same non-zero length, and there must be no
* duplicates in `payees`. * duplicates in `payees`.
*/ */
constructor (address[] memory payees, uint256[] memory shares) public payable {
function __PaymentSplitter_init(address[] memory payees, uint256[] memory shares) internal initializer {
__Context_init_unchained();
__PaymentSplitter_init_unchained(payees, shares);
}
function __PaymentSplitter_init_unchained(address[] memory payees, uint256[] memory shares) internal initializer {
// solhint-disable-next-line max-line-length // solhint-disable-next-line max-line-length
require(payees.length == shares.length, "PaymentSplitter: payees and shares length mismatch"); require(payees.length == shares.length, "PaymentSplitter: payees and shares length mismatch");
require(payees.length > 0, "PaymentSplitter: no payees"); require(payees.length > 0, "PaymentSplitter: no payees");
...@@ -47,8 +56,10 @@ contract PaymentSplitter is Context { ...@@ -47,8 +56,10 @@ contract PaymentSplitter is Context {
for (uint256 i = 0; i < payees.length; i++) { for (uint256 i = 0; i < payees.length; i++) {
_addPayee(payees[i], shares[i]); _addPayee(payees[i], shares[i]);
} }
} }
/** /**
* @dev The Ether received will be logged with {PaymentReceived} events. Note that these events are not fully * @dev The Ether received will be logged with {PaymentReceived} events. Note that these events are not fully
* reliable: it's possible for a contract to receive Ether without triggering this function. This only affects the * reliable: it's possible for a contract to receive Ether without triggering this function. This only affects the
...@@ -131,4 +142,6 @@ contract PaymentSplitter is Context { ...@@ -131,4 +142,6 @@ contract PaymentSplitter is Context {
_totalShares = _totalShares.add(shares_); _totalShares = _totalShares.add(shares_);
emit PayeeAdded(account, shares_); emit PayeeAdded(account, shares_);
} }
uint256[45] private __gap;
} }
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
pragma solidity ^0.6.2; pragma solidity ^0.6.2;
import "./escrow/Escrow.sol"; import "./escrow/Escrow.sol";
import "../Initializable.sol";
/** /**
* @dev Simple implementation of a * @dev Simple implementation of a
...@@ -22,13 +23,22 @@ import "./escrow/Escrow.sol"; ...@@ -22,13 +23,22 @@ import "./escrow/Escrow.sol";
* instead of Solidity's `transfer` function. Payees can query their due * instead of Solidity's `transfer` function. Payees can query their due
* payments with {payments}, and retrieve them with {withdrawPayments}. * payments with {payments}, and retrieve them with {withdrawPayments}.
*/ */
contract PullPayment { contract PullPaymentUpgradeSafe is Initializable {
Escrow private _escrow; EscrowUpgradeSafe private _escrow;
constructor () internal {
_escrow = new Escrow(); function __PullPayment_init() internal initializer {
__PullPayment_init_unchained();
} }
function __PullPayment_init_unchained() internal initializer {
_escrow = new EscrowUpgradeSafe();
_escrow.initialize();
}
/** /**
* @dev Withdraw accumulated payments, forwarding all gas to the recipient. * @dev Withdraw accumulated payments, forwarding all gas to the recipient.
* *
...@@ -66,4 +76,6 @@ contract PullPayment { ...@@ -66,4 +76,6 @@ contract PullPayment {
function _asyncTransfer(address dest, uint256 amount) internal virtual { function _asyncTransfer(address dest, uint256 amount) internal virtual {
_escrow.deposit{ value: amount }(dest); _escrow.deposit{ value: amount }(dest);
} }
uint256[49] private __gap;
} }
...@@ -3,13 +3,26 @@ ...@@ -3,13 +3,26 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "./Escrow.sol"; import "./Escrow.sol";
import "../../Initializable.sol";
/** /**
* @title ConditionalEscrow * @title ConditionalEscrow
* @dev Base abstract escrow to only allow withdrawal if a condition is met. * @dev Base abstract escrow to only allow withdrawal if a condition is met.
* @dev Intended usage: See {Escrow}. Same usage guidelines apply here. * @dev Intended usage: See {Escrow}. Same usage guidelines apply here.
*/ */
abstract contract ConditionalEscrow is Escrow { abstract contract ConditionalEscrowUpgradeSafe is Initializable, EscrowUpgradeSafe {
function __ConditionalEscrow_init() internal initializer {
__Context_init_unchained();
__Ownable_init_unchained();
__Escrow_init_unchained();
__ConditionalEscrow_init_unchained();
}
function __ConditionalEscrow_init_unchained() internal initializer {
}
/** /**
* @dev Returns whether an address is allowed to withdraw their funds. To be * @dev Returns whether an address is allowed to withdraw their funds. To be
* implemented by derived contracts. * implemented by derived contracts.
...@@ -21,4 +34,6 @@ abstract contract ConditionalEscrow is Escrow { ...@@ -21,4 +34,6 @@ abstract contract ConditionalEscrow is Escrow {
require(withdrawalAllowed(payee), "ConditionalEscrow: payee is not allowed to withdraw"); require(withdrawalAllowed(payee), "ConditionalEscrow: payee is not allowed to withdraw");
super.withdraw(payee); super.withdraw(payee);
} }
uint256[50] private __gap;
} }
...@@ -5,6 +5,7 @@ pragma solidity ^0.6.0; ...@@ -5,6 +5,7 @@ pragma solidity ^0.6.0;
import "../../math/SafeMath.sol"; import "../../math/SafeMath.sol";
import "../../access/Ownable.sol"; import "../../access/Ownable.sol";
import "../../utils/Address.sol"; import "../../utils/Address.sol";
import "../../Initializable.sol";
/** /**
* @title Escrow * @title Escrow
...@@ -19,7 +20,22 @@ import "../../utils/Address.sol"; ...@@ -19,7 +20,22 @@ import "../../utils/Address.sol";
* payment method should be its owner, and provide public methods redirecting * payment method should be its owner, and provide public methods redirecting
* to the escrow's deposit and withdraw. * to the escrow's deposit and withdraw.
*/ */
contract Escrow is Ownable { contract EscrowUpgradeSafe is Initializable, OwnableUpgradeSafe {
function initialize() public {
__Escrow_init();
}
function __Escrow_init() internal initializer {
__Context_init_unchained();
__Ownable_init_unchained();
__Escrow_init_unchained();
}
function __Escrow_init_unchained() internal initializer {
}
using SafeMath for uint256; using SafeMath for uint256;
using Address for address payable; using Address for address payable;
...@@ -62,4 +78,6 @@ contract Escrow is Ownable { ...@@ -62,4 +78,6 @@ contract Escrow is Ownable {
emit Withdrawn(payee, payment); emit Withdrawn(payee, payment);
} }
uint256[49] private __gap;
} }
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "./ConditionalEscrow.sol"; import "./ConditionalEscrow.sol";
import "../../Initializable.sol";
/** /**
* @title RefundEscrow * @title RefundEscrow
...@@ -14,7 +15,7 @@ import "./ConditionalEscrow.sol"; ...@@ -14,7 +15,7 @@ import "./ConditionalEscrow.sol";
* withdrawal by the beneficiary, or refunds to the depositors. All interactions * withdrawal by the beneficiary, or refunds to the depositors. All interactions
* with `RefundEscrow` will be made through the owner contract. * with `RefundEscrow` will be made through the owner contract.
*/ */
contract RefundEscrow is ConditionalEscrow { contract RefundEscrowUpgradeSafe is Initializable, ConditionalEscrowUpgradeSafe {
enum State { Active, Refunding, Closed } enum State { Active, Refunding, Closed }
event RefundsClosed(); event RefundsClosed();
...@@ -27,12 +28,25 @@ contract RefundEscrow is ConditionalEscrow { ...@@ -27,12 +28,25 @@ contract RefundEscrow is ConditionalEscrow {
* @dev Constructor. * @dev Constructor.
* @param beneficiary The beneficiary of the deposits. * @param beneficiary The beneficiary of the deposits.
*/ */
constructor (address payable beneficiary) public {
function __RefundEscrow_init(address payable beneficiary) internal initializer {
__Context_init_unchained();
__Ownable_init_unchained();
__Escrow_init_unchained();
__ConditionalEscrow_init_unchained();
__RefundEscrow_init_unchained(beneficiary);
}
function __RefundEscrow_init_unchained(address payable beneficiary) internal initializer {
require(beneficiary != address(0), "RefundEscrow: beneficiary is the zero address"); require(beneficiary != address(0), "RefundEscrow: beneficiary is the zero address");
_beneficiary = beneficiary; _beneficiary = beneficiary;
_state = State.Active; _state = State.Active;
} }
/** /**
* @return The current state of the escrow. * @return The current state of the escrow.
*/ */
...@@ -90,4 +104,6 @@ contract RefundEscrow is ConditionalEscrow { ...@@ -90,4 +104,6 @@ contract RefundEscrow is ConditionalEscrow {
function withdrawalAllowed(address) public view override returns (bool) { function withdrawalAllowed(address) public view override returns (bool) {
return _state == State.Refunding; return _state == State.Refunding;
} }
uint256[49] private __gap;
} }
...@@ -7,6 +7,7 @@ import "../GSN/Context.sol"; ...@@ -7,6 +7,7 @@ import "../GSN/Context.sol";
import "../token/ERC1155/ERC1155.sol"; import "../token/ERC1155/ERC1155.sol";
import "../token/ERC1155/ERC1155Burnable.sol"; import "../token/ERC1155/ERC1155Burnable.sol";
import "../token/ERC1155/ERC1155Pausable.sol"; import "../token/ERC1155/ERC1155Pausable.sol";
import "../Initializable.sol";
/** /**
* @dev {ERC1155} token, including: * @dev {ERC1155} token, including:
...@@ -22,7 +23,7 @@ import "../token/ERC1155/ERC1155Pausable.sol"; ...@@ -22,7 +23,7 @@ import "../token/ERC1155/ERC1155Pausable.sol";
* roles, as well as the default admin role, which will let it grant both minter * roles, as well as the default admin role, which will let it grant both minter
* and pauser roles to other accounts. * and pauser roles to other accounts.
*/ */
contract ERC1155PresetMinterPauser is Context, AccessControl, ERC1155Burnable, ERC1155Pausable { contract ERC1155PresetMinterPauserUpgradeSafe is Initializable, ContextUpgradeSafe, AccessControlUpgradeSafe, ERC1155BurnableUpgradeSafe, ERC1155PausableUpgradeSafe {
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE"); bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
...@@ -30,13 +31,33 @@ contract ERC1155PresetMinterPauser is Context, AccessControl, ERC1155Burnable, E ...@@ -30,13 +31,33 @@ contract ERC1155PresetMinterPauser is Context, AccessControl, ERC1155Burnable, E
* @dev Grants `DEFAULT_ADMIN_ROLE`, `MINTER_ROLE`, and `PAUSER_ROLE` to the account that * @dev Grants `DEFAULT_ADMIN_ROLE`, `MINTER_ROLE`, and `PAUSER_ROLE` to the account that
* deploys the contract. * deploys the contract.
*/ */
constructor(string memory uri) public ERC1155(uri) {
function initialize(string memory uri) public {
__ERC1155PresetMinterPauser_init(uri);
}
function __ERC1155PresetMinterPauser_init(string memory uri) internal initializer {
__Context_init_unchained();
__AccessControl_init_unchained();
__ERC165_init_unchained();
__ERC1155_init_unchained(uri);
__ERC1155Burnable_init_unchained();
__Pausable_init_unchained();
__ERC1155Pausable_init_unchained();
__ERC1155PresetMinterPauser_init_unchained(uri);
}
function __ERC1155PresetMinterPauser_init_unchained(string memory uri) internal initializer {
_setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
_setupRole(MINTER_ROLE, _msgSender()); _setupRole(MINTER_ROLE, _msgSender());
_setupRole(PAUSER_ROLE, _msgSender()); _setupRole(PAUSER_ROLE, _msgSender());
} }
/** /**
* @dev Creates `amount` new tokens for `to`, of token type `id`. * @dev Creates `amount` new tokens for `to`, of token type `id`.
* *
...@@ -97,8 +118,10 @@ contract ERC1155PresetMinterPauser is Context, AccessControl, ERC1155Burnable, E ...@@ -97,8 +118,10 @@ contract ERC1155PresetMinterPauser is Context, AccessControl, ERC1155Burnable, E
uint256[] memory amounts, uint256[] memory amounts,
bytes memory data bytes memory data
) )
internal virtual override(ERC1155, ERC1155Pausable) internal virtual override(ERC1155UpgradeSafe, ERC1155PausableUpgradeSafe)
{ {
super._beforeTokenTransfer(operator, from, to, ids, amounts, data); super._beforeTokenTransfer(operator, from, to, ids, amounts, data);
} }
uint256[50] private __gap;
} }
...@@ -7,6 +7,7 @@ import "../GSN/Context.sol"; ...@@ -7,6 +7,7 @@ import "../GSN/Context.sol";
import "../token/ERC20/ERC20.sol"; import "../token/ERC20/ERC20.sol";
import "../token/ERC20/ERC20Burnable.sol"; import "../token/ERC20/ERC20Burnable.sol";
import "../token/ERC20/ERC20Pausable.sol"; import "../token/ERC20/ERC20Pausable.sol";
import "../Initializable.sol";
/** /**
* @dev {ERC20} token, including: * @dev {ERC20} token, including:
...@@ -22,7 +23,7 @@ import "../token/ERC20/ERC20Pausable.sol"; ...@@ -22,7 +23,7 @@ import "../token/ERC20/ERC20Pausable.sol";
* roles, as well as the default admin role, which will let it grant both minter * roles, as well as the default admin role, which will let it grant both minter
* and pauser roles to other accounts. * and pauser roles to other accounts.
*/ */
contract ERC20PresetMinterPauser is Context, AccessControl, ERC20Burnable, ERC20Pausable { contract ERC20PresetMinterPauserUpgradeSafe is Initializable, ContextUpgradeSafe, AccessControlUpgradeSafe, ERC20BurnableUpgradeSafe, ERC20PausableUpgradeSafe {
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE"); bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
...@@ -32,13 +33,32 @@ contract ERC20PresetMinterPauser is Context, AccessControl, ERC20Burnable, ERC20 ...@@ -32,13 +33,32 @@ contract ERC20PresetMinterPauser is Context, AccessControl, ERC20Burnable, ERC20
* *
* See {ERC20-constructor}. * See {ERC20-constructor}.
*/ */
constructor(string memory name, string memory symbol) public ERC20(name, symbol) {
function initialize(string memory name, string memory symbol) public {
__ERC20PresetMinterPauser_init(name, symbol);
}
function __ERC20PresetMinterPauser_init(string memory name, string memory symbol) internal initializer {
__Context_init_unchained();
__AccessControl_init_unchained();
__ERC20_init_unchained(name, symbol);
__ERC20Burnable_init_unchained();
__Pausable_init_unchained();
__ERC20Pausable_init_unchained();
__ERC20PresetMinterPauser_init_unchained(name, symbol);
}
function __ERC20PresetMinterPauser_init_unchained(string memory name, string memory symbol) internal initializer {
_setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
_setupRole(MINTER_ROLE, _msgSender()); _setupRole(MINTER_ROLE, _msgSender());
_setupRole(PAUSER_ROLE, _msgSender()); _setupRole(PAUSER_ROLE, _msgSender());
} }
/** /**
* @dev Creates `amount` new tokens for `to`. * @dev Creates `amount` new tokens for `to`.
* *
...@@ -81,7 +101,9 @@ contract ERC20PresetMinterPauser is Context, AccessControl, ERC20Burnable, ERC20 ...@@ -81,7 +101,9 @@ contract ERC20PresetMinterPauser is Context, AccessControl, ERC20Burnable, ERC20
_unpause(); _unpause();
} }
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override(ERC20, ERC20Pausable) { function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override(ERC20UpgradeSafe, ERC20PausableUpgradeSafe) {
super._beforeTokenTransfer(from, to, amount); super._beforeTokenTransfer(from, to, amount);
} }
uint256[50] private __gap;
} }
...@@ -8,6 +8,7 @@ import "../utils/Counters.sol"; ...@@ -8,6 +8,7 @@ import "../utils/Counters.sol";
import "../token/ERC721/ERC721.sol"; import "../token/ERC721/ERC721.sol";
import "../token/ERC721/ERC721Burnable.sol"; import "../token/ERC721/ERC721Burnable.sol";
import "../token/ERC721/ERC721Pausable.sol"; import "../token/ERC721/ERC721Pausable.sol";
import "../Initializable.sol";
/** /**
* @dev {ERC721} token, including: * @dev {ERC721} token, including:
...@@ -24,7 +25,7 @@ import "../token/ERC721/ERC721Pausable.sol"; ...@@ -24,7 +25,7 @@ import "../token/ERC721/ERC721Pausable.sol";
* roles, as well as the default admin role, which will let it grant both minter * roles, as well as the default admin role, which will let it grant both minter
* and pauser roles to other accounts. * and pauser roles to other accounts.
*/ */
contract ERC721PresetMinterPauserAutoId is Context, AccessControl, ERC721Burnable, ERC721Pausable { contract ERC721PresetMinterPauserAutoIdUpgradeSafe is Initializable, ContextUpgradeSafe, AccessControlUpgradeSafe, ERC721BurnableUpgradeSafe, ERC721PausableUpgradeSafe {
using Counters for Counters.Counter; using Counters for Counters.Counter;
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
...@@ -39,15 +40,35 @@ contract ERC721PresetMinterPauserAutoId is Context, AccessControl, ERC721Burnabl ...@@ -39,15 +40,35 @@ contract ERC721PresetMinterPauserAutoId is Context, AccessControl, ERC721Burnabl
* Token URIs will be autogenerated based on `baseURI` and their token IDs. * Token URIs will be autogenerated based on `baseURI` and their token IDs.
* See {ERC721-tokenURI}. * See {ERC721-tokenURI}.
*/ */
constructor(string memory name, string memory symbol, string memory baseURI) public ERC721(name, symbol) {
function initialize(string memory name, string memory symbol, string memory baseURI) public {
__ERC721PresetMinterPauserAutoId_init(name, symbol, baseURI);
}
function __ERC721PresetMinterPauserAutoId_init(string memory name, string memory symbol, string memory baseURI) internal initializer {
__Context_init_unchained();
__AccessControl_init_unchained();
__ERC165_init_unchained();
__ERC721_init_unchained(name, symbol);
__ERC721Burnable_init_unchained();
__Pausable_init_unchained();
__ERC721Pausable_init_unchained();
__ERC721PresetMinterPauserAutoId_init_unchained(name, symbol, baseURI);
}
function __ERC721PresetMinterPauserAutoId_init_unchained(string memory name, string memory symbol, string memory baseURI) internal initializer {
_setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
_setupRole(MINTER_ROLE, _msgSender()); _setupRole(MINTER_ROLE, _msgSender());
_setupRole(PAUSER_ROLE, _msgSender()); _setupRole(PAUSER_ROLE, _msgSender());
_setBaseURI(baseURI); _setBaseURI(baseURI);
} }
/** /**
* @dev Creates a new token for `to`. Its token ID will be automatically * @dev Creates a new token for `to`. Its token ID will be automatically
* assigned (and available on the emitted {IERC721-Transfer} event), and the token * assigned (and available on the emitted {IERC721-Transfer} event), and the token
...@@ -96,7 +117,9 @@ contract ERC721PresetMinterPauserAutoId is Context, AccessControl, ERC721Burnabl ...@@ -96,7 +117,9 @@ contract ERC721PresetMinterPauserAutoId is Context, AccessControl, ERC721Burnabl
_unpause(); _unpause();
} }
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual override(ERC721, ERC721Pausable) { function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual override(ERC721UpgradeSafe, ERC721PausableUpgradeSafe) {
super._beforeTokenTransfer(from, to, tokenId); super._beforeTokenTransfer(from, to, tokenId);
} }
uint256[49] private __gap;
} }
...@@ -9,6 +9,7 @@ import "../../GSN/Context.sol"; ...@@ -9,6 +9,7 @@ import "../../GSN/Context.sol";
import "../../introspection/ERC165.sol"; import "../../introspection/ERC165.sol";
import "../../math/SafeMath.sol"; import "../../math/SafeMath.sol";
import "../../utils/Address.sol"; import "../../utils/Address.sol";
import "../../Initializable.sol";
/** /**
* *
...@@ -18,7 +19,7 @@ import "../../utils/Address.sol"; ...@@ -18,7 +19,7 @@ import "../../utils/Address.sol";
* *
* _Available since v3.1._ * _Available since v3.1._
*/ */
contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { contract ERC1155UpgradeSafe is Initializable, ContextUpgradeSafe, ERC165UpgradeSafe, IERC1155, IERC1155MetadataURI {
using SafeMath for uint256; using SafeMath for uint256;
using Address for address; using Address for address;
...@@ -52,7 +53,16 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { ...@@ -52,7 +53,16 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI {
/** /**
* @dev See {_setURI}. * @dev See {_setURI}.
*/ */
constructor (string memory uri) public {
function __ERC1155_init(string memory uri) internal initializer {
__Context_init_unchained();
__ERC165_init_unchained();
__ERC1155_init_unchained(uri);
}
function __ERC1155_init_unchained(string memory uri) internal initializer {
_setURI(uri); _setURI(uri);
// register the supported interfaces to conform to ERC1155 via ERC165 // register the supported interfaces to conform to ERC1155 via ERC165
...@@ -60,8 +70,10 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { ...@@ -60,8 +70,10 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI {
// register the supported interfaces to conform to ERC1155MetadataURI via ERC165 // register the supported interfaces to conform to ERC1155MetadataURI via ERC165
_registerInterface(_INTERFACE_ID_ERC1155_METADATA_URI); _registerInterface(_INTERFACE_ID_ERC1155_METADATA_URI);
} }
/** /**
* @dev See {IERC1155MetadataURI-uri}. * @dev See {IERC1155MetadataURI-uri}.
* *
...@@ -410,4 +422,6 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { ...@@ -410,4 +422,6 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI {
return array; return array;
} }
uint256[47] private __gap;
} }
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "./ERC1155.sol"; import "./ERC1155.sol";
import "../../Initializable.sol";
/** /**
* @dev Extension of {ERC1155} that allows token holders to destroy both their * @dev Extension of {ERC1155} that allows token holders to destroy both their
...@@ -10,7 +11,18 @@ import "./ERC1155.sol"; ...@@ -10,7 +11,18 @@ import "./ERC1155.sol";
* *
* _Available since v3.1._ * _Available since v3.1._
*/ */
abstract contract ERC1155Burnable is ERC1155 { abstract contract ERC1155BurnableUpgradeSafe is Initializable, ERC1155UpgradeSafe {
function __ERC1155Burnable_init() internal initializer {
__Context_init_unchained();
__ERC165_init_unchained();
__ERC1155Burnable_init_unchained();
}
function __ERC1155Burnable_init_unchained() internal initializer {
}
function burn(address account, uint256 id, uint256 value) public virtual { function burn(address account, uint256 id, uint256 value) public virtual {
require( require(
account == _msgSender() || isApprovedForAll(account, _msgSender()), account == _msgSender() || isApprovedForAll(account, _msgSender()),
...@@ -28,4 +40,6 @@ abstract contract ERC1155Burnable is ERC1155 { ...@@ -28,4 +40,6 @@ abstract contract ERC1155Burnable is ERC1155 {
_burnBatch(account, ids, values); _burnBatch(account, ids, values);
} }
uint256[50] private __gap;
} }
...@@ -3,11 +3,23 @@ ...@@ -3,11 +3,23 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "./ERC1155Receiver.sol"; import "./ERC1155Receiver.sol";
import "../../Initializable.sol";
/** /**
* @dev _Available since v3.1._ * @dev _Available since v3.1._
*/ */
contract ERC1155Holder is ERC1155Receiver { contract ERC1155HolderUpgradeSafe is Initializable, ERC1155ReceiverUpgradeSafe {
function __ERC1155Holder_init() internal initializer {
__ERC165_init_unchained();
__ERC1155Receiver_init_unchained();
__ERC1155Holder_init_unchained();
}
function __ERC1155Holder_init_unchained() internal initializer {
}
function onERC1155Received(address, address, uint256, uint256, bytes memory) public virtual override returns (bytes4) { function onERC1155Received(address, address, uint256, uint256, bytes memory) public virtual override returns (bytes4) {
return this.onERC1155Received.selector; return this.onERC1155Received.selector;
} }
...@@ -15,4 +27,6 @@ contract ERC1155Holder is ERC1155Receiver { ...@@ -15,4 +27,6 @@ contract ERC1155Holder is ERC1155Receiver {
function onERC1155BatchReceived(address, address, uint256[] memory, uint256[] memory, bytes memory) public virtual override returns (bytes4) { function onERC1155BatchReceived(address, address, uint256[] memory, uint256[] memory, bytes memory) public virtual override returns (bytes4) {
return this.onERC1155BatchReceived.selector; return this.onERC1155BatchReceived.selector;
} }
uint256[50] private __gap;
} }
...@@ -4,6 +4,7 @@ pragma solidity ^0.6.0; ...@@ -4,6 +4,7 @@ pragma solidity ^0.6.0;
import "./ERC1155.sol"; import "./ERC1155.sol";
import "../../utils/Pausable.sol"; import "../../utils/Pausable.sol";
import "../../Initializable.sol";
/** /**
* @dev ERC1155 token with pausable token transfers, minting and burning. * @dev ERC1155 token with pausable token transfers, minting and burning.
...@@ -14,7 +15,19 @@ import "../../utils/Pausable.sol"; ...@@ -14,7 +15,19 @@ import "../../utils/Pausable.sol";
* *
* _Available since v3.1._ * _Available since v3.1._
*/ */
abstract contract ERC1155Pausable is ERC1155, Pausable { abstract contract ERC1155PausableUpgradeSafe is Initializable, ERC1155UpgradeSafe, PausableUpgradeSafe {
function __ERC1155Pausable_init() internal initializer {
__Context_init_unchained();
__ERC165_init_unchained();
__Pausable_init_unchained();
__ERC1155Pausable_init_unchained();
}
function __ERC1155Pausable_init_unchained() internal initializer {
}
/** /**
* @dev See {ERC1155-_beforeTokenTransfer}. * @dev See {ERC1155-_beforeTokenTransfer}.
* *
...@@ -36,4 +49,6 @@ abstract contract ERC1155Pausable is ERC1155, Pausable { ...@@ -36,4 +49,6 @@ abstract contract ERC1155Pausable is ERC1155, Pausable {
require(!paused(), "ERC1155Pausable: token transfer while paused"); require(!paused(), "ERC1155Pausable: token transfer while paused");
} }
uint256[50] private __gap;
} }
...@@ -4,15 +4,28 @@ pragma solidity ^0.6.0; ...@@ -4,15 +4,28 @@ pragma solidity ^0.6.0;
import "./IERC1155Receiver.sol"; import "./IERC1155Receiver.sol";
import "../../introspection/ERC165.sol"; import "../../introspection/ERC165.sol";
import "../../Initializable.sol";
/** /**
* @dev _Available since v3.1._ * @dev _Available since v3.1._
*/ */
abstract contract ERC1155Receiver is ERC165, IERC1155Receiver { abstract contract ERC1155ReceiverUpgradeSafe is Initializable, ERC165UpgradeSafe, IERC1155Receiver {
constructor() public {
function __ERC1155Receiver_init() internal initializer {
__ERC165_init_unchained();
__ERC1155Receiver_init_unchained();
}
function __ERC1155Receiver_init_unchained() internal initializer {
_registerInterface( _registerInterface(
ERC1155Receiver(0).onERC1155Received.selector ^ IERC1155Receiver(0).onERC1155Received.selector ^
ERC1155Receiver(0).onERC1155BatchReceived.selector IERC1155Receiver(0).onERC1155BatchReceived.selector
); );
} }
uint256[50] private __gap;
} }
...@@ -6,6 +6,7 @@ import "../../GSN/Context.sol"; ...@@ -6,6 +6,7 @@ import "../../GSN/Context.sol";
import "./IERC20.sol"; import "./IERC20.sol";
import "../../math/SafeMath.sol"; import "../../math/SafeMath.sol";
import "../../utils/Address.sol"; import "../../utils/Address.sol";
import "../../Initializable.sol";
/** /**
* @dev Implementation of the {IERC20} interface. * @dev Implementation of the {IERC20} interface.
...@@ -31,7 +32,7 @@ import "../../utils/Address.sol"; ...@@ -31,7 +32,7 @@ import "../../utils/Address.sol";
* functions have been added to mitigate the well-known issues around setting * functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}. * allowances. See {IERC20-approve}.
*/ */
contract ERC20 is Context, IERC20 { contract ERC20UpgradeSafe is Initializable, ContextUpgradeSafe, IERC20 {
using SafeMath for uint256; using SafeMath for uint256;
using Address for address; using Address for address;
...@@ -54,12 +55,22 @@ contract ERC20 is Context, IERC20 { ...@@ -54,12 +55,22 @@ contract ERC20 is Context, IERC20 {
* All three of these values are immutable: they can only be set once during * All three of these values are immutable: they can only be set once during
* construction. * construction.
*/ */
constructor (string memory name, string memory symbol) public {
function __ERC20_init(string memory name, string memory symbol) internal initializer {
__Context_init_unchained();
__ERC20_init_unchained(name, symbol);
}
function __ERC20_init_unchained(string memory name, string memory symbol) internal initializer {
_name = name; _name = name;
_symbol = symbol; _symbol = symbol;
_decimals = 18; _decimals = 18;
} }
/** /**
* @dev Returns the name of the token. * @dev Returns the name of the token.
*/ */
...@@ -304,4 +315,6 @@ contract ERC20 is Context, IERC20 { ...@@ -304,4 +315,6 @@ contract ERC20 is Context, IERC20 {
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/ */
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
uint256[44] private __gap;
} }
...@@ -4,13 +4,24 @@ pragma solidity ^0.6.0; ...@@ -4,13 +4,24 @@ pragma solidity ^0.6.0;
import "../../GSN/Context.sol"; import "../../GSN/Context.sol";
import "./ERC20.sol"; import "./ERC20.sol";
import "../../Initializable.sol";
/** /**
* @dev Extension of {ERC20} that allows token holders to destroy both their own * @dev Extension of {ERC20} that allows token holders to destroy both their own
* tokens and those that they have an allowance for, in a way that can be * tokens and those that they have an allowance for, in a way that can be
* recognized off-chain (via event analysis). * recognized off-chain (via event analysis).
*/ */
abstract contract ERC20Burnable is Context, ERC20 { abstract contract ERC20BurnableUpgradeSafe is Initializable, ContextUpgradeSafe, ERC20UpgradeSafe {
function __ERC20Burnable_init() internal initializer {
__Context_init_unchained();
__ERC20Burnable_init_unchained();
}
function __ERC20Burnable_init_unchained() internal initializer {
}
/** /**
* @dev Destroys `amount` tokens from the caller. * @dev Destroys `amount` tokens from the caller.
* *
...@@ -37,4 +48,6 @@ abstract contract ERC20Burnable is Context, ERC20 { ...@@ -37,4 +48,6 @@ abstract contract ERC20Burnable is Context, ERC20 {
_approve(account, _msgSender(), decreasedAllowance); _approve(account, _msgSender(), decreasedAllowance);
_burn(account, amount); _burn(account, amount);
} }
uint256[50] private __gap;
} }
...@@ -3,22 +3,33 @@ ...@@ -3,22 +3,33 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "./ERC20.sol"; import "./ERC20.sol";
import "../../Initializable.sol";
/** /**
* @dev Extension of {ERC20} that adds a cap to the supply of tokens. * @dev Extension of {ERC20} that adds a cap to the supply of tokens.
*/ */
abstract contract ERC20Capped is ERC20 { abstract contract ERC20CappedUpgradeSafe is Initializable, ERC20UpgradeSafe {
uint256 private _cap; uint256 private _cap;
/** /**
* @dev Sets the value of the `cap`. This value is immutable, it can only be * @dev Sets the value of the `cap`. This value is immutable, it can only be
* set once during construction. * set once during construction.
*/ */
constructor (uint256 cap) public {
function __ERC20Capped_init(uint256 cap) internal initializer {
__Context_init_unchained();
__ERC20Capped_init_unchained(cap);
}
function __ERC20Capped_init_unchained(uint256 cap) internal initializer {
require(cap > 0, "ERC20Capped: cap is 0"); require(cap > 0, "ERC20Capped: cap is 0");
_cap = cap; _cap = cap;
} }
/** /**
* @dev Returns the cap on the token's total supply. * @dev Returns the cap on the token's total supply.
*/ */
...@@ -40,4 +51,6 @@ abstract contract ERC20Capped is ERC20 { ...@@ -40,4 +51,6 @@ abstract contract ERC20Capped is ERC20 {
require(totalSupply().add(amount) <= _cap, "ERC20Capped: cap exceeded"); require(totalSupply().add(amount) <= _cap, "ERC20Capped: cap exceeded");
} }
} }
uint256[49] private __gap;
} }
...@@ -4,6 +4,7 @@ pragma solidity ^0.6.0; ...@@ -4,6 +4,7 @@ pragma solidity ^0.6.0;
import "./ERC20.sol"; import "./ERC20.sol";
import "../../utils/Pausable.sol"; import "../../utils/Pausable.sol";
import "../../Initializable.sol";
/** /**
* @dev ERC20 token with pausable token transfers, minting and burning. * @dev ERC20 token with pausable token transfers, minting and burning.
...@@ -12,7 +13,18 @@ import "../../utils/Pausable.sol"; ...@@ -12,7 +13,18 @@ import "../../utils/Pausable.sol";
* period, or having an emergency switch for freezing all token transfers in the * period, or having an emergency switch for freezing all token transfers in the
* event of a large bug. * event of a large bug.
*/ */
abstract contract ERC20Pausable is ERC20, Pausable { abstract contract ERC20PausableUpgradeSafe is Initializable, ERC20UpgradeSafe, PausableUpgradeSafe {
function __ERC20Pausable_init() internal initializer {
__Context_init_unchained();
__Pausable_init_unchained();
__ERC20Pausable_init_unchained();
}
function __ERC20Pausable_init_unchained() internal initializer {
}
/** /**
* @dev See {ERC20-_beforeTokenTransfer}. * @dev See {ERC20-_beforeTokenTransfer}.
* *
...@@ -25,4 +37,6 @@ abstract contract ERC20Pausable is ERC20, Pausable { ...@@ -25,4 +37,6 @@ abstract contract ERC20Pausable is ERC20, Pausable {
require(!paused(), "ERC20Pausable: token transfer while paused"); require(!paused(), "ERC20Pausable: token transfer while paused");
} }
uint256[50] private __gap;
} }
...@@ -6,6 +6,7 @@ import "../../math/SafeMath.sol"; ...@@ -6,6 +6,7 @@ import "../../math/SafeMath.sol";
import "../../utils/Arrays.sol"; import "../../utils/Arrays.sol";
import "../../utils/Counters.sol"; import "../../utils/Counters.sol";
import "./ERC20.sol"; import "./ERC20.sol";
import "../../Initializable.sol";
/** /**
* @dev This contract extends an ERC20 token with a snapshot mechanism. When a snapshot is created, the balances and * @dev This contract extends an ERC20 token with a snapshot mechanism. When a snapshot is created, the balances and
...@@ -31,7 +32,17 @@ import "./ERC20.sol"; ...@@ -31,7 +32,17 @@ import "./ERC20.sol";
* only significant for the first transfer that immediately follows a snapshot for a particular account. Subsequent * only significant for the first transfer that immediately follows a snapshot for a particular account. Subsequent
* transfers will have normal cost until the next snapshot, and so on. * transfers will have normal cost until the next snapshot, and so on.
*/ */
abstract contract ERC20Snapshot is ERC20 { abstract contract ERC20SnapshotUpgradeSafe is Initializable, ERC20UpgradeSafe {
function __ERC20Snapshot_init() internal initializer {
__Context_init_unchained();
__ERC20Snapshot_init_unchained();
}
function __ERC20Snapshot_init_unchained() internal initializer {
}
// Inspired by Jordi Baylina's MiniMeToken to record historical balances: // Inspired by Jordi Baylina's MiniMeToken to record historical balances:
// https://github.com/Giveth/minimd/blob/ea04d950eea153a04c51fa510b068b9dded390cb/contracts/MiniMeToken.sol // https://github.com/Giveth/minimd/blob/ea04d950eea153a04c51fa510b068b9dded390cb/contracts/MiniMeToken.sol
...@@ -181,4 +192,6 @@ abstract contract ERC20Snapshot is ERC20 { ...@@ -181,4 +192,6 @@ abstract contract ERC20Snapshot is ERC20 {
return ids[ids.length - 1]; return ids[ids.length - 1];
} }
} }
uint256[46] private __gap;
} }
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "./SafeERC20.sol"; import "./SafeERC20.sol";
import "../../Initializable.sol";
/** /**
* @dev A token holder contract that will allow a beneficiary to extract the * @dev A token holder contract that will allow a beneficiary to extract the
...@@ -11,7 +12,7 @@ import "./SafeERC20.sol"; ...@@ -11,7 +12,7 @@ import "./SafeERC20.sol";
* Useful for simple vesting schedules like "advisors get all of their tokens * Useful for simple vesting schedules like "advisors get all of their tokens
* after 1 year". * after 1 year".
*/ */
contract TokenTimelock { contract TokenTimelockUpgradeSafe is Initializable {
using SafeERC20 for IERC20; using SafeERC20 for IERC20;
// ERC20 basic token contract being held // ERC20 basic token contract being held
...@@ -23,14 +24,23 @@ contract TokenTimelock { ...@@ -23,14 +24,23 @@ contract TokenTimelock {
// timestamp when token release is enabled // timestamp when token release is enabled
uint256 private _releaseTime; uint256 private _releaseTime;
constructor (IERC20 token, address beneficiary, uint256 releaseTime) public {
function __TokenTimelock_init(IERC20 token, address beneficiary, uint256 releaseTime) internal initializer {
__TokenTimelock_init_unchained(token, beneficiary, releaseTime);
}
function __TokenTimelock_init_unchained(IERC20 token, address beneficiary, uint256 releaseTime) internal initializer {
// solhint-disable-next-line not-rely-on-time // solhint-disable-next-line not-rely-on-time
require(releaseTime > block.timestamp, "TokenTimelock: release time is before current time"); require(releaseTime > block.timestamp, "TokenTimelock: release time is before current time");
_token = token; _token = token;
_beneficiary = beneficiary; _beneficiary = beneficiary;
_releaseTime = releaseTime; _releaseTime = releaseTime;
} }
/** /**
* @return the token being held. * @return the token being held.
*/ */
...@@ -64,4 +74,6 @@ contract TokenTimelock { ...@@ -64,4 +74,6 @@ contract TokenTimelock {
_token.safeTransfer(_beneficiary, amount); _token.safeTransfer(_beneficiary, amount);
} }
uint256[47] private __gap;
} }
...@@ -13,12 +13,13 @@ import "../../utils/Address.sol"; ...@@ -13,12 +13,13 @@ import "../../utils/Address.sol";
import "../../utils/EnumerableSet.sol"; import "../../utils/EnumerableSet.sol";
import "../../utils/EnumerableMap.sol"; import "../../utils/EnumerableMap.sol";
import "../../utils/Strings.sol"; import "../../utils/Strings.sol";
import "../../Initializable.sol";
/** /**
* @title ERC721 Non-Fungible Token Standard basic implementation * @title ERC721 Non-Fungible Token Standard basic implementation
* @dev see https://eips.ethereum.org/EIPS/eip-721 * @dev see https://eips.ethereum.org/EIPS/eip-721
*/ */
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable { contract ERC721UpgradeSafe is Initializable, ContextUpgradeSafe, ERC165UpgradeSafe, IERC721, IERC721Metadata, IERC721Enumerable {
using SafeMath for uint256; using SafeMath for uint256;
using Address for address; using Address for address;
using EnumerableSet for EnumerableSet.UintSet; using EnumerableSet for EnumerableSet.UintSet;
...@@ -90,7 +91,16 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable ...@@ -90,7 +91,16 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable
/** /**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/ */
constructor (string memory name, string memory symbol) public {
function __ERC721_init(string memory name, string memory symbol) internal initializer {
__Context_init_unchained();
__ERC165_init_unchained();
__ERC721_init_unchained(name, symbol);
}
function __ERC721_init_unchained(string memory name, string memory symbol) internal initializer {
_name = name; _name = name;
_symbol = symbol; _symbol = symbol;
...@@ -98,8 +108,10 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable ...@@ -98,8 +108,10 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable
_registerInterface(_INTERFACE_ID_ERC721); _registerInterface(_INTERFACE_ID_ERC721);
_registerInterface(_INTERFACE_ID_ERC721_METADATA); _registerInterface(_INTERFACE_ID_ERC721_METADATA);
_registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE); _registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE);
} }
/** /**
* @dev See {IERC721-balanceOf}. * @dev See {IERC721-balanceOf}.
*/ */
...@@ -470,4 +482,6 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable ...@@ -470,4 +482,6 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/ */
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual { } function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual { }
uint256[41] private __gap;
} }
...@@ -4,12 +4,24 @@ pragma solidity ^0.6.0; ...@@ -4,12 +4,24 @@ pragma solidity ^0.6.0;
import "../../GSN/Context.sol"; import "../../GSN/Context.sol";
import "./ERC721.sol"; import "./ERC721.sol";
import "../../Initializable.sol";
/** /**
* @title ERC721 Burnable Token * @title ERC721 Burnable Token
* @dev ERC721 Token that can be irreversibly burned (destroyed). * @dev ERC721 Token that can be irreversibly burned (destroyed).
*/ */
abstract contract ERC721Burnable is Context, ERC721 { abstract contract ERC721BurnableUpgradeSafe is Initializable, ContextUpgradeSafe, ERC721UpgradeSafe {
function __ERC721Burnable_init() internal initializer {
__Context_init_unchained();
__ERC165_init_unchained();
__ERC721Burnable_init_unchained();
}
function __ERC721Burnable_init_unchained() internal initializer {
}
/** /**
* @dev Burns `tokenId`. See {ERC721-_burn}. * @dev Burns `tokenId`. See {ERC721-_burn}.
* *
...@@ -22,4 +34,6 @@ abstract contract ERC721Burnable is Context, ERC721 { ...@@ -22,4 +34,6 @@ abstract contract ERC721Burnable is Context, ERC721 {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721Burnable: caller is not owner nor approved"); require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721Burnable: caller is not owner nor approved");
_burn(tokenId); _burn(tokenId);
} }
uint256[50] private __gap;
} }
...@@ -3,14 +3,24 @@ ...@@ -3,14 +3,24 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "./IERC721Receiver.sol"; import "./IERC721Receiver.sol";
import "../../Initializable.sol";
/** /**
* @dev Implementation of the {IERC721Receiver} interface. * @dev Implementation of the {IERC721Receiver} interface.
* *
* Accepts all token transfers. * Accepts all token transfers.
* Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}. * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}.
*/ */
contract ERC721Holder is IERC721Receiver { contract ERC721HolderUpgradeSafe is Initializable, IERC721Receiver {
function __ERC721Holder_init() internal initializer {
__ERC721Holder_init_unchained();
}
function __ERC721Holder_init_unchained() internal initializer {
}
/** /**
* @dev See {IERC721Receiver-onERC721Received}. * @dev See {IERC721Receiver-onERC721Received}.
...@@ -20,4 +30,6 @@ contract ERC721Holder is IERC721Receiver { ...@@ -20,4 +30,6 @@ contract ERC721Holder is IERC721Receiver {
function onERC721Received(address, address, uint256, bytes memory) public virtual override returns (bytes4) { function onERC721Received(address, address, uint256, bytes memory) public virtual override returns (bytes4) {
return this.onERC721Received.selector; return this.onERC721Received.selector;
} }
uint256[50] private __gap;
} }
...@@ -4,6 +4,7 @@ pragma solidity ^0.6.0; ...@@ -4,6 +4,7 @@ pragma solidity ^0.6.0;
import "./ERC721.sol"; import "./ERC721.sol";
import "../../utils/Pausable.sol"; import "../../utils/Pausable.sol";
import "../../Initializable.sol";
/** /**
* @dev ERC721 token with pausable token transfers, minting and burning. * @dev ERC721 token with pausable token transfers, minting and burning.
...@@ -12,7 +13,19 @@ import "../../utils/Pausable.sol"; ...@@ -12,7 +13,19 @@ import "../../utils/Pausable.sol";
* period, or having an emergency switch for freezing all token transfers in the * period, or having an emergency switch for freezing all token transfers in the
* event of a large bug. * event of a large bug.
*/ */
abstract contract ERC721Pausable is ERC721, Pausable { abstract contract ERC721PausableUpgradeSafe is Initializable, ERC721UpgradeSafe, PausableUpgradeSafe {
function __ERC721Pausable_init() internal initializer {
__Context_init_unchained();
__ERC165_init_unchained();
__Pausable_init_unchained();
__ERC721Pausable_init_unchained();
}
function __ERC721Pausable_init_unchained() internal initializer {
}
/** /**
* @dev See {ERC721-_beforeTokenTransfer}. * @dev See {ERC721-_beforeTokenTransfer}.
* *
...@@ -25,4 +38,6 @@ abstract contract ERC721Pausable is ERC721, Pausable { ...@@ -25,4 +38,6 @@ abstract contract ERC721Pausable is ERC721, Pausable {
require(!paused(), "ERC721Pausable: token transfer while paused"); require(!paused(), "ERC721Pausable: token transfer while paused");
} }
uint256[50] private __gap;
} }
...@@ -10,6 +10,7 @@ import "../../token/ERC20/IERC20.sol"; ...@@ -10,6 +10,7 @@ import "../../token/ERC20/IERC20.sol";
import "../../math/SafeMath.sol"; import "../../math/SafeMath.sol";
import "../../utils/Address.sol"; import "../../utils/Address.sol";
import "../../introspection/IERC1820Registry.sol"; import "../../introspection/IERC1820Registry.sol";
import "../../Initializable.sol";
/** /**
* @dev Implementation of the {IERC777} interface. * @dev Implementation of the {IERC777} interface.
...@@ -26,7 +27,7 @@ import "../../introspection/IERC1820Registry.sol"; ...@@ -26,7 +27,7 @@ import "../../introspection/IERC1820Registry.sol";
* are no special restrictions in the amount of tokens that created, moved, or * are no special restrictions in the amount of tokens that created, moved, or
* destroyed. This makes integration with ERC20 applications seamless. * destroyed. This makes integration with ERC20 applications seamless.
*/ */
contract ERC777 is Context, IERC777, IERC20 { contract ERC777UpgradeSafe is Initializable, ContextUpgradeSafe, IERC777, IERC20 {
using SafeMath for uint256; using SafeMath for uint256;
using Address for address; using Address for address;
...@@ -66,11 +67,23 @@ contract ERC777 is Context, IERC777, IERC20 { ...@@ -66,11 +67,23 @@ contract ERC777 is Context, IERC777, IERC20 {
/** /**
* @dev `defaultOperators` may be an empty array. * @dev `defaultOperators` may be an empty array.
*/ */
constructor(
function __ERC777_init(
string memory name,
string memory symbol,
address[] memory defaultOperators
) internal initializer {
__Context_init_unchained();
__ERC777_init_unchained(name, symbol, defaultOperators);
}
function __ERC777_init_unchained(
string memory name, string memory name,
string memory symbol, string memory symbol,
address[] memory defaultOperators address[] memory defaultOperators
) public { ) internal initializer {
_name = name; _name = name;
_symbol = symbol; _symbol = symbol;
...@@ -82,8 +95,10 @@ contract ERC777 is Context, IERC777, IERC20 { ...@@ -82,8 +95,10 @@ contract ERC777 is Context, IERC777, IERC20 {
// register interfaces // register interfaces
_ERC1820_REGISTRY.setInterfaceImplementer(address(this), keccak256("ERC777Token"), address(this)); _ERC1820_REGISTRY.setInterfaceImplementer(address(this), keccak256("ERC777Token"), address(this));
_ERC1820_REGISTRY.setInterfaceImplementer(address(this), keccak256("ERC20Token"), address(this)); _ERC1820_REGISTRY.setInterfaceImplementer(address(this), keccak256("ERC20Token"), address(this));
} }
/** /**
* @dev See {IERC777-name}. * @dev See {IERC777-name}.
*/ */
...@@ -500,4 +515,6 @@ contract ERC777 is Context, IERC777, IERC20 { ...@@ -500,4 +515,6 @@ contract ERC777 is Context, IERC777, IERC20 {
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/ */
function _beforeTokenTransfer(address operator, address from, address to, uint256 amount) internal virtual { } function _beforeTokenTransfer(address operator, address from, address to, uint256 amount) internal virtual { }
uint256[41] private __gap;
} }
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "../GSN/Context.sol"; import "../GSN/Context.sol";
import "../Initializable.sol";
/** /**
* @dev Contract module which allows children to implement an emergency stop * @dev Contract module which allows children to implement an emergency stop
...@@ -13,7 +14,7 @@ import "../GSN/Context.sol"; ...@@ -13,7 +14,7 @@ import "../GSN/Context.sol";
* the functions of your contract. Note that they will not be pausable by * the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place. * simply including this module, only once the modifiers are put in place.
*/ */
contract Pausable is Context { contract PausableUpgradeSafe is Initializable, ContextUpgradeSafe {
/** /**
* @dev Emitted when the pause is triggered by `account`. * @dev Emitted when the pause is triggered by `account`.
*/ */
...@@ -29,10 +30,20 @@ contract Pausable is Context { ...@@ -29,10 +30,20 @@ contract Pausable is Context {
/** /**
* @dev Initializes the contract in unpaused state. * @dev Initializes the contract in unpaused state.
*/ */
constructor () internal {
function __Pausable_init() internal initializer {
__Context_init_unchained();
__Pausable_init_unchained();
}
function __Pausable_init_unchained() internal initializer {
_paused = false; _paused = false;
} }
/** /**
* @dev Returns true if the contract is paused, and false otherwise. * @dev Returns true if the contract is paused, and false otherwise.
*/ */
...@@ -87,4 +98,6 @@ contract Pausable is Context { ...@@ -87,4 +98,6 @@ contract Pausable is Context {
_paused = false; _paused = false;
emit Unpaused(_msgSender()); emit Unpaused(_msgSender());
} }
uint256[49] private __gap;
} }
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
import "../Initializable.sol";
/** /**
* @dev Contract module that helps prevent reentrant calls to a function. * @dev Contract module that helps prevent reentrant calls to a function.
...@@ -18,27 +19,28 @@ pragma solidity ^0.6.0; ...@@ -18,27 +19,28 @@ pragma solidity ^0.6.0;
* to protect against it, check out our blog post * to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/ */
contract ReentrancyGuard { contract ReentrancyGuardUpgradeSafe is Initializable {
// Booleans are more expensive than uint256 or any type that takes up a full bool private _notEntered;
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and function __ReentrancyGuard_init() internal initializer {
// pointer aliasing, and it cannot be disabled. __ReentrancyGuard_init_unchained();
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor () internal {
_status = _NOT_ENTERED;
} }
function __ReentrancyGuard_init_unchained() internal initializer {
// Storing an initial non-zero value makes deployment a bit more
// expensive, but in exchange the refund on every call to nonReentrant
// will be lower in amount. Since refunds are capped to a percetange of
// the total transaction's gas, it is best to keep them low in cases
// like this one, to increase the likelihood of the full refund coming
// into effect.
_notEntered = true;
}
/** /**
* @dev Prevents a contract from calling itself, directly or indirectly. * @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant` * Calling a `nonReentrant` function from another `nonReentrant`
...@@ -48,15 +50,17 @@ contract ReentrancyGuard { ...@@ -48,15 +50,17 @@ contract ReentrancyGuard {
*/ */
modifier nonReentrant() { modifier nonReentrant() {
// On the first call to nonReentrant, _notEntered will be true // On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); require(_notEntered, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail // Any calls to nonReentrant after this point will fail
_status = _ENTERED; _notEntered = false;
_; _;
// By storing the original value once again, a refund is triggered (see // By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200) // https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED; _notEntered = true;
} }
uint256[49] private __gap;
} }
...@@ -2,7 +2,7 @@ const { contract } = require('@openzeppelin/test-environment'); ...@@ -2,7 +2,7 @@ const { contract } = require('@openzeppelin/test-environment');
const { BN, expectEvent } = require('@openzeppelin/test-helpers'); const { BN, expectEvent } = require('@openzeppelin/test-helpers');
const ContextMock = contract.fromArtifact('ContextMock'); const ContextMock = contract.fromArtifact('ContextMockUpgradeSafe');
function shouldBehaveLikeRegularContext (sender) { function shouldBehaveLikeRegularContext (sender) {
describe('msgSender', function () { describe('msgSender', function () {
......
...@@ -2,8 +2,8 @@ const { accounts, contract } = require('@openzeppelin/test-environment'); ...@@ -2,8 +2,8 @@ const { accounts, contract } = require('@openzeppelin/test-environment');
require('@openzeppelin/test-helpers'); require('@openzeppelin/test-helpers');
const ContextMock = contract.fromArtifact('ContextMock'); const ContextMock = contract.fromArtifact('ContextMockUpgradeSafe');
const ContextMockCaller = contract.fromArtifact('ContextMockCaller'); const ContextMockCaller = contract.fromArtifact('ContextMockCallerUpgradeSafe');
const { shouldBehaveLikeRegularContext } = require('./Context.behavior'); const { shouldBehaveLikeRegularContext } = require('./Context.behavior');
......
...@@ -6,7 +6,7 @@ const gsn = require('@openzeppelin/gsn-helpers'); ...@@ -6,7 +6,7 @@ const gsn = require('@openzeppelin/gsn-helpers');
const { fixSignature } = require('../helpers/sign'); const { fixSignature } = require('../helpers/sign');
const { utils: { toBN } } = require('web3'); const { utils: { toBN } } = require('web3');
const ERC721GSNRecipientMock = contract.fromArtifact('ERC721GSNRecipientMock'); const ERC721GSNRecipientMock = contract.fromArtifact('ERC721GSNRecipientMockUpgradeSafe');
describe('ERC721GSNRecipient (integration)', function () { describe('ERC721GSNRecipient (integration)', function () {
const [ signer, sender ] = accounts; const [ signer, sender ] = accounts;
......
...@@ -7,8 +7,8 @@ const gsn = require('@openzeppelin/gsn-helpers'); ...@@ -7,8 +7,8 @@ const gsn = require('@openzeppelin/gsn-helpers');
const { expect } = require('chai'); const { expect } = require('chai');
const GSNRecipientMock = contract.fromArtifact('GSNRecipientMock'); const GSNRecipientMock = contract.fromArtifact('GSNRecipientMockUpgradeSafe');
const ContextMockCaller = contract.fromArtifact('ContextMockCaller'); const ContextMockCaller = contract.fromArtifact('ContextMockCallerUpgradeSafe');
const { shouldBehaveLikeRegularContext } = require('./Context.behavior'); const { shouldBehaveLikeRegularContext } = require('./Context.behavior');
......
...@@ -5,8 +5,8 @@ const gsn = require('@openzeppelin/gsn-helpers'); ...@@ -5,8 +5,8 @@ const gsn = require('@openzeppelin/gsn-helpers');
const { expect } = require('chai'); const { expect } = require('chai');
const GSNRecipientERC20FeeMock = contract.fromArtifact('GSNRecipientERC20FeeMock'); const GSNRecipientERC20FeeMock = contract.fromArtifact('GSNRecipientERC20FeeMockUpgradeSafe');
const ERC20 = contract.fromArtifact('ERC20'); const ERC20 = contract.fromArtifact('ERC20UpgradeSafe');
const IRelayHub = contract.fromArtifact('IRelayHub'); const IRelayHub = contract.fromArtifact('IRelayHub');
describe('GSNRecipientERC20Fee', function () { describe('GSNRecipientERC20Fee', function () {
......
...@@ -6,7 +6,7 @@ const { fixSignature } = require('../helpers/sign'); ...@@ -6,7 +6,7 @@ const { fixSignature } = require('../helpers/sign');
const { utils: { toBN } } = require('web3'); const { utils: { toBN } } = require('web3');
const { ZERO_ADDRESS } = constants; const { ZERO_ADDRESS } = constants;
const GSNRecipientSignatureMock = contract.fromArtifact('GSNRecipientSignatureMock'); const GSNRecipientSignatureMock = contract.fromArtifact('GSNRecipientSignatureMockUpgradeSafe');
describe('GSNRecipientSignature', function () { describe('GSNRecipientSignature', function () {
const [ signer, other ] = accounts; const [ signer, other ] = accounts;
......
...@@ -4,7 +4,7 @@ const { expectEvent, expectRevert } = require('@openzeppelin/test-helpers'); ...@@ -4,7 +4,7 @@ const { expectEvent, expectRevert } = require('@openzeppelin/test-helpers');
const { expect } = require('chai'); const { expect } = require('chai');
const AccessControlMock = contract.fromArtifact('AccessControlMock'); const AccessControlMock = contract.fromArtifact('AccessControlMockUpgradeSafe');
describe('AccessControl', function () { describe('AccessControl', function () {
const [ admin, authorized, otherAuthorized, other, otherAdmin ] = accounts; const [ admin, authorized, otherAuthorized, other, otherAdmin ] = accounts;
......
...@@ -4,7 +4,7 @@ const { ZERO_ADDRESS } = constants; ...@@ -4,7 +4,7 @@ const { ZERO_ADDRESS } = constants;
const { expect } = require('chai'); const { expect } = require('chai');
const Ownable = contract.fromArtifact('OwnableMock'); const Ownable = contract.fromArtifact('OwnableMockUpgradeSafe');
describe('Ownable', function () { describe('Ownable', function () {
const [ owner, other ] = accounts; const [ owner, other ] = accounts;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment