From 6e472b5e460b8b412f927fc0cf147e9d1b46cc75 Mon Sep 17 00:00:00 2001 From: Ivo Yankov Date: Wed, 20 Nov 2024 23:38:49 +0200 Subject: [PATCH] fix: Error in `node update` separate commands when new admin key is not supplied (#854) Signed-off-by: Ivo Yankov --- src/commands/node/handlers.ts | 3 +-- src/core/helpers.ts | 8 +++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/commands/node/handlers.ts b/src/commands/node/handlers.ts index 0debe3553..610b0ab53 100644 --- a/src/commands/node/handlers.ts +++ b/src/commands/node/handlers.ts @@ -196,13 +196,13 @@ export class NodeCommandHandlers { return [ this.tasks.sendNodeUpdateTransaction(), this.tasks.sendPrepareUpgradeTransaction(), - this.tasks.downloadNodeGeneratedFiles(), this.tasks.sendFreezeUpgradeTransaction(), ] } updateExecuteTasks (argv) { return [ + this.tasks.downloadNodeGeneratedFiles(), this.tasks.prepareStagingDirectory('allNodeAliases'), this.tasks.copyNodeKeysToSecrets(), this.tasks.checkAllNodesAreFrozen('existingNodeAliases'), @@ -319,7 +319,6 @@ export class NodeCommandHandlers { const action = helpers.commandActionBuilder([ this.tasks.initialize(argv, updateConfigBuilder.bind(this), lease), this.tasks.loadContextData(argv, NodeCommandHandlers.UPDATE_CONTEXT_FILE, helpers.updateLoadContextParser), - this.tasks.loadAdminKey(), ...this.updateSubmitTransactionsTasks(argv) ], { concurrent: false, diff --git a/src/core/helpers.ts b/src/core/helpers.ts index 9cdeafd51..f05682077 100644 --- a/src/core/helpers.ts +++ b/src/core/helpers.ts @@ -384,6 +384,7 @@ export function updateSaveContextParser (ctx: { config: NodeUpdateConfigClass, u const exportedCtx: any = {} const config = /** @type {NodeUpdateConfigClass} **/ ctx.config + exportedCtx.adminKey = config.adminKey.toString() exportedCtx.newAdminKey = config.newAdminKey.toString() exportedCtx.freezeAdminPrivateKey = config.freezeAdminPrivateKey.toString() exportedCtx.treasuryKey = config.treasuryKey.toString() @@ -409,9 +410,14 @@ export function updateSaveContextParser (ctx: { config: NodeUpdateConfigClass, u */ export function updateLoadContextParser (ctx: { config: NodeUpdateConfigClass, upgradeZipHash: any }, ctxData: any) { const config = ctx.config - config.newAdminKey = PrivateKey.fromStringED25519(ctxData.newAdminKey) + + if (ctxData.newAdminKey && ctxData.newAdminKey.length) { + config.newAdminKey = PrivateKey.fromStringED25519(ctxData.newAdminKey) + } + config.freezeAdminPrivateKey = PrivateKey.fromStringED25519(ctxData.freezeAdminPrivateKey) config.treasuryKey = PrivateKey.fromStringED25519(ctxData.treasuryKey) + config.adminKey = PrivateKey.fromStringED25519(ctxData.adminKey) config.existingNodeAliases = ctxData.existingNodeAliases config.nodeAlias = ctxData.nodeAlias config.newAccountNumber = ctxData.newAccountNumber