diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-02-08 23:23:20 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-02-08 23:23:20 +0800 |
commit | 1233c33116a389f34ac90768c5ef43c8bbfbf514 (patch) | |
tree | 4dfee164683df09ea26c761a90938d773a954859 /packages/website/ts/schemas | |
parent | 8fba0477a69317c19b3446c76a17cb3adbf447d7 (diff) | |
download | dexon-sol-tools-1233c33116a389f34ac90768c5ef43c8bbfbf514.tar dexon-sol-tools-1233c33116a389f34ac90768c5ef43c8bbfbf514.tar.gz dexon-sol-tools-1233c33116a389f34ac90768c5ef43c8bbfbf514.tar.bz2 dexon-sol-tools-1233c33116a389f34ac90768c5ef43c8bbfbf514.tar.lz dexon-sol-tools-1233c33116a389f34ac90768c5ef43c8bbfbf514.tar.xz dexon-sol-tools-1233c33116a389f34ac90768c5ef43c8bbfbf514.tar.zst dexon-sol-tools-1233c33116a389f34ac90768c5ef43c8bbfbf514.zip |
Address feedback
Diffstat (limited to 'packages/website/ts/schemas')
-rw-r--r-- | packages/website/ts/schemas/metadata_schema.ts | 4 | ||||
-rw-r--r-- | packages/website/ts/schemas/order_schema.ts | 2 | ||||
-rw-r--r-- | packages/website/ts/schemas/signature_data_schema.ts | 10 | ||||
-rw-r--r-- | packages/website/ts/schemas/signed_order_schema.ts | 34 | ||||
-rw-r--r-- | packages/website/ts/schemas/token_schema.ts | 2 | ||||
-rw-r--r-- | packages/website/ts/schemas/validator.ts | 23 |
6 files changed, 11 insertions, 64 deletions
diff --git a/packages/website/ts/schemas/metadata_schema.ts b/packages/website/ts/schemas/metadata_schema.ts index ff3bea13a..cd4045d10 100644 --- a/packages/website/ts/schemas/metadata_schema.ts +++ b/packages/website/ts/schemas/metadata_schema.ts @@ -1,8 +1,8 @@ export const orderMetadataSchema = { id: '/OrderMetadata', properties: { - makerToken: { $ref: '/Token' }, - takerToken: { $ref: '/Token' }, + makerToken: { $ref: '/PortalTokenMetadata' }, + takerToken: { $ref: '/PortalTokenMetadata' }, }, required: ['makerToken', 'takerToken'], type: 'object', diff --git a/packages/website/ts/schemas/order_schema.ts b/packages/website/ts/schemas/order_schema.ts index 0c5a6d425..4d427d8ce 100644 --- a/packages/website/ts/schemas/order_schema.ts +++ b/packages/website/ts/schemas/order_schema.ts @@ -1,5 +1,5 @@ export const orderSchema = { - id: '/Order', + id: '/PortalOrder', properties: { signedOrder: { $ref: '/SignedOrder' }, metadata: { $ref: '/OrderMetadata' }, diff --git a/packages/website/ts/schemas/signature_data_schema.ts b/packages/website/ts/schemas/signature_data_schema.ts deleted file mode 100644 index 7852abfef..000000000 --- a/packages/website/ts/schemas/signature_data_schema.ts +++ /dev/null @@ -1,10 +0,0 @@ -export const signatureDataSchema = { - id: '/SignatureData', - properties: { - r: { type: 'string' }, - s: { type: 'string' }, - v: { type: 'number' }, - }, - required: ['r', 's', 'v'], - type: 'object', -}; diff --git a/packages/website/ts/schemas/signed_order_schema.ts b/packages/website/ts/schemas/signed_order_schema.ts deleted file mode 100644 index 385008ab8..000000000 --- a/packages/website/ts/schemas/signed_order_schema.ts +++ /dev/null @@ -1,34 +0,0 @@ -export const signedOrderSchema = { - id: '/SignedOrder', - properties: { - maker: { type: 'string' }, - taker: { type: 'string' }, - makerTokenAddress: { type: 'string' }, - takerTokenAddress: { type: 'string' }, - makerFee: { type: 'string' }, - takerFee: { type: 'string' }, - makerTokenAmount: { type: 'string' }, - takerTokenAmount: { type: 'string' }, - salt: { type: 'string' }, - ecSignature: { $ref: '/SignatureData' }, - expirationUnixTimestampSec: { type: 'string' }, - feeRecipient: { type: 'string' }, - exchangeContractAddress: { type: 'string' }, - }, - required: [ - 'maker', - 'taker', - 'makerTokenAddress', - 'takerTokenAddress', - 'makerFee', - 'takerFee', - 'makerTokenAmount', - 'takerTokenAmount', - 'salt', - 'ecSignature', - 'expirationUnixTimestampSec', - 'feeRecipient', - 'exchangeContractAddress', - ], - type: 'object', -}; diff --git a/packages/website/ts/schemas/token_schema.ts b/packages/website/ts/schemas/token_schema.ts index 34cd6f676..4d1febfee 100644 --- a/packages/website/ts/schemas/token_schema.ts +++ b/packages/website/ts/schemas/token_schema.ts @@ -1,5 +1,5 @@ export const tokenSchema = { - id: '/Token', + id: '/PortalTokenMetadata', properties: { name: { type: 'string' }, symbol: { type: 'string' }, diff --git a/packages/website/ts/schemas/validator.ts b/packages/website/ts/schemas/validator.ts index 14061e2a3..f0b5e6676 100644 --- a/packages/website/ts/schemas/validator.ts +++ b/packages/website/ts/schemas/validator.ts @@ -1,21 +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 { signatureDataSchema } from 'ts/schemas/signature_data_schema'; -import { signedOrderSchema } from 'ts/schemas/signed_order_schema'; import { tokenSchema } from 'ts/schemas/token_schema'; -export class SchemaValidator { - private _validator: Validator; - constructor() { - this._validator = new Validator(); - this._validator.addSchema(signatureDataSchema as JSONSchema, signatureDataSchema.id); - this._validator.addSchema(tokenSchema as JSONSchema, tokenSchema.id); - this._validator.addSchema(orderMetadataSchema as JSONSchema, orderMetadataSchema.id); - this._validator.addSchema(signedOrderSchema as JSONSchema, signedOrderSchema.id); - this._validator.addSchema(orderSchema as JSONSchema, orderSchema.id); - } - public validate(instance: object, schema: Schema) { - return this._validator.validate(instance, schema); - } -} +const validator = new SchemaValidator(); +validator.addSchema(tokenSchema); +validator.addSchema(orderMetadataSchema); +validator.addSchema(orderSchema); + +export { validator }; |