diff options
author | fragosti <francesco.agosti93@gmail.com> | 2018-10-26 05:37:34 +0800 |
---|---|---|
committer | fragosti <francesco.agosti93@gmail.com> | 2018-10-26 05:37:34 +0800 |
commit | 23b165669202c1bdf4bd7d7e509b9bfe06e3ef8a (patch) | |
tree | 28391ad5e06b532075e1d93ce4fa381d96e2f12e /packages/instant/src/components | |
parent | d06b40bd8a938557ebba993afa78d20493ad71ef (diff) | |
download | dexon-sol-tools-23b165669202c1bdf4bd7d7e509b9bfe06e3ef8a.tar.gz dexon-sol-tools-23b165669202c1bdf4bd7d7e509b9bfe06e3ef8a.tar.zst dexon-sol-tools-23b165669202c1bdf4bd7d7e509b9bfe06e3ef8a.zip |
feat: support defaultAssetBuyAmount setting
Diffstat (limited to 'packages/instant/src/components')
-rw-r--r-- | packages/instant/src/components/zero_ex_instant.tsx | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/packages/instant/src/components/zero_ex_instant.tsx b/packages/instant/src/components/zero_ex_instant.tsx index 63d944654..9018c9427 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, SignedOrder } from '@0x/types'; +import { BigNumber } from '@0x/utils'; import * as _ from 'lodash'; import * as React from 'react'; import { Provider } from 'react-redux'; @@ -28,6 +29,7 @@ export interface ZeroExInstantRequiredProps { } export interface ZeroExInstantOptionalProps { + defaultAssetBuyAmount?: number; additionalAssetMetaDataMap: ObjectMap<AssetMetaData>; network: Network; } @@ -35,12 +37,7 @@ export interface ZeroExInstantOptionalProps { export class ZeroExInstant extends React.Component<ZeroExInstantProps> { private readonly _store: Store; private static _mergeInitialStateWithProps(props: ZeroExInstantProps, state: State = INITIAL_STATE): State { - // Create merged object such that properties in props override default settings - const optionalPropsWithDefaults: ZeroExInstantOptionalProps = { - additionalAssetMetaDataMap: props.additionalAssetMetaDataMap || {}, - network: props.network || state.network, - }; - const { network } = optionalPropsWithDefaults; + const network = props.network || state.network; // TODO: Provider needs to not be hard-coded to injected web3. const provider = getProvider(); const assetBuyerOptions = { @@ -65,6 +62,9 @@ export class ZeroExInstant extends React.Component<ZeroExInstantProps> { assetBuyer, network, selectedAsset: assetUtils.createAssetFromAssetData(props.assetData, completeAssetMetaDataMap, network), + selectedAssetAmount: _.isUndefined(props.defaultAssetBuyAmount) + ? state.selectedAssetAmount + : new BigNumber(props.defaultAssetBuyAmount), assetMetaDataMap: completeAssetMetaDataMap, }; return storeStateFromProps; |