@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.
- package/CHANGELOG.md +18 -0
- package/README.md +2 -0
- package/dist/api.d.ts +5 -5
- package/dist/api.d.ts.map +1 -1
- package/dist/build-generic.d.ts +1 -1
- package/dist/build-generic.d.ts.map +1 -1
- package/dist/contract.d.ts +3 -3
- package/dist/contract.d.ts.map +1 -1
- package/dist/environments/hardhat/package-lock.json +15204 -0
- package/dist/environments/hardhat/package.json +34 -0
- package/dist/environments/hardhat/upgradeable/package-lock.json +15588 -0
- package/dist/environments/hardhat/upgradeable/package.json +35 -0
- package/dist/erc1155.js +1 -1
- package/dist/erc1155.js.map +1 -1
- package/dist/erc721.js +2 -0
- package/dist/erc721.js.map +1 -1
- package/dist/error.d.ts +1 -1
- package/dist/error.d.ts.map +1 -1
- package/dist/generate/alternatives.d.ts +2 -2
- package/dist/generate/alternatives.d.ts.map +1 -1
- package/dist/generate/sources.d.ts +1 -1
- package/dist/generate/sources.d.ts.map +1 -1
- package/dist/governor.d.ts +2 -2
- package/dist/governor.d.ts.map +1 -1
- package/dist/governor.js +1 -1
- package/dist/governor.js.map +1 -1
- package/dist/kind.d.ts +1 -1
- package/dist/kind.d.ts.map +1 -1
- package/dist/print-versioned.js +5 -2
- package/dist/print-versioned.js.map +1 -1
- package/dist/print.d.ts.map +1 -1
- package/dist/print.js +5 -2
- package/dist/print.js.map +1 -1
- package/dist/set-access-control.d.ts +1 -1
- package/dist/set-access-control.d.ts.map +1 -1
- package/dist/set-info.d.ts +1 -1
- package/dist/set-info.d.ts.map +1 -1
- package/dist/set-upgradeable.d.ts +1 -1
- package/dist/set-upgradeable.d.ts.map +1 -1
- package/dist/solidity-version.json +1 -0
- package/dist/utils/define-functions.d.ts +1 -1
- package/dist/utils/define-functions.d.ts.map +1 -1
- package/dist/utils/format-lines.d.ts +2 -1
- package/dist/utils/format-lines.d.ts.map +1 -1
- package/dist/utils/format-lines.js +9 -5
- package/dist/utils/format-lines.js.map +1 -1
- package/dist/utils/transitive-closure.d.ts +1 -1
- package/dist/utils/transitive-closure.d.ts.map +1 -1
- package/dist/zip-hardhat.d.ts +5 -0
- package/dist/zip-hardhat.d.ts.map +1 -0
- package/dist/zip-hardhat.js +187 -0
- package/dist/zip-hardhat.js.map +1 -0
- package/dist/zip.js +1 -1
- package/dist/zip.js.map +1 -1
- package/package.json +9 -7
- package/src/.DS_Store +0 -0
- package/src/environments/.DS_Store +0 -0
- package/src/environments/hardhat/.DS_Store +0 -0
- package/src/environments/hardhat/package-lock.json +15204 -0
- package/src/environments/hardhat/package.json +34 -0
- package/src/environments/hardhat/upgradeable/package-lock.json +15588 -0
- package/src/environments/hardhat/upgradeable/package.json +35 -0
- package/src/erc1155.ts +1 -1
- package/src/erc721.ts +2 -0
- package/src/governor.ts +1 -1
- package/src/print-versioned.ts +2 -2
- package/src/print.ts +1 -2
- package/src/solidity-version.json +1 -0
- package/src/utils/format-lines.ts +8 -3
- package/src/zip-hardhat.ts +186 -0
- package/src/zip.ts +1 -1
- package/dist/contract.test.d.ts +0 -2
- package/dist/contract.test.d.ts.map +0 -1
- package/dist/contract.test.js +0 -147
- package/dist/contract.test.js.map +0 -1
- package/dist/custom.test.d.ts +0 -2
- package/dist/custom.test.d.ts.map +0 -1
- package/dist/custom.test.js +0 -70
- package/dist/custom.test.js.map +0 -1
- package/dist/erc1155.test.d.ts +0 -2
- package/dist/erc1155.test.d.ts.map +0 -1
- package/dist/erc1155.test.js +0 -91
- package/dist/erc1155.test.js.map +0 -1
- package/dist/erc20.test.d.ts +0 -2
- package/dist/erc20.test.d.ts.map +0 -1
- package/dist/erc20.test.js +0 -133
- package/dist/erc20.test.js.map +0 -1
- package/dist/erc721.test.d.ts +0 -2
- package/dist/erc721.test.d.ts.map +0 -1
- package/dist/erc721.test.js +0 -112
- package/dist/erc721.test.js.map +0 -1
- package/dist/governor.test.d.ts +0 -2
- package/dist/governor.test.d.ts.map +0 -1
- package/dist/governor.test.js +0 -108
- package/dist/governor.test.js.map +0 -1
- package/dist/utils/to-identifier.test.d.ts +0 -2
- package/dist/utils/to-identifier.test.d.ts.map +0 -1
- package/dist/utils/to-identifier.test.js +0 -21
- package/dist/utils/to-identifier.test.js.map +0 -1
- package/dist/zip.test.d.ts +0 -2
- package/dist/zip.test.d.ts.map +0 -1
- package/dist/zip.test.js +0 -37
- package/dist/zip.test.js.map +0 -1
- package/src/contract.test.ts +0 -164
- package/src/contract.test.ts.md +0 -272
- package/src/contract.test.ts.snap +0 -0
- package/src/custom.test.ts +0 -80
- package/src/custom.test.ts.md +0 -154
- package/src/custom.test.ts.snap +0 -0
- package/src/erc1155.test.ts +0 -103
- package/src/erc1155.test.ts.md +0 -432
- package/src/erc1155.test.ts.snap +0 -0
- package/src/erc20.test.ts +0 -152
- package/src/erc20.test.ts.md +0 -571
- package/src/erc20.test.ts.snap +0 -0
- package/src/erc721.test.ts +0 -129
- package/src/erc721.test.ts.md +0 -517
- package/src/erc721.test.ts.snap +0 -0
- package/src/governor.test.ts +0 -125
- package/src/governor.test.ts.md +0 -1419
- package/src/governor.test.ts.snap +0 -0
- package/src/utils/to-identifier.test.ts +0 -20
- package/src/zip.test.ts +0 -35
package/src/contract.test.ts
DELETED
|
@@ -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
|
-
};
|
package/src/contract.test.ts.md
DELETED
|
@@ -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
|
package/src/custom.test.ts
DELETED
|
@@ -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
|
-
});
|
package/src/custom.test.ts.md
DELETED
|
@@ -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
|
-
`
|
package/src/custom.test.ts.snap
DELETED
|
Binary file
|