diff --git a/packages/cardano-services-client/src/HttpProvider.ts b/packages/cardano-services-client/src/HttpProvider.ts index 0d239525b77..76ee5b18e5f 100644 --- a/packages/cardano-services-client/src/HttpProvider.ts +++ b/packages/cardano-services-client/src/HttpProvider.ts @@ -78,11 +78,9 @@ export const createHttpProvider = ({ new Proxy({} as T, { // eslint-disable-next-line sonarjs/cognitive-complexity get(_, prop) { - if (prop === 'then') return; const method = prop as keyof T; const urlPath = paths[method]; - if (!urlPath) - throw new ProviderError(ProviderFailure.NotImplemented, `HttpProvider missing path for '${prop.toString()}'`); + if (!urlPath) return; return async (...args: any[]) => { try { const req: AxiosRequestConfig = { @@ -123,5 +121,9 @@ export const createHttpProvider = ({ throw new ProviderError(ProviderFailure.Unknown, error); } }; + }, + + has(_, prop) { + return prop in paths; } }); diff --git a/packages/cardano-services-client/test/HttpProvider.test.ts b/packages/cardano-services-client/test/HttpProvider.test.ts index 656a7f89b3b..12f992895b5 100644 --- a/packages/cardano-services-client/test/HttpProvider.test.ts +++ b/packages/cardano-services-client/test/HttpProvider.test.ts @@ -63,10 +63,16 @@ describe('createHttpProvider', () => { if (closeServer) await closeServer(); }); - it('attempting to access unimplemented method throws ProviderError', async () => { + it('attempting to access unimplemented method returns undefined', async () => { const provider = createTxSubmitProviderClient(); + expect('doesNotExist' in provider).toBe(false); // eslint-disable-next-line @typescript-eslint/no-explicit-any - expect(() => (provider as any).doesNotExist).toThrowError(ProviderError); + expect((provider as any).doesNotExist).toBeUndefined(); + }); + + it('"in" operator for implemented property returns true', async () => { + const provider = createTxSubmitProviderClient(); + expect('healthCheck' in provider).toBe(true); }); it('passes through axios options, merging custom header with the included provider version headers', async () => {