Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BaseControllerV2 metadata is required for all the properties #4612

Merged
merged 9 commits into from
Aug 21, 2024
2 changes: 1 addition & 1 deletion packages/base-controller/src/BaseControllerV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export class BaseController<
state,
}: {
messenger: messenger;
metadata: StateMetadata<ControllerState>;
metadata: Required<StateMetadata<ControllerState>>;
name: ControllerName;
state: ControllerState;
}) {
Expand Down
4 changes: 3 additions & 1 deletion packages/composable-controller/src/ComposableController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,9 @@ export class ComposableController<

super({
name: controllerName,
metadata: controllers.reduce<StateMetadata<ComposableControllerState>>(
metadata: controllers.reduce<
Required<StateMetadata<ComposableControllerState>>
>(
(metadata, controller) => ({
...metadata,
[controller.name]: isBaseController(controller)
Expand Down
4 changes: 2 additions & 2 deletions packages/permission-controller/src/PermissionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ export type PermissionControllerState<Permission> =
* @returns The state metadata
*/
function getStateMetadata<Permission extends PermissionConstraint>() {
return { subjects: { anonymous: true, persist: true } } as StateMetadata<
PermissionControllerState<Permission>
return { subjects: { anonymous: true, persist: true } } as Required<
StateMetadata<PermissionControllerState<Permission>>
>;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type {
RestrictedControllerMessenger,
StateMetadata,

Check failure on line 3 in packages/profile-sync-controller/src/controllers/authentication/AuthenticationController.ts

View workflow job for this annotation

GitHub Actions / Lint, build, and test / Lint (20.x)

'StateMetadata' is defined but never used
} from '@metamask/base-controller';
import { BaseController } from '@metamask/base-controller';
import type {
Expand Down Expand Up @@ -56,7 +56,7 @@
export const defaultState: AuthenticationControllerState = {
isSignedIn: false,
};
const metadata: StateMetadata<AuthenticationControllerState> = {
const metadata = {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can also be fixed with.

Suggested change
const metadata = {
const metadata: Required<StateMetadata<AuthenticationControllerState>> = {

Type has been removed to be inline with other v2 controllers.

isSignedIn: {
persist: true,
anonymous: true,
Expand Down
Loading