Remove networkId from orderJSON

This commit is contained in:
Leonid Logvinov
2018-02-07 20:38:30 +01:00
parent 69f5f5e946
commit e6f2c7a382
7 changed files with 3 additions and 20 deletions

View File

@@ -109,7 +109,6 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
<FillOrderJSON <FillOrderJSON
blockchain={this.props.blockchain} blockchain={this.props.blockchain}
tokenByAddress={this.props.tokenByAddress} tokenByAddress={this.props.tokenByAddress}
networkId={this.props.networkId}
orderJSON={this.state.orderJSON} orderJSON={this.state.orderJSON}
onFillOrderJSONChanged={this._onFillOrderJSONChanged.bind(this)} onFillOrderJSONChanged={this._onFillOrderJSONChanged.bind(this)}
/> />
@@ -136,7 +135,6 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
<FillOrderJSON <FillOrderJSON
blockchain={this.props.blockchain} blockchain={this.props.blockchain}
tokenByAddress={this.props.tokenByAddress} tokenByAddress={this.props.tokenByAddress}
networkId={this.props.networkId}
orderJSON={this.state.orderJSON} orderJSON={this.state.orderJSON}
onFillOrderJSONChanged={this._onFillOrderJSONChanged.bind(this)} onFillOrderJSONChanged={this._onFillOrderJSONChanged.bind(this)}
/> />
@@ -444,12 +442,8 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
const signature = parsedOrder.signedOrder.ecSignature; const signature = parsedOrder.signedOrder.ecSignature;
const isValidSignature = ZeroEx.isValidSignature(signature.hash, signature, parsedOrder.signedOrder.maker); const isValidSignature = ZeroEx.isValidSignature(signature.hash, signature, parsedOrder.signedOrder.maker);
if (this.props.networkId !== parsedOrder.metadata.networkId) { if (exchangeContractAddr !== parsedOrder.signedOrder.exchangeContractAddress) {
orderJSONErrMsg = `This order was made on another Ethereum network orderJSONErrMsg = 'This order was made on another network or using a deprecated Exchange contract';
(id: ${parsedOrder.metadata.networkId}). Connect to this network to fill.`;
parsedOrder = undefined;
} else if (exchangeContractAddr !== parsedOrder.signedOrder.exchangeContractAddress) {
orderJSONErrMsg = 'This order was made using a deprecated 0x Exchange contract.';
parsedOrder = undefined; parsedOrder = undefined;
} else if (orderHash !== signature.hash) { } else if (orderHash !== signature.hash) {
orderJSONErrMsg = 'Order hash does not match supplied plaintext values'; orderJSONErrMsg = 'Order hash does not match supplied plaintext values';

View File

@@ -12,7 +12,6 @@ import { utils } from 'ts/utils/utils';
interface FillOrderJSONProps { interface FillOrderJSONProps {
blockchain: Blockchain; blockchain: Blockchain;
tokenByAddress: TokenByAddress; tokenByAddress: TokenByAddress;
networkId: number;
orderJSON: string; orderJSON: string;
onFillOrderJSONChanged: (event: any) => void; onFillOrderJSONChanged: (event: any) => void;
} }
@@ -43,7 +42,6 @@ export class FillOrderJSON extends React.Component<FillOrderJSONProps, FillOrder
const hintSalt = ZeroEx.generatePseudoRandomSalt(); const hintSalt = ZeroEx.generatePseudoRandomSalt();
const feeRecipient = constants.NULL_ADDRESS; const feeRecipient = constants.NULL_ADDRESS;
const hintOrder = utils.generateOrder( const hintOrder = utils.generateOrder(
this.props.networkId,
exchangeContract, exchangeContract,
hintSideToAssetToken, hintSideToAssetToken,
hintOrderExpiryTimestamp, hintOrderExpiryTimestamp,

View File

@@ -216,7 +216,6 @@ export class GenerateOrderForm extends React.Component<GenerateOrderFormProps, G
orderMakerFee={this.props.hashData.makerFee} orderMakerFee={this.props.hashData.makerFee}
orderTakerFee={this.props.hashData.takerFee} orderTakerFee={this.props.hashData.takerFee}
orderFeeRecipient={this.props.hashData.feeRecipientAddress} orderFeeRecipient={this.props.hashData.feeRecipientAddress}
networkId={this.props.networkId}
sideToAssetToken={this.props.sideToAssetToken} sideToAssetToken={this.props.sideToAssetToken}
tokenByAddress={this.props.tokenByAddress} tokenByAddress={this.props.tokenByAddress}
/> />
@@ -329,7 +328,6 @@ export class GenerateOrderForm extends React.Component<GenerateOrderFormProps, G
try { try {
const signatureData = await this.props.blockchain.signOrderHashAsync(orderHash); const signatureData = await this.props.blockchain.signOrderHashAsync(orderHash);
const order = utils.generateOrder( const order = utils.generateOrder(
this.props.networkId,
exchangeContractAddr, exchangeContractAddr,
this.props.sideToAssetToken, this.props.sideToAssetToken,
hashData.orderExpiryTimestamp, hashData.orderExpiryTimestamp,

View File

@@ -20,7 +20,6 @@ interface OrderJSONProps {
orderMakerFee: BigNumber; orderMakerFee: BigNumber;
orderTakerFee: BigNumber; orderTakerFee: BigNumber;
orderFeeRecipient: string; orderFeeRecipient: string;
networkId: number;
sideToAssetToken: SideToAssetToken; sideToAssetToken: SideToAssetToken;
tokenByAddress: TokenByAddress; tokenByAddress: TokenByAddress;
} }
@@ -40,7 +39,6 @@ export class OrderJSON extends React.Component<OrderJSONProps, OrderJSONState> {
} }
public render() { public render() {
const order = utils.generateOrder( const order = utils.generateOrder(
this.props.networkId,
this.props.exchangeContractIfExists, this.props.exchangeContractIfExists,
this.props.sideToAssetToken, this.props.sideToAssetToken,
this.props.orderExpiryTimestamp, this.props.orderExpiryTimestamp,
@@ -162,7 +160,6 @@ You can see and fill it here: ${this.state.shareLink}`);
} }
private _getOrderUrl() { private _getOrderUrl() {
const order = utils.generateOrder( const order = utils.generateOrder(
this.props.networkId,
this.props.exchangeContractIfExists, this.props.exchangeContractIfExists,
this.props.sideToAssetToken, this.props.sideToAssetToken,
this.props.orderExpiryTimestamp, this.props.orderExpiryTimestamp,

View File

@@ -3,8 +3,7 @@ export const orderMetadataSchema = {
properties: { properties: {
makerToken: { $ref: '/Token' }, makerToken: { $ref: '/Token' },
takerToken: { $ref: '/Token' }, takerToken: { $ref: '/Token' },
networkId: { type: 'number' },
}, },
required: ['makerToken', 'takerToken', 'networkId'], required: ['makerToken', 'takerToken'],
type: 'object', type: 'object',
}; };

View File

@@ -76,7 +76,6 @@ export interface SignedOrder {
} }
export interface OrderMetadata { export interface OrderMetadata {
networkId: number;
makerToken: OrderToken; makerToken: OrderToken;
takerToken: OrderToken; takerToken: OrderToken;
} }

View File

@@ -59,7 +59,6 @@ export const utils = {
return formattedDate; return formattedDate;
}, },
generateOrder( generateOrder(
networkId: number,
exchangeContractAddress: string, exchangeContractAddress: string,
sideToAssetToken: SideToAssetToken, sideToAssetToken: SideToAssetToken,
expirationUnixTimestampSec: BigNumber, expirationUnixTimestampSec: BigNumber,
@@ -91,7 +90,6 @@ export const utils = {
exchangeContractAddress, exchangeContractAddress,
}, },
metadata: { metadata: {
networkId,
makerToken: { makerToken: {
name: makerToken.name, name: makerToken.name,
symbol: makerToken.symbol, symbol: makerToken.symbol,