Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@0xproject/json-schemas

Package Overview
Dependencies
Maintainers
5
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@0xproject/json-schemas - npm Package Compare versions

Comparing version 0.7.1 to 0.7.2

8

CHANGELOG.md
# CHANGELOG
v0.7.0 - _December 20, 2017_
------------------------
## v0.7.0 - _December 20, 2017_
* Rename `subscriptionOptsSchema` to `blockRangeSchema` (#272)
v0.6.7 - _November 14, 2017_
------------------------
## v0.6.7 - _November 14, 2017_
* Re-publish JSON-schema previously published under NPM package 0x-json-schemas

@@ -6,7 +6,3 @@ "use strict";

additionalProperties: {
oneOf: [
{ $ref: '/Number' },
{ $ref: '/Address' },
{ $ref: '/OrderHashSchema' },
],
oneOf: [{ $ref: '/Number' }, { $ref: '/Address' }, { $ref: '/OrderHashSchema' }],
},

@@ -13,0 +9,0 @@ type: 'object',

@@ -20,4 +20,12 @@ "use strict";

required: [
'maker', 'taker', 'makerFee', 'takerFee', 'makerTokenAmount', 'takerTokenAmount',
'salt', 'feeRecipient', 'expirationUnixTimestampSec', 'exchangeContractAddress',
'maker',
'taker',
'makerFee',
'takerFee',
'makerTokenAmount',
'takerTokenAmount',
'salt',
'feeRecipient',
'expirationUnixTimestampSec',
'exchangeContractAddress',
],

@@ -24,0 +32,0 @@ type: 'object',

@@ -18,6 +18,11 @@ "use strict";

required: [
'exchangeContractAddress', 'maker', 'taker', 'makerTokenAddress', 'takerTokenAddress',
'expirationUnixTimestampSec', 'salt',
'exchangeContractAddress',
'maker',
'taker',
'makerTokenAddress',
'takerTokenAddress',
'expirationUnixTimestampSec',
'salt',
],
};
//# sourceMappingURL=relayer_api_fees_payload_schema.js.map

@@ -11,3 +11,3 @@ export declare const relayerApiOrderbookChannelSubscribeSchema: {

};
requestId: {
channelId: {
type: string;

@@ -14,0 +14,0 @@ };

@@ -9,6 +9,6 @@ "use strict";

channel: { enum: ['orderbook'] },
requestId: { type: 'number' },
channelId: { type: 'number' },
payload: { $ref: '/RelayerApiOrderbookChannelSubscribePayload' },
},
required: ['type', 'channel', 'requestId', 'payload'],
required: ['type', 'channel', 'channelId', 'payload'],
};

@@ -15,0 +15,0 @@ exports.relayerApiOrderbookChannelSubscribePayload = {

@@ -11,3 +11,3 @@ export declare const relayerApiOrderbookChannelSnapshotSchema: {

};
requestId: {
channelId: {
type: string;

@@ -14,0 +14,0 @@ };

@@ -9,6 +9,6 @@ "use strict";

channel: { enum: ['orderbook'] },
requestId: { type: 'number' },
channelId: { type: 'number' },
payload: { $ref: '/RelayerApiOrderbookChannelSnapshotPayload' },
},
required: ['type', 'channel', 'requestId', 'payload'],
required: ['type', 'channel', 'channelId', 'payload'],
};

@@ -15,0 +15,0 @@ exports.relayerApiOrderbookChannelSnapshotPayload = {

@@ -11,3 +11,3 @@ export declare const relayerApiOrderbookChannelUpdateSchema: {

};
requestId: {
channelId: {
type: string;

@@ -14,0 +14,0 @@ };

@@ -9,7 +9,7 @@ "use strict";

channel: { enum: ['orderbook'] },
requestId: { type: 'number' },
channelId: { type: 'number' },
payload: { $ref: '/SignedOrder' },
},
required: ['type', 'channel', 'requestId', 'payload'],
required: ['type', 'channel', 'channelId', 'payload'],
};
//# sourceMappingURL=relayer_api_orderbook_channel_update_response_schema.js.map

@@ -14,18 +14,9 @@ "use strict";

value: {
oneOf: [
{ $ref: '/Number' },
{ $ref: '/JsNumber' },
],
oneOf: [{ $ref: '/Number' }, { $ref: '/JsNumber' }],
},
gas: {
oneOf: [
{ $ref: '/Number' },
{ $ref: '/JsNumber' },
],
oneOf: [{ $ref: '/Number' }, { $ref: '/JsNumber' }],
},
gasPrice: {
oneOf: [
{ $ref: '/Number' },
{ $ref: '/JsNumber' },
],
oneOf: [{ $ref: '/Number' }, { $ref: '/JsNumber' }],
},

@@ -32,0 +23,0 @@ data: {

@@ -380,3 +380,3 @@ export declare const schemas: {

};
requestId: {
channelId: {
type: string;

@@ -419,3 +419,3 @@ };

};
requestId: {
channelId: {
type: string;

@@ -439,3 +439,3 @@ };

};
requestId: {
channelId: {
type: string;

@@ -442,0 +442,0 @@ };

@@ -11,3 +11,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var bignumber_js_1 = require("bignumber.js");
var utils_1 = require("@0xproject/utils");
var chai = require("chai");

@@ -105,7 +105,3 @@ var dirtyChai = require("dirty-chai");

var s = '0x40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254';
var testCases = [
{},
{ v: v },
{ r: r, s: s, v: 31 },
];
var testCases = [{}, { v: v }, { r: r, s: s, v: 31 }];
var shouldFail = true;

@@ -136,16 +132,7 @@ validateAgainstSchema(testCases, ecSignatureSchema, shouldFail);

it('should validate valid block param', function () {
var testCases = [
42,
'latest',
'pending',
'earliest',
];
var testCases = [42, 'latest', 'pending', 'earliest'];
validateAgainstSchema(testCases, blockParamSchema);
});
it('should fail for invalid block param', function () {
var testCases = [
{},
'42',
'pemding',
];
var testCases = [{}, '42', 'pemding'];
var shouldFail = true;

@@ -157,13 +144,7 @@ validateAgainstSchema(testCases, blockParamSchema, shouldFail);

it('should validate valid subscription opts', function () {
var testCases = [
{ fromBlock: 42, toBlock: 'latest' },
{ fromBlock: 42 },
{},
];
var testCases = [{ fromBlock: 42, toBlock: 'latest' }, { fromBlock: 42 }, {}];
validateAgainstSchema(testCases, blockRangeSchema);
});
it('should fail for invalid subscription opts', function () {
var testCases = [
{ fromBlock: '42' },
];
var testCases = [{ fromBlock: '42' }];
var shouldFail = true;

@@ -182,5 +163,3 @@ validateAgainstSchema(testCases, blockRangeSchema, shouldFail);

it('should validate valid token', function () {
var testCases = [
token,
];
var testCases = [token];
validateAgainstSchema(testCases, tokenSchema);

@@ -216,5 +195,3 @@ });

it('should validate valid order', function () {
var testCases = [
order,
];
var testCases = [order];
validateAgainstSchema(testCases, orderSchema);

@@ -240,15 +217,7 @@ });

it('should validate valid signed orders', function () {
var testCases = [
[signedOrder],
[],
];
var testCases = [[signedOrder], []];
validateAgainstSchema(testCases, signedOrdersSchema);
});
it('should fail for invalid signed orders', function () {
var testCases = [
[
signedOrder,
1,
],
];
var testCases = [[signedOrder, 1]];
var shouldFail = true;

@@ -260,5 +229,3 @@ validateAgainstSchema(testCases, signedOrdersSchema, shouldFail);

it('should validate valid signed order', function () {
var testCases = [
signedOrder,
];
var testCases = [signedOrder];
validateAgainstSchema(testCases, signedOrderSchema);

@@ -282,5 +249,3 @@ });

it('should validate valid order fill or kill requests', function () {
var testCases = [
orderFillOrKillRequests,
];
var testCases = [orderFillOrKillRequests];
validateAgainstSchema(testCases, orderFillOrKillRequestsSchema);

@@ -306,5 +271,3 @@ });

it('should validate valid order cancellation requests', function () {
var testCases = [
orderCancellationRequests,
];
var testCases = [orderCancellationRequests];
validateAgainstSchema(testCases, orderCancellationRequestsSchema);

@@ -330,5 +293,3 @@ });

it('should validate valid order fill requests', function () {
var testCases = [
orderFillRequests,
];
var testCases = [orderFillRequests];
validateAgainstSchema(testCases, orderFillRequestsSchema);

@@ -525,8 +486,4 @@ });

payload: {
bids: [
signedOrder,
],
asks: [
signedOrder,
],
bids: [signedOrder],
asks: [signedOrder],
},

@@ -544,8 +501,4 @@ },

payload: {
bids: [
signedOrder,
],
asks: [
signedOrder,
],
bids: [signedOrder],
asks: [signedOrder],
},

@@ -558,8 +511,4 @@ },

payload: {
bids: [
signedOrder,
],
asks: [
signedOrder,
],
bids: [signedOrder],
asks: [signedOrder],
},

@@ -571,8 +520,4 @@ },

payload: {
bids: [
signedOrder,
],
asks: [
signedOrder,
],
bids: [signedOrder],
asks: [signedOrder],
},

@@ -585,8 +530,4 @@ },

payload: {
bids: [
signedOrder,
],
asks: [
signedOrder,
],
bids: [signedOrder],
asks: [signedOrder],
},

@@ -599,5 +540,3 @@ },

payload: {
bids: [
signedOrder,
],
bids: [signedOrder],
},

@@ -610,5 +549,3 @@ },

payload: {
asks: [
signedOrder,
],
asks: [signedOrder],
},

@@ -621,8 +558,4 @@ },

payload: {
bids: [
signedOrder,
],
asks: [
{},
],
bids: [signedOrder],
asks: [{}],
},

@@ -635,8 +568,4 @@ },

payload: {
bids: [
{},
],
asks: [
signedOrder,
],
bids: [{}],
asks: [signedOrder],
},

@@ -699,3 +628,3 @@ },

forEach(testCases, function (serialized, input) {
expect(JSON.parse(JSON.stringify(new bignumber_js_1.default(input)))).to.be.equal(serialized);
expect(JSON.parse(JSON.stringify(new utils_1.BigNumber(input)))).to.be.equal(serialized);
});

@@ -917,14 +846,7 @@ });

it('should validate valid js number', function () {
var testCases = [
1,
42,
];
var testCases = [1, 42];
validateAgainstSchema(testCases, jsNumber);
});
it('should fail for invalid js number', function () {
var testCases = [
NaN,
-1,
new bignumber_js_1.default(1),
];
var testCases = [NaN, -1, new utils_1.BigNumber(1)];
var shouldFail = true;

@@ -942,3 +864,3 @@ validateAgainstSchema(testCases, jsNumber, shouldFail);

from: NULL_ADDRESS,
gas: new bignumber_js_1.default(42),
gas: new utils_1.BigNumber(42),
},

@@ -955,3 +877,3 @@ {

{
gas: new bignumber_js_1.default(42),
gas: new utils_1.BigNumber(42),
},

@@ -964,3 +886,3 @@ {

[],
new bignumber_js_1.default(1),
new utils_1.BigNumber(1),
];

@@ -967,0 +889,0 @@ var shouldFail = true;

{
"name": "@0xproject/json-schemas",
"version": "0.7.1",
"description": "0x-related json schemas",
"main": "lib/src/index.js",
"types": "lib/src/index.d.ts",
"scripts": {
"lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'",
"test": "run-s clean build run_mocha",
"test:circleci": "yarn test",
"run_mocha": "mocha lib/test/**/*_test.js",
"clean": "shx rm -rf _bundles lib test_temp",
"build": "tsc"
},
"repository": {
"type": "git",
"url": "https://github.com/0xProject/0x.js.git"
},
"author": "",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/0xProject/0x.js/issues"
},
"homepage": "https://github.com/0xProject/0x.js/packages/json-schemas/README.md",
"dependencies": {
"jsonschema": "^1.2.0",
"lodash.values": "^4.3.0"
},
"devDependencies": {
"@0xproject/tslint-config": "^0.4.0",
"@0xproject/utils": "^0.1.2",
"@types/lodash.foreach": "^4.5.3",
"@types/lodash.values": "^4.3.3",
"@types/mocha": "^2.2.42",
"bignumber.js": "~4.1.0",
"chai": "^4.0.1",
"chai-typescript-typings": "^0.0.1",
"dirty-chai": "^2.0.1",
"lodash.foreach": "^4.5.0",
"mocha": "^4.0.1",
"npm-run-all": "^4.1.2",
"shx": "^0.2.2",
"tslint": "5.8.0",
"typescript": "~2.6.1"
}
"name": "@0xproject/json-schemas",
"version": "0.7.2",
"description": "0x-related json schemas",
"main": "lib/src/index.js",
"types": "lib/src/index.d.ts",
"scripts": {
"lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'",
"test": "run-s clean build run_mocha",
"test:circleci": "yarn test",
"run_mocha": "mocha lib/test/**/*_test.js",
"clean": "shx rm -rf _bundles lib test_temp",
"build": "tsc"
},
"repository": {
"type": "git",
"url": "https://github.com/0xProject/0x.js.git"
},
"author": "",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/0xProject/0x.js/issues"
},
"homepage": "https://github.com/0xProject/0x.js/packages/json-schemas/README.md",
"dependencies": {
"jsonschema": "^1.2.0",
"lodash.values": "^4.3.0"
},
"devDependencies": {
"@0xproject/tslint-config": "^0.4.1",
"@0xproject/utils": "^0.1.3",
"@types/lodash.foreach": "^4.5.3",
"@types/lodash.values": "^4.3.3",
"@types/mocha": "^2.2.42",
"chai": "^4.0.1",
"chai-typescript-typings": "^0.0.1",
"dirty-chai": "^2.0.1",
"lodash.foreach": "^4.5.0",
"mocha": "^4.0.1",
"npm-run-all": "^4.1.2",
"shx": "^0.2.2",
"tslint": "5.8.0",
"typescript": "~2.6.1"
}
}

@@ -1,3 +0,2 @@

@0xproject/json-schemas
------
## @0xproject/json-schemas

@@ -36,2 +35,3 @@ Contains 0x-related json schemas

If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
```bash

@@ -42,2 +42,3 @@ yarn config set workspaces-experimental true

Then install dependencies
```bash

@@ -44,0 +45,0 @@ yarn install

@@ -16,6 +16,6 @@ export const blockParamSchema = {

properties: {
fromBlock: {$ref: '/BlockParam'},
toBlock: {$ref: '/BlockParam'},
fromBlock: { $ref: '/BlockParam' },
toBlock: { $ref: '/BlockParam' },
},
type: 'object',
};

@@ -15,4 +15,4 @@ export const ecSignatureParameterSchema = {

},
r: {$ref: '/ECSignatureParameter'},
s: {$ref: '/ECSignatureParameter'},
r: { $ref: '/ECSignatureParameter' },
s: { $ref: '/ECSignatureParameter' },
},

@@ -19,0 +19,0 @@ required: ['v', 'r', 's'],

export const indexFilterValuesSchema = {
id: '/IndexFilterValues',
additionalProperties: {
oneOf: [
{$ref: '/Number'},
{$ref: '/Address'},
{$ref: '/OrderHashSchema'},
],
oneOf: [{ $ref: '/Number' }, { $ref: '/Address' }, { $ref: '/OrderHashSchema' }],
},
type: 'object',
};

@@ -6,4 +6,4 @@ export const orderCancellationRequestsSchema = {

properties: {
order: {$ref: '/Order'},
takerTokenCancelAmount: {$ref: '/Number'},
order: { $ref: '/Order' },
takerTokenCancelAmount: { $ref: '/Number' },
},

@@ -10,0 +10,0 @@ required: ['order', 'takerTokenCancelAmount'],

@@ -6,4 +6,4 @@ export const orderFillOrKillRequestsSchema = {

properties: {
signedOrder: {$ref: '/SignedOrder'},
fillTakerAmount: {$ref: '/Number'},
signedOrder: { $ref: '/SignedOrder' },
fillTakerAmount: { $ref: '/Number' },
},

@@ -10,0 +10,0 @@ required: ['signedOrder', 'fillTakerAmount'],

@@ -6,4 +6,4 @@ export const orderFillRequestsSchema = {

properties: {
signedOrder: {$ref: '/SignedOrder'},
takerTokenFillAmount: {$ref: '/Number'},
signedOrder: { $ref: '/SignedOrder' },
takerTokenFillAmount: { $ref: '/Number' },
},

@@ -10,0 +10,0 @@ required: ['signedOrder', 'takerTokenFillAmount'],

export const orderSchema = {
id: '/Order',
properties: {
maker: {$ref: '/Address'},
taker: {$ref: '/Address'},
makerFee: {$ref: '/Number'},
takerFee: {$ref: '/Number'},
makerTokenAmount: {$ref: '/Number'},
takerTokenAmount: {$ref: '/Number'},
makerTokenAddress: {$ref: '/Address'},
takerTokenAddress: {$ref: '/Address'},
salt: {$ref: '/Number'},
feeRecipient: {$ref: '/Address'},
expirationUnixTimestampSec: {$ref: '/Number'},
exchangeContractAddress: {$ref: '/Address'},
maker: { $ref: '/Address' },
taker: { $ref: '/Address' },
makerFee: { $ref: '/Number' },
takerFee: { $ref: '/Number' },
makerTokenAmount: { $ref: '/Number' },
takerTokenAmount: { $ref: '/Number' },
makerTokenAddress: { $ref: '/Address' },
takerTokenAddress: { $ref: '/Address' },
salt: { $ref: '/Number' },
feeRecipient: { $ref: '/Address' },
expirationUnixTimestampSec: { $ref: '/Number' },
exchangeContractAddress: { $ref: '/Address' },
},
required: [
'maker', 'taker', 'makerFee', 'takerFee', 'makerTokenAmount', 'takerTokenAmount',
'salt', 'feeRecipient', 'expirationUnixTimestampSec', 'exchangeContractAddress',
'maker',
'taker',
'makerFee',
'takerFee',
'makerTokenAmount',
'takerTokenAmount',
'salt',
'feeRecipient',
'expirationUnixTimestampSec',
'exchangeContractAddress',
],

@@ -30,3 +38,3 @@ type: 'object',

properties: {
ecSignature: {$ref: '/ECSignature'},
ecSignature: { $ref: '/ECSignature' },
},

@@ -33,0 +41,0 @@ required: ['ecSignature'],

@@ -5,4 +5,4 @@ export const relayerApiErrorResponseSchema = {

properties: {
code: {type: 'number'},
reason: {type: 'string'},
code: { type: 'number' },
reason: { type: 'string' },
validationErrors: {

@@ -13,5 +13,5 @@ type: 'array',

properties: {
field: {type: 'string'},
code: {type: 'number'},
reason: {type: 'string'},
field: { type: 'string' },
code: { type: 'number' },
reason: { type: 'string' },
},

@@ -18,0 +18,0 @@ required: ['field', 'code', 'reason'],

@@ -5,16 +5,21 @@ export const relayerApiFeesPayloadSchema = {

properties: {
exchangeContractAddress: {$ref: '/Address'},
maker: {$ref: '/Address'},
taker: {$ref: '/Address'},
makerTokenAddress: {$ref: '/Address'},
takerTokenAddress: {$ref: '/Address'},
makerTokenAmount: {$ref: '/Number'},
takerTokenAmount: {$ref: '/Number'},
expirationUnixTimestampSec: {$ref: '/Number'},
salt: {$ref: '/Number'},
exchangeContractAddress: { $ref: '/Address' },
maker: { $ref: '/Address' },
taker: { $ref: '/Address' },
makerTokenAddress: { $ref: '/Address' },
takerTokenAddress: { $ref: '/Address' },
makerTokenAmount: { $ref: '/Number' },
takerTokenAmount: { $ref: '/Number' },
expirationUnixTimestampSec: { $ref: '/Number' },
salt: { $ref: '/Number' },
},
required: [
'exchangeContractAddress', 'maker', 'taker', 'makerTokenAddress', 'takerTokenAddress',
'expirationUnixTimestampSec', 'salt',
'exchangeContractAddress',
'maker',
'taker',
'makerTokenAddress',
'takerTokenAddress',
'expirationUnixTimestampSec',
'salt',
],
};

@@ -5,7 +5,7 @@ export const relayerApiFeesResponseSchema = {

properties: {
makerFee: {$ref: '/Number'},
takerFee: {$ref: '/Number'},
feeRecipient: {$ref: '/Address'},
makerFee: { $ref: '/Number' },
takerFee: { $ref: '/Number' },
feeRecipient: { $ref: '/Address' },
},
required: ['makerFee', 'takerFee', 'feeRecipient'],
};

@@ -5,6 +5,6 @@ export const relayerApiOrderbookChannelSubscribeSchema = {

properties: {
type: {enum: ['subscribe']},
channel: {enum: ['orderbook']},
requestId: {type: 'number'},
payload: {$ref: '/RelayerApiOrderbookChannelSubscribePayload'},
type: { enum: ['subscribe'] },
channel: { enum: ['orderbook'] },
requestId: { type: 'number' },
payload: { $ref: '/RelayerApiOrderbookChannelSubscribePayload' },
},

@@ -18,8 +18,8 @@ required: ['type', 'channel', 'requestId', 'payload'],

properties: {
baseTokenAddress: {$ref: '/Address'},
quoteTokenAddress: {$ref: '/Address'},
snapshot: {type: 'boolean'},
limit: {type: 'number'},
baseTokenAddress: { $ref: '/Address' },
quoteTokenAddress: { $ref: '/Address' },
snapshot: { type: 'boolean' },
limit: { type: 'number' },
},
required: ['baseTokenAddress', 'quoteTokenAddress'],
};

@@ -5,6 +5,6 @@ export const relayerApiOrderbookChannelSnapshotSchema = {

properties: {
type: {enum: ['snapshot']},
channel: {enum: ['orderbook']},
requestId: {type: 'number'},
payload: {$ref: '/RelayerApiOrderbookChannelSnapshotPayload'},
type: { enum: ['snapshot'] },
channel: { enum: ['orderbook'] },
requestId: { type: 'number' },
payload: { $ref: '/RelayerApiOrderbookChannelSnapshotPayload' },
},

@@ -18,6 +18,6 @@ required: ['type', 'channel', 'requestId', 'payload'],

properties: {
bids: {$ref: '/signedOrdersSchema'},
asks: {$ref: '/signedOrdersSchema'},
bids: { $ref: '/signedOrdersSchema' },
asks: { $ref: '/signedOrdersSchema' },
},
required: ['bids', 'asks'],
};

@@ -5,8 +5,8 @@ export const relayerApiOrderbookChannelUpdateSchema = {

properties: {
type: {enum: ['update']},
channel: {enum: ['orderbook']},
requestId: {type: 'number'},
payload: {$ref: '/SignedOrder'},
type: { enum: ['update'] },
channel: { enum: ['orderbook'] },
requestId: { type: 'number' },
payload: { $ref: '/SignedOrder' },
},
required: ['type', 'channel', 'requestId', 'payload'],
};

@@ -5,6 +5,6 @@ export const relayerApiOrderBookResponseSchema = {

properties: {
bids: {$ref: '/signedOrdersSchema'},
asks: {$ref: '/signedOrdersSchema'},
bids: { $ref: '/signedOrdersSchema' },
asks: { $ref: '/signedOrdersSchema' },
},
required: ['bids', 'asks'],
};

@@ -6,4 +6,4 @@ export const relayerApiTokenPairsResponseSchema = {

properties: {
tokenA: {$ref: '/RelayerApiTokenTradeInfo'},
tokenB: {$ref: '/RelayerApiTokenTradeInfo'},
tokenA: { $ref: '/RelayerApiTokenTradeInfo' },
tokenB: { $ref: '/RelayerApiTokenTradeInfo' },
},

@@ -19,8 +19,8 @@ required: ['tokenA', 'tokenB'],

properties: {
address: {$ref: '/Address'},
minAmount: {$ref: '/Number'},
maxAmount: {$ref: '/Number'},
precision: {type: 'number'},
address: { $ref: '/Address' },
minAmount: { $ref: '/Number' },
maxAmount: { $ref: '/Number' },
precision: { type: 'number' },
},
required: ['address'],
};
export const signedOrdersSchema = {
id: '/signedOrdersSchema',
type: 'array',
items: {$ref: '/SignedOrder'},
items: { $ref: '/SignedOrder' },
};
export const tokenSchema = {
id: '/Token',
properties: {
name: {type: 'string'},
symbol: {type: 'string'},
decimals: {type: 'number'},
address: {$ref: '/Address'},
name: { type: 'string' },
symbol: { type: 'string' },
decimals: { type: 'number' },
address: { $ref: '/Address' },
},

@@ -9,0 +9,0 @@ required: ['name', 'symbol', 'decimals', 'address'],

@@ -10,21 +10,12 @@ export const jsNumber = {

properties: {
from: {$ref: '/Address'},
to: {$ref: '/Address'},
from: { $ref: '/Address' },
to: { $ref: '/Address' },
value: {
oneOf: [
{$ref: '/Number'},
{$ref: '/JsNumber'},
],
oneOf: [{ $ref: '/Number' }, { $ref: '/JsNumber' }],
},
gas: {
oneOf: [
{$ref: '/Number'},
{$ref: '/JsNumber'},
],
oneOf: [{ $ref: '/Number' }, { $ref: '/JsNumber' }],
},
gasPrice: {
oneOf: [
{$ref: '/Number'},
{$ref: '/JsNumber'},
],
oneOf: [{ $ref: '/Number' }, { $ref: '/JsNumber' }],
},

@@ -31,0 +22,0 @@ data: {

@@ -1,4 +0,4 @@

export {ValidatorResult, Schema} from 'jsonschema';
export { ValidatorResult, Schema } from 'jsonschema';
export {SchemaValidator} from './schema_validator';
export {schemas} from './schemas';
export { SchemaValidator } from './schema_validator';
export { schemas } from './schemas';

@@ -1,5 +0,5 @@

import {Schema, Validator, ValidatorResult} from 'jsonschema';
import { Schema, Validator, ValidatorResult } from 'jsonschema';
import values = require('lodash.values');
import {schemas} from './schemas';
import { schemas } from './schemas';

@@ -6,0 +6,0 @@ export class SchemaValidator {

@@ -0,42 +1,14 @@

import { addressSchema, 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';
import { orderFillRequestsSchema } from '../schemas/order_fill_requests_schema';
import { orderHashSchema } from '../schemas/order_hash_schema';
import { orderSchema, signedOrderSchema } from '../schemas/order_schemas';
import { relayerApiErrorResponseSchema } from '../schemas/relayer_api_error_response_schema';
import { relayerApiFeesPayloadSchema } from '../schemas/relayer_api_fees_payload_schema';
import { relayerApiFeesResponseSchema } from '../schemas/relayer_api_fees_response_schema';
import {
addressSchema,
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';
import {
orderFillRequestsSchema,
} from '../schemas/order_fill_requests_schema';
import {
orderHashSchema,
} from '../schemas/order_hash_schema';
import {
orderSchema,
signedOrderSchema,
} from '../schemas/order_schemas';
import {
relayerApiErrorResponseSchema,
} from '../schemas/relayer_api_error_response_schema';
import {
relayerApiFeesPayloadSchema,
} from '../schemas/relayer_api_fees_payload_schema';
import {
relayerApiFeesResponseSchema,
} from '../schemas/relayer_api_fees_response_schema';
import {
relayerApiOrderbookChannelSubscribePayload,

@@ -49,22 +21,11 @@ relayerApiOrderbookChannelSubscribeSchema,

} from '../schemas/relayer_api_orderbook_channel_snapshot_schema';
import { relayerApiOrderbookChannelUpdateSchema } from '../schemas/relayer_api_orderbook_channel_update_response_schema';
import { relayerApiOrderBookResponseSchema } from '../schemas/relayer_api_orderbook_response_schema';
import {
relayerApiOrderbookChannelUpdateSchema,
} from '../schemas/relayer_api_orderbook_channel_update_response_schema';
import {
relayerApiOrderBookResponseSchema,
} from '../schemas/relayer_api_orderbook_response_schema';
import {
relayerApiTokenPairsResponseSchema,
relayerApiTokenTradeInfoSchema,
} from '../schemas/relayer_api_token_pairs_response_schema';
import {
signedOrdersSchema,
} from '../schemas/signed_orders_schema';
import {
tokenSchema,
} from '../schemas/token_schema';
import {
jsNumber,
txDataSchema,
} from '../schemas/tx_data_schema';
import { signedOrdersSchema } from '../schemas/signed_orders_schema';
import { tokenSchema } from '../schemas/token_schema';
import { jsNumber, txDataSchema } from '../schemas/tx_data_schema';

@@ -71,0 +32,0 @@ export const schemas = {

@@ -1,2 +0,2 @@

import BigNumber from 'bignumber.js';
import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';

@@ -7,3 +7,3 @@ import * as dirtyChai from 'dirty-chai';

import {schemas, SchemaValidator} from '../src/index';
import { schemas, SchemaValidator } from '../src/index';

@@ -98,5 +98,5 @@ chai.config.includeStack = true;

const testCases = [
'0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc3', // shorter
'0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc3', // shorter
'0xzzzz9190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254', // invalid characters
'40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254', // no 0x
'40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254', // no 0x
];

@@ -127,7 +127,3 @@ const shouldFail = true;

const s = '0x40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254';
const testCases = [
{},
{v},
{r, s, v: 31},
];
const testCases = [{}, { v }, { r, s, v: 31 }];
const shouldFail = true;

@@ -158,16 +154,7 @@ validateAgainstSchema(testCases, ecSignatureSchema, shouldFail);

it('should validate valid block param', () => {
const testCases = [
42,
'latest',
'pending',
'earliest',
];
const testCases = [42, 'latest', 'pending', 'earliest'];
validateAgainstSchema(testCases, blockParamSchema);
});
it('should fail for invalid block param', () => {
const testCases = [
{},
'42',
'pemding',
];
const testCases = [{}, '42', 'pemding'];
const shouldFail = true;

@@ -179,13 +166,7 @@ validateAgainstSchema(testCases, blockParamSchema, shouldFail);

it('should validate valid subscription opts', () => {
const testCases = [
{fromBlock: 42, toBlock: 'latest'},
{fromBlock: 42},
{},
];
const testCases = [{ fromBlock: 42, toBlock: 'latest' }, { fromBlock: 42 }, {}];
validateAgainstSchema(testCases, blockRangeSchema);
});
it('should fail for invalid subscription opts', () => {
const testCases = [
{fromBlock: '42'},
];
const testCases = [{ fromBlock: '42' }];
const shouldFail = true;

@@ -204,5 +185,3 @@ validateAgainstSchema(testCases, blockRangeSchema, shouldFail);

it('should validate valid token', () => {
const testCases = [
token,
];
const testCases = [token];
validateAgainstSchema(testCases, tokenSchema);

@@ -244,5 +223,3 @@ });

it('should validate valid order', () => {
const testCases = [
order,
];
const testCases = [order];
validateAgainstSchema(testCases, orderSchema);

@@ -277,15 +254,7 @@ });

it('should validate valid signed orders', () => {
const testCases = [
[signedOrder],
[],
];
const testCases = [[signedOrder], []];
validateAgainstSchema(testCases, signedOrdersSchema);
});
it('should fail for invalid signed orders', () => {
const testCases = [
[
signedOrder,
1,
],
];
const testCases = [[signedOrder, 1]];
const shouldFail = true;

@@ -297,5 +266,3 @@ validateAgainstSchema(testCases, signedOrdersSchema, shouldFail);

it('should validate valid signed order', () => {
const testCases = [
signedOrder,
];
const testCases = [signedOrder];
validateAgainstSchema(testCases, signedOrderSchema);

@@ -322,5 +289,3 @@ });

it('should validate valid order fill or kill requests', () => {
const testCases = [
orderFillOrKillRequests,
];
const testCases = [orderFillOrKillRequests];
validateAgainstSchema(testCases, orderFillOrKillRequestsSchema);

@@ -349,5 +314,3 @@ });

it('should validate valid order cancellation requests', () => {
const testCases = [
orderCancellationRequests,
];
const testCases = [orderCancellationRequests];
validateAgainstSchema(testCases, orderCancellationRequestsSchema);

@@ -376,5 +339,3 @@ });

it('should validate valid order fill requests', () => {
const testCases = [
orderFillRequests,
];
const testCases = [orderFillRequests];
validateAgainstSchema(testCases, orderFillRequestsSchema);

@@ -574,8 +535,4 @@ });

payload: {
bids: [
signedOrder,
],
asks: [
signedOrder,
],
bids: [signedOrder],
asks: [signedOrder],
},

@@ -593,8 +550,4 @@ },

payload: {
bids: [
signedOrder,
],
asks: [
signedOrder,
],
bids: [signedOrder],
asks: [signedOrder],
},

@@ -607,8 +560,4 @@ },

payload: {
bids: [
signedOrder,
],
asks: [
signedOrder,
],
bids: [signedOrder],
asks: [signedOrder],
},

@@ -620,8 +569,4 @@ },

payload: {
bids: [
signedOrder,
],
asks: [
signedOrder,
],
bids: [signedOrder],
asks: [signedOrder],
},

@@ -634,8 +579,4 @@ },

payload: {
bids: [
signedOrder,
],
asks: [
signedOrder,
],
bids: [signedOrder],
asks: [signedOrder],
},

@@ -648,5 +589,3 @@ },

payload: {
bids: [
signedOrder,
],
bids: [signedOrder],
},

@@ -659,5 +598,3 @@ },

payload: {
asks: [
signedOrder,
],
asks: [signedOrder],
},

@@ -670,8 +607,4 @@ },

payload: {
bids: [
signedOrder,
],
asks: [
{},
],
bids: [signedOrder],
asks: [{}],
},

@@ -684,8 +617,4 @@ },

payload: {
bids: [
{},
],
asks: [
signedOrder,
],
bids: [{}],
asks: [signedOrder],
},

@@ -965,14 +894,7 @@ },

it('should validate valid js number', () => {
const testCases = [
1,
42,
];
const testCases = [1, 42];
validateAgainstSchema(testCases, jsNumber);
});
it('should fail for invalid js number', () => {
const testCases = [
NaN,
-1,
new BigNumber(1),
];
const testCases = [NaN, -1, new BigNumber(1)];
const shouldFail = true;

@@ -979,0 +901,0 @@ validateAgainstSchema(testCases, jsNumber, shouldFail);

{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"lib": [ "es2017", "dom"],
"outDir": "lib",
"sourceMap": true,
"declaration": true,
"noImplicitAny": true,
"strictNullChecks": true
},
"include": [
"./src/**/*",
"./test/**/*",
"../../node_modules/chai-typescript-typings/index.d.ts"
]
"extends": "../../tsconfig",
"compilerOptions": {
"outDir": "lib"
},
"include": ["./src/**/*", "./test/**/*", "../../node_modules/chai-typescript-typings/index.d.ts"]
}
{
"extends": [
"@0xproject/tslint-config"
]
"extends": ["@0xproject/tslint-config"]
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc