aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/components
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-02-08 23:23:20 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-02-08 23:23:20 +0800
commit1233c33116a389f34ac90768c5ef43c8bbfbf514 (patch)
tree4dfee164683df09ea26c761a90938d773a954859 /packages/website/ts/components
parent8fba0477a69317c19b3446c76a17cb3adbf447d7 (diff)
downloaddexon-sol-tools-1233c33116a389f34ac90768c5ef43c8bbfbf514.tar
dexon-sol-tools-1233c33116a389f34ac90768c5ef43c8bbfbf514.tar.gz
dexon-sol-tools-1233c33116a389f34ac90768c5ef43c8bbfbf514.tar.bz2
dexon-sol-tools-1233c33116a389f34ac90768c5ef43c8bbfbf514.tar.lz
dexon-sol-tools-1233c33116a389f34ac90768c5ef43c8bbfbf514.tar.xz
dexon-sol-tools-1233c33116a389f34ac90768c5ef43c8bbfbf514.tar.zst
dexon-sol-tools-1233c33116a389f34ac90768c5ef43c8bbfbf514.zip
Address feedback
Diffstat (limited to 'packages/website/ts/components')
-rw-r--r--packages/website/ts/components/fill_order.tsx71
-rw-r--r--packages/website/ts/components/generate_order/generate_order_form.tsx17
-rw-r--r--packages/website/ts/components/portal.tsx3
-rw-r--r--packages/website/ts/components/visual_order.tsx2
4 files changed, 43 insertions, 50 deletions
diff --git a/packages/website/ts/components/fill_order.tsx b/packages/website/ts/components/fill_order.tsx
index 4252747ec..2582581b1 100644
--- a/packages/website/ts/components/fill_order.tsx
+++ b/packages/website/ts/components/fill_order.tsx
@@ -19,7 +19,7 @@ import { Identicon } from 'ts/components/ui/identicon';
import { VisualOrder } from 'ts/components/visual_order';
import { Dispatcher } from 'ts/redux/dispatcher';
import { orderSchema } from 'ts/schemas/order_schema';
-import { SchemaValidator } from 'ts/schemas/validator';
+import { validator } from 'ts/schemas/validator';
import { AlertTypes, BlockchainErrs, Order, Token, TokenByAddress, WebsitePaths } from 'ts/types';
import { colors } from 'ts/utils/colors';
import { constants } from 'ts/utils/constants';
@@ -59,7 +59,6 @@ interface FillOrderState {
}
export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
- private _validator: SchemaValidator;
private _isUnmounted: boolean;
constructor(props: FillOrderProps) {
super(props);
@@ -82,7 +81,6 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
isConfirmingTokenTracking: false,
tokensToTrack: [],
};
- this._validator = new SchemaValidator();
}
public componentWillMount() {
if (!_.isEmpty(this.state.orderJSON)) {
@@ -199,9 +197,6 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
amount: this.props.orderFillAmount,
symbol: takerToken.symbol,
};
- const orderTaker = !_.isEmpty(this.state.parsedOrder.signedOrder.taker)
- ? this.state.parsedOrder.signedOrder.taker
- : this.props.userAddress;
const parsedOrderExpiration = new BigNumber(this.state.parsedOrder.signedOrder.expirationUnixTimestampSec);
const exchangeRate = orderMakerAmount.div(orderTakerAmount);
@@ -236,8 +231,6 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
<div className="lg-px4 md-px4 sm-px0">
<div className="lg-px4 md-px4 sm-px1 pt1">
<VisualOrder
- orderTakerAddress={orderTaker}
- orderMakerAddress={this.state.parsedOrder.signedOrder.maker}
makerAssetToken={makerAssetToken}
takerAssetToken={takerAssetToken}
tokenByAddress={this.props.tokenByAddress}
@@ -407,7 +400,7 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
let orderHash: string;
try {
const order = JSON.parse(orderJSON);
- const validationResult = this._validator.validate(order, orderSchema);
+ const validationResult = validator.validate(order, orderSchema);
if (validationResult.errors.length > 0) {
orderJSONErrMsg = 'Submitted order JSON is not a valid order';
utils.consoleLog(`Unexpected order JSON validation error: ${validationResult.errors.join(', ')}`);
@@ -415,7 +408,6 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
}
parsedOrder = order;
- const exchangeContractAddr = this.props.blockchain.getExchangeContractAddressIfExists();
const makerAmount = new BigNumber(parsedOrder.signedOrder.makerTokenAmount);
const takerAmount = new BigNumber(parsedOrder.signedOrder.takerTokenAmount);
const expiration = new BigNumber(parsedOrder.signedOrder.expirationUnixTimestampSec);
@@ -441,6 +433,7 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
};
orderHash = ZeroEx.getOrderHashHex(zeroExOrder);
+ const exchangeContractAddr = this.props.blockchain.getExchangeContractAddressIfExists();
const signature = parsedOrder.signedOrder.ecSignature;
const isValidSignature = ZeroEx.isValidSignature(orderHash, signature, parsedOrder.signedOrder.maker);
if (exchangeContractAddr !== parsedOrder.signedOrder.exchangeContractAddress) {
@@ -525,20 +518,21 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
globalErrMsg = 'You must specify a fill amount';
}
- const signedOrder = this.props.blockchain.portalOrderToSignedOrder(
- parsedOrder.signedOrder.maker,
- parsedOrder.signedOrder.taker,
- parsedOrder.signedOrder.makerTokenAddress,
- parsedOrder.signedOrder.takerTokenAddress,
- new BigNumber(parsedOrder.signedOrder.makerTokenAmount),
- new BigNumber(parsedOrder.signedOrder.takerTokenAmount),
- new BigNumber(parsedOrder.signedOrder.makerFee),
- new BigNumber(parsedOrder.signedOrder.takerFee),
- new BigNumber(this.state.parsedOrder.signedOrder.expirationUnixTimestampSec),
- parsedOrder.signedOrder.feeRecipient,
- parsedOrder.signedOrder.ecSignature,
- new BigNumber(parsedOrder.signedOrder.salt),
- );
+ const signedOrder = {
+ exchangeContractAddress: this.props.blockchain.getExchangeContractAddressIfExists(),
+ maker: parsedOrder.signedOrder.maker,
+ taker: _.isEmpty(parsedOrder.signedOrder.taker) ? constants.NULL_ADDRESS : parsedOrder.signedOrder.taker,
+ makerTokenAddress: parsedOrder.signedOrder.makerTokenAddress,
+ takerTokenAddress: parsedOrder.signedOrder.takerTokenAddress,
+ makerTokenAmount: new BigNumber(parsedOrder.signedOrder.makerTokenAmount),
+ takerTokenAmount: new BigNumber(parsedOrder.signedOrder.takerTokenAmount),
+ makerFee: new BigNumber(parsedOrder.signedOrder.makerFee),
+ takerFee: new BigNumber(parsedOrder.signedOrder.takerFee),
+ expirationUnixTimestampSec: new BigNumber(this.state.parsedOrder.signedOrder.expirationUnixTimestampSec),
+ feeRecipient: parsedOrder.signedOrder.feeRecipient,
+ ecSignature: parsedOrder.signedOrder.ecSignature,
+ salt: new BigNumber(parsedOrder.signedOrder.salt),
+ };
if (_.isEmpty(globalErrMsg)) {
try {
await this.props.blockchain.validateFillOrderThrowIfInvalidAsync(
@@ -627,20 +621,21 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
const takerTokenAmount = new BigNumber(parsedOrder.signedOrder.takerTokenAmount);
- const signedOrder = this.props.blockchain.portalOrderToSignedOrder(
- parsedOrder.signedOrder.maker,
- parsedOrder.signedOrder.taker,
- parsedOrder.signedOrder.makerTokenAddress,
- parsedOrder.signedOrder.takerTokenAddress,
- new BigNumber(parsedOrder.signedOrder.makerTokenAmount),
- takerTokenAmount,
- new BigNumber(parsedOrder.signedOrder.makerFee),
- new BigNumber(parsedOrder.signedOrder.takerFee),
- new BigNumber(this.state.parsedOrder.signedOrder.expirationUnixTimestampSec),
- parsedOrder.signedOrder.feeRecipient,
- parsedOrder.signedOrder.ecSignature,
- new BigNumber(parsedOrder.signedOrder.salt),
- );
+ const signedOrder = {
+ exchangeContractAddress: this.props.blockchain.getExchangeContractAddressIfExists(),
+ maker: parsedOrder.signedOrder.maker,
+ taker: parsedOrder.signedOrder.taker,
+ makerTokenAddress: parsedOrder.signedOrder.makerTokenAddress,
+ takerTokenAddress: parsedOrder.signedOrder.takerTokenAddress,
+ makerTokenAmount: new BigNumber(parsedOrder.signedOrder.makerTokenAmount),
+ takerTokenAmount: new BigNumber(parsedOrder.signedOrder.takerTokenAmount),
+ makerFee: new BigNumber(parsedOrder.signedOrder.makerFee),
+ takerFee: new BigNumber(parsedOrder.signedOrder.takerFee),
+ expirationUnixTimestampSec: new BigNumber(this.state.parsedOrder.signedOrder.expirationUnixTimestampSec),
+ feeRecipient: parsedOrder.signedOrder.feeRecipient,
+ ecSignature: parsedOrder.signedOrder.ecSignature,
+ salt: new BigNumber(parsedOrder.signedOrder.salt),
+ };
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
const unavailableTakerAmount = await this.props.blockchain.getUnavailableTakerAmountAsync(orderHash);
const availableTakerTokenAmount = takerTokenAmount.minus(unavailableTakerAmount);
diff --git a/packages/website/ts/components/generate_order/generate_order_form.tsx b/packages/website/ts/components/generate_order/generate_order_form.tsx
index 5f1cf3c8e..fcabd4844 100644
--- a/packages/website/ts/components/generate_order/generate_order_form.tsx
+++ b/packages/website/ts/components/generate_order/generate_order_form.tsx
@@ -18,7 +18,7 @@ import { LifeCycleRaisedButton } from 'ts/components/ui/lifecycle_raised_button'
import { SwapIcon } from 'ts/components/ui/swap_icon';
import { Dispatcher } from 'ts/redux/dispatcher';
import { orderSchema } from 'ts/schemas/order_schema';
-import { SchemaValidator } from 'ts/schemas/validator';
+import { validator } from 'ts/schemas/validator';
import { AlertTypes, BlockchainErrs, HashData, Side, SideToAssetToken, Token, TokenByAddress } from 'ts/types';
import { colors } from 'ts/utils/colors';
import { constants } from 'ts/utils/constants';
@@ -55,7 +55,6 @@ interface GenerateOrderFormState {
}
export class GenerateOrderForm extends React.Component<GenerateOrderFormProps, GenerateOrderFormState> {
- private _validator: SchemaValidator;
constructor(props: GenerateOrderFormProps) {
super(props);
this.state = {
@@ -63,7 +62,6 @@ export class GenerateOrderForm extends React.Component<GenerateOrderFormProps, G
shouldShowIncompleteErrs: false,
signingState: SigningState.UNSIGNED,
};
- this._validator = new SchemaValidator();
}
public componentDidMount() {
window.scrollTo(0, 0);
@@ -79,6 +77,8 @@ export class GenerateOrderForm extends React.Component<GenerateOrderFormProps, G
allowed to fill this order. If no taker is<br> \
specified, anyone is able to fill it.';
const exchangeContractIfExists = this.props.blockchain.getExchangeContractAddressIfExists();
+ const initialTakerAddress =
+ this.props.orderTakerAddress === ZeroEx.NULL_ADDRESS ? '' : this.props.orderTakerAddress;
return (
<div className="clearfix mb2 lg-px4 md-px4 sm-px2">
<h3>Generate an order</h3>
@@ -159,7 +159,7 @@ export class GenerateOrderForm extends React.Component<GenerateOrderFormProps, G
<div className="pt1 flex mx-auto">
<IdenticonAddressInput
label="Taker"
- initialAddress={this.props.orderTakerAddress}
+ initialAddress={initialTakerAddress}
updateOrderAddress={this._updateOrderAddress.bind(this)}
/>
<div className="pt3">
@@ -317,7 +317,7 @@ export class GenerateOrderForm extends React.Component<GenerateOrderFormProps, G
let globalErrMsg = '';
try {
- const signatureData = await this.props.blockchain.signOrderHashAsync(orderHash);
+ const ecSignature = await this.props.blockchain.signOrderHashAsync(orderHash);
const order = utils.generateOrder(
exchangeContractAddr,
this.props.sideToAssetToken,
@@ -327,11 +327,11 @@ export class GenerateOrderForm extends React.Component<GenerateOrderFormProps, G
hashData.makerFee,
hashData.takerFee,
hashData.feeRecipientAddress,
- signatureData,
+ ecSignature,
this.props.tokenByAddress,
hashData.orderSalt,
);
- const validationResult = this._validator.validate(order, orderSchema);
+ const validationResult = validator.validate(order, orderSchema);
if (validationResult.errors.length > 0) {
globalErrMsg = 'Order signing failed. Please refresh and try again';
utils.consoleLog(`Unexpected error occured: Order validation failed:
@@ -356,7 +356,8 @@ export class GenerateOrderForm extends React.Component<GenerateOrderFormProps, G
}
private _updateOrderAddress(address?: string): void {
if (!_.isUndefined(address)) {
- this.props.dispatcher.updateOrderTakerAddress(address);
+ const normalizedAddress = _.isEmpty(address) ? ZeroEx.NULL_ADDRESS : address;
+ this.props.dispatcher.updateOrderTakerAddress(normalizedAddress);
}
}
}
diff --git a/packages/website/ts/components/portal.tsx b/packages/website/ts/components/portal.tsx
index 92589f75c..0d4fb8fdc 100644
--- a/packages/website/ts/components/portal.tsx
+++ b/packages/website/ts/components/portal.tsx
@@ -22,7 +22,7 @@ import { GenerateOrderForm } from 'ts/containers/generate_order_form';
import { localStorage } from 'ts/local_storage/local_storage';
import { Dispatcher } from 'ts/redux/dispatcher';
import { orderSchema } from 'ts/schemas/order_schema';
-import { SchemaValidator } from 'ts/schemas/validator';
+import { validator } from 'ts/schemas/validator';
import { BlockchainErrs, HashData, Order, ProviderType, ScreenWidths, TokenByAddress, WebsitePaths } from 'ts/types';
import { colors } from 'ts/utils/colors';
import { configs } from 'ts/utils/configs';
@@ -367,7 +367,6 @@ export class Portal extends React.Component<PortalAllProps, PortalAllState> {
return undefined;
}
- const validator = new SchemaValidator();
const order = JSON.parse(decodeURIComponent(orderPair[1]));
const validationResult = validator.validate(order, orderSchema);
if (validationResult.errors.length > 0) {
diff --git a/packages/website/ts/components/visual_order.tsx b/packages/website/ts/components/visual_order.tsx
index 092954086..ec2d47f39 100644
--- a/packages/website/ts/components/visual_order.tsx
+++ b/packages/website/ts/components/visual_order.tsx
@@ -8,8 +8,6 @@ import { utils } from 'ts/utils/utils';
const PRECISION = 5;
interface VisualOrderProps {
- orderTakerAddress: string;
- orderMakerAddress: string;
makerAssetToken: AssetToken;
takerAssetToken: AssetToken;
makerToken: Token;