@@ -465,6 +465,8 @@ async function processInitForm(
465465 | undefined
466466> {
467467 let abiFromEtherscan : EthereumABI | undefined = undefined ;
468+ let startBlockFromEtherscan : string | undefined = undefined ;
469+ let contractNameFromEtherscan : string | undefined = undefined ;
468470
469471 try {
470472 const { protocol } = await prompt . ask < { protocol : ProtocolName } > ( {
@@ -586,7 +588,7 @@ async function processInitForm(
586588 loadStartBlockForContract ( network , value ) ,
587589 ) ;
588590 if ( startBlock ) {
589- initStartBlock = Number ( startBlock ) . toString ( ) ;
591+ startBlockFromEtherscan = Number ( startBlock ) . toString ( ) ;
590592 }
591593 }
592594
@@ -597,7 +599,7 @@ async function processInitForm(
597599 loadContractNameForAddress ( network , value ) ,
598600 ) ;
599601 if ( contractName ) {
600- initContractName = contractName ;
602+ contractNameFromEtherscan = contractName ;
601603 }
602604 }
603605
@@ -666,13 +668,9 @@ async function processInitForm(
666668 type : 'input' ,
667669 name : 'startBlock' ,
668670 message : 'Start Block' ,
669- initial : initStartBlock || '0' ,
671+ initial : initStartBlock || startBlockFromEtherscan || '0' ,
670672 skip : ( ) => initFromExample !== undefined || isSubstreams ,
671673 validate : value => parseInt ( value ) >= 0 ,
672- result ( value ) {
673- if ( initStartBlock ) return initStartBlock ;
674- return value ;
675- } ,
676674 } ,
677675 ] ) ;
678676
@@ -681,13 +679,9 @@ async function processInitForm(
681679 type : 'input' ,
682680 name : 'contractName' ,
683681 message : 'Contract Name' ,
684- initial : initContractName || 'Contract' || isSubstreams ,
682+ initial : initContractName || contractNameFromEtherscan || 'Contract' || isSubstreams ,
685683 skip : ( ) => initFromExample !== undefined || ! protocolInstance . hasContract ( ) ,
686684 validate : value => value && value . length > 0 ,
687- result ( value ) {
688- if ( initContractName ) return initContractName ;
689- return value ;
690- } ,
691685 } ,
692686 ] ) ;
693687
0 commit comments