@0xweb/hardhat 0.1.24 → 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.
Files changed (2) hide show
  1. package/lib/index.js +36 -10
  2. package/package.json +6 -5
package/lib/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
 
2
- // source ./RootModule.js
2
+ // source ./RootModuleWrapped.js
3
3
  (function(){
4
-
5
- var _src_config = {};
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) {
@@ -271,33 +275,54 @@ const taskArgsStore = { compileAll: false };
271
275
  await runSuper();
272
276
  });
273
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;
274
281
  const emittedArtifacts = (0, alot_1.default)(compileSolOutput.artifactsEmittedPerJob).mapMany((a) => {
275
282
  return (0, alot_1.default)(a.artifactsEmittedPerFile).mapMany((artifactPerFile) => {
276
283
  return (0, alot_1.default)(artifactPerFile.artifactsEmitted).map((artifactName) => {
277
284
  return {
278
- name: artifactName,
285
+ // Contract Name
286
+ artifactName: artifactName,
287
+ // Contract local path, aka import
288
+ sourceName: artifactPerFile.file.sourceName,
289
+ // Contract system path, aka file path
279
290
  sourceFile: 'file://' + artifactPerFile.file.absolutePath
280
291
  };
281
292
  })
282
- .filter(x => x.sourceFile.includes('@openzeppelin') === false)
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)
283
307
  .toArray();
284
308
  }).toArray();
285
309
  }).toArray();
286
- let namesHash = (0, alot_1.default)(emittedArtifacts).toDictionary(x => x.name);
310
+ let namesHash = (0, alot_1.default)(emittedArtifacts).toDictionary(x => x.artifactName);
287
311
  let files = await atma_io_1.Directory.readFilesAsync(`file://${config.paths.artifacts}/`, '**.json');
288
312
  let compileAll = taskArgsStore.compileAll;
289
313
  let arr = files
290
314
  .map(file => {
291
315
  let path = file.uri.toString();
292
- let match = /(?<name>[^\\\/]+)\.sol[\\\/]/.exec(path);
316
+ let match = /(?<sourceFileName>[^\\\/]+)\.sol[\\\/]/.exec(path);
293
317
  if (match == null) {
294
318
  return null;
295
319
  }
296
- let name = match.groups.name;
320
+ // assume artifactName === sourceFileName @TODO consider to handle different file-contract names
321
+ let name = match.groups.sourceFileName;
297
322
  if (compileAll !== true && name in namesHash === false) {
298
323
  return null;
299
324
  }
300
- if (new RegExp(`${name}\\.json$`).test(path) === false) {
325
+ if (new RegExp(`[\\\/]${name}\\.json$`).test(path) === false) {
301
326
  return null;
302
327
  }
303
328
  return {
@@ -324,4 +349,5 @@ var ConfigHelper;
324
349
  //# sourceMappingURL=index.ts.map
325
350
 
326
351
  }());
327
- // end:source ./RootModule.js
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.24",
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.40",
21
+ "0xweb": "^0.10.69",
22
22
  "alot": "^0.3.0",
23
- "atma-io": "^1.2.65",
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.1.7",
37
- "atma": "^0.15.17",
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": {