diff --git a/helpers/__tests__/services.test.ts b/helpers/__tests__/services.test.ts index 6c0862a3..7970519f 100644 --- a/helpers/__tests__/services.test.ts +++ b/helpers/__tests__/services.test.ts @@ -46,7 +46,7 @@ describe('services helpers: filterUniqueServices', () => { const serviceList = [serviceA, serviceB, serviceC, serviceD] const expectedList = [serviceA, serviceB, serviceC] const filteredList = filterUniqueServices({ address: true, uid: false })( - serviceList + serviceList, ) expect(filteredList).toEqual(expectedList) @@ -91,7 +91,7 @@ describe('services helpers: filterUniqueServices', () => { const serviceList = [serviceA, serviceB, serviceC, serviceD] const expectedList = [serviceA, serviceB, serviceC] const filteredList = filterUniqueServices({ address: true, uid: true })( - serviceList + serviceList, ) expect(filteredList).toEqual(expectedList) @@ -131,10 +131,10 @@ describe('services helpers: combineServices', () => { const expectedListTwo = [serviceC, serviceA, serviceB] expect(combineServices(serviceListOne, serviceListTwo)).toEqual( - expectedListOne + expectedListOne, ) expect(combineServices(serviceListOne, serviceListTwo, true)).toEqual( - expectedListTwo + expectedListTwo, ) }) }) @@ -202,10 +202,10 @@ describe('services helpers: filterOptInServices', () => { const expectedResponseB = [serviceA, serviceB, serviceC] const walletsA = serviceListA.map(x => - injectedServiceToWallet(x as Service) + injectedServiceToWallet(x as Service), ) const walletsB = serviceListB.map(x => - injectedServiceToWallet(x as Service) + injectedServiceToWallet(x as Service), ) const filterOptInServicesA = filterOptInServices({ @@ -263,10 +263,11 @@ describe('services helpers: filterServicesByPlatform', () => { services: [x], })) const services = extractWalletServices(wallets as any) + const extensions = [] const expectedRes = [serviceA, serviceB, serviceC] - expect(filterServicesByPlatform({ wallets, platform })(services)).toEqual( - expectedRes - ) + expect( + filterServicesByPlatform({ wallets, platform, extensions })(services), + ).toEqual(expectedRes) }) }) diff --git a/helpers/services.js b/helpers/services.js index 614c1549..0a3ccdda 100644 --- a/helpers/services.js +++ b/helpers/services.js @@ -70,10 +70,13 @@ export const requiresPlatform = service => { return requiredPlatformTypes.includes(service?.method) } -export const filterServicesByPlatform = ({ wallets, platform }) => +export const filterServicesByPlatform = ({ wallets, platform, extensions }) => filter(service => { if (!requiresPlatform(service)) return true + // If extension is installed, ignore platform requirements + if (isExtensionInstalled(extensions, service)) return true + const wallet = wallets?.find(w => w.uid === service.walletUid) if (!wallet.installLink) return true diff --git a/helpers/wallet-pipes.ts b/helpers/wallet-pipes.ts index 3de79929..15284879 100644 --- a/helpers/wallet-pipes.ts +++ b/helpers/wallet-pipes.ts @@ -102,7 +102,7 @@ export const getWalletPipes = ({ // Filter out extensions if not supported because they were added on the FCL side in previous versions ifElse( always(areUninstalledExtensionsSupported), - filterServicesByPlatform({ wallets, platform }), + filterServicesByPlatform({ wallets, platform, extensions }), reject(isExtension), ), ) as any, @@ -137,7 +137,7 @@ export const getWalletPipes = ({ ifElse( always(includeUninstalledServices), pipe( - filterServicesByPlatform({ wallets, platform }), + filterServicesByPlatform({ wallets, platform, extensions }), appendInstallData({ wallets, platform, extensions }), ), filterUninstalledServices({ extensions }),