diff options
Diffstat (limited to 'packages/website/ts/components')
-rw-r--r-- | packages/website/ts/components/fill_order.tsx | 26 | ||||
-rw-r--r-- | packages/website/ts/components/generate_order/generate_order_form.tsx | 7 | ||||
-rw-r--r-- | packages/website/ts/components/portal/portal.tsx | 2 |
3 files changed, 11 insertions, 24 deletions
diff --git a/packages/website/ts/components/fill_order.tsx b/packages/website/ts/components/fill_order.tsx index 60eccff34..f24d065f4 100644 --- a/packages/website/ts/components/fill_order.tsx +++ b/packages/website/ts/components/fill_order.tsx @@ -26,6 +26,7 @@ import { AlertTypes, BlockchainErrs, PortalOrder, Token, TokenByAddress, Website import { analytics } from 'ts/utils/analytics'; import { constants } from 'ts/utils/constants'; import { errorReporter } from 'ts/utils/error_reporter'; +import { orderParser } from 'ts/utils/order_parser'; import { utils } from 'ts/utils/utils'; interface FillOrderProps { @@ -418,7 +419,7 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> { let parsedOrder: PortalOrder; let orderHash: string; try { - const order = JSON.parse(orderJSON); + const order = orderParser.parseJsonString(orderJSON); const validationResult = validator.validate(order, portalOrderSchema); if (validationResult.errors.length > 0) { orderJSONErrMsg = 'Submitted order JSON is not a valid order'; @@ -427,28 +428,12 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> { } parsedOrder = order; const signedOrder = parsedOrder.signedOrder; - const zeroExOrder: ZeroExOrder = { - exchangeAddress: signedOrder.exchangeAddress, - expirationTimeSeconds: signedOrder.expirationTimeSeconds, - feeRecipientAddress: signedOrder.feeRecipientAddress, - makerAddress: signedOrder.makerAddress, - makerFee: signedOrder.makerFee, - makerAssetData: signedOrder.makerAssetData, - makerAssetAmount: signedOrder.makerAssetAmount, - salt: signedOrder.salt, - takerAddress: _.isEmpty(signedOrder.takerAddress) ? constants.NULL_ADDRESS : signedOrder.takerAddress, - takerFee: signedOrder.takerFee, - takerAssetData: signedOrder.takerAssetData, - takerAssetAmount: signedOrder.takerAssetAmount, - senderAddress: signedOrder.senderAddress, - }; - orderHash = orderHashUtils.getOrderHashHex(zeroExOrder); + orderHash = orderHashUtils.getOrderHashHex(signedOrder); const exchangeContractAddr = this.props.blockchain.getExchangeContractAddressIfExists(); const signature = signedOrder.signature; - const ecSignature = signatureUtils.parseECSignature(signature); - const isSignatureValid = signatureUtils.isValidECSignature( + const isSignatureValid = await this.props.blockchain.isValidSignatureAsync( orderHash, - ecSignature, + signature, signedOrder.makerAddress, ); if (exchangeContractAddr !== signedOrder.exchangeAddress) { @@ -500,6 +485,7 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> { }); } + console.log(parsedOrder); this.setState({ didOrderValidationRun: true, orderJSON, 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 9eb50f3d7..bb6265170 100644 --- a/packages/website/ts/components/generate_order/generate_order_form.tsx +++ b/packages/website/ts/components/generate_order/generate_order_form.tsx @@ -331,7 +331,7 @@ export class GenerateOrderForm extends React.Component<GenerateOrderFormProps, G salt: hashData.orderSalt, takerAddress: hashData.orderTakerAddress, takerFee: hashData.takerFee, - takerAssetData: hashData.receiveTokenContractAddr, + takerAssetData, takerAssetAmount: hashData.receiveAmount, }; const orderHash = orderHashUtils.getOrderHashHex(zeroExOrder); @@ -339,7 +339,7 @@ export class GenerateOrderForm extends React.Component<GenerateOrderFormProps, G let globalErrMsg = ''; let order; try { - const ecSignature = await this.props.blockchain.signOrderHashAsync(orderHash); + const signature = await this.props.blockchain.signOrderHashAsync(orderHash); order = utils.generateOrder( exchangeAddress, this.props.sideToAssetToken, @@ -349,10 +349,11 @@ export class GenerateOrderForm extends React.Component<GenerateOrderFormProps, G hashData.makerFee, hashData.takerFee, hashData.feeRecipientAddress, - ecSignature, + signature, this.props.tokenByAddress, hashData.orderSalt, ); + console.log(order); const validationResult = validator.validate(order, portalOrderSchema); if (validationResult.errors.length > 0) { globalErrMsg = 'Order signing failed. Please refresh and try again'; diff --git a/packages/website/ts/components/portal/portal.tsx b/packages/website/ts/components/portal/portal.tsx index 047464e03..b8d7ceea9 100644 --- a/packages/website/ts/components/portal/portal.tsx +++ b/packages/website/ts/components/portal/portal.tsx @@ -118,7 +118,7 @@ export class Portal extends React.Component<PortalProps, PortalState> { private readonly _throttledScreenWidthUpdate: () => void; constructor(props: PortalProps) { super(props); - this._sharedOrderIfExists = orderParser.parse(window.location.search); + this._sharedOrderIfExists = orderParser.parseQueryString(window.location.search); this._throttledScreenWidthUpdate = _.throttle(this._updateScreenWidth.bind(this), THROTTLE_TIMEOUT); const didAcceptPortalDisclaimer = localStorage.getItemIfExists(constants.LOCAL_STORAGE_KEY_ACCEPT_DISCLAIMER); const hasAcceptedDisclaimer = |