diff --git a/.gitignore b/.gitignore index b143af1de..ddf294d45 100644 --- a/.gitignore +++ b/.gitignore @@ -75,3 +75,6 @@ node_modules/ !.yarn/releases !.yarn/sdks !.yarn/versions + +# IntelliJ +.idea/ diff --git a/src/internal/events.test.ts b/src/internal/events.test.ts index e2644ab25..feae5bae6 100644 --- a/src/internal/events.test.ts +++ b/src/internal/events.test.ts @@ -45,6 +45,24 @@ describe('events', () => { expect(is(event, AccountCreatedEventStruct)).toBe(false); }); + + it('should be a valid accountCreated event with displayConfirmation', () => { + const event = { + method: KeyringEvent.AccountCreated, + params: { + account: { + id: '11027d05-12f8-4ec0-b03f-151d86a8089e', + address: '0x0123', + methods: [], + options: {}, + type: EthAccountType.Eoa, + }, + displayConfirmation: true, + }, + }; + + expect(is(event, AccountCreatedEventStruct)).toBe(true); + }); }); describe('AccountUpdatedEventStruct', () => { diff --git a/src/internal/events.ts b/src/internal/events.ts index 87fb764f1..31579f76a 100644 --- a/src/internal/events.ts +++ b/src/internal/events.ts @@ -1,8 +1,9 @@ import { JsonStruct } from '@metamask/utils'; -import { literal, object } from 'superstruct'; +import { boolean, literal, object } from 'superstruct'; import { KeyringAccountStruct } from '../api'; import { KeyringEvent } from '../events'; +import { exactOptional } from '../superstruct'; import { UuidStruct } from '../utils'; export const AccountCreatedEventStruct = object({ @@ -12,6 +13,12 @@ export const AccountCreatedEventStruct = object({ * New account object. */ account: KeyringAccountStruct, + + /** + * Instructs MetaMask to display the add account confirmation dialog in the UI. + * **Note:** This is not guaranteed to be honored by the MetaMask client. + */ + displayConfirmation: exactOptional(boolean()), }), });