@xyo-network/xl1-cli-lib 1.7.10 → 1.7.12
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 +1 -1
- package/dist/node/index.mjs +32 -6
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/orchestration/services/implementation/account.d.ts.map +1 -1
- package/dist/node/runCLI.d.ts.map +1 -1
- package/dist/node/tryParseConfig.d.ts +6 -0
- package/dist/node/tryParseConfig.d.ts.map +1 -0
- package/dist/node/xl1.mjs +32 -6
- package/dist/node/xl1.mjs.map +1 -1
- package/package.json +35 -33
- package/src/orchestration/services/implementation/account.ts +5 -1
- package/src/runCLI.ts +18 -4
- package/src/tryParseConfig.ts +41 -0
- package/dist/node/initConfig.d.ts +0 -3
- package/dist/node/initConfig.d.ts.map +0 -1
- package/src/initConfig.ts +0 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/xl1-cli-lib",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.12",
|
|
4
4
|
"description": "XYO Layer One CLI Library",
|
|
5
5
|
"homepage": "https://xylabs.com",
|
|
6
6
|
"bugs": {
|
|
@@ -40,35 +40,37 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@opentelemetry/api": "^1.9.0",
|
|
43
|
-
"@xylabs/array": "^4.13.
|
|
44
|
-
"@xylabs/assert": "^4.13.
|
|
45
|
-
"@xylabs/base": "^4.13.
|
|
46
|
-
"@xylabs/creatable": "^4.13.
|
|
47
|
-
"@xylabs/delay": "^4.13.
|
|
48
|
-
"@xylabs/forget": "^4.13.
|
|
49
|
-
"@xylabs/hex": "^4.13.
|
|
50
|
-
"@xylabs/logger": "^4.13.
|
|
51
|
-
"@xylabs/
|
|
52
|
-
"@xylabs/
|
|
53
|
-
"@xylabs/
|
|
54
|
-
"@
|
|
55
|
-
"@xyo-network/archivist-
|
|
56
|
-
"@xyo-network/archivist-
|
|
57
|
-
"@xyo-network/
|
|
58
|
-
"@xyo-network/chain-
|
|
59
|
-
"@xyo-network/chain-
|
|
60
|
-
"@xyo-network/chain-
|
|
61
|
-
"@xyo-network/chain-
|
|
62
|
-
"@xyo-network/chain-
|
|
63
|
-
"@xyo-network/chain-
|
|
64
|
-
"@xyo-network/chain-
|
|
65
|
-
"@xyo-network/
|
|
66
|
-
"@xyo-network/payload-
|
|
67
|
-
"@xyo-network/
|
|
68
|
-
"@xyo-network/wallet
|
|
69
|
-
"@xyo-network/
|
|
70
|
-
"@xyo-network/xl1-protocol
|
|
43
|
+
"@xylabs/array": "^4.13.23",
|
|
44
|
+
"@xylabs/assert": "^4.13.23",
|
|
45
|
+
"@xylabs/base": "^4.13.23",
|
|
46
|
+
"@xylabs/creatable": "^4.13.23",
|
|
47
|
+
"@xylabs/delay": "^4.13.23",
|
|
48
|
+
"@xylabs/forget": "^4.13.23",
|
|
49
|
+
"@xylabs/hex": "^4.13.23",
|
|
50
|
+
"@xylabs/logger": "^4.13.23",
|
|
51
|
+
"@xylabs/object": "^4.13.23",
|
|
52
|
+
"@xylabs/promise": "^4.13.23",
|
|
53
|
+
"@xylabs/telemetry": "^4.13.23",
|
|
54
|
+
"@xylabs/typeof": "^4.13.23",
|
|
55
|
+
"@xyo-network/archivist-lmdb": "^4.1.7",
|
|
56
|
+
"@xyo-network/archivist-memory": "^4.1.7",
|
|
57
|
+
"@xyo-network/archivist-model": "^4.1.7",
|
|
58
|
+
"@xyo-network/chain-api": "^1.7.12",
|
|
59
|
+
"@xyo-network/chain-modules": "^1.7.12",
|
|
60
|
+
"@xyo-network/chain-orchestration": "^1.7.12",
|
|
61
|
+
"@xyo-network/chain-protocol": "^1.7.12",
|
|
62
|
+
"@xyo-network/chain-services": "^1.7.12",
|
|
63
|
+
"@xyo-network/chain-telemetry": "^1.7.12",
|
|
64
|
+
"@xyo-network/chain-utils": "^1.7.12",
|
|
65
|
+
"@xyo-network/chain-validation": "^1.7.12",
|
|
66
|
+
"@xyo-network/payload-builder": "^4.1.7",
|
|
67
|
+
"@xyo-network/payload-model": "^4.1.7",
|
|
68
|
+
"@xyo-network/wallet": "^4.1.7",
|
|
69
|
+
"@xyo-network/wallet-model": "^4.1.7",
|
|
70
|
+
"@xyo-network/xl1-protocol": "^1.7.19",
|
|
71
|
+
"@xyo-network/xl1-protocol-sdk": "^1.7.12",
|
|
71
72
|
"async-mutex": "^0.5.0",
|
|
73
|
+
"cosmiconfig": "^9.0.0",
|
|
72
74
|
"dotenv": "^17.2.0",
|
|
73
75
|
"ethers": "^6.15.0",
|
|
74
76
|
"lmdb": "^3.4.1",
|
|
@@ -76,10 +78,10 @@
|
|
|
76
78
|
"zod": "^3.25.76"
|
|
77
79
|
},
|
|
78
80
|
"devDependencies": {
|
|
79
|
-
"@xylabs/ts-scripts-yarn3": "^7.0.
|
|
80
|
-
"@xylabs/tsconfig": "^7.0.
|
|
81
|
-
"@xylabs/vitest-extended": "^4.13.
|
|
82
|
-
"@xyo-network/chain-sdk": "^1.7.
|
|
81
|
+
"@xylabs/ts-scripts-yarn3": "^7.0.1",
|
|
82
|
+
"@xylabs/tsconfig": "^7.0.1",
|
|
83
|
+
"@xylabs/vitest-extended": "^4.13.23",
|
|
84
|
+
"@xyo-network/chain-sdk": "^1.7.12",
|
|
83
85
|
"nodemon": "^3.1.10",
|
|
84
86
|
"rimraf": "^6.0.1",
|
|
85
87
|
"typescript": "^5.8.3",
|
|
@@ -14,7 +14,11 @@ export const initAccount: Initializable<InitializableParams<{ config: Config }>,
|
|
|
14
14
|
if (isUndefined(walletPhrase)) {
|
|
15
15
|
logger?.warn('[Producer] No wallet mnemonic specified!')
|
|
16
16
|
const randomMnemonic = HDWallet.generateMnemonic()
|
|
17
|
-
logger?.warn(`[Producer] Using randomly generated mnemonic:
|
|
17
|
+
logger?.warn(`[Producer] Using randomly generated mnemonic:
|
|
18
|
+
|
|
19
|
+
${randomMnemonic}
|
|
20
|
+
|
|
21
|
+
`)
|
|
18
22
|
walletPhrase = randomMnemonic
|
|
19
23
|
}
|
|
20
24
|
const wallet = await generateXyoBaseWalletFromPhrase(walletPhrase)
|
package/src/runCLI.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Logger } from '@xylabs/logger'
|
|
2
|
+
import { deepMerge } from '@xylabs/object'
|
|
2
3
|
import { isDefined } from '@xylabs/typeof'
|
|
3
4
|
import { type Config, ConfigSchema } from '@xyo-network/xl1-protocol-sdk'
|
|
4
5
|
import type { Argv } from 'yargs'
|
|
@@ -11,6 +12,7 @@ import { XL1LogoColorizedAscii } from './images.ts'
|
|
|
11
12
|
import { initLogger } from './initLogger.ts'
|
|
12
13
|
import { optionsFromZodSchema } from './optionsFromZodSchema.ts'
|
|
13
14
|
import { Orchestrator } from './orchestration/index.ts'
|
|
15
|
+
import { tryParseConfig } from './tryParseConfig.ts'
|
|
14
16
|
import { waitForHostPort } from './waitForHostPort.ts'
|
|
15
17
|
|
|
16
18
|
/** Version string injected by Rollup at build time. */
|
|
@@ -62,15 +64,27 @@ Run various components of the XL1 ecosystem.
|
|
|
62
64
|
|
|
63
65
|
Usage:
|
|
64
66
|
$0 <command> [options]`)
|
|
65
|
-
.parserConfiguration({
|
|
67
|
+
.parserConfiguration({
|
|
68
|
+
'dot-notation': true, // foo.bar → { foo: { bar } }
|
|
69
|
+
'populate--': true, // Populate -- with all options so we can detected user-supplied vs defaults
|
|
70
|
+
})
|
|
66
71
|
.env('XL1')
|
|
67
72
|
.scriptName('xl1')
|
|
68
|
-
.config()
|
|
69
73
|
.version(version)
|
|
70
74
|
.middleware((argv) => {
|
|
71
75
|
try {
|
|
72
|
-
// Parse
|
|
73
|
-
|
|
76
|
+
// Parse the various config sources
|
|
77
|
+
const parsedConfigFile = tryParseConfig() // Config file
|
|
78
|
+
const parsedConfigArgs = argv // Command-line arguments & ENV VARs
|
|
79
|
+
// Deep merge with precedence
|
|
80
|
+
// TODO: Would like precedence to be defaults < file < ENV < CLI Args
|
|
81
|
+
// but there is currently no way to determine which are defaults vs
|
|
82
|
+
// user-supplied CLI Args since we set the CLI args to the defaults
|
|
83
|
+
// and receive a flattened object. We might need to manually invoke
|
|
84
|
+
// the parser without the defaults to achieve this.
|
|
85
|
+
const mergedConfig = deepMerge(parsedConfigArgs, parsedConfigFile)
|
|
86
|
+
// Validate the merged configuration
|
|
87
|
+
config = ConfigSchema.parse(mergedConfig)
|
|
74
88
|
} catch (err) {
|
|
75
89
|
if (err instanceof ZodError) {
|
|
76
90
|
for (const issue of err.errors) {
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { isDefined, isNull } from '@xylabs/typeof'
|
|
2
|
+
import { cosmiconfigSync, defaultLoaders } from 'cosmiconfig'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The name of the configuration file to search for.
|
|
6
|
+
*/
|
|
7
|
+
const configName = 'xyo'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The name of the section within the configuration file to parse.
|
|
11
|
+
*/
|
|
12
|
+
const configSection = 'xl1' // Default section in the config file
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Attempts to parse the configuration from a file using cosmiconfig.
|
|
16
|
+
* @returns The parsed configuration object if found and valid, otherwise undefined.
|
|
17
|
+
*/
|
|
18
|
+
export const tryParseConfig = (): Record<string, unknown> => {
|
|
19
|
+
const explorer = cosmiconfigSync(
|
|
20
|
+
configName,
|
|
21
|
+
/* {
|
|
22
|
+
searchPlaces: [
|
|
23
|
+
'package.json', // Looks under `xyo` key in package.json
|
|
24
|
+
'.xyorc.json', // Supports common dotfile format
|
|
25
|
+
'xyo.config.json', // Supports custom-named config file
|
|
26
|
+
],
|
|
27
|
+
loaders: {
|
|
28
|
+
'.json': defaultLoaders['.json'],
|
|
29
|
+
'noExt': defaultLoaders['.json'],
|
|
30
|
+
},
|
|
31
|
+
}, */
|
|
32
|
+
)
|
|
33
|
+
const result = explorer.search()
|
|
34
|
+
if (!isNull(result)) {
|
|
35
|
+
const section = result?.config?.[configSection]
|
|
36
|
+
if (isDefined(section) && typeof section === 'object') {
|
|
37
|
+
return section
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return {}
|
|
41
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"initConfig.d.ts","sourceRoot":"","sources":["../../src/initConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,IAAI,MAAM,EAAgB,MAAM,+BAA+B,CAAA;AAEnF,eAAO,MAAM,UAAU,QAAO,MAG7B,CAAA"}
|