From ec198343b551020cfed321937d680af59c2ce127 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Thu, 8 Feb 2018 18:07:38 +0100 Subject: Make naming of schemas consistent --- packages/website/ts/components/fill_order.tsx | 4 ++-- .../ts/components/generate_order/generate_order_form.tsx | 4 ++-- packages/website/ts/components/portal.tsx | 4 ++-- packages/website/ts/schemas/order_schema.ts | 9 --------- packages/website/ts/schemas/portal_order_schema.ts | 9 +++++++++ packages/website/ts/schemas/portal_token_metadata.ts | 10 ++++++++++ packages/website/ts/schemas/token_schema.ts | 10 ---------- packages/website/ts/schemas/validator.ts | 8 ++++---- 8 files changed, 29 insertions(+), 29 deletions(-) delete mode 100644 packages/website/ts/schemas/order_schema.ts create mode 100644 packages/website/ts/schemas/portal_order_schema.ts create mode 100644 packages/website/ts/schemas/portal_token_metadata.ts delete mode 100644 packages/website/ts/schemas/token_schema.ts (limited to 'packages/website') diff --git a/packages/website/ts/components/fill_order.tsx b/packages/website/ts/components/fill_order.tsx index 2582581b1..063c57688 100644 --- a/packages/website/ts/components/fill_order.tsx +++ b/packages/website/ts/components/fill_order.tsx @@ -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 { 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(', ')}`); 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 fcabd4844..a3f222784 100644 --- a/packages/website/ts/components/generate_order/generate_order_form.tsx +++ b/packages/website/ts/components/generate_order/generate_order_form.tsx @@ -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 0) { globalErrMsg = 'Order signing failed. Please refresh and try again'; utils.consoleLog(`Unexpected error occured: Order validation failed: diff --git a/packages/website/ts/components/portal.tsx b/packages/website/ts/components/portal.tsx index 0d4fb8fdc..0409f28c0 100644 --- a/packages/website/ts/components/portal.tsx +++ b/packages/website/ts/components/portal.tsx @@ -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 { } 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; diff --git a/packages/website/ts/schemas/order_schema.ts b/packages/website/ts/schemas/order_schema.ts deleted file mode 100644 index 4d427d8ce..000000000 --- a/packages/website/ts/schemas/order_schema.ts +++ /dev/null @@ -1,9 +0,0 @@ -export const orderSchema = { - id: '/PortalOrder', - properties: { - signedOrder: { $ref: '/SignedOrder' }, - metadata: { $ref: '/OrderMetadata' }, - }, - required: ['signedOrder', 'metadata'], - type: 'object', -}; diff --git a/packages/website/ts/schemas/portal_order_schema.ts b/packages/website/ts/schemas/portal_order_schema.ts new file mode 100644 index 000000000..ea8aeabc6 --- /dev/null +++ b/packages/website/ts/schemas/portal_order_schema.ts @@ -0,0 +1,9 @@ +export const portalOrderSchema = { + id: '/PortalOrder', + properties: { + signedOrder: { $ref: '/SignedOrder' }, + metadata: { $ref: '/OrderMetadata' }, + }, + required: ['signedOrder', 'metadata'], + type: 'object', +}; diff --git a/packages/website/ts/schemas/portal_token_metadata.ts b/packages/website/ts/schemas/portal_token_metadata.ts new file mode 100644 index 000000000..0455c2ac1 --- /dev/null +++ b/packages/website/ts/schemas/portal_token_metadata.ts @@ -0,0 +1,10 @@ +export const portalTokenMetadataSchema = { + id: '/PortalTokenMetadata', + properties: { + name: { type: 'string' }, + symbol: { type: 'string' }, + decimals: { type: 'number' }, + }, + required: ['name', 'symbol', 'decimals'], + type: 'object', +}; diff --git a/packages/website/ts/schemas/token_schema.ts b/packages/website/ts/schemas/token_schema.ts deleted file mode 100644 index 4d1febfee..000000000 --- a/packages/website/ts/schemas/token_schema.ts +++ /dev/null @@ -1,10 +0,0 @@ -export const tokenSchema = { - id: '/PortalTokenMetadata', - properties: { - name: { type: 'string' }, - symbol: { type: 'string' }, - decimals: { type: 'number' }, - }, - required: ['name', 'symbol', 'decimals'], - type: 'object', -}; diff --git a/packages/website/ts/schemas/validator.ts b/packages/website/ts/schemas/validator.ts index f0b5e6676..dac0f0098 100644 --- a/packages/website/ts/schemas/validator.ts +++ b/packages/website/ts/schemas/validator.ts @@ -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 }; -- cgit