@@ -382,11 +382,6 @@ export class PPOMController extends BaseControllerV2<
382382 . catch ( ( error : unknown ) => {
383383 console . error ( 'Error in trying to initialize PPOM' , error ) ;
384384 throw error ;
385- } )
386- . finally ( ( ) => {
387- if ( this . #ppomInitialisationCallback) {
388- this . #ppomInitialisationCallback( ) ;
389- }
390385 } ) ;
391386 }
392387 }
@@ -479,6 +474,11 @@ export class PPOMController extends BaseControllerV2<
479474 // eslint-disable-next-line @typescript-eslint/no-floating-promises
480475 this . #initialisePPOM( ) ;
481476 this . #checkScheduleFileDownloadForAllChains( ) ;
477+ this . #getNewFilesForChain( ETHEREUM_CHAIN_ID ) . finally ( ( ) => {
478+ if ( this . #ppomInitialisationCallback) {
479+ this . #ppomInitialisationCallback( ) ;
480+ }
481+ } ) ;
482482 } else {
483483 this . #resetToInactiveState( ) ;
484484 }
@@ -526,7 +526,7 @@ export class PPOMController extends BaseControllerV2<
526526 */
527527 async #reinitPPOMForNetworkIfRequired( ) : Promise < void > {
528528 if ( this . #isDataRequiredForCurrentChain( ) ) {
529- await this . #getNewFilesForCurrentChain ( ) ;
529+ await this . #getNewFilesForChain ( this . #chainId ) ;
530530 }
531531 }
532532
@@ -661,9 +661,9 @@ export class PPOMController extends BaseControllerV2<
661661 * The function is invoked if user if attempting transaction for current network,
662662 * for which data is not previously fetched.
663663 */
664- async #getNewFilesForCurrentChain ( ) : Promise < void > {
664+ async #getNewFilesForChain ( chainId : string ) : Promise < void > {
665665 for ( const fileVersionInfo of this . state . versionInfo ) {
666- if ( fileVersionInfo . chainId !== this . # chainId) {
666+ if ( fileVersionInfo . chainId !== chainId ) {
667667 continue ;
668668 }
669669
@@ -673,7 +673,7 @@ export class PPOMController extends BaseControllerV2<
673673 ) ;
674674 } ) ;
675675 }
676- await this . #setChainIdDataFetched( this . # chainId) ;
676+ await this . #setChainIdDataFetched( chainId ) ;
677677 await this . #reinitPPOM( ) ;
678678 }
679679
@@ -807,7 +807,6 @@ export class PPOMController extends BaseControllerV2<
807807 if ( isLastFileOfNetwork ) {
808808 // if this was last file for the chainId set dataFetched for chainId to true
809809 await this . #setChainIdDataFetched( fileVersionInfo . chainId ) ;
810- // if (fileVersionInfo.chainId === this.#chainId) {
811810 if ( fileVersionInfo . chainId === ETHEREUM_CHAIN_ID ) {
812811 await this . #reinitPPOM( ) ;
813812 }
0 commit comments