diff --git a/packages/passport/sdk/src/Passport.int.test.ts b/packages/passport/sdk/src/Passport.int.test.ts index 0cb5a821fd..b7e915bf91 100644 --- a/packages/passport/sdk/src/Passport.int.test.ts +++ b/packages/passport/sdk/src/Passport.int.test.ts @@ -93,7 +93,6 @@ describe('Passport', () => { (Magic as jest.Mock).mockImplementation(() => ({ openid: { loginWithOIDC: mockLoginWithOidc }, rpcProvider: { request: mockMagicRequest }, - preload: jest.fn(), })); }); diff --git a/packages/passport/sdk/src/magicAdapter.test.ts b/packages/passport/sdk/src/magicAdapter.test.ts index 762f99621d..c8ec9502f7 100644 --- a/packages/passport/sdk/src/magicAdapter.test.ts +++ b/packages/passport/sdk/src/magicAdapter.test.ts @@ -4,7 +4,7 @@ import MagicAdapter from './magicAdapter'; import { PassportConfiguration } from './config'; import { PassportError, PassportErrorType } from './errors/passportError'; -const loginWithOIDCMock:jest.MockedFunction<(args: LoginWithOpenIdParams) => Promise> = jest.fn(); +const loginWithOIDCMock: jest.MockedFunction<(args: LoginWithOpenIdParams) => Promise> = jest.fn(); const rpcProvider = {}; @@ -23,7 +23,6 @@ describe('MagicWallet', () => { magicProviderId: providerId, } as PassportConfiguration; const idToken = 'e30=.e30=.e30='; - const preload = jest.fn(); beforeEach(() => { jest.resetAllMocks(); @@ -35,7 +34,6 @@ describe('MagicWallet', () => { logout: logoutMock, }, rpcProvider, - preload, })); }); @@ -56,7 +54,6 @@ describe('MagicWallet', () => { }); it('starts initialising the magicClient', () => { jest.spyOn(window.document, 'readyState', 'get').mockReturnValue('complete'); - preload.mockResolvedValue(Promise.resolve()); const magicAdapter = new MagicAdapter(config); // @ts-ignore expect(magicAdapter.lazyMagicClient).toBeDefined(); @@ -83,13 +80,13 @@ describe('MagicWallet', () => { describe('login', () => { it('should call loginWithOIDC and initialise the provider with the correct arguments', async () => { - preload.mockResolvedValue(Promise.resolve()); const magicAdapter = new MagicAdapter(config); const magicProvider = await magicAdapter.login(idToken); expect(Magic).toHaveBeenCalledWith(apiKey, { network: 'mainnet', extensions: [new OpenIdExtension()], + deferPreload: true, }); expect(loginWithOIDCMock).toHaveBeenCalledWith({ @@ -101,7 +98,6 @@ describe('MagicWallet', () => { }); it('should throw a PassportError when an error is thrown', async () => { - preload.mockResolvedValue(Promise.resolve()); const magicAdapter = new MagicAdapter(config); loginWithOIDCMock.mockImplementation(() => { @@ -121,7 +117,6 @@ describe('MagicWallet', () => { describe('logout', () => { it('calls the logout function', async () => { - preload.mockResolvedValue(Promise.resolve()); const magicAdapter = new MagicAdapter(config); await magicAdapter.login(idToken); await magicAdapter.logout(); diff --git a/packages/passport/sdk/src/magicAdapter.ts b/packages/passport/sdk/src/magicAdapter.ts index 7e0d512e0d..96ce80b32a 100644 --- a/packages/passport/sdk/src/magicAdapter.ts +++ b/packages/passport/sdk/src/magicAdapter.ts @@ -23,8 +23,8 @@ export default class MagicAdapter { const client = new Magic(this.config.magicPublishableApiKey, { extensions: [new OpenIdExtension()], network: MAINNET, // We always connect to mainnet to ensure addresses are the same across envs + deferPreload: true, }); - client.preload(); return client; }); }