aboutsummaryrefslogblamecommitdiffstats
path: root/packages/instant/src/util/asset_buyer_factory.ts
blob: 5ba46223c66562b9ac3d6555326f5818a3b01543 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
















                                                                                                        
import { AssetBuyer, AssetBuyerOpts } from '@0x/asset-buyer';
import { Provider } from 'ethereum-types';
import * as _ from 'lodash';

import { Network, OrderSource } from '../types';

export const assetBuyerFactory = {
    getAssetBuyer: (provider: Provider, orderSource: OrderSource, network: Network): AssetBuyer => {
        const assetBuyerOptions: Partial<AssetBuyerOpts> = {
            networkId: network,
        };
        const assetBuyer = _.isString(orderSource)
            ? AssetBuyer.getAssetBuyerForStandardRelayerAPIUrl(provider, orderSource, assetBuyerOptions)
            : AssetBuyer.getAssetBuyerForProvidedOrders(provider, orderSource, assetBuyerOptions);
        return assetBuyer;
    },
};