@openzeppelin/wizard 0.3.0 → 0.4.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/dist/add-pausable.d.ts +1 -0
- package/dist/add-pausable.d.ts.map +1 -1
- package/dist/add-pausable.js +9 -5
- package/dist/add-pausable.js.map +1 -1
- package/dist/contract.d.ts +13 -9
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +5 -5
- package/dist/contract.js.map +1 -1
- package/dist/environments/hardhat/package-lock.json +1488 -7247
- package/dist/environments/hardhat/package.json +4 -22
- package/dist/environments/hardhat/upgradeable/package-lock.json +1674 -7722
- package/dist/environments/hardhat/upgradeable/package.json +5 -22
- package/dist/erc1155.js +24 -15
- package/dist/erc1155.js.map +1 -1
- package/dist/erc20.d.ts +0 -1
- package/dist/erc20.d.ts.map +1 -1
- package/dist/erc20.js +45 -62
- package/dist/erc20.js.map +1 -1
- package/dist/erc721.js +54 -53
- package/dist/erc721.js.map +1 -1
- package/dist/generate/erc20.d.ts.map +1 -1
- package/dist/generate/erc20.js +0 -1
- package/dist/generate/erc20.js.map +1 -1
- package/dist/generate/governor.js +1 -1
- package/dist/generate/governor.js.map +1 -1
- package/dist/governor.d.ts +2 -2
- package/dist/governor.d.ts.map +1 -1
- package/dist/governor.js +104 -98
- package/dist/governor.js.map +1 -1
- package/dist/infer-transpiled.d.ts +3 -0
- package/dist/infer-transpiled.d.ts.map +1 -0
- package/dist/infer-transpiled.js +9 -0
- package/dist/infer-transpiled.js.map +1 -0
- package/dist/options.d.ts +3 -4
- package/dist/options.d.ts.map +1 -1
- package/dist/options.js +14 -11
- package/dist/options.js.map +1 -1
- package/dist/print-versioned.d.ts.map +1 -1
- package/dist/print-versioned.js +6 -1
- package/dist/print-versioned.js.map +1 -1
- package/dist/print.d.ts.map +1 -1
- package/dist/print.js +17 -9
- package/dist/print.js.map +1 -1
- package/dist/scripts/prepare.js +0 -1
- package/dist/scripts/prepare.js.map +1 -1
- package/dist/set-access-control.d.ts +2 -2
- package/dist/set-access-control.d.ts.map +1 -1
- package/dist/set-access-control.js +36 -8
- package/dist/set-access-control.js.map +1 -1
- package/dist/set-upgradeable.d.ts.map +1 -1
- package/dist/set-upgradeable.js +5 -4
- package/dist/set-upgradeable.js.map +1 -1
- package/dist/solidity-version.json +1 -1
- package/dist/zip-foundry.d.ts +5 -0
- package/dist/zip-foundry.d.ts.map +1 -0
- package/dist/zip-foundry.js +224 -0
- package/dist/zip-foundry.js.map +1 -0
- package/dist/zip-hardhat.d.ts.map +1 -1
- package/dist/zip-hardhat.js +36 -11
- package/dist/zip-hardhat.js.map +1 -1
- package/package.json +3 -4
- package/src/add-pausable.ts +7 -3
- package/src/contract.ts +17 -15
- package/src/environments/hardhat/package-lock.json +1488 -7247
- package/src/environments/hardhat/package.json +4 -22
- package/src/environments/hardhat/upgradeable/package-lock.json +1674 -7722
- package/src/environments/hardhat/upgradeable/package.json +5 -22
- package/src/erc1155.ts +30 -23
- package/src/erc20.ts +46 -67
- package/src/erc721.ts +64 -66
- package/src/generate/erc20.ts +0 -1
- package/src/generate/governor.ts +1 -1
- package/src/governor.ts +110 -109
- package/src/infer-transpiled.ts +5 -0
- package/src/options.ts +18 -16
- package/src/print-versioned.ts +6 -2
- package/src/print.ts +17 -13
- package/src/scripts/prepare.ts +0 -2
- package/src/set-access-control.ts +36 -8
- package/src/set-upgradeable.ts +5 -4
- package/src/solidity-version.json +1 -1
- package/src/zip-foundry.ts +259 -0
- package/src/zip-hardhat.ts +39 -11
- package/CHANGELOG.md +0 -30
- package/dist/zip.d.ts +0 -4
- package/dist/zip.d.ts.map +0 -1
- package/dist/zip.js +0 -48
- package/dist/zip.js.map +0 -1
- package/src/.DS_Store +0 -0
- package/src/environments/.DS_Store +0 -0
- package/src/environments/hardhat/.DS_Store +0 -0
- package/src/zip.ts +0 -53
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import JSZip from "jszip";
|
|
2
|
+
import type { GenericOptions } from "./build-generic";
|
|
3
|
+
import type { Contract } from "./contract";
|
|
4
|
+
import { printContract } from "./print";
|
|
5
|
+
import SOLIDITY_VERSION from './solidity-version.json';
|
|
6
|
+
import contracts from '../openzeppelin-contracts';
|
|
7
|
+
import { formatLinesWithSpaces, Lines, spaceBetween } from "./utils/format-lines";
|
|
8
|
+
|
|
9
|
+
function getHeader(c: Contract) {
|
|
10
|
+
return [
|
|
11
|
+
`// SPDX-License-Identifier: ${c.license}`,
|
|
12
|
+
`pragma solidity ^${SOLIDITY_VERSION};`
|
|
13
|
+
];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const test = (c: Contract, opts?: GenericOptions) => {
|
|
17
|
+
return formatLinesWithSpaces(
|
|
18
|
+
2,
|
|
19
|
+
...spaceBetween(
|
|
20
|
+
getHeader(c),
|
|
21
|
+
getImports(c),
|
|
22
|
+
getTestCase(c),
|
|
23
|
+
),
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
function getImports(c: Contract) {
|
|
27
|
+
return [
|
|
28
|
+
'import "forge-std/Test.sol";',
|
|
29
|
+
`import "../src/${c.name}.sol";`,
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function getTestCase(c: Contract) {
|
|
34
|
+
const args = getAddressArgs(c);
|
|
35
|
+
return [
|
|
36
|
+
`contract ${c.name}Test is Test {`,
|
|
37
|
+
spaceBetween(
|
|
38
|
+
[
|
|
39
|
+
`${c.name} public instance;`,
|
|
40
|
+
],
|
|
41
|
+
[
|
|
42
|
+
'function setUp() public {',
|
|
43
|
+
getAddressVariables(args),
|
|
44
|
+
[
|
|
45
|
+
`instance = new ${getDeploymentCall(c, args)};`,
|
|
46
|
+
],
|
|
47
|
+
'}',
|
|
48
|
+
],
|
|
49
|
+
getContractSpecificTestFunction(),
|
|
50
|
+
),
|
|
51
|
+
'}',
|
|
52
|
+
];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function getAddressVariables(args: string[]): Lines[] {
|
|
56
|
+
const vars = [];
|
|
57
|
+
for (let i = 0; i < args.length; i++) {
|
|
58
|
+
// use i + 1 as the private key since it must be non-zero
|
|
59
|
+
vars.push(`address ${args[i]} = vm.addr(${i + 1});`);
|
|
60
|
+
}
|
|
61
|
+
return vars;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function getContractSpecificTestFunction(): Lines[] {
|
|
65
|
+
if (opts !== undefined) {
|
|
66
|
+
switch (opts.kind) {
|
|
67
|
+
case 'ERC20':
|
|
68
|
+
case 'ERC721':
|
|
69
|
+
return [
|
|
70
|
+
'function testName() public {',
|
|
71
|
+
[
|
|
72
|
+
`assertEq(instance.name(), "${opts.name}");`
|
|
73
|
+
],
|
|
74
|
+
'}',
|
|
75
|
+
];
|
|
76
|
+
|
|
77
|
+
case 'ERC1155':
|
|
78
|
+
return [
|
|
79
|
+
'function testUri() public {',
|
|
80
|
+
[
|
|
81
|
+
`assertEq(instance.uri(0), "${opts.uri}");`
|
|
82
|
+
],
|
|
83
|
+
'}',
|
|
84
|
+
];
|
|
85
|
+
|
|
86
|
+
case 'Governor':
|
|
87
|
+
case 'Custom':
|
|
88
|
+
return [
|
|
89
|
+
'function testSomething() public {',
|
|
90
|
+
[
|
|
91
|
+
'// Add your test here',
|
|
92
|
+
],
|
|
93
|
+
'}',
|
|
94
|
+
]
|
|
95
|
+
|
|
96
|
+
default:
|
|
97
|
+
throw new Error('Unknown ERC');
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return [];
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
function getAddressArgs(c: Contract): string[] {
|
|
105
|
+
const args = [];
|
|
106
|
+
for (const constructorArg of c.constructorArgs) {
|
|
107
|
+
if (constructorArg.type === 'address') {
|
|
108
|
+
args.push(constructorArg.name);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return args;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function getDeploymentCall(c: Contract, args: string[]): string {
|
|
115
|
+
return `${c.name}(${args.join(', ')})`;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const script = (c: Contract) => {
|
|
119
|
+
return formatLinesWithSpaces(
|
|
120
|
+
2,
|
|
121
|
+
...spaceBetween(
|
|
122
|
+
getHeader(c),
|
|
123
|
+
getImports(c),
|
|
124
|
+
getScript(c),
|
|
125
|
+
),
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
function getImports(c: Contract) {
|
|
129
|
+
return [
|
|
130
|
+
'import "forge-std/Script.sol";',
|
|
131
|
+
`import "../src/${c.name}.sol";`,
|
|
132
|
+
];
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function getScript(c: Contract) {
|
|
136
|
+
const args = getAddressArgs(c);
|
|
137
|
+
const deploymentLines = [
|
|
138
|
+
'vm.startBroadcast();',
|
|
139
|
+
`${c.name} instance = new ${getDeploymentCall(c, args)};`,
|
|
140
|
+
'console.log("Contract deployed to %s", address(instance));',
|
|
141
|
+
'vm.stopBroadcast();',
|
|
142
|
+
];
|
|
143
|
+
return [
|
|
144
|
+
`contract ${c.name}Script is Script {`,
|
|
145
|
+
spaceBetween(
|
|
146
|
+
[
|
|
147
|
+
'function setUp() public {}',
|
|
148
|
+
],
|
|
149
|
+
[
|
|
150
|
+
'function run() public {',
|
|
151
|
+
args.length > 0 ? addTodoAndCommentOut(deploymentLines) : deploymentLines,
|
|
152
|
+
'}',
|
|
153
|
+
],
|
|
154
|
+
),
|
|
155
|
+
'}',
|
|
156
|
+
];
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function addTodoAndCommentOut(lines: string[]) {
|
|
160
|
+
return [
|
|
161
|
+
'// TODO: Set addresses for the contract arguments below, then uncomment the following lines',
|
|
162
|
+
...lines.map(l => `// ${l}`),
|
|
163
|
+
];
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const setupSh = `\
|
|
168
|
+
#!/usr/bin/env bash
|
|
169
|
+
|
|
170
|
+
# Check if git is installed
|
|
171
|
+
if ! which git &> /dev/null
|
|
172
|
+
then
|
|
173
|
+
echo "git command not found. Install git and try again."
|
|
174
|
+
exit 1
|
|
175
|
+
fi
|
|
176
|
+
|
|
177
|
+
# Check if Foundry is installed
|
|
178
|
+
if ! which forge &> /dev/null
|
|
179
|
+
then
|
|
180
|
+
echo "forge command not found. Install Foundry and try again. See https://book.getfoundry.sh/getting-started/installation"
|
|
181
|
+
exit 1
|
|
182
|
+
fi
|
|
183
|
+
|
|
184
|
+
# Setup Foundry project
|
|
185
|
+
if ! [ -f "foundry.toml" ]
|
|
186
|
+
then
|
|
187
|
+
echo "Initializing Foundry project..."
|
|
188
|
+
|
|
189
|
+
# Initialize sample Foundry project
|
|
190
|
+
forge init --force --no-commit --quiet
|
|
191
|
+
|
|
192
|
+
# Install OpenZeppelin Contracts
|
|
193
|
+
forge install OpenZeppelin/openzeppelin-contracts@v${contracts.version} --no-commit --quiet
|
|
194
|
+
|
|
195
|
+
# Remove template contracts
|
|
196
|
+
rm src/Counter.sol
|
|
197
|
+
rm script/Counter.s.sol
|
|
198
|
+
rm test/Counter.t.sol
|
|
199
|
+
|
|
200
|
+
# Add remappings
|
|
201
|
+
if [ -f "remappings.txt" ]
|
|
202
|
+
then
|
|
203
|
+
echo "" >> remappings.txt
|
|
204
|
+
fi
|
|
205
|
+
echo "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/" >> remappings.txt
|
|
206
|
+
|
|
207
|
+
# Perform initial git commit
|
|
208
|
+
git add .
|
|
209
|
+
git commit -m "openzeppelin: add wizard output" --quiet
|
|
210
|
+
|
|
211
|
+
echo "Done."
|
|
212
|
+
else
|
|
213
|
+
echo "Foundry project already initialized."
|
|
214
|
+
fi
|
|
215
|
+
`;
|
|
216
|
+
|
|
217
|
+
const readme = (c: Contract) => `\
|
|
218
|
+
# Sample Foundry Project
|
|
219
|
+
|
|
220
|
+
This project demonstrates a basic Foundry use case. It comes with a contract generated by [OpenZeppelin Wizard](https://wizard.openzeppelin.com/), a test for that contract, and a script that deploys that contract.
|
|
221
|
+
|
|
222
|
+
## Installing Foundry
|
|
223
|
+
|
|
224
|
+
See [Foundry installation guide](https://book.getfoundry.sh/getting-started/installation).
|
|
225
|
+
|
|
226
|
+
## Initializing the project
|
|
227
|
+
|
|
228
|
+
\`\`\`
|
|
229
|
+
bash setup.sh
|
|
230
|
+
\`\`\`
|
|
231
|
+
|
|
232
|
+
## Testing the contract
|
|
233
|
+
|
|
234
|
+
\`\`\`
|
|
235
|
+
forge test
|
|
236
|
+
\`\`\`
|
|
237
|
+
|
|
238
|
+
## Deploying the contract
|
|
239
|
+
|
|
240
|
+
You can simulate a deployment by running the script:
|
|
241
|
+
|
|
242
|
+
\`\`\`
|
|
243
|
+
forge script script/${c.name}.s.sol
|
|
244
|
+
\`\`\`
|
|
245
|
+
|
|
246
|
+
See [Solidity scripting guide](https://book.getfoundry.sh/tutorials/solidity-scripting) for more information.
|
|
247
|
+
`;
|
|
248
|
+
|
|
249
|
+
export async function zipFoundry(c: Contract, opts?: GenericOptions) {
|
|
250
|
+
const zip = new JSZip();
|
|
251
|
+
|
|
252
|
+
zip.file(`src/${c.name}.sol`, printContract(c));
|
|
253
|
+
zip.file(`test/${c.name}.t.sol`, test(c, opts));
|
|
254
|
+
zip.file(`script/${c.name}.s.sol`, script(c));
|
|
255
|
+
zip.file('setup.sh', setupSh);
|
|
256
|
+
zip.file('README.md', readme(c));
|
|
257
|
+
|
|
258
|
+
return zip;
|
|
259
|
+
}
|
package/src/zip-hardhat.ts
CHANGED
|
@@ -32,7 +32,8 @@ const tsConfig = `\
|
|
|
32
32
|
"esModuleInterop": true,
|
|
33
33
|
"forceConsistentCasingInFileNames": true,
|
|
34
34
|
"strict": true,
|
|
35
|
-
"skipLibCheck": true
|
|
35
|
+
"skipLibCheck": true,
|
|
36
|
+
"resolveJsonModule": true
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
`;
|
|
@@ -45,7 +46,7 @@ coverage.json
|
|
|
45
46
|
typechain
|
|
46
47
|
typechain-types
|
|
47
48
|
|
|
48
|
-
#Hardhat files
|
|
49
|
+
# Hardhat files
|
|
49
50
|
cache
|
|
50
51
|
artifacts
|
|
51
52
|
`;
|
|
@@ -60,6 +61,7 @@ const test = (c: Contract, opts?: GenericOptions) => {
|
|
|
60
61
|
);
|
|
61
62
|
|
|
62
63
|
function getTestCase(c: Contract) {
|
|
64
|
+
const args = getAddressArgs(c);
|
|
63
65
|
return [
|
|
64
66
|
`describe("${c.name}", function () {`,
|
|
65
67
|
[
|
|
@@ -68,11 +70,12 @@ const test = (c: Contract, opts?: GenericOptions) => {
|
|
|
68
70
|
[
|
|
69
71
|
`const ContractFactory = await ethers.getContractFactory("${c.name}");`,
|
|
70
72
|
],
|
|
73
|
+
getAddressVariables(args),
|
|
71
74
|
[
|
|
72
|
-
`const instance = await ${c
|
|
73
|
-
'await instance.
|
|
75
|
+
`const instance = await ${getDeploymentCall(c, args)};`,
|
|
76
|
+
'await instance.waitForDeployment();'
|
|
74
77
|
],
|
|
75
|
-
|
|
78
|
+
getExpects(),
|
|
76
79
|
),
|
|
77
80
|
'});'
|
|
78
81
|
],
|
|
@@ -87,7 +90,7 @@ const test = (c: Contract, opts?: GenericOptions) => {
|
|
|
87
90
|
];
|
|
88
91
|
}
|
|
89
92
|
|
|
90
|
-
function
|
|
93
|
+
function getExpects(): Lines[] {
|
|
91
94
|
if (opts !== undefined) {
|
|
92
95
|
switch (opts.kind) {
|
|
93
96
|
case 'ERC20':
|
|
@@ -107,18 +110,43 @@ const test = (c: Contract, opts?: GenericOptions) => {
|
|
|
107
110
|
}
|
|
108
111
|
return [];
|
|
109
112
|
}
|
|
113
|
+
|
|
114
|
+
function getAddressVariables(args: string[]): Lines[] {
|
|
115
|
+
const vars = [];
|
|
116
|
+
for (let i = 0; i < args.length; i++) {
|
|
117
|
+
vars.push(`const ${args[i]} = (await ethers.getSigners())[${i}].address;`);
|
|
118
|
+
}
|
|
119
|
+
return vars;
|
|
120
|
+
}
|
|
110
121
|
};
|
|
111
122
|
|
|
112
|
-
|
|
123
|
+
function getAddressArgs(c: Contract): string[] {
|
|
124
|
+
const args = [];
|
|
125
|
+
for (const constructorArg of c.constructorArgs) {
|
|
126
|
+
if (constructorArg.type === 'address') {
|
|
127
|
+
args.push(constructorArg.name);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return args;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function getDeploymentCall(c: Contract, args: string[]): string {
|
|
134
|
+
return c.upgradeable ? `upgrades.deployProxy(ContractFactory, [${args.join(', ')}])` : `ContractFactory.deploy(${args.join(', ')})`;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const script = (c: Contract) => {
|
|
138
|
+
const args = getAddressArgs(c);
|
|
139
|
+
return `\
|
|
113
140
|
import { ${getHardhatPlugins(c).join(', ')} } from "hardhat";
|
|
114
141
|
|
|
115
142
|
async function main() {
|
|
116
143
|
const ContractFactory = await ethers.getContractFactory("${c.name}");
|
|
117
144
|
|
|
118
|
-
|
|
119
|
-
await
|
|
145
|
+
${args.length > 0 ? '// TODO: Set addresses for the contract arguments below' : ''}
|
|
146
|
+
const instance = await ${getDeploymentCall(c, args)};
|
|
147
|
+
await instance.waitForDeployment();
|
|
120
148
|
|
|
121
|
-
console.log(\`${c.upgradeable ? 'Proxy' : 'Contract'} deployed to \${instance.
|
|
149
|
+
console.log(\`${c.upgradeable ? 'Proxy' : 'Contract'} deployed to \${await instance.getAddress()}\`);
|
|
122
150
|
}
|
|
123
151
|
|
|
124
152
|
// We recommend this pattern to be able to use async/await everywhere
|
|
@@ -127,7 +155,7 @@ main().catch((error) => {
|
|
|
127
155
|
console.error(error);
|
|
128
156
|
process.exitCode = 1;
|
|
129
157
|
});
|
|
130
|
-
|
|
158
|
+
`};
|
|
131
159
|
|
|
132
160
|
const readme = `\
|
|
133
161
|
# Sample Hardhat Project
|
package/CHANGELOG.md
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
## 0.3.0 (2023-05-25)
|
|
4
|
-
|
|
5
|
-
- **Breaking change**: Update to OpenZeppelin Contracts 4.9. ([#252](https://github.com/OpenZeppelin/contracts-wizard/pull/252))
|
|
6
|
-
|
|
7
|
-
## 0.2.3 (2023-03-23)
|
|
8
|
-
|
|
9
|
-
- Fix module not found error. ([#235](https://github.com/OpenZeppelin/contracts-wizard/issues/235))
|
|
10
|
-
|
|
11
|
-
## 0.2.2 (2023-03-17)
|
|
12
|
-
|
|
13
|
-
- Fix missing file. ([#234](https://github.com/OpenZeppelin/contracts-wizard/pull/234))
|
|
14
|
-
|
|
15
|
-
## 0.2.1 (2023-03-17)
|
|
16
|
-
|
|
17
|
-
- Remove unspecified dependency on `@openzeppelin/contracts`. ([#233](https://github.com/OpenZeppelin/contracts-wizard/pull/233))
|
|
18
|
-
|
|
19
|
-
## 0.2.0 (2022-11-08)
|
|
20
|
-
|
|
21
|
-
- Reduce default block time to 12 seconds in `governor`. ([fdcf912](https://github.com/OpenZeppelin/contracts-wizard/commit/fdcf9129354692b3b7e0fa694233fdd62a1e99bb))
|
|
22
|
-
- **Breaking change**: Update to OpenZeppelin Contracts 4.8 and Solidity ^0.8.9. ([#199](https://github.com/OpenZeppelin/contracts-wizard/pull/199))
|
|
23
|
-
|
|
24
|
-
## 0.1.1 (2022-06-30)
|
|
25
|
-
|
|
26
|
-
- Support custom contract type, optional access control. ([#112](https://github.com/OpenZeppelin/contracts-wizard/pull/112))
|
|
27
|
-
|
|
28
|
-
## 0.1.0 (2022-06-15)
|
|
29
|
-
|
|
30
|
-
- Initial API for Solidity. ([#136](https://github.com/OpenZeppelin/contracts-wizard/pull/136))
|
package/dist/zip.d.ts
DELETED
package/dist/zip.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"zip.d.ts","sourceRoot":"","sources":["../src/zip.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,QAAQ,EAA8C,MAAM,YAAY,CAAC;AAsBvF,wBAAgB,WAAW,CAAC,CAAC,EAAE,QAAQ,GAAG,KAAK,CA4B9C"}
|
package/dist/zip.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.zipContract = void 0;
|
|
7
|
-
const jszip_1 = __importDefault(require("jszip"));
|
|
8
|
-
const print_1 = require("./print");
|
|
9
|
-
const transitive_closure_1 = require("./utils/transitive-closure");
|
|
10
|
-
const openzeppelin_contracts_1 = __importDefault(require("../openzeppelin-contracts"));
|
|
11
|
-
const options_1 = require("./options");
|
|
12
|
-
const readme = (variant) => `\
|
|
13
|
-
# OpenZeppelin Contracts
|
|
14
|
-
|
|
15
|
-
The files in this directory were sourced unmodified from OpenZeppelin Contracts v${openzeppelin_contracts_1.default.version}.
|
|
16
|
-
|
|
17
|
-
They are not meant to be edited.
|
|
18
|
-
|
|
19
|
-
The originals can be found on [GitHub] and [npm].
|
|
20
|
-
|
|
21
|
-
[GitHub]: https://github.com/OpenZeppelin/openzeppelin-contracts${variant}/tree/v${openzeppelin_contracts_1.default.version}
|
|
22
|
-
[npm]: https://www.npmjs.com/package/@openzeppelin/contracts${variant}/v/${openzeppelin_contracts_1.default.version}
|
|
23
|
-
|
|
24
|
-
Generated with OpenZeppelin Contracts Wizard (https://zpl.in/wizard).
|
|
25
|
-
`;
|
|
26
|
-
function zipContract(c) {
|
|
27
|
-
const { transformImport } = (0, options_1.withHelpers)(c);
|
|
28
|
-
const contractsVariant = c.upgradeable ? '-upgradeable' : '';
|
|
29
|
-
const fileName = c.name + '.sol';
|
|
30
|
-
const dependencies = {
|
|
31
|
-
[fileName]: c.imports.map(i => transformImport(i)),
|
|
32
|
-
...openzeppelin_contracts_1.default.dependencies,
|
|
33
|
-
};
|
|
34
|
-
const allImports = (0, transitive_closure_1.reachable)(dependencies, fileName);
|
|
35
|
-
const zip = new jszip_1.default();
|
|
36
|
-
zip.file(fileName, (0, print_1.printContract)(c, { transformImport: p => './' + p }));
|
|
37
|
-
zip.file(`@openzeppelin/contracts${contractsVariant}/README.md`, readme(contractsVariant));
|
|
38
|
-
for (const importPath of allImports) {
|
|
39
|
-
const source = openzeppelin_contracts_1.default.sources[importPath];
|
|
40
|
-
if (source === undefined) {
|
|
41
|
-
throw new Error(`Source for ${importPath} not found`);
|
|
42
|
-
}
|
|
43
|
-
zip.file(importPath, source);
|
|
44
|
-
}
|
|
45
|
-
return zip;
|
|
46
|
-
}
|
|
47
|
-
exports.zipContract = zipContract;
|
|
48
|
-
//# sourceMappingURL=zip.js.map
|
package/dist/zip.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"zip.js","sourceRoot":"","sources":["../src/zip.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAG1B,mCAAwC;AACxC,mEAAuD;AAEvD,uFAAkD;AAClD,uCAAwC;AAExC,MAAM,MAAM,GAAG,CAAC,OAAe,EAAE,EAAE,CAAC;;;mFAG+C,gCAAS,CAAC,OAAO;;;;;;kEAMlC,OAAO,UAAU,gCAAS,CAAC,OAAO;8DACtC,OAAO,MAAM,gCAAS,CAAC,OAAO;;;CAG3F,CAAC;AAEF,SAAgB,WAAW,CAAC,CAAW;IACrC,MAAM,EAAE,eAAe,EAAE,GAAG,IAAA,qBAAW,EAAC,CAAC,CAAC,CAAC;IAC3C,MAAM,gBAAgB,GAAG,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC;IAE7D,MAAM,QAAQ,GAAG,CAAC,CAAC,IAAI,GAAG,MAAM,CAAC;IAEjC,MAAM,YAAY,GAAG;QACnB,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;QAClD,GAAG,gCAAS,CAAC,YAAY;KAC1B,CAAC;IAEF,MAAM,UAAU,GAAG,IAAA,8BAAS,EAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;IAErD,MAAM,GAAG,GAAG,IAAI,eAAK,EAAE,CAAC;IAExB,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAA,qBAAa,EAAC,CAAC,EAAE,EAAE,eAAe,EAAE,CAAC,CAAC,EAAE,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IAEzE,GAAG,CAAC,IAAI,CAAC,0BAA0B,gBAAgB,YAAY,EAAE,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAE3F,KAAK,MAAM,UAAU,IAAI,UAAU,EAAE;QACnC,MAAM,MAAM,GAAG,gCAAS,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAC7C,IAAI,MAAM,KAAK,SAAS,EAAE;YACxB,MAAM,IAAI,KAAK,CAAC,cAAc,UAAU,YAAY,CAAC,CAAC;SACvD;QACD,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;KAC9B;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AA5BD,kCA4BC"}
|
package/src/.DS_Store
DELETED
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/src/zip.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import JSZip from 'jszip';
|
|
2
|
-
|
|
3
|
-
import type { Contract, Parent, ContractFunction, FunctionArgument } from './contract';
|
|
4
|
-
import { printContract } from './print';
|
|
5
|
-
import { reachable } from './utils/transitive-closure';
|
|
6
|
-
|
|
7
|
-
import contracts from '../openzeppelin-contracts';
|
|
8
|
-
import { withHelpers } from './options';
|
|
9
|
-
|
|
10
|
-
const readme = (variant: string) => `\
|
|
11
|
-
# OpenZeppelin Contracts
|
|
12
|
-
|
|
13
|
-
The files in this directory were sourced unmodified from OpenZeppelin Contracts v${contracts.version}.
|
|
14
|
-
|
|
15
|
-
They are not meant to be edited.
|
|
16
|
-
|
|
17
|
-
The originals can be found on [GitHub] and [npm].
|
|
18
|
-
|
|
19
|
-
[GitHub]: https://github.com/OpenZeppelin/openzeppelin-contracts${variant}/tree/v${contracts.version}
|
|
20
|
-
[npm]: https://www.npmjs.com/package/@openzeppelin/contracts${variant}/v/${contracts.version}
|
|
21
|
-
|
|
22
|
-
Generated with OpenZeppelin Contracts Wizard (https://zpl.in/wizard).
|
|
23
|
-
`;
|
|
24
|
-
|
|
25
|
-
export function zipContract(c: Contract): JSZip {
|
|
26
|
-
const { transformImport } = withHelpers(c);
|
|
27
|
-
const contractsVariant = c.upgradeable ? '-upgradeable' : '';
|
|
28
|
-
|
|
29
|
-
const fileName = c.name + '.sol';
|
|
30
|
-
|
|
31
|
-
const dependencies = {
|
|
32
|
-
[fileName]: c.imports.map(i => transformImport(i)),
|
|
33
|
-
...contracts.dependencies,
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const allImports = reachable(dependencies, fileName);
|
|
37
|
-
|
|
38
|
-
const zip = new JSZip();
|
|
39
|
-
|
|
40
|
-
zip.file(fileName, printContract(c, { transformImport: p => './' + p }));
|
|
41
|
-
|
|
42
|
-
zip.file(`@openzeppelin/contracts${contractsVariant}/README.md`, readme(contractsVariant));
|
|
43
|
-
|
|
44
|
-
for (const importPath of allImports) {
|
|
45
|
-
const source = contracts.sources[importPath];
|
|
46
|
-
if (source === undefined) {
|
|
47
|
-
throw new Error(`Source for ${importPath} not found`);
|
|
48
|
-
}
|
|
49
|
-
zip.file(importPath, source);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return zip;
|
|
53
|
-
}
|