@xyo-network/chain-orchestration 1.20.14 → 1.20.16

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 (146) hide show
  1. package/README.md +9 -177
  2. package/dist/browser/index.mjs.map +1 -1
  3. package/dist/browser/shared/config/actors/Api.d.ts +9 -539
  4. package/dist/browser/shared/config/actors/Api.d.ts.map +1 -1
  5. package/dist/browser/shared/config/actors/Bridge.d.ts +9 -689
  6. package/dist/browser/shared/config/actors/Bridge.d.ts.map +1 -1
  7. package/dist/browser/shared/config/actors/Mempool.d.ts +9 -539
  8. package/dist/browser/shared/config/actors/Mempool.d.ts.map +1 -1
  9. package/dist/browser/shared/config/actors/Producer.d.ts +9 -575
  10. package/dist/browser/shared/config/actors/Producer.d.ts.map +1 -1
  11. package/dist/browser/shared/config/actors/RewardRedemption.d.ts +9 -533
  12. package/dist/browser/shared/config/actors/RewardRedemption.d.ts.map +1 -1
  13. package/dist/browser/shared/config/actors/Validator.d.ts +9 -563
  14. package/dist/browser/shared/config/actors/Validator.d.ts.map +1 -1
  15. package/dist/browser/shared/createDeclarationIntentBlock.d.ts +11 -11
  16. package/dist/neutral/index.mjs.map +1 -1
  17. package/dist/neutral/shared/config/actors/Api.d.ts +9 -539
  18. package/dist/neutral/shared/config/actors/Api.d.ts.map +1 -1
  19. package/dist/neutral/shared/config/actors/Bridge.d.ts +9 -689
  20. package/dist/neutral/shared/config/actors/Bridge.d.ts.map +1 -1
  21. package/dist/neutral/shared/config/actors/Mempool.d.ts +9 -539
  22. package/dist/neutral/shared/config/actors/Mempool.d.ts.map +1 -1
  23. package/dist/neutral/shared/config/actors/Producer.d.ts +9 -575
  24. package/dist/neutral/shared/config/actors/Producer.d.ts.map +1 -1
  25. package/dist/neutral/shared/config/actors/RewardRedemption.d.ts +9 -533
  26. package/dist/neutral/shared/config/actors/RewardRedemption.d.ts.map +1 -1
  27. package/dist/neutral/shared/config/actors/Validator.d.ts +9 -563
  28. package/dist/neutral/shared/config/actors/Validator.d.ts.map +1 -1
  29. package/dist/neutral/shared/createDeclarationIntentBlock.d.ts +11 -11
  30. package/dist/node/index.mjs.map +1 -1
  31. package/dist/node/shared/config/actors/Api.d.ts +9 -539
  32. package/dist/node/shared/config/actors/Api.d.ts.map +1 -1
  33. package/dist/node/shared/config/actors/Bridge.d.ts +9 -689
  34. package/dist/node/shared/config/actors/Bridge.d.ts.map +1 -1
  35. package/dist/node/shared/config/actors/Mempool.d.ts +9 -539
  36. package/dist/node/shared/config/actors/Mempool.d.ts.map +1 -1
  37. package/dist/node/shared/config/actors/Producer.d.ts +9 -575
  38. package/dist/node/shared/config/actors/Producer.d.ts.map +1 -1
  39. package/dist/node/shared/config/actors/RewardRedemption.d.ts +9 -533
  40. package/dist/node/shared/config/actors/RewardRedemption.d.ts.map +1 -1
  41. package/dist/node/shared/config/actors/Validator.d.ts +9 -563
  42. package/dist/node/shared/config/actors/Validator.d.ts.map +1 -1
  43. package/dist/node/shared/createDeclarationIntentBlock.d.ts +11 -11
  44. package/package.json +136 -52
  45. package/src/neutral/config/index.ts +0 -1
  46. package/src/neutral/config/locators/basicRemoteRunnerLocator.ts +0 -14
  47. package/src/neutral/config/locators/basicRemoteViewerLocator.ts +0 -11
  48. package/src/neutral/config/locators/index.ts +0 -3
  49. package/src/neutral/config/locators/rootLocatorFromConfig.ts +0 -19
  50. package/src/neutral/index.ts +0 -2
  51. package/src/node/archivists/ChainFinalized/archivist.ts +0 -21
  52. package/src/node/archivists/ChainFinalized/index.ts +0 -1
  53. package/src/node/archivists/ChainFinalized/local.ts +0 -17
  54. package/src/node/archivists/PendingBlocks/archivist.ts +0 -21
  55. package/src/node/archivists/PendingBlocks/index.ts +0 -1
  56. package/src/node/archivists/PendingBlocks/local.ts +0 -17
  57. package/src/node/archivists/RejectedTransactions/archivist.ts +0 -21
  58. package/src/node/archivists/RejectedTransactions/index.ts +0 -1
  59. package/src/node/archivists/RejectedTransactions/local.ts +0 -19
  60. package/src/node/archivists/StakeIntentState/archivist.ts +0 -21
  61. package/src/node/archivists/StakeIntentState/index.ts +0 -1
  62. package/src/node/archivists/StakeIntentState/local.ts +0 -18
  63. package/src/node/archivists/index.ts +0 -4
  64. package/src/node/archivists/lib/index.ts +0 -1
  65. package/src/node/archivists/lib/localPersistentArchivist.ts +0 -63
  66. package/src/node/config/index.ts +0 -2
  67. package/src/node/config/locators/actors/apiLocatorFromConfig.ts +0 -25
  68. package/src/node/config/locators/actors/bridgeLocatorFromConfig.ts +0 -83
  69. package/src/node/config/locators/actors/index.ts +0 -6
  70. package/src/node/config/locators/actors/mempoolLocatorFromConfig.ts +0 -17
  71. package/src/node/config/locators/actors/producerLocatorFromConfig.ts +0 -29
  72. package/src/node/config/locators/actors/rewardRedemptionLocatorFromConfig.ts +0 -56
  73. package/src/node/config/locators/actors/validatorLocatorFromConfig.ts +0 -15
  74. package/src/node/config/locators/basicRemoteRunnerLocator.ts +0 -38
  75. package/src/node/config/locators/basicRemoteViewerLocator.ts +0 -19
  76. package/src/node/config/locators/contextFromConfigWithoutLocator.ts +0 -25
  77. package/src/node/config/locators/index.ts +0 -7
  78. package/src/node/config/locators/localLocatorFromConfig.ts +0 -75
  79. package/src/node/config/locators/localViewerFromConfig.ts +0 -14
  80. package/src/node/config/locators/locatorsFromConfig.ts +0 -75
  81. package/src/node/config/locators/remoteViewerFromConfig.ts +0 -13
  82. package/src/node/config/locators/rootLocatorFromConfig.ts +0 -22
  83. package/src/node/config/locators/telemetryContextFromConfig.ts +0 -15
  84. package/src/node/config/tryParseConfig.ts +0 -42
  85. package/src/node/evm/index.ts +0 -4
  86. package/src/node/evm/initChainId.ts +0 -20
  87. package/src/node/evm/initEvmProvider.ts +0 -22
  88. package/src/node/evm/initInfuraProvider.ts +0 -29
  89. package/src/node/evm/initJsonRpcProvider.ts +0 -22
  90. package/src/node/health/index.ts +0 -1
  91. package/src/node/health/initHealthEndpoints.ts +0 -67
  92. package/src/node/index.ts +0 -8
  93. package/src/node/init/index.ts +0 -6
  94. package/src/node/init/initBalanceSummaryMap.ts +0 -33
  95. package/src/node/init/initEvmProvidersIfAvailable.ts +0 -93
  96. package/src/node/init/initFinalizationArchivistIfNeeded.ts +0 -44
  97. package/src/node/init/initFinalizedArchivist.ts +0 -16
  98. package/src/node/init/initServerNode.ts +0 -51
  99. package/src/node/init/initTransferSummaryMap.ts +0 -33
  100. package/src/node/manifest/getLocator.ts +0 -65
  101. package/src/node/manifest/index.ts +0 -5
  102. package/src/node/manifest/loadNode.ts +0 -26
  103. package/src/node/manifest/node.json +0 -17
  104. package/src/node/manifest/nodeManifest.ts +0 -8
  105. package/src/node/manifest/private/index.ts +0 -4
  106. package/src/node/manifest/public/Chain.json +0 -49
  107. package/src/node/manifest/public/Pending.json +0 -54
  108. package/src/node/manifest/public/index.ts +0 -20
  109. package/src/node/sharedMiddleware.ts +0 -24
  110. package/src/shared/ChainInitializableParams.ts +0 -4
  111. package/src/shared/actor/ValidatorActor.ts +0 -75
  112. package/src/shared/actor/index.ts +0 -1
  113. package/src/shared/buildTelemetryConfig.ts +0 -10
  114. package/src/shared/config/actors/Api.ts +0 -29
  115. package/src/shared/config/actors/Bridge.ts +0 -131
  116. package/src/shared/config/actors/Mempool.ts +0 -39
  117. package/src/shared/config/actors/Producer.ts +0 -56
  118. package/src/shared/config/actors/RewardRedemption.ts +0 -21
  119. package/src/shared/config/actors/Validator.ts +0 -22
  120. package/src/shared/config/actors/index.ts +0 -7
  121. package/src/shared/config/index.ts +0 -3
  122. package/src/shared/config/locators/basicRemoteRunnerLocator.ts +0 -63
  123. package/src/shared/config/locators/basicRemoteViewerLocator.ts +0 -44
  124. package/src/shared/config/locators/commonLocatorFromConfig.ts +0 -40
  125. package/src/shared/config/locators/index.ts +0 -4
  126. package/src/shared/config/locators/remoteLocatorFromConfig.ts +0 -56
  127. package/src/shared/config/mergeConfig.ts +0 -11
  128. package/src/shared/createDeclarationIntentBlock.ts +0 -19
  129. package/src/shared/host/implementation/DefaultHost.ts +0 -25
  130. package/src/shared/host/implementation/DefaultServiceCollection.ts +0 -60
  131. package/src/shared/host/implementation/DefaultServiceProvider.ts +0 -12
  132. package/src/shared/host/implementation/index.ts +0 -2
  133. package/src/shared/host/index.ts +0 -2
  134. package/src/shared/host/model/Host.ts +0 -21
  135. package/src/shared/host/model/ServiceCollection.ts +0 -22
  136. package/src/shared/host/model/ServiceProvider.ts +0 -3
  137. package/src/shared/host/model/index.ts +0 -3
  138. package/src/shared/index.ts +0 -8
  139. package/src/shared/init/index.ts +0 -5
  140. package/src/shared/init/initActorAccount.ts +0 -28
  141. package/src/shared/init/initActorSeedPhrase.ts +0 -29
  142. package/src/shared/init/initBridgedModule.ts +0 -40
  143. package/src/shared/init/initStatusReporter.ts +0 -15
  144. package/src/shared/init/initWallet.ts +0 -44
  145. package/src/shared/orchestrator/Orchestrator.ts +0 -66
  146. package/src/shared/orchestrator/index.ts +0 -1
@@ -1,25 +0,0 @@
1
- import type { Host, ServiceProvider } from '../model/index.ts'
2
-
3
- /**
4
- * A generic host implementation that can be used as a starting point for
5
- * more complex host implementations.
6
- */
7
- export class GenericHost implements Host {
8
- services: ServiceProvider
9
-
10
- constructor(services: ServiceProvider) {
11
- this.services = services
12
- }
13
-
14
- async start(): Promise<void> {
15
- await Promise.resolve()
16
- // Initialize or start your services here
17
- console.log('Host is starting...')
18
- }
19
-
20
- async stop(): Promise<void> {
21
- await Promise.resolve()
22
- // Stop or clean up services here
23
- console.log('Host is stopping...')
24
- }
25
- }
@@ -1,60 +0,0 @@
1
- import type {
2
- ServiceCollection, ServiceDescriptor, ServiceProvider,
3
- } from '../model/index.ts'
4
- import { ServiceLifetime } from '../model/index.ts'
5
- import { DefaultServiceProvider } from './DefaultServiceProvider.ts'
6
-
7
- /**
8
- * A collection of service descriptors, allowing adding/removing services before building.
9
- */
10
- export class DefaultServiceCollection implements ServiceCollection {
11
- private readonly descriptors: ServiceDescriptor[] = []
12
-
13
- /**
14
- * Register a service as Singleton: a single instance is created and shared.
15
- */
16
- addSingleton<T>(
17
- identifier: string | symbol,
18
- implementationFactory: () => T,
19
- ): void {
20
- this.descriptors.push({
21
- identifier,
22
- lifetime: ServiceLifetime.Singleton,
23
- implementationFactory,
24
- })
25
- }
26
-
27
- /**
28
- * Register a service as Transient: a new instance is created on each request.
29
- */
30
- addTransient<T>(
31
- _identifier: string | symbol,
32
- _implementationFactory: () => T,
33
- ): void {
34
- throw new Error('Not implemented')
35
- }
36
-
37
- /**
38
- * Build a concrete, immutable service provider from the current descriptors.
39
- */
40
- build(): ServiceProvider {
41
- const services: Record<string, unknown> = {}
42
- for (const descriptor of this.descriptors) {
43
- if (descriptor.lifetime === ServiceLifetime.Singleton) {
44
- services[descriptor.identifier.toString()] = descriptor.implementationFactory()
45
- }
46
- }
47
- return new DefaultServiceProvider(services)
48
- }
49
-
50
- /**
51
- * Removes all registrations matching the given identifier.
52
- */
53
- remove(identifier: string | symbol): void {
54
- for (let i = this.descriptors.length - 1; i >= 0; i--) {
55
- if (this.descriptors[i].identifier === identifier) {
56
- this.descriptors.splice(i, 1)
57
- }
58
- }
59
- }
60
- }
@@ -1,12 +0,0 @@
1
- import type { ServiceProvider } from '../model/index.ts'
2
-
3
- export class DefaultServiceProvider implements ServiceProvider {
4
- protected _services: Record<string, unknown>
5
- constructor(services: Record<string, unknown>) {
6
- this._services = services
7
- }
8
-
9
- getService<T>(serviceIdentifier: string): T | undefined {
10
- return this._services[serviceIdentifier] as T
11
- }
12
- }
@@ -1,2 +0,0 @@
1
- export * from './DefaultHost.ts'
2
- export * from './DefaultServiceProvider.ts'
@@ -1,2 +0,0 @@
1
- export * from './implementation/index.ts'
2
- export * from './model/index.ts'
@@ -1,21 +0,0 @@
1
- import type { ServiceProvider } from './ServiceProvider.ts'
2
-
3
- /**
4
- * Represents the host for an application.
5
- */
6
- export interface Host {
7
- /**
8
- * Provides access to the application's services (for dependency injection).
9
- */
10
- services: ServiceProvider
11
-
12
- /**
13
- * Starts the host and any underlying services (e.g., background tasks).
14
- */
15
- start(): Promise<void>
16
-
17
- /**
18
- * Stops the host and attempts to gracefully shut down services.
19
- */
20
- stop(): Promise<void>
21
- }
@@ -1,22 +0,0 @@
1
- import type { ServiceProvider } from './ServiceProvider.ts'
2
-
3
- export interface ServiceCollection {
4
- build(): ServiceProvider
5
- }
6
-
7
- /**
8
- * Represents the lifetime of a service
9
- */
10
- export const ServiceLifetime = {
11
- Singleton: 'Singleton',
12
- Transient: 'Transient',
13
- } as const
14
-
15
- /**
16
- * Describes a single service registration
17
- */
18
- export interface ServiceDescriptor<T = unknown> {
19
- identifier: string | symbol
20
- implementationFactory: () => T
21
- lifetime: keyof typeof ServiceLifetime
22
- }
@@ -1,3 +0,0 @@
1
- export interface ServiceProvider {
2
- getService<T = unknown>(serviceIdentifier: string): T | undefined
3
- }
@@ -1,3 +0,0 @@
1
- export * from './Host.ts'
2
- export * from './ServiceCollection.ts'
3
- export * from './ServiceProvider.ts'
@@ -1,8 +0,0 @@
1
- export * from './actor/index.ts'
2
- export * from './buildTelemetryConfig.ts'
3
- export * from './ChainInitializableParams.ts'
4
- export * from './config/index.ts'
5
- export * from './createDeclarationIntentBlock.ts'
6
- export * from './host/index.ts'
7
- export * from './init/index.ts'
8
- export * from './orchestrator/index.ts'
@@ -1,5 +0,0 @@
1
- export * from './initActorAccount.ts'
2
- export * from './initActorSeedPhrase.ts'
3
- export * from './initBridgedModule.ts'
4
- export * from './initStatusReporter.ts'
5
- export * from './initWallet.ts'
@@ -1,28 +0,0 @@
1
- import type { Promisable } from '@xylabs/sdk-js'
2
- import { isDefined, isUndefined } from '@xylabs/sdk-js'
3
- import { HDWallet } from '@xyo-network/sdk-js'
4
- import type { WalletInstance } from '@xyo-network/wallet-model'
5
- import type { ActorConfigContext } from '@xyo-network/xl1-sdk'
6
- import { ADDRESS_INDEX, generateXyoBaseWalletFromPhrase } from '@xyo-network/xl1-sdk'
7
-
8
- const actorAccountSingletons: Record<string, Promisable<WalletInstance>> = {}
9
-
10
- export async function initActorAccount({ config, logger }: Pick<ActorConfigContext, 'config' | 'logger'>): Promise<WalletInstance> {
11
- const actorName = config.name
12
- if (isDefined(actorAccountSingletons[actorName])) return actorAccountSingletons[actorName]
13
- let walletPhrase = config.mnemonic
14
- if (isUndefined(walletPhrase)) {
15
- logger?.warn(`[${actorName}}] No wallet mnemonic specified!`)
16
- const randomMnemonic = HDWallet.generateMnemonic()
17
- logger?.warn(`[${actorName}}] Using randomly generated mnemonic:
18
-
19
- ${randomMnemonic}
20
-
21
- `)
22
- walletPhrase = randomMnemonic
23
- }
24
- const wallet = await generateXyoBaseWalletFromPhrase(walletPhrase)
25
- const account = await wallet.derivePath(ADDRESS_INDEX.XYO)
26
- actorAccountSingletons[actorName] = account
27
- return actorAccountSingletons[actorName]
28
- }
@@ -1,29 +0,0 @@
1
- import { assertEx, isString } from '@xylabs/sdk-js'
2
- import type { BiosExternalInterface } from '@xyo-network/bios-model'
3
- import { HDWallet } from '@xyo-network/sdk-js'
4
- import type { WalletKind } from '@xyo-network/storage-model'
5
- import type { ActorConfigContext } from '@xyo-network/xl1-sdk'
6
-
7
- // TODO: Make nodejs version of bios support round tripping mnemonic between boots
8
- export async function initActorSeedPhrase(context: ActorConfigContext, bios: BiosExternalInterface): Promise<string> {
9
- const { logger, config } = context
10
- const walletKind = config.name as WalletKind
11
- const storedSeedPhrase = await bios.seedPhraseStore.get(walletKind)
12
- logger?.debug(`[API] Stored mnemonic: ${storedSeedPhrase}`)
13
- const { mnemonic } = config
14
- if (isString(storedSeedPhrase) && isString(mnemonic)) {
15
- logger?.warn('[API] Stored mnemonic does not match supplied. Updating stored mnemonic to supplied.')
16
- await bios.seedPhraseStore.set(walletKind, mnemonic)
17
- } else {
18
- let seedPhrase: string
19
- if (isString(mnemonic)) {
20
- seedPhrase = mnemonic
21
- } else {
22
- seedPhrase = HDWallet.generateMnemonic()
23
- logger?.log('[API] No mnemonic provided, using random mnemonic. This is not recommended for production use.')
24
- logger?.log(`[API] Mnemonic: ${seedPhrase}`)
25
- }
26
- await bios.seedPhraseStore.set(walletKind, seedPhrase)
27
- }
28
- return assertEx(await bios.seedPhraseStore.get(walletKind), () => 'Unable to acquire mnemonic from bios')
29
- }
@@ -1,40 +0,0 @@
1
- import type { Address } from '@xylabs/sdk-js'
2
- import { assertEx } from '@xylabs/sdk-js'
3
- import type {
4
- AttachableArchivistInstance, AttachableModuleInstance, BridgeInstance, ModuleIdentifier,
5
- } from '@xyo-network/sdk-js'
6
- import { asAttachableArchivistInstance, asAttachableModuleInstance } from '@xyo-network/sdk-js'
7
- import { Mutex } from 'async-mutex'
8
-
9
- const initMutex = new Mutex()
10
- type ModuleDictionary = Record<ModuleIdentifier, AttachableModuleInstance | undefined>
11
- type BridgedModuleDictionary = Record<Address, ModuleDictionary | undefined>
12
- const bridgedModuleDictionary: BridgedModuleDictionary = {}
13
-
14
- export async function initBridgedModule({ bridge, moduleName }: { bridge: BridgeInstance; moduleName: ModuleIdentifier }): Promise<AttachableModuleInstance> {
15
- return await initMutex.runExclusive(async () => {
16
- const existing = bridgedModuleDictionary?.[bridge.address]?.[moduleName]
17
- if (existing) return existing
18
- const mod = assertEx(await bridge.resolve(moduleName), () => `Could not resolve ${moduleName}`)
19
- const moduleInstance = assertEx(asAttachableModuleInstance(mod), () => `Could not convert ${moduleName} to attachable module instance`)
20
- // Initialize the nested dictionary if needed
21
- let moduleMap = bridgedModuleDictionary[bridge.address]
22
- if (moduleMap === undefined) {
23
- moduleMap = {}
24
- bridgedModuleDictionary[bridge.address] = moduleMap
25
- }
26
- // Store and return the module instance
27
- moduleMap[moduleName] = moduleInstance
28
- return moduleInstance
29
- })
30
- }
31
-
32
- export async function initBridgedArchivistModule({ bridge, moduleName }: {
33
- bridge: BridgeInstance
34
- moduleName: ModuleIdentifier
35
- }): Promise<AttachableArchivistInstance> {
36
- return assertEx(
37
- asAttachableArchivistInstance(await initBridgedModule({ bridge, moduleName })),
38
- () => `Could not convert ${moduleName} to attachable archivist instance`,
39
- )
40
- }
@@ -1,15 +0,0 @@
1
- import type { Logger } from '@xylabs/sdk-js'
2
- import { RuntimeStatusMonitor } from '@xyo-network/xl1-sdk'
3
-
4
- export function initStatusReporter({ logger }: { logger: Logger }) {
5
- const statusReporter = new RuntimeStatusMonitor(logger)
6
- statusReporter.onGlobalTransition({ to: 'started' }, () => {
7
- logger.log('All services started.')
8
- })
9
- statusReporter.onGlobalTransition({ to: 'error' }, () => {
10
- logger.error('Producer encountered an unhandled error!')
11
- // eslint-disable-next-line unicorn/no-process-exit
12
- process.exit(1)
13
- })
14
- return statusReporter
15
- }
@@ -1,44 +0,0 @@
1
- import { isDefined } from '@xylabs/sdk-js'
2
- import { boot } from '@xyo-network/bios'
3
- import { HDWallet } from '@xyo-network/sdk-js'
4
- import type { ActorConfigContext } from '@xyo-network/xl1-sdk'
5
-
6
- import { initActorSeedPhrase } from './initActorSeedPhrase.ts'
7
-
8
- export async function initActorWallet(context: ActorConfigContext, mnemonic?: string) {
9
- const bios = await boot()
10
- const seedPhrase = isDefined(mnemonic)
11
- ? mnemonic
12
- : await initActorSeedPhrase(context, bios)
13
- return await HDWallet.fromPhrase(seedPhrase)
14
- }
15
-
16
- // export async function initApiWallet({ config, logger }: ConfigContext) {
17
- // const { mnemonic } = config.actors.api
18
- // return await initWallet({ config, logger }, mnemonic)
19
- // }
20
-
21
- // export async function initBridgeWallet({ config, logger }: ConfigContext) {
22
- // const { mnemonic } = config.actors.bridge
23
- // return await initWallet({ config, logger }, mnemonic)
24
- // }
25
-
26
- // export async function initMempoolWallet({ config, logger }: ConfigContext) {
27
- // const { mnemonic } = config.actors.mempool
28
- // return await initWallet({ config, logger }, mnemonic)
29
- // }
30
-
31
- // export async function initProducerWallet({ config, logger }: ConfigContext) {
32
- // const { mnemonic } = config.actors.producer
33
- // return await initWallet({ config, logger }, mnemonic)
34
- // }
35
-
36
- // export async function initRewardsRedemptionApiWallet({ config, logger }: ConfigContext) {
37
- // const { mnemonic } = config.actors.rewardRedemption
38
- // return await initWallet({ config, logger }, mnemonic)
39
- // }
40
-
41
- // export async function initValidatorWallet({ config, logger }: ConfigContext) {
42
- // const { mnemonic } = config.actors.mempool
43
- // return await initWallet({ config, logger }, mnemonic)
44
- // }
@@ -1,66 +0,0 @@
1
- import type { CreatableInstance } from '@xylabs/sdk-js'
2
- import { AbstractCreatable, creatable } from '@xylabs/sdk-js'
3
- import { ActorInstanceV3 } from '@xyo-network/xl1-sdk'
4
-
5
- export interface OrchestratorInstance extends CreatableInstance {
6
- registerActor(actor: ActorInstanceV3): Promise<void>
7
- }
8
-
9
- @creatable()
10
- export class Orchestrator extends AbstractCreatable implements OrchestratorInstance {
11
- protected actors: (ActorInstanceV3)[] = []
12
- protected keepAliveHandle: NodeJS.Timeout | null = null
13
- protected running = false
14
-
15
- /**
16
- * Registers an actor.
17
- * (We won't activate the actor until `start()` is called.)
18
- */
19
- async registerActor(actor: ActorInstanceV3) {
20
- if (this.running) {
21
- // If the orchestrator is already running, activate the actor immediately
22
- await actor.start()
23
- }
24
- this.actors.push(actor)
25
- }
26
-
27
- /**
28
- * Starts the orchestrator: activates all actors.
29
- */
30
- override async startHandler() {
31
- await super.startHandler()
32
- if (this.running) {
33
- this.logger?.warn('[Orchestrator] Already started.')
34
- return
35
- }
36
-
37
- this.logger?.log('[Orchestrator] Starting...')
38
- this.running = true
39
- for (const actor of this.actors) {
40
- await actor.start()
41
- }
42
- // This interval will fire every 24.8 days (2^31 - 1 ms), effectively never finishing
43
- this.keepAliveHandle = setInterval(() => {
44
- // No-op
45
- }, 2_147_483_647)
46
- }
47
-
48
- /**
49
- * Stops the orchestrator: deactivates all actors.
50
- */
51
- override async stopHandler() {
52
- await super.stopHandler()
53
- if (!this.running) {
54
- this.logger?.log('[Orchestrator] Already stopped.')
55
- return
56
- }
57
-
58
- this.logger?.log('[Orchestrator] Stopping...')
59
- for (const actor of this.actors) {
60
- await actor.stop()
61
- }
62
- this.running = false
63
- if (this.keepAliveHandle) clearInterval(this.keepAliveHandle)
64
- this.logger?.log('[Orchestrator] Stopped...')
65
- }
66
- }
@@ -1 +0,0 @@
1
- export * from './Orchestrator.ts'