From 2f6a68d4d6d77096cd2affe590e64d9243441f18 Mon Sep 17 00:00:00 2001 From: Joaquim Verges Date: Wed, 27 Apr 2022 15:11:07 -0700 Subject: [PATCH 1/2] reorganize exports for public consumption --- contracts/Multiwrap.sol | 3 +- contracts/Pack.sol | 7 +- contracts/drop/DropERC1155.sol | 11 +- contracts/drop/DropERC20.sol | 7 +- contracts/drop/DropERC721.sol | 12 +- contracts/{ => drop}/SignatureDrop.sol | 30 ++-- contracts/eip/ERC1155.sol | 139 +++++++++++++++++ contracts/eip/ERC20.sol | 28 ++++ contracts/{drop => feature}/DelayedReveal.sol | 4 +- contracts/{drop => feature}/LazyMint.sol | 4 +- .../{token => feature}/SignatureMint.sol | 4 +- .../SignatureMintUpgradeable.sol | 4 +- .../interface}/IBurnableERC1155.sol | 0 .../interface}/IBurnableERC20.sol | 0 .../interface}/IBurnableERC721.sol | 0 .../interface}/IDelayedReveal.sol | 2 +- .../drop => feature/interface}/ILazyMint.sol | 2 +- .../interface}/IMintableERC1155.sol | 0 .../interface}/IMintableERC20.sol | 0 .../interface}/IMintableERC721.sol | 0 .../interface}/ISignatureMint.sol | 7 - .../interface}/IThirdwebOwnable.sol | 2 +- .../interface}/IThirdwebPlatformFee.sol | 2 +- .../interface}/IThirdwebPrimarySale.sol | 2 +- .../interface}/IThirdwebRoyalty.sol | 15 +- contracts/interfaces/IMultiwrap.sol | 4 +- contracts/interfaces/IPack.sol | 4 +- .../interfaces/drop/IDropClaimCondition.sol | 2 +- .../interfaces/marketplace/IMarketplace.sol | 2 +- contracts/interfaces/token/ITokenERC1155.sol | 14 -- contracts/interfaces/token/ITokenERC20.sol | 7 - contracts/token/TokenERC1155.sol | 25 ++- contracts/token/TokenERC20.sol | 12 +- contracts/token/TokenERC721.sol | 16 +- docs/IERC1155.md | 144 ++++++++---------- docs/IERC20.md | 36 ++--- docs/IMultiwrap.md | 22 --- docs/IPack.md | 22 --- docs/IThirdwebRoyalty.md | 22 --- 39 files changed, 339 insertions(+), 278 deletions(-) rename contracts/{ => drop}/SignatureDrop.sol (96%) create mode 100644 contracts/eip/ERC1155.sol create mode 100644 contracts/eip/ERC20.sol rename contracts/{drop => feature}/DelayedReveal.sol (96%) rename contracts/{drop => feature}/LazyMint.sol (97%) rename contracts/{token => feature}/SignatureMint.sol (97%) rename contracts/{token => feature}/SignatureMintUpgradeable.sol (97%) rename contracts/{interfaces/token => feature/interface}/IBurnableERC1155.sol (100%) rename contracts/{interfaces/token => feature/interface}/IBurnableERC20.sol (100%) rename contracts/{interfaces/token => feature/interface}/IBurnableERC721.sol (100%) rename contracts/{interfaces/drop => feature/interface}/IDelayedReveal.sol (92%) rename contracts/{interfaces/drop => feature/interface}/ILazyMint.sol (88%) rename contracts/{interfaces/token => feature/interface}/IMintableERC1155.sol (100%) rename contracts/{interfaces/token => feature/interface}/IMintableERC20.sol (100%) rename contracts/{interfaces/token => feature/interface}/IMintableERC721.sol (100%) rename contracts/{interfaces/token => feature/interface}/ISignatureMint.sol (92%) rename contracts/{interfaces => feature/interface}/IThirdwebOwnable.sol (94%) rename contracts/{interfaces => feature/interface}/IThirdwebPlatformFee.sol (95%) rename contracts/{interfaces => feature/interface}/IThirdwebPrimarySale.sol (95%) rename contracts/{interfaces => feature/interface}/IThirdwebRoyalty.sol (71%) delete mode 100644 contracts/interfaces/token/ITokenERC1155.sol delete mode 100644 contracts/interfaces/token/ITokenERC20.sol diff --git a/contracts/Multiwrap.sol b/contracts/Multiwrap.sol index 9e8680516..b6fdafeaa 100644 --- a/contracts/Multiwrap.sol +++ b/contracts/Multiwrap.sol @@ -22,6 +22,7 @@ import "./openzeppelin-presets/metatx/ERC2771ContextUpgradeable.sol"; // Helpers import "@openzeppelin/contracts-upgradeable/token/ERC1155/utils/ERC1155HolderUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC721/utils/ERC721HolderUpgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/interfaces/IERC2981Upgradeable.sol"; import "./lib/CurrencyTransferLib.sol"; import "./lib/MultiTokenTransferLib.sol"; @@ -354,7 +355,7 @@ contract Multiwrap is public view virtual - override(AccessControlEnumerableUpgradeable, ERC1155Upgradeable, IERC165Upgradeable, ERC1155ReceiverUpgradeable) + override(AccessControlEnumerableUpgradeable, ERC1155Upgradeable, ERC1155ReceiverUpgradeable) returns (bool) { return diff --git a/contracts/Pack.sol b/contracts/Pack.sol index 62b77e82f..7724af957 100644 --- a/contracts/Pack.sol +++ b/contracts/Pack.sol @@ -4,8 +4,8 @@ pragma solidity ^0.8.11; // Base import "./openzeppelin-presets/ERC1155PresetUpgradeable.sol"; import "./interfaces/IThirdwebContract.sol"; -import "./interfaces/IThirdwebOwnable.sol"; -import "./interfaces/IThirdwebRoyalty.sol"; +import "./feature/interface/IThirdwebOwnable.sol"; +import "./feature/interface/IThirdwebRoyalty.sol"; // Randomness import "@chainlink/contracts/src/v0.8/VRFConsumerBase.sol"; @@ -20,6 +20,7 @@ import "./lib/FeeType.sol"; // Helper interfaces import "@openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155Upgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/interfaces/IERC2981Upgradeable.sol"; // Thirdweb top-level import "./interfaces/ITWFee.sol"; @@ -530,7 +531,7 @@ contract Pack is function supportsInterface(bytes4 interfaceId) public view - override(ERC1155PresetUpgradeable, IERC165Upgradeable) + override(ERC1155PresetUpgradeable) returns (bool) { return super.supportsInterface(interfaceId) || type(IERC2981Upgradeable).interfaceId == interfaceId; diff --git a/contracts/drop/DropERC1155.sol b/contracts/drop/DropERC1155.sol index 07c9ac2ed..a0345717c 100644 --- a/contracts/drop/DropERC1155.sol +++ b/contracts/drop/DropERC1155.sol @@ -17,10 +17,13 @@ import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable. // ========== Internal imports ========== import "../interfaces/IThirdwebContract.sol"; -import "../interfaces/IThirdwebPlatformFee.sol"; -import "../interfaces/IThirdwebPrimarySale.sol"; -import "../interfaces/IThirdwebRoyalty.sol"; -import "../interfaces/IThirdwebOwnable.sol"; + +// ========== Features ========== + +import "../feature/interface/IThirdwebPlatformFee.sol"; +import "../feature/interface/IThirdwebPrimarySale.sol"; +import "../feature/interface/IThirdwebRoyalty.sol"; +import "../feature/interface/IThirdwebOwnable.sol"; import { IDropERC1155 } from "../interfaces/drop/IDropERC1155.sol"; import { ITWFee } from "../interfaces/ITWFee.sol"; diff --git a/contracts/drop/DropERC20.sol b/contracts/drop/DropERC20.sol index 315614bc2..2f2b1cf96 100644 --- a/contracts/drop/DropERC20.sol +++ b/contracts/drop/DropERC20.sol @@ -16,8 +16,11 @@ import "@openzeppelin/contracts-upgradeable/utils/MulticallUpgradeable.sol"; // ========== Internal imports ========== import "../interfaces/IThirdwebContract.sol"; -import "../interfaces/IThirdwebPlatformFee.sol"; -import "../interfaces/IThirdwebPrimarySale.sol"; + +// ========== Features ========== + +import "../feature/interface/IThirdwebPlatformFee.sol"; +import "../feature/interface/IThirdwebPrimarySale.sol"; import { IDropERC20 } from "../interfaces/drop/IDropERC20.sol"; import { ITWFee } from "../interfaces/ITWFee.sol"; diff --git a/contracts/drop/DropERC721.sol b/contracts/drop/DropERC721.sol index aeb0fd194..501dde0b3 100644 --- a/contracts/drop/DropERC721.sol +++ b/contracts/drop/DropERC721.sol @@ -17,12 +17,14 @@ import "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol"; import { IDropERC721 } from "../interfaces/drop/IDropERC721.sol"; import { ITWFee } from "../interfaces/ITWFee.sol"; - import "../interfaces/IThirdwebContract.sol"; -import "../interfaces/IThirdwebPlatformFee.sol"; -import "../interfaces/IThirdwebPrimarySale.sol"; -import "../interfaces/IThirdwebRoyalty.sol"; -import "../interfaces/IThirdwebOwnable.sol"; + +// ========== Features ========== + +import "../feature/interface/IThirdwebPlatformFee.sol"; +import "../feature/interface/IThirdwebPrimarySale.sol"; +import "../feature/interface/IThirdwebRoyalty.sol"; +import "../feature/interface/IThirdwebOwnable.sol"; import "../openzeppelin-presets/metatx/ERC2771ContextUpgradeable.sol"; diff --git a/contracts/SignatureDrop.sol b/contracts/drop/SignatureDrop.sol similarity index 96% rename from contracts/SignatureDrop.sol rename to contracts/drop/SignatureDrop.sol index ab4f6ed26..1ea9497f4 100644 --- a/contracts/SignatureDrop.sol +++ b/contracts/drop/SignatureDrop.sol @@ -11,23 +11,25 @@ import "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol"; // ========== Internal imports ========== -import "./interfaces/ITWFee.sol"; +import "../interfaces/ITWFee.sol"; +import "../interfaces/IThirdwebContract.sol"; +import "../interfaces/drop/IDropClaimCondition.sol"; -import "./interfaces/IThirdwebContract.sol"; -import "./interfaces/IThirdwebPlatformFee.sol"; -import "./interfaces/IThirdwebPrimarySale.sol"; -import "./interfaces/IThirdwebRoyalty.sol"; -import "./interfaces/IThirdwebOwnable.sol"; +// ========== Features ========== -import "./interfaces/drop/IDropClaimCondition.sol"; -import "./drop/DelayedReveal.sol"; -import "./drop/LazyMint.sol"; -import "./token/SignatureMintUpgradeable.sol"; +import "../feature/interface/IThirdwebPlatformFee.sol"; +import "../feature/interface/IThirdwebPrimarySale.sol"; +import "../feature/interface/IThirdwebRoyalty.sol"; +import "../feature/interface/IThirdwebOwnable.sol"; +import "../feature/DelayedReveal.sol"; +import "../feature/LazyMint.sol"; +import "../feature/SignatureMintUpgradeable.sol"; -import "./openzeppelin-presets/metatx/ERC2771ContextUpgradeable.sol"; +import "../openzeppelin-presets/metatx/ERC2771ContextUpgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/interfaces/IERC2981Upgradeable.sol"; -import "./lib/CurrencyTransferLib.sol"; -import "./lib/FeeType.sol"; +import "../lib/CurrencyTransferLib.sol"; +import "../lib/FeeType.sol"; contract SignatureDrop is Initializable, @@ -206,7 +208,7 @@ contract SignatureDrop is public view virtual - override(ERC721EnumerableUpgradeable, AccessControlEnumerableUpgradeable, IERC165Upgradeable) + override(ERC721EnumerableUpgradeable, AccessControlEnumerableUpgradeable) returns (bool) { return super.supportsInterface(interfaceId) || type(IERC2981Upgradeable).interfaceId == interfaceId; diff --git a/contracts/eip/ERC1155.sol b/contracts/eip/ERC1155.sol new file mode 100644 index 000000000..27a2ae86d --- /dev/null +++ b/contracts/eip/ERC1155.sol @@ -0,0 +1,139 @@ +// SPDX-License-Identifier: Apache-2.0 +pragma solidity ^0.8.0; + +/** + @title ERC-1155 Multi Token Standard + @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1155.md + Note: The ERC-165 identifier for this interface is 0xd9b67a26. + */ +/* is ERC165 */ +interface IERC1155 { + /** + @dev Either `TransferSingle` or `TransferBatch` MUST emit when tokens are transferred, including zero value transfers as well as minting or burning (see "Safe Transfer Rules" section of the standard). + The `_operator` argument MUST be msg.sender. + The `_from` argument MUST be the address of the holder whose balance is decreased. + The `_to` argument MUST be the address of the recipient whose balance is increased. + The `_id` argument MUST be the token type being transferred. + The `_value` argument MUST be the number of tokens the holder balance is decreased by and match what the recipient balance is increased by. + When minting/creating tokens, the `_from` argument MUST be set to `0x0` (i.e. zero address). + When burning/destroying tokens, the `_to` argument MUST be set to `0x0` (i.e. zero address). + */ + event TransferSingle( + address indexed _operator, + address indexed _from, + address indexed _to, + uint256 _id, + uint256 _value + ); + + /** + @dev Either `TransferSingle` or `TransferBatch` MUST emit when tokens are transferred, including zero value transfers as well as minting or burning (see "Safe Transfer Rules" section of the standard). + The `_operator` argument MUST be msg.sender. + The `_from` argument MUST be the address of the holder whose balance is decreased. + The `_to` argument MUST be the address of the recipient whose balance is increased. + The `_ids` argument MUST be the list of tokens being transferred. + The `_values` argument MUST be the list of number of tokens (matching the list and order of tokens specified in _ids) the holder balance is decreased by and match what the recipient balance is increased by. + When minting/creating tokens, the `_from` argument MUST be set to `0x0` (i.e. zero address). + When burning/destroying tokens, the `_to` argument MUST be set to `0x0` (i.e. zero address). + */ + event TransferBatch( + address indexed _operator, + address indexed _from, + address indexed _to, + uint256[] _ids, + uint256[] _values + ); + + /** + @dev MUST emit when approval for a second party/operator address to manage all tokens for an owner address is enabled or disabled (absense of an event assumes disabled). + */ + event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved); + + /** + @dev MUST emit when the URI is updated for a token ID. + URIs are defined in RFC 3986. + The URI MUST point a JSON file that conforms to the "ERC-1155 Metadata URI JSON Schema". + */ + event URI(string _value, uint256 indexed _id); + + /** + @notice Transfers `_value` amount of an `_id` from the `_from` address to the `_to` address specified (with safety call). + @dev Caller must be approved to manage the tokens being transferred out of the `_from` account (see "Approval" section of the standard). + MUST revert if `_to` is the zero address. + MUST revert if balance of holder for token `_id` is lower than the `_value` sent. + MUST revert on any other error. + MUST emit the `TransferSingle` event to reflect the balance change (see "Safe Transfer Rules" section of the standard). + After the above conditions are met, this function MUST check if `_to` is a smart contract (e.g. code size > 0). If so, it MUST call `onERC1155Received` on `_to` and act appropriately (see "Safe Transfer Rules" section of the standard). + @param _from Source address + @param _to Target address + @param _id ID of the token type + @param _value Transfer amount + @param _data Additional data with no specified format, MUST be sent unaltered in call to `onERC1155Received` on `_to` + */ + function safeTransferFrom( + address _from, + address _to, + uint256 _id, + uint256 _value, + bytes calldata _data + ) external; + + /** + @notice Transfers `_values` amount(s) of `_ids` from the `_from` address to the `_to` address specified (with safety call). + @dev Caller must be approved to manage the tokens being transferred out of the `_from` account (see "Approval" section of the standard). + MUST revert if `_to` is the zero address. + MUST revert if length of `_ids` is not the same as length of `_values`. + MUST revert if any of the balance(s) of the holder(s) for token(s) in `_ids` is lower than the respective amount(s) in `_values` sent to the recipient. + MUST revert on any other error. + MUST emit `TransferSingle` or `TransferBatch` event(s) such that all the balance changes are reflected (see "Safe Transfer Rules" section of the standard). + Balance changes and events MUST follow the ordering of the arrays (_ids[0]/_values[0] before _ids[1]/_values[1], etc). + After the above conditions for the transfer(s) in the batch are met, this function MUST check if `_to` is a smart contract (e.g. code size > 0). If so, it MUST call the relevant `ERC1155TokenReceiver` hook(s) on `_to` and act appropriately (see "Safe Transfer Rules" section of the standard). + @param _from Source address + @param _to Target address + @param _ids IDs of each token type (order and length must match _values array) + @param _values Transfer amounts per token type (order and length must match _ids array) + @param _data Additional data with no specified format, MUST be sent unaltered in call to the `ERC1155TokenReceiver` hook(s) on `_to` + */ + function safeBatchTransferFrom( + address _from, + address _to, + uint256[] calldata _ids, + uint256[] calldata _values, + bytes calldata _data + ) external; + + /** + @notice Get the balance of an account's Tokens. + @param _owner The address of the token holder + @param _id ID of the Token + @return The _owner's balance of the Token type requested + */ + function balanceOf(address _owner, uint256 _id) external view returns (uint256); + + /** + @notice Get the balance of multiple account/token pairs + @param _owners The addresses of the token holders + @param _ids ID of the Tokens + @return The _owner's balance of the Token types requested (i.e. balance for each (owner, id) pair) + */ + function balanceOfBatch(address[] calldata _owners, uint256[] calldata _ids) + external + view + returns (uint256[] memory); + + /** + @notice Enable or disable approval for a third party ("operator") to manage all of the caller's tokens. + @dev MUST emit the ApprovalForAll event on success. + @param _operator Address to add to the set of authorized operators + @param _approved True if the operator is approved, false to revoke approval + */ + function setApprovalForAll(address _operator, bool _approved) external; + + /** + @notice Queries the approval status of an operator for a given owner. + @param _owner The owner of the Tokens + @param _operator Address of authorized operator + @return True if the operator is approved, false if not + */ + function isApprovedForAll(address _owner, address _operator) external view returns (bool); +} diff --git a/contracts/eip/ERC20.sol b/contracts/eip/ERC20.sol new file mode 100644 index 000000000..6350dfc2c --- /dev/null +++ b/contracts/eip/ERC20.sol @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: Apache-2.0 +pragma solidity ^0.8.0; + +/** + * @title ERC20 interface + * @dev see https://github.com/ethereum/EIPs/issues/20 + */ +interface IERC20 { + function totalSupply() external view returns (uint256); + + function balanceOf(address who) external view returns (uint256); + + function allowance(address owner, address spender) external view returns (uint256); + + function transfer(address to, uint256 value) external returns (bool); + + function approve(address spender, uint256 value) external returns (bool); + + function transferFrom( + address from, + address to, + uint256 value + ) external returns (bool); + + event Transfer(address indexed from, address indexed to, uint256 value); + + event Approval(address indexed owner, address indexed spender, uint256 value); +} diff --git a/contracts/drop/DelayedReveal.sol b/contracts/feature/DelayedReveal.sol similarity index 96% rename from contracts/drop/DelayedReveal.sol rename to contracts/feature/DelayedReveal.sol index 5ccc80c29..41ecf821e 100644 --- a/contracts/drop/DelayedReveal.sol +++ b/contracts/feature/DelayedReveal.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 -pragma solidity ^0.8.11; +pragma solidity ^0.8.0; -import "../interfaces/drop/IDelayedReveal.sol"; +import "./interface/IDelayedReveal.sol"; abstract contract DelayedReveal is IDelayedReveal { /// @dev Mapping from id of a batch of tokens => to encrypted base URI for the respective batch of tokens. diff --git a/contracts/drop/LazyMint.sol b/contracts/feature/LazyMint.sol similarity index 97% rename from contracts/drop/LazyMint.sol rename to contracts/feature/LazyMint.sol index 0dff2856c..81fde817e 100644 --- a/contracts/drop/LazyMint.sol +++ b/contracts/feature/LazyMint.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 -pragma solidity ^0.8.11; +pragma solidity ^0.8.0; -import "../interfaces/drop/ILazyMint.sol"; +import "./interface/ILazyMint.sol"; abstract contract LazyMint is ILazyMint { /// @dev Largest tokenId of each batch of tokens with the same baseURI. diff --git a/contracts/token/SignatureMint.sol b/contracts/feature/SignatureMint.sol similarity index 97% rename from contracts/token/SignatureMint.sol rename to contracts/feature/SignatureMint.sol index d4bf9c4f4..8e1e0e2b2 100644 --- a/contracts/token/SignatureMint.sol +++ b/contracts/feature/SignatureMint.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 -pragma solidity ^0.8.11; +pragma solidity ^0.8.0; -import "../interfaces/token/ISignatureMint.sol"; +import "./interface/ISignatureMint.sol"; import "@openzeppelin/contracts/access/AccessControlEnumerable.sol"; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; diff --git a/contracts/token/SignatureMintUpgradeable.sol b/contracts/feature/SignatureMintUpgradeable.sol similarity index 97% rename from contracts/token/SignatureMintUpgradeable.sol rename to contracts/feature/SignatureMintUpgradeable.sol index 11106c375..fda4dee93 100644 --- a/contracts/token/SignatureMintUpgradeable.sol +++ b/contracts/feature/SignatureMintUpgradeable.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 -pragma solidity ^0.8.11; +pragma solidity ^0.8.0; -import "../interfaces/token/ISignatureMint.sol"; +import "./interface/ISignatureMint.sol"; import "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol"; diff --git a/contracts/interfaces/token/IBurnableERC1155.sol b/contracts/feature/interface/IBurnableERC1155.sol similarity index 100% rename from contracts/interfaces/token/IBurnableERC1155.sol rename to contracts/feature/interface/IBurnableERC1155.sol diff --git a/contracts/interfaces/token/IBurnableERC20.sol b/contracts/feature/interface/IBurnableERC20.sol similarity index 100% rename from contracts/interfaces/token/IBurnableERC20.sol rename to contracts/feature/interface/IBurnableERC20.sol diff --git a/contracts/interfaces/token/IBurnableERC721.sol b/contracts/feature/interface/IBurnableERC721.sol similarity index 100% rename from contracts/interfaces/token/IBurnableERC721.sol rename to contracts/feature/interface/IBurnableERC721.sol diff --git a/contracts/interfaces/drop/IDelayedReveal.sol b/contracts/feature/interface/IDelayedReveal.sol similarity index 92% rename from contracts/interfaces/drop/IDelayedReveal.sol rename to contracts/feature/interface/IDelayedReveal.sol index 409a069fb..51d96ff7f 100644 --- a/contracts/interfaces/drop/IDelayedReveal.sol +++ b/contracts/feature/interface/IDelayedReveal.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -pragma solidity ^0.8.11; +pragma solidity ^0.8.0; interface IDelayedReveal { function reveal(uint256 identifier, bytes calldata key) external returns (string memory revealedURI); diff --git a/contracts/interfaces/drop/ILazyMint.sol b/contracts/feature/interface/ILazyMint.sol similarity index 88% rename from contracts/interfaces/drop/ILazyMint.sol rename to contracts/feature/interface/ILazyMint.sol index bcf1510f6..e775cee38 100644 --- a/contracts/interfaces/drop/ILazyMint.sol +++ b/contracts/feature/interface/ILazyMint.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -pragma solidity ^0.8.11; +pragma solidity ^0.8.0; interface ILazyMint { function lazyMint( diff --git a/contracts/interfaces/token/IMintableERC1155.sol b/contracts/feature/interface/IMintableERC1155.sol similarity index 100% rename from contracts/interfaces/token/IMintableERC1155.sol rename to contracts/feature/interface/IMintableERC1155.sol diff --git a/contracts/interfaces/token/IMintableERC20.sol b/contracts/feature/interface/IMintableERC20.sol similarity index 100% rename from contracts/interfaces/token/IMintableERC20.sol rename to contracts/feature/interface/IMintableERC20.sol diff --git a/contracts/interfaces/token/IMintableERC721.sol b/contracts/feature/interface/IMintableERC721.sol similarity index 100% rename from contracts/interfaces/token/IMintableERC721.sol rename to contracts/feature/interface/IMintableERC721.sol diff --git a/contracts/interfaces/token/ISignatureMint.sol b/contracts/feature/interface/ISignatureMint.sol similarity index 92% rename from contracts/interfaces/token/ISignatureMint.sol rename to contracts/feature/interface/ISignatureMint.sol index a82a0edee..9eda91c26 100644 --- a/contracts/interfaces/token/ISignatureMint.sol +++ b/contracts/feature/interface/ISignatureMint.sol @@ -1,13 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; -import "@openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155Upgradeable.sol"; -import "../IThirdwebContract.sol"; -import "../IThirdwebPlatformFee.sol"; -import "../IThirdwebPrimarySale.sol"; -import "../IThirdwebRoyalty.sol"; -import "../IThirdwebOwnable.sol"; - /** * The 'signature minting' mechanism used in thirdweb Token smart contracts is a way for a contract admin to authorize an external party's * request to mint tokens on the admin's contract. diff --git a/contracts/interfaces/IThirdwebOwnable.sol b/contracts/feature/interface/IThirdwebOwnable.sol similarity index 94% rename from contracts/interfaces/IThirdwebOwnable.sol rename to contracts/feature/interface/IThirdwebOwnable.sol index e06401bbd..20e847aec 100644 --- a/contracts/interfaces/IThirdwebOwnable.sol +++ b/contracts/feature/interface/IThirdwebOwnable.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -pragma solidity ^0.8.11; +pragma solidity ^0.8.0; interface IThirdwebOwnable { /// @dev Returns the owner of the contract. diff --git a/contracts/interfaces/IThirdwebPlatformFee.sol b/contracts/feature/interface/IThirdwebPlatformFee.sol similarity index 95% rename from contracts/interfaces/IThirdwebPlatformFee.sol rename to contracts/feature/interface/IThirdwebPlatformFee.sol index 437406129..1b1be27cb 100644 --- a/contracts/interfaces/IThirdwebPlatformFee.sol +++ b/contracts/feature/interface/IThirdwebPlatformFee.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -pragma solidity ^0.8.11; +pragma solidity ^0.8.0; interface IThirdwebPlatformFee { /// @dev Returns the platform fee bps and recipient. diff --git a/contracts/interfaces/IThirdwebPrimarySale.sol b/contracts/feature/interface/IThirdwebPrimarySale.sol similarity index 95% rename from contracts/interfaces/IThirdwebPrimarySale.sol rename to contracts/feature/interface/IThirdwebPrimarySale.sol index 8e14148e7..1ccd585d2 100644 --- a/contracts/interfaces/IThirdwebPrimarySale.sol +++ b/contracts/feature/interface/IThirdwebPrimarySale.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -pragma solidity ^0.8.11; +pragma solidity ^0.8.0; interface IThirdwebPrimarySale { /// @dev The adress that receives all primary sales value. diff --git a/contracts/interfaces/IThirdwebRoyalty.sol b/contracts/feature/interface/IThirdwebRoyalty.sol similarity index 71% rename from contracts/interfaces/IThirdwebRoyalty.sol rename to contracts/feature/interface/IThirdwebRoyalty.sol index 70de127ce..1c0a611c4 100644 --- a/contracts/interfaces/IThirdwebRoyalty.sol +++ b/contracts/feature/interface/IThirdwebRoyalty.sol @@ -1,9 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 -pragma solidity ^0.8.11; +pragma solidity ^0.8.0; -import "@openzeppelin/contracts-upgradeable/interfaces/IERC2981Upgradeable.sol"; - -interface IThirdwebRoyalty is IERC2981Upgradeable { +interface IThirdwebRoyalty { struct RoyaltyInfo { address recipient; uint256 bps; @@ -25,6 +23,15 @@ interface IThirdwebRoyalty is IERC2981Upgradeable { /// @dev Returns the royalty recipient for a particular token Id. function getRoyaltyInfoForToken(uint256 tokenId) external view returns (address, uint16); + /** + * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of + * exchange. The royalty amount is denominated and should be payed in that same unit of exchange. + */ + function royaltyInfo(uint256 tokenId, uint256 salePrice) + external + view + returns (address receiver, uint256 royaltyAmount); + /// @dev Emitted when royalty info is updated. event DefaultRoyalty(address newRoyaltyRecipient, uint256 newRoyaltyBps); diff --git a/contracts/interfaces/IMultiwrap.sol b/contracts/interfaces/IMultiwrap.sol index b7db26f3d..2c0988575 100644 --- a/contracts/interfaces/IMultiwrap.sol +++ b/contracts/interfaces/IMultiwrap.sol @@ -2,8 +2,8 @@ pragma solidity ^0.8.11; import "./IThirdwebContract.sol"; -import "./IThirdwebRoyalty.sol"; -import "./IThirdwebOwnable.sol"; +import "../feature/interface/IThirdwebRoyalty.sol"; +import "../feature/interface/IThirdwebOwnable.sol"; import "../lib/MultiTokenTransferLib.sol"; interface IMultiwrap is IThirdwebContract, IThirdwebOwnable, IThirdwebRoyalty { diff --git a/contracts/interfaces/IPack.sol b/contracts/interfaces/IPack.sol index 2cad69d40..f36e81d76 100644 --- a/contracts/interfaces/IPack.sol +++ b/contracts/interfaces/IPack.sol @@ -2,8 +2,8 @@ pragma solidity ^0.8.11; import "./IThirdwebContract.sol"; -import "./IThirdwebOwnable.sol"; -import "./IThirdwebRoyalty.sol"; +import "../feature/interface/IThirdwebOwnable.sol"; +import "../feature/interface/IThirdwebRoyalty.sol"; interface IPack is IThirdwebContract, IThirdwebOwnable, IThirdwebRoyalty { /** diff --git a/contracts/interfaces/drop/IDropClaimCondition.sol b/contracts/interfaces/drop/IDropClaimCondition.sol index 55777dfc7..fe9409747 100644 --- a/contracts/interfaces/drop/IDropClaimCondition.sol +++ b/contracts/interfaces/drop/IDropClaimCondition.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -pragma solidity ^0.8.11; +pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/utils/structs/BitMapsUpgradeable.sol"; diff --git a/contracts/interfaces/marketplace/IMarketplace.sol b/contracts/interfaces/marketplace/IMarketplace.sol index fee6feca2..e863d76c4 100644 --- a/contracts/interfaces/marketplace/IMarketplace.sol +++ b/contracts/interfaces/marketplace/IMarketplace.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.11; import "../IThirdwebContract.sol"; -import "../IThirdwebPlatformFee.sol"; +import "../../feature/interface/IThirdwebPlatformFee.sol"; interface IMarketplace is IThirdwebContract, IThirdwebPlatformFee { /// @notice Type of the tokens that can be listed for sale. diff --git a/contracts/interfaces/token/ITokenERC1155.sol b/contracts/interfaces/token/ITokenERC1155.sol deleted file mode 100644 index 57e95a5b2..000000000 --- a/contracts/interfaces/token/ITokenERC1155.sol +++ /dev/null @@ -1,14 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -pragma solidity ^0.8.0; - -import "@openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155Upgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/IERC1155MetadataURIUpgradeable.sol"; - -/** - * `SignatureMint1155` is an ERC 1155 contract. It lets anyone mint NFTs by producing a mint request - * and a signature (produced by an account with MINTER_ROLE, signing the mint request). - */ -interface ITokenERC1155 is IERC1155Upgradeable, IERC1155MetadataURIUpgradeable { - /// @dev The total circulating supply of tokens of ID `tokenId` - function totalSupply(uint256 id) external view returns (uint256 supply); -} diff --git a/contracts/interfaces/token/ITokenERC20.sol b/contracts/interfaces/token/ITokenERC20.sol deleted file mode 100644 index 09b9028c0..000000000 --- a/contracts/interfaces/token/ITokenERC20.sol +++ /dev/null @@ -1,7 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -pragma solidity ^0.8.0; - -import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol"; - -interface ITokenERC20 is IERC20MetadataUpgradeable {} diff --git a/contracts/token/TokenERC1155.sol b/contracts/token/TokenERC1155.sol index 457f55aa3..cd8491f1f 100644 --- a/contracts/token/TokenERC1155.sol +++ b/contracts/token/TokenERC1155.sol @@ -2,16 +2,15 @@ pragma solidity ^0.8.11; // Interface -import "../interfaces/token/ITokenERC1155.sol"; -import "../interfaces/token/IMintableERC1155.sol"; -import "../interfaces/token/IBurnableERC1155.sol"; -import "./SignatureMintUpgradeable.sol"; +import "../feature/interface/IMintableERC1155.sol"; +import "../feature/interface/IBurnableERC1155.sol"; +import "../feature/SignatureMintUpgradeable.sol"; import "../interfaces/IThirdwebContract.sol"; -import "../interfaces/IThirdwebPlatformFee.sol"; -import "../interfaces/IThirdwebPrimarySale.sol"; -import "../interfaces/IThirdwebRoyalty.sol"; -import "../interfaces/IThirdwebOwnable.sol"; +import "../feature/interface/IThirdwebPlatformFee.sol"; +import "../feature/interface/IThirdwebPrimarySale.sol"; +import "../feature/interface/IThirdwebRoyalty.sol"; +import "../feature/interface/IThirdwebOwnable.sol"; // Token import "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol"; @@ -45,7 +44,6 @@ contract TokenERC1155 is MulticallUpgradeable, AccessControlEnumerableUpgradeable, ERC1155Upgradeable, - ITokenERC1155, IMintableERC1155, IBurnableERC1155, SignatureMintUpgradeable @@ -168,12 +166,7 @@ contract TokenERC1155 is } /// @dev Returns the URI for a tokenId - function uri(uint256 _tokenId) - public - view - override(ERC1155Upgradeable, IERC1155MetadataURIUpgradeable) - returns (string memory) - { + function uri(uint256 _tokenId) public view override(ERC1155Upgradeable) returns (string memory) { return _tokenURI[_tokenId]; } @@ -450,7 +443,7 @@ contract TokenERC1155 is public view virtual - override(AccessControlEnumerableUpgradeable, ERC1155Upgradeable, IERC165Upgradeable) + override(AccessControlEnumerableUpgradeable, ERC1155Upgradeable) returns (bool) { return diff --git a/contracts/token/TokenERC20.sol b/contracts/token/TokenERC20.sol index 4667dfdca..160b58ba1 100644 --- a/contracts/token/TokenERC20.sol +++ b/contracts/token/TokenERC20.sol @@ -2,14 +2,13 @@ pragma solidity ^0.8.11; //Interface -import "../interfaces/token/ITokenERC20.sol"; -import "../interfaces/token/IBurnableERC20.sol"; -import "../interfaces/token/IMintableERC20.sol"; -import "./SignatureMintUpgradeable.sol"; +import "../feature/interface/IBurnableERC20.sol"; +import "../feature/interface/IMintableERC20.sol"; +import "../feature/SignatureMintUpgradeable.sol"; import "../interfaces/IThirdwebContract.sol"; -import "../interfaces/IThirdwebPlatformFee.sol"; -import "../interfaces/IThirdwebPrimarySale.sol"; +import "../feature/interface/IThirdwebPlatformFee.sol"; +import "../feature/interface/IThirdwebPrimarySale.sol"; // Token import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20BurnableUpgradeable.sol"; @@ -45,7 +44,6 @@ contract TokenERC20 is MulticallUpgradeable, ERC20PausableUpgradeable, ERC20VotesUpgradeable, - ITokenERC20, IMintableERC20, IBurnableERC20, SignatureMintUpgradeable diff --git a/contracts/token/TokenERC721.sol b/contracts/token/TokenERC721.sol index 1c063ee41..51764a00e 100644 --- a/contracts/token/TokenERC721.sol +++ b/contracts/token/TokenERC721.sol @@ -2,15 +2,15 @@ pragma solidity ^0.8.11; // Interface -import "../interfaces/token/IMintableERC721.sol"; -import "../interfaces/token/IBurnableERC721.sol"; -import "./SignatureMintUpgradeable.sol"; +import "../feature/interface/IMintableERC721.sol"; +import "../feature/interface/IBurnableERC721.sol"; +import "../feature/SignatureMintUpgradeable.sol"; import "../interfaces/IThirdwebContract.sol"; -import "../interfaces/IThirdwebPlatformFee.sol"; -import "../interfaces/IThirdwebPrimarySale.sol"; -import "../interfaces/IThirdwebRoyalty.sol"; -import "../interfaces/IThirdwebOwnable.sol"; +import "../feature/interface/IThirdwebPlatformFee.sol"; +import "../feature/interface/IThirdwebPrimarySale.sol"; +import "../feature/interface/IThirdwebRoyalty.sol"; +import "../feature/interface/IThirdwebOwnable.sol"; // Token import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol"; @@ -371,7 +371,7 @@ contract TokenERC721 is public view virtual - override(AccessControlEnumerableUpgradeable, ERC721EnumerableUpgradeable, IERC165Upgradeable) + override(AccessControlEnumerableUpgradeable, ERC721EnumerableUpgradeable) returns (bool) { return super.supportsInterface(interfaceId) || interfaceId == type(IERC2981Upgradeable).interfaceId; diff --git a/docs/IERC1155.md b/docs/IERC1155.md index 167498bf4..32ca592ae 100644 --- a/docs/IERC1155.md +++ b/docs/IERC1155.md @@ -2,161 +2,139 @@ +> ERC-1155 Multi Token Standard - -*Required interface of an ERC1155 compliant contract, as defined in the https://eips.ethereum.org/EIPS/eip-1155[EIP]. _Available since v3.1._* +*See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1155.md Note: The ERC-165 identifier for this interface is 0xd9b67a26.* ## Methods ### balanceOf ```solidity -function balanceOf(address account, uint256 id) external view returns (uint256) +function balanceOf(address _owner, uint256 _id) external view returns (uint256) ``` +Get the balance of an account's Tokens. -*Returns the amount of tokens of token type `id` owned by `account`. Requirements: - `account` cannot be the zero address.* #### Parameters | Name | Type | Description | |---|---|---| -| account | address | undefined -| id | uint256 | undefined +| _owner | address | The address of the token holder +| _id | uint256 | ID of the Token #### Returns | Name | Type | Description | |---|---|---| -| _0 | uint256 | undefined +| _0 | uint256 | The _owner's balance of the Token type requested ### balanceOfBatch ```solidity -function balanceOfBatch(address[] accounts, uint256[] ids) external view returns (uint256[]) +function balanceOfBatch(address[] _owners, uint256[] _ids) external view returns (uint256[]) ``` +Get the balance of multiple account/token pairs -*xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}. Requirements: - `accounts` and `ids` must have the same length.* #### Parameters | Name | Type | Description | |---|---|---| -| accounts | address[] | undefined -| ids | uint256[] | undefined +| _owners | address[] | The addresses of the token holders +| _ids | uint256[] | ID of the Tokens #### Returns | Name | Type | Description | |---|---|---| -| _0 | uint256[] | undefined +| _0 | uint256[] | The _owner's balance of the Token types requested (i.e. balance for each (owner, id) pair) ### isApprovedForAll ```solidity -function isApprovedForAll(address account, address operator) external view returns (bool) +function isApprovedForAll(address _owner, address _operator) external view returns (bool) ``` +Queries the approval status of an operator for a given owner. -*Returns true if `operator` is approved to transfer ``account``'s tokens. See {setApprovalForAll}.* #### Parameters | Name | Type | Description | |---|---|---| -| account | address | undefined -| operator | address | undefined +| _owner | address | The owner of the Tokens +| _operator | address | Address of authorized operator #### Returns | Name | Type | Description | |---|---|---| -| _0 | bool | undefined +| _0 | bool | True if the operator is approved, false if not ### safeBatchTransferFrom ```solidity -function safeBatchTransferFrom(address from, address to, uint256[] ids, uint256[] amounts, bytes data) external nonpayable +function safeBatchTransferFrom(address _from, address _to, uint256[] _ids, uint256[] _values, bytes _data) external nonpayable ``` +Transfers `_values` amount(s) of `_ids` from the `_from` address to the `_to` address specified (with safety call). - -*xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. Emits a {TransferBatch} event. Requirements: - `ids` and `amounts` must have the same length. - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the acceptance magic value.* +*Caller must be approved to manage the tokens being transferred out of the `_from` account (see "Approval" section of the standard). MUST revert if `_to` is the zero address. MUST revert if length of `_ids` is not the same as length of `_values`. MUST revert if any of the balance(s) of the holder(s) for token(s) in `_ids` is lower than the respective amount(s) in `_values` sent to the recipient. MUST revert on any other error. MUST emit `TransferSingle` or `TransferBatch` event(s) such that all the balance changes are reflected (see "Safe Transfer Rules" section of the standard). Balance changes and events MUST follow the ordering of the arrays (_ids[0]/_values[0] before _ids[1]/_values[1], etc). After the above conditions for the transfer(s) in the batch are met, this function MUST check if `_to` is a smart contract (e.g. code size > 0). If so, it MUST call the relevant `ERC1155TokenReceiver` hook(s) on `_to` and act appropriately (see "Safe Transfer Rules" section of the standard).* #### Parameters | Name | Type | Description | |---|---|---| -| from | address | undefined -| to | address | undefined -| ids | uint256[] | undefined -| amounts | uint256[] | undefined -| data | bytes | undefined +| _from | address | Source address +| _to | address | Target address +| _ids | uint256[] | IDs of each token type (order and length must match _values array) +| _values | uint256[] | Transfer amounts per token type (order and length must match _ids array) +| _data | bytes | Additional data with no specified format, MUST be sent unaltered in call to the `ERC1155TokenReceiver` hook(s) on `_to` ### safeTransferFrom ```solidity -function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes data) external nonpayable +function safeTransferFrom(address _from, address _to, uint256 _id, uint256 _value, bytes _data) external nonpayable ``` +Transfers `_value` amount of an `_id` from the `_from` address to the `_to` address specified (with safety call). - -*Transfers `amount` tokens of token type `id` from `from` to `to`. Emits a {TransferSingle} event. Requirements: - `to` cannot be the zero address. - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}. - `from` must have a balance of tokens of type `id` of at least `amount`. - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the acceptance magic value.* +*Caller must be approved to manage the tokens being transferred out of the `_from` account (see "Approval" section of the standard). MUST revert if `_to` is the zero address. MUST revert if balance of holder for token `_id` is lower than the `_value` sent. MUST revert on any other error. MUST emit the `TransferSingle` event to reflect the balance change (see "Safe Transfer Rules" section of the standard). After the above conditions are met, this function MUST check if `_to` is a smart contract (e.g. code size > 0). If so, it MUST call `onERC1155Received` on `_to` and act appropriately (see "Safe Transfer Rules" section of the standard).* #### Parameters | Name | Type | Description | |---|---|---| -| from | address | undefined -| to | address | undefined -| id | uint256 | undefined -| amount | uint256 | undefined -| data | bytes | undefined +| _from | address | Source address +| _to | address | Target address +| _id | uint256 | ID of the token type +| _value | uint256 | Transfer amount +| _data | bytes | Additional data with no specified format, MUST be sent unaltered in call to `onERC1155Received` on `_to` ### setApprovalForAll ```solidity -function setApprovalForAll(address operator, bool approved) external nonpayable +function setApprovalForAll(address _operator, bool _approved) external nonpayable ``` +Enable or disable approval for a third party ("operator") to manage all of the caller's tokens. - -*Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, Emits an {ApprovalForAll} event. Requirements: - `operator` cannot be the caller.* +*MUST emit the ApprovalForAll event on success.* #### Parameters | Name | Type | Description | |---|---|---| -| operator | address | undefined -| approved | bool | undefined - -### supportsInterface - -```solidity -function supportsInterface(bytes4 interfaceId) external view returns (bool) -``` - - - -*Returns true if this contract implements the interface defined by `interfaceId`. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas.* - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| interfaceId | bytes4 | undefined - -#### Returns - -| Name | Type | Description | -|---|---|---| -| _0 | bool | undefined +| _operator | address | Address to add to the set of authorized operators +| _approved | bool | True if the operator is approved, false to revoke approval @@ -165,77 +143,77 @@ function supportsInterface(bytes4 interfaceId) external view returns (bool) ### ApprovalForAll ```solidity -event ApprovalForAll(address indexed account, address indexed operator, bool approved) +event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved) ``` -*Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to `approved`.* +*MUST emit when approval for a second party/operator address to manage all tokens for an owner address is enabled or disabled (absense of an event assumes disabled).* #### Parameters | Name | Type | Description | |---|---|---| -| account `indexed` | address | undefined | -| operator `indexed` | address | undefined | -| approved | bool | undefined | +| _owner `indexed` | address | undefined | +| _operator `indexed` | address | undefined | +| _approved | bool | undefined | ### TransferBatch ```solidity -event TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values) +event TransferBatch(address indexed _operator, address indexed _from, address indexed _to, uint256[] _ids, uint256[] _values) ``` -*Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all transfers.* +*Either `TransferSingle` or `TransferBatch` MUST emit when tokens are transferred, including zero value transfers as well as minting or burning (see "Safe Transfer Rules" section of the standard). The `_operator` argument MUST be msg.sender. The `_from` argument MUST be the address of the holder whose balance is decreased. The `_to` argument MUST be the address of the recipient whose balance is increased. The `_ids` argument MUST be the list of tokens being transferred. The `_values` argument MUST be the list of number of tokens (matching the list and order of tokens specified in _ids) the holder balance is decreased by and match what the recipient balance is increased by. When minting/creating tokens, the `_from` argument MUST be set to `0x0` (i.e. zero address). When burning/destroying tokens, the `_to` argument MUST be set to `0x0` (i.e. zero address).* #### Parameters | Name | Type | Description | |---|---|---| -| operator `indexed` | address | undefined | -| from `indexed` | address | undefined | -| to `indexed` | address | undefined | -| ids | uint256[] | undefined | -| values | uint256[] | undefined | +| _operator `indexed` | address | undefined | +| _from `indexed` | address | undefined | +| _to `indexed` | address | undefined | +| _ids | uint256[] | undefined | +| _values | uint256[] | undefined | ### TransferSingle ```solidity -event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value) +event TransferSingle(address indexed _operator, address indexed _from, address indexed _to, uint256 _id, uint256 _value) ``` -*Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.* +*Either `TransferSingle` or `TransferBatch` MUST emit when tokens are transferred, including zero value transfers as well as minting or burning (see "Safe Transfer Rules" section of the standard). The `_operator` argument MUST be msg.sender. The `_from` argument MUST be the address of the holder whose balance is decreased. The `_to` argument MUST be the address of the recipient whose balance is increased. The `_id` argument MUST be the token type being transferred. The `_value` argument MUST be the number of tokens the holder balance is decreased by and match what the recipient balance is increased by. When minting/creating tokens, the `_from` argument MUST be set to `0x0` (i.e. zero address). When burning/destroying tokens, the `_to` argument MUST be set to `0x0` (i.e. zero address).* #### Parameters | Name | Type | Description | |---|---|---| -| operator `indexed` | address | undefined | -| from `indexed` | address | undefined | -| to `indexed` | address | undefined | -| id | uint256 | undefined | -| value | uint256 | undefined | +| _operator `indexed` | address | undefined | +| _from `indexed` | address | undefined | +| _to `indexed` | address | undefined | +| _id | uint256 | undefined | +| _value | uint256 | undefined | ### URI ```solidity -event URI(string value, uint256 indexed id) +event URI(string _value, uint256 indexed _id) ``` -*Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI. If an {URI} event was emitted for `id`, the standard https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value returned by {IERC1155MetadataURI-uri}.* +*MUST emit when the URI is updated for a token ID. URIs are defined in RFC 3986. The URI MUST point a JSON file that conforms to the "ERC-1155 Metadata URI JSON Schema".* #### Parameters | Name | Type | Description | |---|---|---| -| value | string | undefined | -| id `indexed` | uint256 | undefined | +| _value | string | undefined | +| _id `indexed` | uint256 | undefined | diff --git a/docs/IERC20.md b/docs/IERC20.md index 3b2101125..da676f34b 100644 --- a/docs/IERC20.md +++ b/docs/IERC20.md @@ -2,11 +2,11 @@ +> ERC20 interface - -*Interface of the ERC20 standard as defined in the EIP.* +*see https://github.com/ethereum/EIPs/issues/20* ## Methods @@ -18,7 +18,7 @@ function allowance(address owner, address spender) external view returns (uint25 -*Returns the remaining number of tokens that `spender` will be allowed to spend on behalf of `owner` through {transferFrom}. This is zero by default. This value changes when {approve} or {transferFrom} are called.* + #### Parameters @@ -36,19 +36,19 @@ function allowance(address owner, address spender) external view returns (uint25 ### approve ```solidity -function approve(address spender, uint256 amount) external nonpayable returns (bool) +function approve(address spender, uint256 value) external nonpayable returns (bool) ``` -*Sets `amount` as the allowance of `spender` over the caller's tokens. Returns a boolean value indicating whether the operation succeeded. IMPORTANT: Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 Emits an {Approval} event.* + #### Parameters | Name | Type | Description | |---|---|---| | spender | address | undefined -| amount | uint256 | undefined +| value | uint256 | undefined #### Returns @@ -59,18 +59,18 @@ function approve(address spender, uint256 amount) external nonpayable returns (b ### balanceOf ```solidity -function balanceOf(address account) external view returns (uint256) +function balanceOf(address who) external view returns (uint256) ``` -*Returns the amount of tokens owned by `account`.* + #### Parameters | Name | Type | Description | |---|---|---| -| account | address | undefined +| who | address | undefined #### Returns @@ -86,7 +86,7 @@ function totalSupply() external view returns (uint256) -*Returns the amount of tokens in existence.* + #### Returns @@ -98,19 +98,19 @@ function totalSupply() external view returns (uint256) ### transfer ```solidity -function transfer(address to, uint256 amount) external nonpayable returns (bool) +function transfer(address to, uint256 value) external nonpayable returns (bool) ``` -*Moves `amount` tokens from the caller's account to `to`. Returns a boolean value indicating whether the operation succeeded. Emits a {Transfer} event.* + #### Parameters | Name | Type | Description | |---|---|---| | to | address | undefined -| amount | uint256 | undefined +| value | uint256 | undefined #### Returns @@ -121,12 +121,12 @@ function transfer(address to, uint256 amount) external nonpayable returns (bool) ### transferFrom ```solidity -function transferFrom(address from, address to, uint256 amount) external nonpayable returns (bool) +function transferFrom(address from, address to, uint256 value) external nonpayable returns (bool) ``` -*Moves `amount` tokens from `from` to `to` using the allowance mechanism. `amount` is then deducted from the caller's allowance. Returns a boolean value indicating whether the operation succeeded. Emits a {Transfer} event.* + #### Parameters @@ -134,7 +134,7 @@ function transferFrom(address from, address to, uint256 amount) external nonpaya |---|---|---| | from | address | undefined | to | address | undefined -| amount | uint256 | undefined +| value | uint256 | undefined #### Returns @@ -154,7 +154,7 @@ event Approval(address indexed owner, address indexed spender, uint256 value) -*Emitted when the allowance of a `spender` for an `owner` is set by a call to {approve}. `value` is the new allowance.* + #### Parameters @@ -172,7 +172,7 @@ event Transfer(address indexed from, address indexed to, uint256 value) -*Emitted when `value` tokens are moved from one account (`from`) to another (`to`). Note that `value` may be zero.* + #### Parameters diff --git a/docs/IMultiwrap.md b/docs/IMultiwrap.md index d02f9e41a..6be406904 100644 --- a/docs/IMultiwrap.md +++ b/docs/IMultiwrap.md @@ -210,28 +210,6 @@ function setRoyaltyInfoForToken(uint256 tokenId, address recipient, uint256 bps) | recipient | address | undefined | bps | uint256 | undefined -### supportsInterface - -```solidity -function supportsInterface(bytes4 interfaceId) external view returns (bool) -``` - - - -*Returns true if this contract implements the interface defined by `interfaceId`. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas.* - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| interfaceId | bytes4 | undefined - -#### Returns - -| Name | Type | Description | -|---|---|---| -| _0 | bool | undefined - ### unwrap ```solidity diff --git a/docs/IPack.md b/docs/IPack.md index 80a223699..4bbe435e3 100644 --- a/docs/IPack.md +++ b/docs/IPack.md @@ -246,28 +246,6 @@ function setRoyaltyInfoForToken(uint256 tokenId, address recipient, uint256 bps) | recipient | address | undefined | bps | uint256 | undefined -### supportsInterface - -```solidity -function supportsInterface(bytes4 interfaceId) external view returns (bool) -``` - - - -*Returns true if this contract implements the interface defined by `interfaceId`. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas.* - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| interfaceId | bytes4 | undefined - -#### Returns - -| Name | Type | Description | -|---|---|---| -| _0 | bool | undefined - ## Events diff --git a/docs/IThirdwebRoyalty.md b/docs/IThirdwebRoyalty.md index ef1017db2..9063a98cb 100644 --- a/docs/IThirdwebRoyalty.md +++ b/docs/IThirdwebRoyalty.md @@ -110,28 +110,6 @@ function setRoyaltyInfoForToken(uint256 tokenId, address recipient, uint256 bps) | recipient | address | undefined | bps | uint256 | undefined -### supportsInterface - -```solidity -function supportsInterface(bytes4 interfaceId) external view returns (bool) -``` - - - -*Returns true if this contract implements the interface defined by `interfaceId`. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas.* - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| interfaceId | bytes4 | undefined - -#### Returns - -| Name | Type | Description | -|---|---|---| -| _0 | bool | undefined - ## Events From 7d427ecaa5c1e09e2ecb65271eae3a280a9b64b1 Mon Sep 17 00:00:00 2001 From: Joaquim Verges Date: Wed, 27 Apr 2022 15:45:38 -0700 Subject: [PATCH 2/2] run prettier --- contracts/Pack.sol | 7 +- contracts/eip/ERC1155.sol | 3 +- contracts/eip/ERC1155Enumerable.sol | 16 ++ contracts/eip/ERC1155Metadata.sol | 15 ++ contracts/eip/ERC20.sol | 2 +- contracts/eip/ERC20Metadata.sol | 14 ++ contracts/eip/ERC721.sol | 2 +- contracts/eip/ERC721Enumerable.sol | 2 +- contracts/eip/ERC721Metadata.sol | 2 +- docs/ERC1155.md | 219 ++++++++++++++++++++++++++++ docs/ERC1155Enumerable.md | 54 +++++++ docs/ERC1155Metadata.md | 37 +++++ docs/ERC20.md | 186 +++++++++++++++++++++++ docs/ERC20Metadata.md | 66 +++++++++ docs/IERC1155.md | 144 ++++++++++-------- docs/IERC20.md | 36 ++--- 16 files changed, 714 insertions(+), 91 deletions(-) create mode 100644 contracts/eip/ERC1155Enumerable.sol create mode 100644 contracts/eip/ERC1155Metadata.sol create mode 100644 contracts/eip/ERC20Metadata.sol create mode 100644 docs/ERC1155.md create mode 100644 docs/ERC1155Enumerable.md create mode 100644 docs/ERC1155Metadata.md create mode 100644 docs/ERC20.md create mode 100644 docs/ERC20Metadata.md diff --git a/contracts/Pack.sol b/contracts/Pack.sol index 7724af957..2c98be7e6 100644 --- a/contracts/Pack.sol +++ b/contracts/Pack.sol @@ -528,12 +528,7 @@ contract Pack is **/ /// @dev See EIP 165 - function supportsInterface(bytes4 interfaceId) - public - view - override(ERC1155PresetUpgradeable) - returns (bool) - { + function supportsInterface(bytes4 interfaceId) public view override(ERC1155PresetUpgradeable) returns (bool) { return super.supportsInterface(interfaceId) || type(IERC2981Upgradeable).interfaceId == interfaceId; } diff --git a/contracts/eip/ERC1155.sol b/contracts/eip/ERC1155.sol index 27a2ae86d..0d80f1707 100644 --- a/contracts/eip/ERC1155.sol +++ b/contracts/eip/ERC1155.sol @@ -6,8 +6,7 @@ pragma solidity ^0.8.0; @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1155.md Note: The ERC-165 identifier for this interface is 0xd9b67a26. */ -/* is ERC165 */ -interface IERC1155 { +interface ERC1155 { /** @dev Either `TransferSingle` or `TransferBatch` MUST emit when tokens are transferred, including zero value transfers as well as minting or burning (see "Safe Transfer Rules" section of the standard). The `_operator` argument MUST be msg.sender. diff --git a/contracts/eip/ERC1155Enumerable.sol b/contracts/eip/ERC1155Enumerable.sol new file mode 100644 index 000000000..8ae819422 --- /dev/null +++ b/contracts/eip/ERC1155Enumerable.sol @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: Apache-2.0 +pragma solidity ^0.8.0; + +/// @title ERC1155Enumarable Non-Fungible Token Standard, optional enumeration extension +/// @dev See https://eips.ethereum.org/EIPS/eip-1155 +interface ERC1155Enumerable { + /// @notice Count NFTs tracked by this contract + /// @return A count of valid NFTs tracked by this contract, where each one of + /// them has an assigned and queryable owner not equal to the zero address + function totalSupply(uint256 id) external view returns (uint256); + + /// @notice Returns the next token ID available for minting + /// @return The token identifier for the `_index`th NFT, + /// (sort order not specified) + function nextTokenIdToMint() external view returns (uint256); +} diff --git a/contracts/eip/ERC1155Metadata.sol b/contracts/eip/ERC1155Metadata.sol new file mode 100644 index 000000000..c0fc731de --- /dev/null +++ b/contracts/eip/ERC1155Metadata.sol @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: Apache-2.0 +pragma solidity ^0.8.0; + +/** + Note: The ERC-165 identifier for this interface is 0x0e89341c. +*/ +interface ERC1155Metadata { + /** + @notice A distinct Uniform Resource Identifier (URI) for a given token. + @dev URIs are defined in RFC 3986. + The URI may point to a JSON file that conforms to the "ERC-1155 Metadata URI JSON Schema". + @return URI string + */ + function uri(uint256 _id) external view returns (string memory); +} diff --git a/contracts/eip/ERC20.sol b/contracts/eip/ERC20.sol index 6350dfc2c..1969d7eda 100644 --- a/contracts/eip/ERC20.sol +++ b/contracts/eip/ERC20.sol @@ -5,7 +5,7 @@ pragma solidity ^0.8.0; * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ -interface IERC20 { +interface ERC20 { function totalSupply() external view returns (uint256); function balanceOf(address who) external view returns (uint256); diff --git a/contracts/eip/ERC20Metadata.sol b/contracts/eip/ERC20Metadata.sol new file mode 100644 index 000000000..c2ed055ca --- /dev/null +++ b/contracts/eip/ERC20Metadata.sol @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: Apache-2.0 +pragma solidity ^0.8.0; + +/** + * @title ERC20Metadata interface + * @dev see https://github.com/ethereum/EIPs/issues/20 + */ +interface ERC20Metadata { + function name() external view returns (string memory); + + function symbol() external view returns (string memory); + + function decimals() external view returns (uint8); +} diff --git a/contracts/eip/ERC721.sol b/contracts/eip/ERC721.sol index d1b8516a1..29ad3f645 100644 --- a/contracts/eip/ERC721.sol +++ b/contracts/eip/ERC721.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -pragma solidity ^0.8.11; +pragma solidity ^0.8.0; /// @title ERC-721 Non-Fungible Token Standard /// @dev See https://eips.ethereum.org/EIPS/eip-721 diff --git a/contracts/eip/ERC721Enumerable.sol b/contracts/eip/ERC721Enumerable.sol index 0d625bdcf..1750a9bb3 100644 --- a/contracts/eip/ERC721Enumerable.sol +++ b/contracts/eip/ERC721Enumerable.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -pragma solidity ^0.8.11; +pragma solidity ^0.8.0; /// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension /// @dev See https://eips.ethereum.org/EIPS/eip-721 diff --git a/contracts/eip/ERC721Metadata.sol b/contracts/eip/ERC721Metadata.sol index 79cd43329..908316f18 100644 --- a/contracts/eip/ERC721Metadata.sol +++ b/contracts/eip/ERC721Metadata.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -pragma solidity ^0.8.11; +pragma solidity ^0.8.0; /// @title ERC-721 Non-Fungible Token Standard, optional metadata extension /// @dev See https://eips.ethereum.org/EIPS/eip-721 diff --git a/docs/ERC1155.md b/docs/ERC1155.md new file mode 100644 index 000000000..f01d1abc0 --- /dev/null +++ b/docs/ERC1155.md @@ -0,0 +1,219 @@ +# ERC1155 + + + +> ERC-1155 Multi Token Standard + + + +*See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1155.md Note: The ERC-165 identifier for this interface is 0xd9b67a26.* + +## Methods + +### balanceOf + +```solidity +function balanceOf(address _owner, uint256 _id) external view returns (uint256) +``` + +Get the balance of an account's Tokens. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _owner | address | The address of the token holder +| _id | uint256 | ID of the Token + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | The _owner's balance of the Token type requested + +### balanceOfBatch + +```solidity +function balanceOfBatch(address[] _owners, uint256[] _ids) external view returns (uint256[]) +``` + +Get the balance of multiple account/token pairs + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _owners | address[] | The addresses of the token holders +| _ids | uint256[] | ID of the Tokens + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256[] | The _owner's balance of the Token types requested (i.e. balance for each (owner, id) pair) + +### isApprovedForAll + +```solidity +function isApprovedForAll(address _owner, address _operator) external view returns (bool) +``` + +Queries the approval status of an operator for a given owner. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _owner | address | The owner of the Tokens +| _operator | address | Address of authorized operator + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | True if the operator is approved, false if not + +### safeBatchTransferFrom + +```solidity +function safeBatchTransferFrom(address _from, address _to, uint256[] _ids, uint256[] _values, bytes _data) external nonpayable +``` + +Transfers `_values` amount(s) of `_ids` from the `_from` address to the `_to` address specified (with safety call). + +*Caller must be approved to manage the tokens being transferred out of the `_from` account (see "Approval" section of the standard). MUST revert if `_to` is the zero address. MUST revert if length of `_ids` is not the same as length of `_values`. MUST revert if any of the balance(s) of the holder(s) for token(s) in `_ids` is lower than the respective amount(s) in `_values` sent to the recipient. MUST revert on any other error. MUST emit `TransferSingle` or `TransferBatch` event(s) such that all the balance changes are reflected (see "Safe Transfer Rules" section of the standard). Balance changes and events MUST follow the ordering of the arrays (_ids[0]/_values[0] before _ids[1]/_values[1], etc). After the above conditions for the transfer(s) in the batch are met, this function MUST check if `_to` is a smart contract (e.g. code size > 0). If so, it MUST call the relevant `ERC1155TokenReceiver` hook(s) on `_to` and act appropriately (see "Safe Transfer Rules" section of the standard).* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _from | address | Source address +| _to | address | Target address +| _ids | uint256[] | IDs of each token type (order and length must match _values array) +| _values | uint256[] | Transfer amounts per token type (order and length must match _ids array) +| _data | bytes | Additional data with no specified format, MUST be sent unaltered in call to the `ERC1155TokenReceiver` hook(s) on `_to` + +### safeTransferFrom + +```solidity +function safeTransferFrom(address _from, address _to, uint256 _id, uint256 _value, bytes _data) external nonpayable +``` + +Transfers `_value` amount of an `_id` from the `_from` address to the `_to` address specified (with safety call). + +*Caller must be approved to manage the tokens being transferred out of the `_from` account (see "Approval" section of the standard). MUST revert if `_to` is the zero address. MUST revert if balance of holder for token `_id` is lower than the `_value` sent. MUST revert on any other error. MUST emit the `TransferSingle` event to reflect the balance change (see "Safe Transfer Rules" section of the standard). After the above conditions are met, this function MUST check if `_to` is a smart contract (e.g. code size > 0). If so, it MUST call `onERC1155Received` on `_to` and act appropriately (see "Safe Transfer Rules" section of the standard).* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _from | address | Source address +| _to | address | Target address +| _id | uint256 | ID of the token type +| _value | uint256 | Transfer amount +| _data | bytes | Additional data with no specified format, MUST be sent unaltered in call to `onERC1155Received` on `_to` + +### setApprovalForAll + +```solidity +function setApprovalForAll(address _operator, bool _approved) external nonpayable +``` + +Enable or disable approval for a third party ("operator") to manage all of the caller's tokens. + +*MUST emit the ApprovalForAll event on success.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _operator | address | Address to add to the set of authorized operators +| _approved | bool | True if the operator is approved, false to revoke approval + + + +## Events + +### ApprovalForAll + +```solidity +event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved) +``` + + + +*MUST emit when approval for a second party/operator address to manage all tokens for an owner address is enabled or disabled (absense of an event assumes disabled).* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _owner `indexed` | address | undefined | +| _operator `indexed` | address | undefined | +| _approved | bool | undefined | + +### TransferBatch + +```solidity +event TransferBatch(address indexed _operator, address indexed _from, address indexed _to, uint256[] _ids, uint256[] _values) +``` + + + +*Either `TransferSingle` or `TransferBatch` MUST emit when tokens are transferred, including zero value transfers as well as minting or burning (see "Safe Transfer Rules" section of the standard). The `_operator` argument MUST be msg.sender. The `_from` argument MUST be the address of the holder whose balance is decreased. The `_to` argument MUST be the address of the recipient whose balance is increased. The `_ids` argument MUST be the list of tokens being transferred. The `_values` argument MUST be the list of number of tokens (matching the list and order of tokens specified in _ids) the holder balance is decreased by and match what the recipient balance is increased by. When minting/creating tokens, the `_from` argument MUST be set to `0x0` (i.e. zero address). When burning/destroying tokens, the `_to` argument MUST be set to `0x0` (i.e. zero address).* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _operator `indexed` | address | undefined | +| _from `indexed` | address | undefined | +| _to `indexed` | address | undefined | +| _ids | uint256[] | undefined | +| _values | uint256[] | undefined | + +### TransferSingle + +```solidity +event TransferSingle(address indexed _operator, address indexed _from, address indexed _to, uint256 _id, uint256 _value) +``` + + + +*Either `TransferSingle` or `TransferBatch` MUST emit when tokens are transferred, including zero value transfers as well as minting or burning (see "Safe Transfer Rules" section of the standard). The `_operator` argument MUST be msg.sender. The `_from` argument MUST be the address of the holder whose balance is decreased. The `_to` argument MUST be the address of the recipient whose balance is increased. The `_id` argument MUST be the token type being transferred. The `_value` argument MUST be the number of tokens the holder balance is decreased by and match what the recipient balance is increased by. When minting/creating tokens, the `_from` argument MUST be set to `0x0` (i.e. zero address). When burning/destroying tokens, the `_to` argument MUST be set to `0x0` (i.e. zero address).* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _operator `indexed` | address | undefined | +| _from `indexed` | address | undefined | +| _to `indexed` | address | undefined | +| _id | uint256 | undefined | +| _value | uint256 | undefined | + +### URI + +```solidity +event URI(string _value, uint256 indexed _id) +``` + + + +*MUST emit when the URI is updated for a token ID. URIs are defined in RFC 3986. The URI MUST point a JSON file that conforms to the "ERC-1155 Metadata URI JSON Schema".* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _value | string | undefined | +| _id `indexed` | uint256 | undefined | + + + diff --git a/docs/ERC1155Enumerable.md b/docs/ERC1155Enumerable.md new file mode 100644 index 000000000..0ad9e81c9 --- /dev/null +++ b/docs/ERC1155Enumerable.md @@ -0,0 +1,54 @@ +# ERC1155Enumerable + + + +> ERC1155Enumarable Non-Fungible Token Standard, optional enumeration extension + + + +*See https://eips.ethereum.org/EIPS/eip-1155* + +## Methods + +### nextTokenIdToMint + +```solidity +function nextTokenIdToMint() external view returns (uint256) +``` + +Returns the next token ID available for minting + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | The token identifier for the `_index`th NFT, (sort order not specified) + +### totalSupply + +```solidity +function totalSupply(uint256 id) external view returns (uint256) +``` + +Count NFTs tracked by this contract + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| id | uint256 | undefined + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | A count of valid NFTs tracked by this contract, where each one of them has an assigned and queryable owner not equal to the zero address + + + + diff --git a/docs/ERC1155Metadata.md b/docs/ERC1155Metadata.md new file mode 100644 index 000000000..fd25bad71 --- /dev/null +++ b/docs/ERC1155Metadata.md @@ -0,0 +1,37 @@ +# ERC1155Metadata + + + + + +Note: The ERC-165 identifier for this interface is 0x0e89341c. + + + +## Methods + +### uri + +```solidity +function uri(uint256 _id) external view returns (string) +``` + +A distinct Uniform Resource Identifier (URI) for a given token. + +*URIs are defined in RFC 3986. The URI may point to a JSON file that conforms to the "ERC-1155 Metadata URI JSON Schema".* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _id | uint256 | undefined + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | string | URI string + + + + diff --git a/docs/ERC20.md b/docs/ERC20.md new file mode 100644 index 000000000..55587c48c --- /dev/null +++ b/docs/ERC20.md @@ -0,0 +1,186 @@ +# ERC20 + + + +> ERC20 interface + + + +*see https://github.com/ethereum/EIPs/issues/20* + +## Methods + +### allowance + +```solidity +function allowance(address owner, address spender) external view returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| owner | address | undefined +| spender | address | undefined + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined + +### approve + +```solidity +function approve(address spender, uint256 value) external nonpayable returns (bool) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| spender | address | undefined +| value | uint256 | undefined + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined + +### balanceOf + +```solidity +function balanceOf(address who) external view returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| who | address | undefined + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined + +### totalSupply + +```solidity +function totalSupply() external view returns (uint256) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined + +### transfer + +```solidity +function transfer(address to, uint256 value) external nonpayable returns (bool) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| to | address | undefined +| value | uint256 | undefined + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined + +### transferFrom + +```solidity +function transferFrom(address from, address to, uint256 value) external nonpayable returns (bool) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| from | address | undefined +| to | address | undefined +| value | uint256 | undefined + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined + + + +## Events + +### Approval + +```solidity +event Approval(address indexed owner, address indexed spender, uint256 value) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| owner `indexed` | address | undefined | +| spender `indexed` | address | undefined | +| value | uint256 | undefined | + +### Transfer + +```solidity +event Transfer(address indexed from, address indexed to, uint256 value) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| from `indexed` | address | undefined | +| to `indexed` | address | undefined | +| value | uint256 | undefined | + + + diff --git a/docs/ERC20Metadata.md b/docs/ERC20Metadata.md new file mode 100644 index 000000000..4bf91cd20 --- /dev/null +++ b/docs/ERC20Metadata.md @@ -0,0 +1,66 @@ +# ERC20Metadata + + + +> ERC20Metadata interface + + + +*see https://github.com/ethereum/EIPs/issues/20* + +## Methods + +### decimals + +```solidity +function decimals() external view returns (uint8) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint8 | undefined + +### name + +```solidity +function name() external view returns (string) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | string | undefined + +### symbol + +```solidity +function symbol() external view returns (string) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | string | undefined + + + + diff --git a/docs/IERC1155.md b/docs/IERC1155.md index 32ca592ae..167498bf4 100644 --- a/docs/IERC1155.md +++ b/docs/IERC1155.md @@ -2,139 +2,161 @@ -> ERC-1155 Multi Token Standard -*See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1155.md Note: The ERC-165 identifier for this interface is 0xd9b67a26.* + +*Required interface of an ERC1155 compliant contract, as defined in the https://eips.ethereum.org/EIPS/eip-1155[EIP]. _Available since v3.1._* ## Methods ### balanceOf ```solidity -function balanceOf(address _owner, uint256 _id) external view returns (uint256) +function balanceOf(address account, uint256 id) external view returns (uint256) ``` -Get the balance of an account's Tokens. +*Returns the amount of tokens of token type `id` owned by `account`. Requirements: - `account` cannot be the zero address.* #### Parameters | Name | Type | Description | |---|---|---| -| _owner | address | The address of the token holder -| _id | uint256 | ID of the Token +| account | address | undefined +| id | uint256 | undefined #### Returns | Name | Type | Description | |---|---|---| -| _0 | uint256 | The _owner's balance of the Token type requested +| _0 | uint256 | undefined ### balanceOfBatch ```solidity -function balanceOfBatch(address[] _owners, uint256[] _ids) external view returns (uint256[]) +function balanceOfBatch(address[] accounts, uint256[] ids) external view returns (uint256[]) ``` -Get the balance of multiple account/token pairs +*xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}. Requirements: - `accounts` and `ids` must have the same length.* #### Parameters | Name | Type | Description | |---|---|---| -| _owners | address[] | The addresses of the token holders -| _ids | uint256[] | ID of the Tokens +| accounts | address[] | undefined +| ids | uint256[] | undefined #### Returns | Name | Type | Description | |---|---|---| -| _0 | uint256[] | The _owner's balance of the Token types requested (i.e. balance for each (owner, id) pair) +| _0 | uint256[] | undefined ### isApprovedForAll ```solidity -function isApprovedForAll(address _owner, address _operator) external view returns (bool) +function isApprovedForAll(address account, address operator) external view returns (bool) ``` -Queries the approval status of an operator for a given owner. +*Returns true if `operator` is approved to transfer ``account``'s tokens. See {setApprovalForAll}.* #### Parameters | Name | Type | Description | |---|---|---| -| _owner | address | The owner of the Tokens -| _operator | address | Address of authorized operator +| account | address | undefined +| operator | address | undefined #### Returns | Name | Type | Description | |---|---|---| -| _0 | bool | True if the operator is approved, false if not +| _0 | bool | undefined ### safeBatchTransferFrom ```solidity -function safeBatchTransferFrom(address _from, address _to, uint256[] _ids, uint256[] _values, bytes _data) external nonpayable +function safeBatchTransferFrom(address from, address to, uint256[] ids, uint256[] amounts, bytes data) external nonpayable ``` -Transfers `_values` amount(s) of `_ids` from the `_from` address to the `_to` address specified (with safety call). -*Caller must be approved to manage the tokens being transferred out of the `_from` account (see "Approval" section of the standard). MUST revert if `_to` is the zero address. MUST revert if length of `_ids` is not the same as length of `_values`. MUST revert if any of the balance(s) of the holder(s) for token(s) in `_ids` is lower than the respective amount(s) in `_values` sent to the recipient. MUST revert on any other error. MUST emit `TransferSingle` or `TransferBatch` event(s) such that all the balance changes are reflected (see "Safe Transfer Rules" section of the standard). Balance changes and events MUST follow the ordering of the arrays (_ids[0]/_values[0] before _ids[1]/_values[1], etc). After the above conditions for the transfer(s) in the batch are met, this function MUST check if `_to` is a smart contract (e.g. code size > 0). If so, it MUST call the relevant `ERC1155TokenReceiver` hook(s) on `_to` and act appropriately (see "Safe Transfer Rules" section of the standard).* + +*xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. Emits a {TransferBatch} event. Requirements: - `ids` and `amounts` must have the same length. - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the acceptance magic value.* #### Parameters | Name | Type | Description | |---|---|---| -| _from | address | Source address -| _to | address | Target address -| _ids | uint256[] | IDs of each token type (order and length must match _values array) -| _values | uint256[] | Transfer amounts per token type (order and length must match _ids array) -| _data | bytes | Additional data with no specified format, MUST be sent unaltered in call to the `ERC1155TokenReceiver` hook(s) on `_to` +| from | address | undefined +| to | address | undefined +| ids | uint256[] | undefined +| amounts | uint256[] | undefined +| data | bytes | undefined ### safeTransferFrom ```solidity -function safeTransferFrom(address _from, address _to, uint256 _id, uint256 _value, bytes _data) external nonpayable +function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes data) external nonpayable ``` -Transfers `_value` amount of an `_id` from the `_from` address to the `_to` address specified (with safety call). -*Caller must be approved to manage the tokens being transferred out of the `_from` account (see "Approval" section of the standard). MUST revert if `_to` is the zero address. MUST revert if balance of holder for token `_id` is lower than the `_value` sent. MUST revert on any other error. MUST emit the `TransferSingle` event to reflect the balance change (see "Safe Transfer Rules" section of the standard). After the above conditions are met, this function MUST check if `_to` is a smart contract (e.g. code size > 0). If so, it MUST call `onERC1155Received` on `_to` and act appropriately (see "Safe Transfer Rules" section of the standard).* + +*Transfers `amount` tokens of token type `id` from `from` to `to`. Emits a {TransferSingle} event. Requirements: - `to` cannot be the zero address. - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}. - `from` must have a balance of tokens of type `id` of at least `amount`. - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the acceptance magic value.* #### Parameters | Name | Type | Description | |---|---|---| -| _from | address | Source address -| _to | address | Target address -| _id | uint256 | ID of the token type -| _value | uint256 | Transfer amount -| _data | bytes | Additional data with no specified format, MUST be sent unaltered in call to `onERC1155Received` on `_to` +| from | address | undefined +| to | address | undefined +| id | uint256 | undefined +| amount | uint256 | undefined +| data | bytes | undefined ### setApprovalForAll ```solidity -function setApprovalForAll(address _operator, bool _approved) external nonpayable +function setApprovalForAll(address operator, bool approved) external nonpayable ``` -Enable or disable approval for a third party ("operator") to manage all of the caller's tokens. -*MUST emit the ApprovalForAll event on success.* + +*Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, Emits an {ApprovalForAll} event. Requirements: - `operator` cannot be the caller.* #### Parameters | Name | Type | Description | |---|---|---| -| _operator | address | Address to add to the set of authorized operators -| _approved | bool | True if the operator is approved, false to revoke approval +| operator | address | undefined +| approved | bool | undefined + +### supportsInterface + +```solidity +function supportsInterface(bytes4 interfaceId) external view returns (bool) +``` + + + +*Returns true if this contract implements the interface defined by `interfaceId`. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| interfaceId | bytes4 | undefined + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined @@ -143,77 +165,77 @@ Enable or disable approval for a third party ("operator") to manage al ### ApprovalForAll ```solidity -event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved) +event ApprovalForAll(address indexed account, address indexed operator, bool approved) ``` -*MUST emit when approval for a second party/operator address to manage all tokens for an owner address is enabled or disabled (absense of an event assumes disabled).* +*Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to `approved`.* #### Parameters | Name | Type | Description | |---|---|---| -| _owner `indexed` | address | undefined | -| _operator `indexed` | address | undefined | -| _approved | bool | undefined | +| account `indexed` | address | undefined | +| operator `indexed` | address | undefined | +| approved | bool | undefined | ### TransferBatch ```solidity -event TransferBatch(address indexed _operator, address indexed _from, address indexed _to, uint256[] _ids, uint256[] _values) +event TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values) ``` -*Either `TransferSingle` or `TransferBatch` MUST emit when tokens are transferred, including zero value transfers as well as minting or burning (see "Safe Transfer Rules" section of the standard). The `_operator` argument MUST be msg.sender. The `_from` argument MUST be the address of the holder whose balance is decreased. The `_to` argument MUST be the address of the recipient whose balance is increased. The `_ids` argument MUST be the list of tokens being transferred. The `_values` argument MUST be the list of number of tokens (matching the list and order of tokens specified in _ids) the holder balance is decreased by and match what the recipient balance is increased by. When minting/creating tokens, the `_from` argument MUST be set to `0x0` (i.e. zero address). When burning/destroying tokens, the `_to` argument MUST be set to `0x0` (i.e. zero address).* +*Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all transfers.* #### Parameters | Name | Type | Description | |---|---|---| -| _operator `indexed` | address | undefined | -| _from `indexed` | address | undefined | -| _to `indexed` | address | undefined | -| _ids | uint256[] | undefined | -| _values | uint256[] | undefined | +| operator `indexed` | address | undefined | +| from `indexed` | address | undefined | +| to `indexed` | address | undefined | +| ids | uint256[] | undefined | +| values | uint256[] | undefined | ### TransferSingle ```solidity -event TransferSingle(address indexed _operator, address indexed _from, address indexed _to, uint256 _id, uint256 _value) +event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value) ``` -*Either `TransferSingle` or `TransferBatch` MUST emit when tokens are transferred, including zero value transfers as well as minting or burning (see "Safe Transfer Rules" section of the standard). The `_operator` argument MUST be msg.sender. The `_from` argument MUST be the address of the holder whose balance is decreased. The `_to` argument MUST be the address of the recipient whose balance is increased. The `_id` argument MUST be the token type being transferred. The `_value` argument MUST be the number of tokens the holder balance is decreased by and match what the recipient balance is increased by. When minting/creating tokens, the `_from` argument MUST be set to `0x0` (i.e. zero address). When burning/destroying tokens, the `_to` argument MUST be set to `0x0` (i.e. zero address).* +*Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.* #### Parameters | Name | Type | Description | |---|---|---| -| _operator `indexed` | address | undefined | -| _from `indexed` | address | undefined | -| _to `indexed` | address | undefined | -| _id | uint256 | undefined | -| _value | uint256 | undefined | +| operator `indexed` | address | undefined | +| from `indexed` | address | undefined | +| to `indexed` | address | undefined | +| id | uint256 | undefined | +| value | uint256 | undefined | ### URI ```solidity -event URI(string _value, uint256 indexed _id) +event URI(string value, uint256 indexed id) ``` -*MUST emit when the URI is updated for a token ID. URIs are defined in RFC 3986. The URI MUST point a JSON file that conforms to the "ERC-1155 Metadata URI JSON Schema".* +*Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI. If an {URI} event was emitted for `id`, the standard https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value returned by {IERC1155MetadataURI-uri}.* #### Parameters | Name | Type | Description | |---|---|---| -| _value | string | undefined | -| _id `indexed` | uint256 | undefined | +| value | string | undefined | +| id `indexed` | uint256 | undefined | diff --git a/docs/IERC20.md b/docs/IERC20.md index da676f34b..3b2101125 100644 --- a/docs/IERC20.md +++ b/docs/IERC20.md @@ -2,11 +2,11 @@ -> ERC20 interface -*see https://github.com/ethereum/EIPs/issues/20* + +*Interface of the ERC20 standard as defined in the EIP.* ## Methods @@ -18,7 +18,7 @@ function allowance(address owner, address spender) external view returns (uint25 - +*Returns the remaining number of tokens that `spender` will be allowed to spend on behalf of `owner` through {transferFrom}. This is zero by default. This value changes when {approve} or {transferFrom} are called.* #### Parameters @@ -36,19 +36,19 @@ function allowance(address owner, address spender) external view returns (uint25 ### approve ```solidity -function approve(address spender, uint256 value) external nonpayable returns (bool) +function approve(address spender, uint256 amount) external nonpayable returns (bool) ``` - +*Sets `amount` as the allowance of `spender` over the caller's tokens. Returns a boolean value indicating whether the operation succeeded. IMPORTANT: Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 Emits an {Approval} event.* #### Parameters | Name | Type | Description | |---|---|---| | spender | address | undefined -| value | uint256 | undefined +| amount | uint256 | undefined #### Returns @@ -59,18 +59,18 @@ function approve(address spender, uint256 value) external nonpayable returns (bo ### balanceOf ```solidity -function balanceOf(address who) external view returns (uint256) +function balanceOf(address account) external view returns (uint256) ``` - +*Returns the amount of tokens owned by `account`.* #### Parameters | Name | Type | Description | |---|---|---| -| who | address | undefined +| account | address | undefined #### Returns @@ -86,7 +86,7 @@ function totalSupply() external view returns (uint256) - +*Returns the amount of tokens in existence.* #### Returns @@ -98,19 +98,19 @@ function totalSupply() external view returns (uint256) ### transfer ```solidity -function transfer(address to, uint256 value) external nonpayable returns (bool) +function transfer(address to, uint256 amount) external nonpayable returns (bool) ``` - +*Moves `amount` tokens from the caller's account to `to`. Returns a boolean value indicating whether the operation succeeded. Emits a {Transfer} event.* #### Parameters | Name | Type | Description | |---|---|---| | to | address | undefined -| value | uint256 | undefined +| amount | uint256 | undefined #### Returns @@ -121,12 +121,12 @@ function transfer(address to, uint256 value) external nonpayable returns (bool) ### transferFrom ```solidity -function transferFrom(address from, address to, uint256 value) external nonpayable returns (bool) +function transferFrom(address from, address to, uint256 amount) external nonpayable returns (bool) ``` - +*Moves `amount` tokens from `from` to `to` using the allowance mechanism. `amount` is then deducted from the caller's allowance. Returns a boolean value indicating whether the operation succeeded. Emits a {Transfer} event.* #### Parameters @@ -134,7 +134,7 @@ function transferFrom(address from, address to, uint256 value) external nonpayab |---|---|---| | from | address | undefined | to | address | undefined -| value | uint256 | undefined +| amount | uint256 | undefined #### Returns @@ -154,7 +154,7 @@ event Approval(address indexed owner, address indexed spender, uint256 value) - +*Emitted when the allowance of a `spender` for an `owner` is set by a call to {approve}. `value` is the new allowance.* #### Parameters @@ -172,7 +172,7 @@ event Transfer(address indexed from, address indexed to, uint256 value) - +*Emitted when `value` tokens are moved from one account (`from`) to another (`to`). Note that `value` may be zero.* #### Parameters