diff options
author | fragosti <francesco.agosti93@gmail.com> | 2018-10-26 02:43:53 +0800 |
---|---|---|
committer | fragosti <francesco.agosti93@gmail.com> | 2018-10-26 02:43:53 +0800 |
commit | 2a1c2a55eda0f3d279aa1145b6157892d03001ae (patch) | |
tree | 812b5eb19248c021e8e1f9231e52f884a4683803 /packages/instant/src/components | |
parent | 46a8aad87a978567026881d8c1db998ac14eab4e (diff) | |
download | dexon-0x-contracts-2a1c2a55eda0f3d279aa1145b6157892d03001ae.tar dexon-0x-contracts-2a1c2a55eda0f3d279aa1145b6157892d03001ae.tar.gz dexon-0x-contracts-2a1c2a55eda0f3d279aa1145b6157892d03001ae.tar.bz2 dexon-0x-contracts-2a1c2a55eda0f3d279aa1145b6157892d03001ae.tar.lz dexon-0x-contracts-2a1c2a55eda0f3d279aa1145b6157892d03001ae.tar.xz dexon-0x-contracts-2a1c2a55eda0f3d279aa1145b6157892d03001ae.tar.zst dexon-0x-contracts-2a1c2a55eda0f3d279aa1145b6157892d03001ae.zip |
feat: supply render options from URL
Diffstat (limited to 'packages/instant/src/components')
-rw-r--r-- | packages/instant/src/components/zero_ex_instant.tsx | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/packages/instant/src/components/zero_ex_instant.tsx b/packages/instant/src/components/zero_ex_instant.tsx index ffa5a8250..0fe494726 100644 --- a/packages/instant/src/components/zero_ex_instant.tsx +++ b/packages/instant/src/components/zero_ex_instant.tsx @@ -1,5 +1,6 @@ import { AssetBuyer } from '@0x/asset-buyer'; -import { ObjectMap } from '@0x/types'; +import { ObjectMap, SignedOrder } from '@0x/types'; +import * as _ from 'lodash'; import * as React from 'react'; import { Provider } from 'react-redux'; @@ -21,8 +22,7 @@ export type ZeroExInstantProps = ZeroExInstantRequiredProps & Partial<ZeroExInst export interface ZeroExInstantRequiredProps { // TODO: Change API when we allow the selection of different assetDatas assetData: string; - // TODO: Allow for a function that returns orders - liquiditySource: string; + liquiditySource: string | SignedOrder[]; } export interface ZeroExInstantOptionalProps { @@ -40,9 +40,20 @@ export class ZeroExInstant extends React.Component<ZeroExInstantProps> { }; const { network } = optionalPropsWithDefaults; // TODO: Provider needs to not be hard-coded to injected web3. - const assetBuyer = AssetBuyer.getAssetBuyerForStandardRelayerAPIUrl(getProvider(), props.liquiditySource, { + const provider = getProvider(); + const assetBuyerOptions = { networkId: network, - }); + }; + let assetBuyer; + if (_.isString(props.liquiditySource)) { + assetBuyer = AssetBuyer.getAssetBuyerForStandardRelayerAPIUrl( + provider, + props.liquiditySource, + assetBuyerOptions, + ); + } else { + assetBuyer = AssetBuyer.getAssetBuyerForProvidedOrders(provider, props.liquiditySource, assetBuyerOptions); + } const completeAssetMetaDataMap = { ...props.additionalAssetMetaDataMap, ...state.assetMetaDataMap, |