@@ -465,6 +465,8 @@ async function processInitForm(
465
465
| undefined
466
466
> {
467
467
let abiFromEtherscan : EthereumABI | undefined = undefined ;
468
+ let startBlockFromEtherscan : string | undefined = undefined ;
469
+ let contractNameFromEtherscan : string | undefined = undefined ;
468
470
469
471
try {
470
472
const { protocol } = await prompt . ask < { protocol : ProtocolName } > ( {
@@ -586,7 +588,7 @@ async function processInitForm(
586
588
loadStartBlockForContract ( network , value ) ,
587
589
) ;
588
590
if ( startBlock ) {
589
- initStartBlock = Number ( startBlock ) . toString ( ) ;
591
+ startBlockFromEtherscan = Number ( startBlock ) . toString ( ) ;
590
592
}
591
593
}
592
594
@@ -597,7 +599,7 @@ async function processInitForm(
597
599
loadContractNameForAddress ( network , value ) ,
598
600
) ;
599
601
if ( contractName ) {
600
- initContractName = contractName ;
602
+ contractNameFromEtherscan = contractName ;
601
603
}
602
604
}
603
605
@@ -666,13 +668,9 @@ async function processInitForm(
666
668
type : 'input' ,
667
669
name : 'startBlock' ,
668
670
message : 'Start Block' ,
669
- initial : initStartBlock || '0' ,
671
+ initial : initStartBlock || startBlockFromEtherscan || '0' ,
670
672
skip : ( ) => initFromExample !== undefined || isSubstreams ,
671
673
validate : value => parseInt ( value ) >= 0 ,
672
- result ( value ) {
673
- if ( initStartBlock ) return initStartBlock ;
674
- return value ;
675
- } ,
676
674
} ,
677
675
] ) ;
678
676
@@ -681,13 +679,9 @@ async function processInitForm(
681
679
type : 'input' ,
682
680
name : 'contractName' ,
683
681
message : 'Contract Name' ,
684
- initial : initContractName || 'Contract' || isSubstreams ,
682
+ initial : initContractName || contractNameFromEtherscan || 'Contract' || isSubstreams ,
685
683
skip : ( ) => initFromExample !== undefined || ! protocolInstance . hasContract ( ) ,
686
684
validate : value => value && value . length > 0 ,
687
- result ( value ) {
688
- if ( initContractName ) return initContractName ;
689
- return value ;
690
- } ,
691
685
} ,
692
686
] ) ;
693
687
0 commit comments