import { Callback , ErrorCallback , JSONRPCRequestPayload , Subprovider , SupportedProvider , ZeroExProvider , } from '@0x/subproviders' ; import { providerUtils } from '@0x/utils' ; import { utils } from './utils' ; export class SubproviderAdapter extends Subprovider { private readonly _provider : ZeroExProvider ; constructor ( provider ) { super ( ) ; this . _provider = providerUtils . standardizeOrThrow ( provider ) ; } public async handleRequest ( payload , _next , end ) { this . _provider . sendAsync ( payload , ( err , result ) => { ! utils . isNil ( result ) && ! utils . isNil ( result ! . result ) ? end ( null , result ! . result ) : end ( err || new Error ( result ! . error ?. message ) ) ; } ) ; } }