@openzeppelin/wizard 0.1.1 → 0.2.0
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/README.md +2 -0
- package/dist/environments/hardhat/package-lock.json +14913 -0
- package/dist/environments/hardhat/package.json +34 -0
- package/dist/environments/hardhat/upgradeable/package-lock.json +15333 -0
- package/dist/environments/hardhat/upgradeable/package.json +35 -0
- package/dist/erc721.js +2 -0
- package/dist/erc721.js.map +1 -1
- package/dist/governor.js +1 -1
- package/dist/governor.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/solidity-version.json +1 -0
- package/dist/utils/format-lines.d.ts +1 -0
- 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/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 +8 -6
- package/src/environments/hardhat/package-lock.json +14913 -0
- package/src/environments/hardhat/package.json +34 -0
- package/src/environments/hardhat/upgradeable/package-lock.json +15333 -0
- package/src/environments/hardhat/upgradeable/package.json +35 -0
- package/src/erc721.ts +2 -0
- package/src/governor.ts +1 -1
- 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
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "hardhat-sample",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "hardhat test"
|
|
8
|
+
},
|
|
9
|
+
"author": "",
|
|
10
|
+
"license": "ISC",
|
|
11
|
+
"devDependencies": {
|
|
12
|
+
"@openzeppelin/contracts-upgradeable": "^4.8.0",
|
|
13
|
+
"@openzeppelin/hardhat-upgrades": "^1.21.0",
|
|
14
|
+
"@ethersproject/abi": "^5.7.0",
|
|
15
|
+
"@ethersproject/providers": "^5.7.2",
|
|
16
|
+
"@nomicfoundation/hardhat-chai-matchers": "^1.0.4",
|
|
17
|
+
"@nomicfoundation/hardhat-network-helpers": "^1.0.6",
|
|
18
|
+
"@nomicfoundation/hardhat-toolbox": "^2.0.0",
|
|
19
|
+
"@nomiclabs/hardhat-ethers": "^2.2.0",
|
|
20
|
+
"@nomiclabs/hardhat-etherscan": "^3.1.1",
|
|
21
|
+
"@typechain/ethers-v5": "^10.1.1",
|
|
22
|
+
"@typechain/hardhat": "^6.1.4",
|
|
23
|
+
"@types/chai": "^4.3.3",
|
|
24
|
+
"@types/mocha": "^9.1.1",
|
|
25
|
+
"@types/node": "^18.11.6",
|
|
26
|
+
"chai": "^4.3.6",
|
|
27
|
+
"ethers": "^5.7.2",
|
|
28
|
+
"hardhat": "^2.12.0",
|
|
29
|
+
"hardhat-gas-reporter": "^1.0.9",
|
|
30
|
+
"solidity-coverage": "^0.8.2",
|
|
31
|
+
"ts-node": "^10.9.1",
|
|
32
|
+
"typechain": "^8.1.1",
|
|
33
|
+
"typescript": "^4.8.4"
|
|
34
|
+
}
|
|
35
|
+
}
|
package/src/erc721.ts
CHANGED
|
@@ -197,6 +197,7 @@ const functions = defineFunctions({
|
|
|
197
197
|
{ name: 'from', type: 'address' },
|
|
198
198
|
{ name: 'to', type: 'address' },
|
|
199
199
|
{ name: 'tokenId', type: 'uint256' },
|
|
200
|
+
{ name: 'batchSize', type: 'uint256' },
|
|
200
201
|
],
|
|
201
202
|
},
|
|
202
203
|
|
|
@@ -206,6 +207,7 @@ const functions = defineFunctions({
|
|
|
206
207
|
{ name: 'from', type: 'address' },
|
|
207
208
|
{ name: 'to', type: 'address' },
|
|
208
209
|
{ name: 'tokenId', type: 'uint256' },
|
|
210
|
+
{ name: 'batchSize', type: 'uint256' },
|
|
209
211
|
],
|
|
210
212
|
},
|
|
211
213
|
|
package/src/governor.ts
CHANGED
package/src/print.ts
CHANGED
|
@@ -5,8 +5,7 @@ import { Options, Helpers, withHelpers } from './options';
|
|
|
5
5
|
|
|
6
6
|
import { formatLines, spaceBetween, Lines } from './utils/format-lines';
|
|
7
7
|
import { mapValues } from './utils/map-values';
|
|
8
|
-
|
|
9
|
-
const SOLIDITY_VERSION = '0.8.4';
|
|
8
|
+
import SOLIDITY_VERSION from './solidity-version.json';
|
|
10
9
|
|
|
11
10
|
export function printContract(contract: Contract, opts?: Options): string {
|
|
12
11
|
const helpers = withHelpers(contract, opts);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"0.8.9"
|
|
@@ -5,20 +5,25 @@ export type Lines = string | typeof whitespace | Lines[];
|
|
|
5
5
|
const whitespace = Symbol('whitespace');
|
|
6
6
|
|
|
7
7
|
export function formatLines(...lines: Lines[]): string {
|
|
8
|
-
return
|
|
8
|
+
return formatLinesWithSpaces(4, ...lines);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function formatLinesWithSpaces(spacesPerIndent: number, ...lines: Lines[]): string {
|
|
12
|
+
return [...indentEach(0, lines, spacesPerIndent)].join('\n') + '\n';
|
|
9
13
|
}
|
|
10
14
|
|
|
11
15
|
function* indentEach(
|
|
12
16
|
indent: number,
|
|
13
17
|
lines: Lines[],
|
|
18
|
+
spacesPerIndent: number,
|
|
14
19
|
): Generator<string | typeof whitespace> {
|
|
15
20
|
for (const line of lines) {
|
|
16
21
|
if (line === whitespace) {
|
|
17
22
|
yield '';
|
|
18
23
|
} else if (Array.isArray(line)) {
|
|
19
|
-
yield* indentEach(indent + 1, line);
|
|
24
|
+
yield* indentEach(indent + 1, line, spacesPerIndent);
|
|
20
25
|
} else {
|
|
21
|
-
yield '
|
|
26
|
+
yield ' '.repeat(indent * spacesPerIndent) + line;
|
|
22
27
|
}
|
|
23
28
|
}
|
|
24
29
|
}
|
|
@@ -0,0 +1,186 @@
|
|
|
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 { formatLinesWithSpaces, Lines, spaceBetween } from "./utils/format-lines";
|
|
7
|
+
|
|
8
|
+
const hardhatConfig = (upgradeable: boolean) => `\
|
|
9
|
+
import { HardhatUserConfig } from "hardhat/config";
|
|
10
|
+
import "@nomicfoundation/hardhat-toolbox";
|
|
11
|
+
${upgradeable ? `import "@openzeppelin/hardhat-upgrades";` : ''}
|
|
12
|
+
|
|
13
|
+
const config: HardhatUserConfig = {
|
|
14
|
+
solidity: {
|
|
15
|
+
version: "${SOLIDITY_VERSION}",
|
|
16
|
+
settings: {
|
|
17
|
+
optimizer: {
|
|
18
|
+
enabled: true,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default config;
|
|
25
|
+
`;
|
|
26
|
+
|
|
27
|
+
const tsConfig = `\
|
|
28
|
+
{
|
|
29
|
+
"compilerOptions": {
|
|
30
|
+
"target": "es2020",
|
|
31
|
+
"module": "commonjs",
|
|
32
|
+
"esModuleInterop": true,
|
|
33
|
+
"forceConsistentCasingInFileNames": true,
|
|
34
|
+
"strict": true,
|
|
35
|
+
"skipLibCheck": true
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
`;
|
|
39
|
+
|
|
40
|
+
const gitIgnore = `\
|
|
41
|
+
node_modules
|
|
42
|
+
.env
|
|
43
|
+
coverage
|
|
44
|
+
coverage.json
|
|
45
|
+
typechain
|
|
46
|
+
typechain-types
|
|
47
|
+
|
|
48
|
+
#Hardhat files
|
|
49
|
+
cache
|
|
50
|
+
artifacts
|
|
51
|
+
`;
|
|
52
|
+
|
|
53
|
+
const test = (c: Contract, opts?: GenericOptions) => {
|
|
54
|
+
return formatLinesWithSpaces(
|
|
55
|
+
2,
|
|
56
|
+
...spaceBetween(
|
|
57
|
+
getImports(c),
|
|
58
|
+
getTestCase(c),
|
|
59
|
+
),
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
function getTestCase(c: Contract) {
|
|
63
|
+
return [
|
|
64
|
+
`describe("${c.name}", function () {`,
|
|
65
|
+
[
|
|
66
|
+
'it("Test contract", async function () {',
|
|
67
|
+
spaceBetween(
|
|
68
|
+
[
|
|
69
|
+
`const ContractFactory = await ethers.getContractFactory("${c.name}");`,
|
|
70
|
+
],
|
|
71
|
+
[
|
|
72
|
+
`const instance = await ${c.upgradeable ? 'upgrades.deployProxy(ContractFactory)' : 'ContractFactory.deploy()'};`,
|
|
73
|
+
'await instance.deployed();'
|
|
74
|
+
],
|
|
75
|
+
getContractSpecificExpects(),
|
|
76
|
+
),
|
|
77
|
+
'});'
|
|
78
|
+
],
|
|
79
|
+
'});',
|
|
80
|
+
];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function getImports(c: Contract) {
|
|
84
|
+
return [
|
|
85
|
+
'import { expect } from "chai";',
|
|
86
|
+
`import { ${getHardhatPlugins(c).join(', ')} } from "hardhat";`,
|
|
87
|
+
];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function getContractSpecificExpects(): Lines[] {
|
|
91
|
+
if (opts !== undefined) {
|
|
92
|
+
switch (opts.kind) {
|
|
93
|
+
case 'ERC20':
|
|
94
|
+
case 'ERC721':
|
|
95
|
+
return [`expect(await instance.name()).to.equal("${opts.name}");`];
|
|
96
|
+
|
|
97
|
+
case 'ERC1155':
|
|
98
|
+
return [`expect(await instance.uri(0)).to.equal("${opts.uri}");`];
|
|
99
|
+
|
|
100
|
+
case 'Governor':
|
|
101
|
+
case 'Custom':
|
|
102
|
+
break;
|
|
103
|
+
|
|
104
|
+
default:
|
|
105
|
+
throw new Error('Unknown ERC');
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return [];
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const script = (c: Contract) => `\
|
|
113
|
+
import { ${getHardhatPlugins(c).join(', ')} } from "hardhat";
|
|
114
|
+
|
|
115
|
+
async function main() {
|
|
116
|
+
const ContractFactory = await ethers.getContractFactory("${c.name}");
|
|
117
|
+
|
|
118
|
+
const instance = await ${c.upgradeable ? 'upgrades.deployProxy(ContractFactory)' : 'ContractFactory.deploy()'};
|
|
119
|
+
await instance.deployed();
|
|
120
|
+
|
|
121
|
+
console.log(\`${c.upgradeable ? 'Proxy' : 'Contract'} deployed to \${instance.address}\`);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// We recommend this pattern to be able to use async/await everywhere
|
|
125
|
+
// and properly handle errors.
|
|
126
|
+
main().catch((error) => {
|
|
127
|
+
console.error(error);
|
|
128
|
+
process.exitCode = 1;
|
|
129
|
+
});
|
|
130
|
+
`;
|
|
131
|
+
|
|
132
|
+
const readme = `\
|
|
133
|
+
# Sample Hardhat Project
|
|
134
|
+
|
|
135
|
+
This project demonstrates a basic Hardhat 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.
|
|
136
|
+
|
|
137
|
+
## Installing dependencies
|
|
138
|
+
|
|
139
|
+
\`\`\`
|
|
140
|
+
npm install
|
|
141
|
+
\`\`\`
|
|
142
|
+
|
|
143
|
+
## Testing the contract
|
|
144
|
+
|
|
145
|
+
\`\`\`
|
|
146
|
+
npm test
|
|
147
|
+
\`\`\`
|
|
148
|
+
|
|
149
|
+
## Deploying the contract
|
|
150
|
+
|
|
151
|
+
You can target any network from your Hardhat config using:
|
|
152
|
+
|
|
153
|
+
\`\`\`
|
|
154
|
+
npx hardhat run --network <network-name> scripts/deploy.ts
|
|
155
|
+
\`\`\`
|
|
156
|
+
`;
|
|
157
|
+
|
|
158
|
+
function getHardhatPlugins(c: Contract) {
|
|
159
|
+
let plugins = ['ethers'];
|
|
160
|
+
if (c.upgradeable) {
|
|
161
|
+
plugins.push('upgrades');
|
|
162
|
+
}
|
|
163
|
+
return plugins;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export async function zipHardhat(c: Contract, opts?: GenericOptions) {
|
|
167
|
+
const zip = new JSZip();
|
|
168
|
+
|
|
169
|
+
const { default: packageJson } = c.upgradeable ? await import("./environments/hardhat/upgradeable/package.json") : await import("./environments/hardhat/package.json");
|
|
170
|
+
packageJson.license = c.license;
|
|
171
|
+
|
|
172
|
+
const { default: packageLock } = c.upgradeable ? await import("./environments/hardhat/upgradeable/package-lock.json") : await import("./environments/hardhat/package-lock.json");
|
|
173
|
+
packageLock.packages[''].license = c.license;
|
|
174
|
+
|
|
175
|
+
zip.file(`contracts/${c.name}.sol`, printContract(c));
|
|
176
|
+
zip.file('test/test.ts', test(c, opts));
|
|
177
|
+
zip.file('scripts/deploy.ts', script(c));
|
|
178
|
+
zip.file('.gitignore', gitIgnore);
|
|
179
|
+
zip.file('hardhat.config.ts', hardhatConfig(c.upgradeable));
|
|
180
|
+
zip.file('package.json', JSON.stringify(packageJson, null, 2));
|
|
181
|
+
zip.file(`package-lock.json`, JSON.stringify(packageLock, null, 2));
|
|
182
|
+
zip.file('README.md', readme);
|
|
183
|
+
zip.file('tsconfig.json', tsConfig);
|
|
184
|
+
|
|
185
|
+
return zip;
|
|
186
|
+
}
|
package/src/zip.ts
CHANGED
|
@@ -29,7 +29,7 @@ export function zipContract(c: Contract): JSZip {
|
|
|
29
29
|
const fileName = c.name + '.sol';
|
|
30
30
|
|
|
31
31
|
const dependencies = {
|
|
32
|
-
[fileName]: c.
|
|
32
|
+
[fileName]: c.imports.map(i => transformImport(i)),
|
|
33
33
|
...contracts.dependencies,
|
|
34
34
|
};
|
|
35
35
|
|
package/dist/contract.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contract.test.d.ts","sourceRoot":"","sources":["../src/contract.test.ts"],"names":[],"mappings":""}
|
package/dist/contract.test.js
DELETED
|
@@ -1,147 +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
|
-
const ava_1 = __importDefault(require("ava"));
|
|
7
|
-
const contract_1 = require("./contract");
|
|
8
|
-
const print_1 = require("./print");
|
|
9
|
-
const set_info_1 = require("./set-info");
|
|
10
|
-
(0, ava_1.default)('contract basics', t => {
|
|
11
|
-
const Foo = new contract_1.ContractBuilder('Foo');
|
|
12
|
-
t.snapshot((0, print_1.printContract)(Foo));
|
|
13
|
-
});
|
|
14
|
-
(0, ava_1.default)('contract with a parent', t => {
|
|
15
|
-
const Foo = new contract_1.ContractBuilder('Foo');
|
|
16
|
-
const Bar = { name: 'Bar', path: './Bar.sol' };
|
|
17
|
-
Foo.addParent(Bar);
|
|
18
|
-
t.snapshot((0, print_1.printContract)(Foo));
|
|
19
|
-
});
|
|
20
|
-
(0, ava_1.default)('contract with two parents', t => {
|
|
21
|
-
const Foo = new contract_1.ContractBuilder('Foo');
|
|
22
|
-
const Bar = { name: 'Bar', path: './Bar.sol' };
|
|
23
|
-
const Quux = { name: 'Quux', path: './Quux.sol' };
|
|
24
|
-
Foo.addParent(Bar);
|
|
25
|
-
Foo.addParent(Quux);
|
|
26
|
-
t.snapshot((0, print_1.printContract)(Foo));
|
|
27
|
-
});
|
|
28
|
-
(0, ava_1.default)('contract with a parent with parameters', t => {
|
|
29
|
-
const Foo = new contract_1.ContractBuilder('Foo');
|
|
30
|
-
const Bar = { name: 'Bar', path: './Bar.sol' };
|
|
31
|
-
Foo.addParent(Bar, ["param1", "param2"]);
|
|
32
|
-
t.snapshot((0, print_1.printContract)(Foo));
|
|
33
|
-
});
|
|
34
|
-
(0, ava_1.default)('contract with two parents only one with parameters', t => {
|
|
35
|
-
const Foo = new contract_1.ContractBuilder('Foo');
|
|
36
|
-
const Bar = { name: 'Bar', path: './Bar.sol' };
|
|
37
|
-
const Quux = { name: 'Quux', path: './Quux.sol' };
|
|
38
|
-
Foo.addParent(Bar, ["param1", "param2"]);
|
|
39
|
-
Foo.addParent(Quux);
|
|
40
|
-
t.snapshot((0, print_1.printContract)(Foo));
|
|
41
|
-
});
|
|
42
|
-
(0, ava_1.default)('contract with one override', t => {
|
|
43
|
-
const Foo = new contract_1.ContractBuilder('Foo');
|
|
44
|
-
const _beforeTokenTransfer = {
|
|
45
|
-
name: '_beforeTokenTransfer',
|
|
46
|
-
kind: 'internal',
|
|
47
|
-
args: [
|
|
48
|
-
{ name: 'from', type: 'address' },
|
|
49
|
-
{ name: 'to', type: 'address' },
|
|
50
|
-
{ name: 'amount', type: 'uint256' },
|
|
51
|
-
],
|
|
52
|
-
};
|
|
53
|
-
Foo.addOverride('ERC20', _beforeTokenTransfer);
|
|
54
|
-
t.snapshot((0, print_1.printContract)(Foo));
|
|
55
|
-
});
|
|
56
|
-
(0, ava_1.default)('contract with two overrides', t => {
|
|
57
|
-
const Foo = new contract_1.ContractBuilder('Foo');
|
|
58
|
-
Foo.addOverride('ERC20', _beforeTokenTransfer);
|
|
59
|
-
Foo.addOverride('ERC20Snapshot', _beforeTokenTransfer);
|
|
60
|
-
t.snapshot((0, print_1.printContract)(Foo));
|
|
61
|
-
});
|
|
62
|
-
(0, ava_1.default)('contract with two different overrides', t => {
|
|
63
|
-
const Foo = new contract_1.ContractBuilder('Foo');
|
|
64
|
-
Foo.addOverride('ERC20', _beforeTokenTransfer);
|
|
65
|
-
Foo.addOverride('OtherParent', _beforeTokenTransfer);
|
|
66
|
-
Foo.addOverride('ERC20', _otherFunction);
|
|
67
|
-
Foo.addOverride('OtherParent', _otherFunction);
|
|
68
|
-
t.snapshot((0, print_1.printContract)(Foo));
|
|
69
|
-
});
|
|
70
|
-
(0, ava_1.default)('contract with a modifier', t => {
|
|
71
|
-
const Foo = new contract_1.ContractBuilder('Foo');
|
|
72
|
-
Foo.addModifier('whenNotPaused', _otherFunction);
|
|
73
|
-
t.snapshot((0, print_1.printContract)(Foo));
|
|
74
|
-
});
|
|
75
|
-
(0, ava_1.default)('contract with a modifier and override', t => {
|
|
76
|
-
const Foo = new contract_1.ContractBuilder('Foo');
|
|
77
|
-
Foo.addModifier('whenNotPaused', _otherFunction);
|
|
78
|
-
Foo.addOverride('ERC20', _otherFunction);
|
|
79
|
-
Foo.addOverride('OtherParent', _otherFunction);
|
|
80
|
-
t.snapshot((0, print_1.printContract)(Foo));
|
|
81
|
-
});
|
|
82
|
-
(0, ava_1.default)('contract with constructor code', t => {
|
|
83
|
-
const Foo = new contract_1.ContractBuilder('Foo');
|
|
84
|
-
Foo.addConstructorCode('_mint(msg.sender, 10 ether);');
|
|
85
|
-
t.snapshot((0, print_1.printContract)(Foo));
|
|
86
|
-
});
|
|
87
|
-
(0, ava_1.default)('contract with constructor code and a parent', t => {
|
|
88
|
-
const Foo = new contract_1.ContractBuilder('Foo');
|
|
89
|
-
const Bar = { name: 'Bar', path: './Bar.sol' };
|
|
90
|
-
Foo.addParent(Bar, ["param1", "param2"]);
|
|
91
|
-
Foo.addConstructorCode('_mint(msg.sender, 10 ether);');
|
|
92
|
-
t.snapshot((0, print_1.printContract)(Foo));
|
|
93
|
-
});
|
|
94
|
-
(0, ava_1.default)('contract with function code', t => {
|
|
95
|
-
const Foo = new contract_1.ContractBuilder('Foo');
|
|
96
|
-
Foo.addFunctionCode('_mint(msg.sender, 10 ether);', _otherFunction);
|
|
97
|
-
t.snapshot((0, print_1.printContract)(Foo));
|
|
98
|
-
});
|
|
99
|
-
(0, ava_1.default)('contract with overriden function with code', t => {
|
|
100
|
-
const Foo = new contract_1.ContractBuilder('Foo');
|
|
101
|
-
Foo.addOverride('Bar', _otherFunction);
|
|
102
|
-
Foo.addFunctionCode('_mint(msg.sender, 10 ether);', _otherFunction);
|
|
103
|
-
t.snapshot((0, print_1.printContract)(Foo));
|
|
104
|
-
});
|
|
105
|
-
(0, ava_1.default)('contract with one variable', t => {
|
|
106
|
-
const Foo = new contract_1.ContractBuilder('Foo');
|
|
107
|
-
Foo.addVariable('uint value = 42;');
|
|
108
|
-
t.snapshot((0, print_1.printContract)(Foo));
|
|
109
|
-
});
|
|
110
|
-
(0, ava_1.default)('contract with two variables', t => {
|
|
111
|
-
const Foo = new contract_1.ContractBuilder('Foo');
|
|
112
|
-
Foo.addVariable('uint value = 42;');
|
|
113
|
-
Foo.addVariable('string name = "john";');
|
|
114
|
-
t.snapshot((0, print_1.printContract)(Foo));
|
|
115
|
-
});
|
|
116
|
-
(0, ava_1.default)('name with special characters', t => {
|
|
117
|
-
const Foo = new contract_1.ContractBuilder('foo bar baz');
|
|
118
|
-
t.snapshot((0, print_1.printContract)(Foo));
|
|
119
|
-
});
|
|
120
|
-
(0, ava_1.default)('using for statement', t => {
|
|
121
|
-
const Foo = new contract_1.ContractBuilder('Foo');
|
|
122
|
-
Foo.addUsing({
|
|
123
|
-
name: 'Counters',
|
|
124
|
-
path: './Counters.sol',
|
|
125
|
-
}, 'Counters.Counter');
|
|
126
|
-
t.snapshot((0, print_1.printContract)(Foo));
|
|
127
|
-
});
|
|
128
|
-
(0, ava_1.default)('contract with info', t => {
|
|
129
|
-
const Foo = new contract_1.ContractBuilder('Foo');
|
|
130
|
-
Foo.addNatspecTag(set_info_1.TAG_SECURITY_CONTACT, 'security@example.com');
|
|
131
|
-
t.snapshot((0, print_1.printContract)(Foo));
|
|
132
|
-
});
|
|
133
|
-
const _beforeTokenTransfer = {
|
|
134
|
-
name: '_beforeTokenTransfer',
|
|
135
|
-
kind: 'internal',
|
|
136
|
-
args: [
|
|
137
|
-
{ name: 'from', type: 'address' },
|
|
138
|
-
{ name: 'to', type: 'address' },
|
|
139
|
-
{ name: 'amount', type: 'uint256' },
|
|
140
|
-
],
|
|
141
|
-
};
|
|
142
|
-
const _otherFunction = {
|
|
143
|
-
name: '_otherFunction',
|
|
144
|
-
kind: 'internal',
|
|
145
|
-
args: [],
|
|
146
|
-
};
|
|
147
|
-
//# sourceMappingURL=contract.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contract.test.js","sourceRoot":"","sources":["../src/contract.test.ts"],"names":[],"mappings":";;;;;AAAA,8CAAuB;AAEvB,yCAA6C;AAC7C,mCAAwC;AACxC,yCAAkD;AAElD,IAAA,aAAI,EAAC,iBAAiB,EAAE,CAAC,CAAC,EAAE;IAC1B,MAAM,GAAG,GAAG,IAAI,0BAAe,CAAC,KAAK,CAAC,CAAC;IACvC,CAAC,CAAC,QAAQ,CAAC,IAAA,qBAAa,EAAC,GAAG,CAAC,CAAC,CAAC;AACjC,CAAC,CAAC,CAAC;AAEH,IAAA,aAAI,EAAC,wBAAwB,EAAE,CAAC,CAAC,EAAE;IACjC,MAAM,GAAG,GAAG,IAAI,0BAAe,CAAC,KAAK,CAAC,CAAC;IACvC,MAAM,GAAG,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;IAC/C,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC,CAAC,QAAQ,CAAC,IAAA,qBAAa,EAAC,GAAG,CAAC,CAAC,CAAC;AACjC,CAAC,CAAC,CAAC;AAEH,IAAA,aAAI,EAAC,2BAA2B,EAAE,CAAC,CAAC,EAAE;IACpC,MAAM,GAAG,GAAG,IAAI,0BAAe,CAAC,KAAK,CAAC,CAAC;IACvC,MAAM,GAAG,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;IAC/C,MAAM,IAAI,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,CAA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AQ,EAAE,IAAI,EAAE,SAAS,EAAE;KACpC;CACF,CAAC;AAEF,MAAM,cAAc,GAAG;IACrB,IAAI,EAAE,gBAAgB;IACtB,IAAI,EAAE,UAAmB;IACzB,IAAI,EAAE,EAAE;CACT,CAAC"}
|
package/dist/custom.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"custom.test.d.ts","sourceRoot":"","sources":["../src/custom.test.ts"],"names":[],"mappings":""}
|
package/dist/custom.test.js
DELETED
|
@@ -1,70 +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
|
-
const ava_1 = __importDefault(require("ava"));
|
|
7
|
-
const _1 = require(".");
|
|
8
|
-
const custom_1 = require("./custom");
|
|
9
|
-
const print_1 = require("./print");
|
|
10
|
-
function testCustom(title, opts) {
|
|
11
|
-
(0, ava_1.default)(title, t => {
|
|
12
|
-
const c = (0, custom_1.buildCustom)({
|
|
13
|
-
name: 'MyContract',
|
|
14
|
-
...opts,
|
|
15
|
-
});
|
|
16
|
-
t.snapshot((0, print_1.printContract)(c));
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Tests external API for equivalence with internal API
|
|
21
|
-
*/
|
|
22
|
-
function testAPIEquivalence(title, opts) {
|
|
23
|
-
(0, ava_1.default)(title, t => {
|
|
24
|
-
t.is(_1.custom.print(opts), (0, print_1.printContract)((0, custom_1.buildCustom)({
|
|
25
|
-
name: 'MyContract',
|
|
26
|
-
...opts,
|
|
27
|
-
})));
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
testCustom('custom', {});
|
|
31
|
-
testCustom('pausable', {
|
|
32
|
-
pausable: true,
|
|
33
|
-
});
|
|
34
|
-
testCustom('upgradeable transparent', {
|
|
35
|
-
upgradeable: 'transparent',
|
|
36
|
-
});
|
|
37
|
-
testCustom('upgradeable uups', {
|
|
38
|
-
upgradeable: 'uups',
|
|
39
|
-
});
|
|
40
|
-
testCustom('access control disabled', {
|
|
41
|
-
access: false,
|
|
42
|
-
});
|
|
43
|
-
testCustom('access control ownable', {
|
|
44
|
-
access: 'ownable',
|
|
45
|
-
});
|
|
46
|
-
testCustom('access control roles', {
|
|
47
|
-
access: 'roles',
|
|
48
|
-
});
|
|
49
|
-
testCustom('upgradeable uups with access control disabled', {
|
|
50
|
-
// API should override access to true since it is required for UUPS
|
|
51
|
-
access: false,
|
|
52
|
-
upgradeable: 'uups',
|
|
53
|
-
});
|
|
54
|
-
testAPIEquivalence('custom API default');
|
|
55
|
-
testAPIEquivalence('custom API basic', { name: 'CustomContract' });
|
|
56
|
-
testAPIEquivalence('custom API full upgradeable', {
|
|
57
|
-
name: 'CustomContract',
|
|
58
|
-
access: 'roles',
|
|
59
|
-
pausable: true,
|
|
60
|
-
upgradeable: 'uups',
|
|
61
|
-
});
|
|
62
|
-
(0, ava_1.default)('custom API assert defaults', async (t) => {
|
|
63
|
-
t.is(_1.custom.print(_1.custom.defaults), _1.custom.print());
|
|
64
|
-
});
|
|
65
|
-
(0, ava_1.default)('API isAccessControlRequired', async (t) => {
|
|
66
|
-
t.is(_1.custom.isAccessControlRequired({ pausable: true }), true);
|
|
67
|
-
t.is(_1.custom.isAccessControlRequired({ upgradeable: 'uups' }), true);
|
|
68
|
-
t.is(_1.custom.isAccessControlRequired({ upgradeable: 'transparent' }), false);
|
|
69
|
-
});
|
|
70
|
-
//# sourceMappingURL=custom.test.js.map
|
package/dist/custom.test.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"custom.test.js","sourceRoot":"","sources":["../src/custom.test.ts"],"names":[],"mappings":";;;;;AAAA,8CAAuB;AACvB,wBAA2B;AAE3B,qCAAsD;AACtD,mCAAwC;AAExC,SAAS,UAAU,CAAC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kB,CAAC,oBAAoB,CAAC,CAAC;AAEzC,kBAAkB,CAAC,kBAAkB,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC,CAAC;AAEnE,kBAAkB,CAAC,6BAA6B,EAAE;IAChD,IAAI,EAAE,gBAAgB;IACtB,MAAM,EAAE,OAAO;IACf,QAAQ,EAAE,IAAI;IACd,WAAW,EAAE,MAAM;CACpB,CAAC,CAAC;AAEH,IAAA,aAAI,EAAC,4BAA4B,EAAE,KAAK,EAAC,CAAC,EAAC,EAAE;IAC3C,CAAC,CAAC,EAAE,CAAC,SAAM,CAAC,KAAK,CAAC,SAAM,CAAC,QAAQ,CAAC,EAAE,SAAM,CAAC,KAAK,EAAE,CAAC,CAAC;AACtD,CAAC,CAAC,CAAC;AAEH,IAAA,aAAI,EAAC,6BAA6B,EAAE,KAAK,EAAC,CAAC,EAAC,EAAE;IAC5C,CAAC,CAAC,EAAE,CAAC,SAAM,CAAC,uBAAuB,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;IAC/D,CAAC,CAAC,EAAE,CAAC,SAAM,CAAC,uBAAuB,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;IACpE,CAAC,CAAC,EAAE,CAAC,SAAM,CAAC,uBAAuB,CAAC,EAAE,WAAW,EAAE,aAAa,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;AAC9E,CAAC,CAAC,CAAC"}
|
package/dist/erc1155.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"erc1155.test.d.ts","sourceRoot":"","sources":["../src/erc1155.test.ts"],"names":[],"mappings":""}
|
package/dist/erc1155.test.js
DELETED
|
@@ -1,91 +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
|
-
const ava_1 = __importDefault(require("ava"));
|
|
7
|
-
const _1 = require(".");
|
|
8
|
-
const erc1155_1 = require("./erc1155");
|
|
9
|
-
const print_1 = require("./print");
|
|
10
|
-
function testERC1155(title, opts) {
|
|
11
|
-
(0, ava_1.default)(title, t => {
|
|
12
|
-
const c = (0, erc1155_1.buildERC1155)({
|
|
13
|
-
name: 'MyToken',
|
|
14
|
-
uri: 'https://gateway.pinata.cloud/ipfs/QmcP9hxrnC1T5ATPmq2saFeAM1ypFX9BnAswCdHB9JCjLA/',
|
|
15
|
-
...opts,
|
|
16
|
-
});
|
|
17
|
-
t.snapshot((0, print_1.printContract)(c));
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Tests external API for equivalence with internal API
|
|
22
|
-
*/
|
|
23
|
-
function testAPIEquivalence(title, opts) {
|
|
24
|
-
(0, ava_1.default)(title, t => {
|
|
25
|
-
t.is(_1.erc1155.print(opts), (0, print_1.printContract)((0, erc1155_1.buildERC1155)({
|
|
26
|
-
name: 'MyToken',
|
|
27
|
-
uri: '',
|
|
28
|
-
...opts,
|
|
29
|
-
})));
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
testERC1155('basic', {});
|
|
33
|
-
testERC1155('basic + roles', {
|
|
34
|
-
access: 'roles',
|
|
35
|
-
});
|
|
36
|
-
testERC1155('no updatable uri', {
|
|
37
|
-
updatableUri: false,
|
|
38
|
-
});
|
|
39
|
-
testERC1155('burnable', {
|
|
40
|
-
burnable: true,
|
|
41
|
-
});
|
|
42
|
-
testERC1155('pausable', {
|
|
43
|
-
pausable: true,
|
|
44
|
-
});
|
|
45
|
-
testERC1155('mintable', {
|
|
46
|
-
mintable: true,
|
|
47
|
-
});
|
|
48
|
-
testERC1155('mintable + roles', {
|
|
49
|
-
mintable: true,
|
|
50
|
-
access: 'roles',
|
|
51
|
-
});
|
|
52
|
-
testERC1155('supply tracking', {
|
|
53
|
-
supply: true,
|
|
54
|
-
});
|
|
55
|
-
testERC1155('full upgradeable transparent', {
|
|
56
|
-
mintable: true,
|
|
57
|
-
access: 'roles',
|
|
58
|
-
burnable: true,
|
|
59
|
-
pausable: true,
|
|
60
|
-
upgradeable: 'transparent',
|
|
61
|
-
});
|
|
62
|
-
testERC1155('full upgradeable uups', {
|
|
63
|
-
mintable: true,
|
|
64
|
-
access: 'roles',
|
|
65
|
-
burnable: true,
|
|
66
|
-
pausable: true,
|
|
67
|
-
upgradeable: 'uups',
|
|
68
|
-
});
|
|
69
|
-
testAPIEquivalence('API default');
|
|
70
|
-
testAPIEquivalence('API basic', { name: 'CustomToken', uri: 'https://gateway.pinata.cloud/ipfs/QmcP9hxrnC1T5ATPmq2saFeAM1ypFX9BnAswCdHB9JCjLA/' });
|
|
71
|
-
testAPIEquivalence('API full upgradeable', {
|
|
72
|
-
name: 'CustomToken',
|
|
73
|
-
uri: 'https://gateway.pinata.cloud/ipfs/QmcP9hxrnC1T5ATPmq2saFeAM1ypFX9BnAswCdHB9JCjLA/',
|
|
74
|
-
mintable: true,
|
|
75
|
-
access: 'roles',
|
|
76
|
-
burnable: true,
|
|
77
|
-
pausable: true,
|
|
78
|
-
upgradeable: 'uups',
|
|
79
|
-
});
|
|
80
|
-
(0, ava_1.default)('API assert defaults', async (t) => {
|
|
81
|
-
t.is(_1.erc1155.print(_1.erc1155.defaults), _1.erc1155.print());
|
|
82
|
-
});
|
|
83
|
-
(0, ava_1.default)('API isAccessControlRequired', async (t) => {
|
|
84
|
-
t.is(_1.erc1155.isAccessControlRequired({ updatableUri: false, mintable: true }), true);
|
|
85
|
-
t.is(_1.erc1155.isAccessControlRequired({ updatableUri: false, pausable: true }), true);
|
|
86
|
-
t.is(_1.erc1155.isAccessControlRequired({ updatableUri: false, upgradeable: 'uups' }), true);
|
|
87
|
-
t.is(_1.erc1155.isAccessControlRequired({ updatableUri: true }), true);
|
|
88
|
-
t.is(_1.erc1155.isAccessControlRequired({ updatableUri: false }), false);
|
|
89
|
-
t.is(_1.erc1155.isAccessControlRequired({}), true); // updatableUri is true by default
|
|
90
|
-
});
|
|
91
|
-
//# sourceMappingURL=erc1155.test.js.map
|
package/dist/erc1155.test.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"erc1155.test.js","sourceRoot":"","sources":["../src/erc1155.test.ts"],"names":[],"mappings":";;;;;AAAA,8CAAuB;AACvB,wBAA4B;AAE5B,uCAAyD;AACzD,mCAAwC;AAExC,SAAS,WAAW,CAAC,KAAa,EAAE,IAA6B;IAC/D,IAAA,aAAI,EAAC,KAAK,EAAE,CAAC,CAAC,EAAE;QACd,MAAM,CAAC,GAAG,IAAA,sBAAY,EAAC;YACrB,IAAI,EAAE,SAAS;YACf,GAAG,EAAE,mFAAmF;YACxF,GAAG,IAAI;SACR,CAAC,CAAC;QACH,CAAC,CAAC,QAAQ,CAAC,IAAA,qBAAa,EAAC,CAAC,CAAC,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACF,SAAS,kBAAkB,CAAC,KAAa,EAAE,IAAqB;IAC/D,IAAA,aAAI,EAAC,KAAK,EAAE,CAAC,CAAC,EAAE;QACd,CAAC,CAAC,EAAE,CAAC,UAAO,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,IAAA,qBAAa,EAAC,IAAA,sBAAY,EAAC;YACnD,IAAI,EAAE,SAAS;YACf,GAAG,EAAE,EAAE;YACP,GAAG,IAAI;SACR,CAAC,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACL,CAAC;AAED,WAAW,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AAEzB,WAAW,CAAC,eAAe,EAAE;IAC3B,MAAM,EAAE,OAAO;CAChB,CAAC,CAAC;AAEH,WAAW,CAAC,kBAAkB,EAAE;IAC9B,YAAY,EAAE,KAAK;CACpB,CAAC,CAAC;AAEH,WAAW,CAAC,U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