@0xweb/hardhat 0.1.24 → 0.1.27
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/lib/index.js +61 -11
- package/package.json +6 -5
- package/readme.md +3 -3
package/lib/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
// source ./
|
|
2
|
+
// source ./RootModuleWrapped.js
|
|
3
3
|
(function(){
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
|
|
5
|
+
var _src_config = {};
|
|
6
6
|
var _src_constants = {};
|
|
7
7
|
var _src_utils__path = {};
|
|
8
8
|
|
|
@@ -105,6 +105,30 @@ var $path;
|
|
|
105
105
|
return pathUtil.join(...paths).replace(/\\/g, '/');
|
|
106
106
|
}
|
|
107
107
|
$path.join = join;
|
|
108
|
+
function normalize(path) {
|
|
109
|
+
path = path
|
|
110
|
+
// Replace all / duplicates, but not near the protocol
|
|
111
|
+
.replace(/(?<![:/])\/{2,}/g, '/')
|
|
112
|
+
// Use forward slashes
|
|
113
|
+
.replace(/\\/g, '/')
|
|
114
|
+
// Replace "foo/./bar" with single slash: "foo/bar"
|
|
115
|
+
.replace(/\/\.\//g, '/');
|
|
116
|
+
while (true) {
|
|
117
|
+
let next = path.replace(/([^\/]+)\/\.\.\//g, (match, p1) => {
|
|
118
|
+
if (p1 !== '..' && p1 !== '.') {
|
|
119
|
+
return '';
|
|
120
|
+
}
|
|
121
|
+
return match;
|
|
122
|
+
});
|
|
123
|
+
if (next === path) {
|
|
124
|
+
// nothing to collapse
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
path = next;
|
|
128
|
+
}
|
|
129
|
+
return path;
|
|
130
|
+
}
|
|
131
|
+
$path.normalize = normalize;
|
|
108
132
|
})($path = exports.$path || (exports.$path = {}));
|
|
109
133
|
//# sourceMappingURL=$path.js.map
|
|
110
134
|
//# sourceMappingURL=$path.ts.map;
|
|
@@ -145,12 +169,16 @@ const taskArgsStore = { compileAll: false };
|
|
|
145
169
|
.addOptionalParam('root', 'Overrides root directory. If sources is also overridden must be the sub-folder of the sources dir')
|
|
146
170
|
.addOptionalParam('package', 'Compile the contracts within a specific mono-repo package. Artifacts and 0xc classes will be placed in the package directory')
|
|
147
171
|
.addOptionalParam('tsgen', 'Skip the TypeScript class generation', true, config_1.types.boolean)
|
|
172
|
+
.addOptionalParam('install', 'CSV sol path to install, default installs all compiled contracts from sources')
|
|
148
173
|
.addFlag('watch', 'Watch sources directory and reruns compilation task on changes')
|
|
149
174
|
.setAction(async (compilationArgs, { run, config, artifacts }, runSuper) => {
|
|
150
175
|
ConfigHelper.resetPaths(config.paths);
|
|
151
176
|
if (compilationArgs.tsgen === false) {
|
|
152
177
|
config['0xweb'].tsgen = false;
|
|
153
178
|
}
|
|
179
|
+
if (compilationArgs.install != null) {
|
|
180
|
+
config['0xweb'].install = compilationArgs.install;
|
|
181
|
+
}
|
|
154
182
|
if (compilationArgs.package != null) {
|
|
155
183
|
config['0xweb'].package = compilationArgs.package;
|
|
156
184
|
if (compilationArgs.artifacts == null) {
|
|
@@ -233,7 +261,7 @@ const taskArgsStore = { compileAll: false };
|
|
|
233
261
|
const app = new _0xweb_1.App();
|
|
234
262
|
await (0, alot_1.default)(contracts)
|
|
235
263
|
.forEachAsync(async (contract, i) => {
|
|
236
|
-
console.log(
|
|
264
|
+
console.log(`⏳ Generate ${contract.name}(${contract.path}) ${i}/${contracts.length}`);
|
|
237
265
|
const params = [
|
|
238
266
|
`install`, `${contract.path}`,
|
|
239
267
|
'--name', contract.name,
|
|
@@ -271,33 +299,54 @@ const taskArgsStore = { compileAll: false };
|
|
|
271
299
|
await runSuper();
|
|
272
300
|
});
|
|
273
301
|
async function getCompiledAbis(config, compileSolOutput) {
|
|
302
|
+
var _a, _b, _c;
|
|
303
|
+
const sources = config.paths.sources;
|
|
304
|
+
const installs = (_c = (_b = (_a = config['0xweb']) === null || _a === void 0 ? void 0 : _a.install) === null || _b === void 0 ? void 0 : _b.split(',').map(x => x.trim())) !== null && _c !== void 0 ? _c : null;
|
|
274
305
|
const emittedArtifacts = (0, alot_1.default)(compileSolOutput.artifactsEmittedPerJob).mapMany((a) => {
|
|
275
306
|
return (0, alot_1.default)(a.artifactsEmittedPerFile).mapMany((artifactPerFile) => {
|
|
276
307
|
return (0, alot_1.default)(artifactPerFile.artifactsEmitted).map((artifactName) => {
|
|
277
308
|
return {
|
|
278
|
-
|
|
309
|
+
// Contract Name
|
|
310
|
+
artifactName: artifactName,
|
|
311
|
+
// Contract local path, aka import
|
|
312
|
+
sourceName: artifactPerFile.file.sourceName,
|
|
313
|
+
// Contract system path, aka file path
|
|
279
314
|
sourceFile: 'file://' + artifactPerFile.file.absolutePath
|
|
280
315
|
};
|
|
281
316
|
})
|
|
282
|
-
.filter(x =>
|
|
317
|
+
.filter(x => {
|
|
318
|
+
if (installs != null) {
|
|
319
|
+
let shouldInstall = installs.some(toInstall => {
|
|
320
|
+
var _a;
|
|
321
|
+
return x.artifactName === toInstall || ((_a = x.sourceName) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === toInstall.toLowerCase();
|
|
322
|
+
});
|
|
323
|
+
return shouldInstall;
|
|
324
|
+
}
|
|
325
|
+
if (sources != null) {
|
|
326
|
+
return _path_1.$path.normalize(x.sourceFile).toLowerCase().startsWith(`file://${_path_1.$path.normalize(sources).toLowerCase()}`);
|
|
327
|
+
}
|
|
328
|
+
return false;
|
|
329
|
+
})
|
|
330
|
+
//.filter(x => x.sourceFile.includes('@openzeppelin') === false)
|
|
283
331
|
.toArray();
|
|
284
332
|
}).toArray();
|
|
285
333
|
}).toArray();
|
|
286
|
-
let namesHash = (0, alot_1.default)(emittedArtifacts).toDictionary(x => x.
|
|
334
|
+
let namesHash = (0, alot_1.default)(emittedArtifacts).toDictionary(x => x.artifactName);
|
|
287
335
|
let files = await atma_io_1.Directory.readFilesAsync(`file://${config.paths.artifacts}/`, '**.json');
|
|
288
336
|
let compileAll = taskArgsStore.compileAll;
|
|
289
337
|
let arr = files
|
|
290
338
|
.map(file => {
|
|
291
339
|
let path = file.uri.toString();
|
|
292
|
-
let match = /(?<
|
|
340
|
+
let match = /(?<sourceFileName>[^\\\/]+)\.sol[\\\/]/.exec(path);
|
|
293
341
|
if (match == null) {
|
|
294
342
|
return null;
|
|
295
343
|
}
|
|
296
|
-
|
|
344
|
+
// assume artifactName === sourceFileName @TODO consider to handle different file-contract names
|
|
345
|
+
let name = match.groups.sourceFileName;
|
|
297
346
|
if (compileAll !== true && name in namesHash === false) {
|
|
298
347
|
return null;
|
|
299
348
|
}
|
|
300
|
-
if (new RegExp(
|
|
349
|
+
if (new RegExp(`[\\\/]${name}\\.json$`).test(path) === false) {
|
|
301
350
|
return null;
|
|
302
351
|
}
|
|
303
352
|
return {
|
|
@@ -324,4 +373,5 @@ var ConfigHelper;
|
|
|
324
373
|
//# sourceMappingURL=index.ts.map
|
|
325
374
|
|
|
326
375
|
}());
|
|
327
|
-
|
|
376
|
+
|
|
377
|
+
// end:source ./RootModuleWrapped.js
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xweb/hardhat",
|
|
3
3
|
"description": "0xweb plugin for Hardhat",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.27",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Alex Kit",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
],
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"0xweb": "^0.10.
|
|
21
|
+
"0xweb": "^0.10.69",
|
|
22
22
|
"alot": "^0.3.0",
|
|
23
|
-
"atma-io": "^1.
|
|
23
|
+
"atma-io": "^1.3.5",
|
|
24
24
|
"memd": "^0.3.10"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
@@ -33,8 +33,9 @@
|
|
|
33
33
|
"release": "atma bump && npm run build && git add -A && git commit -am 'bump' && git push && git push origin master:release"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"app-bundler": "^0.
|
|
37
|
-
"atma": "^0.15.
|
|
36
|
+
"app-bundler": "^0.2.14",
|
|
37
|
+
"atma": "^0.15.23",
|
|
38
|
+
"atma-loader-ts": "^1.2.7",
|
|
38
39
|
"shellbee": "^0.5.22"
|
|
39
40
|
},
|
|
40
41
|
"app-bundler": {
|
package/readme.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
----
|
|
5
|
-
[](https://badge.fury.io/js/@0xweb%2Fhardhat)
|
|
6
6
|
[](https://circleci.com/gh/0xweb-org/hardhat)
|
|
7
7
|
|
|
8
8
|
|
|
@@ -95,7 +95,7 @@ const text = await foo.name();
|
|
|
95
95
|
- `npx hardhat compile --sources /foo/bar/qux` - compiles solidity files which are located outside the `/contracts` folder
|
|
96
96
|
- `npx hardhat compile --artifacts /dist` - set custom folder for artifacts (ABI JSONs and TS contracts)
|
|
97
97
|
- `npx hardhat compile --watch` - Compile the sources and waits to recompile on changes
|
|
98
|
-
- `npx hardhat compile --tsgen false` - Do not generate the TS classes
|
|
99
98
|
- `npx hardhat compile --package path/to/package/folder` - You can split your project into packages, and with the command compile the contracts in a package, the sources will be searched in that directory, and the artifacts output will be written to that directory
|
|
100
|
-
|
|
99
|
+
- `npx hardhat compile --tsgen false` - Do not generate the TS classes. Installs all the contracts from the sources directory.
|
|
100
|
+
- `npx hardhat compile --install TimelockController` - Installs only specified Artifact name or *.sol paths. Comma separated.
|
|
101
101
|
----
|