Skip to content

Commit e5f7fa0

Browse files
authored
feat: Add new metadata properties to DelegationController (#6531)
## Explanation The new metadata properties `includeInStateLogs` and `usedInUi` have been added to the `DelegationController` ## References * Fixes #6507 * Related to #6443 ## Checklist - [ ] I've updated the test suite for new or updated code as appropriate - [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [ ] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs), highlighting breaking changes as necessary - [ ] I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes
1 parent cb75a90 commit e5f7fa0

File tree

3 files changed

+61
-1
lines changed

3 files changed

+61
-1
lines changed

packages/delegation-controller/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Add two new controller state metadata properties: `includeInStateLogs` and `usedInUi` ([#6531](https://github.com/MetaMask/core/pull/6531))
13+
1014
### Changed
1115

1216
- Bump `@metamask/base-controller` from `^8.1.0` to `^8.3.0` ([#6355](https://github.com/MetaMask/core/pull/6355), [#6465](https://github.com/MetaMask/core/pull/6465))

packages/delegation-controller/src/DelegationController.test.ts

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { AccountsControllerGetSelectedAccountAction } from '@metamask/accounts-controller';
2-
import { Messenger } from '@metamask/base-controller';
2+
import { deriveStateFromMetadata, Messenger } from '@metamask/base-controller';
33
import {
44
type KeyringControllerSignTypedMessageAction,
55
SignTypedDataVersion,
@@ -670,4 +670,58 @@ describe(`${controllerName}`, () => {
670670
);
671671
});
672672
});
673+
674+
describe('metadata', () => {
675+
it('includes expected state in debug snapshots', () => {
676+
const { controller } = createController();
677+
678+
expect(
679+
deriveStateFromMetadata(
680+
controller.state,
681+
controller.metadata,
682+
'anonymous',
683+
),
684+
).toMatchInlineSnapshot(`Object {}`);
685+
});
686+
687+
it('includes expected state in state logs', () => {
688+
const { controller } = createController();
689+
690+
expect(
691+
deriveStateFromMetadata(
692+
controller.state,
693+
controller.metadata,
694+
'includeInStateLogs',
695+
),
696+
).toMatchInlineSnapshot(`Object {}`);
697+
});
698+
699+
it('persists expected state', () => {
700+
const { controller } = createController();
701+
702+
expect(
703+
deriveStateFromMetadata(
704+
controller.state,
705+
controller.metadata,
706+
'persist',
707+
),
708+
).toMatchInlineSnapshot(`
709+
Object {
710+
"delegations": Object {},
711+
}
712+
`);
713+
});
714+
715+
it('includes expected state in UI', () => {
716+
const { controller } = createController();
717+
718+
expect(
719+
deriveStateFromMetadata(
720+
controller.state,
721+
controller.metadata,
722+
'usedInUi',
723+
),
724+
).toMatchInlineSnapshot(`Object {}`);
725+
});
726+
});
673727
});

packages/delegation-controller/src/DelegationController.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ export const controllerName = 'DelegationController';
2121

2222
const delegationControllerMetadata = {
2323
delegations: {
24+
includeInStateLogs: false,
2425
persist: true,
2526
anonymous: false,
27+
usedInUi: false,
2628
},
2729
} satisfies StateMetadata<DelegationControllerState>;
2830

0 commit comments

Comments
 (0)