@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,571 +0,0 @@
1
- # Snapshot report for `src/erc20.test.ts`
2
-
3
- The actual snapshot is saved in `erc20.test.ts.snap`.
4
-
5
- Generated by [AVA](https://avajs.dev).
6
-
7
- ## basic erc20
8
-
9
- > Snapshot 1
10
-
11
- `// SPDX-License-Identifier: MIT␊
12
- pragma solidity ^0.8.4;␊
13
-
14
- import "@openzeppelin/contracts/token/ERC20/ERC20.sol";␊
15
-
16
- contract MyToken is ERC20 {␊
17
- constructor() ERC20("MyToken", "MTK") {}␊
18
- }␊
19
- `
20
-
21
- ## erc20 with snapshots
22
-
23
- > Snapshot 1
24
-
25
- `// SPDX-License-Identifier: MIT␊
26
- pragma solidity ^0.8.4;␊
27
-
28
- import "@openzeppelin/contracts/token/ERC20/ERC20.sol";␊
29
- import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Snapshot.sol";␊
30
- import "@openzeppelin/contracts/access/Ownable.sol";␊
31
-
32
- contract MyToken is ERC20, ERC20Snapshot, Ownable {␊
33
- constructor() ERC20("MyToken", "MTK") {}␊
34
-
35
- function snapshot() public onlyOwner {␊
36
- _snapshot();␊
37
- }␊
38
-
39
- // The following functions are overrides required by Solidity.␊
40
-
41
- function _beforeTokenTransfer(address from, address to, uint256 amount)␊
42
- internal␊
43
- override(ERC20, ERC20Snapshot)␊
44
- {␊
45
- super._beforeTokenTransfer(from, to, amount);␊
46
- }␊
47
- }␊
48
- `
49
-
50
- ## erc20 burnable
51
-
52
- > Snapshot 1
53
-
54
- `// SPDX-License-Identifier: MIT␊
55
- pragma solidity ^0.8.4;␊
56
-
57
- import "@openzeppelin/contracts/token/ERC20/ERC20.sol";␊
58
- import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";␊
59
-
60
- contract MyToken is ERC20, ERC20Burnable {␊
61
- constructor() ERC20("MyToken", "MTK") {}␊
62
- }␊
63
- `
64
-
65
- ## erc20 burnable with snapshots
66
-
67
- > Snapshot 1
68
-
69
- `// SPDX-License-Identifier: MIT␊
70
- pragma solidity ^0.8.4;␊
71
-
72
- import "@openzeppelin/contracts/token/ERC20/ERC20.sol";␊
73
- import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";␊
74
- import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Snapshot.sol";␊
75
- import "@openzeppelin/contracts/access/Ownable.sol";␊
76
-
77
- contract MyToken is ERC20, ERC20Burnable, ERC20Snapshot, Ownable {␊
78
- constructor() ERC20("MyToken", "MTK") {}␊
79
-
80
- function snapshot() public onlyOwner {␊
81
- _snapshot();␊
82
- }␊
83
-
84
- // The following functions are overrides required by Solidity.␊
85
-
86
- function _beforeTokenTransfer(address from, address to, uint256 amount)␊
87
- internal␊
88
- override(ERC20, ERC20Snapshot)␊
89
- {␊
90
- super._beforeTokenTransfer(from, to, amount);␊
91
- }␊
92
- }␊
93
- `
94
-
95
- ## erc20 pausable
96
-
97
- > Snapshot 1
98
-
99
- `// SPDX-License-Identifier: MIT␊
100
- pragma solidity ^0.8.4;␊
101
-
102
- import "@openzeppelin/contracts/token/ERC20/ERC20.sol";␊
103
- import "@openzeppelin/contracts/security/Pausable.sol";␊
104
- import "@openzeppelin/contracts/access/Ownable.sol";␊
105
-
106
- contract MyToken is ERC20, Pausable, Ownable {␊
107
- constructor() ERC20("MyToken", "MTK") {}␊
108
-
109
- function pause() public onlyOwner {␊
110
- _pause();␊
111
- }␊
112
-
113
- function unpause() public onlyOwner {␊
114
- _unpause();␊
115
- }␊
116
-
117
- function _beforeTokenTransfer(address from, address to, uint256 amount)␊
118
- internal␊
119
- whenNotPaused␊
120
- override␊
121
- {␊
122
- super._beforeTokenTransfer(from, to, amount);␊
123
- }␊
124
- }␊
125
- `
126
-
127
- ## erc20 pausable with roles
128
-
129
- > Snapshot 1
130
-
131
- `// SPDX-License-Identifier: MIT␊
132
- pragma solidity ^0.8.4;␊
133
-
134
- import "@openzeppelin/contracts/token/ERC20/ERC20.sol";␊
135
- import "@openzeppelin/contracts/security/Pausable.sol";␊
136
- import "@openzeppelin/contracts/access/AccessControl.sol";␊
137
-
138
- contract MyToken is ERC20, Pausable, AccessControl {␊
139
- bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");␊
140
-
141
- constructor() ERC20("MyToken", "MTK") {␊
142
- _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);␊
143
- _grantRole(PAUSER_ROLE, msg.sender);␊
144
- }␊
145
-
146
- function pause() public onlyRole(PAUSER_ROLE) {␊
147
- _pause();␊
148
- }␊
149
-
150
- function unpause() public onlyRole(PAUSER_ROLE) {␊
151
- _unpause();␊
152
- }␊
153
-
154
- function _beforeTokenTransfer(address from, address to, uint256 amount)␊
155
- internal␊
156
- whenNotPaused␊
157
- override␊
158
- {␊
159
- super._beforeTokenTransfer(from, to, amount);␊
160
- }␊
161
- }␊
162
- `
163
-
164
- ## erc20 burnable pausable
165
-
166
- > Snapshot 1
167
-
168
- `// SPDX-License-Identifier: MIT␊
169
- pragma solidity ^0.8.4;␊
170
-
171
- import "@openzeppelin/contracts/token/ERC20/ERC20.sol";␊
172
- import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";␊
173
- import "@openzeppelin/contracts/security/Pausable.sol";␊
174
- import "@openzeppelin/contracts/access/Ownable.sol";␊
175
-
176
- contract MyToken is ERC20, ERC20Burnable, Pausable, Ownable {␊
177
- constructor() ERC20("MyToken", "MTK") {}␊
178
-
179
- function pause() public onlyOwner {␊
180
- _pause();␊
181
- }␊
182
-
183
- function unpause() public onlyOwner {␊
184
- _unpause();␊
185
- }␊
186
-
187
- function _beforeTokenTransfer(address from, address to, uint256 amount)␊
188
- internal␊
189
- whenNotPaused␊
190
- override␊
191
- {␊
192
- super._beforeTokenTransfer(from, to, amount);␊
193
- }␊
194
- }␊
195
- `
196
-
197
- ## erc20 burnable pausable with snapshots
198
-
199
- > Snapshot 1
200
-
201
- `// SPDX-License-Identifier: MIT␊
202
- pragma solidity ^0.8.4;␊
203
-
204
- import "@openzeppelin/contracts/token/ERC20/ERC20.sol";␊
205
- import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";␊
206
- import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Snapshot.sol";␊
207
- import "@openzeppelin/contracts/access/Ownable.sol";␊
208
- import "@openzeppelin/contracts/security/Pausable.sol";␊
209
-
210
- contract MyToken is ERC20, ERC20Burnable, ERC20Snapshot, Ownable, Pausable {␊
211
- constructor() ERC20("MyToken", "MTK") {}␊
212
-
213
- function snapshot() public onlyOwner {␊
214
- _snapshot();␊
215
- }␊
216
-
217
- function pause() public onlyOwner {␊
218
- _pause();␊
219
- }␊
220
-
221
- function unpause() public onlyOwner {␊
222
- _unpause();␊
223
- }␊
224
-
225
- function _beforeTokenTransfer(address from, address to, uint256 amount)␊
226
- internal␊
227
- whenNotPaused␊
228
- override(ERC20, ERC20Snapshot)␊
229
- {␊
230
- super._beforeTokenTransfer(from, to, amount);␊
231
- }␊
232
- }␊
233
- `
234
-
235
- ## erc20 preminted
236
-
237
- > Snapshot 1
238
-
239
- `// SPDX-License-Identifier: MIT␊
240
- pragma solidity ^0.8.4;␊
241
-
242
- import "@openzeppelin/contracts/token/ERC20/ERC20.sol";␊
243
-
244
- contract MyToken is ERC20 {␊
245
- constructor() ERC20("MyToken", "MTK") {␊
246
- _mint(msg.sender, 1000 * 10 ** decimals());␊
247
- }␊
248
- }␊
249
- `
250
-
251
- ## erc20 premint of 0
252
-
253
- > Snapshot 1
254
-
255
- `// SPDX-License-Identifier: MIT␊
256
- pragma solidity ^0.8.4;␊
257
-
258
- import "@openzeppelin/contracts/token/ERC20/ERC20.sol";␊
259
-
260
- contract MyToken is ERC20 {␊
261
- constructor() ERC20("MyToken", "MTK") {}␊
262
- }␊
263
- `
264
-
265
- ## erc20 mintable
266
-
267
- > Snapshot 1
268
-
269
- `// SPDX-License-Identifier: MIT␊
270
- pragma solidity ^0.8.4;␊
271
-
272
- import "@openzeppelin/contracts/token/ERC20/ERC20.sol";␊
273
- import "@openzeppelin/contracts/access/Ownable.sol";␊
274
-
275
- contract MyToken is ERC20, Ownable {␊
276
- constructor() ERC20("MyToken", "MTK") {}␊
277
-
278
- function mint(address to, uint256 amount) public onlyOwner {␊
279
- _mint(to, amount);␊
280
- }␊
281
- }␊
282
- `
283
-
284
- ## erc20 mintable with roles
285
-
286
- > Snapshot 1
287
-
288
- `// SPDX-License-Identifier: MIT␊
289
- pragma solidity ^0.8.4;␊
290
-
291
- import "@openzeppelin/contracts/token/ERC20/ERC20.sol";␊
292
- import "@openzeppelin/contracts/access/AccessControl.sol";␊
293
-
294
- contract MyToken is ERC20, AccessControl {␊
295
- bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");␊
296
-
297
- constructor() ERC20("MyToken", "MTK") {␊
298
- _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);␊
299
- _grantRole(MINTER_ROLE, msg.sender);␊
300
- }␊
301
-
302
- function mint(address to, uint256 amount) public onlyRole(MINTER_ROLE) {␊
303
- _mint(to, amount);␊
304
- }␊
305
- }␊
306
- `
307
-
308
- ## erc20 permit
309
-
310
- > Snapshot 1
311
-
312
- `// SPDX-License-Identifier: MIT␊
313
- pragma solidity ^0.8.4;␊
314
-
315
- import "@openzeppelin/contracts/token/ERC20/ERC20.sol";␊
316
- import "@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol";␊
317
-
318
- contract MyToken is ERC20, ERC20Permit {␊
319
- constructor() ERC20("MyToken", "MTK") ERC20Permit("MyToken") {}␊
320
- }␊
321
- `
322
-
323
- ## erc20 votes
324
-
325
- > Snapshot 1
326
-
327
- `// SPDX-License-Identifier: MIT␊
328
- pragma solidity ^0.8.4;␊
329
-
330
- import "@openzeppelin/contracts/token/ERC20/ERC20.sol";␊
331
- import "@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol";␊
332
- import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Votes.sol";␊
333
-
334
- contract MyToken is ERC20, ERC20Permit, ERC20Votes {␊
335
- constructor() ERC20("MyToken", "MTK") ERC20Permit("MyToken") {}␊
336
-
337
- // The following functions are overrides required by Solidity.␊
338
-
339
- function _afterTokenTransfer(address from, address to, uint256 amount)␊
340
- internal␊
341
- override(ERC20, ERC20Votes)␊
342
- {␊
343
- super._afterTokenTransfer(from, to, amount);␊
344
- }␊
345
-
346
- function _mint(address to, uint256 amount)␊
347
- internal␊
348
- override(ERC20, ERC20Votes)␊
349
- {␊
350
- super._mint(to, amount);␊
351
- }␊
352
-
353
- function _burn(address account, uint256 amount)␊
354
- internal␊
355
- override(ERC20, ERC20Votes)␊
356
- {␊
357
- super._burn(account, amount);␊
358
- }␊
359
- }␊
360
- `
361
-
362
- ## erc20 flashmint
363
-
364
- > Snapshot 1
365
-
366
- `// SPDX-License-Identifier: MIT␊
367
- pragma solidity ^0.8.4;␊
368
-
369
- import "@openzeppelin/contracts/token/ERC20/ERC20.sol";␊
370
- import "@openzeppelin/contracts/token/ERC20/extensions/ERC20FlashMint.sol";␊
371
-
372
- contract MyToken is ERC20, ERC20FlashMint {␊
373
- constructor() ERC20("MyToken", "MTK") {}␊
374
- }␊
375
- `
376
-
377
- ## erc20 full upgradeable transparent
378
-
379
- > Snapshot 1
380
-
381
- `// SPDX-License-Identifier: MIT␊
382
- pragma solidity ^0.8.4;␊
383
-
384
- import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";␊
385
- import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20BurnableUpgradeable.sol";␊
386
- import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20SnapshotUpgradeable.sol";␊
387
- import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";␊
388
- import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";␊
389
- import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-ERC20PermitUpgradeable.sol";␊
390
- import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20VotesUpgradeable.sol";␊
391
- import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20FlashMintUpgradeable.sol";␊
392
- import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";␊
393
-
394
- contract MyToken is Initializable, ERC20Upgradeable, ERC20BurnableUpgradeable, ERC20SnapshotUpgradeable, AccessControlUpgradeable, PausableUpgradeable, ERC20PermitUpgradeable, ERC20VotesUpgradeable, ERC20FlashMintUpgradeable {␊
395
- bytes32 public constant SNAPSHOT_ROLE = keccak256("SNAPSHOT_ROLE");␊
396
- bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");␊
397
- bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");␊
398
-
399
- /// @custom:oz-upgrades-unsafe-allow constructor␊
400
- constructor() {␊
401
- _disableInitializers();␊
402
- }␊
403
-
404
- function initialize() initializer public {␊
405
- __ERC20_init("MyToken", "MTK");␊
406
- __ERC20Burnable_init();␊
407
- __ERC20Snapshot_init();␊
408
- __AccessControl_init();␊
409
- __Pausable_init();␊
410
- __ERC20Permit_init("MyToken");␊
411
- __ERC20Votes_init();␊
412
- __ERC20FlashMint_init();␊
413
-
414
- _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);␊
415
- _grantRole(SNAPSHOT_ROLE, msg.sender);␊
416
- _grantRole(PAUSER_ROLE, msg.sender);␊
417
- _mint(msg.sender, 2000 * 10 ** decimals());␊
418
- _grantRole(MINTER_ROLE, msg.sender);␊
419
- }␊
420
-
421
- function snapshot() public onlyRole(SNAPSHOT_ROLE) {␊
422
- _snapshot();␊
423
- }␊
424
-
425
- function pause() public onlyRole(PAUSER_ROLE) {␊
426
- _pause();␊
427
- }␊
428
-
429
- function unpause() public onlyRole(PAUSER_ROLE) {␊
430
- _unpause();␊
431
- }␊
432
-
433
- function mint(address to, uint256 amount) public onlyRole(MINTER_ROLE) {␊
434
- _mint(to, amount);␊
435
- }␊
436
-
437
- function _beforeTokenTransfer(address from, address to, uint256 amount)␊
438
- internal␊
439
- whenNotPaused␊
440
- override(ERC20Upgradeable, ERC20SnapshotUpgradeable)␊
441
- {␊
442
- super._beforeTokenTransfer(from, to, amount);␊
443
- }␊
444
-
445
- // The following functions are overrides required by Solidity.␊
446
-
447
- function _afterTokenTransfer(address from, address to, uint256 amount)␊
448
- internal␊
449
- override(ERC20Upgradeable, ERC20VotesUpgradeable)␊
450
- {␊
451
- super._afterTokenTransfer(from, to, amount);␊
452
- }␊
453
-
454
- function _mint(address to, uint256 amount)␊
455
- internal␊
456
- override(ERC20Upgradeable, ERC20VotesUpgradeable)␊
457
- {␊
458
- super._mint(to, amount);␊
459
- }␊
460
-
461
- function _burn(address account, uint256 amount)␊
462
- internal␊
463
- override(ERC20Upgradeable, ERC20VotesUpgradeable)␊
464
- {␊
465
- super._burn(account, amount);␊
466
- }␊
467
- }␊
468
- `
469
-
470
- ## erc20 full upgradeable uups
471
-
472
- > Snapshot 1
473
-
474
- `// SPDX-License-Identifier: MIT␊
475
- pragma solidity ^0.8.4;␊
476
-
477
- import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";␊
478
- import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20BurnableUpgradeable.sol";␊
479
- import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20SnapshotUpgradeable.sol";␊
480
- import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";␊
481
- import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";␊
482
- import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-ERC20PermitUpgradeable.sol";␊
483
- import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20VotesUpgradeable.sol";␊
484
- import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20FlashMintUpgradeable.sol";␊
485
- import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";␊
486
- import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";␊
487
-
488
- contract MyToken is Initializable, ERC20Upgradeable, ERC20BurnableUpgradeable, ERC20SnapshotUpgradeable, AccessControlUpgradeable, PausableUpgradeable, ERC20PermitUpgradeable, ERC20VotesUpgradeable, ERC20FlashMintUpgradeable, UUPSUpgradeable {␊
489
- bytes32 public constant SNAPSHOT_ROLE = keccak256("SNAPSHOT_ROLE");␊
490
- bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");␊
491
- bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");␊
492
- bytes32 public constant UPGRADER_ROLE = keccak256("UPGRADER_ROLE");␊
493
-
494
- /// @custom:oz-upgrades-unsafe-allow constructor␊
495
- constructor() {␊
496
- _disableInitializers();␊
497
- }␊
498
-
499
- function initialize() initializer public {␊
500
- __ERC20_init("MyToken", "MTK");␊
501
- __ERC20Burnable_init();␊
502
- __ERC20Snapshot_init();␊
503
- __AccessControl_init();␊
504
- __Pausable_init();␊
505
- __ERC20Permit_init("MyToken");␊
506
- __ERC20Votes_init();␊
507
- __ERC20FlashMint_init();␊
508
- __UUPSUpgradeable_init();␊
509
-
510
- _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);␊
511
- _grantRole(SNAPSHOT_ROLE, msg.sender);␊
512
- _grantRole(PAUSER_ROLE, msg.sender);␊
513
- _mint(msg.sender, 2000 * 10 ** decimals());␊
514
- _grantRole(MINTER_ROLE, msg.sender);␊
515
- _grantRole(UPGRADER_ROLE, msg.sender);␊
516
- }␊
517
-
518
- function snapshot() public onlyRole(SNAPSHOT_ROLE) {␊
519
- _snapshot();␊
520
- }␊
521
-
522
- function pause() public onlyRole(PAUSER_ROLE) {␊
523
- _pause();␊
524
- }␊
525
-
526
- function unpause() public onlyRole(PAUSER_ROLE) {␊
527
- _unpause();␊
528
- }␊
529
-
530
- function mint(address to, uint256 amount) public onlyRole(MINTER_ROLE) {␊
531
- _mint(to, amount);␊
532
- }␊
533
-
534
- function _beforeTokenTransfer(address from, address to, uint256 amount)␊
535
- internal␊
536
- whenNotPaused␊
537
- override(ERC20Upgradeable, ERC20SnapshotUpgradeable)␊
538
- {␊
539
- super._beforeTokenTransfer(from, to, amount);␊
540
- }␊
541
-
542
- function _authorizeUpgrade(address newImplementation)␊
543
- internal␊
544
- onlyRole(UPGRADER_ROLE)␊
545
- override␊
546
- {}␊
547
-
548
- // The following functions are overrides required by Solidity.␊
549
-
550
- function _afterTokenTransfer(address from, address to, uint256 amount)␊
551
- internal␊
552
- override(ERC20Upgradeable, ERC20VotesUpgradeable)␊
553
- {␊
554
- super._afterTokenTransfer(from, to, amount);␊
555
- }␊
556
-
557
- function _mint(address to, uint256 amount)␊
558
- internal␊
559
- override(ERC20Upgradeable, ERC20VotesUpgradeable)␊
560
- {␊
561
- super._mint(to, amount);␊
562
- }␊
563
-
564
- function _burn(address account, uint256 amount)␊
565
- internal␊
566
- override(ERC20Upgradeable, ERC20VotesUpgradeable)␊
567
- {␊
568
- super._burn(account, amount);␊
569
- }␊
570
- }␊
571
- `
Binary file
@@ -1,129 +0,0 @@
1
- import test from 'ava';
2
- import { erc721 } from '.';
3
-
4
- import { buildERC721, ERC721Options } from './erc721';
5
- import { printContract } from './print';
6
-
7
- function testERC721(title: string, opts: Partial<ERC721Options>) {
8
- test(title, t => {
9
- const c = buildERC721({
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?: ERC721Options) {
22
- test(title, t => {
23
- t.is(erc721.print(opts), printContract(buildERC721({
24
- name: 'MyToken',
25
- symbol: 'MTK',
26
- ...opts,
27
- })));
28
- });
29
- }
30
-
31
- testERC721('basic', {});
32
-
33
- testERC721('base uri', {
34
- baseUri: 'https://gateway.pinata.cloud/ipfs/QmcP9hxrnC1T5ATPmq2saFeAM1ypFX9BnAswCdHB9JCjLA/',
35
- });
36
-
37
- testERC721('enumerable', {
38
- enumerable: true,
39
- });
40
-
41
- testERC721('uri storage', {
42
- uriStorage: true,
43
- });
44
-
45
- testERC721('mintable + uri storage', {
46
- mintable: true,
47
- uriStorage: true,
48
- });
49
-
50
- testERC721('mintable + uri storage + incremental', {
51
- mintable: true,
52
- uriStorage: true,
53
- incremental: true,
54
- });
55
-
56
- testERC721('burnable', {
57
- burnable: true,
58
- });
59
-
60
- testERC721('burnable + uri storage', {
61
- uriStorage: true,
62
- burnable: true,
63
- });
64
-
65
- testERC721('pausable', {
66
- pausable: true,
67
- });
68
-
69
- testERC721('mintable', {
70
- mintable: true,
71
- });
72
-
73
- testERC721('mintable + roles', {
74
- mintable: true,
75
- access: 'roles',
76
- });
77
-
78
- testERC721('mintable + incremental', {
79
- mintable: true,
80
- incremental: true,
81
- });
82
-
83
- testERC721('votes', {
84
- votes: true,
85
- });
86
-
87
- testERC721('full upgradeable transparent', {
88
- mintable: true,
89
- enumerable: true,
90
- pausable: true,
91
- burnable: true,
92
- votes: true,
93
- upgradeable: 'transparent',
94
- });
95
-
96
- testERC721('full upgradeable uups', {
97
- mintable: true,
98
- enumerable: true,
99
- pausable: true,
100
- burnable: true,
101
- votes: true,
102
- upgradeable: 'uups',
103
- });
104
-
105
- testAPIEquivalence('API default');
106
-
107
- testAPIEquivalence('API basic', { name: 'CustomToken', symbol: 'CTK' });
108
-
109
- testAPIEquivalence('API full upgradeable', {
110
- name: 'CustomToken',
111
- symbol: 'CTK',
112
- mintable: true,
113
- enumerable: true,
114
- pausable: true,
115
- burnable: true,
116
- votes: true,
117
- upgradeable: 'uups',
118
- });
119
-
120
- test('API assert defaults', async t => {
121
- t.is(erc721.print(erc721.defaults), erc721.print());
122
- });
123
-
124
- test('API isAccessControlRequired', async t => {
125
- t.is(erc721.isAccessControlRequired({ mintable: true }), true);
126
- t.is(erc721.isAccessControlRequired({ pausable: true }), true);
127
- t.is(erc721.isAccessControlRequired({ upgradeable: 'uups' }), true);
128
- t.is(erc721.isAccessControlRequired({ upgradeable: 'transparent' }), false);
129
- });