@0xweb/hardhat 0.1.17 → 0.1.18
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 +25 -6
- 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,6 +143,7 @@ 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('package', 'Compile the contracts within a specific mono-repo package. Artifacts and 0xc classes will be placed in the package directory')
|
|
146
147
|
.addOptionalParam('watch', 'Re-runs compilation task on changes', false, {
|
|
147
148
|
name: 'boolean',
|
|
148
149
|
validate(argName, argumentValue) { },
|
|
@@ -164,10 +165,19 @@ const taskArgsStore = { compileAll: false };
|
|
|
164
165
|
}
|
|
165
166
|
})
|
|
166
167
|
.setAction(async (compilationArgs, { run, config, artifacts }, runSuper) => {
|
|
168
|
+
ConfigHelper.resetPaths(config.paths);
|
|
167
169
|
if (compilationArgs.tsgen === false) {
|
|
168
170
|
config['0xweb'].tsgen = false;
|
|
169
171
|
}
|
|
170
|
-
|
|
172
|
+
if (compilationArgs.package != null) {
|
|
173
|
+
config['0xweb'].package = compilationArgs.package;
|
|
174
|
+
if (compilationArgs.artifacts == null) {
|
|
175
|
+
compilationArgs.artifacts = _path_1.$path.join(compilationArgs.package, 'artifacts');
|
|
176
|
+
}
|
|
177
|
+
if (compilationArgs.sources == null) {
|
|
178
|
+
compilationArgs.sources = _path_1.$path.join(compilationArgs.sources, 'contracts');
|
|
179
|
+
}
|
|
180
|
+
}
|
|
171
181
|
// Re-set Artifacts Path manually, as Hardhat initializes the Artifacts Instance before this task runs.
|
|
172
182
|
// Other paths (sources, cache) will be resolved later by hardhat from config
|
|
173
183
|
const artifactsInstance = artifacts;
|
|
@@ -224,13 +234,22 @@ const taskArgsStore = { compileAll: false };
|
|
|
224
234
|
return;
|
|
225
235
|
}
|
|
226
236
|
const contracts = await getCompiledAbis(config, compileSolOutput);
|
|
237
|
+
const pkg = config['0xweb'].package;
|
|
227
238
|
const app = new _0xweb_1.App();
|
|
228
239
|
await (0, alot_1.default)(contracts)
|
|
229
240
|
.forEachAsync(async (contract, i) => {
|
|
230
241
|
console.log(`Generation ${contract.name}(${contract.path}) ${i}/${contracts.length}`);
|
|
231
|
-
|
|
242
|
+
const params = [
|
|
243
|
+
`install`, `${contract.path}`,
|
|
244
|
+
'--name', contract.name,
|
|
245
|
+
'--chain', 'hardhat'
|
|
246
|
+
];
|
|
247
|
+
if (pkg != null) {
|
|
248
|
+
params.push('--output', _path_1.$path.join(pkg, '0xc'));
|
|
249
|
+
}
|
|
250
|
+
await app.execute(params);
|
|
232
251
|
})
|
|
233
|
-
.toArrayAsync({ threads:
|
|
252
|
+
.toArrayAsync({ threads: 4 });
|
|
234
253
|
});
|
|
235
254
|
(0, config_1.task)(constants_1.TASK_0xWEB, 'Generate 0xWeb classes for compiled contracts')
|
|
236
255
|
.setAction(async (_, { run }) => {
|
|
@@ -242,7 +261,7 @@ const taskArgsStore = { compileAll: false };
|
|
|
242
261
|
if (global) {
|
|
243
262
|
return;
|
|
244
263
|
}
|
|
245
|
-
const dir = `/
|
|
264
|
+
const dir = `/0xc/hardhat/`;
|
|
246
265
|
if (await atma_io_1.Directory.existsAsync(dir)) {
|
|
247
266
|
await atma_io_1.Directory.removeAsync(dir);
|
|
248
267
|
}
|