aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
Diffstat (limited to 'packages')
-rw-r--r--packages/sra-report/.npmignore5
-rw-r--r--packages/sra-report/CHANGELOG.md1
-rw-r--r--packages/sra-report/README.md53
-rw-r--r--packages/sra-report/package.json42
-rw-r--r--packages/sra-report/postman_configs/collections/sra_report.postman_collection.json384
-rw-r--r--packages/sra-report/postman_configs/environments/kovan_tokens.postman_environment.json34
-rw-r--r--packages/sra-report/postman_configs/environments/mainnet_tokens.postman_environment.json28
-rw-r--r--packages/sra-report/scripts/postpublish.js5
-rw-r--r--packages/sra-report/src/globals.d.ts6
-rw-r--r--packages/sra-report/src/index.ts108
-rw-r--r--packages/sra-report/src/types.ts3
-rw-r--r--packages/sra-report/src/utils.ts5
-rw-r--r--packages/sra-report/tsconfig.json7
-rw-r--r--packages/sra-report/tslint.json3
14 files changed, 684 insertions, 0 deletions
diff --git a/packages/sra-report/.npmignore b/packages/sra-report/.npmignore
new file mode 100644
index 000000000..87bc30436
--- /dev/null
+++ b/packages/sra-report/.npmignore
@@ -0,0 +1,5 @@
+.*
+yarn-error.log
+/src/
+/scripts/
+tsconfig.json
diff --git a/packages/sra-report/CHANGELOG.md b/packages/sra-report/CHANGELOG.md
new file mode 100644
index 000000000..a0cf709bc
--- /dev/null
+++ b/packages/sra-report/CHANGELOG.md
@@ -0,0 +1 @@
+# CHANGELOG
diff --git a/packages/sra-report/README.md b/packages/sra-report/README.md
new file mode 100644
index 000000000..18802f06a
--- /dev/null
+++ b/packages/sra-report/README.md
@@ -0,0 +1,53 @@
+# SRA Report
+
+This package allows you to generate reports detailing an endpoint's [standard relayer API HTTP specification](https://github.com/0xProject/standard-relayer-api/blob/master/http/v0.md) compliance.
+
+## Installation
+
+`yarn add -g @0xproject/sra-report`
+
+## Usage
+
+```
+abi-gen
+Options:
+ --help Show help [boolean]
+ --version Show version number [boolean]
+ --url, -u API endpoint to test for standard relayer API compliance
+ [string] [required]
+ --output, -o, --out Folder where to write the reports [string]
+ --network-id, -n ID of the network that the API is serving orders from
+ [number] [default: 1]
+```
+
+## Contributing
+
+We strongly encourage that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository.
+
+Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
+
+### Install Dependencies
+
+If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
+
+```bash
+yarn config set workspaces-experimental true
+```
+
+Then install dependencies
+
+```bash
+yarn install
+```
+
+### Build
+
+```bash
+yarn build
+```
+
+### Lint
+
+```bash
+yarn lint
+```
diff --git a/packages/sra-report/package.json b/packages/sra-report/package.json
new file mode 100644
index 000000000..0eaa5277e
--- /dev/null
+++ b/packages/sra-report/package.json
@@ -0,0 +1,42 @@
+{
+ "name": "@0xproject/sra-report",
+ "version": "0.0.1",
+ "description": "Generate reports for standard relayer API compliance",
+ "main": "lib/index.js",
+ "types": "lib/index.d.ts",
+ "scripts": {
+ "build:watch": "tsc -w",
+ "lint": "tslint --project . 'src/**/*.ts'",
+ "clean": "shx rm -rf lib",
+ "build": "tsc"
+ },
+ "bin": {
+ "sra-report": "lib/index.js"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/0xProject/0x.js.git"
+ },
+ "license": "Apache-2.0",
+ "bugs": {
+ "url": "https://github.com/0xProject/0x.js/issues"
+ },
+ "homepage": "https://github.com/0xProject/0x.js/packages/abi-gen/README.md",
+ "dependencies": {
+ "@0xproject/assert": "^0.0.20",
+ "@0xproject/json-schemas": "^0.7.12",
+ "chalk": "^2.3.0",
+ "lodash": "^4.17.4",
+ "newman": "^3.9.3",
+ "yargs": "^10.0.3"
+ },
+ "devDependencies": {
+ "@0xproject/tslint-config": "^0.4.9",
+ "@types/lodash": "^4.14.104",
+ "@types/node": "^8.0.53",
+ "@types/yargs": "^10.0.0",
+ "shx": "^0.2.2",
+ "tslint": "5.8.0",
+ "typescript": "2.7.1"
+ }
+}
diff --git a/packages/sra-report/postman_configs/collections/sra_report.postman_collection.json b/packages/sra-report/postman_configs/collections/sra_report.postman_collection.json
new file mode 100644
index 000000000..861f040f7
--- /dev/null
+++ b/packages/sra-report/postman_configs/collections/sra_report.postman_collection.json
@@ -0,0 +1,384 @@
+{
+ "info": {
+ "name": "0x Standard Relayer API",
+ "_postman_id": "d5828163-ddb9-46a9-ec39-c2b81417b6c0",
+ "description":
+ "[Standard Relayer Api](\nhttps://github.com/0xProject/standard-relayer-api)\n\n\n0x Protocol is an open standard. Because of this, we expect many independent applications to be built that will want to use the protocol. In order to make it easier for anyone to source liquidity that conforms to the 0x order format, relayers can opt-in to implementing a set of standard relayer API endpoints. In doing so, they allow clients of the standard relayer API to access the orders on their orderbook.",
+ "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
+ },
+ "item": [
+ {
+ "name": "GET /token_pairs",
+ "description": "",
+ "item": [
+ {
+ "name": "Default",
+ "event": [
+ {
+ "listen": "test",
+ "script": {
+ "id": "e25cd907-44f8-4d1e-823a-429d6244e6b4",
+ "type": "text/javascript",
+ "exec": [""]
+ }
+ }
+ ],
+ "request": {
+ "method": "GET",
+ "header": [],
+ "body": {},
+ "url": {
+ "raw": "{{url}}/v0/token_pairs",
+ "host": ["{{url}}"],
+ "path": ["v0", "token_pairs"]
+ },
+ "description":
+ "Retrieves a list of orders given query parameters. For querying an entire orderbook snapshot, the orderbook endpoint is recommended.\n\nParameters\n * exchangeContractAddress [string]: returns orders created for this exchange address\n * tokenAddress [string]: returns orders where makerTokenAddress or takerTokenAddress is token address\n * makerTokenAddress [string]: returns orders with specified makerTokenAddress\n * takerTokenAddress [string]: returns orders with specified makerTokenAddress\n * maker [string]: returns orders where maker is maker address\n * taker [string]: returns orders where taker is taker address\n * trader [string]: returns orders where maker or taker is trader address\n * feeRecipient [string]: returns orders where feeRecipient is feeRecipient address\n\nAll parameters are optional."
+ },
+ "response": []
+ },
+ {
+ "name": "DAI pairs",
+ "event": [
+ {
+ "listen": "test",
+ "script": {
+ "id": "cb6e73f9-f5a7-4d75-807a-c9db94dda4f3",
+ "type": "text/javascript",
+ "exec": [""]
+ }
+ }
+ ],
+ "request": {
+ "method": "GET",
+ "header": [],
+ "body": {},
+ "url": {
+ "raw": "{{url}}/v0/token_pairs?tokenA={{DAI_address}}",
+ "host": ["{{url}}"],
+ "path": ["v0", "token_pairs"],
+ "query": [
+ {
+ "key": "tokenA",
+ "value": "{{DAI_address}}",
+ "equals": true
+ }
+ ]
+ },
+ "description":
+ "Retrieves a list of orders given query parameters. For querying an entire orderbook snapshot, the orderbook endpoint is recommended.\n\nParameters\n * exchangeContractAddress [string]: returns orders created for this exchange address\n * tokenAddress [string]: returns orders where makerTokenAddress or takerTokenAddress is token address\n * makerTokenAddress [string]: returns orders with specified makerTokenAddress\n * takerTokenAddress [string]: returns orders with specified makerTokenAddress\n * maker [string]: returns orders where maker is maker address\n * taker [string]: returns orders where taker is taker address\n * trader [string]: returns orders where maker or taker is trader address\n * feeRecipient [string]: returns orders where feeRecipient is feeRecipient address\n\nAll parameters are optional."
+ },
+ "response": []
+ },
+ {
+ "name": "WETH pairs",
+ "event": [
+ {
+ "listen": "test",
+ "script": {
+ "id": "cb6e73f9-f5a7-4d75-807a-c9db94dda4f3",
+ "type": "text/javascript",
+ "exec": [""]
+ }
+ }
+ ],
+ "request": {
+ "method": "GET",
+ "header": [],
+ "body": {},
+ "url": {
+ "raw": "{{url}}/v0/token_pairs?tokenA={{WETH_address}}",
+ "host": ["{{url}}"],
+ "path": ["v0", "token_pairs"],
+ "query": [
+ {
+ "key": "tokenA",
+ "value": "{{WETH_address}}",
+ "equals": true
+ }
+ ]
+ },
+ "description":
+ "Retrieves a list of orders given query parameters. For querying an entire orderbook snapshot, the orderbook endpoint is recommended.\n\nParameters\n * exchangeContractAddress [string]: returns orders created for this exchange address\n * tokenAddress [string]: returns orders where makerTokenAddress or takerTokenAddress is token address\n * makerTokenAddress [string]: returns orders with specified makerTokenAddress\n * takerTokenAddress [string]: returns orders with specified makerTokenAddress\n * maker [string]: returns orders where maker is maker address\n * taker [string]: returns orders where taker is taker address\n * trader [string]: returns orders where maker or taker is trader address\n * feeRecipient [string]: returns orders where feeRecipient is feeRecipient address\n\nAll parameters are optional."
+ },
+ "response": []
+ }
+ ]
+ },
+ {
+ "name": "GET /orders",
+ "description": "",
+ "item": [
+ {
+ "name": "Default",
+ "event": [
+ {
+ "listen": "test",
+ "script": {
+ "id": "742679e1-5c16-4fe3-8056-dc7d34257564",
+ "type": "text/javascript",
+ "exec": [
+ "const orders = JSON.parse(responseBody);",
+ "const firstOrder = orders[0];",
+ "const firstOrderHash = _.get(firstOrder, \"orderHash\");",
+ "pm.globals.set(\"_orderHash\", firstOrderHash);"
+ ]
+ }
+ }
+ ],
+ "request": {
+ "method": "GET",
+ "header": [],
+ "body": {},
+ "url": {
+ "raw": "{{url}}/v0/orders",
+ "host": ["{{url}}"],
+ "path": ["v0", "orders"]
+ },
+ "description":
+ "Retrieves a list of orders given query parameters. For querying an entire orderbook snapshot, the orderbook endpoint is recommended.\n\nParameters\n * exchangeContractAddress [string]: returns orders created for this exchange address\n * tokenAddress [string]: returns orders where makerTokenAddress or takerTokenAddress is token address\n * makerTokenAddress [string]: returns orders with specified makerTokenAddress\n * takerTokenAddress [string]: returns orders with specified makerTokenAddress\n * maker [string]: returns orders where maker is maker address\n * taker [string]: returns orders where taker is taker address\n * trader [string]: returns orders where maker or taker is trader address\n * feeRecipient [string]: returns orders where feeRecipient is feeRecipient address\n\nAll parameters are optional."
+ },
+ "response": []
+ },
+ {
+ "name": "DAI orders",
+ "event": [
+ {
+ "listen": "test",
+ "script": {
+ "id": "a1eabd96-fee3-4328-ae50-4a992f0401ba",
+ "type": "text/javascript",
+ "exec": [""]
+ }
+ }
+ ],
+ "request": {
+ "method": "GET",
+ "header": [],
+ "body": {},
+ "url": {
+ "raw": "{{url}}/v0/orders?tokenAddress={{DAI_address}}",
+ "host": ["{{url}}"],
+ "path": ["v0", "orders"],
+ "query": [
+ {
+ "key": "tokenAddress",
+ "value": "{{DAI_address}}",
+ "equals": true
+ }
+ ]
+ },
+ "description":
+ "Retrieves a list of orders given query parameters. For querying an entire orderbook snapshot, the orderbook endpoint is recommended.\n\nParameters\n * exchangeContractAddress [string]: returns orders created for this exchange address\n * tokenAddress [string]: returns orders where makerTokenAddress or takerTokenAddress is token address\n * makerTokenAddress [string]: returns orders with specified makerTokenAddress\n * takerTokenAddress [string]: returns orders with specified makerTokenAddress\n * maker [string]: returns orders where maker is maker address\n * taker [string]: returns orders where taker is taker address\n * trader [string]: returns orders where maker or taker is trader address\n * feeRecipient [string]: returns orders where feeRecipient is feeRecipient address\n\nAll parameters are optional."
+ },
+ "response": []
+ },
+ {
+ "name": "WETH orders",
+ "event": [
+ {
+ "listen": "test",
+ "script": {
+ "id": "1a0acd0e-5e4a-4e08-b4e9-291a4e9c433a",
+ "type": "text/javascript",
+ "exec": [""]
+ }
+ }
+ ],
+ "request": {
+ "method": "GET",
+ "header": [],
+ "body": {},
+ "url": {
+ "raw": "{{url}}/v0/orders?tokenAddress={{WETH_address}}",
+ "host": ["{{url}}"],
+ "path": ["v0", "orders"],
+ "query": [
+ {
+ "key": "tokenAddress",
+ "value": "{{WETH_address}}",
+ "equals": true
+ }
+ ]
+ },
+ "description":
+ "Retrieves a list of orders given query parameters. For querying an entire orderbook snapshot, the orderbook endpoint is recommended.\n\nParameters\n * exchangeContractAddress [string]: returns orders created for this exchange address\n * tokenAddress [string]: returns orders where makerTokenAddress or takerTokenAddress is token address\n * makerTokenAddress [string]: returns orders with specified makerTokenAddress\n * takerTokenAddress [string]: returns orders with specified makerTokenAddress\n * maker [string]: returns orders where maker is maker address\n * taker [string]: returns orders where taker is taker address\n * trader [string]: returns orders where maker or taker is trader address\n * feeRecipient [string]: returns orders where feeRecipient is feeRecipient address\n\nAll parameters are optional."
+ },
+ "response": []
+ }
+ ],
+ "event": [
+ {
+ "listen": "prerequest",
+ "script": {
+ "id": "4eafcc26-fb01-4182-b963-67a0b418fcbc",
+ "type": "text/javascript",
+ "exec": [""]
+ }
+ },
+ {
+ "listen": "test",
+ "script": {
+ "id": "d28effd1-4a73-4ee8-82cc-21b1ab06928d",
+ "type": "text/javascript",
+ "exec": [""]
+ }
+ }
+ ]
+ },
+ {
+ "name": "GET /orderbook",
+ "description": "",
+ "item": [
+ {
+ "name": "ZRX/WETH orderbook",
+ "event": [
+ {
+ "listen": "test",
+ "script": {
+ "id": "1a0acd0e-5e4a-4e08-b4e9-291a4e9c433a",
+ "type": "text/javascript",
+ "exec": [""]
+ }
+ }
+ ],
+ "request": {
+ "method": "GET",
+ "header": [],
+ "body": {},
+ "url": {
+ "raw":
+ "{{url}}/v0/orderbook?baseTokenAddress={{ZRX_address}}&quoteTokenAddress={{WETH_address}}",
+ "host": ["{{url}}"],
+ "path": ["v0", "orderbook"],
+ "query": [
+ {
+ "key": "baseTokenAddress",
+ "value": "{{ZRX_address}}",
+ "equals": true
+ },
+ {
+ "key": "quoteTokenAddress",
+ "value": "{{WETH_address}}",
+ "equals": true
+ }
+ ]
+ },
+ "description":
+ "Retrieves a list of orders given query parameters. For querying an entire orderbook snapshot, the orderbook endpoint is recommended.\n\nParameters\n * exchangeContractAddress [string]: returns orders created for this exchange address\n * tokenAddress [string]: returns orders where makerTokenAddress or takerTokenAddress is token address\n * makerTokenAddress [string]: returns orders with specified makerTokenAddress\n * takerTokenAddress [string]: returns orders with specified makerTokenAddress\n * maker [string]: returns orders where maker is maker address\n * taker [string]: returns orders where taker is taker address\n * trader [string]: returns orders where maker or taker is trader address\n * feeRecipient [string]: returns orders where feeRecipient is feeRecipient address\n\nAll parameters are optional."
+ },
+ "response": []
+ },
+ {
+ "name": "ZRX/DAI orderbook",
+ "event": [
+ {
+ "listen": "test",
+ "script": {
+ "id": "1a0acd0e-5e4a-4e08-b4e9-291a4e9c433a",
+ "type": "text/javascript",
+ "exec": [""]
+ }
+ }
+ ],
+ "request": {
+ "method": "GET",
+ "header": [],
+ "body": {},
+ "url": {
+ "raw":
+ "{{url}}/v0/orderbook?baseTokenAddress={{ZRX_address}}&quoteTokenAddress={{DAI_address}}",
+ "host": ["{{url}}"],
+ "path": ["v0", "orderbook"],
+ "query": [
+ {
+ "key": "baseTokenAddress",
+ "value": "{{ZRX_address}}",
+ "equals": true
+ },
+ {
+ "key": "quoteTokenAddress",
+ "value": "{{DAI_address}}",
+ "equals": true
+ }
+ ]
+ },
+ "description":
+ "Retrieves a list of orders given query parameters. For querying an entire orderbook snapshot, the orderbook endpoint is recommended.\n\nParameters\n * exchangeContractAddress [string]: returns orders created for this exchange address\n * tokenAddress [string]: returns orders where makerTokenAddress or takerTokenAddress is token address\n * makerTokenAddress [string]: returns orders with specified makerTokenAddress\n * takerTokenAddress [string]: returns orders with specified makerTokenAddress\n * maker [string]: returns orders where maker is maker address\n * taker [string]: returns orders where taker is taker address\n * trader [string]: returns orders where maker or taker is trader address\n * feeRecipient [string]: returns orders where feeRecipient is feeRecipient address\n\nAll parameters are optional."
+ },
+ "response": []
+ }
+ ]
+ },
+ {
+ "name": "GET /order",
+ "description": "",
+ "item": [
+ {
+ "name": "order by order hash",
+ "request": {
+ "method": "GET",
+ "header": [],
+ "body": {},
+ "url": {
+ "raw": "{{url}}/v0/order/{{_orderHash}}",
+ "host": ["{{url}}"],
+ "path": ["v0", "order", "{{_orderHash}}"]
+ },
+ "description": "Retrieves a specific order by orderHash."
+ },
+ "response": []
+ }
+ ]
+ },
+ {
+ "name": "POST /fees",
+ "description": "",
+ "item": [
+ {
+ "name": "Calculate Fees",
+ "request": {
+ "method": "POST",
+ "header": [
+ {
+ "key": "Content-Type",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw":
+ "{\n \"exchangeContractAddress\": \"0x12459c951127e0c374ff9105dda097662a027093\",\n \"maker\": \"0x9e56625509c2f60af937f23b7b532600390e8c8b\",\n \"taker\": \"0x0000000000000000000000000000000000000000\",\n \"makerTokenAddress\": \"0x323b5d4c32345ced77393b3530b1eed0f346429d\",\n \"takerTokenAddress\": \"0xef7fff64389b814a946f3e92105513705ca6b990\",\n \"makerTokenAmount\": \"10000000000000000\",\n \"takerTokenAmount\": \"20000000000000000\",\n \"expirationUnixTimestampSec\": \"42\",\n \"salt\": \"67006738228878699843088602623665307406148487219438534730168799356281242528500\"\n}"
+ },
+ "url": {
+ "raw": "{{url}}/v0/fees",
+ "host": ["{{url}}"],
+ "path": ["v0", "fees"]
+ },
+ "description":
+ "Given an unsigned order without the fee-related properties, returns the required feeRecipient, makerFee, and takerFee of that order."
+ },
+ "response": []
+ }
+ ]
+ }
+ ],
+ "event": [
+ {
+ "listen": "prerequest",
+ "script": {
+ "id": "da60f639-df79-4f4d-9861-79219f5fc341",
+ "type": "text/javascript",
+ "exec": [""]
+ }
+ },
+ {
+ "listen": "test",
+ "script": {
+ "id": "b4917e72-ac87-421d-b7a5-21b64285ba5b",
+ "type": "text/javascript",
+ "exec": [""]
+ }
+ }
+ ]
+}
diff --git a/packages/sra-report/postman_configs/environments/kovan_tokens.postman_environment.json b/packages/sra-report/postman_configs/environments/kovan_tokens.postman_environment.json
new file mode 100644
index 000000000..fc2b1a9ff
--- /dev/null
+++ b/packages/sra-report/postman_configs/environments/kovan_tokens.postman_environment.json
@@ -0,0 +1,34 @@
+{
+ "id": "8dab7221-c8b8-2931-92c8-605f6f4072e1",
+ "name": "Kovan Tokens",
+ "values": [
+ {
+ "enabled": true,
+ "key": "url",
+ "value": "https://api.radarrelay.com/0x",
+ "type": "text"
+ },
+ {
+ "enabled": true,
+ "key": "DAI_address",
+ "value": "0xb18845c260f680d5b9d84649638813e342e4f8c9",
+ "type": "text"
+ },
+ {
+ "enabled": true,
+ "key": "WETH_address",
+ "value": "0xd0a1e359811322d97991e03f863a0c30c2cf029c",
+ "type": "text"
+ },
+ {
+ "enabled": true,
+ "key": "ZRX_address",
+ "value": "0x6ff6c0ff1d68b964901f986d4c9fa3ac68346570",
+ "type": "text"
+ }
+ ],
+ "timestamp": 1518639440766,
+ "_postman_variable_scope": "environment",
+ "_postman_exported_at": "2018-02-14T22:49:13.162Z",
+ "_postman_exported_using": "Postman/5.5.2"
+}
diff --git a/packages/sra-report/postman_configs/environments/mainnet_tokens.postman_environment.json b/packages/sra-report/postman_configs/environments/mainnet_tokens.postman_environment.json
new file mode 100644
index 000000000..0040dda95
--- /dev/null
+++ b/packages/sra-report/postman_configs/environments/mainnet_tokens.postman_environment.json
@@ -0,0 +1,28 @@
+{
+ "id": "e1087711-9cff-fd54-ba20-990b17a15f80",
+ "name": "Mainnet tokens",
+ "values": [
+ {
+ "enabled": true,
+ "key": "DAI_address",
+ "value": "0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359",
+ "type": "text"
+ },
+ {
+ "enabled": true,
+ "key": "WETH_address",
+ "value": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
+ "type": "text"
+ },
+ {
+ "enabled": true,
+ "key": "ZRX_address",
+ "value": "0xe41d2489571d322189246dafa5ebde1f4699f498",
+ "type": "text"
+ }
+ ],
+ "timestamp": 1518561760642,
+ "_postman_variable_scope": "environment",
+ "_postman_exported_at": "2018-02-14T22:48:11.259Z",
+ "_postman_exported_using": "Postman/5.5.2"
+}
diff --git a/packages/sra-report/scripts/postpublish.js b/packages/sra-report/scripts/postpublish.js
new file mode 100644
index 000000000..b3e5407c8
--- /dev/null
+++ b/packages/sra-report/scripts/postpublish.js
@@ -0,0 +1,5 @@
+const postpublish_utils = require('../../../scripts/postpublish_utils');
+const packageJSON = require('../package.json');
+
+const subPackageName = packageJSON.name;
+postpublish_utils.standardPostPublishAsync(subPackageName); \ No newline at end of file
diff --git a/packages/sra-report/src/globals.d.ts b/packages/sra-report/src/globals.d.ts
new file mode 100644
index 000000000..eb09d3fcf
--- /dev/null
+++ b/packages/sra-report/src/globals.d.ts
@@ -0,0 +1,6 @@
+declare module 'newman';
+
+declare module '*.json' {
+ const value: any;
+ export default value;
+}
diff --git a/packages/sra-report/src/index.ts b/packages/sra-report/src/index.ts
new file mode 100644
index 000000000..fe100bd42
--- /dev/null
+++ b/packages/sra-report/src/index.ts
@@ -0,0 +1,108 @@
+#!/usr/bin/env node
+
+import { assert } from '@0xproject/assert';
+import { schemas } from '@0xproject/json-schemas';
+import chalk from 'chalk';
+import * as _ from 'lodash';
+import * as newman from 'newman';
+import * as yargs from 'yargs';
+
+import * as sraReportCollectionJSON from '../postman_configs/collections/sra_report.postman_collection.json';
+import * as kovanTokensEnvironmentJSON from '../postman_configs/environments/kovan_tokens.postman_environment.json';
+import * as mainnetTokensEnvironmentJSON from '../postman_configs/environments/mainnet_tokens.postman_environment.json';
+
+import { Schema } from './types';
+import { utils } from './utils';
+
+const DEFAULT_NETWORK_ID = 1;
+const SUPPORTED_NETWORK_IDS = [1, 42];
+
+// extract command line arguments
+const args = yargs
+ .option('url', {
+ alias: ['u'],
+ describe: 'API endpoint to test for standard relayer API compliance',
+ type: 'string',
+ demandOption: true,
+ })
+ .option('output', {
+ alias: ['o', 'out'],
+ describe: 'Folder where to write the reports',
+ type: 'string',
+ normalize: true,
+ demandOption: false,
+ })
+ .option('network-id', {
+ alias: ['n'],
+ describe: 'ID of the network that the API is serving orders from',
+ type: 'number',
+ default: DEFAULT_NETWORK_ID,
+ })
+ .example("$0 --url 'http://api.example.com' --out 'src/contracts/generated/' --network-id 42", 'Full usage example')
+ .argv;
+// perform extra validation on command line arguments
+try {
+ assert.isHttpUrl('args', args.url);
+} catch (err) {
+ utils.log(`${chalk.red(`Invalid url format:`)} ${args.url}`);
+ process.exit(1);
+}
+if (!_.includes(SUPPORTED_NETWORK_IDS, args.networkId)) {
+ utils.log(`${chalk.red(`Unsupported network id:`)} ${args.networkId}`);
+ utils.log(`${chalk.bold(`Supported network ids:`)} ${SUPPORTED_NETWORK_IDS}`);
+ process.exit(1);
+}
+// run newman
+newman.run(
+ {
+ collection: sraReportCollectionJSON,
+ reporters: 'cli',
+ globals: createGlobals(args.url, _.values(schemas)),
+ environment: getEnvironment(args.networkId),
+ },
+ (err: Error) => {
+ if (err) {
+ throw err;
+ }
+ utils.log('collection run complete!');
+ },
+);
+function createGlobals(url: string, schemaList: Schema[]) {
+ const urlGlobalsValue = {
+ key: 'url',
+ value: args.url,
+ enabled: true,
+ type: 'text',
+ };
+ const schemaGlobalsValues = _.map(schemaList, (schema: Schema) => {
+ return {
+ key: convertSchemaIdToKey(schema.id),
+ value: JSON.stringify(schema),
+ enabled: true,
+ type: 'text',
+ };
+ });
+ const globalsValues = _.concat(schemaGlobalsValues, urlGlobalsValue);
+ const globals = {
+ values: globalsValues,
+ };
+ return globals;
+}
+function convertSchemaIdToKey(schemaId: string) {
+ let result = schemaId;
+ if (_.startsWith(result, '/')) {
+ result = result.substr(1);
+ }
+ result = `${result}Schema`;
+ return result;
+}
+function getEnvironment(networkId: number) {
+ switch (networkId) {
+ case 1:
+ return mainnetTokensEnvironmentJSON;
+ case 42:
+ return kovanTokensEnvironmentJSON;
+ default:
+ return {};
+ }
+}
diff --git a/packages/sra-report/src/types.ts b/packages/sra-report/src/types.ts
new file mode 100644
index 000000000..f08ef4042
--- /dev/null
+++ b/packages/sra-report/src/types.ts
@@ -0,0 +1,3 @@
+export interface Schema {
+ id: string;
+}
diff --git a/packages/sra-report/src/utils.ts b/packages/sra-report/src/utils.ts
new file mode 100644
index 000000000..5423cabd9
--- /dev/null
+++ b/packages/sra-report/src/utils.ts
@@ -0,0 +1,5 @@
+export const utils = {
+ log(...args: any[]): void {
+ console.log(...args); // tslint:disable-line:no-console
+ },
+};
diff --git a/packages/sra-report/tsconfig.json b/packages/sra-report/tsconfig.json
new file mode 100644
index 000000000..3d967d05f
--- /dev/null
+++ b/packages/sra-report/tsconfig.json
@@ -0,0 +1,7 @@
+{
+ "extends": "../../tsconfig",
+ "compilerOptions": {
+ "outDir": "lib"
+ },
+ "include": ["./src/**/*", "../../node_modules/web3-typescript-typings/index.d.ts"]
+}
diff --git a/packages/sra-report/tslint.json b/packages/sra-report/tslint.json
new file mode 100644
index 000000000..ffaefe83a
--- /dev/null
+++ b/packages/sra-report/tslint.json
@@ -0,0 +1,3 @@
+{
+ "extends": ["@0xproject/tslint-config"]
+}