@0xweb/hardhat 0.1.17 → 0.1.19

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 +27 -26
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -128,12 +128,12 @@ var $path;
128
128
  "use strict";
129
129
  Object.defineProperty(exports, "__esModule", { value: true });
130
130
  const alot_1 = require("alot");
131
+ const atma_io_1 = require("atma-io");
132
+ const _0xweb_1 = require("0xweb");
131
133
  const task_names_1 = require("hardhat/builtin-tasks/task-names");
132
134
  const config_1 = require("hardhat/config");
133
135
  const config_2 = _src_config;
134
136
  const constants_1 = _src_constants;
135
- const atma_io_1 = require("atma-io");
136
- const _0xweb_1 = require("0xweb");
137
137
  const _path_1 = _src_utils__path;
138
138
  const taskArgsStore = { compileAll: false };
139
139
  (0, config_1.extendConfig)((config) => {
@@ -143,31 +143,23 @@ const taskArgsStore = { compileAll: false };
143
143
  .addOptionalParam('sources', 'Override the sources directory')
144
144
  .addOptionalParam('artifacts', 'Override the artifacts output directory')
145
145
  .addOptionalParam('root', 'Overrides root directory. If sources is also overridden must be the sub-folder of the sources dir')
146
- .addOptionalParam('watch', 'Re-runs compilation task on changes', false, {
147
- name: 'boolean',
148
- validate(argName, argumentValue) { },
149
- parse(val) {
150
- if (val === '' || val === '1' || val === true || val === 'true') {
151
- return true;
152
- }
153
- return false;
154
- }
155
- })
156
- .addOptionalParam('tsgen', 'Skip the TypeScript class generation', true, {
157
- name: 'boolean',
158
- validate(key, value) { },
159
- parse(key, value) {
160
- if (value === '0' || value === 0 || value === false || value === 'false') {
161
- return false;
162
- }
163
- return true;
164
- }
165
- })
146
+ .addOptionalParam('package', 'Compile the contracts within a specific mono-repo package. Artifacts and 0xc classes will be placed in the package directory')
147
+ .addOptionalParam('tsgen', 'Skip the TypeScript class generation', true, config_1.types.boolean)
148
+ .addFlag('watch', 'Watch sources directory and reruns compilation task on changes')
166
149
  .setAction(async (compilationArgs, { run, config, artifacts }, runSuper) => {
150
+ ConfigHelper.resetPaths(config.paths);
167
151
  if (compilationArgs.tsgen === false) {
168
152
  config['0xweb'].tsgen = false;
169
153
  }
170
- ConfigHelper.resetPaths(config.paths);
154
+ if (compilationArgs.package != null) {
155
+ config['0xweb'].package = compilationArgs.package;
156
+ if (compilationArgs.artifacts == null) {
157
+ compilationArgs.artifacts = _path_1.$path.join(compilationArgs.package, 'artifacts');
158
+ }
159
+ if (compilationArgs.sources == null) {
160
+ compilationArgs.sources = _path_1.$path.join(compilationArgs.sources, 'contracts');
161
+ }
162
+ }
171
163
  // Re-set Artifacts Path manually, as Hardhat initializes the Artifacts Instance before this task runs.
172
164
  // Other paths (sources, cache) will be resolved later by hardhat from config
173
165
  const artifactsInstance = artifacts;
@@ -224,13 +216,22 @@ const taskArgsStore = { compileAll: false };
224
216
  return;
225
217
  }
226
218
  const contracts = await getCompiledAbis(config, compileSolOutput);
219
+ const pkg = config['0xweb'].package;
227
220
  const app = new _0xweb_1.App();
228
221
  await (0, alot_1.default)(contracts)
229
222
  .forEachAsync(async (contract, i) => {
230
223
  console.log(`Generation ${contract.name}(${contract.path}) ${i}/${contracts.length}`);
231
- await app.execute([`install`, `${contract.path}`, '--name', contract.name, '--chain', 'hardhat']);
224
+ const params = [
225
+ `install`, `${contract.path}`,
226
+ '--name', contract.name,
227
+ '--chain', 'hardhat'
228
+ ];
229
+ if (pkg != null) {
230
+ params.push('--output', _path_1.$path.join(pkg, '0xc'));
231
+ }
232
+ await app.execute(params);
232
233
  })
233
- .toArrayAsync({ threads: 1 });
234
+ .toArrayAsync({ threads: 4 });
234
235
  });
235
236
  (0, config_1.task)(constants_1.TASK_0xWEB, 'Generate 0xWeb classes for compiled contracts')
236
237
  .setAction(async (_, { run }) => {
@@ -242,7 +243,7 @@ const taskArgsStore = { compileAll: false };
242
243
  if (global) {
243
244
  return;
244
245
  }
245
- const dir = `/0xweb/hardhat/`;
246
+ const dir = `/0xc/hardhat/`;
246
247
  if (await atma_io_1.Directory.existsAsync(dir)) {
247
248
  await atma_io_1.Directory.removeAsync(dir);
248
249
  }
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.17",
4
+ "version": "0.1.19",
5
5
  "main": "./lib/index.js",
6
6
  "author": {
7
7
  "name": "Alex Kit",