aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLeonid <logvinov.leon@gmail.com>2017-06-10 02:29:08 +0800
committerGitHub <noreply@github.com>2017-06-10 02:29:08 +0800
commit1460966d8f03e5ec0012b21d4c4614c4c3ec44bc (patch)
treeed24d8f87f57b90380d8167b35c5019005a94aba /src
parent478125f3d4feccd3b8396773888d65798af8287f (diff)
parentaefa147ba0e36f7ec302a5f5b6f496cabf784599 (diff)
downloaddexon-sol-tools-1460966d8f03e5ec0012b21d4c4614c4c3ec44bc.tar
dexon-sol-tools-1460966d8f03e5ec0012b21d4c4614c4c3ec44bc.tar.gz
dexon-sol-tools-1460966d8f03e5ec0012b21d4c4614c4c3ec44bc.tar.bz2
dexon-sol-tools-1460966d8f03e5ec0012b21d4c4614c4c3ec44bc.tar.lz
dexon-sol-tools-1460966d8f03e5ec0012b21d4c4614c4c3ec44bc.tar.xz
dexon-sol-tools-1460966d8f03e5ec0012b21d4c4614c4c3ec44bc.tar.zst
dexon-sol-tools-1460966d8f03e5ec0012b21d4c4614c4c3ec44bc.zip
Merge pull request #54 from 0xProject/schema-tests
Schema tests
Diffstat (limited to 'src')
-rw-r--r--src/schemas/ec_signature_schema.ts2
-rw-r--r--src/schemas/order_cancel_schema.ts2
-rw-r--r--src/schemas/order_fill_or_kill_requests_schema.ts2
-rw-r--r--src/schemas/order_fill_requests_schema.ts2
-rw-r--r--src/schemas/token_schema.ts14
-rw-r--r--src/utils/schema_validator.ts4
6 files changed, 18 insertions, 8 deletions
diff --git a/src/schemas/ec_signature_schema.ts b/src/schemas/ec_signature_schema.ts
index e39a8bd70..df1121989 100644
--- a/src/schemas/ec_signature_schema.ts
+++ b/src/schemas/ec_signature_schema.ts
@@ -1,4 +1,4 @@
-export const ecSignatureParameter = {
+export const ecSignatureParameterSchema = {
id: '/ecSignatureParameter',
type: 'string',
pattern: '^0[xX][0-9A-Fa-f]{64}$',
diff --git a/src/schemas/order_cancel_schema.ts b/src/schemas/order_cancel_schema.ts
index 5cc8f745c..04b2c179f 100644
--- a/src/schemas/order_cancel_schema.ts
+++ b/src/schemas/order_cancel_schema.ts
@@ -4,7 +4,7 @@ export const orderCancellationRequestsSchema = {
items: {
properties: {
order: {$ref: '/orderSchema'},
- takerTokenCancelAmount: {type: '/numberSchema'},
+ 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
index 4db7113de..6f7878c45 100644
--- a/src/schemas/order_fill_or_kill_requests_schema.ts
+++ b/src/schemas/order_fill_or_kill_requests_schema.ts
@@ -4,7 +4,7 @@ export const orderFillOrKillRequestsSchema = {
items: {
properties: {
signedOrder: {$ref: '/signedOrderSchema'},
- fillTakerAmount: {type: '/numberSchema'},
+ 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
index 44f4e33e2..0f3ee1e99 100644
--- a/src/schemas/order_fill_requests_schema.ts
+++ b/src/schemas/order_fill_requests_schema.ts
@@ -4,7 +4,7 @@ export const orderFillRequestsSchema = {
items: {
properties: {
signedOrder: {$ref: '/signedOrderSchema'},
- takerTokenFillAmount: {type: '/numberSchema'},
+ takerTokenFillAmount: {$ref: '/numberSchema'},
},
required: ['signedOrder', 'takerTokenFillAmount'],
type: 'object',
diff --git a/src/schemas/token_schema.ts b/src/schemas/token_schema.ts
index 01702af68..1236e07c1 100644
--- a/src/schemas/token_schema.ts
+++ b/src/schemas/token_schema.ts
@@ -4,8 +4,18 @@ export const tokenSchema = {
name: {type: 'string'},
symbol: {type: 'string'},
decimals: {type: 'number'},
- address: {type: 'string'},
- url: {type: 'string'},
+ address: {$ref: '/addressSchema'},
+ url: {
+ oneOf: [
+ {
+ type: 'string',
+ format: 'uri',
+ },
+ {
+ enum: [''],
+ },
+ ],
+ },
},
required: ['name', 'symbol', 'decimals', 'address', 'url'],
type: 'object',
diff --git a/src/utils/schema_validator.ts b/src/utils/schema_validator.ts
index 72f6afffa..755f6e715 100644
--- a/src/utils/schema_validator.ts
+++ b/src/utils/schema_validator.ts
@@ -1,5 +1,5 @@
import {Validator, ValidatorResult} from 'jsonschema';
-import {ecSignatureSchema, ecSignatureParameter} from '../schemas/ec_signature_schema';
+import {ecSignatureSchema, ecSignatureParameterSchema} from '../schemas/ec_signature_schema';
import {orderSchema, signedOrderSchema} from '../schemas/order_schemas';
import {addressSchema, numberSchema} from '../schemas/basic_type_schemas';
import {tokenSchema} from '../schemas/token_schema';
@@ -22,7 +22,7 @@ export class SchemaValidator {
this.validator.addSchema(addressSchema, addressSchema.id);
this.validator.addSchema(ecSignatureSchema, ecSignatureSchema.id);
this.validator.addSchema(signedOrderSchema, signedOrderSchema.id);
- this.validator.addSchema(ecSignatureParameter, ecSignatureParameter.id);
+ this.validator.addSchema(ecSignatureParameterSchema, ecSignatureParameterSchema.id);
this.validator.addSchema(orderFillOrKillRequestsSchema, orderFillOrKillRequestsSchema.id);
}
public validate(instance: object, schema: Schema): ValidatorResult {