@xyo-network/xl1-cli-lib 1.15.2 → 1.15.3

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.
Files changed (82) hide show
  1. package/README.md +364 -236
  2. package/dist/node/commands/bridge/index.d.ts +2 -0
  3. package/dist/node/commands/bridge/index.d.ts.map +1 -0
  4. package/dist/node/commands/bridge/runBridge.d.ts +9 -0
  5. package/dist/node/commands/bridge/runBridge.d.ts.map +1 -0
  6. package/dist/node/commands/index.d.ts +1 -0
  7. package/dist/node/commands/index.d.ts.map +1 -1
  8. package/dist/node/index.mjs +58 -101
  9. package/dist/node/index.mjs.map +1 -1
  10. package/dist/node/orchestration/archivists/lib/localPersistentArchivist.d.ts +1 -1
  11. package/dist/node/orchestration/archivists/lib/localPersistentArchivist.d.ts.map +1 -1
  12. package/dist/node/orchestration/initServices.d.ts +1 -1
  13. package/dist/node/orchestration/initServices.d.ts.map +1 -1
  14. package/dist/node/orchestration/map/BalanceSummary/initBalanceSummaryMap.d.ts +2 -4
  15. package/dist/node/orchestration/map/BalanceSummary/initBalanceSummaryMap.d.ts.map +1 -1
  16. package/dist/node/orchestration/map/BalanceSummary/initLocalBalanceSummaryMap.d.ts +2 -4
  17. package/dist/node/orchestration/map/BalanceSummary/initLocalBalanceSummaryMap.d.ts.map +1 -1
  18. package/dist/node/orchestration/map/BalanceSummary/initLocalTransferSummaryMap.d.ts +2 -4
  19. package/dist/node/orchestration/map/BalanceSummary/initLocalTransferSummaryMap.d.ts.map +1 -1
  20. package/dist/node/orchestration/map/BalanceSummary/initTransferSummaryMap.d.ts +2 -4
  21. package/dist/node/orchestration/map/BalanceSummary/initTransferSummaryMap.d.ts.map +1 -1
  22. package/dist/node/orchestration/map/index.d.ts +0 -1
  23. package/dist/node/orchestration/map/index.d.ts.map +1 -1
  24. package/dist/node/orchestration/services/implementation/balance.d.ts.map +1 -1
  25. package/dist/node/orchestration/services/implementation/head/createForkedHead/config/getBridgeSourceDetails.d.ts +2 -2
  26. package/dist/node/orchestration/services/implementation/head/createForkedHead/config/getBridgeSourceDetails.d.ts.map +1 -1
  27. package/dist/node/orchestration/services/implementation/head/head.d.ts.map +1 -1
  28. package/dist/node/orchestration/services/implementation/index.d.ts +1 -0
  29. package/dist/node/orchestration/services/implementation/index.d.ts.map +1 -1
  30. package/dist/node/orchestration/services/implementation/iterator.d.ts.map +1 -1
  31. package/dist/node/orchestration/services/implementation/producer.d.ts.map +1 -1
  32. package/dist/node/orchestration/services/implementation/transfer.d.ts.map +1 -1
  33. package/dist/node/orchestration/services/implementation/validator.d.ts.map +1 -1
  34. package/dist/node/runCLI.d.ts.map +1 -1
  35. package/dist/node/xl1.mjs +57 -101
  36. package/dist/node/xl1.mjs.map +1 -1
  37. package/package.json +36 -32
  38. package/src/commands/bridge/index.ts +1 -0
  39. package/src/commands/bridge/runBridge.ts +12 -0
  40. package/src/commands/index.ts +1 -0
  41. package/src/orchestration/archivists/lib/localPersistentArchivist.ts +1 -3
  42. package/src/orchestration/initServices.ts +22 -7
  43. package/src/orchestration/map/BalanceSummary/initBalanceSummaryMap.ts +3 -5
  44. package/src/orchestration/map/BalanceSummary/initLocalBalanceSummaryMap.ts +5 -7
  45. package/src/orchestration/map/BalanceSummary/initLocalTransferSummaryMap.ts +5 -7
  46. package/src/orchestration/map/BalanceSummary/initTransferSummaryMap.ts +3 -5
  47. package/src/orchestration/map/index.ts +0 -1
  48. package/src/orchestration/services/implementation/balance.ts +5 -5
  49. package/src/orchestration/services/implementation/head/head.ts +28 -28
  50. package/src/orchestration/services/implementation/index.ts +1 -0
  51. package/src/orchestration/services/implementation/iterator.ts +10 -10
  52. package/src/orchestration/services/implementation/producer.ts +5 -5
  53. package/src/orchestration/services/implementation/transfer.ts +5 -5
  54. package/src/orchestration/services/implementation/validator.ts +5 -5
  55. package/src/runCLI.ts +10 -1
  56. package/dist/node/orchestration/map/driver/index.d.ts +0 -2
  57. package/dist/node/orchestration/map/driver/index.d.ts.map +0 -1
  58. package/dist/node/orchestration/map/driver/lmdb/Params.d.ts +0 -7
  59. package/dist/node/orchestration/map/driver/lmdb/Params.d.ts.map +0 -1
  60. package/dist/node/orchestration/map/driver/lmdb/SynchronousLmdbMap.d.ts +0 -32
  61. package/dist/node/orchestration/map/driver/lmdb/SynchronousLmdbMap.d.ts.map +0 -1
  62. package/dist/node/orchestration/map/driver/lmdb/index.d.ts +0 -2
  63. package/dist/node/orchestration/map/driver/lmdb/index.d.ts.map +0 -1
  64. package/dist/node/orchestration/map/driver/lmdb/spec/SynchronousLmdbMap.spec.d.ts +0 -2
  65. package/dist/node/orchestration/map/driver/lmdb/spec/SynchronousLmdbMap.spec.d.ts.map +0 -1
  66. package/dist/node/orchestration/map/localPersistentMap.d.ts +0 -13
  67. package/dist/node/orchestration/map/localPersistentMap.d.ts.map +0 -1
  68. package/dist/node/orchestration/store/StoreKind.d.ts +0 -2
  69. package/dist/node/orchestration/store/StoreKind.d.ts.map +0 -1
  70. package/dist/node/orchestration/store/getStoreDirectory.d.ts +0 -10
  71. package/dist/node/orchestration/store/getStoreDirectory.d.ts.map +0 -1
  72. package/dist/node/orchestration/store/index.d.ts +0 -3
  73. package/dist/node/orchestration/store/index.d.ts.map +0 -1
  74. package/src/orchestration/map/driver/index.ts +0 -1
  75. package/src/orchestration/map/driver/lmdb/Params.ts +0 -7
  76. package/src/orchestration/map/driver/lmdb/SynchronousLmdbMap.ts +0 -66
  77. package/src/orchestration/map/driver/lmdb/index.ts +0 -1
  78. package/src/orchestration/map/driver/lmdb/spec/SynchronousLmdbMap.spec.ts +0 -97
  79. package/src/orchestration/map/localPersistentMap.ts +0 -52
  80. package/src/orchestration/store/StoreKind.ts +0 -1
  81. package/src/orchestration/store/getStoreDirectory.ts +0 -14
  82. package/src/orchestration/store/index.ts +0 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/xl1-cli-lib",
3
- "version": "1.15.2",
3
+ "version": "1.15.3",
4
4
  "description": "XYO Layer One CLI Library",
5
5
  "homepage": "https://xylabs.com",
6
6
  "bugs": {
@@ -41,49 +41,53 @@
41
41
  },
42
42
  "dependencies": {
43
43
  "@opentelemetry/api": "~1.9.0",
44
- "@xylabs/array": "~5.0.11",
45
- "@xylabs/assert": "~5.0.11",
46
- "@xylabs/base": "~5.0.11",
47
- "@xylabs/creatable": "~5.0.11",
48
- "@xylabs/delay": "~5.0.11",
49
- "@xylabs/hex": "~5.0.11",
50
- "@xylabs/logger": "~5.0.11",
51
- "@xylabs/object": "~5.0.11",
52
- "@xylabs/promise": "~5.0.11",
53
- "@xylabs/telemetry": "~5.0.11",
54
- "@xylabs/typeof": "~5.0.11",
55
- "@xyo-network/archivist-lmdb": "~5.1.3",
56
- "@xyo-network/archivist-memory": "~5.1.3",
57
- "@xyo-network/archivist-model": "~5.1.3",
58
- "@xyo-network/chain-api": "~1.15.2",
59
- "@xyo-network/chain-sdk": "~1.15.2",
60
- "@xyo-network/payload-builder": "~5.1.3",
61
- "@xyo-network/payload-model": "~5.1.3",
62
- "@xyo-network/wallet": "~5.1.3",
63
- "@xyo-network/wallet-model": "~5.1.3",
64
- "@xyo-network/xl1-protocol": "~1.12.40",
65
- "@xyo-network/xl1-protocol-sdk": "~1.15.2",
44
+ "@xylabs/array": "~5.0.12",
45
+ "@xylabs/assert": "~5.0.12",
46
+ "@xylabs/base": "~5.0.12",
47
+ "@xylabs/creatable": "~5.0.12",
48
+ "@xylabs/delay": "~5.0.12",
49
+ "@xylabs/hex": "~5.0.12",
50
+ "@xylabs/logger": "~5.0.12",
51
+ "@xylabs/object": "~5.0.12",
52
+ "@xylabs/promise": "~5.0.12",
53
+ "@xylabs/telemetry": "~5.0.12",
54
+ "@xylabs/typeof": "~5.0.12",
55
+ "@xyo-network/archivist-lmdb": "~5.1.6",
56
+ "@xyo-network/archivist-memory": "~5.1.6",
57
+ "@xyo-network/archivist-model": "~5.1.6",
58
+ "@xyo-network/chain-api": "~1.15.3",
59
+ "@xyo-network/chain-bridge": "~1.15.3",
60
+ "@xyo-network/chain-sdk": "~1.15.3",
61
+ "@xyo-network/payload-builder": "~5.1.6",
62
+ "@xyo-network/payload-model": "~5.1.6",
63
+ "@xyo-network/wallet": "~5.1.6",
64
+ "@xyo-network/wallet-model": "~5.1.6",
65
+ "@xyo-network/xl1-protocol": "~1.12.66",
66
+ "@xyo-network/xl1-protocol-sdk": "~1.15.3",
66
67
  "async-mutex": "~0.5.0",
67
68
  "cosmiconfig": "~9.0.0",
68
- "dotenv": "~17.2.2",
69
+ "dotenv": "~17.2.3",
69
70
  "ethers": "~6.15.0",
70
- "lmdb": "~3.4.2",
71
71
  "yargs": "~18.0.0",
72
- "zod": "~4.1.11"
72
+ "zod": "~4.1.12"
73
73
  },
74
74
  "devDependencies": {
75
- "@xylabs/ts-scripts-yarn3": "~7.1.7",
76
- "@xylabs/tsconfig": "~7.1.7",
77
- "@xylabs/vitest-extended": "~5.0.11",
78
- "@xyo-network/account-model": "~5.1.3",
79
- "eslint": "^9.36.0",
75
+ "@xylabs/ts-scripts-yarn3": "~7.1.8",
76
+ "@xylabs/tsconfig": "~7.1.8",
77
+ "@xylabs/vitest-extended": "~5.0.12",
78
+ "@xyo-network/account-model": "~5.1.6",
79
+ "eslint": "^9.37.0",
80
+ "lmdb": "~3.4.3",
80
81
  "nodemon": "~3.1.10",
81
82
  "rimraf": "~6.0.1",
82
83
  "tslib": "~2.8.1",
83
- "typescript": "~5.9.2",
84
+ "typescript": "~5.9.3",
84
85
  "vitest": "~3.2.4",
85
86
  "vitest-mock-extended": "~3.1.0"
86
87
  },
88
+ "peerDependencies": {
89
+ "lmdb": "^3.4.3"
90
+ },
87
91
  "engines": {
88
92
  "node": ">=22.3 <23"
89
93
  },
@@ -0,0 +1 @@
1
+ export * from './runBridge.ts'
@@ -0,0 +1,12 @@
1
+ import type { Logger } from '@xylabs/logger'
2
+ import { getServer } from '@xyo-network/chain-bridge'
3
+ import type { Config } from '@xyo-network/xl1-protocol-sdk'
4
+
5
+ interface RunBridgeContext {
6
+ config: Config
7
+ logger?: Logger
8
+ }
9
+
10
+ export function runBridge(context: RunBridgeContext) {
11
+ void getServer(context)
12
+ }
@@ -1,3 +1,4 @@
1
1
  export * from './api/index.ts'
2
+ export * from './bridge/index.ts'
2
3
  export * from './producer/index.ts'
3
4
  export * from './validator/index.ts'
@@ -3,9 +3,7 @@ import Path from 'node:path'
3
3
 
4
4
  import { LmdbArchivist, LmdbArchivistConfigSchema } from '@xyo-network/archivist-lmdb'
5
5
  import type { ArchivistInstance } from '@xyo-network/archivist-model'
6
-
7
- import type { StoreKind } from '../../store/index.ts'
8
- import { getStoreDirectory } from '../../store/index.ts'
6
+ import { getStoreDirectory, type StoreKind } from '@xyo-network/chain-sdk'
9
7
 
10
8
  const DEFAULT_STORAGE_ROOT = Path.join(process.cwd(), '.store')
11
9
 
@@ -1,13 +1,16 @@
1
1
  import { assertEx } from '@xylabs/assert'
2
2
  import type { CreatableName } from '@xylabs/creatable'
3
- import { asAddress } from '@xylabs/hex'
3
+ import { asAddress, ZERO_HASH } from '@xylabs/hex'
4
4
  import type { Logger } from '@xylabs/logger'
5
5
  import { isDefined } from '@xylabs/typeof'
6
6
  import type { BaseBlockProducerServiceParams, XyoValidatorParams } from '@xyo-network/chain-sdk'
7
7
  import {
8
- balanceSummaryRepositoryFromMap, initTelemetry, startupSpanAsync, validateHydratedBlockState,
8
+ initTelemetry, startupSpanAsync, validateHydratedBlockState,
9
9
  } from '@xyo-network/chain-sdk'
10
- import type { ChainServiceCollectionV2, Config } from '@xyo-network/xl1-protocol-sdk'
10
+ import type { Payload, WithStorageMeta } from '@xyo-network/payload-model'
11
+ import {
12
+ type ChainServiceCollectionV2, type Config, readPayloadMapFromStore,
13
+ } from '@xyo-network/xl1-protocol-sdk'
11
14
 
12
15
  import {
13
16
  initChainFinalizedArchivist, initChainSubmissionsArchivist, initPendingBundledTransactionsArchivist, initRejectedTransactionsArchivist,
@@ -20,7 +23,7 @@ import {
20
23
  initAccount, initBalanceService, initBlockProducer,
21
24
  initBlockRewardService, initChainIterator, initChainService, initElectionService, initHead,
22
25
  initPendingTransactions, initStakeIntentService,
23
- initTimeService,
26
+ initTimeService, initTransferService,
24
27
  } from './services/index.ts'
25
28
  import { RuntimeStatusMonitor } from './status/index.ts'
26
29
 
@@ -122,6 +125,7 @@ export const initServices = async (context: InitServicesContext): Promise<ChainS
122
125
  ])
123
126
 
124
127
  const chainId = chainService.chainId
128
+ const chainMap = readPayloadMapFromStore<WithStorageMeta<Payload>>(chainArchivist)
125
129
  const chainContractViewer = chainService
126
130
  const chainStakeViewer = chainService
127
131
  const chainStaker = chainService
@@ -155,7 +159,7 @@ export const initServices = async (context: InitServicesContext): Promise<ChainS
155
159
  'ChainIterator',
156
160
  () => initChainIterator({
157
161
  name: 'ChainIterator' as CreatableName,
158
- chainArchivist,
162
+ chainMap,
159
163
  head,
160
164
  ...initParams,
161
165
  }),
@@ -164,8 +168,19 @@ export const initServices = async (context: InitServicesContext): Promise<ChainS
164
168
  'BalanceService',
165
169
  () => initBalanceService({
166
170
  name: 'BalanceService' as CreatableName,
167
- chainArchivist,
168
- summaryRepository: balanceSummaryRepositoryFromMap(balanceSummaryMap),
171
+ context: {
172
+ store: { chainMap }, head: () => ZERO_HASH, chainId, summaryMap: balanceSummaryMap,
173
+ },
174
+ ...initParams,
175
+ }),
176
+ ),
177
+ startupSpanAsync(
178
+ 'TransferService',
179
+ () => initTransferService({
180
+ name: 'TransferService' as CreatableName,
181
+ context: {
182
+ store: { chainMap }, head: () => ZERO_HASH, chainId, summaryMap: transferSummaryMap,
183
+ },
169
184
  ...initParams,
170
185
  }),
171
186
  ),
@@ -1,18 +1,16 @@
1
- import type { Hash } from '@xylabs/hex'
2
1
  import { isDefined } from '@xylabs/typeof'
3
- import type { MapType } from '@xyo-network/chain-sdk'
4
2
  import { startupSpanAsync } from '@xyo-network/chain-sdk'
5
3
  import type { WithStorageMeta } from '@xyo-network/payload-model'
6
- import type { BalancesStepSummary } from '@xyo-network/xl1-protocol-sdk'
4
+ import type { BalancesStepSummary, MapType } from '@xyo-network/xl1-protocol-sdk'
7
5
  import { Mutex } from 'async-mutex'
8
6
 
9
7
  import type { ChainInitializableParams } from '../../ChainInitializableParams.ts'
10
8
  import { initLocalBalanceSummaryMap } from './initLocalBalanceSummaryMap.ts'
11
9
 
12
10
  const mutex = new Mutex()
13
- let singleton: MapType<Hash, WithStorageMeta<BalancesStepSummary>> | undefined
11
+ let singleton: MapType<string, WithStorageMeta<BalancesStepSummary>> | undefined
14
12
 
15
- export async function initBalanceSummaryMap(params: ChainInitializableParams): Promise<MapType<Hash, WithStorageMeta<BalancesStepSummary>>> {
13
+ export async function initBalanceSummaryMap(params: ChainInitializableParams): Promise<MapType<string, WithStorageMeta<BalancesStepSummary>>> {
16
14
  return await mutex.runExclusive(async () => {
17
15
  if (isDefined(singleton)) return singleton
18
16
  const local = await startupSpanAsync('BalanceSummaryMap:initLocal', () => initLocalBalanceSummaryMap(params))
@@ -1,21 +1,19 @@
1
- import type { Hash } from '@xylabs/hex'
2
1
  import { isDefined } from '@xylabs/typeof'
3
- import type { MapType } from '@xyo-network/chain-sdk'
2
+ import { getLocalPersistentMap } from '@xyo-network/chain-sdk'
4
3
  import type { WithStorageMeta } from '@xyo-network/payload-model'
5
- import type { BalancesStepSummary } from '@xyo-network/xl1-protocol-sdk'
4
+ import type { BalancesStepSummary, MapType } from '@xyo-network/xl1-protocol-sdk'
6
5
  import { Mutex } from 'async-mutex'
7
6
 
8
7
  import type { ChainInitializableParams } from '../../ChainInitializableParams.ts'
9
- import { getLocalPersistentMap } from '../localPersistentMap.ts'
10
8
 
11
9
  const mutex = new Mutex()
12
- let singleton: MapType<Hash, WithStorageMeta<BalancesStepSummary>> | undefined
10
+ let singleton: MapType<string, WithStorageMeta<BalancesStepSummary>> | undefined
13
11
 
14
- export const initLocalBalanceSummaryMap = async (params: ChainInitializableParams): Promise<MapType<Hash, WithStorageMeta<BalancesStepSummary>>> => {
12
+ export const initLocalBalanceSummaryMap = async (params: ChainInitializableParams): Promise<MapType<string, WithStorageMeta<BalancesStepSummary>>> => {
15
13
  return await mutex.runExclusive(async () => {
16
14
  if (isDefined(singleton)) return singleton
17
15
  const { root } = params.config.storage
18
- singleton = await getLocalPersistentMap<Hash, WithStorageMeta<BalancesStepSummary>>('balance', 'summary', root)
16
+ singleton = await getLocalPersistentMap<string, WithStorageMeta<BalancesStepSummary>>('balance', 'summary', root)
19
17
  return singleton
20
18
  })
21
19
  }
@@ -1,21 +1,19 @@
1
- import type { Hash } from '@xylabs/hex'
2
1
  import { isDefined } from '@xylabs/typeof'
3
- import type { MapType } from '@xyo-network/chain-sdk'
2
+ import { getLocalPersistentMap } from '@xyo-network/chain-sdk'
4
3
  import type { WithStorageMeta } from '@xyo-network/payload-model'
5
- import type { BalancesStepSummary } from '@xyo-network/xl1-protocol-sdk'
4
+ import type { MapType, TransfersStepSummary } from '@xyo-network/xl1-protocol-sdk'
6
5
  import { Mutex } from 'async-mutex'
7
6
 
8
7
  import type { ChainInitializableParams } from '../../ChainInitializableParams.ts'
9
- import { getLocalPersistentMap } from '../localPersistentMap.ts'
10
8
 
11
9
  const mutex = new Mutex()
12
- let singleton: MapType<Hash, WithStorageMeta<BalancesStepSummary>> | undefined
10
+ let singleton: MapType<string, WithStorageMeta<TransfersStepSummary>> | undefined
13
11
 
14
- export const initLocalTransferSummaryMap = async (params: ChainInitializableParams): Promise<MapType<Hash, WithStorageMeta<BalancesStepSummary>>> => {
12
+ export const initLocalTransferSummaryMap = async (params: ChainInitializableParams): Promise<MapType<string, WithStorageMeta<TransfersStepSummary>>> => {
15
13
  return await mutex.runExclusive(async () => {
16
14
  if (isDefined(singleton)) return singleton
17
15
  const { root } = params.config.storage
18
- singleton = await getLocalPersistentMap<Hash, WithStorageMeta<BalancesStepSummary>>('transfer', 'summary', root)
16
+ singleton = await getLocalPersistentMap<string, WithStorageMeta<TransfersStepSummary>>('transfer', 'summary', root)
19
17
  return singleton
20
18
  })
21
19
  }
@@ -1,18 +1,16 @@
1
- import type { Hash } from '@xylabs/hex'
2
1
  import { isDefined } from '@xylabs/typeof'
3
- import type { MapType } from '@xyo-network/chain-sdk'
4
2
  import { startupSpanAsync } from '@xyo-network/chain-sdk'
5
3
  import type { WithStorageMeta } from '@xyo-network/payload-model'
6
- import type { BalancesStepSummary } from '@xyo-network/xl1-protocol-sdk'
4
+ import type { MapType, TransfersStepSummary } from '@xyo-network/xl1-protocol-sdk'
7
5
  import { Mutex } from 'async-mutex'
8
6
 
9
7
  import type { ChainInitializableParams } from '../../ChainInitializableParams.ts'
10
8
  import { initLocalTransferSummaryMap } from './initLocalTransferSummaryMap.ts'
11
9
 
12
10
  const mutex = new Mutex()
13
- let singleton: MapType<Hash, WithStorageMeta<BalancesStepSummary>> | undefined
11
+ let singleton: MapType<string, WithStorageMeta<TransfersStepSummary>> | undefined
14
12
 
15
- export async function initTransferSummaryMap(params: ChainInitializableParams): Promise<MapType<Hash, WithStorageMeta<BalancesStepSummary>>> {
13
+ export async function initTransferSummaryMap(params: ChainInitializableParams): Promise<MapType<string, WithStorageMeta<TransfersStepSummary>>> {
16
14
  return await mutex.runExclusive(async () => {
17
15
  if (isDefined(singleton)) return singleton
18
16
  const local = await startupSpanAsync('TransferSummaryMap:initLocal', () => initLocalTransferSummaryMap(params))
@@ -1,2 +1 @@
1
1
  export * from './BalanceSummary/index.ts'
2
- export * from './driver/index.ts'
@@ -6,8 +6,8 @@ import type { AccountBalanceServiceV2, Initializable } from '@xyo-network/xl1-pr
6
6
  let balanceServiceSingleton: Promisable<AccountBalanceServiceV2> | undefined
7
7
 
8
8
  export const initBalanceService: Initializable<BaseAccountBalanceServiceParams, AccountBalanceServiceV2>
9
- = async (params): Promise<AccountBalanceServiceV2> => {
10
- if (balanceServiceSingleton) return balanceServiceSingleton
11
- balanceServiceSingleton = await BaseAccountBalanceService.create(params)
12
- return balanceServiceSingleton
13
- }
9
+ = async (params): Promise<AccountBalanceServiceV2> => {
10
+ if (balanceServiceSingleton) return balanceServiceSingleton
11
+ balanceServiceSingleton = await BaseAccountBalanceService.create(params)
12
+ return balanceServiceSingleton
13
+ }
@@ -22,32 +22,32 @@ export const initHead: Initializable<{
22
22
  chainService: ChainService
23
23
  chainSubmissionsArchivistWrite: ArchivistInstance
24
24
  }, WithStorageMeta<BlockBoundWitness>>
25
- = async (params): Promise<WithStorageMeta<BlockBoundWitness>> => {
26
- const {
27
- account, chainArchivist, chainSubmissionsArchivistWrite, chainService,
28
- } = params
29
- if (headSingleton) return headSingleton
30
- let head = await findMostRecentBlock(chainArchivist)
25
+ = async (params): Promise<WithStorageMeta<BlockBoundWitness>> => {
26
+ const {
27
+ account, chainArchivist, chainSubmissionsArchivistWrite, chainService,
28
+ } = params
29
+ if (headSingleton) return headSingleton
30
+ let head = await findMostRecentBlock(chainArchivist)
31
31
 
32
- // If there is a head
33
- if (head) {
34
- // If there is a head but check if it matches our chainId or we should fork from it
35
- const forkFromBlock = await getForkFromBlock(head, chainService, chainArchivist)
36
- // If we should fork form a block in the current chain
37
- if (isDefined(forkFromBlock)) {
38
- // Create a new chain from the fork from block
39
- const chain = await createForkedHead(forkFromBlock, account, chainService)
40
- await submitNewChain(chain, chainArchivist, chainSubmissionsArchivistWrite)
41
- const newBlock = assertEx(chain.at(-1), () => new Error('Failed to get new head after forking'))
42
- head = newBlock[0]
43
- }
44
- } else {
45
- // If there is no head, create one
46
- const chain = await createBootstrapHead(account, chainService)
47
- await submitNewChain(chain, chainArchivist, chainSubmissionsArchivistWrite)
48
- const newBlock = assertEx(chain.at(-1), () => new Error('Failed to get new head after genesis'))
49
- head = newBlock[0]
50
- }
51
- headSingleton = head
52
- return headSingleton
53
- }
32
+ // If there is a head
33
+ if (head) {
34
+ // If there is a head but check if it matches our chainId or we should fork from it
35
+ const forkFromBlock = await getForkFromBlock(head, chainService, chainArchivist)
36
+ // If we should fork form a block in the current chain
37
+ if (isDefined(forkFromBlock)) {
38
+ // Create a new chain from the fork from block
39
+ const chain = await createForkedHead(forkFromBlock, account, chainService)
40
+ await submitNewChain(chain, chainArchivist, chainSubmissionsArchivistWrite)
41
+ const newBlock = assertEx(chain.at(-1), () => new Error('Failed to get new head after forking'))
42
+ head = newBlock[0]
43
+ }
44
+ } else {
45
+ // If there is no head, create one
46
+ const chain = await createBootstrapHead(account, chainService)
47
+ await submitNewChain(chain, chainArchivist, chainSubmissionsArchivistWrite)
48
+ const newBlock = assertEx(chain.at(-1), () => new Error('Failed to get new head after genesis'))
49
+ head = newBlock[0]
50
+ }
51
+ headSingleton = head
52
+ return headSingleton
53
+ }
@@ -8,4 +8,5 @@ export * from './pendingTransactions.ts'
8
8
  export * from './producer.ts'
9
9
  export * from './reward.ts'
10
10
  export * from './time.ts'
11
+ export * from './transfer.ts'
11
12
  export * from './validator.ts'
@@ -22,15 +22,15 @@ export const initChainIterator: Initializable<XyoChainIteratorParams, EventingCh
22
22
  }
23
23
 
24
24
  export const initStakeIntentService: Initializable<XyoStakeIntentServiceParams, StakeIntentService>
25
- = (params) => {
26
- if (stakeIntentServiceSingleton) return stakeIntentServiceSingleton
27
- stakeIntentServiceSingleton = XyoStakeIntentService.create(params)
28
- return stakeIntentServiceSingleton
29
- }
25
+ = (params) => {
26
+ if (stakeIntentServiceSingleton) return stakeIntentServiceSingleton
27
+ stakeIntentServiceSingleton = XyoStakeIntentService.create(params)
28
+ return stakeIntentServiceSingleton
29
+ }
30
30
 
31
31
  export const initElectionService: Initializable<BaseElectionServicesParams, ElectionService>
32
- = (params) => {
33
- if (electionServiceSingleton) return electionServiceSingleton
34
- electionServiceSingleton = BaseElectionService.create(params)
35
- return electionServiceSingleton
36
- }
32
+ = (params) => {
33
+ if (electionServiceSingleton) return electionServiceSingleton
34
+ electionServiceSingleton = BaseElectionService.create(params)
35
+ return electionServiceSingleton
36
+ }
@@ -6,8 +6,8 @@ import type { BlockProducerService, Initializable } from '@xyo-network/xl1-proto
6
6
  let serviceSingleton: Promisable<BlockProducerService> | undefined
7
7
 
8
8
  export const initBlockProducer: Initializable<BaseBlockProducerServiceParams, BlockProducerService>
9
- = async (params: BaseBlockProducerServiceParams): Promise<BlockProducerService> => {
10
- if (serviceSingleton) return serviceSingleton
11
- serviceSingleton = await BaseBlockProducerService.create(params)
12
- return serviceSingleton
13
- }
9
+ = async (params: BaseBlockProducerServiceParams): Promise<BlockProducerService> => {
10
+ if (serviceSingleton) return serviceSingleton
11
+ serviceSingleton = await BaseBlockProducerService.create(params)
12
+ return serviceSingleton
13
+ }
@@ -6,8 +6,8 @@ import type { AccountTransfersService, Initializable } from '@xyo-network/xl1-pr
6
6
  let transferServiceSingleton: Promisable<AccountTransfersService> | undefined
7
7
 
8
8
  export const initTransferService: Initializable<BaseAccountTransferServiceParams, AccountTransfersService>
9
- = async (params): Promise<AccountTransfersService> => {
10
- if (transferServiceSingleton) return transferServiceSingleton
11
- transferServiceSingleton = await BaseAccountTransfersService.create(params)
12
- return transferServiceSingleton
13
- }
9
+ = async (params): Promise<AccountTransfersService> => {
10
+ if (transferServiceSingleton) return transferServiceSingleton
11
+ transferServiceSingleton = await BaseAccountTransfersService.create(params)
12
+ return transferServiceSingleton
13
+ }
@@ -7,8 +7,8 @@ import { initBlockProducer } from './producer.ts'
7
7
  let serviceSingleton: Promisable<BlockProducerService> | undefined
8
8
 
9
9
  export const initValidator: Initializable<BaseBlockProducerServiceParams, BlockProducerService>
10
- = (params: BaseBlockProducerServiceParams): Promisable<BlockProducerService> => {
11
- if (serviceSingleton) return serviceSingleton
12
- serviceSingleton = initBlockProducer(params)
13
- return serviceSingleton
14
- }
10
+ = (params: BaseBlockProducerServiceParams): Promisable<BlockProducerService> => {
11
+ if (serviceSingleton) return serviceSingleton
12
+ serviceSingleton = initBlockProducer(params)
13
+ return serviceSingleton
14
+ }
package/src/runCLI.ts CHANGED
@@ -7,7 +7,9 @@ import yargs from 'yargs'
7
7
  import { hideBin } from 'yargs/helpers'
8
8
  import { ZodError } from 'zod'
9
9
 
10
- import { runApi, runProducer } from './commands/index.ts'
10
+ import {
11
+ runApi, runBridge, runProducer,
12
+ } from './commands/index.ts'
11
13
  import { XL1LogoColorizedAscii } from './images.ts'
12
14
  import { initLogger } from './initLogger.ts'
13
15
  import { optionsFromGlobalZodRegistry } from './optionsFromGlobalZodRegistry.ts'
@@ -102,6 +104,13 @@ $0 <command> [options]`)
102
104
  runApi({ ...context, config })
103
105
  })
104
106
  })
107
+ .command('bridge', 'Run a XL1 Bridge Node', (yargs) => {
108
+ return yargs
109
+ .command('$0', 'Run a XL1 Bridge Node', () => {}, () => {
110
+ const context = getContextFromConfig(config)
111
+ runBridge({ ...context, config })
112
+ })
113
+ })
105
114
  .command('producer', 'Run a XL1 Producer Node', (yargs) => {
106
115
  return yargs
107
116
  .command('$0', 'Run a XL1 Producer Node', () => {}, async () => {
@@ -1,2 +0,0 @@
1
- export * from './lmdb/index.ts';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/orchestration/map/driver/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA"}
@@ -1,7 +0,0 @@
1
- import type { CreatableParams } from '@xylabs/creatable';
2
- export interface LmdbMapParams extends CreatableParams {
3
- dbName: string;
4
- location: string;
5
- storeName: string;
6
- }
7
- //# sourceMappingURL=Params.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Params.d.ts","sourceRoot":"","sources":["../../../../../../src/orchestration/map/driver/lmdb/Params.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAExD,MAAM,WAAW,aAAc,SAAQ,eAAe;IACpD,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;CAClB"}
@@ -1,32 +0,0 @@
1
- import { AbstractCreatable } from '@xylabs/creatable';
2
- import { SynchronousMap } from '@xyo-network/chain-sdk';
3
- import { Database, Key, RootDatabase } from 'lmdb';
4
- import { LmdbMapParams } from './Params.ts';
5
- /**
6
- * A synchronous LMDB-backed Map implementation.
7
- * This class provides a synchronous interface to an LMDB database, allowing for key-value storage.
8
- * It allows for multi-tenancy within a single LMDB environment by using a root database (located
9
- * at this.folderPath) and a specific DB within the environment (specified by this.params.storeName).
10
- * @template K - The type of keys in the map.
11
- * @template V - The type of values in the map.
12
- */
13
- export declare class SynchronousLmdbMap<K extends Key, V> extends AbstractCreatable<LmdbMapParams> implements SynchronousMap<K, V> {
14
- protected db: Database<V, K>;
15
- protected rootDatabase: RootDatabase;
16
- /**
17
- * The path to the LMDB folder where the database is stored.
18
- * This is constructed from the location and dbName parameters
19
- * allowing for multiple DBs within the root (by specifying a
20
- * different storeName).
21
- * @returns The folder path for the LMDB database.
22
- */
23
- get folderPath(): string;
24
- all(): V[];
25
- clear(): void;
26
- delete(id: K): boolean;
27
- get(id: K): V | undefined;
28
- has(id: K): boolean;
29
- set(id: K, data: V): this;
30
- startHandler(): Promise<void>;
31
- }
32
- //# sourceMappingURL=SynchronousLmdbMap.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SynchronousLmdbMap.d.ts","sourceRoot":"","sources":["../../../../../../src/orchestration/map/driver/lmdb/SynchronousLmdbMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAa,MAAM,mBAAmB,CAAA;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,EACL,QAAQ,EAAE,GAAG,EAAQ,YAAY,EAClC,MAAM,MAAM,CAAA;AAEb,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAG3C;;;;;;;GAOG;AACH,qBACa,kBAAkB,CAAC,CAAC,SAAS,GAAG,EAAE,CAAC,CAAE,SAAQ,iBAAiB,CAAC,aAAa,CAAE,YAAW,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC;IACxH,SAAS,CAAC,EAAE,EAAG,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IAC7B,SAAS,CAAC,YAAY,EAAG,YAAY,CAAA;IAErC;;;;;;OAMG;IACH,IAAI,UAAU,WAEb;IAED,GAAG,IAAI,CAAC,EAAE;IAIV,KAAK,IAAI,IAAI;IAIb,MAAM,CAAC,EAAE,EAAE,CAAC,GAAG,OAAO;IAItB,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS;IAIzB,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,OAAO;IAInB,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,IAAI;IAKV,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;CAO7C"}
@@ -1,2 +0,0 @@
1
- export * from './SynchronousLmdbMap.ts';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/orchestration/map/driver/lmdb/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=SynchronousLmdbMap.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SynchronousLmdbMap.spec.d.ts","sourceRoot":"","sources":["../../../../../../../src/orchestration/map/driver/lmdb/spec/SynchronousLmdbMap.spec.ts"],"names":[],"mappings":""}
@@ -1,13 +0,0 @@
1
- import type { MapType } from '@xyo-network/chain-sdk';
2
- import type { StoreKind } from '../store/index.ts';
3
- /**
4
- * Returns a local persistent map
5
- * @param dbName The name of the database
6
- * @param storeName The name of the store
7
- * @param storageRoot The root directory for storage (default is '.store' in the current working directory)
8
- * @param kind The kind of the map
9
- * @returns a map
10
- */
11
- export declare const getLocalPersistentMap: <TId, TData>(dbName: string, storeName: string, storageRoot?: string, kind?: StoreKind) => Promise<MapType<TId, TData>>;
12
- export declare const deleteLocalPersistentMap: (dbName: string, storageRoot?: string, kind?: StoreKind) => Promise<void>;
13
- //# sourceMappingURL=localPersistentMap.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"localPersistentMap.d.ts","sourceRoot":"","sources":["../../../../src/orchestration/map/localPersistentMap.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAErD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAMlD;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,GAAU,GAAG,EAAE,KAAK,EACpD,QAAQ,MAAM,EACd,WAAW,MAAM,EACjB,cAAc,MAAM,EACpB,OAAM,SAAkB,KAAG,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAWvD,CAAA;AAED,eAAO,MAAM,wBAAwB,GACnC,QAAQ,MAAM,EACd,cAAc,MAAM,EACpB,OAAM,SAAkB,KACvB,OAAO,CAAC,IAAI,CAWd,CAAA"}
@@ -1,2 +0,0 @@
1
- export type StoreKind = 'lmdb';
2
- //# sourceMappingURL=StoreKind.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"StoreKind.d.ts","sourceRoot":"","sources":["../../../../src/orchestration/store/StoreKind.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,MAAM,CAAA"}
@@ -1,10 +0,0 @@
1
- import type { StoreKind } from './StoreKind.ts';
2
- /**
3
- * Creates a convention-based directory path for an archivist store
4
- * @param name The name of the archivist
5
- * @param storageRoot The root directory for storage
6
- * @param kind The kind of the archivist (optional)
7
- * @returns The directory path for the archivist store
8
- */
9
- export declare const getStoreDirectory: (name: string, storageRoot: string, kind?: StoreKind) => string;
10
- //# sourceMappingURL=getStoreDirectory.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getStoreDirectory.d.ts","sourceRoot":"","sources":["../../../../src/orchestration/store/getStoreDirectory.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE/C;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAAI,MAAM,MAAM,EAAE,aAAa,MAAM,EAAE,OAAO,SAAS,KAAG,MAEvF,CAAA"}
@@ -1,3 +0,0 @@
1
- export * from './getStoreDirectory.ts';
2
- export * from './StoreKind.ts';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/orchestration/store/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAA;AACtC,cAAc,gBAAgB,CAAA"}
@@ -1 +0,0 @@
1
- export * from './lmdb/index.ts'
@@ -1,7 +0,0 @@
1
- import type { CreatableParams } from '@xylabs/creatable'
2
-
3
- export interface LmdbMapParams extends CreatableParams {
4
- dbName: string
5
- location: string
6
- storeName: string
7
- }