@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/xl1-cli-lib",
3
- "version": "1.7.10",
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.21",
44
- "@xylabs/assert": "^4.13.21",
45
- "@xylabs/base": "^4.13.21",
46
- "@xylabs/creatable": "^4.13.21",
47
- "@xylabs/delay": "^4.13.21",
48
- "@xylabs/forget": "^4.13.21",
49
- "@xylabs/hex": "^4.13.21",
50
- "@xylabs/logger": "^4.13.21",
51
- "@xylabs/promise": "^4.13.21",
52
- "@xylabs/telemetry": "^4.13.21",
53
- "@xylabs/typeof": "^4.13.21",
54
- "@xyo-network/archivist-lmdb": "^4.1.6",
55
- "@xyo-network/archivist-memory": "^4.1.6",
56
- "@xyo-network/archivist-model": "^4.1.6",
57
- "@xyo-network/chain-api": "^1.7.10",
58
- "@xyo-network/chain-modules": "^1.7.10",
59
- "@xyo-network/chain-orchestration": "^1.7.10",
60
- "@xyo-network/chain-protocol": "^1.7.10",
61
- "@xyo-network/chain-services": "^1.7.10",
62
- "@xyo-network/chain-telemetry": "^1.7.10",
63
- "@xyo-network/chain-utils": "^1.7.10",
64
- "@xyo-network/chain-validation": "^1.7.10",
65
- "@xyo-network/payload-builder": "^4.1.6",
66
- "@xyo-network/payload-model": "^4.1.6",
67
- "@xyo-network/wallet": "^4.1.6",
68
- "@xyo-network/wallet-model": "^4.1.6",
69
- "@xyo-network/xl1-protocol": "^1.7.10",
70
- "@xyo-network/xl1-protocol-sdk": "^1.7.10",
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.0",
80
- "@xylabs/tsconfig": "^7.0.0",
81
- "@xylabs/vitest-extended": "^4.13.21",
82
- "@xyo-network/chain-sdk": "^1.7.10",
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: ${randomMnemonic}`)
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({ 'dot-notation': true }) // foo.bar → { foo: { bar } }
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 and validate the config
73
- config = ConfigSchema.parse(argv)
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,3 +0,0 @@
1
- import { type Config as Config } from '@xyo-network/xl1-protocol-sdk';
2
- export declare const initConfig: () => Config;
3
- //# sourceMappingURL=initConfig.d.ts.map
@@ -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"}
package/src/initConfig.ts DELETED
@@ -1,6 +0,0 @@
1
- import { type Config as Config, ConfigSchema } from '@xyo-network/xl1-protocol-sdk'
2
-
3
- export const initConfig = (): Config => {
4
- const config: Config = ConfigSchema.parse({})
5
- return config
6
- }