@openzeppelin/wizard 0.1.1 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +2 -0
  3. package/dist/api.d.ts +5 -5
  4. package/dist/api.d.ts.map +1 -1
  5. package/dist/build-generic.d.ts +1 -1
  6. package/dist/build-generic.d.ts.map +1 -1
  7. package/dist/contract.d.ts +3 -3
  8. package/dist/contract.d.ts.map +1 -1
  9. package/dist/environments/hardhat/package-lock.json +15204 -0
  10. package/dist/environments/hardhat/package.json +34 -0
  11. package/dist/environments/hardhat/upgradeable/package-lock.json +15588 -0
  12. package/dist/environments/hardhat/upgradeable/package.json +35 -0
  13. package/dist/erc1155.js +1 -1
  14. package/dist/erc1155.js.map +1 -1
  15. package/dist/erc721.js +2 -0
  16. package/dist/erc721.js.map +1 -1
  17. package/dist/error.d.ts +1 -1
  18. package/dist/error.d.ts.map +1 -1
  19. package/dist/generate/alternatives.d.ts +2 -2
  20. package/dist/generate/alternatives.d.ts.map +1 -1
  21. package/dist/generate/sources.d.ts +1 -1
  22. package/dist/generate/sources.d.ts.map +1 -1
  23. package/dist/governor.d.ts +2 -2
  24. package/dist/governor.d.ts.map +1 -1
  25. package/dist/governor.js +1 -1
  26. package/dist/governor.js.map +1 -1
  27. package/dist/kind.d.ts +1 -1
  28. package/dist/kind.d.ts.map +1 -1
  29. package/dist/print-versioned.js +5 -2
  30. package/dist/print-versioned.js.map +1 -1
  31. package/dist/print.d.ts.map +1 -1
  32. package/dist/print.js +5 -2
  33. package/dist/print.js.map +1 -1
  34. package/dist/set-access-control.d.ts +1 -1
  35. package/dist/set-access-control.d.ts.map +1 -1
  36. package/dist/set-info.d.ts +1 -1
  37. package/dist/set-info.d.ts.map +1 -1
  38. package/dist/set-upgradeable.d.ts +1 -1
  39. package/dist/set-upgradeable.d.ts.map +1 -1
  40. package/dist/solidity-version.json +1 -0
  41. package/dist/utils/define-functions.d.ts +1 -1
  42. package/dist/utils/define-functions.d.ts.map +1 -1
  43. package/dist/utils/format-lines.d.ts +2 -1
  44. package/dist/utils/format-lines.d.ts.map +1 -1
  45. package/dist/utils/format-lines.js +9 -5
  46. package/dist/utils/format-lines.js.map +1 -1
  47. package/dist/utils/transitive-closure.d.ts +1 -1
  48. package/dist/utils/transitive-closure.d.ts.map +1 -1
  49. package/dist/zip-hardhat.d.ts +5 -0
  50. package/dist/zip-hardhat.d.ts.map +1 -0
  51. package/dist/zip-hardhat.js +187 -0
  52. package/dist/zip-hardhat.js.map +1 -0
  53. package/dist/zip.js +1 -1
  54. package/dist/zip.js.map +1 -1
  55. package/package.json +9 -7
  56. package/src/.DS_Store +0 -0
  57. package/src/environments/.DS_Store +0 -0
  58. package/src/environments/hardhat/.DS_Store +0 -0
  59. package/src/environments/hardhat/package-lock.json +15204 -0
  60. package/src/environments/hardhat/package.json +34 -0
  61. package/src/environments/hardhat/upgradeable/package-lock.json +15588 -0
  62. package/src/environments/hardhat/upgradeable/package.json +35 -0
  63. package/src/erc1155.ts +1 -1
  64. package/src/erc721.ts +2 -0
  65. package/src/governor.ts +1 -1
  66. package/src/print-versioned.ts +2 -2
  67. package/src/print.ts +1 -2
  68. package/src/solidity-version.json +1 -0
  69. package/src/utils/format-lines.ts +8 -3
  70. package/src/zip-hardhat.ts +186 -0
  71. package/src/zip.ts +1 -1
  72. package/dist/contract.test.d.ts +0 -2
  73. package/dist/contract.test.d.ts.map +0 -1
  74. package/dist/contract.test.js +0 -147
  75. package/dist/contract.test.js.map +0 -1
  76. package/dist/custom.test.d.ts +0 -2
  77. package/dist/custom.test.d.ts.map +0 -1
  78. package/dist/custom.test.js +0 -70
  79. package/dist/custom.test.js.map +0 -1
  80. package/dist/erc1155.test.d.ts +0 -2
  81. package/dist/erc1155.test.d.ts.map +0 -1
  82. package/dist/erc1155.test.js +0 -91
  83. package/dist/erc1155.test.js.map +0 -1
  84. package/dist/erc20.test.d.ts +0 -2
  85. package/dist/erc20.test.d.ts.map +0 -1
  86. package/dist/erc20.test.js +0 -133
  87. package/dist/erc20.test.js.map +0 -1
  88. package/dist/erc721.test.d.ts +0 -2
  89. package/dist/erc721.test.d.ts.map +0 -1
  90. package/dist/erc721.test.js +0 -112
  91. package/dist/erc721.test.js.map +0 -1
  92. package/dist/governor.test.d.ts +0 -2
  93. package/dist/governor.test.d.ts.map +0 -1
  94. package/dist/governor.test.js +0 -108
  95. package/dist/governor.test.js.map +0 -1
  96. package/dist/utils/to-identifier.test.d.ts +0 -2
  97. package/dist/utils/to-identifier.test.d.ts.map +0 -1
  98. package/dist/utils/to-identifier.test.js +0 -21
  99. package/dist/utils/to-identifier.test.js.map +0 -1
  100. package/dist/zip.test.d.ts +0 -2
  101. package/dist/zip.test.d.ts.map +0 -1
  102. package/dist/zip.test.js +0 -37
  103. package/dist/zip.test.js.map +0 -1
  104. package/src/contract.test.ts +0 -164
  105. package/src/contract.test.ts.md +0 -272
  106. package/src/contract.test.ts.snap +0 -0
  107. package/src/custom.test.ts +0 -80
  108. package/src/custom.test.ts.md +0 -154
  109. package/src/custom.test.ts.snap +0 -0
  110. package/src/erc1155.test.ts +0 -103
  111. package/src/erc1155.test.ts.md +0 -432
  112. package/src/erc1155.test.ts.snap +0 -0
  113. package/src/erc20.test.ts +0 -152
  114. package/src/erc20.test.ts.md +0 -571
  115. package/src/erc20.test.ts.snap +0 -0
  116. package/src/erc721.test.ts +0 -129
  117. package/src/erc721.test.ts.md +0 -517
  118. package/src/erc721.test.ts.snap +0 -0
  119. package/src/governor.test.ts +0 -125
  120. package/src/governor.test.ts.md +0 -1419
  121. package/src/governor.test.ts.snap +0 -0
  122. package/src/utils/to-identifier.test.ts +0 -20
  123. package/src/zip.test.ts +0 -35
@@ -1,103 +0,0 @@
1
- import test from 'ava';
2
- import { erc1155 } from '.';
3
-
4
- import { buildERC1155, ERC1155Options } from './erc1155';
5
- import { printContract } from './print';
6
-
7
- function testERC1155(title: string, opts: Partial<ERC1155Options>) {
8
- test(title, t => {
9
- const c = buildERC1155({
10
- name: 'MyToken',
11
- uri: 'https://gateway.pinata.cloud/ipfs/QmcP9hxrnC1T5ATPmq2saFeAM1ypFX9BnAswCdHB9JCjLA/',
12
- ...opts,
13
- });
14
- t.snapshot(printContract(c));
15
- });
16
- }
17
-
18
- /**
19
- * Tests external API for equivalence with internal API
20
- */
21
- function testAPIEquivalence(title: string, opts?: ERC1155Options) {
22
- test(title, t => {
23
- t.is(erc1155.print(opts), printContract(buildERC1155({
24
- name: 'MyToken',
25
- uri: '',
26
- ...opts,
27
- })));
28
- });
29
- }
30
-
31
- testERC1155('basic', {});
32
-
33
- testERC1155('basic + roles', {
34
- access: 'roles',
35
- });
36
-
37
- testERC1155('no updatable uri', {
38
- updatableUri: false,
39
- });
40
-
41
- testERC1155('burnable', {
42
- burnable: true,
43
- });
44
-
45
- testERC1155('pausable', {
46
- pausable: true,
47
- });
48
-
49
- testERC1155('mintable', {
50
- mintable: true,
51
- });
52
-
53
- testERC1155('mintable + roles', {
54
- mintable: true,
55
- access: 'roles',
56
- });
57
-
58
- testERC1155('supply tracking', {
59
- supply: true,
60
- });
61
-
62
- testERC1155('full upgradeable transparent', {
63
- mintable: true,
64
- access: 'roles',
65
- burnable: true,
66
- pausable: true,
67
- upgradeable: 'transparent',
68
- });
69
-
70
- testERC1155('full upgradeable uups', {
71
- mintable: true,
72
- access: 'roles',
73
- burnable: true,
74
- pausable: true,
75
- upgradeable: 'uups',
76
- });
77
-
78
- testAPIEquivalence('API default');
79
-
80
- testAPIEquivalence('API basic', { name: 'CustomToken', uri: 'https://gateway.pinata.cloud/ipfs/QmcP9hxrnC1T5ATPmq2saFeAM1ypFX9BnAswCdHB9JCjLA/' });
81
-
82
- testAPIEquivalence('API full upgradeable', {
83
- name: 'CustomToken',
84
- uri: 'https://gateway.pinata.cloud/ipfs/QmcP9hxrnC1T5ATPmq2saFeAM1ypFX9BnAswCdHB9JCjLA/',
85
- mintable: true,
86
- access: 'roles',
87
- burnable: true,
88
- pausable: true,
89
- upgradeable: 'uups',
90
- });
91
-
92
- test('API assert defaults', async t => {
93
- t.is(erc1155.print(erc1155.defaults), erc1155.print());
94
- });
95
-
96
- test('API isAccessControlRequired', async t => {
97
- t.is(erc1155.isAccessControlRequired({ updatableUri: false, mintable: true }), true);
98
- t.is(erc1155.isAccessControlRequired({ updatableUri: false, pausable: true }), true);
99
- t.is(erc1155.isAccessControlRequired({ updatableUri: false, upgradeable: 'uups' }), true);
100
- t.is(erc1155.isAccessControlRequired({ updatableUri: true }), true);
101
- t.is(erc1155.isAccessControlRequired({ updatableUri: false}), false);
102
- t.is(erc1155.isAccessControlRequired({}), true); // updatableUri is true by default
103
- });
@@ -1,432 +0,0 @@
1
- # Snapshot report for `src/erc1155.test.ts`
2
-
3
- The actual snapshot is saved in `erc1155.test.ts.snap`.
4
-
5
- Generated by [AVA](https://avajs.dev).
6
-
7
- ## basic
8
-
9
- > Snapshot 1
10
-
11
- `// SPDX-License-Identifier: MIT␊
12
- pragma solidity ^0.8.4;␊
13
-
14
- import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";␊
15
- import "@openzeppelin/contracts/access/Ownable.sol";␊
16
-
17
- contract MyToken is ERC1155, Ownable {␊
18
- constructor()␊
19
- ERC1155("https://gateway.pinata.cloud/ipfs/QmcP9hxrnC1T5ATPmq2saFeAM1ypFX9BnAswCdHB9JCjLA/")␊
20
- {}␊
21
-
22
- function setURI(string memory newuri) public onlyOwner {␊
23
- _setURI(newuri);␊
24
- }␊
25
- }␊
26
- `
27
-
28
- ## basic + roles
29
-
30
- > Snapshot 1
31
-
32
- `// SPDX-License-Identifier: MIT␊
33
- pragma solidity ^0.8.4;␊
34
-
35
- import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";␊
36
- import "@openzeppelin/contracts/access/AccessControl.sol";␊
37
-
38
- contract MyToken is ERC1155, AccessControl {␊
39
- bytes32 public constant URI_SETTER_ROLE = keccak256("URI_SETTER_ROLE");␊
40
-
41
- constructor()␊
42
- ERC1155("https://gateway.pinata.cloud/ipfs/QmcP9hxrnC1T5ATPmq2saFeAM1ypFX9BnAswCdHB9JCjLA/")␊
43
- {␊
44
- _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);␊
45
- _grantRole(URI_SETTER_ROLE, msg.sender);␊
46
- }␊
47
-
48
- function setURI(string memory newuri) public onlyRole(URI_SETTER_ROLE) {␊
49
- _setURI(newuri);␊
50
- }␊
51
-
52
- // The following functions are overrides required by Solidity.␊
53
-
54
- function supportsInterface(bytes4 interfaceId)␊
55
- public␊
56
- view␊
57
- override(ERC1155, AccessControl)␊
58
- returns (bool)␊
59
- {␊
60
- return super.supportsInterface(interfaceId);␊
61
- }␊
62
- }␊
63
- `
64
-
65
- ## no updatable uri
66
-
67
- > Snapshot 1
68
-
69
- `// SPDX-License-Identifier: MIT␊
70
- pragma solidity ^0.8.4;␊
71
-
72
- import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";␊
73
-
74
- contract MyToken is ERC1155 {␊
75
- constructor()␊
76
- ERC1155("https://gateway.pinata.cloud/ipfs/QmcP9hxrnC1T5ATPmq2saFeAM1ypFX9BnAswCdHB9JCjLA/")␊
77
- {}␊
78
- }␊
79
- `
80
-
81
- ## burnable
82
-
83
- > Snapshot 1
84
-
85
- `// SPDX-License-Identifier: MIT␊
86
- pragma solidity ^0.8.4;␊
87
-
88
- import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";␊
89
- import "@openzeppelin/contracts/access/Ownable.sol";␊
90
- import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Burnable.sol";␊
91
-
92
- contract MyToken is ERC1155, Ownable, ERC1155Burnable {␊
93
- constructor()␊
94
- ERC1155("https://gateway.pinata.cloud/ipfs/QmcP9hxrnC1T5ATPmq2saFeAM1ypFX9BnAswCdHB9JCjLA/")␊
95
- {}␊
96
-
97
- function setURI(string memory newuri) public onlyOwner {␊
98
- _setURI(newuri);␊
99
- }␊
100
- }␊
101
- `
102
-
103
- ## pausable
104
-
105
- > Snapshot 1
106
-
107
- `// SPDX-License-Identifier: MIT␊
108
- pragma solidity ^0.8.4;␊
109
-
110
- import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";␊
111
- import "@openzeppelin/contracts/access/Ownable.sol";␊
112
- import "@openzeppelin/contracts/security/Pausable.sol";␊
113
-
114
- contract MyToken is ERC1155, Ownable, Pausable {␊
115
- constructor()␊
116
- ERC1155("https://gateway.pinata.cloud/ipfs/QmcP9hxrnC1T5ATPmq2saFeAM1ypFX9BnAswCdHB9JCjLA/")␊
117
- {}␊
118
-
119
- function setURI(string memory newuri) public onlyOwner {␊
120
- _setURI(newuri);␊
121
- }␊
122
-
123
- function pause() public onlyOwner {␊
124
- _pause();␊
125
- }␊
126
-
127
- function unpause() public onlyOwner {␊
128
- _unpause();␊
129
- }␊
130
-
131
- function _beforeTokenTransfer(address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data)␊
132
- internal␊
133
- whenNotPaused␊
134
- override␊
135
- {␊
136
- super._beforeTokenTransfer(operator, from, to, ids, amounts, data);␊
137
- }␊
138
- }␊
139
- `
140
-
141
- ## mintable
142
-
143
- > Snapshot 1
144
-
145
- `// SPDX-License-Identifier: MIT␊
146
- pragma solidity ^0.8.4;␊
147
-
148
- import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";␊
149
- import "@openzeppelin/contracts/access/Ownable.sol";␊
150
-
151
- contract MyToken is ERC1155, Ownable {␊
152
- constructor()␊
153
- ERC1155("https://gateway.pinata.cloud/ipfs/QmcP9hxrnC1T5ATPmq2saFeAM1ypFX9BnAswCdHB9JCjLA/")␊
154
- {}␊
155
-
156
- function setURI(string memory newuri) public onlyOwner {␊
157
- _setURI(newuri);␊
158
- }␊
159
-
160
- function mint(address account, uint256 id, uint256 amount, bytes memory data)␊
161
- public␊
162
- onlyOwner␊
163
- {␊
164
- _mint(account, id, amount, data);␊
165
- }␊
166
-
167
- function mintBatch(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data)␊
168
- public␊
169
- onlyOwner␊
170
- {␊
171
- _mintBatch(to, ids, amounts, data);␊
172
- }␊
173
- }␊
174
- `
175
-
176
- ## mintable + roles
177
-
178
- > Snapshot 1
179
-
180
- `// SPDX-License-Identifier: MIT␊
181
- pragma solidity ^0.8.4;␊
182
-
183
- import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";␊
184
- import "@openzeppelin/contracts/access/AccessControl.sol";␊
185
-
186
- contract MyToken is ERC1155, AccessControl {␊
187
- bytes32 public constant URI_SETTER_ROLE = keccak256("URI_SETTER_ROLE");␊
188
- bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");␊
189
-
190
- constructor()␊
191
- ERC1155("https://gateway.pinata.cloud/ipfs/QmcP9hxrnC1T5ATPmq2saFeAM1ypFX9BnAswCdHB9JCjLA/")␊
192
- {␊
193
- _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);␊
194
- _grantRole(URI_SETTER_ROLE, msg.sender);␊
195
- _grantRole(MINTER_ROLE, msg.sender);␊
196
- }␊
197
-
198
- function setURI(string memory newuri) public onlyRole(URI_SETTER_ROLE) {␊
199
- _setURI(newuri);␊
200
- }␊
201
-
202
- function mint(address account, uint256 id, uint256 amount, bytes memory data)␊
203
- public␊
204
- onlyRole(MINTER_ROLE)␊
205
- {␊
206
- _mint(account, id, amount, data);␊
207
- }␊
208
-
209
- function mintBatch(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data)␊
210
- public␊
211
- onlyRole(MINTER_ROLE)␊
212
- {␊
213
- _mintBatch(to, ids, amounts, data);␊
214
- }␊
215
-
216
- // The following functions are overrides required by Solidity.␊
217
-
218
- function supportsInterface(bytes4 interfaceId)␊
219
- public␊
220
- view␊
221
- override(ERC1155, AccessControl)␊
222
- returns (bool)␊
223
- {␊
224
- return super.supportsInterface(interfaceId);␊
225
- }␊
226
- }␊
227
- `
228
-
229
- ## supply tracking
230
-
231
- > Snapshot 1
232
-
233
- `// SPDX-License-Identifier: MIT␊
234
- pragma solidity ^0.8.4;␊
235
-
236
- import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";␊
237
- import "@openzeppelin/contracts/access/Ownable.sol";␊
238
- import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Supply.sol";␊
239
-
240
- contract MyToken is ERC1155, Ownable, ERC1155Supply {␊
241
- constructor()␊
242
- ERC1155("https://gateway.pinata.cloud/ipfs/QmcP9hxrnC1T5ATPmq2saFeAM1ypFX9BnAswCdHB9JCjLA/")␊
243
- {}␊
244
-
245
- function setURI(string memory newuri) public onlyOwner {␊
246
- _setURI(newuri);␊
247
- }␊
248
-
249
- // The following functions are overrides required by Solidity.␊
250
-
251
- function _beforeTokenTransfer(address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data)␊
252
- internal␊
253
- override(ERC1155, ERC1155Supply)␊
254
- {␊
255
- super._beforeTokenTransfer(operator, from, to, ids, amounts, data);␊
256
- }␊
257
- }␊
258
- `
259
-
260
- ## full upgradeable transparent
261
-
262
- > Snapshot 1
263
-
264
- `// SPDX-License-Identifier: MIT␊
265
- pragma solidity ^0.8.4;␊
266
-
267
- import "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol";␊
268
- import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";␊
269
- import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";␊
270
- import "@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155BurnableUpgradeable.sol";␊
271
- import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";␊
272
-
273
- contract MyToken is Initializable, ERC1155Upgradeable, AccessControlUpgradeable, PausableUpgradeable, ERC1155BurnableUpgradeable {␊
274
- bytes32 public constant URI_SETTER_ROLE = keccak256("URI_SETTER_ROLE");␊
275
- bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");␊
276
- bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");␊
277
-
278
- /// @custom:oz-upgrades-unsafe-allow constructor␊
279
- constructor() {␊
280
- _disableInitializers();␊
281
- }␊
282
-
283
- function initialize() initializer public {␊
284
- __ERC1155_init("https://gateway.pinata.cloud/ipfs/QmcP9hxrnC1T5ATPmq2saFeAM1ypFX9BnAswCdHB9JCjLA/");␊
285
- __AccessControl_init();␊
286
- __Pausable_init();␊
287
- __ERC1155Burnable_init();␊
288
-
289
- _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);␊
290
- _grantRole(URI_SETTER_ROLE, msg.sender);␊
291
- _grantRole(PAUSER_ROLE, msg.sender);␊
292
- _grantRole(MINTER_ROLE, msg.sender);␊
293
- }␊
294
-
295
- function setURI(string memory newuri) public onlyRole(URI_SETTER_ROLE) {␊
296
- _setURI(newuri);␊
297
- }␊
298
-
299
- function pause() public onlyRole(PAUSER_ROLE) {␊
300
- _pause();␊
301
- }␊
302
-
303
- function unpause() public onlyRole(PAUSER_ROLE) {␊
304
- _unpause();␊
305
- }␊
306
-
307
- function mint(address account, uint256 id, uint256 amount, bytes memory data)␊
308
- public␊
309
- onlyRole(MINTER_ROLE)␊
310
- {␊
311
- _mint(account, id, amount, data);␊
312
- }␊
313
-
314
- function mintBatch(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data)␊
315
- public␊
316
- onlyRole(MINTER_ROLE)␊
317
- {␊
318
- _mintBatch(to, ids, amounts, data);␊
319
- }␊
320
-
321
- function _beforeTokenTransfer(address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data)␊
322
- internal␊
323
- whenNotPaused␊
324
- override␊
325
- {␊
326
- super._beforeTokenTransfer(operator, from, to, ids, amounts, data);␊
327
- }␊
328
-
329
- // The following functions are overrides required by Solidity.␊
330
-
331
- function supportsInterface(bytes4 interfaceId)␊
332
- public␊
333
- view␊
334
- override(ERC1155Upgradeable, AccessControlUpgradeable)␊
335
- returns (bool)␊
336
- {␊
337
- return super.supportsInterface(interfaceId);␊
338
- }␊
339
- }␊
340
- `
341
-
342
- ## full upgradeable uups
343
-
344
- > Snapshot 1
345
-
346
- `// SPDX-License-Identifier: MIT␊
347
- pragma solidity ^0.8.4;␊
348
-
349
- import "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol";␊
350
- import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";␊
351
- import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";␊
352
- import "@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155BurnableUpgradeable.sol";␊
353
- import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";␊
354
- import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";␊
355
-
356
- contract MyToken is Initializable, ERC1155Upgradeable, AccessControlUpgradeable, PausableUpgradeable, ERC1155BurnableUpgradeable, UUPSUpgradeable {␊
357
- bytes32 public constant URI_SETTER_ROLE = keccak256("URI_SETTER_ROLE");␊
358
- bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");␊
359
- bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");␊
360
- bytes32 public constant UPGRADER_ROLE = keccak256("UPGRADER_ROLE");␊
361
-
362
- /// @custom:oz-upgrades-unsafe-allow constructor␊
363
- constructor() {␊
364
- _disableInitializers();␊
365
- }␊
366
-
367
- function initialize() initializer public {␊
368
- __ERC1155_init("https://gateway.pinata.cloud/ipfs/QmcP9hxrnC1T5ATPmq2saFeAM1ypFX9BnAswCdHB9JCjLA/");␊
369
- __AccessControl_init();␊
370
- __Pausable_init();␊
371
- __ERC1155Burnable_init();␊
372
- __UUPSUpgradeable_init();␊
373
-
374
- _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);␊
375
- _grantRole(URI_SETTER_ROLE, msg.sender);␊
376
- _grantRole(PAUSER_ROLE, msg.sender);␊
377
- _grantRole(MINTER_ROLE, msg.sender);␊
378
- _grantRole(UPGRADER_ROLE, msg.sender);␊
379
- }␊
380
-
381
- function setURI(string memory newuri) public onlyRole(URI_SETTER_ROLE) {␊
382
- _setURI(newuri);␊
383
- }␊
384
-
385
- function pause() public onlyRole(PAUSER_ROLE) {␊
386
- _pause();␊
387
- }␊
388
-
389
- function unpause() public onlyRole(PAUSER_ROLE) {␊
390
- _unpause();␊
391
- }␊
392
-
393
- function mint(address account, uint256 id, uint256 amount, bytes memory data)␊
394
- public␊
395
- onlyRole(MINTER_ROLE)␊
396
- {␊
397
- _mint(account, id, amount, data);␊
398
- }␊
399
-
400
- function mintBatch(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data)␊
401
- public␊
402
- onlyRole(MINTER_ROLE)␊
403
- {␊
404
- _mintBatch(to, ids, amounts, data);␊
405
- }␊
406
-
407
- function _beforeTokenTransfer(address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data)␊
408
- internal␊
409
- whenNotPaused␊
410
- override␊
411
- {␊
412
- super._beforeTokenTransfer(operator, from, to, ids, amounts, data);␊
413
- }␊
414
-
415
- function _authorizeUpgrade(address newImplementation)␊
416
- internal␊
417
- onlyRole(UPGRADER_ROLE)␊
418
- override␊
419
- {}␊
420
-
421
- // The following functions are overrides required by Solidity.␊
422
-
423
- function supportsInterface(bytes4 interfaceId)␊
424
- public␊
425
- view␊
426
- override(ERC1155Upgradeable, AccessControlUpgradeable)␊
427
- returns (bool)␊
428
- {␊
429
- return super.supportsInterface(interfaceId);␊
430
- }␊
431
- }␊
432
- `
Binary file
package/src/erc20.test.ts DELETED
@@ -1,152 +0,0 @@
1
- import test from 'ava';
2
- import { erc20 } from '.';
3
-
4
- import { buildERC20, ERC20Options } from './erc20';
5
- import { printContract } from './print';
6
-
7
- function testERC20(title: string, opts: Partial<ERC20Options>) {
8
- test(title, t => {
9
- const c = buildERC20({
10
- name: 'MyToken',
11
- symbol: 'MTK',
12
- ...opts,
13
- });
14
- t.snapshot(printContract(c));
15
- });
16
- }
17
-
18
- /**
19
- * Tests external API for equivalence with internal API
20
- */
21
- function testAPIEquivalence(title: string, opts?: ERC20Options) {
22
- test(title, t => {
23
- t.is(erc20.print(opts), printContract(buildERC20({
24
- name: 'MyToken',
25
- symbol: 'MTK',
26
- ...opts,
27
- })));
28
- });
29
- }
30
-
31
- testERC20('basic erc20', {});
32
-
33
- testERC20('erc20 with snapshots', {
34
- snapshots: true,
35
- });
36
-
37
- testERC20('erc20 burnable', {
38
- burnable: true,
39
- });
40
-
41
- testERC20('erc20 burnable with snapshots', {
42
- burnable: true,
43
- snapshots: true,
44
- });
45
-
46
- testERC20('erc20 pausable', {
47
- pausable: true,
48
- access: 'ownable',
49
- });
50
-
51
- testERC20('erc20 pausable with roles', {
52
- pausable: true,
53
- access: 'roles',
54
- });
55
-
56
- testERC20('erc20 burnable pausable', {
57
- burnable: true,
58
- pausable: true,
59
- });
60
-
61
- testERC20('erc20 burnable pausable with snapshots', {
62
- burnable: true,
63
- pausable: true,
64
- snapshots: true,
65
- });
66
-
67
- testERC20('erc20 preminted', {
68
- premint: '1000',
69
- });
70
-
71
- testERC20('erc20 premint of 0', {
72
- premint: '0',
73
- });
74
-
75
- testERC20('erc20 mintable', {
76
- mintable: true,
77
- access: 'ownable',
78
- });
79
-
80
- testERC20('erc20 mintable with roles', {
81
- mintable: true,
82
- access: 'roles',
83
- });
84
-
85
- testERC20('erc20 permit', {
86
- permit: true,
87
- });
88
-
89
- testERC20('erc20 votes', {
90
- votes: true,
91
- });
92
-
93
- testERC20('erc20 flashmint', {
94
- flashmint: true,
95
- });
96
-
97
- testERC20('erc20 full upgradeable transparent', {
98
- premint: '2000',
99
- access: 'roles',
100
- burnable: true,
101
- mintable: true,
102
- pausable: true,
103
- snapshots: true,
104
- permit: true,
105
- votes: true,
106
- flashmint: true,
107
- upgradeable: 'transparent',
108
- });
109
-
110
- testERC20('erc20 full upgradeable uups', {
111
- premint: '2000',
112
- access: 'roles',
113
- burnable: true,
114
- mintable: true,
115
- pausable: true,
116
- snapshots: true,
117
- permit: true,
118
- votes: true,
119
- flashmint: true,
120
- upgradeable: 'uups',
121
- });
122
-
123
- testAPIEquivalence('erc20 API default');
124
-
125
- testAPIEquivalence('erc20 API basic', { name: 'CustomToken', symbol: 'CTK' });
126
-
127
- testAPIEquivalence('erc20 API full upgradeable', {
128
- name: 'CustomToken',
129
- symbol: 'CTK',
130
- premint: '2000',
131
- access: 'roles',
132
- burnable: true,
133
- mintable: true,
134
- pausable: true,
135
- snapshots: true,
136
- permit: true,
137
- votes: true,
138
- flashmint: true,
139
- upgradeable: 'uups',
140
- });
141
-
142
- test('erc20 API assert defaults', async t => {
143
- t.is(erc20.print(erc20.defaults), erc20.print());
144
- });
145
-
146
- test('erc20 API isAccessControlRequired', async t => {
147
- t.is(erc20.isAccessControlRequired({ mintable: true }), true);
148
- t.is(erc20.isAccessControlRequired({ pausable: true }), true);
149
- t.is(erc20.isAccessControlRequired({ snapshots: true }), true);
150
- t.is(erc20.isAccessControlRequired({ upgradeable: 'uups' }), true);
151
- t.is(erc20.isAccessControlRequired({ upgradeable: 'transparent' }), false);
152
- });