Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Move json-schema schemas to JSON files #1145

Merged
merged 15 commits into from
Oct 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ lib
/packages/contracts/generated-artifacts
/packages/abi-gen-wrappers/src/generated-wrappers
/packages/contract-artifacts/artifacts
/packages/json-schemas/schemas
/packages/metacoin/src/contract_wrappers
/packages/metacoin/artifacts
/packages/sra-spec/public/
Expand Down
2 changes: 1 addition & 1 deletion packages/0x.js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"sinon": "^4.0.0",
"source-map-support": "^0.5.0",
"tslint": "5.11.0",
"typedoc": "0.12.0",
"typedoc": "0.13.0",
"typescript": "3.0.1",
"uglifyjs-webpack-plugin": "^2.0.1",
"webpack": "^4.20.2"
Expand Down
2 changes: 1 addition & 1 deletion packages/asset-buyer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"nyc": "^11.0.1",
"shx": "^0.2.2",
"tslint": "5.11.0",
"typedoc": "0.12.0",
"typedoc": "0.13.0",
"typescript": "3.0.1"
},
"publishConfig": {
Expand Down
3 changes: 2 additions & 1 deletion packages/base-contract/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ export class BaseContract {
if (abiDefinition.type !== AbiType.Function) {
return false;
}
const abiFunctionSignature = abiUtils.getFunctionSignature(abiDefinition);
// tslint:disable-next-line:no-unnecessary-type-assertion
const abiFunctionSignature = abiUtils.getFunctionSignature(abiDefinition as MethodAbi);
if (abiFunctionSignature === functionSignature) {
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/connect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"nyc": "^11.0.1",
"shx": "^0.2.2",
"tslint": "5.11.0",
"typedoc": "0.12.0",
"typedoc": "0.13.0",
"typescript": "3.0.1"
},
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/connect/src/utils/assert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const assert = {
sharedAssert.doesConformToSchema(
variableName,
subscriptionOpts,
schemas.relayerApiOrdersChannelSubscribePayload,
schemas.relayerApiOrdersChannelSubscribePayloadSchema,
);
},
isOrdersChannelHandler(variableName: string, handler: any): void {
Expand Down
2 changes: 1 addition & 1 deletion packages/contract-wrappers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"sinon": "^4.0.0",
"source-map-support": "^0.5.0",
"tslint": "5.11.0",
"typedoc": "0.12.0",
"typedoc": "0.13.0",
"typescript": "3.0.1",
"web3-provider-engine": "14.0.6"
},
Expand Down
16 changes: 12 additions & 4 deletions packages/ethereum-types/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ export type ConstructorStateMutability = 'nonpayable' | 'payable';
export type StateMutability = 'pure' | 'view' | ConstructorStateMutability;

export interface MethodAbi {
type: 'function'; // We hardcode this here b/c doc pages cannot render an enum value
// Ideally this would be set to: `'function'` but then TS complains when artifacts are loaded
// from JSON files, and this value has type `string` not type `'function'`
type: string;
name: string;
inputs: DataItem[];
outputs: DataItem[];
Expand All @@ -30,14 +32,18 @@ export interface MethodAbi {
}

export interface ConstructorAbi {
type: 'constructor'; // We hardcode this here b/c doc pages cannot render an enum value
// Ideally this would be set to: `'constructor'` but then TS complains when artifacts are loaded
// from JSON files, and this value has type `string` not type `'constructor'`
type: string;
inputs: DataItem[];
payable: boolean;
stateMutability: ConstructorStateMutability;
}

export interface FallbackAbi {
type: 'fallback'; // We hardcode this here b/c doc pages cannot render an enum value
// Ideally this would be set to: `'fallback'` but then TS complains when artifacts are loaded
// from JSON files, and this value has type `string` not type `'fallback'`
type: string;
payable: boolean;
}

Expand All @@ -46,7 +52,9 @@ export interface EventParameter extends DataItem {
}

export interface EventAbi {
type: 'event'; // We hardcode this here b/c doc pages cannot render an enum value
// Ideally this would be set to: `'event'` but then TS complains when artifacts are loaded
// from JSON files, and this value has type `string` not type `'event'`
type: string;
name: string;
inputs: EventParameter[];
anonymous: boolean;
Expand Down
2 changes: 1 addition & 1 deletion packages/instant/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"shx": "^0.2.2",
"ts-jest": "^23.10.3",
"tslint": "5.11.0",
"typedoc": "0.12.0",
"typedoc": "0.13.0",
"typescript": "3.0.1",
"webpack": "^4.20.2",
"webpack-cli": "^3.1.1",
Expand Down
10 changes: 10 additions & 0 deletions packages/json-schemas/CHANGELOG.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
[
{
"version": "2.0.0",
"changes": [
{
"note":
"Convert all schemas to JSON files so that they can be used with `json-schema` implemenations in other programming languages.",
"pr": 1145
}
]
},
{
"timestamp": 1538693146,
"version": "1.0.7",
Expand Down
4 changes: 2 additions & 2 deletions packages/json-schemas/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"scripts": {
"build": "tsc -b",
"build:ci": "yarn build",
"lint": "tslint --project .",
"lint": "tslint --project . --exclude **/schemas/**/*",
"test": "yarn run_mocha",
"rebuild_and_test": "run-s clean build test",
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
Expand Down Expand Up @@ -59,7 +59,7 @@
"nyc": "^11.0.1",
"shx": "^0.2.2",
"tslint": "5.11.0",
"typedoc": "0.12.0",
"typedoc": "0.13.0",
"typescript": "3.0.1"
},
"publishConfig": {
Expand Down
5 changes: 5 additions & 0 deletions packages/json-schemas/schemas/address_schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"id": "/addressSchema",
"type": "string",
"pattern": "^0x[0-9a-f]{40}$"
}
17 changes: 0 additions & 17 deletions packages/json-schemas/schemas/basic_type_schemas.ts

This file was deleted.

11 changes: 11 additions & 0 deletions packages/json-schemas/schemas/block_param_schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"id": "/blockParamSchema",
"oneOf": [
{
"type": "number"
},
{
"enum": ["latest", "earliest", "pending"]
}
]
}
8 changes: 8 additions & 0 deletions packages/json-schemas/schemas/block_range_schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"id": "/blockRangeSchema",
"properties": {
"fromBlock": { "$ref": "/blockParamSchema" },
"toBlock": { "$ref": "/blockParamSchema" }
},
"type": "object"
}
20 changes: 0 additions & 20 deletions packages/json-schemas/schemas/block_range_schema.ts

This file was deleted.

27 changes: 27 additions & 0 deletions packages/json-schemas/schemas/call_data_schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"id": "/callDataSchema",
"properties": {
"from": { "$ref": "/addressSchema" },
"to": { "$ref": "/addressSchema" },
"value": {
"oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/jsNumber" }]
},
"gas": {
"oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/jsNumber" }]
},
"gasPrice": {
"oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/jsNumber" }]
},
"data": {
"type": "string",
"pattern": "^0x[0-9a-f]*$"
},
"nonce": {
"type": "number",
"minimum": 0
}
},
"required": [],
"type": "object",
"additionalProperties": false
}
27 changes: 0 additions & 27 deletions packages/json-schemas/schemas/call_data_schema.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"id": "/ecSignatureParameterSchema",
"type": "string",
"pattern": "^0[xX][0-9A-Fa-f]{64}$"
}
14 changes: 14 additions & 0 deletions packages/json-schemas/schemas/ec_signature_schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"id": "/ECSignature",
"properties": {
"v": {
"type": "number",
"minimum": 27,
"maximum": 28
},
"r": { "$ref": "/ecSignatureParameterSchema" },
"s": { "$ref": "/ecSignatureParameterSchema" }
},
"required": ["v", "r", "s"],
"type": "object"
}
20 changes: 0 additions & 20 deletions packages/json-schemas/schemas/ec_signature_schema.ts

This file was deleted.

28 changes: 0 additions & 28 deletions packages/json-schemas/schemas/eip712_typed_data.ts

This file was deleted.

28 changes: 28 additions & 0 deletions packages/json-schemas/schemas/eip712_typed_data_schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"id": "/eip712TypedDataSchema",
"type": "object",
"properties": {
"types": {
"type": "object",
"properties": {
"EIP712Domain": { "type": "array" }
},
"additionalProperties": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": { "type": "string" },
"type": { "type": "string" }
},
"required": ["name", "type"]
}
},
"required": ["EIP712Domain"]
},
"primaryType": { "type": "string" },
"domain": { "type": "object" },
"message": { "type": "object" }
},
"required": ["types", "primaryType", "domain", "message"]
}
5 changes: 5 additions & 0 deletions packages/json-schemas/schemas/hex_schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"id": "/hexSchema",
"type": "string",
"pattern": "^0x(([0-9a-f][0-9a-f])+)?$"
}
7 changes: 7 additions & 0 deletions packages/json-schemas/schemas/index_filter_values_schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"id": "/indexFilterValuesSchema",
"additionalProperties": {
"oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/addressSchema" }, { "$ref": "/orderHashSchema" }]
},
"type": "object"
}
7 changes: 0 additions & 7 deletions packages/json-schemas/schemas/index_filter_values_schema.ts

This file was deleted.

5 changes: 5 additions & 0 deletions packages/json-schemas/schemas/js_number.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"id": "/jsNumber",
"type": "number",
"minimum": 0
}
Loading