@@ -11,6 +11,7 @@ import { DEFAULT_IPFS_URL } from '../command-helpers/ipfs.js';
11
11
import { initNetworksConfig } from '../command-helpers/network.js' ;
12
12
import { chooseNodeUrl } from '../command-helpers/node.js' ;
13
13
import { PromptManager } from '../command-helpers/prompt-manager.js' ;
14
+ import { checkForProxy } from '../command-helpers/proxy.js' ;
14
15
import { loadRegistry } from '../command-helpers/registry.js' ;
15
16
import { retryWithPrompt } from '../command-helpers/retry.js' ;
16
17
import { generateScaffold , writeScaffold } from '../command-helpers/scaffold.js' ;
@@ -622,38 +623,22 @@ async function processInitForm(
622
623
( ) => contractService . getABI ( protocolInstance . getABI ( ) , network . id , address ) ,
623
624
) ,
624
625
) ;
625
- initDebugger . extend ( 'processInitForm' ) ( "abiFromEtherscan len: '%s'" , abiFromApi ?. name ) ;
626
- const isProxy = abiFromApi ?. callFunctionSignatures ( ) . includes ( 'upgradeTo(address)' ) ;
627
- if ( isProxy ) {
628
- const impl = await retryWithPrompt ( ( ) =>
629
- withSpinner (
630
- 'Fetching proxy implementation address...' ,
631
- 'Failed to fetch proxy implementation address' ,
632
- 'Warning fetching proxy implementation address' ,
633
- ( ) => contractService . getProxyImplementation ( network . id , address ) ,
634
- ) ,
626
+ initDebugger . extend ( 'processInitForm' ) ( "ABI: '%s'" , abiFromApi ?. name ) ;
627
+ if ( abiFromApi ) {
628
+ const { implementationAbi, implementationAddress } = await checkForProxy (
629
+ contractService ,
630
+ network . id ,
631
+ address ,
632
+ abiFromApi ,
635
633
) ;
636
- initDebugger . extend ( 'processInitForm' ) ( "proxyImplementation: '%s'" , impl ) ;
637
- if ( impl ) {
638
- const useImplementation = await prompt
639
- . confirm (
640
- `Proxy contract detected. Use implementation contract ABI at ${ impl } ?` ,
641
- true ,
642
- )
643
- . catch ( ( ) => false ) ;
644
-
645
- if ( useImplementation ) {
646
- implAddress = impl ;
647
- abiFromApi = await retryWithPrompt ( ( ) =>
648
- withSpinner (
649
- 'Fetching implementation contract ABI...' ,
650
- 'Failed to fetch implementation ABI' ,
651
- 'Warning fetching implementation ABI' ,
652
- ( ) =>
653
- contractService . getABI ( protocolInstance . getABI ( ) , network . id , implAddress ! ) ,
654
- ) ,
655
- ) ;
656
- }
634
+ if ( implementationAddress ) {
635
+ implAddress = implementationAddress ;
636
+ abiFromApi = implementationAbi ! ;
637
+ initDebugger . extend ( 'processInitForm' ) (
638
+ "Impl ABI: '%s', Impl Address: '%s'" ,
639
+ abiFromApi ?. name ,
640
+ implAddress ,
641
+ ) ;
657
642
}
658
643
}
659
644
}
0 commit comments