@0xweb/hardhat 0.1.23 → 0.1.26
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 +50 -12
- package/package.json +6 -5
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
|
|
|
@@ -145,12 +145,16 @@ const taskArgsStore = { compileAll: false };
|
|
|
145
145
|
.addOptionalParam('root', 'Overrides root directory. If sources is also overridden must be the sub-folder of the sources dir')
|
|
146
146
|
.addOptionalParam('package', 'Compile the contracts within a specific mono-repo package. Artifacts and 0xc classes will be placed in the package directory')
|
|
147
147
|
.addOptionalParam('tsgen', 'Skip the TypeScript class generation', true, config_1.types.boolean)
|
|
148
|
+
.addOptionalParam('install', 'CSV sol path to install, default installs all compiled contracts from sources')
|
|
148
149
|
.addFlag('watch', 'Watch sources directory and reruns compilation task on changes')
|
|
149
150
|
.setAction(async (compilationArgs, { run, config, artifacts }, runSuper) => {
|
|
150
151
|
ConfigHelper.resetPaths(config.paths);
|
|
151
152
|
if (compilationArgs.tsgen === false) {
|
|
152
153
|
config['0xweb'].tsgen = false;
|
|
153
154
|
}
|
|
155
|
+
if (compilationArgs.install != null) {
|
|
156
|
+
config['0xweb'].install = compilationArgs.install;
|
|
157
|
+
}
|
|
154
158
|
if (compilationArgs.package != null) {
|
|
155
159
|
config['0xweb'].package = compilationArgs.package;
|
|
156
160
|
if (compilationArgs.artifacts == null) {
|
|
@@ -194,9 +198,21 @@ const taskArgsStore = { compileAll: false };
|
|
|
194
198
|
if (compilationArgs.watch) {
|
|
195
199
|
const directory = `file://${config.paths.sources}/`;
|
|
196
200
|
atma_io_1.Directory.watch(directory, async (...args) => {
|
|
197
|
-
|
|
201
|
+
try {
|
|
202
|
+
await runSuper();
|
|
203
|
+
}
|
|
204
|
+
catch (error) {
|
|
205
|
+
console.log(`Compilation failed`, error);
|
|
206
|
+
console.log(`Watching...`);
|
|
207
|
+
}
|
|
198
208
|
});
|
|
199
|
-
|
|
209
|
+
try {
|
|
210
|
+
await runSuper();
|
|
211
|
+
}
|
|
212
|
+
catch (error) {
|
|
213
|
+
console.log(`Compilation failed`, error);
|
|
214
|
+
console.log(`Watching...`);
|
|
215
|
+
}
|
|
200
216
|
// prevent from exit
|
|
201
217
|
await new Promise(resolve => { });
|
|
202
218
|
return;
|
|
@@ -259,33 +275,54 @@ const taskArgsStore = { compileAll: false };
|
|
|
259
275
|
await runSuper();
|
|
260
276
|
});
|
|
261
277
|
async function getCompiledAbis(config, compileSolOutput) {
|
|
278
|
+
var _a, _b, _c;
|
|
279
|
+
const sources = config.paths.sources;
|
|
280
|
+
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;
|
|
262
281
|
const emittedArtifacts = (0, alot_1.default)(compileSolOutput.artifactsEmittedPerJob).mapMany((a) => {
|
|
263
282
|
return (0, alot_1.default)(a.artifactsEmittedPerFile).mapMany((artifactPerFile) => {
|
|
264
283
|
return (0, alot_1.default)(artifactPerFile.artifactsEmitted).map((artifactName) => {
|
|
265
284
|
return {
|
|
266
|
-
|
|
285
|
+
// Contract Name
|
|
286
|
+
artifactName: artifactName,
|
|
287
|
+
// Contract local path, aka import
|
|
288
|
+
sourceName: artifactPerFile.file.sourceName,
|
|
289
|
+
// Contract system path, aka file path
|
|
267
290
|
sourceFile: 'file://' + artifactPerFile.file.absolutePath
|
|
268
291
|
};
|
|
269
292
|
})
|
|
270
|
-
.filter(x =>
|
|
293
|
+
.filter(x => {
|
|
294
|
+
if (installs != null) {
|
|
295
|
+
let shouldInstall = installs.some(toInstall => {
|
|
296
|
+
var _a;
|
|
297
|
+
return x.artifactName === toInstall || ((_a = x.sourceName) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === toInstall.toLowerCase();
|
|
298
|
+
});
|
|
299
|
+
return shouldInstall;
|
|
300
|
+
}
|
|
301
|
+
if (sources != null) {
|
|
302
|
+
return x.sourceFile.toLowerCase().startsWith(`file://${sources.toLowerCase()}`);
|
|
303
|
+
}
|
|
304
|
+
return false;
|
|
305
|
+
})
|
|
306
|
+
//.filter(x => x.sourceFile.includes('@openzeppelin') === false)
|
|
271
307
|
.toArray();
|
|
272
308
|
}).toArray();
|
|
273
309
|
}).toArray();
|
|
274
|
-
let namesHash = (0, alot_1.default)(emittedArtifacts).toDictionary(x => x.
|
|
310
|
+
let namesHash = (0, alot_1.default)(emittedArtifacts).toDictionary(x => x.artifactName);
|
|
275
311
|
let files = await atma_io_1.Directory.readFilesAsync(`file://${config.paths.artifacts}/`, '**.json');
|
|
276
312
|
let compileAll = taskArgsStore.compileAll;
|
|
277
313
|
let arr = files
|
|
278
314
|
.map(file => {
|
|
279
315
|
let path = file.uri.toString();
|
|
280
|
-
let match = /(?<
|
|
316
|
+
let match = /(?<sourceFileName>[^\\\/]+)\.sol[\\\/]/.exec(path);
|
|
281
317
|
if (match == null) {
|
|
282
318
|
return null;
|
|
283
319
|
}
|
|
284
|
-
|
|
320
|
+
// assume artifactName === sourceFileName @TODO consider to handle different file-contract names
|
|
321
|
+
let name = match.groups.sourceFileName;
|
|
285
322
|
if (compileAll !== true && name in namesHash === false) {
|
|
286
323
|
return null;
|
|
287
324
|
}
|
|
288
|
-
if (new RegExp(
|
|
325
|
+
if (new RegExp(`[\\\/]${name}\\.json$`).test(path) === false) {
|
|
289
326
|
return null;
|
|
290
327
|
}
|
|
291
328
|
return {
|
|
@@ -312,4 +349,5 @@ var ConfigHelper;
|
|
|
312
349
|
//# sourceMappingURL=index.ts.map
|
|
313
350
|
|
|
314
351
|
}());
|
|
315
|
-
|
|
352
|
+
|
|
353
|
+
// 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.26",
|
|
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": {
|