Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion packages/snaps-controllers/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- **BREAKING:** All action types were renamed from `DoSomething` to `ControllerNameDoSomethingAction` ([#3907](https://github.com/MetaMask/snaps/pull/3907), [#3911](https://github.com/MetaMask/snaps/pull/3911), [#3912](https://github.com/MetaMask/snaps/pull/3912), [#3916](https://github.com/MetaMask/snaps/pull/3916))
- **BREAKING:** All action types were renamed from `DoSomething` to `ControllerNameDoSomethingAction` ([#3907](https://github.com/MetaMask/snaps/pull/3907), [#3911](https://github.com/MetaMask/snaps/pull/3911), [#3912](https://github.com/MetaMask/snaps/pull/3912), [#3916](https://github.com/MetaMask/snaps/pull/3916), [#3918](https://github.com/MetaMask/snaps/pull/3918))
- `SnapController` actions:
- `GetSnap` is now `SnapControllerGetSnapAction`.
- Note: The method is now called `getSnap` instead of `get`.
Expand Down Expand Up @@ -56,6 +56,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `HandleRequest` is now `ExecutionServiceHandleRequestAction`.
- `TerminateSnap` is now `ExecutionServiceTerminateSnapAction`.
- `GetExecutionStatus` is now `ExecutionServiceGetExecutionStatusAction`.
- `SnapRegistryController` actions:
- `GetResult` is now `SnapRegistryControllerGetAction`.
- `GetMetadata` is now `SnapRegistryControllerGetMetadataAction`.
- `ResolveVersion` is now `SnapRegistryControllerResolveVersionAction`.
- `Update` is now `SnapRegistryControllerRequestUpdateAction`.
- Note: The method is now called `requestUpdate` instead of `update`.
- **BREAKING:** All event types were renamed from `OnSomething` to `ControllerOnSomethingEvent` ([#3907](https://github.com/MetaMask/snaps/pull/3907), [#3916](https://github.com/MetaMask/snaps/pull/3916))
- `SnapController` events:
- `SnapStateChange` was removed in favour of `SnapControllerStateChangeEvent`.
Expand All @@ -76,6 +82,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `OutboundResponse` is now `ExecutionServiceOutboundResponseEvent`.
- **BREAKING:**: Rename `MultichainRouter` to `MultichainRoutingService` and update action types accordingly ([#3913](https://github.com/MetaMask/snaps/pull/3913))
- This is consistent with the naming of other services.
- **BREAKING:** Rename `JsonSnapsRegistry` to `SnapRegistryController` and update action types accordingly ([#3918](https://github.com/MetaMask/snaps/pull/3918))
- This is consistent with the naming of other controllers.
- The controller name is now `SnapRegistryController` instead of `SnapsRegistry` as well.
- **BREAKING:** `MultichainRoutingService` now requires `SnapController:getRunnableSnaps` instead of `SnapController:getAllSnaps` ([#3913](https://github.com/MetaMask/snaps/pull/3913))
- **BREAKING:** `SnapInsightsController` now requires `SnapController:getRunnableSnaps` instead of `SnapController:getAllSnaps` ([#3915](https://github.com/MetaMask/snaps/pull/3915))
- **RREAKING:** Replace `ExecutionService` interface with abstract class ([#3916](https://github.com/MetaMask/snaps/pull/3916))
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-controllers/coverage.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"branches": 94.97,
"functions": 98.78,
"lines": 98.63,
"statements": 98.43
"statements": 98.32
}
52 changes: 26 additions & 26 deletions packages/snaps-controllers/src/snaps/SnapController.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ import {
METAMASK_ORIGIN,
STATE_DEBOUNCE_TIMEOUT,
} from './constants';
import { SnapsRegistryStatus } from './registry';
import { SnapRegistryStatus } from './registry';
import type { SnapControllerState } from './SnapController';
import {
controllerName,
Expand Down Expand Up @@ -127,7 +127,7 @@ import {
MOCK_SNAP_PERMISSIONS,
MOCK_SNAP_SUBJECT_METADATA,
MOCK_WALLET_SNAP_PERMISSION,
MockSnapsRegistry,
MockSnapRegistryController,
sleep,
waitForStateChange,
} from '../test-utils';
Expand Down Expand Up @@ -817,7 +817,7 @@ describe('SnapController', () => {

expect(options.messenger.call).toHaveBeenNthCalledWith(
2,
'SnapsRegistry:get',
'SnapRegistryController:get',
{
[MOCK_SNAP_ID]: {
version: '1.0.0',
Expand Down Expand Up @@ -1048,7 +1048,7 @@ describe('SnapController', () => {

it('throws an error if snap is not on allowlist and allowlisting is required but resolve succeeds', async () => {
const rootMessenger = getRootMessenger();
const registry = new MockSnapsRegistry(rootMessenger);
const registry = new MockSnapRegistryController(rootMessenger);

const controller = await getSnapController(
getSnapControllerOptions({
Expand Down Expand Up @@ -1077,7 +1077,7 @@ describe('SnapController', () => {

it('throws an error if the registry is unavailable and allowlisting is required but resolve succeeds', async () => {
const rootMessenger = getRootMessenger();
const registry = new MockSnapsRegistry(rootMessenger);
const registry = new MockSnapRegistryController(rootMessenger);

const controller = await getSnapController(
getSnapControllerOptions({
Expand All @@ -1091,7 +1091,7 @@ describe('SnapController', () => {
// Mock resolve to succeed, but registry.get() will fail later
registry.resolveVersion.mockReturnValue('1.0.0');
registry.get.mockReturnValue({
[MOCK_SNAP_ID]: { status: SnapsRegistryStatus.Unavailable },
[MOCK_SNAP_ID]: { status: SnapRegistryStatus.Unavailable },
});

await expect(
Expand Down Expand Up @@ -1141,7 +1141,7 @@ describe('SnapController', () => {

it('resolves to allowlisted version when allowlisting is required', async () => {
const rootMessenger = getRootMessenger();
const registry = new MockSnapsRegistry(rootMessenger);
const registry = new MockSnapRegistryController(rootMessenger);

const { manifest, sourceCode, svgIcon } =
await getMockSnapFilesWithUpdatedChecksum({
Expand All @@ -1151,7 +1151,7 @@ describe('SnapController', () => {
});

registry.get.mockResolvedValueOnce({
[MOCK_SNAP_ID]: { status: SnapsRegistryStatus.Verified },
[MOCK_SNAP_ID]: { status: SnapRegistryStatus.Verified },
});

registry.resolveVersion.mockReturnValue('1.1.0');
Expand Down Expand Up @@ -1181,7 +1181,7 @@ describe('SnapController', () => {

it('does not use registry resolving when allowlist is not required', async () => {
const rootMessenger = getRootMessenger();
const registry = new MockSnapsRegistry(rootMessenger);
const registry = new MockSnapRegistryController(rootMessenger);

const controller = await getSnapController(
getSnapControllerOptions({
Expand Down Expand Up @@ -8918,7 +8918,7 @@ describe('SnapController', () => {

it('throws an error if the new version of the snap is blocked', async () => {
const rootMessenger = getRootMessenger();
const registry = new MockSnapsRegistry(rootMessenger);
const registry = new MockSnapRegistryController(rootMessenger);

const { manifest } = await getMockSnapFilesWithUpdatedChecksum({
manifest: getSnapManifest({
Expand All @@ -8940,7 +8940,7 @@ describe('SnapController', () => {
);

registry.get.mockResolvedValueOnce({
[MOCK_SNAP_ID]: { status: SnapsRegistryStatus.Blocked },
[MOCK_SNAP_ID]: { status: SnapRegistryStatus.Blocked },
});

await expect(
Expand Down Expand Up @@ -10519,7 +10519,7 @@ describe('SnapController', () => {
describe('updateRegistry', () => {
it('updates the registry database', async () => {
const rootMessenger = getRootMessenger();
const registry = new MockSnapsRegistry(rootMessenger);
const registry = new MockSnapRegistryController(rootMessenger);

const snapController = await getSnapController(
getSnapControllerOptions({
Expand All @@ -10531,14 +10531,14 @@ describe('SnapController', () => {
);
await snapController.updateRegistry();

expect(registry.update).toHaveBeenCalled();
expect(registry.requestUpdate).toHaveBeenCalled();

snapController.destroy();
});

it('blocks snaps as expected', async () => {
const rootMessenger = getRootMessenger();
const registry = new MockSnapsRegistry(rootMessenger);
const registry = new MockSnapRegistryController(rootMessenger);

const mockSnapA = getMockSnapData({
id: 'npm:exampleA' as SnapId,
Expand Down Expand Up @@ -10569,7 +10569,7 @@ describe('SnapController', () => {
// Block snap A, ignore B.
registry.get.mockResolvedValueOnce({
[mockSnapA.id]: {
status: SnapsRegistryStatus.Blocked,
status: SnapRegistryStatus.Blocked,
reason: { explanation, infoUrl },
},
});
Expand Down Expand Up @@ -10609,7 +10609,7 @@ describe('SnapController', () => {

it('stops running snaps when they are blocked', async () => {
const rootMessenger = getRootMessenger();
const registry = new MockSnapsRegistry(rootMessenger);
const registry = new MockSnapRegistryController(rootMessenger);

const mockSnap = getMockSnapData({
id: 'npm:example' as SnapId,
Expand All @@ -10629,7 +10629,7 @@ describe('SnapController', () => {

// Block the snap
registry.get.mockResolvedValueOnce({
[mockSnap.id]: { status: SnapsRegistryStatus.Blocked },
[mockSnap.id]: { status: SnapRegistryStatus.Blocked },
});
await snapController.updateRegistry();
await waitForStateChange(options.messenger);
Expand All @@ -10644,7 +10644,7 @@ describe('SnapController', () => {

it('unblocks snaps as expected', async () => {
const rootMessenger = getRootMessenger();
const registry = new MockSnapsRegistry(rootMessenger);
const registry = new MockSnapRegistryController(rootMessenger);

const mockSnapA = getMockSnapData({
id: 'npm:exampleA' as SnapId,
Expand Down Expand Up @@ -10683,8 +10683,8 @@ describe('SnapController', () => {
// Indicate that both snaps A and B are unblocked, and update blocked
// states.
registry.get.mockResolvedValueOnce({
[mockSnapA.id]: { status: SnapsRegistryStatus.Unverified },
[mockSnapB.id]: { status: SnapsRegistryStatus.Unverified },
[mockSnapA.id]: { status: SnapRegistryStatus.Unverified },
[mockSnapB.id]: { status: SnapRegistryStatus.Unverified },
});
await snapController.updateRegistry();

Expand All @@ -10707,7 +10707,7 @@ describe('SnapController', () => {
it('updating blocked snaps does not throw if a snap is removed while fetching the blocklist', async () => {
const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation();
const rootMessenger = getRootMessenger();
const registry = new MockSnapsRegistry(rootMessenger);
const registry = new MockSnapRegistryController(rootMessenger);

const mockSnap = getMockSnapData({
id: 'npm:example' as SnapId,
Expand Down Expand Up @@ -10736,7 +10736,7 @@ describe('SnapController', () => {

// Resolve the blocklist and wait for the call to complete
resolveBlockListPromise({
[mockSnap.id]: { status: SnapsRegistryStatus.Blocked },
[mockSnap.id]: { status: SnapRegistryStatus.Blocked },
});
await updateBlockList;

Expand All @@ -10750,7 +10750,7 @@ describe('SnapController', () => {
it('logs but does not throw unexpected errors while blocking', async () => {
const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation();
const rootMessenger = getRootMessenger();
const registry = new MockSnapsRegistry(rootMessenger);
const registry = new MockSnapRegistryController(rootMessenger);

const mockSnap = getMockSnapData({
id: 'npm:example' as SnapId,
Expand All @@ -10774,7 +10774,7 @@ describe('SnapController', () => {

// Block the snap
registry.get.mockResolvedValueOnce({
[mockSnap.id]: { status: SnapsRegistryStatus.Blocked },
[mockSnap.id]: { status: SnapRegistryStatus.Blocked },
});
await snapController.updateRegistry();

Expand All @@ -10793,7 +10793,7 @@ describe('SnapController', () => {

it('updates preinstalled Snaps', async () => {
const rootMessenger = getRootMessenger();
const registry = new MockSnapsRegistry(rootMessenger);
const registry = new MockSnapRegistryController(rootMessenger);

// Simulate previous permissions, some of which will be removed
rootMessenger.registerActionHandler(
Expand Down Expand Up @@ -10889,7 +10889,7 @@ describe('SnapController', () => {

it('does not update preinstalled Snaps when the feature flag is off', async () => {
const rootMessenger = getRootMessenger();
const registry = new MockSnapsRegistry(rootMessenger);
const registry = new MockSnapRegistryController(rootMessenger);

const snapId = 'npm:@metamask/jsx-example-snap' as SnapId;

Expand Down
Loading
Loading