@layerzerolabs/hardhat-deploy-mnemonic 1.5.32

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 ADDED
@@ -0,0 +1,65 @@
1
+ # hardhat-workspace
2
+
3
+ ## files
4
+
5
+ - `index.ts`: the entry point to this module, can be imported in the hardhat.config.ts, and will change the HardhatContext.
6
+ - `utils.ts`: utility functions, can be imported individually, and will not change the HardhatContext.
7
+
8
+ ## usage
9
+
10
+ use `mnemonics` field to overwrite the setting of `namedAccounts`.
11
+
12
+ ### overwrite the mnemonic
13
+
14
+ ```
15
+ const config: HardhatUserConfig = {
16
+ namedAccounts: {
17
+ deployer: 0
18
+ },
19
+ mnemonics: {
20
+ deployer: {
21
+ mnemonic: 'test test test test test test test test test test test junk',
22
+ path: `m/44'/60'/0'/0'/0'`,
23
+ }
24
+ }
25
+ }
26
+ ```
27
+
28
+ it will be equivalent to
29
+
30
+ ```
31
+ const config: HardhatUserConfig = {
32
+ namedAccounts: {
33
+ deployer: 'privatekey://0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80'
34
+ },
35
+ }
36
+ ```
37
+
38
+ ### overwrite with address
39
+
40
+ ```
41
+ const config: HardhatUserConfig = {
42
+ namedAccounts: {
43
+ deployer: 0
44
+ },
45
+ mnemonics: {
46
+ deployer: {
47
+ address: '0x0000000000000000000000000000000000000001',
48
+ }
49
+ }
50
+ }
51
+ ```
52
+
53
+ it will be equivalent to
54
+
55
+ ```
56
+ const config: HardhatUserConfig = {
57
+ namedAccounts: {
58
+ deployer: '0x0000000000000000000000000000000000000001'
59
+ },
60
+ }
61
+ ```
62
+
63
+ ## TODO
64
+
65
+ - [ ] specialized for networks
@@ -0,0 +1,2 @@
1
+ import './type-extensions';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,mBAAmB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const config_1 = require("hardhat/config");
4
+ // This import is needed to let the TypeScript compiler know that it should include your type
5
+ // extensions in your npm package's types file.
6
+ require("./type-extensions");
7
+ const utils_1 = require("./utils");
8
+ (0, config_1.extendConfig)((config, userConfig) => {
9
+ // We apply our default config here. Any other kind of config resolution
10
+ // or normalization should be placed here.
11
+ //
12
+ // `config` is the resolved config, which will be used during runtime and
13
+ // you should modify.
14
+ // `userConfig` is the config as provided by the user. You should not modify
15
+ // it.
16
+ //
17
+ // If you extended the `HardhatConfig` type, you need to make sure that
18
+ // executing this function ensures that the `config` object is in a valid
19
+ // state for its type, including its extensions. For example, you may
20
+ // need to apply a default value, like in this example.
21
+ });
22
+ (0, config_1.extendEnvironment)((hre) => {
23
+ (0, utils_1.overwriteNamedAccounts)(hre.config, hre.userConfig);
24
+ });
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,2CAAmF;AAGnF,6FAA6F;AAC7F,+CAA+C;AAC/C,6BAA0B;AAC1B,mCAAgD;AAEhD,IAAA,qBAAY,EAAC,CAAC,MAAqB,EAAE,UAAuC,EAAE,EAAE;IAC5E,wEAAwE;IACxE,0CAA0C;IAC1C,EAAE;IACF,yEAAyE;IACzE,qBAAqB;IACrB,4EAA4E;IAC5E,MAAM;IACN,EAAE;IACF,uEAAuE;IACvE,yEAAyE;IACzE,qEAAqE;IACrE,uDAAuD;AAC3D,CAAC,CAAC,CAAA;AAEF,IAAA,0BAAiB,EAAC,CAAC,GAAG,EAAE,EAAE;IACtB,IAAA,8BAAsB,EAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,UAAU,CAAC,CAAA;AACtD,CAAC,CAAC,CAAA"}
@@ -0,0 +1,24 @@
1
+ import 'hardhat/types/config';
2
+ import 'hardhat/types/runtime';
3
+ export interface WorkspacesConfig {
4
+ mnemonic: string;
5
+ [key: string]: string[] | string;
6
+ }
7
+ declare module 'hardhat/types/config' {
8
+ interface HardhatUserConfig {
9
+ mnemonics?: {
10
+ [name: string]: {
11
+ mnemonic?: string;
12
+ path?: string;
13
+ address?: string;
14
+ };
15
+ };
16
+ }
17
+ interface HardhatConfig {
18
+ }
19
+ }
20
+ declare module 'hardhat/types/runtime' {
21
+ interface HardhatRuntimeEnvironment {
22
+ }
23
+ }
24
+ //# 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":"AAEA,OAAO,sBAAsB,CAAA;AAC7B,OAAO,uBAAuB,CAAA;AAE9B,MAAM,WAAW,gBAAgB;IAC7B,QAAQ,EAAE,MAAM,CAAA;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,CAAA;CACnC;AAKD,OAAO,QAAQ,sBAAsB,CAAC;IAClC,UAAiB,iBAAiB;QAC9B,SAAS,CAAC,EAAE;YACR,CAAC,IAAI,EAAE,MAAM,GAAG;gBACZ,QAAQ,CAAC,EAAE,MAAM,CAAA;gBACjB,IAAI,CAAC,EAAE,MAAM,CAAA;gBACb,OAAO,CAAC,EAAE,MAAM,CAAA;aACnB,CAAA;SACJ,CAAA;KACJ;IAED,UAAiB,aAAa;KAAG;CACpC;AAED,OAAO,QAAQ,uBAAuB,CAAC;IACnC,UAAiB,yBAAyB;KAAG;CAChD"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // If your plugin extends types from another plugin, you should import the plugin here.
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;AACvF,+GAA+G;AAC/G,gCAA6B;AAC7B,iCAA8B"}
@@ -0,0 +1,4 @@
1
+ import { HardhatConfig, HardhatUserConfig } from 'hardhat/types/config';
2
+ import './type-extensions';
3
+ export declare function overwriteNamedAccounts(config: HardhatConfig, userConfig: HardhatUserConfig): void;
4
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAEvE,OAAO,mBAAmB,CAAA;AAE1B,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,iBAAiB,QA+B1F"}
package/dist/utils.js ADDED
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.overwriteNamedAccounts = void 0;
4
+ const ethers_1 = require("ethers");
5
+ require("./type-extensions");
6
+ function overwriteNamedAccounts(config, userConfig) {
7
+ // only apply if the hardhat-deploy plugin is enabled
8
+ if ('namedAccounts' in config === false) {
9
+ return;
10
+ }
11
+ if ('mnemonics' in userConfig === false) {
12
+ return;
13
+ }
14
+ // @ts-ignore
15
+ const { mnemonics = {} } = userConfig;
16
+ // `config.namedAccounts = userConfig.namedAccounts;` in the hardhat-deploy plugin
17
+ // and userConfig is freezed by deepFreezeUserConfig in hardhat,
18
+ // so changing the value of config.namedAccounts directly will cause error HH10.
19
+ // it can be fixed by copying the value of config.namedAccounts to a new object.
20
+ const result = {};
21
+ for (const key in mnemonics) {
22
+ const setting = mnemonics[key];
23
+ if ('mnemonic' in setting) {
24
+ const wallet = ethers_1.ethers.Wallet.fromMnemonic(setting.mnemonic, setting.path);
25
+ result[key] = 'privatekey://' + wallet.privateKey;
26
+ }
27
+ else if ('address' in setting) {
28
+ result[key] = setting.address;
29
+ }
30
+ }
31
+ // @ts-ignore
32
+ config.namedAccounts = result;
33
+ }
34
+ exports.overwriteNamedAccounts = overwriteNamedAccounts;
35
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAAA,mCAA+B;AAG/B,6BAA0B;AAE1B,SAAgB,sBAAsB,CAAC,MAAqB,EAAE,UAA6B;IACvF,qDAAqD;IACrD,IAAI,eAAe,IAAI,MAAM,KAAK,KAAK,EAAE;QACrC,OAAM;KACT;IAED,IAAI,WAAW,IAAI,UAAU,KAAK,KAAK,EAAE;QACrC,OAAM;KACT;IAED,aAAa;IACb,MAAM,EAAE,SAAS,GAAG,EAAE,EAAE,GAAG,UAAU,CAAA;IAErC,kFAAkF;IAClF,gEAAgE;IAChE,gFAAgF;IAChF,gFAAgF;IAChF,MAAM,MAAM,GAA2B,EAAE,CAAA;IAEzC,KAAK,MAAM,GAAG,IAAI,SAAS,EAAE;QACzB,MAAM,OAAO,GAAG,SAAS,CAAC,GAAG,CAAC,CAAA;QAC9B,IAAI,UAAU,IAAI,OAAO,EAAE;YACvB,MAAM,MAAM,GAAG,eAAM,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,QAAS,EAAE,OAAO,CAAC,IAAI,CAAC,CAAA;YAC1E,MAAM,CAAC,GAAG,CAAC,GAAG,eAAe,GAAG,MAAM,CAAC,UAAU,CAAA;SACpD;aAAM,IAAI,SAAS,IAAI,OAAO,EAAE;YAC7B,MAAM,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,OAAQ,CAAA;SACjC;KACJ;IAED,aAAa;IACb,MAAM,CAAC,aAAa,GAAG,MAAM,CAAA;AACjC,CAAC;AA/BD,wDA+BC"}
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@layerzerolabs/hardhat-deploy-mnemonic",
3
+ "version": "1.5.32",
4
+ "main": "dist/index.js",
5
+ "files": [
6
+ "dist/**/*"
7
+ ],
8
+ "scripts": {
9
+ "build": "$npm_execpath tsc",
10
+ "clean": "$npm_execpath rimraf dist",
11
+ "format": "$npm_execpath prettier --ignore-path $(git rev-parse --show-toplevel)/.prettierignore --write ",
12
+ "lint": "$npm_execpath eslint --no-error-on-unmatched-pattern --ext .ts --fix"
13
+ },
14
+ "dependencies": {
15
+ "ethers": "^5.7.2"
16
+ },
17
+ "devDependencies": {
18
+ "@jest/globals": "^29.5.0",
19
+ "@layerzerolabs-internal/typescript-config": "^1.5.32",
20
+ "async-mutex": "^0.4.0",
21
+ "hardhat": "^2.16.0",
22
+ "jest": "^29.5.0",
23
+ "lodash": "^4.17.21",
24
+ "rimraf": "^3.0.2",
25
+ "ts-jest": "^29.0.5",
26
+ "typescript": "^5.1.3"
27
+ },
28
+ "peerDependencies": {
29
+ "hardhat": "^2.16.0",
30
+ "hardhat-deploy": "^0.11.23"
31
+ },
32
+ "packageManager": "yarn@3.3.1"
33
+ }