aboutsummaryrefslogtreecommitdiffstats
path: root/packages/json-schemas/schemas
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2017-11-14 08:32:01 +0800
committerBrandon Millman <brandon.millman@gmail.com>2017-11-14 22:42:50 +0800
commit56b5619d24b44d23f770b58b0c9e1d4a63b89aca (patch)
tree52c047aa9ce6dbd5af93f495dbb21a8c3a662a6f /packages/json-schemas/schemas
parent08963f269b543d0f6f125ff77efdda23339865ed (diff)
downloaddexon-sol-tools-56b5619d24b44d23f770b58b0c9e1d4a63b89aca.tar.gz
dexon-sol-tools-56b5619d24b44d23f770b58b0c9e1d4a63b89aca.tar.zst
dexon-sol-tools-56b5619d24b44d23f770b58b0c9e1d4a63b89aca.zip
Add json-schemas package to mono repo
Diffstat (limited to 'packages/json-schemas/schemas')
-rw-r--r--packages/json-schemas/schemas/basic_type_schemas.ts11
-rw-r--r--packages/json-schemas/schemas/ec_signature_schema.ts20
-rw-r--r--packages/json-schemas/schemas/index_filter_values_schema.ts11
-rw-r--r--packages/json-schemas/schemas/order_cancel_schema.ts12
-rw-r--r--packages/json-schemas/schemas/order_fill_or_kill_requests_schema.ts12
-rw-r--r--packages/json-schemas/schemas/order_fill_requests_schema.ts12
-rw-r--r--packages/json-schemas/schemas/order_hash_schema.ts5
-rw-r--r--packages/json-schemas/schemas/order_schemas.ts35
-rw-r--r--packages/json-schemas/schemas/relayer_api_error_response_schema.ts21
-rw-r--r--packages/json-schemas/schemas/relayer_api_fees_payload_schema.ts19
-rw-r--r--packages/json-schemas/schemas/relayer_api_fees_response_schema.ts10
-rw-r--r--packages/json-schemas/schemas/relayer_api_orberbook_channel_subscribe_schema.ts22
-rw-r--r--packages/json-schemas/schemas/relayer_api_orderbook_channel_snapshot_schema.ts21
-rw-r--r--packages/json-schemas/schemas/relayer_api_orderbook_channel_update_response_schema.ts11
-rw-r--r--packages/json-schemas/schemas/relayer_api_orderbook_response_schema.ts9
-rw-r--r--packages/json-schemas/schemas/relayer_api_token_pairs_response_schema.ts24
-rw-r--r--packages/json-schemas/schemas/signed_orders_schema.ts5
-rw-r--r--packages/json-schemas/schemas/subscription_opts_schema.ts20
-rw-r--r--packages/json-schemas/schemas/token_schema.ts11
-rw-r--r--packages/json-schemas/schemas/tx_data_schema.ts42
20 files changed, 333 insertions, 0 deletions
diff --git a/packages/json-schemas/schemas/basic_type_schemas.ts b/packages/json-schemas/schemas/basic_type_schemas.ts
new file mode 100644
index 000000000..9d81ff333
--- /dev/null
+++ b/packages/json-schemas/schemas/basic_type_schemas.ts
@@ -0,0 +1,11 @@
+export const addressSchema = {
+ id: '/Address',
+ type: 'string',
+ pattern: '^0x[0-9a-f]{40}$',
+};
+
+export const numberSchema = {
+ id: '/Number',
+ type: 'string',
+ pattern: '^\\d+(\\.\\d+)?$',
+};
diff --git a/packages/json-schemas/schemas/ec_signature_schema.ts b/packages/json-schemas/schemas/ec_signature_schema.ts
new file mode 100644
index 000000000..2b769f3b6
--- /dev/null
+++ b/packages/json-schemas/schemas/ec_signature_schema.ts
@@ -0,0 +1,20 @@
+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/index_filter_values_schema.ts b/packages/json-schemas/schemas/index_filter_values_schema.ts
new file mode 100644
index 000000000..f7e323e45
--- /dev/null
+++ b/packages/json-schemas/schemas/index_filter_values_schema.ts
@@ -0,0 +1,11 @@
+export const indexFilterValuesSchema = {
+ id: '/IndexFilterValues',
+ additionalProperties: {
+ oneOf: [
+ {$ref: '/Number'},
+ {$ref: '/Address'},
+ {$ref: '/OrderHashSchema'},
+ ],
+ },
+ type: 'object',
+};
diff --git a/packages/json-schemas/schemas/order_cancel_schema.ts b/packages/json-schemas/schemas/order_cancel_schema.ts
new file mode 100644
index 000000000..ac7d2ee20
--- /dev/null
+++ b/packages/json-schemas/schemas/order_cancel_schema.ts
@@ -0,0 +1,12 @@
+export const orderCancellationRequestsSchema = {
+ id: '/OrderCancellationRequests',
+ type: 'array',
+ items: {
+ properties: {
+ order: {$ref: '/Order'},
+ takerTokenCancelAmount: {$ref: '/Number'},
+ },
+ required: ['order', 'takerTokenCancelAmount'],
+ type: 'object',
+ },
+};
diff --git a/packages/json-schemas/schemas/order_fill_or_kill_requests_schema.ts b/packages/json-schemas/schemas/order_fill_or_kill_requests_schema.ts
new file mode 100644
index 000000000..4ef7b069a
--- /dev/null
+++ b/packages/json-schemas/schemas/order_fill_or_kill_requests_schema.ts
@@ -0,0 +1,12 @@
+export const orderFillOrKillRequestsSchema = {
+ id: '/OrderFillOrKillRequests',
+ type: 'array',
+ items: {
+ properties: {
+ signedOrder: {$ref: '/SignedOrder'},
+ fillTakerAmount: {$ref: '/Number'},
+ },
+ required: ['signedOrder', 'fillTakerAmount'],
+ type: 'object',
+ },
+};
diff --git a/packages/json-schemas/schemas/order_fill_requests_schema.ts b/packages/json-schemas/schemas/order_fill_requests_schema.ts
new file mode 100644
index 000000000..ec19dd9f8
--- /dev/null
+++ b/packages/json-schemas/schemas/order_fill_requests_schema.ts
@@ -0,0 +1,12 @@
+export const orderFillRequestsSchema = {
+ id: '/OrderFillRequests',
+ type: 'array',
+ items: {
+ properties: {
+ signedOrder: {$ref: '/SignedOrder'},
+ takerTokenFillAmount: {$ref: '/Number'},
+ },
+ required: ['signedOrder', 'takerTokenFillAmount'],
+ type: 'object',
+ },
+};
diff --git a/packages/json-schemas/schemas/order_hash_schema.ts b/packages/json-schemas/schemas/order_hash_schema.ts
new file mode 100644
index 000000000..6af06927f
--- /dev/null
+++ b/packages/json-schemas/schemas/order_hash_schema.ts
@@ -0,0 +1,5 @@
+export const orderHashSchema = {
+ id: '/OrderHashSchema',
+ type: 'string',
+ pattern: '^0x[0-9a-fA-F]{64}$',
+};
diff --git a/packages/json-schemas/schemas/order_schemas.ts b/packages/json-schemas/schemas/order_schemas.ts
new file mode 100644
index 000000000..3cce49351
--- /dev/null
+++ b/packages/json-schemas/schemas/order_schemas.ts
@@ -0,0 +1,35 @@
+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'},
+ },
+ required: [
+ 'maker', 'taker', 'makerFee', 'takerFee', 'makerTokenAmount', 'takerTokenAmount',
+ 'salt', 'feeRecipient', 'expirationUnixTimestampSec', 'exchangeContractAddress',
+ ],
+ type: 'object',
+};
+
+export const signedOrderSchema = {
+ id: '/SignedOrder',
+ allOf: [
+ { $ref: '/Order' },
+ {
+ properties: {
+ ecSignature: {$ref: '/ECSignature'},
+ },
+ required: ['ecSignature'],
+ },
+ ],
+};
diff --git a/packages/json-schemas/schemas/relayer_api_error_response_schema.ts b/packages/json-schemas/schemas/relayer_api_error_response_schema.ts
new file mode 100644
index 000000000..eacbb2bce
--- /dev/null
+++ b/packages/json-schemas/schemas/relayer_api_error_response_schema.ts
@@ -0,0 +1,21 @@
+export const relayerApiErrorResponseSchema = {
+ id: '/RelayerApiErrorResponse',
+ type: 'object',
+ properties: {
+ code: {type: 'number'},
+ reason: {type: 'string'},
+ validationErrors: {
+ type: 'array',
+ items: {
+ type: 'object',
+ properties: {
+ field: {type: 'string'},
+ code: {type: 'number'},
+ reason: {type: 'string'},
+ },
+ required: ['field', 'code', 'reason'],
+ },
+ },
+ },
+ required: ['code', 'reason'],
+};
diff --git a/packages/json-schemas/schemas/relayer_api_fees_payload_schema.ts b/packages/json-schemas/schemas/relayer_api_fees_payload_schema.ts
new file mode 100644
index 000000000..645660844
--- /dev/null
+++ b/packages/json-schemas/schemas/relayer_api_fees_payload_schema.ts
@@ -0,0 +1,19 @@
+export const relayerApiFeesPayloadSchema = {
+ id: '/RelayerApiFeesPayload',
+ type: 'object',
+ 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'},
+ },
+ required: [
+ 'exchangeContractAddress', 'maker', 'taker', 'makerTokenAddress', 'takerTokenAddress',
+ 'expirationUnixTimestampSec', 'salt',
+ ],
+};
diff --git a/packages/json-schemas/schemas/relayer_api_fees_response_schema.ts b/packages/json-schemas/schemas/relayer_api_fees_response_schema.ts
new file mode 100644
index 000000000..86e51feb0
--- /dev/null
+++ b/packages/json-schemas/schemas/relayer_api_fees_response_schema.ts
@@ -0,0 +1,10 @@
+export const relayerApiFeesResponseSchema = {
+ id: '/RelayerApiFeesResponse',
+ type: 'object',
+ properties: {
+ makerFee: {$ref: '/Number'},
+ takerFee: {$ref: '/Number'},
+ feeRecipient: {$ref: '/Address'},
+ },
+ required: ['makerFee', 'takerFee', 'feeRecipient'],
+};
diff --git a/packages/json-schemas/schemas/relayer_api_orberbook_channel_subscribe_schema.ts b/packages/json-schemas/schemas/relayer_api_orberbook_channel_subscribe_schema.ts
new file mode 100644
index 000000000..8ded9adb0
--- /dev/null
+++ b/packages/json-schemas/schemas/relayer_api_orberbook_channel_subscribe_schema.ts
@@ -0,0 +1,22 @@
+export const relayerApiOrderbookChannelSubscribeSchema = {
+ id: '/RelayerApiOrderbookChannelSubscribe',
+ type: 'object',
+ properties: {
+ type: {enum: ['subscribe']},
+ channel: {enum: ['orderbook']},
+ payload: {$ref: '/RelayerApiOrderbookChannelSubscribePayload'},
+ },
+ required: ['type', 'channel', 'payload'],
+};
+
+export const relayerApiOrderbookChannelSubscribePayload = {
+ id: '/RelayerApiOrderbookChannelSubscribePayload',
+ type: 'object',
+ properties: {
+ baseTokenAddress: {$ref: '/Address'},
+ quoteTokenAddress: {$ref: '/Address'},
+ snapshot: {type: 'boolean'},
+ limit: {type: 'number'},
+ },
+ required: ['baseTokenAddress', 'quoteTokenAddress'],
+};
diff --git a/packages/json-schemas/schemas/relayer_api_orderbook_channel_snapshot_schema.ts b/packages/json-schemas/schemas/relayer_api_orderbook_channel_snapshot_schema.ts
new file mode 100644
index 000000000..cfc0ddc8f
--- /dev/null
+++ b/packages/json-schemas/schemas/relayer_api_orderbook_channel_snapshot_schema.ts
@@ -0,0 +1,21 @@
+export const relayerApiOrderbookChannelSnapshotSchema = {
+ id: '/RelayerApiOrderbookChannelSnapshot',
+ type: 'object',
+ properties: {
+ type: {enum: ['snapshot']},
+ channel: {enum: ['orderbook']},
+ channelId: {type: 'number'},
+ payload: {$ref: '/RelayerApiOrderbookChannelSnapshotPayload'},
+ },
+ required: ['type', 'channel', 'channelId', 'payload'],
+};
+
+export const relayerApiOrderbookChannelSnapshotPayload = {
+ id: '/RelayerApiOrderbookChannelSnapshotPayload',
+ type: 'object',
+ properties: {
+ bids: {$ref: '/signedOrdersSchema'},
+ asks: {$ref: '/signedOrdersSchema'},
+ },
+ required: ['bids', 'asks'],
+};
diff --git a/packages/json-schemas/schemas/relayer_api_orderbook_channel_update_response_schema.ts b/packages/json-schemas/schemas/relayer_api_orderbook_channel_update_response_schema.ts
new file mode 100644
index 000000000..51308ed49
--- /dev/null
+++ b/packages/json-schemas/schemas/relayer_api_orderbook_channel_update_response_schema.ts
@@ -0,0 +1,11 @@
+export const relayerApiOrderbookChannelUpdateSchema = {
+ id: '/RelayerApiOrderbookChannelUpdate',
+ type: 'object',
+ properties: {
+ type: {enum: ['update']},
+ channel: {enum: ['orderbook']},
+ channelId: {type: 'number'},
+ payload: {$ref: '/SignedOrder'},
+ },
+ required: ['type', 'channel', 'channelId', 'payload'],
+};
diff --git a/packages/json-schemas/schemas/relayer_api_orderbook_response_schema.ts b/packages/json-schemas/schemas/relayer_api_orderbook_response_schema.ts
new file mode 100644
index 000000000..b592d4f8e
--- /dev/null
+++ b/packages/json-schemas/schemas/relayer_api_orderbook_response_schema.ts
@@ -0,0 +1,9 @@
+export const relayerApiOrderBookResponseSchema = {
+ id: '/RelayerApiOrderBookResponse',
+ type: 'object',
+ properties: {
+ bids: {$ref: '/signedOrdersSchema'},
+ asks: {$ref: '/signedOrdersSchema'},
+ },
+ required: ['bids', 'asks'],
+};
diff --git a/packages/json-schemas/schemas/relayer_api_token_pairs_response_schema.ts b/packages/json-schemas/schemas/relayer_api_token_pairs_response_schema.ts
new file mode 100644
index 000000000..8ecab1424
--- /dev/null
+++ b/packages/json-schemas/schemas/relayer_api_token_pairs_response_schema.ts
@@ -0,0 +1,24 @@
+export const relayerApiTokenPairsResponseSchema = {
+ id: '/RelayerApiTokenPairsResponse',
+ type: 'array',
+ items: {
+ properties: {
+ tokenA: {$ref: '/RelayerApiTokenTradeInfo'},
+ tokenB: {$ref: '/RelayerApiTokenTradeInfo'},
+ },
+ required: ['tokenA', 'tokenB'],
+ type: 'object',
+ },
+};
+
+export const relayerApiTokenTradeInfoSchema = {
+ id: '/RelayerApiTokenTradeInfo',
+ type: 'object',
+ properties: {
+ address: {$ref: '/Address'},
+ minAmount: {$ref: '/Number'},
+ maxAmount: {$ref: '/Number'},
+ precision: {type: 'number'},
+ },
+ required: ['address'],
+};
diff --git a/packages/json-schemas/schemas/signed_orders_schema.ts b/packages/json-schemas/schemas/signed_orders_schema.ts
new file mode 100644
index 000000000..c4c4a68ac
--- /dev/null
+++ b/packages/json-schemas/schemas/signed_orders_schema.ts
@@ -0,0 +1,5 @@
+export const signedOrdersSchema = {
+ id: '/signedOrdersSchema',
+ type: 'array',
+ items: {$ref: '/SignedOrder'},
+};
diff --git a/packages/json-schemas/schemas/subscription_opts_schema.ts b/packages/json-schemas/schemas/subscription_opts_schema.ts
new file mode 100644
index 000000000..a476e6963
--- /dev/null
+++ b/packages/json-schemas/schemas/subscription_opts_schema.ts
@@ -0,0 +1,20 @@
+export const blockParamSchema = {
+ id: '/BlockParam',
+ oneOf: [
+ {
+ type: 'number',
+ },
+ {
+ enum: ['latest', 'earliest', 'pending'],
+ },
+ ],
+};
+
+export const subscriptionOptsSchema = {
+ id: '/SubscriptionOpts',
+ properties: {
+ fromBlock: {$ref: '/BlockParam'},
+ toBlock: {$ref: '/BlockParam'},
+ },
+ type: 'object',
+};
diff --git a/packages/json-schemas/schemas/token_schema.ts b/packages/json-schemas/schemas/token_schema.ts
new file mode 100644
index 000000000..aca4d4ad2
--- /dev/null
+++ b/packages/json-schemas/schemas/token_schema.ts
@@ -0,0 +1,11 @@
+export const tokenSchema = {
+ id: '/Token',
+ properties: {
+ name: {type: 'string'},
+ symbol: {type: 'string'},
+ decimals: {type: 'number'},
+ address: {$ref: '/Address'},
+ },
+ required: ['name', 'symbol', 'decimals', 'address'],
+ type: 'object',
+};
diff --git a/packages/json-schemas/schemas/tx_data_schema.ts b/packages/json-schemas/schemas/tx_data_schema.ts
new file mode 100644
index 000000000..41eaadd3c
--- /dev/null
+++ b/packages/json-schemas/schemas/tx_data_schema.ts
@@ -0,0 +1,42 @@
+export const jsNumber = {
+ id: '/JsNumber',
+ type: 'number',
+ minimum: 0,
+};
+
+export const txDataSchema = {
+ id: '/TxData',
+ properties: {
+ from: {$ref: '/Address'},
+ to: {$ref: '/Address'},
+ value: {
+ oneOf: [
+ {$ref: '/Number'},
+ {$ref: '/JsNumber'},
+ ],
+ },
+ gas: {
+ oneOf: [
+ {$ref: '/Number'},
+ {$ref: '/JsNumber'},
+ ],
+ },
+ gasPrice: {
+ oneOf: [
+ {$ref: '/Number'},
+ {$ref: '/JsNumber'},
+ ],
+ },
+ data: {
+ type: 'string',
+ pattern: '^0x[0-9a-f]*$',
+ },
+ nonce: {
+ type: 'number',
+ minimum: 0,
+ },
+ },
+ required: ['from'],
+ type: 'object',
+ additionalProperties: false,
+};