aboutsummaryrefslogtreecommitdiffstats
path: root/packages/json-schemas
diff options
context:
space:
mode:
Diffstat (limited to 'packages/json-schemas')
-rw-r--r--packages/json-schemas/CHANGELOG.json19
-rw-r--r--packages/json-schemas/CHANGELOG.md6
-rw-r--r--packages/json-schemas/package.json13
-rw-r--r--packages/json-schemas/schemas/basic_type_schemas.ts6
-rw-r--r--packages/json-schemas/schemas/ec_signature_schema.ts20
-rw-r--r--packages/json-schemas/schemas/order_schemas.ts36
-rw-r--r--packages/json-schemas/src/schemas.ts6
-rw-r--r--packages/json-schemas/test/schema_test.ts87
8 files changed, 85 insertions, 108 deletions
diff --git a/packages/json-schemas/CHANGELOG.json b/packages/json-schemas/CHANGELOG.json
index 4114cdcf4..3399a452a 100644
--- a/packages/json-schemas/CHANGELOG.json
+++ b/packages/json-schemas/CHANGELOG.json
@@ -1,5 +1,24 @@
[
{
+ "version": "0.8.0",
+ "changes": [
+ {
+ "note":
+ "Update Order & SignedOrder schemas, remove ECSignature schema and add Hex schema as part of V2 upgrades",
+ "pr": 615
+ }
+ ]
+ },
+ {
+ "timestamp": 1527008794,
+ "version": "0.7.24",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1525477860,
"version": "0.7.23",
"changes": [
diff --git a/packages/json-schemas/CHANGELOG.md b/packages/json-schemas/CHANGELOG.md
index 257d14fdf..0b35f2408 100644
--- a/packages/json-schemas/CHANGELOG.md
+++ b/packages/json-schemas/CHANGELOG.md
@@ -5,7 +5,11 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
-## v0.7.23 - _May 5, 2018_
+## v0.7.24 - _May 22, 2018_
+
+ * Dependencies updated
+
+## v0.7.23 - _May 4, 2018_
* Dependencies updated
diff --git a/packages/json-schemas/package.json b/packages/json-schemas/package.json
index 6db04b35b..1612bbc0a 100644
--- a/packages/json-schemas/package.json
+++ b/packages/json-schemas/package.json
@@ -1,8 +1,8 @@
{
"name": "@0xproject/json-schemas",
- "version": "0.7.23",
+ "version": "0.7.24",
"engines": {
- "node" : ">=6.12"
+ "node": ">=6.12"
},
"description": "0x-related json schemas",
"main": "lib/src/index.js",
@@ -45,15 +45,15 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/json-schemas/README.md",
"dependencies": {
- "@0xproject/typescript-typings": "^0.3.1",
+ "@0xproject/typescript-typings": "^0.3.2",
"@types/node": "^8.0.53",
"jsonschema": "^1.2.0",
"lodash.values": "^4.3.0"
},
"devDependencies": {
- "@0xproject/monorepo-scripts": "^0.1.19",
- "@0xproject/tslint-config": "^0.4.17",
- "@0xproject/utils": "^0.6.1",
+ "@0xproject/monorepo-scripts": "^0.1.20",
+ "@0xproject/tslint-config": "^0.4.18",
+ "@0xproject/utils": "^0.6.2",
"@types/lodash.foreach": "^4.5.3",
"@types/lodash.values": "^4.3.3",
"@types/mocha": "^2.2.42",
@@ -61,6 +61,7 @@
"copyfiles": "^1.2.0",
"dirty-chai": "^2.0.1",
"lodash.foreach": "^4.5.0",
+ "make-promises-safe": "^1.1.0",
"mocha": "^4.0.1",
"npm-run-all": "^4.1.2",
"nyc": "^11.0.1",
diff --git a/packages/json-schemas/schemas/basic_type_schemas.ts b/packages/json-schemas/schemas/basic_type_schemas.ts
index 9d81ff333..7565df9e0 100644
--- a/packages/json-schemas/schemas/basic_type_schemas.ts
+++ b/packages/json-schemas/schemas/basic_type_schemas.ts
@@ -4,6 +4,12 @@ export const addressSchema = {
pattern: '^0x[0-9a-f]{40}$',
};
+export const hexSchema = {
+ id: '/Hex',
+ type: 'string',
+ pattern: '^0x([0-9a-f][0-9a-f])+$',
+};
+
export const numberSchema = {
id: '/Number',
type: 'string',
diff --git a/packages/json-schemas/schemas/ec_signature_schema.ts b/packages/json-schemas/schemas/ec_signature_schema.ts
deleted file mode 100644
index 71b840dd8..000000000
--- a/packages/json-schemas/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/packages/json-schemas/schemas/order_schemas.ts b/packages/json-schemas/schemas/order_schemas.ts
index 6f17224ad..183118c23 100644
--- a/packages/json-schemas/schemas/order_schemas.ts
+++ b/packages/json-schemas/schemas/order_schemas.ts
@@ -1,30 +1,30 @@
export const orderSchema = {
id: '/Order',
properties: {
- maker: { $ref: '/Address' },
- taker: { $ref: '/Address' },
+ makerAddress: { $ref: '/Address' },
+ takerAddress: { $ref: '/Address' },
makerFee: { $ref: '/Number' },
takerFee: { $ref: '/Number' },
- makerTokenAmount: { $ref: '/Number' },
- takerTokenAmount: { $ref: '/Number' },
- makerTokenAddress: { $ref: '/Address' },
- takerTokenAddress: { $ref: '/Address' },
+ makerAssetAmount: { $ref: '/Number' },
+ takerAssetAmount: { $ref: '/Number' },
+ makerAssetData: { $ref: '/Hex' },
+ takerAssetData: { $ref: '/Hex' },
salt: { $ref: '/Number' },
- feeRecipient: { $ref: '/Address' },
- expirationUnixTimestampSec: { $ref: '/Number' },
- exchangeContractAddress: { $ref: '/Address' },
+ feeRecipientAddress: { $ref: '/Address' },
+ expirationTimeSeconds: { $ref: '/Number' },
},
required: [
- 'maker',
- 'taker',
+ 'makerAddress',
+ 'takerAddress',
'makerFee',
'takerFee',
- 'makerTokenAmount',
- 'takerTokenAmount',
+ 'makerAssetAmount',
+ 'takerAssetAmount',
+ 'makerAssetData',
+ 'takerAssetData',
'salt',
- 'feeRecipient',
- 'expirationUnixTimestampSec',
- 'exchangeContractAddress',
+ 'feeRecipientAddress',
+ 'expirationTimeSeconds',
],
type: 'object',
};
@@ -35,9 +35,9 @@ export const signedOrderSchema = {
{ $ref: '/Order' },
{
properties: {
- ecSignature: { $ref: '/ECSignature' },
+ signature: { $ref: '/Hex' },
},
- required: ['ecSignature'],
+ required: ['signature'],
},
],
};
diff --git a/packages/json-schemas/src/schemas.ts b/packages/json-schemas/src/schemas.ts
index 5cb07acfe..26d6e6cf1 100644
--- a/packages/json-schemas/src/schemas.ts
+++ b/packages/json-schemas/src/schemas.ts
@@ -1,6 +1,5 @@
-import { addressSchema, numberSchema } from '../schemas/basic_type_schemas';
+import { addressSchema, hexSchema, numberSchema } from '../schemas/basic_type_schemas';
import { blockParamSchema, blockRangeSchema } from '../schemas/block_range_schema';
-import { ecSignatureParameterSchema, ecSignatureSchema } from '../schemas/ec_signature_schema';
import { indexFilterValuesSchema } from '../schemas/index_filter_values_schema';
import { orderCancellationRequestsSchema } from '../schemas/order_cancel_schema';
import { orderFillOrKillRequestsSchema } from '../schemas/order_fill_or_kill_requests_schema';
@@ -31,8 +30,7 @@ import { jsNumber, txDataSchema } from '../schemas/tx_data_schema';
export const schemas = {
numberSchema,
addressSchema,
- ecSignatureSchema,
- ecSignatureParameterSchema,
+ hexSchema,
indexFilterValuesSchema,
orderCancellationRequestsSchema,
orderFillOrKillRequestsSchema,
diff --git a/packages/json-schemas/test/schema_test.ts b/packages/json-schemas/test/schema_test.ts
index 7b058781d..379f92442 100644
--- a/packages/json-schemas/test/schema_test.ts
+++ b/packages/json-schemas/test/schema_test.ts
@@ -2,6 +2,7 @@ import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
import * as dirtyChai from 'dirty-chai';
import forEach = require('lodash.foreach');
+import 'make-promises-safe';
import 'mocha';
import { schemas, SchemaValidator } from '../src/index';
@@ -13,8 +14,7 @@ const NULL_ADDRESS = '0x0000000000000000000000000000000000000000';
const {
numberSchema,
addressSchema,
- ecSignatureSchema,
- ecSignatureParameterSchema,
+ hexSchema,
orderCancellationRequestsSchema,
orderFillOrKillRequestsSchema,
orderFillRequestsSchema,
@@ -84,47 +84,15 @@ describe('Schema', () => {
validateAgainstSchema(testCases, addressSchema, shouldFail);
});
});
- describe('#ecSignatureParameterSchema', () => {
- it('should validate valid parameters', () => {
- const testCases = [
- '0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33',
- '0X40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254',
- ];
- validateAgainstSchema(testCases, ecSignatureParameterSchema);
- });
- it('should fail for invalid parameters', () => {
- const testCases = [
- '0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc3', // shorter
- '0xzzzz9190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254', // invalid characters
- '40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254', // no 0x
- ];
- const shouldFail = true;
- validateAgainstSchema(testCases, ecSignatureParameterSchema, shouldFail);
- });
- });
- describe('#ecSignatureSchema', () => {
- it('should validate valid signature', () => {
- const signature = {
- v: 27,
- r: '0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33',
- s: '0x40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254',
- };
- const testCases = [
- signature,
- {
- ...signature,
- v: 28,
- },
- ];
- validateAgainstSchema(testCases, ecSignatureSchema);
+ describe('#hexSchema', () => {
+ it('should validate valid hex string', () => {
+ const testCases = ['0x8b0292b11a196601ed2ce54b665cafeca0347d42', NULL_ADDRESS];
+ validateAgainstSchema(testCases, hexSchema);
});
- it('should fail for invalid signature', () => {
- const v = 27;
- const r = '0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33';
- const s = '0x40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254';
- const testCases = [{}, { v }, { r, s, v: 31 }];
+ it('should fail for invalid hex string', () => {
+ const testCases = ['0x', '0', '0xzzzzzzB11a196601eD2ce54B665CaFEca0347D42'];
const shouldFail = true;
- validateAgainstSchema(testCases, ecSignatureSchema, shouldFail);
+ validateAgainstSchema(testCases, hexSchema, shouldFail);
});
});
describe('#orderHashSchema', () => {
@@ -148,7 +116,8 @@ describe('Schema', () => {
});
describe('#blockParamSchema', () => {
it('should validate valid block param', () => {
- const testCases = [42, 'latest', 'pending', 'earliest'];
+ const blockNumber = 42;
+ const testCases = [blockNumber, 'latest', 'pending', 'earliest'];
validateAgainstSchema(testCases, blockParamSchema);
});
it('should fail for invalid block param', () => {
@@ -181,6 +150,7 @@ describe('Schema', () => {
validateAgainstSchema(testCases, tokenSchema);
});
it('should fail for invalid token', () => {
+ const num = 4;
const testCases = [
{
...token,
@@ -191,7 +161,7 @@ describe('Schema', () => {
decimals: undefined,
},
[],
- 4,
+ num,
];
const shouldFail = true;
validateAgainstSchema(testCases, tokenSchema, shouldFail);
@@ -199,18 +169,17 @@ describe('Schema', () => {
});
describe('order including schemas', () => {
const order = {
- maker: NULL_ADDRESS,
- taker: NULL_ADDRESS,
+ makerAddress: NULL_ADDRESS,
+ takerAddress: NULL_ADDRESS,
makerFee: '1',
takerFee: '2',
- makerTokenAmount: '1',
- takerTokenAmount: '2',
- makerTokenAddress: NULL_ADDRESS,
- takerTokenAddress: NULL_ADDRESS,
+ makerAssetAmount: '1',
+ takerAssetAmount: '2',
+ makerAssetData: NULL_ADDRESS,
+ takerAssetData: NULL_ADDRESS,
salt: '67006738228878699843088602623665307406148487219438534730168799356281242528500',
- feeRecipient: NULL_ADDRESS,
- exchangeContractAddress: NULL_ADDRESS,
- expirationUnixTimestampSec: '42',
+ feeRecipientAddress: NULL_ADDRESS,
+ expirationTimeSeconds: '42',
};
describe('#orderSchema', () => {
it('should validate valid order', () => {
@@ -236,11 +205,8 @@ describe('Schema', () => {
describe('signed order including schemas', () => {
const signedOrder = {
...order,
- ecSignature: {
- v: 27,
- r: '0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33',
- s: '0x40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254',
- },
+ signature:
+ '0x031b61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc3340349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254',
};
describe('#signedOrdersSchema', () => {
it('should validate valid signed orders', () => {
@@ -262,7 +228,7 @@ describe('Schema', () => {
const testCases = [
{
...signedOrder,
- ecSignature: undefined,
+ signature: undefined,
},
];
const shouldFail = true;
@@ -870,10 +836,12 @@ describe('Schema', () => {
});
describe('#jsNumberSchema', () => {
it('should validate valid js number', () => {
+ // tslint:disable-next-line:custom-no-magic-numbers
const testCases = [1, 42];
validateAgainstSchema(testCases, jsNumber);
});
it('should fail for invalid js number', () => {
+ // tslint:disable-next-line:custom-no-magic-numbers
const testCases = [NaN, -1, new BigNumber(1)];
const shouldFail = true;
validateAgainstSchema(testCases, jsNumber, shouldFail);
@@ -881,13 +849,14 @@ describe('Schema', () => {
});
describe('#txDataSchema', () => {
it('should validate valid txData', () => {
+ const bigNumGasAmount = new BigNumber(42);
const testCases = [
{
from: NULL_ADDRESS,
},
{
from: NULL_ADDRESS,
- gas: new BigNumber(42),
+ gas: bigNumGasAmount,
},
{
from: NULL_ADDRESS,