@@ -1335,6 +1335,9 @@ export class SnapController extends BaseController<
13351335 * runnable Snaps.
13361336 */
13371337 init ( ) {
1338+ // Lazily populate the `isReady` state.
1339+ this . #ensureCanUsePlatform( ) . catch ( logWarning ) ;
1340+
13381341 this . #callLifecycleHooks( METAMASK_ORIGIN , HandlerType . OnStart ) ;
13391342 }
13401343
@@ -1545,7 +1548,7 @@ export class SnapController extends BaseController<
15451548 * Also updates any preinstalled Snaps to the latest allowlisted version.
15461549 */
15471550 async updateRegistry ( ) : Promise < void > {
1548- await this . #assertCanUsePlatform ( ) ;
1551+ await this . #ensureCanUsePlatform ( ) ;
15491552 await this . messenger . call ( 'SnapsRegistry:update' ) ;
15501553
15511554 const blockedSnaps = await this . messenger . call (
@@ -1725,12 +1728,14 @@ export class SnapController extends BaseController<
17251728 /**
17261729 * Waits for onboarding and then asserts whether the Snaps platform is allowed to run.
17271730 */
1728- async #assertCanUsePlatform ( ) {
1731+ async #ensureCanUsePlatform ( ) {
17291732 // Ensure the user has onboarded before allowing access to Snaps.
17301733 await this . #ensureOnboardingComplete( ) ;
17311734
17321735 const flags = this . #getFeatureFlags( ) ;
17331736
1737+ // If the user has onboarded, the Snaps Platform is considered ready,
1738+ // if it isn't forced to be disabled via feature flags.
17341739 const isReady = flags . disableSnaps !== true ;
17351740 if ( this . state . isReady !== isReady ) {
17361741 this . update ( ( state ) => {
@@ -1819,7 +1824,7 @@ export class SnapController extends BaseController<
18191824 * @param snapId - The id of the Snap to start.
18201825 */
18211826 async startSnap ( snapId : SnapId ) : Promise < void > {
1822- await this . #assertCanUsePlatform ( ) ;
1827+ await this . #ensureCanUsePlatform ( ) ;
18231828 const snap = this . state . snaps [ snapId ] ;
18241829
18251830 if ( ! snap . enabled ) {
@@ -2720,7 +2725,7 @@ export class SnapController extends BaseController<
27202725 origin : string ,
27212726 requestedSnaps : RequestSnapsParams ,
27222727 ) : Promise < RequestSnapsResult > {
2723- await this . #assertCanUsePlatform ( ) ;
2728+ await this . #ensureCanUsePlatform ( ) ;
27242729
27252730 const result : RequestSnapsResult = { } ;
27262731
@@ -3006,7 +3011,7 @@ export class SnapController extends BaseController<
30063011 if ( ! automaticUpdate ) {
30073012 this . #assertCanInstallSnaps( ) ;
30083013 }
3009- await this . #assertCanUsePlatform ( ) ;
3014+ await this . #ensureCanUsePlatform ( ) ;
30103015
30113016 const snap = this . getExpect ( snapId ) ;
30123017
@@ -3641,7 +3646,7 @@ export class SnapController extends BaseController<
36413646 handler : handlerType ,
36423647 request : rawRequest ,
36433648 } : SnapRpcHookArgs & { snapId : SnapId } ) : Promise < unknown > {
3644- await this . #assertCanUsePlatform ( ) ;
3649+ await this . #ensureCanUsePlatform ( ) ;
36453650
36463651 const snap = this . get ( snapId ) ;
36473652
0 commit comments