aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-06-10 01:26:21 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-06-10 01:26:21 +0800
commit4e9a83132cdec4a6278052919310118c2abbc0ca (patch)
tree4fb97f8d432a51dff1f47578486361da00afd5e4
parent33741c5e1e258523cb49d8171de0b5218e70ca3d (diff)
downloaddexon-0x-contracts-4e9a83132cdec4a6278052919310118c2abbc0ca.tar.gz
dexon-0x-contracts-4e9a83132cdec4a6278052919310118c2abbc0ca.tar.zst
dexon-0x-contracts-4e9a83132cdec4a6278052919310118c2abbc0ca.zip
Address feedback
-rw-r--r--src/contract_wrappers/exchange_wrapper.ts2
-rw-r--r--src/utils/schema_validator.ts13
2 files changed, 6 insertions, 9 deletions
diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts
index c76de79e9..65a873a9f 100644
--- a/src/contract_wrappers/exchange_wrapper.ts
+++ b/src/contract_wrappers/exchange_wrapper.ts
@@ -426,7 +426,7 @@ export class ExchangeWrapper extends ContractWrapper {
await this.validateCancelOrderAndThrowIfInvalidAsync(
cancellationRequest.order, cancellationRequest.takerTokenCancelAmount,
);
- };
+ }
if (_.isEmpty(orderCancellationRequests)) {
return; // no-op
}
diff --git a/src/utils/schema_validator.ts b/src/utils/schema_validator.ts
index 786dca624..6e0e6ab9c 100644
--- a/src/utils/schema_validator.ts
+++ b/src/utils/schema_validator.ts
@@ -7,13 +7,6 @@ import {orderFillOrKillRequestsSchema} from '../schemas/order_fill_or_kill_reque
export class SchemaValidator {
private validator: Validator;
- // 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.
- static convertToJSONSchemaCompatibleObject(obj: any): any {
- return JSON.parse(JSON.stringify(obj));
- }
constructor() {
this.validator = new Validator();
this.validator.addSchema(tokenSchema, tokenSchema.id);
@@ -25,8 +18,12 @@ export class SchemaValidator {
this.validator.addSchema(ecSignatureParameter, ecSignatureParameter.id);
this.validator.addSchema(orderFillOrKillRequestsSchema, 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 = SchemaValidator.convertToJSONSchemaCompatibleObject(instance);
+ const jsonSchemaCompatibleObject = JSON.parse(JSON.stringify(instance));
return this.validator.validate(jsonSchemaCompatibleObject, schema);
}
}