UNPKG

@hashgraph/solo

Version:

An opinionated CLI tool to deploy and manage private Hedera Networks.

41 lines (31 loc) 1.66 kB
// SPDX-License-Identifier: Apache-2.0 import {type SchemaMigration} from '../../api/schema-migration.js'; import {VersionRange} from '../../../../../business/utils/version-range.js'; import {SemanticVersion} from '../../../../../business/utils/semantic-version.js'; import {IllegalArgumentError} from '../../../../../business/errors/illegal-argument-error.js'; import {type RemoteConfigStructure} from '../../../model/remote/interfaces/remote-config-structure.js'; import {type DeploymentStateStructure} from '../../../model/remote/interfaces/deployment-state-structure.js'; import {type PriorityMapping} from '../../../../../types/index.js'; export class RemoteConfigV4Migration implements SchemaMigration { public get range(): VersionRange<number> { return VersionRange.fromIntegerVersion(3); } public get version(): SemanticVersion<number> { return new SemanticVersion(4); } public async migrate(source: object): Promise<object> { if (!source) { // We should never pass null or undefined to this method, if this happens we should throw an error throw new IllegalArgumentError('source must not be null or undefined'); } // eslint-disable-next-line @typescript-eslint/no-explicit-any const clone: RemoteConfigStructure = structuredClone(source) as any as RemoteConfigStructure; const state: DeploymentStateStructure = clone.state; for (const node of state.consensusNodes) { node.blockNodeMap = state.blockNodes.map((node): PriorityMapping => [node.metadata.id, 1]); } // Set the schema version to the new version clone.schemaVersion = this.version.major; return clone; } }