aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-08-28 22:47:49 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-08-28 22:49:57 +0800
commit96da2c26dceca03340a213baae5a490df2f7183c (patch)
tree6c984b77c1cd5ca312310d7f72ad4b512ecb9df5 /src
parent0afc95982b195378653e15697f65d4ad3bf48e66 (diff)
downloaddexon-sol-tools-96da2c26dceca03340a213baae5a490df2f7183c.tar
dexon-sol-tools-96da2c26dceca03340a213baae5a490df2f7183c.tar.gz
dexon-sol-tools-96da2c26dceca03340a213baae5a490df2f7183c.tar.bz2
dexon-sol-tools-96da2c26dceca03340a213baae5a490df2f7183c.tar.lz
dexon-sol-tools-96da2c26dceca03340a213baae5a490df2f7183c.tar.xz
dexon-sol-tools-96da2c26dceca03340a213baae5a490df2f7183c.tar.zst
dexon-sol-tools-96da2c26dceca03340a213baae5a490df2f7183c.zip
Use 0x-json-schemas
Diffstat (limited to 'src')
-rw-r--r--src/0x.ts11
-rw-r--r--src/contract_wrappers/exchange_wrapper.ts43
-rw-r--r--src/contract_wrappers/token_wrapper.ts7
-rw-r--r--src/globals.d.ts49
-rw-r--r--src/schemas/basic_type_schemas.ts11
-rw-r--r--src/schemas/ec_signature_schema.ts20
-rw-r--r--src/schemas/index_filter_values_schema.ts11
-rw-r--r--src/schemas/order_cancel_schema.ts12
-rw-r--r--src/schemas/order_fill_or_kill_requests_schema.ts12
-rw-r--r--src/schemas/order_fill_requests_schema.ts12
-rw-r--r--src/schemas/order_hash_schema.ts5
-rw-r--r--src/schemas/order_schemas.ts39
-rw-r--r--src/schemas/signed_orders_schema.ts5
-rw-r--r--src/schemas/subscription_opts_schema.ts20
-rw-r--r--src/schemas/token_schema.ts11
-rw-r--r--src/utils/assert.ts2
-rw-r--r--src/utils/schema_validator.ts36
17 files changed, 26 insertions, 280 deletions
diff --git a/src/0x.ts b/src/0x.ts
index e7c10fb73..e8b6b77b0 100644
--- a/src/0x.ts
+++ b/src/0x.ts
@@ -1,5 +1,6 @@
import * as _ from 'lodash';
import * as BigNumber from 'bignumber.js';
+import {SchemaValidator, schemas} from '0x-json-schemas';
import {bigNumberConfigs} from './bignumber_config';
import * as ethUtil from 'ethereumjs-util';
import contract = require('truffle-contract');
@@ -13,13 +14,9 @@ import {assert} from './utils/assert';
import {ExchangeWrapper} from './contract_wrappers/exchange_wrapper';
import {TokenRegistryWrapper} from './contract_wrappers/token_registry_wrapper';
import {EtherTokenWrapper} from './contract_wrappers/ether_token_wrapper';
-import {ecSignatureSchema} from './schemas/ec_signature_schema';
import {TokenWrapper} from './contract_wrappers/token_wrapper';
import {TokenTransferProxyWrapper} from './contract_wrappers/token_transfer_proxy_wrapper';
import {ECSignature, ZeroExError, Order, SignedOrder, Web3Provider} from './types';
-import {orderHashSchema} from './schemas/order_hash_schema';
-import {orderSchema} from './schemas/order_schemas';
-import {SchemaValidator} from './utils/schema_validator';
// Customize our BigNumber instances
bigNumberConfigs.configure();
@@ -70,7 +67,7 @@ export class ZeroEx {
*/
public static isValidSignature(data: string, signature: ECSignature, signerAddress: string): boolean {
assert.isHexString('data', data);
- assert.doesConformToSchema('signature', signature, ecSignatureSchema);
+ assert.doesConformToSchema('signature', signature, schemas.ecSignatureSchema);
assert.isETHAddressHex('signerAddress', signerAddress);
const dataBuff = ethUtil.toBuffer(data);
@@ -113,7 +110,7 @@ export class ZeroEx {
// format, we only assert that we were indeed passed a string.
assert.isString('orderHash', orderHash);
const schemaValidator = new SchemaValidator();
- const isValidOrderHash = schemaValidator.validate(orderHash, orderHashSchema).valid;
+ const isValidOrderHash = schemaValidator.validate(orderHash, schemas.orderHashSchema).valid;
return isValidOrderHash;
}
/**
@@ -154,7 +151,7 @@ export class ZeroEx {
* @return The resulting orderHash from hashing the supplied order.
*/
public static getOrderHashHex(order: Order|SignedOrder): string {
- assert.doesConformToSchema('order', order, orderSchema);
+ assert.doesConformToSchema('order', order, schemas.orderSchema);
const orderHashHex = utils.getOrderHashHex(order);
return orderHashHex;
}
diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts
index 66cf06dee..a01940f4b 100644
--- a/src/contract_wrappers/exchange_wrapper.ts
+++ b/src/contract_wrappers/exchange_wrapper.ts
@@ -1,5 +1,6 @@
import * as _ from 'lodash';
import * as BigNumber from 'bignumber.js';
+import {SchemaValidator, schemas} from '0x-json-schemas';
import promisify = require('es6-promisify');
import {Web3Wrapper} from '../web3_wrapper';
import {
@@ -32,15 +33,6 @@ import {utils} from '../utils/utils';
import {eventUtils} from '../utils/event_utils';
import {OrderValidationUtils} from '../utils/order_validation_utils';
import {ContractWrapper} from './contract_wrapper';
-import {ecSignatureSchema} from '../schemas/ec_signature_schema';
-import {signedOrdersSchema} from '../schemas/signed_orders_schema';
-import {subscriptionOptsSchema} from '../schemas/subscription_opts_schema';
-import {indexFilterValuesSchema} from '../schemas/index_filter_values_schema';
-import {orderFillRequestsSchema} from '../schemas/order_fill_requests_schema';
-import {orderCancellationRequestsSchema} from '../schemas/order_cancel_schema';
-import {orderFillOrKillRequestsSchema} from '../schemas/order_fill_or_kill_requests_schema';
-import {orderHashSchema} from '../schemas/order_hash_schema';
-import {signedOrderSchema, orderSchema} from '../schemas/order_schemas';
import {constants} from '../utils/constants';
import {TokenWrapper} from './token_wrapper';
import {decorators} from '../utils/decorators';
@@ -96,7 +88,7 @@ export class ExchangeWrapper extends ContractWrapper {
* @return The amount of the order (in taker tokens) that has either been filled or canceled.
*/
public async getUnavailableTakerAmountAsync(orderHash: string): Promise<BigNumber.BigNumber> {
- assert.doesConformToSchema('orderHash', orderHash, orderHashSchema);
+ assert.doesConformToSchema('orderHash', orderHash, schemas.orderHashSchema);
const exchangeContract = await this._getExchangeContractAsync();
let unavailableTakerTokenAmount = await exchangeContract.getUnavailableTakerTokenAmount.call(orderHash);
@@ -110,7 +102,7 @@ export class ExchangeWrapper extends ContractWrapper {
* @return The amount of the order (in taker tokens) that has already been filled.
*/
public async getFilledTakerAmountAsync(orderHash: string): Promise<BigNumber.BigNumber> {
- assert.doesConformToSchema('orderHash', orderHash, orderHashSchema);
+ assert.doesConformToSchema('orderHash', orderHash, schemas.orderHashSchema);
const exchangeContract = await this._getExchangeContractAsync();
let fillAmountInBaseUnits = await exchangeContract.filled.call(orderHash);
@@ -125,7 +117,7 @@ export class ExchangeWrapper extends ContractWrapper {
* @return The amount of the order (in taker tokens) that has been cancelled.
*/
public async getCanceledTakerAmountAsync(orderHash: string): Promise<BigNumber.BigNumber> {
- assert.doesConformToSchema('orderHash', orderHash, orderHashSchema);
+ assert.doesConformToSchema('orderHash', orderHash, schemas.orderHashSchema);
const exchangeContract = await this._getExchangeContractAsync();
let cancelledAmountInBaseUnits = await exchangeContract.cancelled.call(orderHash);
@@ -155,7 +147,7 @@ export class ExchangeWrapper extends ContractWrapper {
public async fillOrderAsync(signedOrder: SignedOrder, fillTakerTokenAmount: BigNumber.BigNumber,
shouldThrowOnInsufficientBalanceOrAllowance: boolean,
takerAddress: string): Promise<BigNumber.BigNumber> {
- assert.doesConformToSchema('signedOrder', signedOrder, signedOrderSchema);
+ assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
assert.isBigNumber('fillTakerTokenAmount', fillTakerTokenAmount);
assert.isBoolean('shouldThrowOnInsufficientBalanceOrAllowance', shouldThrowOnInsufficientBalanceOrAllowance);
await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
@@ -215,7 +207,7 @@ export class ExchangeWrapper extends ContractWrapper {
public async fillOrdersUpToAsync(signedOrders: SignedOrder[], fillTakerTokenAmount: BigNumber.BigNumber,
shouldThrowOnInsufficientBalanceOrAllowance: boolean,
takerAddress: string): Promise<BigNumber.BigNumber> {
- assert.doesConformToSchema('signedOrders', signedOrders, signedOrdersSchema);
+ assert.doesConformToSchema('signedOrders', signedOrders, schemas.signedOrdersSchema);
const takerTokenAddresses = _.map(signedOrders, signedOrder => signedOrder.takerTokenAddress);
assert.hasAtMostOneUniqueValue(takerTokenAddresses,
ExchangeContractErrs.MultipleTakerTokensInFillUpToDisallowed);
@@ -301,7 +293,7 @@ export class ExchangeWrapper extends ContractWrapper {
public async batchFillOrdersAsync(orderFillRequests: OrderFillRequest[],
shouldThrowOnInsufficientBalanceOrAllowance: boolean,
takerAddress: string): Promise<void> {
- assert.doesConformToSchema('orderFillRequests', orderFillRequests, orderFillRequestsSchema);
+ assert.doesConformToSchema('orderFillRequests', orderFillRequests, schemas.orderFillRequestsSchema);
const exchangeContractAddresses = _.map(
orderFillRequests,
orderFillRequest => orderFillRequest.signedOrder.exchangeContractAddress,
@@ -372,7 +364,7 @@ export class ExchangeWrapper extends ContractWrapper {
@decorators.contractCallErrorHandler
public async fillOrKillOrderAsync(signedOrder: SignedOrder, fillTakerTokenAmount: BigNumber.BigNumber,
takerAddress: string): Promise<void> {
- assert.doesConformToSchema('signedOrder', signedOrder, signedOrderSchema);
+ assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
assert.isBigNumber('fillTakerTokenAmount', fillTakerTokenAmount);
await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
@@ -417,7 +409,8 @@ export class ExchangeWrapper extends ContractWrapper {
@decorators.contractCallErrorHandler
public async batchFillOrKillAsync(orderFillOrKillRequests: OrderFillOrKillRequest[],
takerAddress: string): Promise<void> {
- assert.doesConformToSchema('orderFillOrKillRequests', orderFillOrKillRequests, orderFillOrKillRequestsSchema);
+ assert.doesConformToSchema('orderFillOrKillRequests', orderFillOrKillRequests,
+ schemas.orderFillOrKillRequestsSchema);
const exchangeContractAddresses = _.map(
orderFillOrKillRequests,
orderFillOrKillRequest => orderFillOrKillRequest.signedOrder.exchangeContractAddress,
@@ -483,7 +476,7 @@ export class ExchangeWrapper extends ContractWrapper {
@decorators.contractCallErrorHandler
public async cancelOrderAsync(
order: Order|SignedOrder, cancelTakerTokenAmount: BigNumber.BigNumber): Promise<BigNumber.BigNumber> {
- assert.doesConformToSchema('order', order, orderSchema);
+ assert.doesConformToSchema('order', order, schemas.orderSchema);
assert.isBigNumber('takerTokenCancelAmount', cancelTakerTokenAmount);
await assert.isSenderAddressAsync('order.maker', order.maker, this._web3Wrapper);
@@ -522,7 +515,7 @@ export class ExchangeWrapper extends ContractWrapper {
@decorators.contractCallErrorHandler
public async batchCancelOrdersAsync(orderCancellationRequests: OrderCancellationRequest[]): Promise<void> {
assert.doesConformToSchema('orderCancellationRequests', orderCancellationRequests,
- orderCancellationRequestsSchema);
+ schemas.orderCancellationRequestsSchema);
const exchangeContractAddresses = _.map(
orderCancellationRequests,
orderCancellationRequest => orderCancellationRequest.order.exchangeContractAddress,
@@ -584,8 +577,8 @@ export class ExchangeWrapper extends ContractWrapper {
Promise<ContractEventEmitter> {
assert.isETHAddressHex('exchangeContractAddress', exchangeContractAddress);
assert.doesBelongToStringEnum('eventName', eventName, ExchangeEvents);
- assert.doesConformToSchema('subscriptionOpts', subscriptionOpts, subscriptionOptsSchema);
- assert.doesConformToSchema('indexFilterValues', indexFilterValues, indexFilterValuesSchema);
+ assert.doesConformToSchema('subscriptionOpts', subscriptionOpts, schemas.subscriptionOptsSchema);
+ assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
const exchangeContract = await this._getExchangeContractAsync();
let createLogEvent: CreateContractEvent;
switch (eventName) {
@@ -637,7 +630,7 @@ export class ExchangeWrapper extends ContractWrapper {
public async validateFillOrderThrowIfInvalidAsync(signedOrder: SignedOrder,
fillTakerTokenAmount: BigNumber.BigNumber,
takerAddress: string): Promise<void> {
- assert.doesConformToSchema('signedOrder', signedOrder, signedOrderSchema);
+ assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
assert.isBigNumber('fillTakerTokenAmount', fillTakerTokenAmount);
await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
const zrxTokenAddress = await this._getZRXTokenAddressAsync();
@@ -652,7 +645,7 @@ export class ExchangeWrapper extends ContractWrapper {
*/
public async validateCancelOrderThrowIfInvalidAsync(
order: Order, cancelTakerTokenAmount: BigNumber.BigNumber): Promise<void> {
- assert.doesConformToSchema('order', order, orderSchema);
+ assert.doesConformToSchema('order', order, schemas.orderSchema);
assert.isBigNumber('cancelTakerTokenAmount', cancelTakerTokenAmount);
const orderHash = utils.getOrderHashHex(order);
const unavailableTakerTokenAmount = await this.getUnavailableTakerAmountAsync(orderHash);
@@ -670,7 +663,7 @@ export class ExchangeWrapper extends ContractWrapper {
public async validateFillOrKillOrderThrowIfInvalidAsync(signedOrder: SignedOrder,
fillTakerTokenAmount: BigNumber.BigNumber,
takerAddress: string): Promise<void> {
- assert.doesConformToSchema('signedOrder', signedOrder, signedOrderSchema);
+ assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
assert.isBigNumber('fillTakerTokenAmount', fillTakerTokenAmount);
await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
const zrxTokenAddress = await this._getZRXTokenAddressAsync();
@@ -705,7 +698,7 @@ export class ExchangeWrapper extends ContractWrapper {
private async _isValidSignatureUsingContractCallAsync(dataHex: string, ecSignature: ECSignature,
signerAddressHex: string): Promise<boolean> {
assert.isHexString('dataHex', dataHex);
- assert.doesConformToSchema('ecSignature', ecSignature, ecSignatureSchema);
+ assert.doesConformToSchema('ecSignature', ecSignature, schemas.ecSignatureSchema);
assert.isETHAddressHex('signerAddressHex', signerAddressHex);
const exchangeInstance = await this._getExchangeContractAsync();
diff --git a/src/contract_wrappers/token_wrapper.ts b/src/contract_wrappers/token_wrapper.ts
index a2812ccdb..51490359e 100644
--- a/src/contract_wrappers/token_wrapper.ts
+++ b/src/contract_wrappers/token_wrapper.ts
@@ -1,5 +1,6 @@
import * as _ from 'lodash';
import * as BigNumber from 'bignumber.js';
+import {SchemaValidator, schemas} from '0x-json-schemas';
import {Web3Wrapper} from '../web3_wrapper';
import {assert} from '../utils/assert';
import {utils} from '../utils/utils';
@@ -8,8 +9,6 @@ import {constants} from '../utils/constants';
import {ContractWrapper} from './contract_wrapper';
import * as TokenArtifacts from '../artifacts/Token.json';
import * as TokenTransferProxyArtifacts from '../artifacts/TokenTransferProxy.json';
-import {subscriptionOptsSchema} from '../schemas/subscription_opts_schema';
-import {indexFilterValuesSchema} from '../schemas/index_filter_values_schema';
import {
TokenContract,
ZeroExError,
@@ -230,8 +229,8 @@ export class TokenWrapper extends ContractWrapper {
indexFilterValues: IndexedFilterValues): Promise<ContractEventEmitter> {
assert.isETHAddressHex('tokenAddress', tokenAddress);
assert.doesBelongToStringEnum('eventName', eventName, TokenEvents);
- assert.doesConformToSchema('subscriptionOpts', subscriptionOpts, subscriptionOptsSchema);
- assert.doesConformToSchema('indexFilterValues', indexFilterValues, indexFilterValuesSchema);
+ assert.doesConformToSchema('subscriptionOpts', subscriptionOpts, schemas.subscriptionOptsSchema);
+ assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
const tokenContract = await this._getTokenContractAsync(tokenAddress);
let createLogEvent: CreateContractEvent;
switch (eventName) {
diff --git a/src/globals.d.ts b/src/globals.d.ts
index f1720e366..9879a57ad 100644
--- a/src/globals.d.ts
+++ b/src/globals.d.ts
@@ -25,55 +25,6 @@ declare namespace Chai {
}
/* tslint:enable */
-// jsonschema declarations
-// Source: https://github.com/tdegrunt/jsonschema/blob/master/lib/index.d.ts
-declare interface Schema {
- id?: string;
- $schema?: string;
- title?: string;
- description?: string;
- multipleOf?: number;
- maximum?: number;
- exclusiveMaximum?: boolean;
- minimum?: number;
- exclusiveMinimum?: boolean;
- maxLength?: number;
- minLength?: number;
- pattern?: string;
- additionalItems?: boolean | Schema;
- items?: Schema | Schema[];
- maxItems?: number;
- minItems?: number;
- uniqueItems?: boolean;
- maxProperties?: number;
- minProperties?: number;
- required?: string[];
- additionalProperties?: boolean | Schema;
- definitions?: {
- [name: string]: Schema;
- };
- properties?: {
- [name: string]: Schema;
- };
- patternProperties?: {
- [name: string]: Schema;
- };
- dependencies?: {
- [name: string]: Schema | string[];
- };
- 'enum'?: any[];
- type?: string | string[];
- allOf?: Schema[];
- anyOf?: Schema[];
- oneOf?: Schema[];
- not?: Schema;
- // This is the only property that's not defined in https://github.com/tdegrunt/jsonschema/blob/master/lib/index.d.ts
- // There is an open issue for that: https://github.com/tdegrunt/jsonschema/issues/194
- // There is also an opened PR: https://github.com/tdegrunt/jsonschema/pull/218/files
- // As soon as it gets merged we should be good to use types from 'jsonschema' package
- $ref?: string;
-}
-
declare module '*.json' {
const json: any;
/* tslint:disable */
diff --git a/src/schemas/basic_type_schemas.ts b/src/schemas/basic_type_schemas.ts
deleted file mode 100644
index 5d66cf79b..000000000
--- a/src/schemas/basic_type_schemas.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-export const addressSchema = {
- id: '/addressSchema',
- type: 'string',
- pattern: '^0x[0-9a-f]{40}$',
-};
-
-export const numberSchema = {
- id: '/numberSchema',
- type: 'string',
- pattern: '^\\d+(\\.\\d+)?$',
-};
diff --git a/src/schemas/ec_signature_schema.ts b/src/schemas/ec_signature_schema.ts
deleted file mode 100644
index df1121989..000000000
--- a/src/schemas/ec_signature_schema.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-export const ecSignatureParameterSchema = {
- id: '/ecSignatureParameter',
- type: 'string',
- pattern: '^0[xX][0-9A-Fa-f]{64}$',
-};
-
-export const ecSignatureSchema = {
- id: '/ECSignature',
- properties: {
- v: {
- type: 'number',
- minimum: 27,
- maximum: 28,
- },
- r: {$ref: '/ecSignatureParameter'},
- s: {$ref: '/ecSignatureParameter'},
- },
- required: ['v', 'r', 's'],
- type: 'object',
-};
diff --git a/src/schemas/index_filter_values_schema.ts b/src/schemas/index_filter_values_schema.ts
deleted file mode 100644
index 7c8d3f943..000000000
--- a/src/schemas/index_filter_values_schema.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-export const indexFilterValuesSchema = {
- id: '/indexFilterValues',
- additionalProperties: {
- oneOf: [
- {$ref: '/numberSchema'},
- {$ref: '/addressSchema'},
- {$ref: '/orderHashSchema'},
- ],
- },
- type: 'object',
-};
diff --git a/src/schemas/order_cancel_schema.ts b/src/schemas/order_cancel_schema.ts
deleted file mode 100644
index 04b2c179f..000000000
--- a/src/schemas/order_cancel_schema.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-export const orderCancellationRequestsSchema = {
- id: '/OrderCancellationRequests',
- type: 'array',
- items: {
- properties: {
- order: {$ref: '/orderSchema'},
- takerTokenCancelAmount: {$ref: '/numberSchema'},
- },
- required: ['order', 'takerTokenCancelAmount'],
- type: 'object',
- },
-};
diff --git a/src/schemas/order_fill_or_kill_requests_schema.ts b/src/schemas/order_fill_or_kill_requests_schema.ts
deleted file mode 100644
index 6f7878c45..000000000
--- a/src/schemas/order_fill_or_kill_requests_schema.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-export const orderFillOrKillRequestsSchema = {
- id: '/OrderFillOrKillRequests',
- type: 'array',
- items: {
- properties: {
- signedOrder: {$ref: '/signedOrderSchema'},
- fillTakerAmount: {$ref: '/numberSchema'},
- },
- required: ['signedOrder', 'fillTakerAmount'],
- type: 'object',
- },
-};
diff --git a/src/schemas/order_fill_requests_schema.ts b/src/schemas/order_fill_requests_schema.ts
deleted file mode 100644
index 0f3ee1e99..000000000
--- a/src/schemas/order_fill_requests_schema.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-export const orderFillRequestsSchema = {
- id: '/OrderFillRequests',
- type: 'array',
- items: {
- properties: {
- signedOrder: {$ref: '/signedOrderSchema'},
- takerTokenFillAmount: {$ref: '/numberSchema'},
- },
- required: ['signedOrder', 'takerTokenFillAmount'],
- type: 'object',
- },
-};
diff --git a/src/schemas/order_hash_schema.ts b/src/schemas/order_hash_schema.ts
deleted file mode 100644
index 9773a88f9..000000000
--- a/src/schemas/order_hash_schema.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-export const orderHashSchema = {
- id: '/orderHashSchema',
- type: 'string',
- pattern: '^0x[0-9a-fA-F]{64}$',
-};
diff --git a/src/schemas/order_schemas.ts b/src/schemas/order_schemas.ts
deleted file mode 100644
index c346687b5..000000000
--- a/src/schemas/order_schemas.ts
+++ /dev/null
@@ -1,39 +0,0 @@
-export const orderSchema = {
- id: '/orderSchema',
- properties: {
- maker: {$ref: '/addressSchema'},
- taker: {$ref: '/addressSchema'},
-
- makerFee: {$ref: '/numberSchema'},
- takerFee: {$ref: '/numberSchema'},
-
- makerTokenAmount: {$ref: '/numberSchema'},
- takerTokenAmount: {$ref: '/numberSchema'},
-
- makerTokenAddress: {$ref: '/addressSchema'},
- takerTokenAddress: {$ref: '/addressSchema'},
-
- salt: {$ref: '/numberSchema'},
- feeRecipient: {$ref: '/addressSchema'},
- expirationUnixTimestampSec: {$ref: '/numberSchema'},
- exchangeContractAddress: {$ref: '/addressSchema'},
- },
- required: [
- 'maker', 'taker', 'makerFee', 'takerFee', 'makerTokenAmount', 'takerTokenAmount',
- 'salt', 'feeRecipient', 'expirationUnixTimestampSec', 'exchangeContractAddress',
- ],
- type: 'object',
-};
-
-export const signedOrderSchema = {
- id: '/signedOrderSchema',
- allOf: [
- { $ref: '/orderSchema' },
- {
- properties: {
- ecSignature: {$ref: '/ECSignature'},
- },
- required: ['ecSignature'],
- },
- ],
-};
diff --git a/src/schemas/signed_orders_schema.ts b/src/schemas/signed_orders_schema.ts
deleted file mode 100644
index 3b3b23649..000000000
--- a/src/schemas/signed_orders_schema.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-export const signedOrdersSchema = {
- id: '/signedOrdersSchema',
- type: 'array',
- items: {$ref: '/signedOrderSchema'},
-};
diff --git a/src/schemas/subscription_opts_schema.ts b/src/schemas/subscription_opts_schema.ts
deleted file mode 100644
index 0bb44fecf..000000000
--- a/src/schemas/subscription_opts_schema.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-export const blockParamSchema = {
- id: '/blockParam',
- oneOf: [
- {
- type: 'number',
- },
- {
- enum: ['latest', 'earliest', 'pending'],
- },
- ],
-};
-
-export const subscriptionOptsSchema = {
- id: '/subscriptionOpts',
- properties: {
- fromBlock: {$ref: '/blockParam'},
- toBlock: {$ref: '/blockParam'},
- },
- type: 'object',
-};
diff --git a/src/schemas/token_schema.ts b/src/schemas/token_schema.ts
deleted file mode 100644
index e9e359fdf..000000000
--- a/src/schemas/token_schema.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-export const tokenSchema = {
- id: '/token',
- properties: {
- name: {type: 'string'},
- symbol: {type: 'string'},
- decimals: {type: 'number'},
- address: {$ref: '/addressSchema'},
- },
- required: ['name', 'symbol', 'decimals', 'address'],
- type: 'object',
-};
diff --git a/src/utils/assert.ts b/src/utils/assert.ts
index 0e6169b44..a26b19311 100644
--- a/src/utils/assert.ts
+++ b/src/utils/assert.ts
@@ -2,7 +2,7 @@ import * as _ from 'lodash';
import * as BigNumber from 'bignumber.js';
import * as Web3 from 'web3';
import {Web3Wrapper} from '../web3_wrapper';
-import {SchemaValidator} from './schema_validator';
+import {SchemaValidator, Schema} from '0x-json-schemas';
const HEX_REGEX = /^0x[0-9A-F]*$/i;
diff --git a/src/utils/schema_validator.ts b/src/utils/schema_validator.ts
deleted file mode 100644
index 6916aa85b..000000000
--- a/src/utils/schema_validator.ts
+++ /dev/null
@@ -1,36 +0,0 @@
-import {Validator, ValidatorResult, Schema as JSONSchema} from 'jsonschema';
-import {ecSignatureSchema, ecSignatureParameterSchema} from '../schemas/ec_signature_schema';
-import {orderHashSchema} from '../schemas/order_hash_schema';
-import {orderSchema, signedOrderSchema} from '../schemas/order_schemas';
-import {addressSchema, numberSchema} from '../schemas/basic_type_schemas';
-import {tokenSchema} from '../schemas/token_schema';
-import {subscriptionOptsSchema, blockParamSchema} from '../schemas/subscription_opts_schema';
-import {indexFilterValuesSchema} from '../schemas/index_filter_values_schema';
-import {orderFillOrKillRequestsSchema} from '../schemas/order_fill_or_kill_requests_schema';
-
-export class SchemaValidator {
- private validator: Validator;
- constructor() {
- this.validator = new Validator();
- this.validator.addSchema(tokenSchema as JSONSchema, tokenSchema.id);
- this.validator.addSchema(orderSchema as JSONSchema, orderSchema.id);
- this.validator.addSchema(numberSchema as JSONSchema, numberSchema.id);
- this.validator.addSchema(addressSchema as JSONSchema, addressSchema.id);
- this.validator.addSchema(orderHashSchema as JSONSchema, orderHashSchema.id);
- this.validator.addSchema(blockParamSchema as JSONSchema, blockParamSchema.id);
- this.validator.addSchema(ecSignatureSchema as JSONSchema, ecSignatureSchema.id);
- this.validator.addSchema(signedOrderSchema as JSONSchema, signedOrderSchema.id);
- this.validator.addSchema(subscriptionOptsSchema as JSONSchema, subscriptionOptsSchema.id);
- this.validator.addSchema(indexFilterValuesSchema as JSONSchema, indexFilterValuesSchema.id);
- this.validator.addSchema(ecSignatureParameterSchema as JSONSchema, ecSignatureParameterSchema.id);
- this.validator.addSchema(orderFillOrKillRequestsSchema as JSONSchema, orderFillOrKillRequestsSchema.id);
- }
- // In order to validate a complex JS object using jsonschema, we must replace any complex
- // sub-types (e.g BigNumber) with a simpler string representation. Since BigNumber and other
- // complex types implement the `toString` method, we can stringify the object and
- // then parse it. The resultant object can then be checked using jsonschema.
- public validate(instance: any, schema: Schema): ValidatorResult {
- const jsonSchemaCompatibleObject = JSON.parse(JSON.stringify(instance));
- return this.validator.validate(jsonSchemaCompatibleObject, schema);
- }
-}