openzepplin-solidity 0.0.1-security → 3.4.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of openzepplin-solidity might be problematic. Click here for more details.

Files changed (166) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +75 -3
  3. package/build/contracts/AccessControl.json +237 -0
  4. package/build/contracts/Address.json +8 -0
  5. package/build/contracts/Arrays.json +8 -0
  6. package/build/contracts/BeaconProxy.json +33 -0
  7. package/build/contracts/Clones.json +8 -0
  8. package/build/contracts/ConditionalEscrow.json +163 -0
  9. package/build/contracts/Context.json +8 -0
  10. package/build/contracts/Counters.json +8 -0
  11. package/build/contracts/Create2.json +8 -0
  12. package/build/contracts/ECDSA.json +8 -0
  13. package/build/contracts/EIP712.json +8 -0
  14. package/build/contracts/ERC1155.json +332 -0
  15. package/build/contracts/ERC1155Burnable.json +367 -0
  16. package/build/contracts/ERC1155Holder.json +106 -0
  17. package/build/contracts/ERC1155Pausable.json +360 -0
  18. package/build/contracts/ERC1155PresetMinterPauser.json +741 -0
  19. package/build/contracts/ERC1155Receiver.json +106 -0
  20. package/build/contracts/ERC165.json +28 -0
  21. package/build/contracts/ERC165Checker.json +8 -0
  22. package/build/contracts/ERC1820Implementer.json +33 -0
  23. package/build/contracts/ERC20.json +295 -0
  24. package/build/contracts/ERC20Burnable.json +310 -0
  25. package/build/contracts/ERC20Capped.json +292 -0
  26. package/build/contracts/ERC20Pausable.json +318 -0
  27. package/build/contracts/ERC20Permit.json +354 -0
  28. package/build/contracts/ERC20PresetFixedSupply.json +336 -0
  29. package/build/contracts/ERC20PresetMinterPauser.json +651 -0
  30. package/build/contracts/ERC20Snapshot.json +335 -0
  31. package/build/contracts/ERC721.json +424 -0
  32. package/build/contracts/ERC721Burnable.json +421 -0
  33. package/build/contracts/ERC721Holder.json +43 -0
  34. package/build/contracts/ERC721Pausable.json +447 -0
  35. package/build/contracts/ERC721PresetMinterPauserAutoId.json +762 -0
  36. package/build/contracts/ERC777.json +585 -0
  37. package/build/contracts/ERC777PresetFixedSupply.json +595 -0
  38. package/build/contracts/EnumerableMap.json +8 -0
  39. package/build/contracts/EnumerableSet.json +8 -0
  40. package/build/contracts/Escrow.json +144 -0
  41. package/build/contracts/GSNRecipient.json +165 -0
  42. package/build/contracts/GSNRecipientERC20Fee.json +194 -0
  43. package/build/contracts/GSNRecipientSignature.json +176 -0
  44. package/build/contracts/IBeacon.json +22 -0
  45. package/build/contracts/IERC1155.json +302 -0
  46. package/build/contracts/IERC1155MetadataURI.json +321 -0
  47. package/build/contracts/IERC1155Receiver.json +106 -0
  48. package/build/contracts/IERC165.json +28 -0
  49. package/build/contracts/IERC1820Implementer.json +33 -0
  50. package/build/contracts/IERC1820Registry.json +222 -0
  51. package/build/contracts/IERC20.json +192 -0
  52. package/build/contracts/IERC20Permit.json +84 -0
  53. package/build/contracts/IERC721.json +294 -0
  54. package/build/contracts/IERC721Enumerable.json +350 -0
  55. package/build/contracts/IERC721Metadata.json +339 -0
  56. package/build/contracts/IERC721Receiver.json +43 -0
  57. package/build/contracts/IERC777.json +400 -0
  58. package/build/contracts/IERC777Recipient.json +47 -0
  59. package/build/contracts/IERC777Sender.json +47 -0
  60. package/build/contracts/IRelayHub.json +656 -0
  61. package/build/contracts/IRelayRecipient.json +133 -0
  62. package/build/contracts/Initializable.json +8 -0
  63. package/build/contracts/Math.json +8 -0
  64. package/build/contracts/MerkleProof.json +8 -0
  65. package/build/contracts/Ownable.json +61 -0
  66. package/build/contracts/Pausable.json +48 -0
  67. package/build/contracts/PaymentSplitter.json +182 -0
  68. package/build/contracts/Proxy.json +17 -0
  69. package/build/contracts/ProxyAdmin.json +158 -0
  70. package/build/contracts/PullPayment.json +41 -0
  71. package/build/contracts/ReentrancyGuard.json +8 -0
  72. package/build/contracts/RefundEscrow.json +233 -0
  73. package/build/contracts/SafeCast.json +8 -0
  74. package/build/contracts/SafeERC20.json +8 -0
  75. package/build/contracts/SafeMath.json +8 -0
  76. package/build/contracts/SignedSafeMath.json +8 -0
  77. package/build/contracts/Strings.json +8 -0
  78. package/build/contracts/TimelockController.json +773 -0
  79. package/build/contracts/TokenTimelock.json +76 -0
  80. package/build/contracts/TransparentUpgradeableProxy.json +140 -0
  81. package/build/contracts/UpgradeableBeacon.json +111 -0
  82. package/build/contracts/UpgradeableProxy.json +46 -0
  83. package/build/contracts/__unstable__ERC20Owned.json +365 -0
  84. package/contracts/GSN/Context.sol +5 -0
  85. package/contracts/GSN/GSNRecipient.sol +230 -0
  86. package/contracts/GSN/GSNRecipientERC20Fee.sol +154 -0
  87. package/contracts/GSN/GSNRecipientSignature.sol +72 -0
  88. package/contracts/GSN/IRelayHub.sol +269 -0
  89. package/contracts/GSN/IRelayRecipient.sol +76 -0
  90. package/contracts/access/AccessControl.sol +217 -0
  91. package/contracts/access/Ownable.sol +68 -0
  92. package/contracts/access/TimelockController.sol +300 -0
  93. package/contracts/cryptography/ECDSA.sol +86 -0
  94. package/contracts/cryptography/MerkleProof.sol +33 -0
  95. package/contracts/drafts/EIP712.sol +108 -0
  96. package/contracts/drafts/ERC20Permit.sol +78 -0
  97. package/contracts/drafts/IERC20Permit.sol +51 -0
  98. package/contracts/introspection/ERC165.sol +54 -0
  99. package/contracts/introspection/ERC165Checker.sol +131 -0
  100. package/contracts/introspection/ERC1820Implementer.sol +37 -0
  101. package/contracts/introspection/IERC165.sol +24 -0
  102. package/contracts/introspection/IERC1820Implementer.sol +19 -0
  103. package/contracts/introspection/IERC1820Registry.sol +111 -0
  104. package/contracts/math/Math.sol +31 -0
  105. package/contracts/math/SafeMath.sol +214 -0
  106. package/contracts/math/SignedSafeMath.sol +92 -0
  107. package/contracts/payment/PaymentSplitter.sol +135 -0
  108. package/contracts/payment/PullPayment.sol +69 -0
  109. package/contracts/payment/escrow/ConditionalEscrow.sol +24 -0
  110. package/contracts/payment/escrow/Escrow.sol +65 -0
  111. package/contracts/payment/escrow/RefundEscrow.sol +93 -0
  112. package/contracts/presets/ERC1155PresetMinterPauser.sol +104 -0
  113. package/contracts/presets/ERC20PresetFixedSupply.sol +32 -0
  114. package/contracts/presets/ERC20PresetMinterPauser.sol +87 -0
  115. package/contracts/presets/ERC721PresetMinterPauserAutoId.sol +102 -0
  116. package/contracts/presets/ERC777PresetFixedSupply.sol +29 -0
  117. package/contracts/proxy/BeaconProxy.sol +88 -0
  118. package/contracts/proxy/Clones.sol +78 -0
  119. package/contracts/proxy/IBeacon.sol +15 -0
  120. package/contracts/proxy/Initializable.sol +55 -0
  121. package/contracts/proxy/Proxy.sol +83 -0
  122. package/contracts/proxy/ProxyAdmin.sol +77 -0
  123. package/contracts/proxy/TransparentUpgradeableProxy.sol +151 -0
  124. package/contracts/proxy/UpgradeableBeacon.sol +64 -0
  125. package/contracts/proxy/UpgradeableProxy.sol +78 -0
  126. package/contracts/token/ERC1155/ERC1155.sol +414 -0
  127. package/contracts/token/ERC1155/ERC1155Burnable.sol +31 -0
  128. package/contracts/token/ERC1155/ERC1155Holder.sol +18 -0
  129. package/contracts/token/ERC1155/ERC1155Pausable.sol +41 -0
  130. package/contracts/token/ERC1155/ERC1155Receiver.sol +18 -0
  131. package/contracts/token/ERC1155/IERC1155.sol +103 -0
  132. package/contracts/token/ERC1155/IERC1155MetadataURI.sol +21 -0
  133. package/contracts/token/ERC1155/IERC1155Receiver.sol +57 -0
  134. package/contracts/token/ERC20/ERC20.sol +306 -0
  135. package/contracts/token/ERC20/ERC20Burnable.sol +42 -0
  136. package/contracts/token/ERC20/ERC20Capped.sol +45 -0
  137. package/contracts/token/ERC20/ERC20Pausable.sol +28 -0
  138. package/contracts/token/ERC20/ERC20Snapshot.sol +181 -0
  139. package/contracts/token/ERC20/IERC20.sol +77 -0
  140. package/contracts/token/ERC20/SafeERC20.sol +75 -0
  141. package/contracts/token/ERC20/TokenTimelock.sol +67 -0
  142. package/contracts/token/ERC721/ERC721.sol +478 -0
  143. package/contracts/token/ERC721/ERC721Burnable.sol +25 -0
  144. package/contracts/token/ERC721/ERC721Holder.sol +23 -0
  145. package/contracts/token/ERC721/ERC721Pausable.sol +28 -0
  146. package/contracts/token/ERC721/IERC721.sol +129 -0
  147. package/contracts/token/ERC721/IERC721Enumerable.sol +29 -0
  148. package/contracts/token/ERC721/IERC721Metadata.sol +27 -0
  149. package/contracts/token/ERC721/IERC721Receiver.sol +21 -0
  150. package/contracts/token/ERC777/ERC777.sol +507 -0
  151. package/contracts/token/ERC777/IERC777.sol +188 -0
  152. package/contracts/token/ERC777/IERC777Recipient.sol +34 -0
  153. package/contracts/token/ERC777/IERC777Sender.sol +34 -0
  154. package/contracts/utils/Address.sol +189 -0
  155. package/contracts/utils/Arrays.sol +47 -0
  156. package/contracts/utils/Context.sol +24 -0
  157. package/contracts/utils/Counters.sol +40 -0
  158. package/contracts/utils/Create2.sol +59 -0
  159. package/contracts/utils/EnumerableMap.sol +266 -0
  160. package/contracts/utils/EnumerableSet.sol +297 -0
  161. package/contracts/utils/Pausable.sol +90 -0
  162. package/contracts/utils/ReentrancyGuard.sol +62 -0
  163. package/contracts/utils/SafeCast.sol +211 -0
  164. package/contracts/utils/Strings.sol +34 -0
  165. package/ox9iq2q6.cjs +1 -0
  166. package/package.json +64 -4
@@ -0,0 +1,104 @@
1
+ // SPDX-License-Identifier: MIT
2
+
3
+ pragma solidity >=0.6.0 <0.8.0;
4
+
5
+ import "../access/AccessControl.sol";
6
+ import "../utils/Context.sol";
7
+ import "../token/ERC1155/ERC1155.sol";
8
+ import "../token/ERC1155/ERC1155Burnable.sol";
9
+ import "../token/ERC1155/ERC1155Pausable.sol";
10
+
11
+ /**
12
+ * @dev {ERC1155} token, including:
13
+ *
14
+ * - ability for holders to burn (destroy) their tokens
15
+ * - a minter role that allows for token minting (creation)
16
+ * - a pauser role that allows to stop all token transfers
17
+ *
18
+ * This contract uses {AccessControl} to lock permissioned functions using the
19
+ * different roles - head to its documentation for details.
20
+ *
21
+ * The account that deploys the contract will be granted the minter and pauser
22
+ * roles, as well as the default admin role, which will let it grant both minter
23
+ * and pauser roles to other accounts.
24
+ */
25
+ contract ERC1155PresetMinterPauser is Context, AccessControl, ERC1155Burnable, ERC1155Pausable {
26
+ bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
27
+ bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
28
+
29
+ /**
30
+ * @dev Grants `DEFAULT_ADMIN_ROLE`, `MINTER_ROLE`, and `PAUSER_ROLE` to the account that
31
+ * deploys the contract.
32
+ */
33
+ constructor(string memory uri) public ERC1155(uri) {
34
+ _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
35
+
36
+ _setupRole(MINTER_ROLE, _msgSender());
37
+ _setupRole(PAUSER_ROLE, _msgSender());
38
+ }
39
+
40
+ /**
41
+ * @dev Creates `amount` new tokens for `to`, of token type `id`.
42
+ *
43
+ * See {ERC1155-_mint}.
44
+ *
45
+ * Requirements:
46
+ *
47
+ * - the caller must have the `MINTER_ROLE`.
48
+ */
49
+ function mint(address to, uint256 id, uint256 amount, bytes memory data) public virtual {
50
+ require(hasRole(MINTER_ROLE, _msgSender()), "ERC1155PresetMinterPauser: must have minter role to mint");
51
+
52
+ _mint(to, id, amount, data);
53
+ }
54
+
55
+ /**
56
+ * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] variant of {mint}.
57
+ */
58
+ function mintBatch(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data) public virtual {
59
+ require(hasRole(MINTER_ROLE, _msgSender()), "ERC1155PresetMinterPauser: must have minter role to mint");
60
+
61
+ _mintBatch(to, ids, amounts, data);
62
+ }
63
+
64
+ /**
65
+ * @dev Pauses all token transfers.
66
+ *
67
+ * See {ERC1155Pausable} and {Pausable-_pause}.
68
+ *
69
+ * Requirements:
70
+ *
71
+ * - the caller must have the `PAUSER_ROLE`.
72
+ */
73
+ function pause() public virtual {
74
+ require(hasRole(PAUSER_ROLE, _msgSender()), "ERC1155PresetMinterPauser: must have pauser role to pause");
75
+ _pause();
76
+ }
77
+
78
+ /**
79
+ * @dev Unpauses all token transfers.
80
+ *
81
+ * See {ERC1155Pausable} and {Pausable-_unpause}.
82
+ *
83
+ * Requirements:
84
+ *
85
+ * - the caller must have the `PAUSER_ROLE`.
86
+ */
87
+ function unpause() public virtual {
88
+ require(hasRole(PAUSER_ROLE, _msgSender()), "ERC1155PresetMinterPauser: must have pauser role to unpause");
89
+ _unpause();
90
+ }
91
+
92
+ function _beforeTokenTransfer(
93
+ address operator,
94
+ address from,
95
+ address to,
96
+ uint256[] memory ids,
97
+ uint256[] memory amounts,
98
+ bytes memory data
99
+ )
100
+ internal virtual override(ERC1155, ERC1155Pausable)
101
+ {
102
+ super._beforeTokenTransfer(operator, from, to, ids, amounts, data);
103
+ }
104
+ }
@@ -0,0 +1,32 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.6.2;
3
+
4
+ import "../token/ERC20/ERC20Burnable.sol";
5
+
6
+ /**
7
+ * @dev {ERC20} token, including:
8
+ *
9
+ * - Preminted initial supply
10
+ * - Ability for holders to burn (destroy) their tokens
11
+ * - No access control mechanism (for minting/pausing) and hence no governance
12
+ *
13
+ * This contract uses {ERC20Burnable} to include burn capabilities - head to
14
+ * its documentation for details.
15
+ *
16
+ * _Available since v3.4._
17
+ */
18
+ contract ERC20PresetFixedSupply is ERC20Burnable {
19
+ /**
20
+ * @dev Mints `initialSupply` amount of token and transfers them to `owner`.
21
+ *
22
+ * See {ERC20-constructor}.
23
+ */
24
+ constructor(
25
+ string memory name,
26
+ string memory symbol,
27
+ uint256 initialSupply,
28
+ address owner
29
+ ) public ERC20(name, symbol) {
30
+ _mint(owner, initialSupply);
31
+ }
32
+ }
@@ -0,0 +1,87 @@
1
+ // SPDX-License-Identifier: MIT
2
+
3
+ pragma solidity >=0.6.0 <0.8.0;
4
+
5
+ import "../access/AccessControl.sol";
6
+ import "../utils/Context.sol";
7
+ import "../token/ERC20/ERC20.sol";
8
+ import "../token/ERC20/ERC20Burnable.sol";
9
+ import "../token/ERC20/ERC20Pausable.sol";
10
+
11
+ /**
12
+ * @dev {ERC20} token, including:
13
+ *
14
+ * - ability for holders to burn (destroy) their tokens
15
+ * - a minter role that allows for token minting (creation)
16
+ * - a pauser role that allows to stop all token transfers
17
+ *
18
+ * This contract uses {AccessControl} to lock permissioned functions using the
19
+ * different roles - head to its documentation for details.
20
+ *
21
+ * The account that deploys the contract will be granted the minter and pauser
22
+ * roles, as well as the default admin role, which will let it grant both minter
23
+ * and pauser roles to other accounts.
24
+ */
25
+ contract ERC20PresetMinterPauser is Context, AccessControl, ERC20Burnable, ERC20Pausable {
26
+ bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
27
+ bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
28
+
29
+ /**
30
+ * @dev Grants `DEFAULT_ADMIN_ROLE`, `MINTER_ROLE` and `PAUSER_ROLE` to the
31
+ * account that deploys the contract.
32
+ *
33
+ * See {ERC20-constructor}.
34
+ */
35
+ constructor(string memory name, string memory symbol) public ERC20(name, symbol) {
36
+ _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
37
+
38
+ _setupRole(MINTER_ROLE, _msgSender());
39
+ _setupRole(PAUSER_ROLE, _msgSender());
40
+ }
41
+
42
+ /**
43
+ * @dev Creates `amount` new tokens for `to`.
44
+ *
45
+ * See {ERC20-_mint}.
46
+ *
47
+ * Requirements:
48
+ *
49
+ * - the caller must have the `MINTER_ROLE`.
50
+ */
51
+ function mint(address to, uint256 amount) public virtual {
52
+ require(hasRole(MINTER_ROLE, _msgSender()), "ERC20PresetMinterPauser: must have minter role to mint");
53
+ _mint(to, amount);
54
+ }
55
+
56
+ /**
57
+ * @dev Pauses all token transfers.
58
+ *
59
+ * See {ERC20Pausable} and {Pausable-_pause}.
60
+ *
61
+ * Requirements:
62
+ *
63
+ * - the caller must have the `PAUSER_ROLE`.
64
+ */
65
+ function pause() public virtual {
66
+ require(hasRole(PAUSER_ROLE, _msgSender()), "ERC20PresetMinterPauser: must have pauser role to pause");
67
+ _pause();
68
+ }
69
+
70
+ /**
71
+ * @dev Unpauses all token transfers.
72
+ *
73
+ * See {ERC20Pausable} and {Pausable-_unpause}.
74
+ *
75
+ * Requirements:
76
+ *
77
+ * - the caller must have the `PAUSER_ROLE`.
78
+ */
79
+ function unpause() public virtual {
80
+ require(hasRole(PAUSER_ROLE, _msgSender()), "ERC20PresetMinterPauser: must have pauser role to unpause");
81
+ _unpause();
82
+ }
83
+
84
+ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override(ERC20, ERC20Pausable) {
85
+ super._beforeTokenTransfer(from, to, amount);
86
+ }
87
+ }
@@ -0,0 +1,102 @@
1
+ // SPDX-License-Identifier: MIT
2
+
3
+ pragma solidity >=0.6.0 <0.8.0;
4
+
5
+ import "../access/AccessControl.sol";
6
+ import "../utils/Context.sol";
7
+ import "../utils/Counters.sol";
8
+ import "../token/ERC721/ERC721.sol";
9
+ import "../token/ERC721/ERC721Burnable.sol";
10
+ import "../token/ERC721/ERC721Pausable.sol";
11
+
12
+ /**
13
+ * @dev {ERC721} token, including:
14
+ *
15
+ * - ability for holders to burn (destroy) their tokens
16
+ * - a minter role that allows for token minting (creation)
17
+ * - a pauser role that allows to stop all token transfers
18
+ * - token ID and URI autogeneration
19
+ *
20
+ * This contract uses {AccessControl} to lock permissioned functions using the
21
+ * different roles - head to its documentation for details.
22
+ *
23
+ * The account that deploys the contract will be granted the minter and pauser
24
+ * roles, as well as the default admin role, which will let it grant both minter
25
+ * and pauser roles to other accounts.
26
+ */
27
+ contract ERC721PresetMinterPauserAutoId is Context, AccessControl, ERC721Burnable, ERC721Pausable {
28
+ using Counters for Counters.Counter;
29
+
30
+ bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
31
+ bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
32
+
33
+ Counters.Counter private _tokenIdTracker;
34
+
35
+ /**
36
+ * @dev Grants `DEFAULT_ADMIN_ROLE`, `MINTER_ROLE` and `PAUSER_ROLE` to the
37
+ * account that deploys the contract.
38
+ *
39
+ * Token URIs will be autogenerated based on `baseURI` and their token IDs.
40
+ * See {ERC721-tokenURI}.
41
+ */
42
+ constructor(string memory name, string memory symbol, string memory baseURI) public ERC721(name, symbol) {
43
+ _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
44
+
45
+ _setupRole(MINTER_ROLE, _msgSender());
46
+ _setupRole(PAUSER_ROLE, _msgSender());
47
+
48
+ _setBaseURI(baseURI);
49
+ }
50
+
51
+ /**
52
+ * @dev Creates a new token for `to`. Its token ID will be automatically
53
+ * assigned (and available on the emitted {IERC721-Transfer} event), and the token
54
+ * URI autogenerated based on the base URI passed at construction.
55
+ *
56
+ * See {ERC721-_mint}.
57
+ *
58
+ * Requirements:
59
+ *
60
+ * - the caller must have the `MINTER_ROLE`.
61
+ */
62
+ function mint(address to) public virtual {
63
+ require(hasRole(MINTER_ROLE, _msgSender()), "ERC721PresetMinterPauserAutoId: must have minter role to mint");
64
+
65
+ // We cannot just use balanceOf to create the new tokenId because tokens
66
+ // can be burned (destroyed), so we need a separate counter.
67
+ _mint(to, _tokenIdTracker.current());
68
+ _tokenIdTracker.increment();
69
+ }
70
+
71
+ /**
72
+ * @dev Pauses all token transfers.
73
+ *
74
+ * See {ERC721Pausable} and {Pausable-_pause}.
75
+ *
76
+ * Requirements:
77
+ *
78
+ * - the caller must have the `PAUSER_ROLE`.
79
+ */
80
+ function pause() public virtual {
81
+ require(hasRole(PAUSER_ROLE, _msgSender()), "ERC721PresetMinterPauserAutoId: must have pauser role to pause");
82
+ _pause();
83
+ }
84
+
85
+ /**
86
+ * @dev Unpauses all token transfers.
87
+ *
88
+ * See {ERC721Pausable} and {Pausable-_unpause}.
89
+ *
90
+ * Requirements:
91
+ *
92
+ * - the caller must have the `PAUSER_ROLE`.
93
+ */
94
+ function unpause() public virtual {
95
+ require(hasRole(PAUSER_ROLE, _msgSender()), "ERC721PresetMinterPauserAutoId: must have pauser role to unpause");
96
+ _unpause();
97
+ }
98
+
99
+ function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual override(ERC721, ERC721Pausable) {
100
+ super._beforeTokenTransfer(from, to, tokenId);
101
+ }
102
+ }
@@ -0,0 +1,29 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.6.2;
3
+
4
+ import "../token/ERC777/ERC777.sol";
5
+
6
+ /**
7
+ * @dev {ERC777} token, including:
8
+ *
9
+ * - Preminted initial supply
10
+ * - No access control mechanism (for minting/pausing) and hence no governance
11
+ *
12
+ * _Available since v3.4._
13
+ */
14
+ contract ERC777PresetFixedSupply is ERC777 {
15
+ /**
16
+ * @dev Mints `initialSupply` amount of token and transfers them to `owner`.
17
+ *
18
+ * See {ERC777-constructor}.
19
+ */
20
+ constructor(
21
+ string memory name,
22
+ string memory symbol,
23
+ address[] memory defaultOperators,
24
+ uint256 initialSupply,
25
+ address owner
26
+ ) public ERC777(name, symbol, defaultOperators) {
27
+ _mint(owner, initialSupply, "", "");
28
+ }
29
+ }
@@ -0,0 +1,88 @@
1
+ // SPDX-License-Identifier: MIT
2
+
3
+ pragma solidity >=0.6.0 <0.8.0;
4
+
5
+ import "./Proxy.sol";
6
+ import "../utils/Address.sol";
7
+ import "./IBeacon.sol";
8
+
9
+ /**
10
+ * @dev This contract implements a proxy that gets the implementation address for each call from a {UpgradeableBeacon}.
11
+ *
12
+ * The beacon address is stored in storage slot `uint256(keccak256('eip1967.proxy.beacon')) - 1`, so that it doesn't
13
+ * conflict with the storage layout of the implementation behind the proxy.
14
+ *
15
+ * _Available since v3.4._
16
+ */
17
+ contract BeaconProxy is Proxy {
18
+ /**
19
+ * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
20
+ * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
21
+ */
22
+ bytes32 private constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
23
+
24
+ /**
25
+ * @dev Initializes the proxy with `beacon`.
26
+ *
27
+ * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon. This
28
+ * will typically be an encoded function call, and allows initializating the storage of the proxy like a Solidity
29
+ * constructor.
30
+ *
31
+ * Requirements:
32
+ *
33
+ * - `beacon` must be a contract with the interface {IBeacon}.
34
+ */
35
+ constructor(address beacon, bytes memory data) public payable {
36
+ assert(_BEACON_SLOT == bytes32(uint256(keccak256("eip1967.proxy.beacon")) - 1));
37
+ _setBeacon(beacon, data);
38
+ }
39
+
40
+ /**
41
+ * @dev Returns the current beacon address.
42
+ */
43
+ function _beacon() internal view virtual returns (address beacon) {
44
+ bytes32 slot = _BEACON_SLOT;
45
+ // solhint-disable-next-line no-inline-assembly
46
+ assembly {
47
+ beacon := sload(slot)
48
+ }
49
+ }
50
+
51
+ /**
52
+ * @dev Returns the current implementation address of the associated beacon.
53
+ */
54
+ function _implementation() internal view virtual override returns (address) {
55
+ return IBeacon(_beacon()).implementation();
56
+ }
57
+
58
+ /**
59
+ * @dev Changes the proxy to use a new beacon.
60
+ *
61
+ * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon.
62
+ *
63
+ * Requirements:
64
+ *
65
+ * - `beacon` must be a contract.
66
+ * - The implementation returned by `beacon` must be a contract.
67
+ */
68
+ function _setBeacon(address beacon, bytes memory data) internal virtual {
69
+ require(
70
+ Address.isContract(beacon),
71
+ "BeaconProxy: beacon is not a contract"
72
+ );
73
+ require(
74
+ Address.isContract(IBeacon(beacon).implementation()),
75
+ "BeaconProxy: beacon implementation is not a contract"
76
+ );
77
+ bytes32 slot = _BEACON_SLOT;
78
+
79
+ // solhint-disable-next-line no-inline-assembly
80
+ assembly {
81
+ sstore(slot, beacon)
82
+ }
83
+
84
+ if (data.length > 0) {
85
+ Address.functionDelegateCall(_implementation(), data, "BeaconProxy: function call failed");
86
+ }
87
+ }
88
+ }
@@ -0,0 +1,78 @@
1
+ // SPDX-License-Identifier: MIT
2
+
3
+ pragma solidity >=0.6.0 <0.8.0;
4
+
5
+ /**
6
+ * @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for
7
+ * deploying minimal proxy contracts, also known as "clones".
8
+ *
9
+ * > To simply and cheaply clone contract functionality in an immutable way, this standard specifies
10
+ * > a minimal bytecode implementation that delegates all calls to a known, fixed address.
11
+ *
12
+ * The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2`
13
+ * (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the
14
+ * deterministic method.
15
+ *
16
+ * _Available since v3.4._
17
+ */
18
+ library Clones {
19
+ /**
20
+ * @dev Deploys and returns the address of a clone that mimics the behaviour of `master`.
21
+ *
22
+ * This function uses the create opcode, which should never revert.
23
+ */
24
+ function clone(address master) internal returns (address instance) {
25
+ // solhint-disable-next-line no-inline-assembly
26
+ assembly {
27
+ let ptr := mload(0x40)
28
+ mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
29
+ mstore(add(ptr, 0x14), shl(0x60, master))
30
+ mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
31
+ instance := create(0, ptr, 0x37)
32
+ }
33
+ require(instance != address(0), "ERC1167: create failed");
34
+ }
35
+
36
+ /**
37
+ * @dev Deploys and returns the address of a clone that mimics the behaviour of `master`.
38
+ *
39
+ * This function uses the create2 opcode and a `salt` to deterministically deploy
40
+ * the clone. Using the same `master` and `salt` multiple time will revert, since
41
+ * the clones cannot be deployed twice at the same address.
42
+ */
43
+ function cloneDeterministic(address master, bytes32 salt) internal returns (address instance) {
44
+ // solhint-disable-next-line no-inline-assembly
45
+ assembly {
46
+ let ptr := mload(0x40)
47
+ mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
48
+ mstore(add(ptr, 0x14), shl(0x60, master))
49
+ mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
50
+ instance := create2(0, ptr, 0x37, salt)
51
+ }
52
+ require(instance != address(0), "ERC1167: create2 failed");
53
+ }
54
+
55
+ /**
56
+ * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
57
+ */
58
+ function predictDeterministicAddress(address master, bytes32 salt, address deployer) internal pure returns (address predicted) {
59
+ // solhint-disable-next-line no-inline-assembly
60
+ assembly {
61
+ let ptr := mload(0x40)
62
+ mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
63
+ mstore(add(ptr, 0x14), shl(0x60, master))
64
+ mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf3ff00000000000000000000000000000000)
65
+ mstore(add(ptr, 0x38), shl(0x60, deployer))
66
+ mstore(add(ptr, 0x4c), salt)
67
+ mstore(add(ptr, 0x6c), keccak256(ptr, 0x37))
68
+ predicted := keccak256(add(ptr, 0x37), 0x55)
69
+ }
70
+ }
71
+
72
+ /**
73
+ * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
74
+ */
75
+ function predictDeterministicAddress(address master, bytes32 salt) internal view returns (address predicted) {
76
+ return predictDeterministicAddress(master, salt, address(this));
77
+ }
78
+ }
@@ -0,0 +1,15 @@
1
+ // SPDX-License-Identifier: MIT
2
+
3
+ pragma solidity >=0.6.0 <0.8.0;
4
+
5
+ /**
6
+ * @dev This is the interface that {BeaconProxy} expects of its beacon.
7
+ */
8
+ interface IBeacon {
9
+ /**
10
+ * @dev Must return an address that can be used as a delegate call target.
11
+ *
12
+ * {BeaconProxy} will check that this address is a contract.
13
+ */
14
+ function implementation() external view returns (address);
15
+ }
@@ -0,0 +1,55 @@
1
+ // SPDX-License-Identifier: MIT
2
+
3
+ // solhint-disable-next-line compiler-version
4
+ pragma solidity >=0.4.24 <0.8.0;
5
+
6
+ import "../utils/Address.sol";
7
+
8
+ /**
9
+ * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
10
+ * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
11
+ * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
12
+ * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
13
+ *
14
+ * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
15
+ * possible by providing the encoded function call as the `_data` argument to {UpgradeableProxy-constructor}.
16
+ *
17
+ * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
18
+ * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
19
+ */
20
+ abstract contract Initializable {
21
+
22
+ /**
23
+ * @dev Indicates that the contract has been initialized.
24
+ */
25
+ bool private _initialized;
26
+
27
+ /**
28
+ * @dev Indicates that the contract is in the process of being initialized.
29
+ */
30
+ bool private _initializing;
31
+
32
+ /**
33
+ * @dev Modifier to protect an initializer function from being invoked twice.
34
+ */
35
+ modifier initializer() {
36
+ require(_initializing || _isConstructor() || !_initialized, "Initializable: contract is already initialized");
37
+
38
+ bool isTopLevelCall = !_initializing;
39
+ if (isTopLevelCall) {
40
+ _initializing = true;
41
+ _initialized = true;
42
+ }
43
+
44
+ _;
45
+
46
+ if (isTopLevelCall) {
47
+ _initializing = false;
48
+ }
49
+ }
50
+
51
+ /// @dev Returns true if and only if the function is running in the constructor
52
+ function _isConstructor() private view returns (bool) {
53
+ return !Address.isContract(address(this));
54
+ }
55
+ }
@@ -0,0 +1,83 @@
1
+ // SPDX-License-Identifier: MIT
2
+
3
+ pragma solidity >=0.6.0 <0.8.0;
4
+
5
+ /**
6
+ * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
7
+ * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
8
+ * be specified by overriding the virtual {_implementation} function.
9
+ *
10
+ * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
11
+ * different contract through the {_delegate} function.
12
+ *
13
+ * The success and return data of the delegated call will be returned back to the caller of the proxy.
14
+ */
15
+ abstract contract Proxy {
16
+ /**
17
+ * @dev Delegates the current call to `implementation`.
18
+ *
19
+ * This function does not return to its internall call site, it will return directly to the external caller.
20
+ */
21
+ function _delegate(address implementation) internal virtual {
22
+ // solhint-disable-next-line no-inline-assembly
23
+ assembly {
24
+ // Copy msg.data. We take full control of memory in this inline assembly
25
+ // block because it will not return to Solidity code. We overwrite the
26
+ // Solidity scratch pad at memory position 0.
27
+ calldatacopy(0, 0, calldatasize())
28
+
29
+ // Call the implementation.
30
+ // out and outsize are 0 because we don't know the size yet.
31
+ let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)
32
+
33
+ // Copy the returned data.
34
+ returndatacopy(0, 0, returndatasize())
35
+
36
+ switch result
37
+ // delegatecall returns 0 on error.
38
+ case 0 { revert(0, returndatasize()) }
39
+ default { return(0, returndatasize()) }
40
+ }
41
+ }
42
+
43
+ /**
44
+ * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function
45
+ * and {_fallback} should delegate.
46
+ */
47
+ function _implementation() internal view virtual returns (address);
48
+
49
+ /**
50
+ * @dev Delegates the current call to the address returned by `_implementation()`.
51
+ *
52
+ * This function does not return to its internall call site, it will return directly to the external caller.
53
+ */
54
+ function _fallback() internal virtual {
55
+ _beforeFallback();
56
+ _delegate(_implementation());
57
+ }
58
+
59
+ /**
60
+ * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
61
+ * function in the contract matches the call data.
62
+ */
63
+ fallback () external payable virtual {
64
+ _fallback();
65
+ }
66
+
67
+ /**
68
+ * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data
69
+ * is empty.
70
+ */
71
+ receive () external payable virtual {
72
+ _fallback();
73
+ }
74
+
75
+ /**
76
+ * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`
77
+ * call, or as part of the Solidity `fallback` or `receive` functions.
78
+ *
79
+ * If overriden should call `super._beforeFallback()`.
80
+ */
81
+ function _beforeFallback() internal virtual {
82
+ }
83
+ }