diff --git a/packages/extension/src/client/Aztec/ApiManager.js b/packages/extension/src/client/Aztec/ApiManager.js index 80e08d4f9..eb275587e 100644 --- a/packages/extension/src/client/Aztec/ApiManager.js +++ b/packages/extension/src/client/Aztec/ApiManager.js @@ -7,6 +7,7 @@ import EventListeners from '~/utils/EventListeners'; import Web3Service from '~/client/services/Web3Service'; import ApiPermissionService from '~/client/services/ApiPermissionService'; import ConnectionService from '~/client/services/ConnectionService'; +import Account from '~/client/apis/Account'; export default class ApiManager { constructor() { @@ -106,12 +107,14 @@ export default class ApiManager { error = null, }, ) => { - this.aztecAccount = aztecAccount; + this.aztecAccount = aztecAccount + ? new Account(aztecAccount) + : null; this.error = error; this.eventListeners.notify( 'profileChanged', 'aztecAccountChanged', - aztecAccount, + this.aztecAccount, error, ); this.flushEnableListeners(options); diff --git a/packages/extension/src/client/Aztec/__tests__/ApiManager.spec.js b/packages/extension/src/client/Aztec/__tests__/ApiManager.spec.js index d2c61109b..3180bcc63 100644 --- a/packages/extension/src/client/Aztec/__tests__/ApiManager.spec.js +++ b/packages/extension/src/client/Aztec/__tests__/ApiManager.spec.js @@ -2,6 +2,7 @@ import asyncForEach from '~/utils/asyncForEach'; import Web3Service from '~/client/services/Web3Service'; import ConnectionService from '~/client/services/ConnectionService'; import ApiPermissionService from '~/client/services/ApiPermissionService'; +import Account from '~/client/apis/Account'; import ApiManager from '../ApiManager'; jest.spyOn(ConnectionService, 'init') @@ -119,10 +120,17 @@ describe('ApiManager.handleResolveSession', () => { aztecAccount, }); - expect(manager.aztecAccount).toBe(aztecAccount); + expect(manager.aztecAccount).toBeInstanceOf(Account); + expect(manager.aztecAccount.address).toBe(aztecAccount.address); expect(manager.error).toBe(null); expect(profileListener).toHaveBeenCalledTimes(1); - expect(profileListener).toHaveBeenLastCalledWith('aztecAccountChanged', aztecAccount, null); + expect(profileListener).toHaveBeenLastCalledWith( + 'aztecAccountChanged', + expect.objectContaining({ + address: aztecAccount.address, + }), + null, + ); expect(flushEnableListenersSpy).toHaveBeenCalledTimes(1); expect(flushEnableListenersSpy).toHaveBeenCalledWith(options); });