Skip to content

Commit af7cf57

Browse files
committed
feat: Add new metadata properties to AppMetadataController
The new metadata properties includeInStateLogs and usedInUi have been added to the `AppMetadataController`. Fixes #6515
1 parent 11476e1 commit af7cf57

File tree

2 files changed

+80
-1
lines changed

2 files changed

+80
-1
lines changed

packages/app-metadata-controller/src/AppMetadataController.test.ts

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Messenger } from '@metamask/base-controller';
1+
import { Messenger, deriveStateFromMetadata } from '@metamask/base-controller';
22

33
import {
44
AppMetadataController,
@@ -120,6 +120,77 @@ describe('AppMetadataController', () => {
120120
);
121121
});
122122
});
123+
124+
describe('metadata', () => {
125+
it('includes expected state in debug snapshots', () => {
126+
withController(({ controller }) => {
127+
expect(
128+
deriveStateFromMetadata(
129+
controller.state,
130+
controller.metadata,
131+
'anonymous',
132+
),
133+
).toMatchInlineSnapshot(`
134+
Object {
135+
"currentAppVersion": "",
136+
"currentMigrationVersion": 0,
137+
"previousAppVersion": "",
138+
"previousMigrationVersion": 0,
139+
}
140+
`);
141+
});
142+
});
143+
144+
it('includes expected state in state logs', () => {
145+
withController(({ controller }) => {
146+
expect(
147+
deriveStateFromMetadata(
148+
controller.state,
149+
controller.metadata,
150+
'includeInStateLogs',
151+
),
152+
).toMatchInlineSnapshot(`
153+
Object {
154+
"currentAppVersion": "",
155+
"currentMigrationVersion": 0,
156+
"previousAppVersion": "",
157+
"previousMigrationVersion": 0,
158+
}
159+
`);
160+
});
161+
});
162+
163+
it('persists expected state', () => {
164+
withController(({ controller }) => {
165+
expect(
166+
deriveStateFromMetadata(
167+
controller.state,
168+
controller.metadata,
169+
'persist',
170+
),
171+
).toMatchInlineSnapshot(`
172+
Object {
173+
"currentAppVersion": "",
174+
"currentMigrationVersion": 0,
175+
"previousAppVersion": "",
176+
"previousMigrationVersion": 0,
177+
}
178+
`);
179+
});
180+
});
181+
182+
it('exposes expected state to UI', () => {
183+
withController(({ controller }) => {
184+
expect(
185+
deriveStateFromMetadata(
186+
controller.state,
187+
controller.metadata,
188+
'usedInUi',
189+
),
190+
).toMatchInlineSnapshot(`Object {}`);
191+
});
192+
});
193+
});
123194
});
124195

125196
type WithControllerOptions = Partial<AppMetadataControllerOptions>;

packages/app-metadata-controller/src/AppMetadataController.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,20 +103,28 @@ export type AppMetadataControllerMessenger = RestrictedMessenger<
103103
*/
104104
const controllerMetadata = {
105105
currentAppVersion: {
106+
includeInStateLogs: true,
106107
persist: true,
107108
anonymous: true,
109+
usedInUi: false,
108110
},
109111
previousAppVersion: {
112+
includeInStateLogs: true,
110113
persist: true,
111114
anonymous: true,
115+
usedInUi: false,
112116
},
113117
previousMigrationVersion: {
118+
includeInStateLogs: true,
114119
persist: true,
115120
anonymous: true,
121+
usedInUi: false,
116122
},
117123
currentMigrationVersion: {
124+
includeInStateLogs: true,
118125
persist: true,
119126
anonymous: true,
127+
usedInUi: false,
120128
},
121129
} satisfies StateMetadata<AppMetadataControllerState>;
122130

0 commit comments

Comments
 (0)