@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,164 +0,0 @@
1
- import test from 'ava';
2
-
3
- import { ContractBuilder } from './contract';
4
- import { printContract } from './print';
5
- import { TAG_SECURITY_CONTACT } from './set-info';
6
-
7
- test('contract basics', t => {
8
- const Foo = new ContractBuilder('Foo');
9
- t.snapshot(printContract(Foo));
10
- });
11
-
12
- test('contract with a parent', t => {
13
- const Foo = new ContractBuilder('Foo');
14
- const Bar = { name: 'Bar', path: './Bar.sol' };
15
- Foo.addParent(Bar);
16
- t.snapshot(printContract(Foo));
17
- });
18
-
19
- test('contract with two parents', t => {
20
- const Foo = new ContractBuilder('Foo');
21
- const Bar = { name: 'Bar', path: './Bar.sol' };
22
- const Quux = { name: 'Quux', path: './Quux.sol' };
23
- Foo.addParent(Bar);
24
- Foo.addParent(Quux);
25
- t.snapshot(printContract(Foo));
26
- });
27
-
28
- test('contract with a parent with parameters', t => {
29
- const Foo = new ContractBuilder('Foo');
30
- const Bar = { name: 'Bar', path: './Bar.sol' };
31
- Foo.addParent(Bar, ["param1", "param2"]);
32
- t.snapshot(printContract(Foo));
33
- });
34
-
35
- test('contract with two parents only one with parameters', t => {
36
- const Foo = new ContractBuilder('Foo');
37
- const Bar = { name: 'Bar', path: './Bar.sol' };
38
- const Quux = { name: 'Quux', path: './Quux.sol' };
39
- Foo.addParent(Bar, ["param1", "param2"]);
40
- Foo.addParent(Quux);
41
- t.snapshot(printContract(Foo));
42
- });
43
-
44
- test('contract with one override', t => {
45
- const Foo = new ContractBuilder('Foo');
46
- const _beforeTokenTransfer = {
47
- name: '_beforeTokenTransfer',
48
- kind: 'internal' as const,
49
- args: [
50
- { name: 'from', type: 'address' },
51
- { name: 'to', type: 'address' },
52
- { name: 'amount', type: 'uint256' },
53
- ],
54
- };
55
- Foo.addOverride('ERC20', _beforeTokenTransfer);
56
- t.snapshot(printContract(Foo));
57
- });
58
-
59
- test('contract with two overrides', t => {
60
- const Foo = new ContractBuilder('Foo');
61
- Foo.addOverride('ERC20', _beforeTokenTransfer);
62
- Foo.addOverride('ERC20Snapshot', _beforeTokenTransfer);
63
- t.snapshot(printContract(Foo));
64
- });
65
-
66
- test('contract with two different overrides', t => {
67
- const Foo = new ContractBuilder('Foo');
68
- Foo.addOverride('ERC20', _beforeTokenTransfer);
69
- Foo.addOverride('OtherParent', _beforeTokenTransfer);
70
- Foo.addOverride('ERC20', _otherFunction);
71
- Foo.addOverride('OtherParent', _otherFunction);
72
- t.snapshot(printContract(Foo));
73
- });
74
-
75
- test('contract with a modifier', t => {
76
- const Foo = new ContractBuilder('Foo');
77
- Foo.addModifier('whenNotPaused', _otherFunction);
78
- t.snapshot(printContract(Foo));
79
- });
80
-
81
- test('contract with a modifier and override', t => {
82
- const Foo = new ContractBuilder('Foo');
83
- Foo.addModifier('whenNotPaused', _otherFunction);
84
- Foo.addOverride('ERC20', _otherFunction);
85
- Foo.addOverride('OtherParent', _otherFunction);
86
- t.snapshot(printContract(Foo));
87
- });
88
-
89
- test('contract with constructor code', t => {
90
- const Foo = new ContractBuilder('Foo');
91
- Foo.addConstructorCode('_mint(msg.sender, 10 ether);');
92
- t.snapshot(printContract(Foo));
93
- });
94
-
95
- test('contract with constructor code and a parent', t => {
96
- const Foo = new ContractBuilder('Foo');
97
- const Bar = { name: 'Bar', path: './Bar.sol' };
98
- Foo.addParent(Bar, ["param1", "param2"]);
99
- Foo.addConstructorCode('_mint(msg.sender, 10 ether);');
100
- t.snapshot(printContract(Foo));
101
- });
102
-
103
- test('contract with function code', t => {
104
- const Foo = new ContractBuilder('Foo');
105
- Foo.addFunctionCode('_mint(msg.sender, 10 ether);', _otherFunction);
106
- t.snapshot(printContract(Foo));
107
- });
108
-
109
- test('contract with overriden function with code', t => {
110
- const Foo = new ContractBuilder('Foo');
111
- Foo.addOverride('Bar', _otherFunction);
112
- Foo.addFunctionCode('_mint(msg.sender, 10 ether);', _otherFunction);
113
- t.snapshot(printContract(Foo));
114
- });
115
-
116
- test('contract with one variable', t => {
117
- const Foo = new ContractBuilder('Foo');
118
- Foo.addVariable('uint value = 42;');
119
- t.snapshot(printContract(Foo));
120
- });
121
-
122
- test('contract with two variables', t => {
123
- const Foo = new ContractBuilder('Foo');
124
- Foo.addVariable('uint value = 42;');
125
- Foo.addVariable('string name = "john";');
126
- t.snapshot(printContract(Foo));
127
- });
128
-
129
- test('name with special characters', t => {
130
- const Foo = new ContractBuilder('foo bar baz');
131
- t.snapshot(printContract(Foo));
132
- });
133
-
134
- test('using for statement', t => {
135
- const Foo = new ContractBuilder('Foo');
136
- Foo.addUsing({
137
- name: 'Counters',
138
- path: './Counters.sol',
139
- }, 'Counters.Counter');
140
- t.snapshot(printContract(Foo));
141
- });
142
-
143
- test('contract with info', t => {
144
- const Foo = new ContractBuilder('Foo');
145
- Foo.addNatspecTag(TAG_SECURITY_CONTACT, 'security@example.com');
146
- t.snapshot(printContract(Foo));
147
- });
148
-
149
-
150
- const _beforeTokenTransfer = {
151
- name: '_beforeTokenTransfer',
152
- kind: 'internal' as const,
153
- args: [
154
- { name: 'from', type: 'address' },
155
- { name: 'to', type: 'address' },
156
- { name: 'amount', type: 'uint256' },
157
- ],
158
- };
159
-
160
- const _otherFunction = {
161
- name: '_otherFunction',
162
- kind: 'internal' as const,
163
- args: [],
164
- };
@@ -1,272 +0,0 @@
1
- # Snapshot report for `src/contract.test.ts`
2
-
3
- The actual snapshot is saved in `contract.test.ts.snap`.
4
-
5
- Generated by [AVA](https://avajs.dev).
6
-
7
- ## contract basics
8
-
9
- > Snapshot 1
10
-
11
- `// SPDX-License-Identifier: MIT␊
12
- pragma solidity ^0.8.4;␊
13
-
14
- contract Foo {␊
15
- }␊
16
- `
17
-
18
- ## contract with a parent
19
-
20
- > Snapshot 1
21
-
22
- `// SPDX-License-Identifier: MIT␊
23
- pragma solidity ^0.8.4;␊
24
-
25
- import "./Bar.sol";␊
26
-
27
- contract Foo is Bar {␊
28
- }␊
29
- `
30
-
31
- ## contract with two parents
32
-
33
- > Snapshot 1
34
-
35
- `// SPDX-License-Identifier: MIT␊
36
- pragma solidity ^0.8.4;␊
37
-
38
- import "./Bar.sol";␊
39
- import "./Quux.sol";␊
40
-
41
- contract Foo is Bar, Quux {␊
42
- }␊
43
- `
44
-
45
- ## contract with a parent with parameters
46
-
47
- > Snapshot 1
48
-
49
- `// SPDX-License-Identifier: MIT␊
50
- pragma solidity ^0.8.4;␊
51
-
52
- import "./Bar.sol";␊
53
-
54
- contract Foo is Bar {␊
55
- constructor() Bar("param1", "param2") {}␊
56
- }␊
57
- `
58
-
59
- ## contract with two parents only one with parameters
60
-
61
- > Snapshot 1
62
-
63
- `// SPDX-License-Identifier: MIT␊
64
- pragma solidity ^0.8.4;␊
65
-
66
- import "./Bar.sol";␊
67
- import "./Quux.sol";␊
68
-
69
- contract Foo is Bar, Quux {␊
70
- constructor() Bar("param1", "param2") {}␊
71
- }␊
72
- `
73
-
74
- ## contract with one override
75
-
76
- > Snapshot 1
77
-
78
- `// SPDX-License-Identifier: MIT␊
79
- pragma solidity ^0.8.4;␊
80
-
81
- contract Foo {␊
82
- }␊
83
- `
84
-
85
- ## contract with two overrides
86
-
87
- > Snapshot 1
88
-
89
- `// SPDX-License-Identifier: MIT␊
90
- pragma solidity ^0.8.4;␊
91
-
92
- contract Foo {␊
93
- // The following functions are overrides required by Solidity.␊
94
-
95
- function _beforeTokenTransfer(address from, address to, uint256 amount)␊
96
- internal␊
97
- override(ERC20, ERC20Snapshot)␊
98
- {␊
99
- super._beforeTokenTransfer(from, to, amount);␊
100
- }␊
101
- }␊
102
- `
103
-
104
- ## contract with two different overrides
105
-
106
- > Snapshot 1
107
-
108
- `// SPDX-License-Identifier: MIT␊
109
- pragma solidity ^0.8.4;␊
110
-
111
- contract Foo {␊
112
- // The following functions are overrides required by Solidity.␊
113
-
114
- function _beforeTokenTransfer(address from, address to, uint256 amount)␊
115
- internal␊
116
- override(ERC20, OtherParent)␊
117
- {␊
118
- super._beforeTokenTransfer(from, to, amount);␊
119
- }␊
120
-
121
- function _otherFunction() internal override(ERC20, OtherParent) {␊
122
- super._otherFunction();␊
123
- }␊
124
- }␊
125
- `
126
-
127
- ## contract with a modifier
128
-
129
- > Snapshot 1
130
-
131
- `// SPDX-License-Identifier: MIT␊
132
- pragma solidity ^0.8.4;␊
133
-
134
- contract Foo {␊
135
- function _otherFunction() internal whenNotPaused {}␊
136
- }␊
137
- `
138
-
139
- ## contract with a modifier and override
140
-
141
- > Snapshot 1
142
-
143
- `// SPDX-License-Identifier: MIT␊
144
- pragma solidity ^0.8.4;␊
145
-
146
- contract Foo {␊
147
- function _otherFunction() internal whenNotPaused override(ERC20, OtherParent) {␊
148
- super._otherFunction();␊
149
- }␊
150
- }␊
151
- `
152
-
153
- ## contract with constructor code
154
-
155
- > Snapshot 1
156
-
157
- `// SPDX-License-Identifier: MIT␊
158
- pragma solidity ^0.8.4;␊
159
-
160
- contract Foo {␊
161
- constructor() {␊
162
- _mint(msg.sender, 10 ether);␊
163
- }␊
164
- }␊
165
- `
166
-
167
- ## contract with constructor code and a parent
168
-
169
- > Snapshot 1
170
-
171
- `// SPDX-License-Identifier: MIT␊
172
- pragma solidity ^0.8.4;␊
173
-
174
- import "./Bar.sol";␊
175
-
176
- contract Foo is Bar {␊
177
- constructor() Bar("param1", "param2") {␊
178
- _mint(msg.sender, 10 ether);␊
179
- }␊
180
- }␊
181
- `
182
-
183
- ## contract with function code
184
-
185
- > Snapshot 1
186
-
187
- `// SPDX-License-Identifier: MIT␊
188
- pragma solidity ^0.8.4;␊
189
-
190
- contract Foo {␊
191
- function _otherFunction() internal {␊
192
- _mint(msg.sender, 10 ether);␊
193
- }␊
194
- }␊
195
- `
196
-
197
- ## contract with overriden function with code
198
-
199
- > Snapshot 1
200
-
201
- `// SPDX-License-Identifier: MIT␊
202
- pragma solidity ^0.8.4;␊
203
-
204
- contract Foo {␊
205
- function _otherFunction() internal override {␊
206
- _mint(msg.sender, 10 ether);␊
207
- super._otherFunction();␊
208
- }␊
209
- }␊
210
- `
211
-
212
- ## contract with one variable
213
-
214
- > Snapshot 1
215
-
216
- `// SPDX-License-Identifier: MIT␊
217
- pragma solidity ^0.8.4;␊
218
-
219
- contract Foo {␊
220
- uint value = 42;␊
221
- }␊
222
- `
223
-
224
- ## contract with two variables
225
-
226
- > Snapshot 1
227
-
228
- `// SPDX-License-Identifier: MIT␊
229
- pragma solidity ^0.8.4;␊
230
-
231
- contract Foo {␊
232
- uint value = 42;␊
233
- string name = "john";␊
234
- }␊
235
- `
236
-
237
- ## name with special characters
238
-
239
- > Snapshot 1
240
-
241
- `// SPDX-License-Identifier: MIT␊
242
- pragma solidity ^0.8.4;␊
243
-
244
- contract FooBarBaz {␊
245
- }␊
246
- `
247
-
248
- ## using for statement
249
-
250
- > Snapshot 1
251
-
252
- `// SPDX-License-Identifier: MIT␊
253
- pragma solidity ^0.8.4;␊
254
-
255
- import "./Counters.sol";␊
256
-
257
- contract Foo {␊
258
- using Counters for Counters.Counter;␊
259
- }␊
260
- `
261
-
262
- ## contract with info
263
-
264
- > Snapshot 1
265
-
266
- `// SPDX-License-Identifier: MIT␊
267
- pragma solidity ^0.8.4;␊
268
-
269
- /// @custom:security-contact security@example.com␊
270
- contract Foo {␊
271
- }␊
272
- `
Binary file
@@ -1,80 +0,0 @@
1
- import test from 'ava';
2
- import { custom } from '.';
3
-
4
- import { buildCustom, CustomOptions } from './custom';
5
- import { printContract } from './print';
6
-
7
- function testCustom(title: string, opts: Partial<CustomOptions>) {
8
- test(title, t => {
9
- const c = buildCustom({
10
- name: 'MyContract',
11
- ...opts,
12
- });
13
- t.snapshot(printContract(c));
14
- });
15
- }
16
-
17
- /**
18
- * Tests external API for equivalence with internal API
19
- */
20
- function testAPIEquivalence(title: string, opts?: CustomOptions) {
21
- test(title, t => {
22
- t.is(custom.print(opts), printContract(buildCustom({
23
- name: 'MyContract',
24
- ...opts,
25
- })));
26
- });
27
- }
28
-
29
- testCustom('custom', {});
30
-
31
- testCustom('pausable', {
32
- pausable: true,
33
- });
34
-
35
- testCustom('upgradeable transparent', {
36
- upgradeable: 'transparent',
37
- });
38
-
39
- testCustom('upgradeable uups', {
40
- upgradeable: 'uups',
41
- });
42
-
43
- testCustom('access control disabled', {
44
- access: false,
45
- });
46
-
47
- testCustom('access control ownable', {
48
- access: 'ownable',
49
- });
50
-
51
- testCustom('access control roles', {
52
- access: 'roles',
53
- });
54
-
55
- testCustom('upgradeable uups with access control disabled', {
56
- // API should override access to true since it is required for UUPS
57
- access: false,
58
- upgradeable: 'uups',
59
- });
60
-
61
- testAPIEquivalence('custom API default');
62
-
63
- testAPIEquivalence('custom API basic', { name: 'CustomContract' });
64
-
65
- testAPIEquivalence('custom API full upgradeable', {
66
- name: 'CustomContract',
67
- access: 'roles',
68
- pausable: true,
69
- upgradeable: 'uups',
70
- });
71
-
72
- test('custom API assert defaults', async t => {
73
- t.is(custom.print(custom.defaults), custom.print());
74
- });
75
-
76
- test('API isAccessControlRequired', async t => {
77
- t.is(custom.isAccessControlRequired({ pausable: true }), true);
78
- t.is(custom.isAccessControlRequired({ upgradeable: 'uups' }), true);
79
- t.is(custom.isAccessControlRequired({ upgradeable: 'transparent' }), false);
80
- });
@@ -1,154 +0,0 @@
1
- # Snapshot report for `src/custom.test.ts`
2
-
3
- The actual snapshot is saved in `custom.test.ts.snap`.
4
-
5
- Generated by [AVA](https://avajs.dev).
6
-
7
- ## custom
8
-
9
- > Snapshot 1
10
-
11
- `// SPDX-License-Identifier: MIT␊
12
- pragma solidity ^0.8.4;␊
13
-
14
- contract MyContract {␊
15
- }␊
16
- `
17
-
18
- ## pausable
19
-
20
- > Snapshot 1
21
-
22
- `// SPDX-License-Identifier: MIT␊
23
- pragma solidity ^0.8.4;␊
24
-
25
- import "@openzeppelin/contracts/security/Pausable.sol";␊
26
- import "@openzeppelin/contracts/access/Ownable.sol";␊
27
-
28
- contract MyContract is Pausable, Ownable {␊
29
- function pause() public onlyOwner {␊
30
- _pause();␊
31
- }␊
32
-
33
- function unpause() public onlyOwner {␊
34
- _unpause();␊
35
- }␊
36
- }␊
37
- `
38
-
39
- ## upgradeable transparent
40
-
41
- > Snapshot 1
42
-
43
- `// SPDX-License-Identifier: MIT␊
44
- pragma solidity ^0.8.4;␊
45
-
46
- import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";␊
47
-
48
- contract MyContract is Initializable {␊
49
- /// @custom:oz-upgrades-unsafe-allow constructor␊
50
- constructor() {␊
51
- _disableInitializers();␊
52
- }␊
53
- }␊
54
- `
55
-
56
- ## upgradeable uups
57
-
58
- > Snapshot 1
59
-
60
- `// SPDX-License-Identifier: MIT␊
61
- pragma solidity ^0.8.4;␊
62
-
63
- import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";␊
64
- import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";␊
65
- import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";␊
66
-
67
- contract MyContract is Initializable, OwnableUpgradeable, UUPSUpgradeable {␊
68
- /// @custom:oz-upgrades-unsafe-allow constructor␊
69
- constructor() {␊
70
- _disableInitializers();␊
71
- }␊
72
-
73
- function initialize() initializer public {␊
74
- __Ownable_init();␊
75
- __UUPSUpgradeable_init();␊
76
- }␊
77
-
78
- function _authorizeUpgrade(address newImplementation)␊
79
- internal␊
80
- onlyOwner␊
81
- override␊
82
- {}␊
83
- }␊
84
- `
85
-
86
- ## access control disabled
87
-
88
- > Snapshot 1
89
-
90
- `// SPDX-License-Identifier: MIT␊
91
- pragma solidity ^0.8.4;␊
92
-
93
- contract MyContract {␊
94
- }␊
95
- `
96
-
97
- ## access control ownable
98
-
99
- > Snapshot 1
100
-
101
- `// SPDX-License-Identifier: MIT␊
102
- pragma solidity ^0.8.4;␊
103
-
104
- import "@openzeppelin/contracts/access/Ownable.sol";␊
105
-
106
- contract MyContract is Ownable {␊
107
- }␊
108
- `
109
-
110
- ## access control roles
111
-
112
- > Snapshot 1
113
-
114
- `// SPDX-License-Identifier: MIT␊
115
- pragma solidity ^0.8.4;␊
116
-
117
- import "@openzeppelin/contracts/access/AccessControl.sol";␊
118
-
119
- contract MyContract is AccessControl {␊
120
- constructor() {␊
121
- _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);␊
122
- }␊
123
- }␊
124
- `
125
-
126
- ## upgradeable uups with access control disabled
127
-
128
- > Snapshot 1
129
-
130
- `// SPDX-License-Identifier: MIT␊
131
- pragma solidity ^0.8.4;␊
132
-
133
- import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";␊
134
- import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";␊
135
- import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";␊
136
-
137
- contract MyContract is Initializable, OwnableUpgradeable, UUPSUpgradeable {␊
138
- /// @custom:oz-upgrades-unsafe-allow constructor␊
139
- constructor() {␊
140
- _disableInitializers();␊
141
- }␊
142
-
143
- function initialize() initializer public {␊
144
- __Ownable_init();␊
145
- __UUPSUpgradeable_init();␊
146
- }␊
147
-
148
- function _authorizeUpgrade(address newImplementation)␊
149
- internal␊
150
- onlyOwner␊
151
- override␊
152
- {}␊
153
- }␊
154
- `
Binary file