@@ -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+
387419export 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