aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-02-08 03:58:19 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-02-08 03:58:19 +0800
commit8fba0477a69317c19b3446c76a17cb3adbf447d7 (patch)
tree7c0cc8f53f1c9e7fe7f5f6d3d1f7b8249edbdaa7 /packages
parente6f2c7a382e2e7e940f430f350240cb2f703bdcd (diff)
downloaddexon-0x-contracts-8fba0477a69317c19b3446c76a17cb3adbf447d7.tar.gz
dexon-0x-contracts-8fba0477a69317c19b3446c76a17cb3adbf447d7.tar.zst
dexon-0x-contracts-8fba0477a69317c19b3446c76a17cb3adbf447d7.zip
Remove hash from signatureData
Diffstat (limited to 'packages')
-rw-r--r--packages/website/ts/blockchain.ts13
-rw-r--r--packages/website/ts/components/fill_order.tsx11
-rw-r--r--packages/website/ts/components/fill_order_json.tsx5
-rw-r--r--packages/website/ts/components/generate_order/generate_order_form.tsx17
-rw-r--r--packages/website/ts/components/order_json.tsx9
-rw-r--r--packages/website/ts/containers/generate_order_form.tsx5
-rw-r--r--packages/website/ts/redux/dispatcher.ts8
-rw-r--r--packages/website/ts/redux/reducer.ts11
-rw-r--r--packages/website/ts/schemas/signature_data_schema.ts3
-rw-r--r--packages/website/ts/types.ts4
-rw-r--r--packages/website/ts/utils/utils.ts4
11 files changed, 37 insertions, 53 deletions
diff --git a/packages/website/ts/blockchain.ts b/packages/website/ts/blockchain.ts
index 099efb405..697ff4f10 100644
--- a/packages/website/ts/blockchain.ts
+++ b/packages/website/ts/blockchain.ts
@@ -2,6 +2,7 @@ import {
BlockParam,
BlockRange,
DecodedLogEvent,
+ ECSignature,
ExchangeContractEventArgs,
ExchangeEvents,
IndexedFilterValues,
@@ -299,10 +300,9 @@ export class Blockchain {
takerFee: BigNumber,
expirationUnixTimestampSec: BigNumber,
feeRecipient: string,
- signatureData: SignatureData,
+ ecSignature: ECSignature,
salt: BigNumber,
): SignedOrder {
- const ecSignature = signatureData;
const exchangeContractAddress = this.getExchangeContractAddressIfExists();
const takerOrNullAddress = _.isEmpty(taker) ? constants.NULL_ADDRESS : taker;
const signedOrder = {
@@ -413,7 +413,7 @@ export class Blockchain {
return newTokenBalancePromise;
}
- public async signOrderHashAsync(orderHash: string): Promise<SignatureData> {
+ public async signOrderHashAsync(orderHash: string): Promise<ECSignature> {
utils.assert(!_.isUndefined(this._zeroEx), 'ZeroEx must be instantiated.');
const makerAddress = this._userAddress;
// If makerAddress is undefined, this means they have a web3 instance injected into their browser
@@ -436,11 +436,8 @@ export class Blockchain {
makerAddress,
shouldAddPersonalMessagePrefix,
);
- const signatureData = _.extend({}, ecSignature, {
- hash: orderHash,
- });
- this._dispatcher.updateSignatureData(signatureData);
- return signatureData;
+ this._dispatcher.updateECSignature(ecSignature);
+ return ecSignature;
}
public async mintTestTokensAsync(token: Token) {
utils.assert(this._doesUserAddressExist(), BlockchainCallErrs.UserHasNoAssociatedAddresses);
diff --git a/packages/website/ts/components/fill_order.tsx b/packages/website/ts/components/fill_order.tsx
index d2c36ff0c..4252747ec 100644
--- a/packages/website/ts/components/fill_order.tsx
+++ b/packages/website/ts/components/fill_order.tsx
@@ -404,6 +404,7 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
private async _validateFillOrderFireAndForgetAsync(orderJSON: string) {
let orderJSONErrMsg = '';
let parsedOrder: Order;
+ let orderHash: string;
try {
const order = JSON.parse(orderJSON);
const validationResult = this._validator.validate(order, orderSchema);
@@ -438,16 +439,13 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
takerTokenAddress: parsedOrder.signedOrder.takerTokenAddress,
takerTokenAmount: takerAmount,
};
- const orderHash = ZeroEx.getOrderHashHex(zeroExOrder);
+ orderHash = ZeroEx.getOrderHashHex(zeroExOrder);
const signature = parsedOrder.signedOrder.ecSignature;
- const isValidSignature = ZeroEx.isValidSignature(signature.hash, signature, parsedOrder.signedOrder.maker);
+ const isValidSignature = ZeroEx.isValidSignature(orderHash, signature, parsedOrder.signedOrder.maker);
if (exchangeContractAddr !== parsedOrder.signedOrder.exchangeContractAddress) {
orderJSONErrMsg = 'This order was made on another network or using a deprecated Exchange contract';
parsedOrder = undefined;
- } else if (orderHash !== signature.hash) {
- orderJSONErrMsg = 'Order hash does not match supplied plaintext values';
- parsedOrder = undefined;
} else if (!isValidSignature) {
orderJSONErrMsg = 'Order signature is invalid';
parsedOrder = undefined;
@@ -477,7 +475,6 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
// Clear cache entry if user updates orderJSON to invalid entry
this.props.dispatcher.updateUserSuppliedOrderCache(undefined);
} else {
- const orderHash = parsedOrder.signedOrder.ecSignature.hash;
unavailableTakerAmount = await this.props.blockchain.getUnavailableTakerAmountAsync(orderHash);
const isMakerTokenAddressInRegistry = await this.props.blockchain.isAddressInTokenRegistryAsync(
parsedOrder.signedOrder.makerTokenAddress,
@@ -617,7 +614,6 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
});
const parsedOrder = this.state.parsedOrder;
- const orderHash = parsedOrder.signedOrder.ecSignature.hash;
const takerAddress = this.props.userAddress;
if (_.isUndefined(takerAddress)) {
@@ -645,6 +641,7 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
parsedOrder.signedOrder.ecSignature,
new BigNumber(parsedOrder.signedOrder.salt),
);
+ const orderHash = ZeroEx.getOrderHashHex(signedOrder);
const unavailableTakerAmount = await this.props.blockchain.getUnavailableTakerAmountAsync(orderHash);
const availableTakerTokenAmount = takerTokenAmount.minus(unavailableTakerAmount);
try {
diff --git a/packages/website/ts/components/fill_order_json.tsx b/packages/website/ts/components/fill_order_json.tsx
index 877b65116..7d5351ec4 100644
--- a/packages/website/ts/components/fill_order_json.tsx
+++ b/packages/website/ts/components/fill_order_json.tsx
@@ -33,8 +33,7 @@ export class FillOrderJSON extends React.Component<FillOrderJSONProps, FillOrder
},
};
const hintOrderExpiryTimestamp = utils.initialOrderExpiryUnixTimestampSec();
- const hintSignatureData = {
- hash: '0xf965a9978a0381ab58f5a2408ad967c...',
+ const hintECSignature = {
r: '0xf01103f759e2289a28593eaf22e5820032...',
s: '937862111edcba395f8a9e0cc1b2c5e12320...',
v: 27,
@@ -50,7 +49,7 @@ export class FillOrderJSON extends React.Component<FillOrderJSONProps, FillOrder
constants.MAKER_FEE,
constants.TAKER_FEE,
feeRecipient,
- hintSignatureData,
+ hintECSignature,
this.props.tokenByAddress,
hintSalt,
);
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 6fe0fa4f3..5f1cf3c8e 100644
--- a/packages/website/ts/components/generate_order/generate_order_form.tsx
+++ b/packages/website/ts/components/generate_order/generate_order_form.tsx
@@ -1,4 +1,4 @@
-import { Order, ZeroEx } from '0x.js';
+import { ECSignature, Order, ZeroEx } from '0x.js';
import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash';
import Dialog from 'material-ui/Dialog';
@@ -19,16 +19,7 @@ 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 {
- AlertTypes,
- BlockchainErrs,
- HashData,
- Side,
- SideToAssetToken,
- SignatureData,
- Token,
- TokenByAddress,
-} from 'ts/types';
+import { AlertTypes, BlockchainErrs, HashData, Side, SideToAssetToken, Token, TokenByAddress } from 'ts/types';
import { colors } from 'ts/utils/colors';
import { constants } from 'ts/utils/constants';
import { errorReporter } from 'ts/utils/error_reporter';
@@ -49,7 +40,7 @@ interface GenerateOrderFormProps {
orderExpiryTimestamp: BigNumber;
networkId: number;
userAddress: string;
- orderSignatureData: SignatureData;
+ orderECSignature: ECSignature;
orderTakerAddress: string;
orderSalt: BigNumber;
sideToAssetToken: SideToAssetToken;
@@ -209,7 +200,7 @@ export class GenerateOrderForm extends React.Component<GenerateOrderFormProps, G
<OrderJSON
exchangeContractIfExists={exchangeContractIfExists}
orderExpiryTimestamp={this.props.orderExpiryTimestamp}
- orderSignatureData={this.props.orderSignatureData}
+ orderECSignature={this.props.orderECSignature}
orderTakerAddress={this.props.orderTakerAddress}
orderMakerAddress={this.props.userAddress}
orderSalt={this.props.orderSalt}
diff --git a/packages/website/ts/components/order_json.tsx b/packages/website/ts/components/order_json.tsx
index a908f2895..a5dd9ebc1 100644
--- a/packages/website/ts/components/order_json.tsx
+++ b/packages/website/ts/components/order_json.tsx
@@ -1,10 +1,11 @@
+import { ECSignature } from '0x.js';
import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash';
import Paper from 'material-ui/Paper';
import TextField from 'material-ui/TextField';
import * as React from 'react';
import { CopyIcon } from 'ts/components/ui/copy_icon';
-import { SideToAssetToken, SignatureData, TokenByAddress, WebsitePaths } from 'ts/types';
+import { SideToAssetToken, TokenByAddress, WebsitePaths } from 'ts/types';
import { configs } from 'ts/utils/configs';
import { constants } from 'ts/utils/constants';
import { errorReporter } from 'ts/utils/error_reporter';
@@ -13,7 +14,7 @@ import { utils } from 'ts/utils/utils';
interface OrderJSONProps {
exchangeContractIfExists: string;
orderExpiryTimestamp: BigNumber;
- orderSignatureData: SignatureData;
+ orderECSignature: ECSignature;
orderTakerAddress: string;
orderMakerAddress: string;
orderSalt: BigNumber;
@@ -47,7 +48,7 @@ export class OrderJSON extends React.Component<OrderJSONProps, OrderJSONState> {
this.props.orderMakerFee,
this.props.orderTakerFee,
this.props.orderFeeRecipient,
- this.props.orderSignatureData,
+ this.props.orderECSignature,
this.props.tokenByAddress,
this.props.orderSalt,
);
@@ -168,7 +169,7 @@ You can see and fill it here: ${this.state.shareLink}`);
this.props.orderMakerFee,
this.props.orderTakerFee,
this.props.orderFeeRecipient,
- this.props.orderSignatureData,
+ this.props.orderECSignature,
this.props.tokenByAddress,
this.props.orderSalt,
);
diff --git a/packages/website/ts/containers/generate_order_form.tsx b/packages/website/ts/containers/generate_order_form.tsx
index 57863dbae..2cdb7b810 100644
--- a/packages/website/ts/containers/generate_order_form.tsx
+++ b/packages/website/ts/containers/generate_order_form.tsx
@@ -1,3 +1,4 @@
+import { ECSignature } from '0x.js';
import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash';
import * as React from 'react';
@@ -18,7 +19,7 @@ interface ConnectedState {
blockchainErr: BlockchainErrs;
blockchainIsLoaded: boolean;
orderExpiryTimestamp: BigNumber;
- orderSignatureData: SignatureData;
+ orderECSignature: ECSignature;
userAddress: string;
orderTakerAddress: string;
orderSalt: BigNumber;
@@ -32,7 +33,7 @@ const mapStateToProps = (state: State, ownProps: GenerateOrderFormProps): Connec
blockchainErr: state.blockchainErr,
blockchainIsLoaded: state.blockchainIsLoaded,
orderExpiryTimestamp: state.orderExpiryTimestamp,
- orderSignatureData: state.orderSignatureData,
+ orderECSignature: state.orderECSignature,
orderTakerAddress: state.orderTakerAddress,
orderSalt: state.orderSalt,
networkId: state.networkId,
diff --git a/packages/website/ts/redux/dispatcher.ts b/packages/website/ts/redux/dispatcher.ts
index 87415b285..925f2aa29 100644
--- a/packages/website/ts/redux/dispatcher.ts
+++ b/packages/website/ts/redux/dispatcher.ts
@@ -1,3 +1,4 @@
+import { ECSignature } from '0x.js';
import { BigNumber } from '@0xproject/utils';
import { Dispatch } from 'redux';
import { State } from 'ts/redux/reducer';
@@ -10,7 +11,6 @@ import {
ScreenWidths,
Side,
SideToAssetToken,
- SignatureData,
Token,
TokenByAddress,
} from 'ts/types';
@@ -148,10 +148,10 @@ export class Dispatcher {
type: ActionTypes.ForceTokenStateRefetch,
});
}
- public updateSignatureData(signatureData: SignatureData) {
+ public updateECSignature(ecSignature: ECSignature) {
this._dispatch({
- data: signatureData,
- type: ActionTypes.UpdateOrderSignatureData,
+ data: ecSignature,
+ type: ActionTypes.UpdateOrderECSignature,
});
}
public updateUserEtherBalance(balance: BigNumber) {
diff --git a/packages/website/ts/redux/reducer.ts b/packages/website/ts/redux/reducer.ts
index 7b0b03dae..cab8cbfe6 100644
--- a/packages/website/ts/redux/reducer.ts
+++ b/packages/website/ts/redux/reducer.ts
@@ -1,4 +1,4 @@
-import { ZeroEx } from '0x.js';
+import { ECSignature, ZeroEx } from '0x.js';
import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash';
import * as moment from 'moment';
@@ -29,7 +29,7 @@ export interface State {
orderExpiryTimestamp: BigNumber;
orderFillAmount: BigNumber;
orderTakerAddress: string;
- orderSignatureData: SignatureData;
+ orderECSignature: ECSignature;
orderSalt: BigNumber;
nodeVersion: string;
screenWidth: ScreenWidths;
@@ -59,8 +59,7 @@ const INITIAL_STATE: State = {
networkId: undefined,
orderExpiryTimestamp: utils.initialOrderExpiryUnixTimestampSec(),
orderFillAmount: undefined,
- orderSignatureData: {
- hash: '',
+ orderECSignature: {
r: '',
s: '',
v: 27,
@@ -188,10 +187,10 @@ export function reducer(state: State = INITIAL_STATE, action: Action) {
lastForceTokenStateRefetch: moment().unix(),
};
- case ActionTypes.UpdateOrderSignatureData: {
+ case ActionTypes.UpdateOrderECSignature: {
return {
...state,
- orderSignatureData: action.data,
+ orderECSignature: action.data,
};
}
diff --git a/packages/website/ts/schemas/signature_data_schema.ts b/packages/website/ts/schemas/signature_data_schema.ts
index 8d3f15926..7852abfef 100644
--- a/packages/website/ts/schemas/signature_data_schema.ts
+++ b/packages/website/ts/schemas/signature_data_schema.ts
@@ -1,11 +1,10 @@
export const signatureDataSchema = {
id: '/SignatureData',
properties: {
- hash: { type: 'string' },
r: { type: 'string' },
s: { type: 'string' },
v: { type: 'number' },
},
- required: ['hash', 'r', 's', 'v'],
+ required: ['r', 's', 'v'],
type: 'object',
};
diff --git a/packages/website/ts/types.ts b/packages/website/ts/types.ts
index a628ebec1..2b255f523 100644
--- a/packages/website/ts/types.ts
+++ b/packages/website/ts/types.ts
@@ -71,7 +71,7 @@ export interface SignedOrder {
expirationUnixTimestampSec: string;
feeRecipient: string;
salt: string;
- ecSignature: SignatureData;
+ ecSignature: ECSignature;
exchangeContractAddress: string;
}
@@ -123,7 +123,7 @@ export enum ActionTypes {
UpdateChosenAssetTokenAddress = 'UPDATE_CHOSEN_ASSET_TOKEN_ADDRESS',
UpdateOrderTakerAddress = 'UPDATE_ORDER_TAKER_ADDRESS',
UpdateOrderSalt = 'UPDATE_ORDER_SALT',
- UpdateOrderSignatureData = 'UPDATE_ORDER_SIGNATURE_DATA',
+ UpdateOrderECSignature = 'UPDATE_ORDER_EC_SIGNATURE',
UpdateTokenByAddress = 'UPDATE_TOKEN_BY_ADDRESS',
RemoveTokenFromTokenByAddress = 'REMOVE_TOKEN_FROM_TOKEN_BY_ADDRESS',
ForceTokenStateRefetch = 'FORCE_TOKEN_STATE_REFETCH',
diff --git a/packages/website/ts/utils/utils.ts b/packages/website/ts/utils/utils.ts
index eaff5c658..bf6b70f84 100644
--- a/packages/website/ts/utils/utils.ts
+++ b/packages/website/ts/utils/utils.ts
@@ -1,4 +1,4 @@
-import { ExchangeContractErrs, ZeroExError } from '0x.js';
+import { ECSignature, ExchangeContractErrs, ZeroExError } from '0x.js';
import { BigNumber } from '@0xproject/utils';
import deepEqual = require('deep-equal');
import isMobile = require('is-mobile');
@@ -67,7 +67,7 @@ export const utils = {
makerFee: BigNumber,
takerFee: BigNumber,
feeRecipient: string,
- ecSignature: SignatureData,
+ ecSignature: ECSignature,
tokenByAddress: TokenByAddress,
orderSalt: BigNumber,
): Order {