aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/schemas
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-02-08 03:26:13 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-02-08 03:26:13 +0800
commit69f5f5e94627458f4eb41f4150cfa3d140658d09 (patch)
tree233be0fd8343ebd92143103f1ae421ad1aae70f2 /packages/website/ts/schemas
parentae14b0a71d70f057efb9cbd4d180aca76a3ad5d1 (diff)
downloaddexon-sol-tools-69f5f5e94627458f4eb41f4150cfa3d140658d09.tar
dexon-sol-tools-69f5f5e94627458f4eb41f4150cfa3d140658d09.tar.gz
dexon-sol-tools-69f5f5e94627458f4eb41f4150cfa3d140658d09.tar.bz2
dexon-sol-tools-69f5f5e94627458f4eb41f4150cfa3d140658d09.tar.lz
dexon-sol-tools-69f5f5e94627458f4eb41f4150cfa3d140658d09.tar.xz
dexon-sol-tools-69f5f5e94627458f4eb41f4150cfa3d140658d09.tar.zst
dexon-sol-tools-69f5f5e94627458f4eb41f4150cfa3d140658d09.zip
Split Order into signedOrder and metadata
Diffstat (limited to 'packages/website/ts/schemas')
-rw-r--r--packages/website/ts/schemas/metadata_schema.ts10
-rw-r--r--packages/website/ts/schemas/order_schema.ts37
-rw-r--r--packages/website/ts/schemas/signed_order_schema.ts34
-rw-r--r--packages/website/ts/schemas/validator.ts4
4 files changed, 51 insertions, 34 deletions
diff --git a/packages/website/ts/schemas/metadata_schema.ts b/packages/website/ts/schemas/metadata_schema.ts
new file mode 100644
index 000000000..272b23fbd
--- /dev/null
+++ b/packages/website/ts/schemas/metadata_schema.ts
@@ -0,0 +1,10 @@
+export const orderMetadataSchema = {
+ id: '/OrderMetadata',
+ properties: {
+ makerToken: { $ref: '/Token' },
+ takerToken: { $ref: '/Token' },
+ networkId: { type: 'number' },
+ },
+ required: ['makerToken', 'takerToken', 'networkId'],
+ type: 'object',
+};
diff --git a/packages/website/ts/schemas/order_schema.ts b/packages/website/ts/schemas/order_schema.ts
index 6ddc9e445..0c5a6d425 100644
--- a/packages/website/ts/schemas/order_schema.ts
+++ b/packages/website/ts/schemas/order_schema.ts
@@ -1,40 +1,9 @@
export const orderSchema = {
id: '/Order',
properties: {
- maker: { type: 'string' },
- taker: { type: 'string' },
- makerTokenAddress: { type: 'string' },
- takerTokenAddress: { type: 'string' },
- makerToken: { $ref: '/Token' },
- takerToken: { $ref: '/Token' },
- 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' },
- networkId: { type: 'number' },
+ signedOrder: { $ref: '/SignedOrder' },
+ metadata: { $ref: '/OrderMetadata' },
},
- required: [
- 'maker',
- 'taker',
- 'makerTokenAddress',
- 'takerTokenAddress',
- 'makerToken',
- 'takerToken',
- 'makerFee',
- 'takerFee',
- 'makerTokenAmount',
- 'takerTokenAmount',
- 'salt',
- 'ecSignature',
- 'expirationUnixTimestampSec',
- 'feeRecipient',
- 'exchangeContractAddress',
- 'networkId',
- ],
+ required: ['signedOrder', 'metadata'],
type: 'object',
};
diff --git a/packages/website/ts/schemas/signed_order_schema.ts b/packages/website/ts/schemas/signed_order_schema.ts
new file mode 100644
index 000000000..385008ab8
--- /dev/null
+++ b/packages/website/ts/schemas/signed_order_schema.ts
@@ -0,0 +1,34 @@
+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/validator.ts b/packages/website/ts/schemas/validator.ts
index e2ffc7b79..14061e2a3 100644
--- a/packages/website/ts/schemas/validator.ts
+++ b/packages/website/ts/schemas/validator.ts
@@ -1,6 +1,8 @@
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 {
@@ -9,6 +11,8 @@ export class SchemaValidator {
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) {