Skip to content

Commit 276d56c

Browse files
committed
re-add check
1 parent 03f10c3 commit 276d56c

3 files changed

Lines changed: 36 additions & 2 deletions

File tree

packages/devtools-move/tasks/move/build.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { spawn } from 'child_process'
33
import fs from 'fs'
44
import path from 'path'
55
import { DeployTaskContext } from '../../sdk/baseTaskHelper'
6-
import { getAptosCLICommand } from './utils/config'
6+
import { getAptosCLICommand, checkInitiaCLIVersion } from './utils/config'
77

88
let stdErr = ''
99

@@ -70,6 +70,7 @@ async function getCLICmd(chain: string, stage: string) {
7070
if (chain === 'aptos' || chain === 'movement') {
7171
return await getAptosCLICommand(chain, stage)
7272
} else if (chain === 'initia') {
73+
await checkInitiaCLIVersion()
7374
return 'initiad'
7475
} else {
7576
throw new Error(`Chain ${chain}-${stage} not supported for build.`)

packages/devtools-move/tasks/move/deploy.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { deploymentFile } from '../shared/types'
77
import path from 'path'
88
import type { OAppOmniGraphHardhat } from '@layerzerolabs/toolbox-hardhat'
99
import { DeployTaskContext } from '../../sdk/baseTaskHelper'
10-
import { getAptosCLICommand, getInitiaRPCUrl } from './utils/config'
10+
import { getAptosCLICommand, checkInitiaCLIVersion, getInitiaRPCUrl } from './utils/config'
1111
let stdOut = ''
1212
let stdErr = ''
1313

@@ -36,6 +36,7 @@ async function deployMovementContracts(
3636
`--named-addresses=${namedAddresses}`,
3737
]
3838
} else if (chainName === 'initia') {
39+
await checkInitiaCLIVersion()
3940
const userAccountName = getInitiaKeyName()
4041

4142
cmd = 'initiad'

packages/devtools-move/tasks/move/utils/config.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,38 @@ export function isVersionLessThanOrEqualTo(installed: string, required: string):
384384
//////////////////////////////////// Initia Specific Helpers //////////////////////////////////
385385
///////////////////////////////////////////////////////////////////////////////////////////////
386386

387+
async function getInitiaVersion(): Promise<string> {
388+
return new Promise((resolve, reject) => {
389+
const childProcess = spawn('initiad', ['version'])
390+
let stdout = ''
391+
392+
childProcess.stdout?.on('data', (data) => {
393+
stdout += data.toString()
394+
})
395+
396+
childProcess.on('close', (code) => {
397+
if (code === 0) {
398+
const versionMatch = stdout.match(/v(\d+\.\d+\.\d+)/)
399+
versionMatch ? resolve(versionMatch[1]) : reject(new Error(`Could not parse version`))
400+
} else {
401+
reject(new Error(`initiad version exited with code ${code}`))
402+
}
403+
})
404+
405+
childProcess.on('error', reject)
406+
})
407+
}
408+
409+
export async function checkInitiaCLIVersion(): Promise<void> {
410+
const version = await getInitiaVersion()
411+
412+
if (isVersionGreaterOrEqualTo(version, '1.3.1')) {
413+
console.log(`🚀 Initia CLI version ${version} is compatible.`)
414+
} else {
415+
throw new Error(`❌ Initia CLI version ${version} is not supported. Required: >= 1.3.1`)
416+
}
417+
}
418+
387419
export function getInitiaRPCUrl() {
388420
if (!process.env.INITIA_RPC_URL) {
389421
throw new Error('INITIA_RPC_URL is not set.\n\nPlease set the INITIA_RPC_URL environment variable.')

0 commit comments

Comments
 (0)