Make naming of schemas consistent
This commit is contained in:
@@ -18,7 +18,7 @@ import { EthereumAddress } from 'ts/components/ui/ethereum_address';
|
||||
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 { portalOrderSchema } from 'ts/schemas/portal_order_schema';
|
||||
import { validator } from 'ts/schemas/validator';
|
||||
import { AlertTypes, BlockchainErrs, Order, Token, TokenByAddress, WebsitePaths } from 'ts/types';
|
||||
import { colors } from 'ts/utils/colors';
|
||||
@@ -400,7 +400,7 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
|
||||
let orderHash: string;
|
||||
try {
|
||||
const order = JSON.parse(orderJSON);
|
||||
const validationResult = validator.validate(order, orderSchema);
|
||||
const validationResult = validator.validate(order, portalOrderSchema);
|
||||
if (validationResult.errors.length > 0) {
|
||||
orderJSONErrMsg = 'Submitted order JSON is not a valid order';
|
||||
utils.consoleLog(`Unexpected order JSON validation error: ${validationResult.errors.join(', ')}`);
|
||||
|
||||
@@ -17,7 +17,7 @@ import { HelpTooltip } from 'ts/components/ui/help_tooltip';
|
||||
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 { portalOrderSchema } from 'ts/schemas/portal_order_schema';
|
||||
import { validator } from 'ts/schemas/validator';
|
||||
import { AlertTypes, BlockchainErrs, HashData, Side, SideToAssetToken, Token, TokenByAddress } from 'ts/types';
|
||||
import { colors } from 'ts/utils/colors';
|
||||
@@ -331,7 +331,7 @@ export class GenerateOrderForm extends React.Component<GenerateOrderFormProps, G
|
||||
this.props.tokenByAddress,
|
||||
hashData.orderSalt,
|
||||
);
|
||||
const validationResult = validator.validate(order, orderSchema);
|
||||
const validationResult = validator.validate(order, portalOrderSchema);
|
||||
if (validationResult.errors.length > 0) {
|
||||
globalErrMsg = 'Order signing failed. Please refresh and try again';
|
||||
utils.consoleLog(`Unexpected error occured: Order validation failed:
|
||||
|
||||
@@ -21,7 +21,7 @@ import { FlashMessage } from 'ts/components/ui/flash_message';
|
||||
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 { portalOrderSchema } from 'ts/schemas/portal_order_schema';
|
||||
import { validator } from 'ts/schemas/validator';
|
||||
import { BlockchainErrs, HashData, Order, ProviderType, ScreenWidths, TokenByAddress, WebsitePaths } from 'ts/types';
|
||||
import { colors } from 'ts/utils/colors';
|
||||
@@ -368,7 +368,7 @@ export class Portal extends React.Component<PortalAllProps, PortalAllState> {
|
||||
}
|
||||
|
||||
const order = JSON.parse(decodeURIComponent(orderPair[1]));
|
||||
const validationResult = validator.validate(order, orderSchema);
|
||||
const validationResult = validator.validate(order, portalOrderSchema);
|
||||
if (validationResult.errors.length > 0) {
|
||||
utils.consoleLog(`Invalid shared order: ${validationResult.errors}`);
|
||||
return undefined;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export const orderSchema = {
|
||||
export const portalOrderSchema = {
|
||||
id: '/PortalOrder',
|
||||
properties: {
|
||||
signedOrder: { $ref: '/SignedOrder' },
|
||||
@@ -1,4 +1,4 @@
|
||||
export const tokenSchema = {
|
||||
export const portalTokenMetadataSchema = {
|
||||
id: '/PortalTokenMetadata',
|
||||
properties: {
|
||||
name: { type: 'string' },
|
||||
@@ -1,12 +1,12 @@
|
||||
import { SchemaValidator } from '@0xproject/json-schemas';
|
||||
import { Schema as JSONSchema, Validator } from 'jsonschema';
|
||||
import { orderMetadataSchema } from 'ts/schemas/metadata_schema';
|
||||
import { orderSchema } from 'ts/schemas/order_schema';
|
||||
import { tokenSchema } from 'ts/schemas/token_schema';
|
||||
import { portalOrderSchema } from 'ts/schemas/portal_order_schema';
|
||||
import { portalTokenMetadataSchema } from 'ts/schemas/portal_token_metadata';
|
||||
|
||||
const validator = new SchemaValidator();
|
||||
validator.addSchema(tokenSchema);
|
||||
validator.addSchema(portalTokenMetadataSchema);
|
||||
validator.addSchema(orderMetadataSchema);
|
||||
validator.addSchema(orderSchema);
|
||||
validator.addSchema(portalOrderSchema);
|
||||
|
||||
export { validator };
|
||||
|
||||
Reference in New Issue
Block a user