diff --git a/packages/airnode-deployer/src/cli/commands.ts b/packages/airnode-deployer/src/cli/commands.ts index f78f3704aa..c9236906f3 100644 --- a/packages/airnode-deployer/src/cli/commands.ts +++ b/packages/airnode-deployer/src/cli/commands.ts @@ -1,11 +1,11 @@ import * as fs from 'fs'; import * as os from 'os'; import * as path from 'path'; -import { loadConfig } from '@api3/airnode-node'; +import { loadConfig, deriveDeploymentVersionId } from '@api3/airnode-node'; import { go } from '@api3/promise-utils'; import { bold } from 'chalk'; import { deployAirnode, removeAirnode, saveDeploymentFiles } from '../infrastructure'; -import { writeReceiptFile, parseReceiptFile, parseSecretsFile } from '../utils'; +import { writeReceiptFile, parseReceiptFile, parseSecretsFile, deriveAirnodeAddress } from '../utils'; import * as logger from '../utils/logger'; import { logAndReturnError, MultiMessageError } from '../utils/infrastructure'; @@ -73,6 +73,8 @@ export async function deploy(configPath: string, secretsPath: string, receiptFil const output = goDeployAirnode.data; if (output.httpGatewayUrl) logger.info(`HTTP gateway URL: ${output.httpGatewayUrl}`); if (output.httpSignedDataGatewayUrl) logger.info(`HTTP signed data gateway URL: ${output.httpSignedDataGatewayUrl}`); + + return { creationTime: time }; } export async function removeWithReceipt(receiptFilename: string) { @@ -95,10 +97,24 @@ export async function rollback(deploymentId: string, versionId: string, receiptF try { await saveDeploymentFiles(deploymentId, versionId, configPathTmp, secretsPathTmp); - await deploy(configPathTmp, secretsPathTmp, receiptFile, autoRemove); + const { creationTime } = await deploy(configPathTmp, secretsPathTmp, receiptFile, autoRemove); + + const secrets = parseSecretsFile(secretsPathTmp); + const config = loadConfig(configPathTmp, secrets); + const { airnodeWalletMnemonic, cloudProvider, stage, nodeVersion } = config.nodeSettings; + const airnodeAddress = deriveAirnodeAddress(airnodeWalletMnemonic); + const newVersionId = deriveDeploymentVersionId( + cloudProvider, + airnodeAddress, + stage, + nodeVersion, + `${creationTime.getTime()}` + ); + + spinner.succeed( + `Rollback of deployment '${deploymentId}' successful, new version '${newVersionId}' with configuration from version '${versionId}' created` + ); } finally { fs.rmSync(configDirTmp, { recursive: true }); } - - spinner.succeed(`Rollback of deployment '${deploymentId}' to version '${versionId}' successful`); } diff --git a/packages/airnode-deployer/src/cli/index.ts b/packages/airnode-deployer/src/cli/index.ts index 1e21949f90..9a6d0f5616 100644 --- a/packages/airnode-deployer/src/cli/index.ts +++ b/packages/airnode-deployer/src/cli/index.ts @@ -27,7 +27,7 @@ function drawHeader() { ); } -async function runCommand(command: () => Promise) { +async function runCommand(command: () => Promise) { const goCommand = await go(command); if (!goCommand.success) { loggerUtils.log('\n\n\nError details:');