aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-05-25 00:39:28 +0800
committerGitHub <noreply@github.com>2018-05-25 00:39:28 +0800
commit62431fee8e0c79a61f7ebb7677e6c88f0ae95116 (patch)
treef7aa155da9dd3a88d531d525f9f26f89b10e0e2a /packages
parent2f7ab3e32d1c54f42c435503426bc421fa89afd8 (diff)
parent357201869a56f01d33f3b1bf91be18a6029d5d7f (diff)
downloaddexon-sol-tools-62431fee8e0c79a61f7ebb7677e6c88f0ae95116.tar
dexon-sol-tools-62431fee8e0c79a61f7ebb7677e6c88f0ae95116.tar.gz
dexon-sol-tools-62431fee8e0c79a61f7ebb7677e6c88f0ae95116.tar.bz2
dexon-sol-tools-62431fee8e0c79a61f7ebb7677e6c88f0ae95116.tar.lz
dexon-sol-tools-62431fee8e0c79a61f7ebb7677e6c88f0ae95116.tar.xz
dexon-sol-tools-62431fee8e0c79a61f7ebb7677e6c88f0ae95116.tar.zst
dexon-sol-tools-62431fee8e0c79a61f7ebb7677e6c88f0ae95116.zip
Merge pull request #615 from 0xProject/refactor/json-schemas/for-v2
Refactor order schemas in json-schemas for v2
Diffstat (limited to 'packages')
-rw-r--r--packages/assert/package.json2
-rw-r--r--packages/connect/package.json2
-rw-r--r--packages/contract-wrappers/package.json2
-rw-r--r--packages/json-schemas/CHANGELOG.json10
-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.ts75
-rw-r--r--packages/order-utils/package.json2
-rw-r--r--packages/order-watcher/package.json2
-rw-r--r--packages/sol-compiler/package.json2
-rw-r--r--packages/sra-report/package.json2
-rw-r--r--packages/website/webpack.config.js7
14 files changed, 68 insertions, 106 deletions
diff --git a/packages/assert/package.json b/packages/assert/package.json
index 88f4dac99..e26c88fd7 100644
--- a/packages/assert/package.json
+++ b/packages/assert/package.json
@@ -47,7 +47,7 @@
"typescript": "2.7.1"
},
"dependencies": {
- "@0xproject/json-schemas": "^0.7.24",
+ "@0xproject/json-schemas": "0.7.22",
"@0xproject/typescript-typings": "^0.3.2",
"@0xproject/utils": "^0.6.2",
"lodash": "^4.17.4",
diff --git a/packages/connect/package.json b/packages/connect/package.json
index ed54b47ac..d1e392606 100644
--- a/packages/connect/package.json
+++ b/packages/connect/package.json
@@ -51,7 +51,7 @@
"homepage": "https://github.com/0xProject/0x-monorepo/packages/connect/README.md",
"dependencies": {
"@0xproject/assert": "^0.2.10",
- "@0xproject/json-schemas": "^0.7.24",
+ "@0xproject/json-schemas": "0.7.22",
"@0xproject/types": "^0.7.0",
"@0xproject/typescript-typings": "^0.3.2",
"@0xproject/utils": "^0.6.2",
diff --git a/packages/contract-wrappers/package.json b/packages/contract-wrappers/package.json
index 10719c831..6183bb701 100644
--- a/packages/contract-wrappers/package.json
+++ b/packages/contract-wrappers/package.json
@@ -79,7 +79,7 @@
"@0xproject/assert": "^0.2.10",
"@0xproject/base-contract": "^0.3.2",
"@0xproject/fill-scenarios": "^0.0.2",
- "@0xproject/json-schemas": "^0.7.24",
+ "@0xproject/json-schemas": "0.7.22",
"@0xproject/order-utils": "^0.0.5",
"@0xproject/types": "^0.7.0",
"@0xproject/typescript-typings": "^0.3.2",
diff --git a/packages/json-schemas/CHANGELOG.json b/packages/json-schemas/CHANGELOG.json
index ea0df7eb7..3399a452a 100644
--- a/packages/json-schemas/CHANGELOG.json
+++ b/packages/json-schemas/CHANGELOG.json
@@ -1,5 +1,15 @@
[
{
+ "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": [
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 b9574a0c9..379f92442 100644
--- a/packages/json-schemas/test/schema_test.ts
+++ b/packages/json-schemas/test/schema_test.ts
@@ -14,8 +14,7 @@ const NULL_ADDRESS = '0x0000000000000000000000000000000000000000';
const {
numberSchema,
addressSchema,
- ecSignatureSchema,
- ecSignatureParameterSchema,
+ hexSchema,
orderCancellationRequestsSchema,
orderFillOrKillRequestsSchema,
orderFillRequestsSchema,
@@ -85,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', () => {
@@ -202,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', () => {
@@ -239,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', () => {
@@ -265,7 +228,7 @@ describe('Schema', () => {
const testCases = [
{
...signedOrder,
- ecSignature: undefined,
+ signature: undefined,
},
];
const shouldFail = true;
diff --git a/packages/order-utils/package.json b/packages/order-utils/package.json
index 117b57f45..19e3d5668 100644
--- a/packages/order-utils/package.json
+++ b/packages/order-utils/package.json
@@ -63,7 +63,7 @@
},
"dependencies": {
"@0xproject/assert": "^0.2.10",
- "@0xproject/json-schemas": "^0.7.24",
+ "@0xproject/json-schemas": "0.7.22",
"@0xproject/types": "^0.7.0",
"@0xproject/typescript-typings": "^0.3.2",
"@0xproject/utils": "^0.6.2",
diff --git a/packages/order-watcher/package.json b/packages/order-watcher/package.json
index c84858bfd..ee9d66cd3 100644
--- a/packages/order-watcher/package.json
+++ b/packages/order-watcher/package.json
@@ -80,7 +80,7 @@
"@0xproject/base-contract": "^0.3.2",
"@0xproject/contract-wrappers": "^0.0.2",
"@0xproject/fill-scenarios": "^0.0.2",
- "@0xproject/json-schemas": "^0.7.24",
+ "@0xproject/json-schemas": "0.7.22",
"@0xproject/order-utils": "^0.0.5",
"@0xproject/types": "^0.7.0",
"@0xproject/typescript-typings": "^0.3.2",
diff --git a/packages/sol-compiler/package.json b/packages/sol-compiler/package.json
index c94e59eb4..7e55d718d 100644
--- a/packages/sol-compiler/package.json
+++ b/packages/sol-compiler/package.json
@@ -72,7 +72,7 @@
"zeppelin-solidity": "1.8.0"
},
"dependencies": {
- "@0xproject/json-schemas": "^0.7.24",
+ "@0xproject/json-schemas": "0.7.22",
"@0xproject/sol-resolver": "^0.0.5",
"@0xproject/types": "^0.7.0",
"@0xproject/typescript-typings": "^0.3.2",
diff --git a/packages/sra-report/package.json b/packages/sra-report/package.json
index 810acab1c..7e58a80a2 100644
--- a/packages/sra-report/package.json
+++ b/packages/sra-report/package.json
@@ -35,7 +35,7 @@
"@0xproject/types": "^0.7.0",
"@0xproject/order-utils": "^0.0.5",
"@0xproject/connect": "^0.6.13",
- "@0xproject/json-schemas": "^0.7.24",
+ "@0xproject/json-schemas": "0.7.22",
"@0xproject/typescript-typings": "^0.3.2",
"@0xproject/utils": "^0.6.2",
"chalk": "^2.3.0",
diff --git a/packages/website/webpack.config.js b/packages/website/webpack.config.js
index f9abeb27c..b5e9cf6dd 100644
--- a/packages/website/webpack.config.js
+++ b/packages/website/webpack.config.js
@@ -1,6 +1,6 @@
const path = require('path');
const webpack = require('webpack');
-const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
+const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
module.exports = {
entry: ['./ts/index.tsx'],
@@ -25,6 +25,11 @@ module.exports = {
{
test: /\.js$/,
loader: 'source-map-loader',
+ exclude: [
+ // instead of /\/node_modules\//
+ path.join(process.cwd(), 'node_modules'),
+ path.join(process.cwd(), '../..', 'node_modules'),
+ ],
},
{
test: /\.tsx?$/,