@layerzerolabs/hardhat-collect-outcomes 1.5.44
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/README.md +58 -0
- package/dist/src/ExampleHardhatRuntimeEnvironmentField.d.ts +4 -0
- package/dist/src/ExampleHardhatRuntimeEnvironmentField.d.ts.map +1 -0
- package/dist/src/ExampleHardhatRuntimeEnvironmentField.js +10 -0
- package/dist/src/ExampleHardhatRuntimeEnvironmentField.js.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +88 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/type-extensions.d.ts +39 -0
- package/dist/src/type-extensions.d.ts.map +1 -0
- package/dist/src/type-extensions.js +7 -0
- package/dist/src/type-extensions.js.map +1 -0
- package/dist/src/utils.d.ts +4 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/dist/src/utils.js +60 -0
- package/dist/src/utils.js.map +1 -0
- package/package.json +64 -0
- package/src/ExampleHardhatRuntimeEnvironmentField.ts +5 -0
- package/src/index.ts +103 -0
- package/src/type-extensions.ts +59 -0
- package/src/utils.ts +35 -0
package/README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Hardhat TypeScript plugin boilerplate
|
|
2
|
+
|
|
3
|
+
This is a sample Hardhat plugin written in TypeScript. Creating a Hardhat plugin
|
|
4
|
+
can be as easy as extracting a part of your config into a different file and
|
|
5
|
+
publishing it to npm.
|
|
6
|
+
|
|
7
|
+
This sample project contains an example on how to do that, but also comes with
|
|
8
|
+
many more features:
|
|
9
|
+
|
|
10
|
+
- A mocha test suite ready to use
|
|
11
|
+
- TravisCI already setup
|
|
12
|
+
- A package.json with scripts and publishing info
|
|
13
|
+
- Examples on how to do different things
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
To start working on your project, just run
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Plugin development
|
|
24
|
+
|
|
25
|
+
Make sure to read our [Plugin Development Guide](https://hardhat.org/advanced/building-plugins.html) to learn how to build a plugin.
|
|
26
|
+
|
|
27
|
+
## Testing
|
|
28
|
+
|
|
29
|
+
Running `npm run test` will run every test located in the `test/` folder. They
|
|
30
|
+
use [mocha](https://mochajs.org) and [chai](https://www.chaijs.com/),
|
|
31
|
+
but you can customize them.
|
|
32
|
+
|
|
33
|
+
We recommend creating unit tests for your own modules, and integration tests for
|
|
34
|
+
the interaction of the plugin with Hardhat and its dependencies.
|
|
35
|
+
|
|
36
|
+
## Linting and autoformat
|
|
37
|
+
|
|
38
|
+
All of Hardhat projects use [prettier](https://prettier.io/) and
|
|
39
|
+
[tslint](https://palantir.github.io/tslint/).
|
|
40
|
+
|
|
41
|
+
You can check if your code style is correct by running `npm run lint`, and fix
|
|
42
|
+
it with `npm run lint:fix`.
|
|
43
|
+
|
|
44
|
+
## Building the project
|
|
45
|
+
|
|
46
|
+
Just run `npm run build` ️👷
|
|
47
|
+
|
|
48
|
+
## README file
|
|
49
|
+
|
|
50
|
+
This README describes this boilerplate project, but won't be very useful to your
|
|
51
|
+
plugin users.
|
|
52
|
+
|
|
53
|
+
Take a look at `README-TEMPLATE.md` for an example of what a Hardhat plugin's
|
|
54
|
+
README should look like.
|
|
55
|
+
|
|
56
|
+
## Migrating from Buidler?
|
|
57
|
+
|
|
58
|
+
Take a look at [the migration guide](MIGRATION.md)!
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExampleHardhatRuntimeEnvironmentField.d.ts","sourceRoot":"","sources":["../../src/ExampleHardhatRuntimeEnvironmentField.ts"],"names":[],"mappings":"AAAA,qBAAa,qCAAqC;IACvC,QAAQ;CAGlB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExampleHardhatRuntimeEnvironmentField = void 0;
|
|
4
|
+
class ExampleHardhatRuntimeEnvironmentField {
|
|
5
|
+
sayHello() {
|
|
6
|
+
return 'hello';
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
exports.ExampleHardhatRuntimeEnvironmentField = ExampleHardhatRuntimeEnvironmentField;
|
|
10
|
+
//# sourceMappingURL=ExampleHardhatRuntimeEnvironmentField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExampleHardhatRuntimeEnvironmentField.js","sourceRoot":"","sources":["../../src/ExampleHardhatRuntimeEnvironmentField.ts"],"names":[],"mappings":";;;AAAA,MAAa,qCAAqC;IACvC,QAAQ;QACX,OAAO,OAAO,CAAA;IAClB,CAAC;CACJ;AAJD,sFAIC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const glob_1 = require("glob");
|
|
4
|
+
const task_names_1 = require("hardhat/builtin-tasks/task-names");
|
|
5
|
+
const config_1 = require("hardhat/config");
|
|
6
|
+
const hardhat_deploy_1 = require("hardhat-deploy");
|
|
7
|
+
// This import is needed to let the TypeScript compiler know that it should include your type
|
|
8
|
+
// extensions in your npm package's types file.
|
|
9
|
+
require("./type-extensions");
|
|
10
|
+
const utils_1 = require("./utils");
|
|
11
|
+
(0, config_1.extendConfig)((config, userConfig) => {
|
|
12
|
+
// We apply our default config here. Any other kind of config resolution
|
|
13
|
+
// or normalization should be placed here.
|
|
14
|
+
//
|
|
15
|
+
// `config` is the resolved config, which will be used during runtime and
|
|
16
|
+
// you should modify.
|
|
17
|
+
// `userConfig` is the config as provided by the user. You should not modify
|
|
18
|
+
// it.
|
|
19
|
+
//
|
|
20
|
+
// If you extended the `HardhatConfig` type, you need to make sure that
|
|
21
|
+
// executing this function ensures that the `config` object is in a valid
|
|
22
|
+
// state for its type, including its extensions. For example, you may
|
|
23
|
+
// need to apply a default value, like in this example.
|
|
24
|
+
const userCollects = userConfig.paths?.collects ?? {};
|
|
25
|
+
config.paths.collects = {};
|
|
26
|
+
if (userCollects.artifacts !== undefined) {
|
|
27
|
+
const setting = userCollects.artifacts;
|
|
28
|
+
config.paths.collects.artifacts = {
|
|
29
|
+
target: (0, utils_1.abspath)(setting.target, config.paths.root),
|
|
30
|
+
patterns: setting.patterns ?? [],
|
|
31
|
+
skip: setting.skip,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
if (userCollects.deployments !== undefined) {
|
|
35
|
+
const setting = userCollects.deployments;
|
|
36
|
+
config.paths.collects.deployments = {
|
|
37
|
+
target: (0, utils_1.abspath)(setting.target, config.paths.root),
|
|
38
|
+
patterns: setting.patterns ?? [],
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
if (userCollects.typechain !== undefined) {
|
|
42
|
+
const setting = userCollects.typechain;
|
|
43
|
+
config.paths.collects.typechain = {
|
|
44
|
+
target: (0, utils_1.abspath)(setting.target, config.paths.root),
|
|
45
|
+
patterns: setting.patterns ?? [],
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
(0, config_1.extendEnvironment)((hre) => { });
|
|
50
|
+
(0, config_1.subtask)(task_names_1.TASK_COMPILE_SOLIDITY_COMPILE_JOBS, 'copying artifacts').setAction(async (taskArgs, { config, network }, runSuper) => {
|
|
51
|
+
const compileSolOutput = await runSuper(taskArgs);
|
|
52
|
+
if (config.paths.collects.artifacts === undefined) {
|
|
53
|
+
return compileSolOutput;
|
|
54
|
+
}
|
|
55
|
+
const { skip } = config.paths.collects.artifacts;
|
|
56
|
+
if (skip) {
|
|
57
|
+
if (skip.zksync !== undefined && skip.zksync === network.zksync) {
|
|
58
|
+
return compileSolOutput;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const artifactsRoot = config.paths.artifacts;
|
|
62
|
+
const patterns = config.paths.collects.artifacts.patterns.map((p) => `${artifactsRoot}/${p}`);
|
|
63
|
+
const target = config.paths.collects.artifacts.target;
|
|
64
|
+
for (const pattern of patterns) {
|
|
65
|
+
const files = await (0, glob_1.glob)(pattern);
|
|
66
|
+
await Promise.all(files.map(async (f) => {
|
|
67
|
+
await (0, utils_1.copyFilesInRelativePath)(artifactsRoot, f, target);
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
70
|
+
return compileSolOutput;
|
|
71
|
+
});
|
|
72
|
+
(0, config_1.subtask)(hardhat_deploy_1.TASK_DEPLOY_RUN_DEPLOY, 'deploy run only').setAction(async (taskArgs, { config }, runSuper) => {
|
|
73
|
+
const deployOutput = await runSuper(taskArgs);
|
|
74
|
+
if (config.paths.collects.deployments === undefined) {
|
|
75
|
+
return deployOutput;
|
|
76
|
+
}
|
|
77
|
+
const deploymentsRoot = config.paths.deployments;
|
|
78
|
+
const patterns = config.paths.collects.deployments.patterns.map((p) => `${deploymentsRoot}/${p}`);
|
|
79
|
+
const target = config.paths.collects.deployments.target;
|
|
80
|
+
for (const pattern of patterns) {
|
|
81
|
+
const files = await (0, glob_1.glob)(pattern);
|
|
82
|
+
await Promise.all(files.map(async (f) => {
|
|
83
|
+
await (0, utils_1.copyFilesInRelativePath)(deploymentsRoot, f, target);
|
|
84
|
+
}));
|
|
85
|
+
}
|
|
86
|
+
return deployOutput;
|
|
87
|
+
});
|
|
88
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;AAAA,+BAA2B;AAC3B,iEAAqF;AACrF,2CAAyE;AAEzE,mDAAuD;AAEvD,6FAA6F;AAC7F,+CAA+C;AAC/C,6BAA0B;AAC1B,mCAA0D;AAE1D,IAAA,qBAAY,EAAC,CAAC,MAAqB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
|
2
|
+
import 'hardhat/types/runtime';
|
|
3
|
+
declare module 'hardhat/types/config' {
|
|
4
|
+
interface CollectsArtifactsConfig {
|
|
5
|
+
skip?: {
|
|
6
|
+
zksync?: boolean;
|
|
7
|
+
};
|
|
8
|
+
target: string;
|
|
9
|
+
patterns: string[];
|
|
10
|
+
}
|
|
11
|
+
interface CollectsDeploymentsConfig {
|
|
12
|
+
target: string;
|
|
13
|
+
patterns: string[];
|
|
14
|
+
}
|
|
15
|
+
interface CollectsTypeChainConfig {
|
|
16
|
+
target: string;
|
|
17
|
+
patterns: string[];
|
|
18
|
+
}
|
|
19
|
+
interface ProjectPathsUserConfig {
|
|
20
|
+
collects?: {
|
|
21
|
+
artifacts?: CollectsArtifactsConfig;
|
|
22
|
+
deployments?: CollectsDeploymentsConfig;
|
|
23
|
+
typechain?: CollectsTypeChainConfig;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
interface ProjectPathsConfig {
|
|
27
|
+
collects: {
|
|
28
|
+
artifacts?: CollectsArtifactsConfig;
|
|
29
|
+
deployments?: CollectsDeploymentsConfig;
|
|
30
|
+
typechain?: CollectsTypeChainConfig;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
declare module 'hardhat/types/runtime' {
|
|
35
|
+
interface HardhatArguments {
|
|
36
|
+
preprocessor?: string;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=type-extensions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-extensions.d.ts","sourceRoot":"","sources":["../../src/type-extensions.ts"],"names":[],"mappings":"AAGA,OAAO,sBAAsB,CAAA;AAC7B,OAAO,uBAAuB,CAAA;AAE9B,OAAO,QAAQ,sBAAsB,CAAC;IAGlC,UAAiB,uBAAuB;QACpC,IAAI,CAAC,EAAE;YACH,MAAM,CAAC,EAAE,OAAO,CAAA;SACnB,CAAA;QACD,MAAM,EAAE,MAAM,CAAA;QACd,QAAQ,EAAE,MAAM,EAAE,CAAA;KACrB;IACD,UAAiB,yBAAyB;QACtC,MAAM,EAAE,MAAM,CAAA;QACd,QAAQ,EAAE,MAAM,EAAE,CAAA;KACrB;IACD,UAAiB,uBAAuB;QACpC,MAAM,EAAE,MAAM,CAAA;QACd,QAAQ,EAAE,MAAM,EAAE,CAAA;KACrB;IAID,UAAiB,sBAAsB;QACnC,QAAQ,CAAC,EAAE;YACP,SAAS,CAAC,EAAE,uBAAuB,CAAA;YACnC,WAAW,CAAC,EAAE,yBAAyB,CAAA;YACvC,SAAS,CAAC,EAAE,uBAAuB,CAAA;SACtC,CAAA;KACJ;IAOD,UAAiB,kBAAkB;QAC/B,QAAQ,EAAE;YACN,SAAS,CAAC,EAAE,uBAAuB,CAAA;YACnC,WAAW,CAAC,EAAE,yBAAyB,CAAA;YACvC,SAAS,CAAC,EAAE,uBAAuB,CAAA;SACtC,CAAA;KACJ;CACJ;AAED,OAAO,QAAQ,uBAAuB,CAAC;IAMnC,UAAiB,gBAAgB;QAC7B,YAAY,CAAC,EAAE,MAAM,CAAA;KACxB;CACJ"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// If your plugin extends types from another plugin, you should import the plugin here.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
// To extend one of Hardhat's types, you need to import the module where it has been defined, and redeclare it.
|
|
5
|
+
require("hardhat/types/config");
|
|
6
|
+
require("hardhat/types/runtime");
|
|
7
|
+
//# sourceMappingURL=type-extensions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-extensions.js","sourceRoot":"","sources":["../../src/type-extensions.ts"],"names":[],"mappings":";AAAA,uFAAuF;;AAEvF,+GAA+G;AAC/G,gCAA6B;AAC7B,iCAA8B"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function abspath(p: string, root: string): string;
|
|
2
|
+
export declare function globFiles(files: string[], patterns: string[]): Promise<string[]>;
|
|
3
|
+
export declare function copyFilesInRelativePath(root: string, sour: string, target: string): Promise<void>;
|
|
4
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAOA,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAK9C;AAED,wBAAsB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAOtF;AAED,wBAAsB,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,iBAWvF"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.copyFilesInRelativePath = exports.globFiles = exports.abspath = void 0;
|
|
27
|
+
const path = __importStar(require("path"));
|
|
28
|
+
const minimatch_1 = require("minimatch");
|
|
29
|
+
const fs = require('node:fs');
|
|
30
|
+
const util = require('node:util');
|
|
31
|
+
function abspath(p, root) {
|
|
32
|
+
if (path.isAbsolute(p)) {
|
|
33
|
+
return p;
|
|
34
|
+
}
|
|
35
|
+
return path.normalize(path.join(root, p));
|
|
36
|
+
}
|
|
37
|
+
exports.abspath = abspath;
|
|
38
|
+
async function globFiles(files, patterns) {
|
|
39
|
+
const retval = [];
|
|
40
|
+
for (const pattern of patterns) {
|
|
41
|
+
const rv = files.filter(minimatch_1.minimatch.filter(pattern, { matchBase: true }));
|
|
42
|
+
retval.push(...rv);
|
|
43
|
+
}
|
|
44
|
+
return retval;
|
|
45
|
+
}
|
|
46
|
+
exports.globFiles = globFiles;
|
|
47
|
+
async function copyFilesInRelativePath(root, sour, target) {
|
|
48
|
+
if (!path.isAbsolute(sour)) {
|
|
49
|
+
throw new Error(`sour must be absolute path: ${sour}`);
|
|
50
|
+
}
|
|
51
|
+
const relative = path.relative(root, sour);
|
|
52
|
+
const dest = path.join(target, relative);
|
|
53
|
+
const dir = path.dirname(dest);
|
|
54
|
+
if (!fs.exists(dir)) {
|
|
55
|
+
await util.promisify(fs.mkdir)(dir, { recursive: true });
|
|
56
|
+
}
|
|
57
|
+
await util.promisify(fs.copyFile)(sour, dest);
|
|
58
|
+
}
|
|
59
|
+
exports.copyFilesInRelativePath = copyFilesInRelativePath;
|
|
60
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot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,CAAC,CAAA;IAC9B,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;QACjB,MAAM,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;KAC3D;IACD,MAAM,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;AACjD,CAAC;AAXD,0DAWC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@layerzerolabs/hardhat-collect-outcomes",
|
|
3
|
+
"version": "1.5.44",
|
|
4
|
+
"description": "hardhat plugin to collect files from smart contracts",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"ethereum",
|
|
7
|
+
"smart-contracts",
|
|
8
|
+
"hardhat",
|
|
9
|
+
"hardhat-plugin"
|
|
10
|
+
],
|
|
11
|
+
"license": "BUSL-1.1",
|
|
12
|
+
"author": "LayerZero Labs",
|
|
13
|
+
"main": "dist/src/index.js",
|
|
14
|
+
"types": "dist/src/index.d.ts",
|
|
15
|
+
"files": [
|
|
16
|
+
"dist/src/**/*",
|
|
17
|
+
"src/**/*",
|
|
18
|
+
"LICENSE",
|
|
19
|
+
"README.md"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "$npm_execpath tsc",
|
|
23
|
+
"clean": "$npm_execpath rimraf dist",
|
|
24
|
+
"format": "$npm_execpath prettier --ignore-path $(git rev-parse --show-toplevel)/.prettierignore --write ",
|
|
25
|
+
"lint": "$npm_execpath eslint --no-error-on-unmatched-pattern --ext .ts --fix",
|
|
26
|
+
"test": "$npm_execpath mocha --timeout 60000 --exit 'test/**/*.test.ts'",
|
|
27
|
+
"watch": "$npm_execpath tsc -w"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@ethersproject/abi": "^5.7.0",
|
|
31
|
+
"@ethersproject/providers": "^5.7.2",
|
|
32
|
+
"glob": "^9.3.0",
|
|
33
|
+
"minimatch": "^7.4.2",
|
|
34
|
+
"rimraf": "^3.0.2"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@ethersproject/abi": "^5.7.0",
|
|
38
|
+
"@layerzerolabs-internal/typescript-config": "^1.5.44",
|
|
39
|
+
"@nomiclabs/hardhat-ethers": "^2.2.2",
|
|
40
|
+
"@typechain/ethers-v5": "^10.2.0",
|
|
41
|
+
"@typechain/hardhat": "^6.1.5",
|
|
42
|
+
"@types/chai": "^4.1.7",
|
|
43
|
+
"@types/fs-extra": "^5.0.4",
|
|
44
|
+
"@types/mocha": "^5.2.6",
|
|
45
|
+
"@types/node": "^8.10.38",
|
|
46
|
+
"chai": "^4.2.0",
|
|
47
|
+
"ethers": "^5.7.2",
|
|
48
|
+
"hardhat": "^2.16.0",
|
|
49
|
+
"hardhat-deploy": "^0.11.25",
|
|
50
|
+
"mocha": "^7.1.2",
|
|
51
|
+
"prettier": "2.0.5",
|
|
52
|
+
"ts-node": "^8.1.0",
|
|
53
|
+
"typechain": "^8.1.1",
|
|
54
|
+
"typescript": "^5.1.3"
|
|
55
|
+
},
|
|
56
|
+
"peerDependencies": {
|
|
57
|
+
"@nomiclabs/hardhat-ethers": "^2.2.2",
|
|
58
|
+
"@typechain/ethers-v5": "^10.2.0",
|
|
59
|
+
"@typechain/hardhat": "^6.1.5",
|
|
60
|
+
"ethers": "^5.7.2",
|
|
61
|
+
"hardhat": "^2.16.0",
|
|
62
|
+
"hardhat-deploy": "^0.11.25"
|
|
63
|
+
}
|
|
64
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { glob } from 'glob'
|
|
2
|
+
import { TASK_COMPILE_SOLIDITY_COMPILE_JOBS } from 'hardhat/builtin-tasks/task-names'
|
|
3
|
+
import { extendConfig, extendEnvironment, subtask } from 'hardhat/config'
|
|
4
|
+
import { HardhatConfig, HardhatUserConfig } from 'hardhat/types'
|
|
5
|
+
import { TASK_DEPLOY_RUN_DEPLOY } from 'hardhat-deploy'
|
|
6
|
+
|
|
7
|
+
// This import is needed to let the TypeScript compiler know that it should include your type
|
|
8
|
+
// extensions in your npm package's types file.
|
|
9
|
+
import './type-extensions'
|
|
10
|
+
import { abspath, copyFilesInRelativePath } from './utils'
|
|
11
|
+
|
|
12
|
+
extendConfig((config: HardhatConfig, userConfig: Readonly<HardhatUserConfig>) => {
|
|
13
|
+
// We apply our default config here. Any other kind of config resolution
|
|
14
|
+
// or normalization should be placed here.
|
|
15
|
+
//
|
|
16
|
+
// `config` is the resolved config, which will be used during runtime and
|
|
17
|
+
// you should modify.
|
|
18
|
+
// `userConfig` is the config as provided by the user. You should not modify
|
|
19
|
+
// it.
|
|
20
|
+
//
|
|
21
|
+
// If you extended the `HardhatConfig` type, you need to make sure that
|
|
22
|
+
// executing this function ensures that the `config` object is in a valid
|
|
23
|
+
// state for its type, including its extensions. For example, you may
|
|
24
|
+
// need to apply a default value, like in this example.
|
|
25
|
+
const userCollects = userConfig.paths?.collects ?? {}
|
|
26
|
+
config.paths.collects = {}
|
|
27
|
+
|
|
28
|
+
if (userCollects.artifacts !== undefined) {
|
|
29
|
+
const setting = userCollects.artifacts
|
|
30
|
+
config.paths.collects.artifacts = {
|
|
31
|
+
target: abspath(setting.target, config.paths.root),
|
|
32
|
+
patterns: setting.patterns ?? [],
|
|
33
|
+
skip: setting.skip,
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (userCollects.deployments !== undefined) {
|
|
38
|
+
const setting = userCollects.deployments
|
|
39
|
+
config.paths.collects.deployments = {
|
|
40
|
+
target: abspath(setting.target, config.paths.root),
|
|
41
|
+
patterns: setting.patterns ?? [],
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (userCollects.typechain !== undefined) {
|
|
46
|
+
const setting = userCollects.typechain
|
|
47
|
+
config.paths.collects.typechain = {
|
|
48
|
+
target: abspath(setting.target, config.paths.root),
|
|
49
|
+
patterns: setting.patterns ?? [],
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
extendEnvironment((hre) => {})
|
|
55
|
+
|
|
56
|
+
subtask(TASK_COMPILE_SOLIDITY_COMPILE_JOBS, 'copying artifacts').setAction(
|
|
57
|
+
async (taskArgs, { config, network }, runSuper) => {
|
|
58
|
+
const compileSolOutput = await runSuper(taskArgs)
|
|
59
|
+
if (config.paths.collects.artifacts === undefined) {
|
|
60
|
+
return compileSolOutput
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const { skip } = config.paths.collects.artifacts
|
|
64
|
+
if (skip) {
|
|
65
|
+
if (skip.zksync !== undefined && skip.zksync === network.zksync) {
|
|
66
|
+
return compileSolOutput
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const artifactsRoot = config.paths.artifacts
|
|
70
|
+
const patterns = config.paths.collects.artifacts!.patterns.map((p) => `${artifactsRoot}/${p}`)
|
|
71
|
+
const target = config.paths.collects.artifacts!.target
|
|
72
|
+
for (const pattern of patterns) {
|
|
73
|
+
const files = await glob(pattern)
|
|
74
|
+
await Promise.all(
|
|
75
|
+
files.map(async (f) => {
|
|
76
|
+
await copyFilesInRelativePath(artifactsRoot, f, target)
|
|
77
|
+
})
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return compileSolOutput
|
|
82
|
+
}
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
subtask(TASK_DEPLOY_RUN_DEPLOY, 'deploy run only').setAction(async (taskArgs, { config }, runSuper) => {
|
|
86
|
+
const deployOutput = await runSuper(taskArgs)
|
|
87
|
+
if (config.paths.collects.deployments === undefined) {
|
|
88
|
+
return deployOutput
|
|
89
|
+
}
|
|
90
|
+
const deploymentsRoot = config.paths.deployments
|
|
91
|
+
const patterns = config.paths.collects.deployments!.patterns.map((p) => `${deploymentsRoot}/${p}`)
|
|
92
|
+
const target = config.paths.collects.deployments!.target
|
|
93
|
+
for (const pattern of patterns) {
|
|
94
|
+
const files = await glob(pattern)
|
|
95
|
+
await Promise.all(
|
|
96
|
+
files.map(async (f) => {
|
|
97
|
+
await copyFilesInRelativePath(deploymentsRoot, f, target)
|
|
98
|
+
})
|
|
99
|
+
)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return deployOutput
|
|
103
|
+
})
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// If your plugin extends types from another plugin, you should import the plugin here.
|
|
2
|
+
|
|
3
|
+
// To extend one of Hardhat's types, you need to import the module where it has been defined, and redeclare it.
|
|
4
|
+
import 'hardhat/types/config'
|
|
5
|
+
import 'hardhat/types/runtime'
|
|
6
|
+
|
|
7
|
+
declare module 'hardhat/types/config' {
|
|
8
|
+
// This is an example of an extension to one of the Hardhat config values.
|
|
9
|
+
|
|
10
|
+
export interface CollectsArtifactsConfig {
|
|
11
|
+
skip?: {
|
|
12
|
+
zksync?: boolean
|
|
13
|
+
}
|
|
14
|
+
target: string
|
|
15
|
+
patterns: string[]
|
|
16
|
+
}
|
|
17
|
+
export interface CollectsDeploymentsConfig {
|
|
18
|
+
target: string
|
|
19
|
+
patterns: string[]
|
|
20
|
+
}
|
|
21
|
+
export interface CollectsTypeChainConfig {
|
|
22
|
+
target: string
|
|
23
|
+
patterns: string[]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// We extend the UserConfig type, which represents the config as written
|
|
27
|
+
// by the users. Things are normally optional here.
|
|
28
|
+
export interface ProjectPathsUserConfig {
|
|
29
|
+
collects?: {
|
|
30
|
+
artifacts?: CollectsArtifactsConfig
|
|
31
|
+
deployments?: CollectsDeploymentsConfig
|
|
32
|
+
typechain?: CollectsTypeChainConfig
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// We also extend the Config type, which represents the configuration
|
|
37
|
+
// after it has been resolved. This is the type used during the execution
|
|
38
|
+
// of tasks, tests and scripts.
|
|
39
|
+
// Normally, you don't want things to be optional here. As you can apply
|
|
40
|
+
// default values using the extendConfig function.
|
|
41
|
+
export interface ProjectPathsConfig {
|
|
42
|
+
collects: {
|
|
43
|
+
artifacts?: CollectsArtifactsConfig
|
|
44
|
+
deployments?: CollectsDeploymentsConfig
|
|
45
|
+
typechain?: CollectsTypeChainConfig
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
declare module 'hardhat/types/runtime' {
|
|
51
|
+
// This is an example of an extension to the Hardhat Runtime Environment.
|
|
52
|
+
// This new field will be available in tasks' actions, scripts, and tests.
|
|
53
|
+
// export interface HardhatRuntimeEnvironment {
|
|
54
|
+
// }
|
|
55
|
+
|
|
56
|
+
export interface HardhatArguments {
|
|
57
|
+
preprocessor?: string
|
|
58
|
+
}
|
|
59
|
+
}
|
package/src/utils.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as path from 'path'
|
|
2
|
+
|
|
3
|
+
import { minimatch } from 'minimatch'
|
|
4
|
+
|
|
5
|
+
const fs = require('node:fs')
|
|
6
|
+
const util = require('node:util')
|
|
7
|
+
|
|
8
|
+
export function abspath(p: string, root: string) {
|
|
9
|
+
if (path.isAbsolute(p)) {
|
|
10
|
+
return p
|
|
11
|
+
}
|
|
12
|
+
return path.normalize(path.join(root, p))
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export async function globFiles(files: string[], patterns: string[]): Promise<string[]> {
|
|
16
|
+
const retval: string[] = []
|
|
17
|
+
for (const pattern of patterns) {
|
|
18
|
+
const rv = files.filter(minimatch.filter(pattern, { matchBase: true }))
|
|
19
|
+
retval.push(...rv)
|
|
20
|
+
}
|
|
21
|
+
return retval
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export async function copyFilesInRelativePath(root: string, sour: string, target: string) {
|
|
25
|
+
if (!path.isAbsolute(sour)) {
|
|
26
|
+
throw new Error(`sour must be absolute path: ${sour}`)
|
|
27
|
+
}
|
|
28
|
+
const relative = path.relative(root, sour)
|
|
29
|
+
const dest = path.join(target, relative)
|
|
30
|
+
const dir = path.dirname(dest)
|
|
31
|
+
if (!fs.exists(dir)) {
|
|
32
|
+
await util.promisify(fs.mkdir)(dir, { recursive: true })
|
|
33
|
+
}
|
|
34
|
+
await util.promisify(fs.copyFile)(sour, dest)
|
|
35
|
+
}
|