Skip to content

Commit 6a20e47

Browse files
committed
rework is ready
1 parent 84a60b0 commit 6a20e47

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

packages/snaps-controllers/src/snaps/SnapController.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,9 +1346,6 @@ export class SnapController extends BaseController<
13461346
* runnable Snaps.
13471347
*/
13481348
init() {
1349-
// Lazily populate the `isReady` state.
1350-
this.#ensureCanUsePlatform().catch(logWarning);
1351-
13521349
this.#setup().catch((error) => {
13531350
logError('Error during SnapController initialization.', error);
13541351
});
@@ -1369,6 +1366,8 @@ export class SnapController extends BaseController<
13691366
await this.#handlePreinstalledSnaps(this.#preinstalledSnaps);
13701367
}
13711368

1369+
await this.#platformIsReady();
1370+
13721371
this.#controllerSetup.resolve();
13731372
} catch (error) {
13741373
this.#controllerSetup.reject(error);
@@ -1765,11 +1764,15 @@ export class SnapController extends BaseController<
17651764
* Waits for onboarding and then asserts whether the Snaps platform is allowed to run.
17661765
*/
17671766
async #ensureCanUsePlatform() {
1768-
// Ensure the user has onboarded before allowing access to Snaps.
1769-
await this.#ensureOnboardingComplete();
1767+
await this.#platformIsReady();
17701768

17711769
// Ensure the controller has finished setting up.
17721770
await this.#controllerSetup.promise;
1771+
}
1772+
1773+
async #platformIsReady() {
1774+
// Ensure the user has onboarded before allowing access to Snaps.
1775+
await this.#ensureOnboardingComplete();
17731776

17741777
const flags = this.#getFeatureFlags();
17751778

packages/snaps-controllers/src/test-utils/controller.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {
2525
} from '@metamask/snaps-rpc-methods';
2626
import type { SnapId } from '@metamask/snaps-sdk';
2727
import { Text } from '@metamask/snaps-sdk/jsx';
28-
import type { PersistedSnap, Snap } from '@metamask/snaps-utils';
28+
import type { PersistedSnap } from '@metamask/snaps-utils';
2929
import { SnapCaveatType } from '@metamask/snaps-utils';
3030
import {
3131
getPersistedSnapObject,

yarn.lock

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4269,11 +4269,8 @@ __metadata:
42694269
"@metamask/snaps-rpc-methods": "workspace:^"
42704270
"@metamask/snaps-sdk": "workspace:^"
42714271
"@metamask/snaps-utils": "workspace:^"
4272-
<<<<<<< HEAD
4273-
"@metamask/superstruct": "npm:^3.2.1"
4274-
=======
42754272
"@metamask/storage-service": "npm:^0.0.1"
4276-
>>>>>>> 57095fea (Add `StorageService` and handle preinstalled snap setup in `init`)
4273+
"@metamask/superstruct": "npm:^3.2.1"
42774274
"@metamask/utils": "npm:^11.8.1"
42784275
"@noble/hashes": "npm:^1.7.1"
42794276
"@swc/core": "npm:1.11.31"

0 commit comments

Comments
 (0)