Skip to content

Commit

Permalink
Merge branch 'master' into feature/internalSetOwner
Browse files Browse the repository at this point in the history
  • Loading branch information
Amxx committed Mar 10, 2021
2 parents 446bbdf + fb95a8b commit 92d2b29
Show file tree
Hide file tree
Showing 20 changed files with 1,086 additions and 839 deletions.
36 changes: 24 additions & 12 deletions CHANGELOG.md
@@ -1,27 +1,35 @@
# Changelog

## Unreleased

* `IERC20Metadata`: add a new extended interface that includes the optional `name()`, `symbol()` and `decimals()` functions. ([#2561](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2561))
* `ERC777`: make reception acquirement optional in `_mint`. ([#2552](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2552))

## 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))
* `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))
* `GSN`: deprecate GSNv1 support in favor of upcoming 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 behavior 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))
* `ERC721`: remove enumerability of tokens from the base implementation. This feature is now provided separately through the `ERC721Enumerable` extension. ([#2511](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2511))
* `AccessControl`: removed enumerability by default for a more lightweight contract. It is now opt-in through `AccessControlEnumerable`. ([#2512](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2512))
* Meta Transactions: add `ERC2771Context` and a `MinimalForwarder` for meta-transactions. ([#2508](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2508))
* Overall reorganisation of the contract folder to improve clarity and discoverability. ([#2503](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2503))
* `ERC20Capped`: optimize gas usage of by enforcing te check directly in `_mint`. ([#2524](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2524))
* Overall reorganization of the contract folder to improve clarity and discoverability. ([#2503](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2503))
* `ERC20Capped`: optimize gas usage by enforcing the check directly in `_mint`. ([#2524](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2524))
* Rename `UpgradeableProxy` to `ERC1967Proxy`. ([#2547](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2547))
* `ERC777`: Optimize the gas costs of the constructor. ([#2551](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2551))
* `ERC721URIStorage`: Add a new extension that implements the `_setTokenURI` behavior as it was available in 3.4.0. ([#2555](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2555))
* `AccessControl`: Added ERC165 interface detection. ([#2562](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2562))
* `AccessControlEnumerable`: Fixed `renounceRole` not updated underlying set. ([#2572](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2572))
* `Ownable`: Add `_transferOwnership` to Ownable. ([#2568](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/#2568))
* `AccessControl`: Make some private functions internal. ([#2568](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/#2568))
* `ERC777`: optimize the gas costs of the constructor. ([#2551](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2551))
* `ERC721URIStorage`: add a new extension that implements the `_setTokenURI` behavior as it was available in 3.4.0. ([#2555](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2555))
* `AccessControl`: added ERC165 interface detection. ([#2562](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2562))
* `ERC1155`: make `uri` public so overloading function can call it using super. ([#2576](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2576))

### Bug fixes for beta releases

* `AccessControlEnumerable`: Fixed `renounceRole` not updating enumerable set of addresses for a role. ([#2572](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2572))


### How to upgrade from 3.x

Expand All @@ -33,6 +41,10 @@ npx openzeppelin-contracts-migrate-imports

Make sure you're using git or another version control system to be able to recover from any potential error in our script.

### How to upgrade from 4.0-beta.x

Some further changes have been done between the different beta iterations. Transitions made during this period are configured in the `migrate-imports` script. Consequently, you can upgrade from any previous 4.0-beta.x version using the same script as described in the *How to upgrade from 3.x* section.

## 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))
Expand Down
Expand Up @@ -2,9 +2,9 @@

pragma solidity ^0.8.0;

import "./Address.sol";
import "./Context.sol";
import "./math/SafeMath.sol";
import "../utils/Address.sol";
import "../utils/Context.sol";
import "../utils/math/SafeMath.sol";

/**
* @title PaymentSplitter
Expand Down
10 changes: 10 additions & 0 deletions contracts/finance/README.adoc
@@ -0,0 +1,10 @@
= Finance

[.readme-notice]
NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/finance

This directory includes primitives for financial systems. We currently only offer the {PaymentSplitter} contract, but we want to grow this directory so we welcome ideas.

== PaymentSplitter

{{PaymentSplitter}}
2 changes: 1 addition & 1 deletion contracts/governance/README.adoc
@@ -1,7 +1,7 @@
= Governance

[.readme-notice]
NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/access
NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/governance

This directory includes primitives for on-chain governance. We currently only offer the {TimelockController} contract, that can be used as a component in a governance systems to introduce a delay between a proposal and its execution.

Expand Down
10 changes: 10 additions & 0 deletions contracts/mocks/ERC777Mock.sol
Expand Up @@ -27,6 +27,16 @@ contract ERC777Mock is Context, ERC777 {
_mint(to, amount, userData, operatorData);
}

function mintInternalExtended (
address to,
uint256 amount,
bytes memory userData,
bytes memory operatorData,
bool requireReceptionAck
) public {
_mint(to, amount, userData, operatorData, requireReceptionAck);
}

function approveInternal(address holder, address spender, uint256 value) public {
_approve(holder, spender, value);
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/InitializableMock.sol
Expand Up @@ -2,7 +2,7 @@

pragma solidity ^0.8.0;

import "../utils/Initializable.sol";
import "../proxy/utils/Initializable.sol";

/**
* @title InitializableMock
Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/MultipleInheritanceInitializableMocks.sol
Expand Up @@ -2,7 +2,7 @@

pragma solidity ^0.8.0;

import "../utils/Initializable.sol";
import "../proxy/utils/Initializable.sol";

// Sample contracts showing upgradeability with multiple inheritance.
// Child contract inherits from Father and Mother contracts, and Father extends from Gramps.
Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/RegressionImplementation.sol
Expand Up @@ -2,7 +2,7 @@

pragma solidity ^0.8.0;

import "../utils/Initializable.sol";
import "../proxy/utils/Initializable.sol";

contract Implementation1 is Initializable {
uint internal _value;
Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/SingleInheritanceInitializableMocks.sol
Expand Up @@ -2,7 +2,7 @@

pragma solidity ^0.8.0;

import "../utils/Initializable.sol";
import "../proxy/utils/Initializable.sol";

/**
* @title MigratableMockV1
Expand Down
4 changes: 4 additions & 0 deletions contracts/proxy/README.adoc
Expand Up @@ -40,3 +40,7 @@ CAUTION: Using upgradeable proxies correctly and securely is a difficult task th
== Minimal Clones

{{Clones}}

== Utils

{{Initializable}}
Expand Up @@ -3,7 +3,7 @@
// solhint-disable-next-line compiler-version
pragma solidity ^0.8.0;

import "./Address.sol";
import "../../utils/Address.sol";

/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
Expand Down
2 changes: 1 addition & 1 deletion contracts/token/ERC1155/ERC1155.sol
Expand Up @@ -55,7 +55,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI {
* Clients calling this function must replace the `\{id\}` substring with the
* actual token type ID.
*/
function uri(uint256) external view virtual override returns (string memory) {
function uri(uint256) public view virtual override returns (string memory) {
return _uri;
}

Expand Down
9 changes: 5 additions & 4 deletions contracts/token/ERC20/ERC20.sol
Expand Up @@ -3,6 +3,7 @@
pragma solidity ^0.8.0;

import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";

/**
Expand All @@ -29,7 +30,7 @@ import "../../utils/Context.sol";
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20 is Context, IERC20 {
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping (address => uint256) private _balances;

mapping (address => mapping (address => uint256)) private _allowances;
Expand All @@ -56,15 +57,15 @@ contract ERC20 is Context, IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
function name() public view virtual override returns (string memory) {
return _name;
}

/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
function symbol() public view virtual override returns (string memory) {
return _symbol;
}

Expand All @@ -81,7 +82,7 @@ contract ERC20 is Context, IERC20 {
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual returns (uint8) {
function decimals() public view virtual override returns (uint8) {
return 18;
}

Expand Down
3 changes: 3 additions & 0 deletions contracts/token/ERC20/README.adoc
Expand Up @@ -10,6 +10,7 @@ TIP: For an overview of ERC20 tokens and a walk through on how to create a token
There a few core contracts that implement the behavior specified in the EIP:

* {IERC20}: the interface all ERC20 implementations should conform to.
* {IERC20Metadata}: the extended ERC20 interface including the <<ERC20-name,`name`>>, <<ERC20-symbol,`symbol`>> and <<ERC20-decimals,`decimals`>> functions.
* {ERC20}: the implementation of the ERC20 interface, including the <<ERC20-name,`name`>>, <<ERC20-symbol,`symbol`>> and <<ERC20-decimals,`decimals`>> optional standard extension to the base interface.
Additionally there are multiple custom extensions, including:
Expand All @@ -36,6 +37,8 @@ NOTE: This core set of contracts is designed to be unopinionated, allowing devel

{{IERC20}}

{{IERC20Metadata}}

{{ERC20}}

== Extensions
Expand Down
25 changes: 25 additions & 0 deletions contracts/token/ERC20/extensions/IERC20Metadata.sol
@@ -0,0 +1,25 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC20.sol";

/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);

/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);

/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}
33 changes: 32 additions & 1 deletion contracts/token/ERC777/ERC777.sol
Expand Up @@ -312,6 +312,37 @@ contract ERC777 is Context, IERC777, IERC20 {
)
internal
virtual
{
_mint(account, amount, userData, operatorData, true);
}

/**
* @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* If `requireReceptionAck` is set to true, and if a send hook is
* registered for `account`, the corresponding function will be called with
* `operator`, `data` and `operatorData`.
*
* See {IERC777Sender} and {IERC777Recipient}.
*
* Emits {Minted} and {IERC20-Transfer} events.
*
* Requirements
*
* - `account` cannot be the zero address.
* - if `account` is a contract, it must implement the {IERC777Recipient}
* interface.
*/
function _mint(
address account,
uint256 amount,
bytes memory userData,
bytes memory operatorData,
bool requireReceptionAck
)
internal
virtual
{
require(account != address(0), "ERC777: mint to the zero address");

Expand All @@ -323,7 +354,7 @@ contract ERC777 is Context, IERC777, IERC20 {
_totalSupply += amount;
_balances[account] += amount;

_callTokensReceived(operator, address(0), account, amount, userData, operatorData, true);
_callTokensReceived(operator, address(0), account, amount, userData, operatorData, requireReceptionAck);

emit Minted(operator, account, amount, userData, operatorData);
emit Transfer(address(0), account, amount);
Expand Down
12 changes: 8 additions & 4 deletions contracts/utils/README.adoc
Expand Up @@ -40,6 +40,14 @@ Finally, {Create2} contains all necessary utilities to safely use the https://bl

{{EIP712}}

== Escrow

{{ConditionalEscrow}}

{{Escrow}}

{{RefundEscrow}}

== Introspection

This set of interfaces and contracts deal with https://en.wikipedia.org/wiki/Type_introspection[type introspection] of contracts, that is, examining which functions can be called on them. This is usually referred to as a contract's _interface_.
Expand Down Expand Up @@ -84,7 +92,3 @@ Note that, in all cases, accounts simply _declare_ their interfaces, but they ar
{{Counters}}

{{Strings}}

== Other

{{Initializable}}

0 comments on commit 92d2b29

Please sign in to comment.