Commit 1e533d92 by github-actions

Transpile 435f0650

parent c4edd765
...@@ -27,3 +27,8 @@ jobs: ...@@ -27,3 +27,8 @@ jobs:
- run: bash scripts/upgradeable/transpile.sh - run: bash scripts/upgradeable/transpile.sh
if: github.event_name == 'pull_request' if: github.event_name == 'pull_request'
- run: npm run test - run: npm run test
env:
FORCE_COLOR: 1
ENABLE_GAS_REPORT: 1
- name: Print gas report
run: cat gas-report.txt
...@@ -20,6 +20,17 @@ ...@@ -20,6 +20,17 @@
## Unreleased ## Unreleased
* Now targeting the 0.8.x line of Solidity compilers. For 0.6.x (resp 0.7.x) support, use version 3.4.0 (resp 3.4.0-solc-0.7) of OpenZeppelin.
* `Context`: making `_msgData` return `bytes calldata` instead of `bytes memory` ([#2492](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2492))
* `ERC20`: Removed the `_setDecimals` function and the storage slot associated to decimals. ([#2502](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2502))
* `Strings`: addition of a `toHexString` function. ([#2504](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2504))
* `EnumerableMap`: change implementation to optimize for `key → value` lookups instead of enumeration. ([#2518](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2518))
* `GSN`: Deprecate GSNv1 support in favor of upcomming support for GSNv2. ([#2521](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2521))
* `ERC165`: Remove uses of storage in the base ERC165 implementation. ERC165 based contracts now use storage-less virtual functions. Old behaviour remains available in the `ERC165Storage` extension. ([#2505](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2505))
* `Initializable`: Make initializer check stricter during construction. ([#2531](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2531))
## 3.4.0 (2021-02-02)
* `BeaconProxy`: added new kind of proxy that allows simultaneous atomic upgrades. ([#2411](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2411)) * `BeaconProxy`: added new kind of proxy that allows simultaneous atomic upgrades. ([#2411](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2411))
* `EIP712`: added helpers to verify EIP712 typed data signatures on chain. ([#2418](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2418)) * `EIP712`: added helpers to verify EIP712 typed data signatures on chain. ([#2418](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2418))
* `ERC20Permit`: added an implementation of the ERC20 permit extension for gasless token approvals. ([#2237](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2237)) * `ERC20Permit`: added an implementation of the ERC20 permit extension for gasless token approvals. ([#2237](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2237))
...@@ -47,6 +58,12 @@ If you're using our implementation of ERC777 from version 3.3.0 or earlier, and ...@@ -47,6 +58,12 @@ If you're using our implementation of ERC777 from version 3.3.0 or earlier, and
* `TimelockController`: added a contract to augment access control schemes with a delay. ([#2354](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2354)) * `TimelockController`: added a contract to augment access control schemes with a delay. ([#2354](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2354))
* `EnumerableSet`: added `Bytes32Set`, for sets of `bytes32`. ([#2395](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2395)) * `EnumerableSet`: added `Bytes32Set`, for sets of `bytes32`. ([#2395](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2395))
## 3.2.2-solc-0.7 (2020-10-28)
* Resolve warnings introduced by Solidity 0.7.4. ([#2396](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2396))
## 3.2.1-solc-0.7 (2020-09-15)
* `ERC777`: Remove a warning about function state visibility in Solidity 0.7. ([#2327](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2327))
## 3.2.0 (2020-09-10) ## 3.2.0 (2020-09-10)
### New features ### New features
......
...@@ -34,7 +34,7 @@ The package replicates the structure of the main OpenZeppelin Contracts package, ...@@ -34,7 +34,7 @@ The package replicates the structure of the main OpenZeppelin Contracts package,
Constructors are replaced by internal initializer functions following the naming convention `__{ContractName}_init`. Since these are internal, you must always define your own public initializer function and call the parent initializer of the contract you extend. Constructors are replaced by internal initializer functions following the naming convention `__{ContractName}_init`. Since these are internal, you must always define your own public initializer function and call the parent initializer of the contract you extend.
```diff ```diff
- constructor() ERC721("MyCollectible", "MCO") public { - constructor() ERC721("MyCollectible", "MCO") {
+ function initialize() initializer public { + function initialize() initializer public {
+ __ERC721_init("MyCollectible", "MCO"); + __ERC721_init("MyCollectible", "MCO");
} }
......
const fs = require('fs');
const path = require('path');
usePlugin('solidity-coverage');
usePlugin('@nomiclabs/buidler-truffle5');
for (const f of fs.readdirSync(path.join(__dirname, 'buidler'))) {
require(path.join(__dirname, 'buidler', f));
}
module.exports = {
networks: {
buidlerevm: {
blockGasLimit: 10000000,
},
},
solc: {
version: '0.6.12',
},
};
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
import "../utils/ContextUpgradeable.sol";
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
import "./GSNRecipientUpgradeable.sol";
import "../math/SafeMathUpgradeable.sol";
import "../access/OwnableUpgradeable.sol";
import "../token/ERC20/SafeERC20Upgradeable.sol";
import "../token/ERC20/ERC20Upgradeable.sol";
import "../proxy/Initializable.sol";
/**
* @dev A xref:ROOT:gsn-strategies.adoc#gsn-strategies[GSN strategy] that charges transaction fees in a special purpose ERC20
* token, which we refer to as the gas payment token. The amount charged is exactly the amount of Ether charged to the
* recipient. This means that the token is essentially pegged to the value of Ether.
*
* The distribution strategy of the gas payment token to users is not defined by this contract. It's a mintable token
* whose only minter is the recipient, so the strategy must be implemented in a derived contract, making use of the
* internal {_mint} function.
*/
contract GSNRecipientERC20FeeUpgradeable is Initializable, GSNRecipientUpgradeable {
using SafeERC20Upgradeable for __unstable__ERC20OwnedUpgradeable;
using SafeMathUpgradeable for uint256;
enum GSNRecipientERC20FeeErrorCodes {
INSUFFICIENT_BALANCE
}
__unstable__ERC20OwnedUpgradeable private _token;
/**
* @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.
*/
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__ERC20OwnedUpgradeable();
_token.initialize(name, symbol);
}
/**
* @dev Returns the gas payment token.
*/
function token() public view virtual returns (__unstable__ERC20OwnedUpgradeable) {
return _token;
}
/**
* @dev Internal function that mints the gas payment token. Derived contracts should expose this function in their public API, with proper access control mechanisms.
*/
function _mint(address account, uint256 amount) internal virtual {
token().mint(account, amount);
}
/**
* @dev Ensures that only users with enough gas payment token balance can have transactions relayed through the GSN.
*/
function acceptRelayedCall(
address,
address from,
bytes memory,
uint256 transactionFee,
uint256 gasPrice,
uint256,
uint256,
bytes memory,
uint256 maxPossibleCharge
)
public
view
virtual
override
returns (uint256, bytes memory)
{
if (token().balanceOf(from) < maxPossibleCharge) {
return _rejectRelayedCall(uint256(GSNRecipientERC20FeeErrorCodes.INSUFFICIENT_BALANCE));
}
return _approveRelayedCall(abi.encode(from, maxPossibleCharge, transactionFee, gasPrice));
}
/**
* @dev Implements the precharge to the user. The maximum possible charge (depending on gas limit, gas price, and
* fee) will be deducted from the user balance of gas payment token. Note that this is an overestimation of the
* actual charge, necessary because we cannot predict how much gas the execution will actually need. The remainder
* is returned to the user in {_postRelayedCall}.
*/
function _preRelayedCall(bytes memory context) internal virtual override returns (bytes32) {
(address from, uint256 maxPossibleCharge) = abi.decode(context, (address, uint256));
// The maximum token charge is pre-charged from the user
token().safeTransferFrom(from, address(this), maxPossibleCharge);
return 0;
}
/**
* @dev Returns to the user the extra amount that was previously charged, once the actual execution cost is known.
*/
function _postRelayedCall(bytes memory context, bool, uint256 actualCharge, bytes32) internal virtual override {
(address from, uint256 maxPossibleCharge, uint256 transactionFee, uint256 gasPrice) =
abi.decode(context, (address, uint256, uint256, uint256));
// actualCharge is an _estimated_ charge, which assumes postRelayedCall will use all available gas.
// This implementation's gas cost can be roughly estimated as 10k gas, for the two SSTORE operations in an
// ERC20 transfer.
uint256 overestimation = _computeCharge(_POST_RELAYED_CALL_MAX_GAS.sub(10000), gasPrice, transactionFee);
actualCharge = actualCharge.sub(overestimation);
// After the relayed call has been executed and the actual charge estimated, the excess pre-charge is returned
token().safeTransfer(from, maxPossibleCharge.sub(actualCharge));
}
uint256[49] private __gap;
}
/**
* @title __unstable__ERC20Owned
* @dev An ERC20 token owned by another contract, which has minting permissions and can use transferFrom to receive
* anyone's tokens. This contract is an internal helper for GSNRecipientERC20Fee, and should not be used
* outside of this context.
*/
// solhint-disable-next-line contract-name-camelcase
contract __unstable__ERC20OwnedUpgradeable is Initializable, ERC20Upgradeable, OwnableUpgradeable {
function initialize(string memory name, string memory symbol) public virtual initializer {
____unstable__ERC20Owned_init(name, symbol);
}
uint256 private constant _UINT256_MAX = 2**256 - 1;
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
function mint(address account, uint256 amount) public virtual onlyOwner {
_mint(account, amount);
}
// The owner has 'infinite' allowance for all token holders
function allowance(address tokenOwner, address spender) public view virtual override returns (uint256) {
if (spender == owner()) {
return _UINT256_MAX;
} else {
return super.allowance(tokenOwner, spender);
}
}
// Allowance for the owner cannot be changed (it is always 'infinite')
function _approve(address tokenOwner, address spender, uint256 value) internal virtual override {
if (spender == owner()) {
return;
} else {
super._approve(tokenOwner, spender, value);
}
}
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
if (recipient == owner()) {
_transfer(sender, recipient, amount);
return true;
} else {
return super.transferFrom(sender, recipient, amount);
}
}
uint256[50] private __gap;
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
import "./GSNRecipientUpgradeable.sol";
import "../cryptography/ECDSAUpgradeable.sol";
import "../proxy/Initializable.sol";
/**
* @dev A xref:ROOT:gsn-strategies.adoc#gsn-strategies[GSN strategy] that allows relayed transactions through when they are
* accompanied by the signature of a trusted signer. The intent is for this signature to be generated by a server that
* 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.
*/
contract GSNRecipientSignatureUpgradeable is Initializable, GSNRecipientUpgradeable {
using ECDSAUpgradeable for bytes32;
address private _trustedSigner;
enum GSNRecipientSignatureErrorCodes {
INVALID_SIGNER
}
/**
* @dev Sets the trusted signer that is going to be producing signatures to approve relayed calls.
*/
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");
_trustedSigner = trustedSigner;
}
/**
* @dev Ensures that only transactions with a trusted signature can be relayed through the GSN.
*/
function acceptRelayedCall(
address relay,
address from,
bytes memory encodedFunction,
uint256 transactionFee,
uint256 gasPrice,
uint256 gasLimit,
uint256 nonce,
bytes memory approvalData,
uint256
)
public
view
virtual
override
returns (uint256, bytes memory)
{
bytes memory blob = abi.encodePacked(
relay,
from,
encodedFunction,
transactionFee,
gasPrice,
gasLimit,
nonce, // Prevents replays on RelayHub
getHubAddr(), // Prevents replays in multiple RelayHubs
address(this) // Prevents replays in multiple recipients
);
if (keccak256(blob).toEthSignedMessageHash().recover(approvalData) == _trustedSigner) {
return _approveRelayedCall();
} else {
return _rejectRelayedCall(uint256(GSNRecipientSignatureErrorCodes.INVALID_SIGNER));
}
}
function _preRelayedCall(bytes memory) internal virtual override returns (bytes32) { }
function _postRelayedCall(bytes memory, bool, uint256, bytes32) internal virtual override { }
uint256[49] private __gap;
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Base interface for a contract that will be called via the GSN from {IRelayHub}.
*
* TIP: You don't need to write an implementation yourself! Inherit from {GSNRecipient} instead.
*/
interface IRelayRecipientUpgradeable {
/**
* @dev Returns the address of the {IRelayHub} instance this recipient interacts with.
*/
function getHubAddr() external view returns (address);
/**
* @dev Called by {IRelayHub} to validate if this recipient accepts being charged for a relayed call. Note that the
* recipient will be charged regardless of the execution result of the relayed call (i.e. if it reverts or not).
*
* The relay request was originated by `from` and will be served by `relay`. `encodedFunction` is the relayed call
* calldata, so its first four bytes are the function selector. The relayed call will be forwarded `gasLimit` gas,
* and the transaction executed with a gas price of at least `gasPrice`. ``relay``'s fee is `transactionFee`, and the
* recipient will be charged at most `maxPossibleCharge` (in wei). `nonce` is the sender's (`from`) nonce for
* replay attack protection in {IRelayHub}, and `approvalData` is a optional parameter that can be used to hold a signature
* over all or some of the previous values.
*
* Returns a tuple, where the first value is used to indicate approval (0) or rejection (custom non-zero error code,
* values 1 to 10 are reserved) and the second one is data to be passed to the other {IRelayRecipient} functions.
*
* {acceptRelayedCall} is called with 50k gas: if it runs out during execution, the request will be considered
* rejected. A regular revert will also trigger a rejection.
*/
function acceptRelayedCall(
address relay,
address from,
bytes calldata encodedFunction,
uint256 transactionFee,
uint256 gasPrice,
uint256 gasLimit,
uint256 nonce,
bytes calldata approvalData,
uint256 maxPossibleCharge
)
external
view
returns (uint256, bytes memory);
/**
* @dev Called by {IRelayHub} on approved relay call requests, before the relayed call is executed. This allows to e.g.
* pre-charge the sender of the transaction.
*
* `context` is the second value returned in the tuple by {acceptRelayedCall}.
*
* Returns a value to be passed to {postRelayedCall}.
*
* {preRelayedCall} is called with 100k gas: if it runs out during execution or otherwise reverts, the relayed call
* will not be executed, but the recipient will still be charged for the transaction's cost.
*/
function preRelayedCall(bytes calldata context) external returns (bytes32);
/**
* @dev Called by {IRelayHub} on approved relay call requests, after the relayed call is executed. This allows to e.g.
* charge the user for the relayed call costs, return any overcharges from {preRelayedCall}, or perform
* contract-specific bookkeeping.
*
* `context` is the second value returned in the tuple by {acceptRelayedCall}. `success` is the execution status of
* the relayed call. `actualCharge` is an estimate of how much the recipient will be charged for the transaction,
* not including any gas used by {postRelayedCall} itself. `preRetVal` is {preRelayedCall}'s return value.
*
*
* {postRelayedCall} is called with 100k gas: if it runs out during execution or otherwise reverts, the relayed call
* and the call to {preRelayedCall} will be reverted retroactively, but the recipient will still be charged for the
* transaction's cost.
*/
function postRelayedCall(bytes calldata context, bool success, uint256 actualCharge, bytes32 preRetVal) external;
}
= Gas Station Network (GSN)
[.readme-notice]
NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/gsn
This set of contracts provide all the tools required to make a contract callable via the https://gsn.openzeppelin.com[Gas Station Network].
TIP: If you're new to the GSN, head over to our xref:learn::sending-gasless-transactions.adoc[overview of the system] and basic guide to xref:ROOT:gsn.adoc[creating a GSN-capable contract].
The core contract a recipient must inherit from is {GSNRecipient}: it includes all necessary interfaces, as well as some helper methods to make interacting with the GSN easier.
Utilities to make writing xref:ROOT:gsn-strategies.adoc[GSN strategies] easy are available in {GSNRecipient}, or you can simply use one of our pre-made strategies:
* {GSNRecipientERC20Fee} charges the end user for gas costs in an application-specific xref:ROOT:tokens.adoc#ERC20[ERC20 token]
* {GSNRecipientSignature} accepts all relayed calls that have been signed by a trusted third party (e.g. a private key in a backend)
You can also take a look at the two contract interfaces that make up the GSN protocol: {IRelayRecipient} and {IRelayHub}, but you won't need to use those directly.
== Recipient
{{GSNRecipient}}
== Strategies
{{GSNRecipientSignature}}
{{GSNRecipientERC20Fee}}
== Protocol
{{IRelayRecipient}}
{{IRelayHub}}
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../utils/EnumerableSetUpgradeable.sol"; import "../utils/EnumerableSetUpgradeable.sol";
import "../utils/AddressUpgradeable.sol"; import "../utils/AddressUpgradeable.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol"; import "../utils/ContextUpgradeable.sol";
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.9 <0.8.0; pragma solidity ^0.8.0;
pragma experimental ABIEncoderV2;
import "./../math/SafeMathUpgradeable.sol";
import "./AccessControlUpgradeable.sol"; import "./AccessControlUpgradeable.sol";
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
...@@ -23,7 +21,6 @@ import "../proxy/Initializable.sol"; ...@@ -23,7 +21,6 @@ import "../proxy/Initializable.sol";
* _Available since v3.3._ * _Available since v3.3._
*/ */
contract TimelockControllerUpgradeable is Initializable, AccessControlUpgradeable { contract TimelockControllerUpgradeable is Initializable, AccessControlUpgradeable {
bytes32 public constant TIMELOCK_ADMIN_ROLE = keccak256("TIMELOCK_ADMIN_ROLE"); bytes32 public constant TIMELOCK_ADMIN_ROLE = keccak256("TIMELOCK_ADMIN_ROLE");
bytes32 public constant PROPOSER_ROLE = keccak256("PROPOSER_ROLE"); bytes32 public constant PROPOSER_ROLE = keccak256("PROPOSER_ROLE");
bytes32 public constant EXECUTOR_ROLE = keccak256("EXECUTOR_ROLE"); bytes32 public constant EXECUTOR_ROLE = keccak256("EXECUTOR_ROLE");
...@@ -206,7 +203,7 @@ contract TimelockControllerUpgradeable is Initializable, AccessControlUpgradeabl ...@@ -206,7 +203,7 @@ contract TimelockControllerUpgradeable is Initializable, AccessControlUpgradeabl
require(!isOperation(id), "TimelockController: operation already scheduled"); require(!isOperation(id), "TimelockController: operation already scheduled");
require(delay >= getMinDelay(), "TimelockController: insufficient delay"); require(delay >= getMinDelay(), "TimelockController: insufficient delay");
// solhint-disable-next-line not-rely-on-time // solhint-disable-next-line not-rely-on-time
_timestamps[id] = SafeMathUpgradeable.add(block.timestamp, delay); _timestamps[id] = block.timestamp + delay;
} }
/** /**
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
/** /**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
/** /**
* @dev These functions deal with verification of Merkle trees (hash trees), * @dev These functions deal with verification of Merkle trees (hash trees),
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
/** /**
...@@ -65,7 +65,7 @@ abstract contract EIP712Upgradeable is Initializable { ...@@ -65,7 +65,7 @@ abstract contract EIP712Upgradeable is Initializable {
typeHash, typeHash,
name, name,
version, version,
_getChainId(), block.chainid,
address(this) address(this)
) )
); );
...@@ -90,14 +90,6 @@ abstract contract EIP712Upgradeable is Initializable { ...@@ -90,14 +90,6 @@ abstract contract EIP712Upgradeable is Initializable {
return keccak256(abi.encodePacked("\x19\x01", _domainSeparatorV4(), structHash)); return keccak256(abi.encodePacked("\x19\x01", _domainSeparatorV4(), structHash));
} }
function _getChainId() private view returns (uint256 chainId) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
// solhint-disable-next-line no-inline-assembly
assembly {
chainId := chainid()
}
}
/** /**
* @dev The hash of the name parameter for the EIP712 domain. * @dev The hash of the name parameter for the EIP712 domain.
* *
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.5 <0.8.0; pragma solidity ^0.8.0;
import "../token/ERC20/ERC20Upgradeable.sol"; import "../token/ERC20/ERC20Upgradeable.sol";
import "./IERC20PermitUpgradeable.sol"; import "./IERC20PermitUpgradeable.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
/** /**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.2 <0.8.0; pragma solidity ^0.8.0;
import "./IERC165Upgradeable.sol";
/** /**
* @dev Library used to query support of an interface declared via {IERC165}. * @dev Library used to query support of an interface declared via {IERC165}.
...@@ -13,18 +15,13 @@ library ERC165CheckerUpgradeable { ...@@ -13,18 +15,13 @@ library ERC165CheckerUpgradeable {
// As per the EIP-165 spec, no interface should ever match 0xffffffff // As per the EIP-165 spec, no interface should ever match 0xffffffff
bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff; bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff;
/*
* bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7
*/
bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7;
/** /**
* @dev Returns true if `account` supports the {IERC165} interface, * @dev Returns true if `account` supports the {IERC165} interface,
*/ */
function supportsERC165(address account) internal view returns (bool) { function supportsERC165(address account) internal view returns (bool) {
// Any contract that implements ERC165 must explicitly indicate support of // Any contract that implements ERC165 must explicitly indicate support of
// InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid // InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid
return _supportsERC165Interface(account, _INTERFACE_ID_ERC165) && return _supportsERC165Interface(account, type(IERC165Upgradeable).interfaceId) &&
!_supportsERC165Interface(account, _INTERFACE_ID_INVALID); !_supportsERC165Interface(account, _INTERFACE_ID_INVALID);
} }
...@@ -103,29 +100,9 @@ library ERC165CheckerUpgradeable { ...@@ -103,29 +100,9 @@ library ERC165CheckerUpgradeable {
* Interface identification is specified in ERC-165. * Interface identification is specified in ERC-165.
*/ */
function _supportsERC165Interface(address account, bytes4 interfaceId) private view returns (bool) { function _supportsERC165Interface(address account, bytes4 interfaceId) private view returns (bool) {
// success determines whether the staticcall succeeded and result determines bytes memory encodedParams = abi.encodeWithSelector(IERC165Upgradeable(account).supportsInterface.selector, interfaceId);
// whether the contract at account indicates support of _interfaceId
(bool success, bool result) = _callERC165SupportsInterface(account, interfaceId);
return (success && result);
}
/**
* @notice Calls the function with selector 0x01ffc9a7 (ERC165) and suppresses throw
* @param account The address of the contract to query for support of an interface
* @param interfaceId The interface identifier, as specified in ERC-165
* @return success true if the STATICCALL succeeded, false otherwise
* @return result true if the STATICCALL succeeded and the contract at account
* indicates support of the interface with identifier interfaceId, false otherwise
*/
function _callERC165SupportsInterface(address account, bytes4 interfaceId)
private
view
returns (bool, bool)
{
bytes memory encodedParams = abi.encodeWithSelector(_INTERFACE_ID_ERC165, interfaceId);
(bool success, bytes memory result) = account.staticcall{ gas: 30000 }(encodedParams); (bool success, bytes memory result) = account.staticcall{ gas: 30000 }(encodedParams);
if (result.length < 32) return (false, false); if (result.length < 32) return false;
return (success, abi.decode(result, (bool))); return success && abi.decode(result, (bool));
} }
} }
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./ERC165Upgradeable.sol";
import "../proxy/Initializable.sol";
/**
* @dev Storage based implementation of the {IERC165} interface.
*
* Contracts may inherit from this and call {_registerInterface} to declare
* their support of an interface.
*/
abstract contract ERC165StorageUpgradeable is Initializable, ERC165Upgradeable {
function __ERC165Storage_init() internal initializer {
__ERC165_init_unchained();
__ERC165Storage_init_unchained();
}
function __ERC165Storage_init_unchained() internal initializer {
}
/**
* @dev Mapping of interface ids to whether or not it's supported.
*/
mapping(bytes4 => bool) private _supportedInterfaces;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return super.supportsInterface(interfaceId) || _supportedInterfaces[interfaceId];
}
/**
* @dev Registers the contract as an implementer of the interface defined by
* `interfaceId`. Support of the actual ERC165 interface is automatic and
* registering its interface id is not required.
*
* See {IERC165-supportsInterface}.
*
* Requirements:
*
* - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`).
*/
function _registerInterface(bytes4 interfaceId) internal virtual {
require(interfaceId != 0xffffffff, "ERC165: invalid interface id");
_supportedInterfaces[interfaceId] = true;
}
uint256[49] private __gap;
}
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "./IERC165Upgradeable.sol"; import "./IERC165Upgradeable.sol";
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
...@@ -8,53 +8,29 @@ import "../proxy/Initializable.sol"; ...@@ -8,53 +8,29 @@ import "../proxy/Initializable.sol";
/** /**
* @dev Implementation of the {IERC165} interface. * @dev Implementation of the {IERC165} interface.
* *
* Contracts may inherit from this and call {_registerInterface} to declare * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* their support of an interface. * for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/ */
abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable { abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {
/*
* bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7
*/
bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7;
/**
* @dev Mapping of interface ids to whether or not it's supported.
*/
mapping(bytes4 => bool) private _supportedInterfaces;
function __ERC165_init() internal initializer { function __ERC165_init() internal initializer {
__ERC165_init_unchained(); __ERC165_init_unchained();
} }
function __ERC165_init_unchained() internal initializer { function __ERC165_init_unchained() internal initializer {
// Derived contracts need only register support for their own interfaces,
// we register support for ERC165 itself here
_registerInterface(_INTERFACE_ID_ERC165);
} }
/** /**
* @dev See {IERC165-supportsInterface}. * @dev See {IERC165-supportsInterface}.
*
* Time complexity O(1), guaranteed to always use less than 30 000 gas.
*/ */
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return _supportedInterfaces[interfaceId]; return interfaceId == type(IERC165Upgradeable).interfaceId;
}
/**
* @dev Registers the contract as an implementer of the interface defined by
* `interfaceId`. Support of the actual ERC165 interface is automatic and
* registering its interface id is not required.
*
* See {IERC165-supportsInterface}.
*
* Requirements:
*
* - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`).
*/
function _registerInterface(bytes4 interfaceId) internal virtual {
require(interfaceId != 0xffffffff, "ERC165: invalid interface id");
_supportedInterfaces[interfaceId] = true;
} }
uint256[49] private __gap; uint256[50] private __gap;
} }
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "./IERC1820ImplementerUpgradeable.sol"; import "./IERC1820ImplementerUpgradeable.sol";
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
...@@ -20,7 +20,7 @@ contract ERC1820ImplementerUpgradeable is Initializable, IERC1820ImplementerUpgr ...@@ -20,7 +20,7 @@ contract ERC1820ImplementerUpgradeable is Initializable, IERC1820ImplementerUpgr
function __ERC1820Implementer_init_unchained() internal initializer { function __ERC1820Implementer_init_unchained() internal initializer {
} }
bytes32 constant private _ERC1820_ACCEPT_MAGIC = keccak256(abi.encodePacked("ERC1820_ACCEPT_MAGIC")); bytes32 private constant _ERC1820_ACCEPT_MAGIC = keccak256("ERC1820_ACCEPT_MAGIC");
mapping(bytes32 => mapping(address => bool)) private _supportedInterfaces; mapping(bytes32 => mapping(address => bool)) private _supportedInterfaces;
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
/** /**
* @dev Interface of the ERC165 standard, as defined in the * @dev Interface of the ERC165 standard, as defined in the
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
/** /**
* @dev Interface for an ERC1820 implementer, as defined in the * @dev Interface for an ERC1820 implementer, as defined in the
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
/** /**
* @dev Interface of the global ERC1820 Registry, as defined in the * @dev Interface of the global ERC1820 Registry, as defined in the
......
...@@ -20,6 +20,8 @@ Note that, in all cases, accounts simply _declare_ their interfaces, but they ar ...@@ -20,6 +20,8 @@ Note that, in all cases, accounts simply _declare_ their interfaces, but they ar
{{ERC165}} {{ERC165}}
{{ERC165Storage}}
{{ERC165Checker}} {{ERC165Checker}}
== Global == Global
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
/** /**
* @dev Standard math utilities missing in the Solidity language. * @dev Standard math utilities missing in the Solidity language.
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
/** /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow * @dev Wrappers over Solidity's arithmetic operations.
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ */
library SafeMathUpgradeable { library SafeMathUpgradeable {
/** /**
...@@ -22,9 +12,11 @@ library SafeMathUpgradeable { ...@@ -22,9 +12,11 @@ library SafeMathUpgradeable {
* _Available since v3.4._ * _Available since v3.4._
*/ */
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
uint256 c = a + b; unchecked {
if (c < a) return (false, 0); uint256 c = a + b;
return (true, c); if (c < a) return (false, 0);
return (true, c);
}
} }
/** /**
...@@ -33,8 +25,10 @@ library SafeMathUpgradeable { ...@@ -33,8 +25,10 @@ library SafeMathUpgradeable {
* _Available since v3.4._ * _Available since v3.4._
*/ */
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b > a) return (false, 0); unchecked {
return (true, a - b); if (b > a) return (false, 0);
return (true, a - b);
}
} }
/** /**
...@@ -43,13 +37,15 @@ library SafeMathUpgradeable { ...@@ -43,13 +37,15 @@ library SafeMathUpgradeable {
* _Available since v3.4._ * _Available since v3.4._
*/ */
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the unchecked {
// benefit is lost if 'b' is also tested. // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 // benefit is lost if 'b' is also tested.
if (a == 0) return (true, 0); // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
uint256 c = a * b; if (a == 0) return (true, 0);
if (c / a != b) return (false, 0); uint256 c = a * b;
return (true, c); if (c / a != b) return (false, 0);
return (true, c);
}
} }
/** /**
...@@ -58,8 +54,10 @@ library SafeMathUpgradeable { ...@@ -58,8 +54,10 @@ library SafeMathUpgradeable {
* _Available since v3.4._ * _Available since v3.4._
*/ */
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b == 0) return (false, 0); unchecked {
return (true, a / b); if (b == 0) return (false, 0);
return (true, a / b);
}
} }
/** /**
...@@ -68,8 +66,10 @@ library SafeMathUpgradeable { ...@@ -68,8 +66,10 @@ library SafeMathUpgradeable {
* _Available since v3.4._ * _Available since v3.4._
*/ */
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b == 0) return (false, 0); unchecked {
return (true, a % b); if (b == 0) return (false, 0);
return (true, a % b);
}
} }
/** /**
...@@ -83,9 +83,7 @@ library SafeMathUpgradeable { ...@@ -83,9 +83,7 @@ library SafeMathUpgradeable {
* - Addition cannot overflow. * - Addition cannot overflow.
*/ */
function add(uint256 a, uint256 b) internal pure returns (uint256) { function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b; return a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
} }
/** /**
...@@ -99,7 +97,6 @@ library SafeMathUpgradeable { ...@@ -99,7 +97,6 @@ library SafeMathUpgradeable {
* - Subtraction cannot overflow. * - Subtraction cannot overflow.
*/ */
function sub(uint256 a, uint256 b) internal pure returns (uint256) { function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, "SafeMath: subtraction overflow");
return a - b; return a - b;
} }
...@@ -114,26 +111,20 @@ library SafeMathUpgradeable { ...@@ -114,26 +111,20 @@ library SafeMathUpgradeable {
* - Multiplication cannot overflow. * - Multiplication cannot overflow.
*/ */
function mul(uint256 a, uint256 b) internal pure returns (uint256) { function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) return 0; return a * b;
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
} }
/** /**
* @dev Returns the integer division of two unsigned integers, reverting on * @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero. * division by zero. The result is rounded towards zero.
* *
* Counterpart to Solidity's `/` operator. Note: this function uses a * Counterpart to Solidity's `/` operator.
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
* *
* Requirements: * Requirements:
* *
* - The divisor cannot be zero. * - The divisor cannot be zero.
*/ */
function div(uint256 a, uint256 b) internal pure returns (uint256) { function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "SafeMath: division by zero");
return a / b; return a / b;
} }
...@@ -150,7 +141,6 @@ library SafeMathUpgradeable { ...@@ -150,7 +141,6 @@ library SafeMathUpgradeable {
* - The divisor cannot be zero. * - The divisor cannot be zero.
*/ */
function mod(uint256 a, uint256 b) internal pure returns (uint256) { function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "SafeMath: modulo by zero");
return a % b; return a % b;
} }
...@@ -168,16 +158,19 @@ library SafeMathUpgradeable { ...@@ -168,16 +158,19 @@ library SafeMathUpgradeable {
* - Subtraction cannot overflow. * - Subtraction cannot overflow.
*/ */
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage); unchecked {
return a - b; require(b <= a, errorMessage);
return a - b;
}
} }
/** /**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on * @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero. * division by zero. The result is rounded towards zero.
* *
* CAUTION: This function is deprecated because it requires allocating memory for the error * Counterpart to Solidity's `%` operator. This function uses a `revert`
* message unnecessarily. For custom revert reasons use {tryDiv}. * opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
* *
* Counterpart to Solidity's `/` operator. Note: this function uses a * Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity * `revert` opcode (which leaves remaining gas untouched) while Solidity
...@@ -188,8 +181,10 @@ library SafeMathUpgradeable { ...@@ -188,8 +181,10 @@ library SafeMathUpgradeable {
* - The divisor cannot be zero. * - The divisor cannot be zero.
*/ */
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage); unchecked {
return a / b; require(b > 0, errorMessage);
return a / b;
}
} }
/** /**
...@@ -208,7 +203,9 @@ library SafeMathUpgradeable { ...@@ -208,7 +203,9 @@ library SafeMathUpgradeable {
* - The divisor cannot be zero. * - The divisor cannot be zero.
*/ */
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage); unchecked {
return a % b; require(b > 0, errorMessage);
return a % b;
}
} }
} }
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
/** /**
* @title SignedSafeMath * @title SignedSafeMath
* @dev Signed math operations with safety checks that revert on error. * @dev Signed math operations that revert on error.
*/ */
library SignedSafeMathUpgradeable { library SignedSafeMathUpgradeable {
int256 constant private _INT256_MIN = -2**255;
/** /**
* @dev Returns the multiplication of two signed integers, reverting on * @dev Returns the multiplication of two signed integers, reverting on
* overflow. * overflow.
...@@ -20,40 +18,21 @@ library SignedSafeMathUpgradeable { ...@@ -20,40 +18,21 @@ library SignedSafeMathUpgradeable {
* - Multiplication cannot overflow. * - Multiplication cannot overflow.
*/ */
function mul(int256 a, int256 b) internal pure returns (int256) { function mul(int256 a, int256 b) internal pure returns (int256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the return a * b;
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
require(!(a == -1 && b == _INT256_MIN), "SignedSafeMath: multiplication overflow");
int256 c = a * b;
require(c / a == b, "SignedSafeMath: multiplication overflow");
return c;
} }
/** /**
* @dev Returns the integer division of two signed integers. Reverts on * @dev Returns the integer division of two signed integers. Reverts on
* division by zero. The result is rounded towards zero. * division by zero. The result is rounded towards zero.
* *
* Counterpart to Solidity's `/` operator. Note: this function uses a * Counterpart to Solidity's `/` operator.
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
* *
* Requirements: * Requirements:
* *
* - The divisor cannot be zero. * - The divisor cannot be zero.
*/ */
function div(int256 a, int256 b) internal pure returns (int256) { function div(int256 a, int256 b) internal pure returns (int256) {
require(b != 0, "SignedSafeMath: division by zero"); return a / b;
require(!(b == -1 && a == _INT256_MIN), "SignedSafeMath: division overflow");
int256 c = a / b;
return c;
} }
/** /**
...@@ -67,10 +46,7 @@ library SignedSafeMathUpgradeable { ...@@ -67,10 +46,7 @@ library SignedSafeMathUpgradeable {
* - Subtraction cannot overflow. * - Subtraction cannot overflow.
*/ */
function sub(int256 a, int256 b) internal pure returns (int256) { function sub(int256 a, int256 b) internal pure returns (int256) {
int256 c = a - b; return a - b;
require((b >= 0 && c <= a) || (b < 0 && c > a), "SignedSafeMath: subtraction overflow");
return c;
} }
/** /**
...@@ -84,9 +60,6 @@ library SignedSafeMathUpgradeable { ...@@ -84,9 +60,6 @@ library SignedSafeMathUpgradeable {
* - Addition cannot overflow. * - Addition cannot overflow.
*/ */
function add(int256 a, int256 b) internal pure returns (int256) { function add(int256 a, int256 b) internal pure returns (int256) {
int256 c = a + b; return a + b;
require((b >= 0 && c >= a) || (b < 0 && c < a), "SignedSafeMath: addition overflow");
return c;
} }
} }
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../access/AccessControlUpgradeable.sol"; import "../access/AccessControlUpgradeable.sol";
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../utils/AddressUpgradeable.sol"; import "../utils/AddressUpgradeable.sol";
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../utils/ArraysUpgradeable.sol"; import "../utils/ArraysUpgradeable.sol";
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
contract BadBeaconNoImplUpgradeable is Initializable { contract BadBeaconNoImplUpgradeable is Initializable {
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
contract CallReceiverMockUpgradeable is Initializable { contract CallReceiverMockUpgradeable is Initializable {
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../proxy/ClonesUpgradeable.sol"; import "../proxy/ClonesUpgradeable.sol";
import "../utils/AddressUpgradeable.sol"; import "../utils/AddressUpgradeable.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../payment/escrow/ConditionalEscrowUpgradeable.sol"; import "../payment/escrow/ConditionalEscrowUpgradeable.sol";
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol"; import "../utils/ContextUpgradeable.sol";
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../utils/CountersUpgradeable.sol"; import "../utils/CountersUpgradeable.sol";
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../utils/Create2Upgradeable.sol"; import "../utils/Create2Upgradeable.sol";
import "../introspection/ERC1820ImplementerUpgradeable.sol"; import "../introspection/ERC1820ImplementerUpgradeable.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
abstract contract ImplUpgradeable is Initializable { abstract contract ImplUpgradeable is Initializable {
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../cryptography/ECDSAUpgradeable.sol"; import "../cryptography/ECDSAUpgradeable.sol";
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../drafts/EIP712Upgradeable.sol"; import "../drafts/EIP712Upgradeable.sol";
import "../cryptography/ECDSAUpgradeable.sol"; import "../cryptography/ECDSAUpgradeable.sol";
...@@ -28,12 +28,8 @@ contract EIP712ExternalUpgradeable is Initializable, EIP712Upgradeable { ...@@ -28,12 +28,8 @@ contract EIP712ExternalUpgradeable is Initializable, EIP712Upgradeable {
require(recoveredSigner == signer); require(recoveredSigner == signer);
} }
function getChainId() external view returns (uint256 chainId) { function getChainId() external view returns (uint256) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return block.chainid;
// solhint-disable-next-line no-inline-assembly
assembly {
chainId := chainid()
}
} }
uint256[50] private __gap; uint256[50] private __gap;
} }
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../token/ERC1155/ERC1155BurnableUpgradeable.sol"; import "../token/ERC1155/ERC1155BurnableUpgradeable.sol";
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../token/ERC1155/ERC1155Upgradeable.sol"; import "../token/ERC1155/ERC1155Upgradeable.sol";
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "./ERC1155MockUpgradeable.sol"; import "./ERC1155MockUpgradeable.sol";
import "../token/ERC1155/ERC1155PausableUpgradeable.sol"; import "../token/ERC1155/ERC1155PausableUpgradeable.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../introspection/ERC165Upgradeable.sol";
import "../token/ERC1155/IERC1155ReceiverUpgradeable.sol"; import "../token/ERC1155/IERC1155ReceiverUpgradeable.sol";
import "./ERC165MockUpgradeable.sol";
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
contract ERC1155ReceiverMockUpgradeable is Initializable, IERC1155ReceiverUpgradeable, ERC165MockUpgradeable { contract ERC1155ReceiverMockUpgradeable is Initializable, IERC1155ReceiverUpgradeable, ERC165Upgradeable {
bytes4 private _recRetval; bytes4 private _recRetval;
bool private _recReverts; bool private _recReverts;
bytes4 private _batRetval; bytes4 private _batRetval;
...@@ -22,7 +22,6 @@ contract ERC1155ReceiverMockUpgradeable is Initializable, IERC1155ReceiverUpgrad ...@@ -22,7 +22,6 @@ contract ERC1155ReceiverMockUpgradeable is Initializable, IERC1155ReceiverUpgrad
bool batReverts bool batReverts
) internal initializer { ) internal initializer {
__ERC165_init_unchained(); __ERC165_init_unchained();
__ERC165Mock_init_unchained();
__ERC1155ReceiverMock_init_unchained(recRetval, recReverts, batRetval, batReverts); __ERC1155ReceiverMock_init_unchained(recRetval, recReverts, batRetval, batReverts);
} }
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../../introspection/IERC165Upgradeable.sol"; import "../../introspection/IERC165Upgradeable.sol";
import "../../proxy/Initializable.sol"; import "../../proxy/Initializable.sol";
......
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../../proxy/Initializable.sol";
contract ERC165MissingDataUpgradeable is Initializable {
function __ERC165MissingData_init() internal initializer {
__ERC165MissingData_init_unchained();
}
function __ERC165MissingData_init_unchained() internal initializer {
}
function supportsInterface(bytes4 interfaceId) public view {} // missing return
uint256[50] private __gap;
}
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../../proxy/Initializable.sol"; import "../../proxy/Initializable.sol";
contract ERC165NotSupportedUpgradeable is Initializable { function __ERC165NotSupported_init() internal initializer { contract ERC165NotSupportedUpgradeable is Initializable { function __ERC165NotSupported_init() internal initializer {
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../introspection/ERC165CheckerUpgradeable.sol"; import "../introspection/ERC165CheckerUpgradeable.sol";
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../introspection/ERC165Upgradeable.sol"; import "../introspection/ERC165Upgradeable.sol";
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
...@@ -13,8 +13,5 @@ contract ERC165MockUpgradeable is Initializable, ERC165Upgradeable { ...@@ -13,8 +13,5 @@ contract ERC165MockUpgradeable is Initializable, ERC165Upgradeable {
function __ERC165Mock_init_unchained() internal initializer { function __ERC165Mock_init_unchained() internal initializer {
} }
function registerInterface(bytes4 interfaceId) public {
_registerInterface(interfaceId);
}
uint256[50] private __gap; uint256[50] private __gap;
} }
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../introspection/ERC165StorageUpgradeable.sol";
import "../proxy/Initializable.sol";
contract ERC165StorageMockUpgradeable is Initializable, ERC165StorageUpgradeable {
function __ERC165StorageMock_init() internal initializer {
__ERC165_init_unchained();
__ERC165Storage_init_unchained();
__ERC165StorageMock_init_unchained();
}
function __ERC165StorageMock_init_unchained() internal initializer {
}
function registerInterface(bytes4 interfaceId) public {
_registerInterface(interfaceId);
}
uint256[50] private __gap;
}
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../introspection/ERC1820ImplementerUpgradeable.sol"; import "../introspection/ERC1820ImplementerUpgradeable.sol";
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../token/ERC20/ERC20BurnableUpgradeable.sol"; import "../token/ERC20/ERC20BurnableUpgradeable.sol";
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../token/ERC20/ERC20CappedUpgradeable.sol"; import "../token/ERC20/ERC20CappedUpgradeable.sol";
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../token/ERC20/ERC20Upgradeable.sol"; import "../token/ERC20/ERC20Upgradeable.sol";
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
contract ERC20DecimalsMockUpgradeable is Initializable, ERC20Upgradeable { contract ERC20DecimalsMockUpgradeable is Initializable, ERC20Upgradeable {
function __ERC20DecimalsMock_init(string memory name, string memory symbol, uint8 decimals) internal initializer { uint8 private _decimals;
function __ERC20DecimalsMock_init(string memory name_, string memory symbol_, uint8 decimals_) internal initializer {
__Context_init_unchained(); __Context_init_unchained();
__ERC20_init_unchained(name, symbol); __ERC20_init_unchained(name_, symbol_);
__ERC20DecimalsMock_init_unchained(name, symbol, decimals); __ERC20DecimalsMock_init_unchained(name_, symbol_, decimals_);
}
function __ERC20DecimalsMock_init_unchained(string memory name_, string memory symbol_, uint8 decimals_) internal initializer {
_decimals = decimals_;
} }
function __ERC20DecimalsMock_init_unchained(string memory name, string memory symbol, uint8 decimals) internal initializer { function decimals() public view virtual override returns (uint8) {
_setupDecimals(decimals); return _decimals;
} }
uint256[50] private __gap; uint256[50] private __gap;
} }
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../token/ERC20/ERC20Upgradeable.sol"; import "../token/ERC20/ERC20Upgradeable.sol";
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../token/ERC20/ERC20PausableUpgradeable.sol"; import "../token/ERC20/ERC20PausableUpgradeable.sol";
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../drafts/ERC20PermitUpgradeable.sol"; import "../drafts/ERC20PermitUpgradeable.sol";
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
...@@ -28,12 +28,8 @@ contract ERC20PermitMockUpgradeable is Initializable, ERC20PermitUpgradeable { ...@@ -28,12 +28,8 @@ contract ERC20PermitMockUpgradeable is Initializable, ERC20PermitUpgradeable {
_mint(initialAccount, initialBalance); _mint(initialAccount, initialBalance);
} }
function getChainId() external view returns (uint256 chainId) { function getChainId() external view returns (uint256) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return block.chainid;
// solhint-disable-next-line no-inline-assembly
assembly {
chainId := chainid()
}
} }
uint256[50] private __gap; uint256[50] private __gap;
} }
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../token/ERC20/ERC20SnapshotUpgradeable.sol"; import "../token/ERC20/ERC20SnapshotUpgradeable.sol";
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../token/ERC721/ERC721BurnableUpgradeable.sol"; import "../token/ERC721/ERC721BurnableUpgradeable.sol";
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
......
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
import "../token/ERC721/ERC721Upgradeable.sol";
import "../GSN/GSNRecipientUpgradeable.sol";
import "../GSN/GSNRecipientSignatureUpgradeable.sol";
import "../proxy/Initializable.sol";
/**
* @title ERC721GSNRecipientMock
* A simple ERC721 mock that has GSN support enabled
*/
contract ERC721GSNRecipientMockUpgradeable is Initializable, ERC721Upgradeable, GSNRecipientUpgradeable, GSNRecipientSignatureUpgradeable {
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 {
_mint(_msgSender(), tokenId);
}
function _msgSender() internal view override(ContextUpgradeable, GSNRecipientUpgradeable) returns (address payable) {
return GSNRecipientUpgradeable._msgSender();
}
function _msgData() internal view override(ContextUpgradeable, GSNRecipientUpgradeable) returns (bytes memory) {
return GSNRecipientUpgradeable._msgData();
}
uint256[50] private __gap;
}
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../token/ERC721/ERC721Upgradeable.sol"; import "../token/ERC721/ERC721Upgradeable.sol";
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../token/ERC721/ERC721PausableUpgradeable.sol"; import "../token/ERC721/ERC721PausableUpgradeable.sol";
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../token/ERC721/IERC721ReceiverUpgradeable.sol"; import "../token/ERC721/IERC721ReceiverUpgradeable.sol";
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
contract ERC721ReceiverMockUpgradeable is Initializable, IERC721ReceiverUpgradeable { contract ERC721ReceiverMockUpgradeable is Initializable, IERC721ReceiverUpgradeable {
enum Error {
None,
RevertWithMessage,
RevertWithoutMessage,
Panic
}
bytes4 private _retval; bytes4 private _retval;
bool private _reverts; Error private _error;
event Received(address operator, address from, uint256 tokenId, bytes data, uint256 gas); event Received(address operator, address from, uint256 tokenId, bytes data, uint256 gas);
function __ERC721ReceiverMock_init(bytes4 retval, bool reverts) internal initializer { function __ERC721ReceiverMock_init(bytes4 retval, Error error) internal initializer {
__ERC721ReceiverMock_init_unchained(retval, reverts); __ERC721ReceiverMock_init_unchained(retval, error);
} }
function __ERC721ReceiverMock_init_unchained(bytes4 retval, bool reverts) internal initializer { function __ERC721ReceiverMock_init_unchained(bytes4 retval, Error error) internal initializer {
_retval = retval; _retval = retval;
_reverts = reverts; _error = error;
} }
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)
{ {
require(!_reverts, "ERC721ReceiverMock: reverting"); if (_error == Error.RevertWithMessage) {
revert("ERC721ReceiverMock: reverting");
} else if (_error == Error.RevertWithoutMessage) {
revert();
} else if (_error == Error.Panic) {
uint256 a = uint256(0) / uint256(0);
a;
}
emit Received(operator, from, tokenId, data, gasleft()); emit Received(operator, from, tokenId, data, gasleft());
return _retval; return _retval;
} }
uint256[49] private __gap; uint256[50] private __gap;
} }
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol"; import "../utils/ContextUpgradeable.sol";
import "../token/ERC777/ERC777Upgradeable.sol"; import "../token/ERC777/ERC777Upgradeable.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol"; import "../utils/ContextUpgradeable.sol";
import "../token/ERC777/IERC777Upgradeable.sol"; import "../token/ERC777/IERC777Upgradeable.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../utils/EnumerableMapUpgradeable.sol"; import "../utils/EnumerableMapUpgradeable.sol";
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
...@@ -52,5 +52,5 @@ contract EnumerableMapMockUpgradeable is Initializable { ...@@ -52,5 +52,5 @@ contract EnumerableMapMockUpgradeable is Initializable {
function getWithMessage(uint256 key, string calldata errorMessage) public view returns (address) { function getWithMessage(uint256 key, string calldata errorMessage) public view returns (address) {
return _map.get(key, errorMessage); return _map.get(key, errorMessage);
} }
uint256[48] private __gap; uint256[47] private __gap;
} }
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../utils/EnumerableSetUpgradeable.sol"; import "../utils/EnumerableSetUpgradeable.sol";
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
contract EtherReceiverMockUpgradeable is Initializable { contract EtherReceiverMockUpgradeable is Initializable {
......
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
import "../GSN/GSNRecipientUpgradeable.sol";
import "../GSN/GSNRecipientERC20FeeUpgradeable.sol";
import "../proxy/Initializable.sol";
contract GSNRecipientERC20FeeMockUpgradeable is Initializable, GSNRecipientUpgradeable, GSNRecipientERC20FeeUpgradeable {
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 { }
function mint(address account, uint256 amount) public {
_mint(account, amount);
}
event MockFunctionCalled(uint256 senderBalance);
function mockFunction() public {
emit MockFunctionCalled(token().balanceOf(_msgSender()));
}
uint256[50] private __gap;
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
import "./ContextMockUpgradeable.sol";
import "../GSN/GSNRecipientUpgradeable.sol";
import "../proxy/Initializable.sol";
// By inheriting from GSNRecipient, Context's internal functions are overridden automatically
contract GSNRecipientMockUpgradeable is Initializable, ContextMockUpgradeable, GSNRecipientUpgradeable {
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 {
_withdrawDeposits(amount, payee);
}
function acceptRelayedCall(address, address, bytes calldata, uint256, uint256, uint256, uint256, bytes calldata, uint256)
external
view
override
returns (uint256, bytes memory)
{
return (0, "");
}
function _preRelayedCall(bytes memory) internal override returns (bytes32) { }
function _postRelayedCall(bytes memory, bool, uint256, bytes32) internal override { }
function upgradeRelayHub(address newRelayHub) public {
return _upgradeRelayHub(newRelayHub);
}
function _msgSender() internal override(ContextUpgradeable, GSNRecipientUpgradeable) view virtual returns (address payable) {
return GSNRecipientUpgradeable._msgSender();
}
function _msgData() internal override(ContextUpgradeable, GSNRecipientUpgradeable) view virtual returns (bytes memory) {
return GSNRecipientUpgradeable._msgData();
}
uint256[50] private __gap;
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
import "../GSN/GSNRecipientUpgradeable.sol";
import "../GSN/GSNRecipientSignatureUpgradeable.sol";
import "../proxy/Initializable.sol";
contract GSNRecipientSignatureMockUpgradeable is Initializable, GSNRecipientUpgradeable, GSNRecipientSignatureUpgradeable {
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 { }
event MockFunctionCalled();
function mockFunction() public {
emit MockFunctionCalled();
}
uint256[50] private __gap;
}
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../math/MathUpgradeable.sol"; import "../math/MathUpgradeable.sol";
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import { MerkleProofUpgradeable } from "../cryptography/MerkleProofUpgradeable.sol"; import { MerkleProofUpgradeable } from "../cryptography/MerkleProofUpgradeable.sol";
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../access/OwnableUpgradeable.sol"; import "../access/OwnableUpgradeable.sol";
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../utils/PausableUpgradeable.sol"; import "../utils/PausableUpgradeable.sol";
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../payment/PullPaymentUpgradeable.sol"; import "../payment/PullPaymentUpgradeable.sol";
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol"; import "../utils/ContextUpgradeable.sol";
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../utils/ReentrancyGuardUpgradeable.sol"; import "../utils/ReentrancyGuardUpgradeable.sol";
import "./ReentrancyAttackUpgradeable.sol"; import "./ReentrancyAttackUpgradeable.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../utils/SafeCastUpgradeable.sol"; import "../utils/SafeCastUpgradeable.sol";
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol"; import "../utils/ContextUpgradeable.sol";
import "../token/ERC20/IERC20Upgradeable.sol"; import "../token/ERC20/IERC20Upgradeable.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../math/SafeMathUpgradeable.sol"; import "../math/SafeMathUpgradeable.sol";
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../math/SignedSafeMathUpgradeable.sol"; import "../math/SignedSafeMathUpgradeable.sol";
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../utils/StringsUpgradeable.sol"; import "../utils/StringsUpgradeable.sol";
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
...@@ -15,5 +15,11 @@ contract StringsMockUpgradeable is Initializable { ...@@ -15,5 +15,11 @@ contract StringsMockUpgradeable is Initializable {
function fromUint256(uint256 value) public pure returns (string memory) { function fromUint256(uint256 value) public pure returns (string memory) {
return StringsUpgradeable.toString(value); return StringsUpgradeable.toString(value);
} }
function fromUint256Hex(uint256 value) public pure returns (string memory) {
return StringsUpgradeable.toHexString(value);
}
function fromUint256HexFixed(uint256 value, uint256 length) public pure returns (string memory) {
return StringsUpgradeable.toHexString(value, length);
}
uint256[50] private __gap; uint256[50] private __gap;
} }
{ {
"name": "@openzeppelin/contracts-upgradeable", "name": "@openzeppelin/contracts-upgradeable",
"description": "Secure Smart Contract library for Solidity", "description": "Secure Smart Contract library for Solidity",
"version": "3.3.0", "version": "3.4.0",
"files": [ "files": [
"**/*.sol", "**/*.sol",
"/build/contracts/*.json", "/build/contracts/*.json",
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol"; import "../utils/ContextUpgradeable.sol";
import "../math/SafeMathUpgradeable.sol"; import "../math/SafeMathUpgradeable.sol";
...@@ -21,8 +21,6 @@ import "../proxy/Initializable.sol"; ...@@ -21,8 +21,6 @@ import "../proxy/Initializable.sol";
* function. * function.
*/ */
contract PaymentSplitterUpgradeable is Initializable, ContextUpgradeable { contract PaymentSplitterUpgradeable is Initializable, ContextUpgradeable {
using SafeMathUpgradeable for uint256;
event PayeeAdded(address account, uint256 shares); event PayeeAdded(address account, uint256 shares);
event PaymentReleased(address to, uint256 amount); event PaymentReleased(address to, uint256 amount);
event PaymentReceived(address from, uint256 amount); event PaymentReceived(address from, uint256 amount);
...@@ -111,13 +109,13 @@ contract PaymentSplitterUpgradeable is Initializable, ContextUpgradeable { ...@@ -111,13 +109,13 @@ contract PaymentSplitterUpgradeable is Initializable, ContextUpgradeable {
function release(address payable account) public virtual { function release(address payable account) public virtual {
require(_shares[account] > 0, "PaymentSplitter: account has no shares"); require(_shares[account] > 0, "PaymentSplitter: account has no shares");
uint256 totalReceived = address(this).balance.add(_totalReleased); uint256 totalReceived = address(this).balance + _totalReleased;
uint256 payment = totalReceived.mul(_shares[account]).div(_totalShares).sub(_released[account]); uint256 payment = totalReceived * _shares[account] / _totalShares - _released[account];
require(payment != 0, "PaymentSplitter: account is not due payment"); require(payment != 0, "PaymentSplitter: account is not due payment");
_released[account] = _released[account].add(payment); _released[account] = _released[account] + payment;
_totalReleased = _totalReleased.add(payment); _totalReleased = _totalReleased + payment;
AddressUpgradeable.sendValue(account, payment); AddressUpgradeable.sendValue(account, payment);
emit PaymentReleased(account, payment); emit PaymentReleased(account, payment);
...@@ -135,7 +133,7 @@ contract PaymentSplitterUpgradeable is Initializable, ContextUpgradeable { ...@@ -135,7 +133,7 @@ contract PaymentSplitterUpgradeable is Initializable, ContextUpgradeable {
_payees.push(account); _payees.push(account);
_shares[account] = shares_; _shares[account] = shares_;
_totalShares = _totalShares.add(shares_); _totalShares = _totalShares + shares_;
emit PayeeAdded(account, shares_); emit PayeeAdded(account, shares_);
} }
uint256[45] private __gap; uint256[45] private __gap;
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.2 <0.8.0; pragma solidity ^0.8.0;
import "./escrow/EscrowUpgradeable.sol"; import "./escrow/EscrowUpgradeable.sol";
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
...@@ -72,5 +72,5 @@ abstract contract PullPaymentUpgradeable is Initializable { ...@@ -72,5 +72,5 @@ abstract contract PullPaymentUpgradeable is Initializable {
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; uint256[50] private __gap;
} }
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "./EscrowUpgradeable.sol"; import "./EscrowUpgradeable.sol";
import "../../proxy/Initializable.sol"; import "../../proxy/Initializable.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../../math/SafeMathUpgradeable.sol";
import "../../access/OwnableUpgradeable.sol"; import "../../access/OwnableUpgradeable.sol";
import "../../utils/AddressUpgradeable.sol"; import "../../utils/AddressUpgradeable.sol";
import "../../proxy/Initializable.sol"; import "../../proxy/Initializable.sol";
...@@ -32,7 +31,6 @@ contract EscrowUpgradeable is Initializable, OwnableUpgradeable { ...@@ -32,7 +31,6 @@ contract EscrowUpgradeable is Initializable, OwnableUpgradeable {
function __Escrow_init_unchained() internal initializer { function __Escrow_init_unchained() internal initializer {
} }
using SafeMathUpgradeable for uint256;
using AddressUpgradeable for address payable; using AddressUpgradeable for address payable;
event Deposited(address indexed payee, uint256 weiAmount); event Deposited(address indexed payee, uint256 weiAmount);
...@@ -50,7 +48,7 @@ contract EscrowUpgradeable is Initializable, OwnableUpgradeable { ...@@ -50,7 +48,7 @@ contract EscrowUpgradeable is Initializable, OwnableUpgradeable {
*/ */
function deposit(address payee) public payable virtual onlyOwner { function deposit(address payee) public payable virtual onlyOwner {
uint256 amount = msg.value; uint256 amount = msg.value;
_deposits[payee] = _deposits[payee].add(amount); _deposits[payee] = _deposits[payee] + amount;
emit Deposited(payee, amount); emit Deposited(payee, amount);
} }
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "./ConditionalEscrowUpgradeable.sol"; import "./ConditionalEscrowUpgradeable.sol";
import "../../proxy/Initializable.sol"; import "../../proxy/Initializable.sol";
...@@ -16,6 +16,8 @@ import "../../proxy/Initializable.sol"; ...@@ -16,6 +16,8 @@ import "../../proxy/Initializable.sol";
* with `RefundEscrow` will be made through the owner contract. * with `RefundEscrow` will be made through the owner contract.
*/ */
contract RefundEscrowUpgradeable is Initializable, ConditionalEscrowUpgradeable { contract RefundEscrowUpgradeable is Initializable, ConditionalEscrowUpgradeable {
using AddressUpgradeable for address payable;
enum State { Active, Refunding, Closed } enum State { Active, Refunding, Closed }
event RefundsClosed(); event RefundsClosed();
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0; pragma solidity ^0.8.0;
import "../access/AccessControlUpgradeable.sol"; import "../access/AccessControlUpgradeable.sol";
import "../utils/ContextUpgradeable.sol"; import "../utils/ContextUpgradeable.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity ^0.6.2; pragma solidity ^0.8.0;
import "../token/ERC20/ERC20BurnableUpgradeable.sol"; import "../token/ERC20/ERC20BurnableUpgradeable.sol";
import "../proxy/Initializable.sol"; import "../proxy/Initializable.sol";
...@@ -26,7 +26,7 @@ contract ERC20PresetFixedSupplyUpgradeable is Initializable, ERC20BurnableUpgrad ...@@ -26,7 +26,7 @@ contract ERC20PresetFixedSupplyUpgradeable is Initializable, ERC20BurnableUpgrad
__ERC20PresetFixedSupply_init(name, symbol, initialSupply, owner); __ERC20PresetFixedSupply_init(name, symbol, initialSupply, owner);
} }
/** /**
* @dev Mints `initialSupply` amount of token and transfers them to `owner`. * @dev Mints `initialSupply` amount of token and transfers them to `owner`.
* *
* See {ERC20-constructor}. * See {ERC20-constructor}.
*/ */
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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