From 42ecc087cbd3558258107fbce645441955416497 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Thu, 22 Feb 2018 00:30:35 -0800 Subject: Implement initial sra-report command line tool --- packages/sra-report/.npmignore | 5 + packages/sra-report/CHANGELOG.md | 1 + packages/sra-report/README.md | 53 +++ packages/sra-report/package.json | 42 ++ .../collections/sra_report.postman_collection.json | 384 +++++++++++++++++ .../kovan_tokens.postman_environment.json | 34 ++ .../mainnet_tokens.postman_environment.json | 28 ++ packages/sra-report/scripts/postpublish.js | 5 + packages/sra-report/src/globals.d.ts | 6 + packages/sra-report/src/index.ts | 108 +++++ packages/sra-report/src/types.ts | 3 + packages/sra-report/src/utils.ts | 5 + packages/sra-report/tsconfig.json | 7 + packages/sra-report/tslint.json | 3 + yarn.lock | 472 +++++++++++++++++++-- 15 files changed, 1121 insertions(+), 35 deletions(-) create mode 100644 packages/sra-report/.npmignore create mode 100644 packages/sra-report/CHANGELOG.md create mode 100644 packages/sra-report/README.md create mode 100644 packages/sra-report/package.json create mode 100644 packages/sra-report/postman_configs/collections/sra_report.postman_collection.json create mode 100644 packages/sra-report/postman_configs/environments/kovan_tokens.postman_environment.json create mode 100644 packages/sra-report/postman_configs/environments/mainnet_tokens.postman_environment.json create mode 100644 packages/sra-report/scripts/postpublish.js create mode 100644 packages/sra-report/src/globals.d.ts create mode 100644 packages/sra-report/src/index.ts create mode 100644 packages/sra-report/src/types.ts create mode 100644 packages/sra-report/src/utils.ts create mode 100644 packages/sra-report/tsconfig.json create mode 100644 packages/sra-report/tslint.json 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}}"eTokenAddress={{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}}"eTokenAddress={{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"] +} diff --git a/yarn.lock b/yarn.lock index 7c7dcd76b..3a458565e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,6 +2,10 @@ # yarn lockfile v1 +"8fold-marked@0.3.9": + version "0.3.9" + resolved "https://registry.yarnpkg.com/8fold-marked/-/8fold-marked-0.3.9.tgz#bb89c645612f8ccfaffac1ca6e3c11f168c9cf59" + "@types/accounting@^0.4.1": version "0.4.1" resolved "https://registry.yarnpkg.com/@types/accounting/-/accounting-0.4.1.tgz#865d9f5694fd7c438fba34eb4bc82eec6f34cdd5" @@ -109,6 +113,10 @@ version "4.14.92" resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.92.tgz#6e3cb0b71a1e12180a47a42a744e856c3ae99a57" +"@types/lodash@^4.14.104": + version "4.14.104" + resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.104.tgz#53ee2357fa2e6e68379341d92eb2ecea4b11bb80" + "@types/marked@0.0.28": version "0.0.28" resolved "https://registry.yarnpkg.com/@types/marked/-/marked-0.0.28.tgz#44ba754e9fa51432583e8eb30a7c4dd249b52faa" @@ -611,6 +619,12 @@ async@2.1.4: dependencies: lodash "^4.14.0" +async@2.6.0, async@^2.0.1, async@^2.1.2, async@^2.4.0, async@^2.5.0: + version "2.6.0" + resolved "https://registry.yarnpkg.com/async/-/async-2.6.0.tgz#61a29abb6fcc026fea77e56d1c6ec53a795951f4" + dependencies: + lodash "^4.14.0" + async@^0.9.0: version "0.9.2" resolved "https://registry.yarnpkg.com/async/-/async-0.9.2.tgz#aea74d5e61c1f899613bf64bda66d4c78f2fd17d" @@ -619,12 +633,6 @@ async@^1.4.0, async@^1.4.2, async@^1.5.0, async@^1.5.2: version "1.5.2" resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a" -async@^2.0.1, async@^2.1.2, async@^2.4.0, async@^2.5.0: - version "2.6.0" - resolved "https://registry.yarnpkg.com/async/-/async-2.6.0.tgz#61a29abb6fcc026fea77e56d1c6ec53a795951f4" - dependencies: - lodash "^4.14.0" - async@~1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/async/-/async-1.2.1.tgz#a4816a17cd5ff516dfa2c7698a453369b9790de0" @@ -669,7 +677,7 @@ aws-sign2@~0.7.0: version "0.7.0" resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.7.0.tgz#b46e890934a9591f2d2f6f86d7e6a9f1b3fe76a8" -aws4@^1.2.1, aws4@^1.6.0: +aws4@1.6.0, aws4@^1.2.1, aws4@^1.6.0: version "1.6.0" resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.6.0.tgz#83ef5ca860b2b32e4a0deedee8c771b9db57471e" @@ -1343,6 +1351,10 @@ blockies@^0.0.2: version "0.0.2" resolved "https://registry.yarnpkg.com/blockies/-/blockies-0.0.2.tgz#22ad58da4f6b382bc79bf4386c5820c70047e4ed" +bluebird@^2.6.2: + version "2.11.0" + resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-2.11.0.tgz#534b9033c022c9579c56ba3b3e5a5caafbb650e1" + bluebird@^3.5.0: version "3.5.1" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.1.tgz#d9551f9de98f1fcda1e683d17ee91a0602ee2eb9" @@ -1540,6 +1552,10 @@ bs58check@^1.0.8: bs58 "^3.1.0" create-hash "^1.1.0" +btoa@1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/btoa/-/btoa-1.1.2.tgz#3e40b81663f81d2dd6596a4cb714a8dc16cfabe0" + buffer-indexof@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/buffer-indexof/-/buffer-indexof-1.1.1.tgz#52fabcc6a606d1a00302802648ef68f639da268c" @@ -1705,7 +1721,7 @@ chain-function@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/chain-function/-/chain-function-1.0.0.tgz#0d4ab37e7e18ead0bdc47b920764118ce58733dc" -chalk@^1.0.0, chalk@^1.1.3: +chalk@^1.0.0, chalk@^1.1.0, chalk@^1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" dependencies: @@ -1731,6 +1747,10 @@ chardet@^0.4.0: version "0.4.2" resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.4.2.tgz#b5473b33dc97c424e5d98dc87d55d4d8a29c8bf2" +charset@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/charset/-/charset-1.0.1.tgz#8d59546c355be61049a8fa9164747793319852bd" + check-error@^1.0.1, check-error@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82" @@ -1788,6 +1808,10 @@ cipher-base@^1.0.0, cipher-base@^1.0.1, cipher-base@^1.0.3: inherits "^2.0.1" safe-buffer "^5.0.1" +circular-json@0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/circular-json/-/circular-json-0.3.1.tgz#be8b36aefccde8b3ca7aa2d6afc07a37242c0d2d" + clap@^1.0.9: version "1.2.3" resolved "https://registry.yarnpkg.com/clap/-/clap-1.2.3.tgz#4f36745b32008492557f46412d66d50cb99bce51" @@ -1817,6 +1841,21 @@ cli-cursor@^2.1.0: dependencies: restore-cursor "^2.0.0" +cli-progress@1.7.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/cli-progress/-/cli-progress-1.7.0.tgz#401cdfeacc1a34afc281b4bdf88829236724c92f" + dependencies: + colors "^1.1.2" + +cli-table2@0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/cli-table2/-/cli-table2-0.2.0.tgz#2d1ef7f218a0e786e214540562d4bd177fe32d97" + dependencies: + lodash "^3.10.1" + string-width "^1.0.1" + optionalDependencies: + colors "^1.1.2" + cli-width@^1.0.1: version "1.1.1" resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-1.1.1.tgz#a4d293ef67ebb7b88d4a4d42c0ccf00c4d1e366d" @@ -1936,7 +1975,7 @@ colormin@^1.0.5: css-color-names "0.0.4" has "^1.0.1" -colors@^1.1.2, colors@~1.1.2: +colors@1.1.2, colors@^1.1.2, colors@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/colors/-/colors-1.1.2.tgz#168a4701756b6a7f51a12ce0c97bfa28c084ed63" @@ -1961,7 +2000,11 @@ commander@2.11.0: version "2.11.0" resolved "https://registry.yarnpkg.com/commander/-/commander-2.11.0.tgz#157152fd1e7a6c8d98a5b715cf376df928004563" -commander@^2.9.0: +commander@2.12.2: + version "2.12.2" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.12.2.tgz#0f5946c427ed9ec0d91a46bb9def53e54650e555" + +commander@2.13.0, commander@^2.9.0: version "2.13.0" resolved "https://registry.yarnpkg.com/commander/-/commander-2.13.0.tgz#6964bca67685df7c1f1430c584f07d7597885b9c" @@ -2420,14 +2463,14 @@ crypto-browserify@^3.11.0: randombytes "^2.0.0" randomfill "^1.0.3" +crypto-js@3.1.9-1, crypto-js@^3.1.9-1: + version "3.1.9-1" + resolved "https://registry.yarnpkg.com/crypto-js/-/crypto-js-3.1.9-1.tgz#fda19e761fc077e01ffbfdc6e9fdfc59e8806cd8" + crypto-js@^3.1.4: version "3.1.8" resolved "https://registry.yarnpkg.com/crypto-js/-/crypto-js-3.1.8.tgz#715f070bf6014f2ae992a98b3929258b713f08d5" -crypto-js@^3.1.9-1: - version "3.1.9-1" - resolved "https://registry.yarnpkg.com/crypto-js/-/crypto-js-3.1.9-1.tgz#fda19e761fc077e01ffbfdc6e9fdfc59e8806cd8" - crypto-random-string@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/crypto-random-string/-/crypto-random-string-1.0.0.tgz#a230f64f568310e1498009940790ec99545bca7e" @@ -2528,6 +2571,10 @@ csso@~2.3.1: clap "^1.0.9" source-map "^0.5.3" +csv-parse@1.2.4: + version "1.2.4" + resolved "https://registry.yarnpkg.com/csv-parse/-/csv-parse-1.2.4.tgz#cbf676e355226625888c6432400b83f07e75cc2e" + currently-unhandled@^0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/currently-unhandled/-/currently-unhandled-0.4.1.tgz#988df33feab191ef799a61369dd76c17adf957ea" @@ -2571,6 +2618,10 @@ dateformat@^2.0.0: version "2.2.0" resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-2.2.0.tgz#4065e2013cf9fb916ddfd82efb506ad4c6769062" +dbug@~0.4.2: + version "0.4.2" + resolved "https://registry.yarnpkg.com/dbug/-/dbug-0.4.2.tgz#32b4b3105e8861043a6f9ac755d80e542d365b31" + debug-log@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/debug-log/-/debug-log-1.0.1.tgz#2307632d4c04382b8df8a32f70b895046d52745f" @@ -2797,6 +2848,13 @@ dom-helpers@^3.2.0: version "3.3.1" resolved "https://registry.yarnpkg.com/dom-helpers/-/dom-helpers-3.3.1.tgz#fc1a4e15ffdf60ddde03a480a9c0fece821dd4a6" +dom-serializer@0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/dom-serializer/-/dom-serializer-0.1.0.tgz#073c697546ce0780ce23be4a28e293e40bc30c82" + dependencies: + domelementtype "~1.1.1" + entities "~1.1.1" + dom-walk@^0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/dom-walk/-/dom-walk-0.1.1.tgz#672226dc74c8f799ad35307df936aba11acd6018" @@ -2805,6 +2863,27 @@ domain-browser@^1.1.1: version "1.1.7" resolved "https://registry.yarnpkg.com/domain-browser/-/domain-browser-1.1.7.tgz#867aa4b093faa05f1de08c06f4d7b21fdf8698bc" +domelementtype@1, domelementtype@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-1.3.0.tgz#b17aed82e8ab59e52dd9c19b1756e0fc187204c2" + +domelementtype@~1.1.1: + version "1.1.3" + resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-1.1.3.tgz#bd28773e2642881aec51544924299c5cd822185b" + +domhandler@^2.3.0: + version "2.4.1" + resolved "https://registry.yarnpkg.com/domhandler/-/domhandler-2.4.1.tgz#892e47000a99be55bbf3774ffea0561d8879c259" + dependencies: + domelementtype "1" + +domutils@^1.5.1: + version "1.7.0" + resolved "https://registry.yarnpkg.com/domutils/-/domutils-1.7.0.tgz#56ea341e834e06e6748af7a1cb25da67ea9f8c2a" + dependencies: + dom-serializer "0" + domelementtype "1" + dot-prop@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-3.0.0.tgz#1b708af094a49c9a0e7dbcad790aba539dac1177" @@ -2932,7 +3011,7 @@ enhanced-resolve@^3.4.0: object-assign "^4.0.1" tapable "^0.2.7" -"entities@~ 1.1.1": +entities@^1.1.1, "entities@~ 1.1.1", entities@~1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/entities/-/entities-1.1.1.tgz#6e5c2d0a5621b5dadaecef80b90edfb5cd7772f0" @@ -3032,7 +3111,7 @@ es6-weak-map@^2.0.1: es6-iterator "^2.0.1" es6-symbol "^3.1.1" -escape-html@~1.0.3: +escape-html@1.0.3, escape-html@~1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" @@ -3272,6 +3351,10 @@ eventemitter3@1.x.x: version "1.2.0" resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-1.2.0.tgz#1c86991d816ad1e504750e73874224ecf3bec508" +eventemitter3@3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-3.0.0.tgz#fc29ecf233bd19fbd527bb4089bbf665dc90c1e3" + events@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/events/-/events-1.1.1.tgz#9ebdb7635ad099c70dcc4c2a1f5004288e8bd924" @@ -3518,7 +3601,7 @@ figures@^2.0.0: dependencies: escape-string-regexp "^1.0.5" -file-type@^3.6.0: +file-type@3.9.0, file-type@^3.6.0: version "3.9.0" resolved "https://registry.yarnpkg.com/file-type/-/file-type-3.9.0.tgz#257a078384d1db8087bc449d107d52a52672b9e9" @@ -3526,6 +3609,10 @@ filename-regex@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/filename-regex/-/filename-regex-2.0.1.tgz#c1c4b9bee3e09725ddb106b75c1e301fe2f18b26" +filesize@3.5.11: + version "3.5.11" + resolved "https://registry.yarnpkg.com/filesize/-/filesize-3.5.11.tgz#1919326749433bb3cf77368bd158caabcc19e9ee" + fill-range@^2.1.0: version "2.2.3" resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-2.2.3.tgz#50b77dfd7e469bc7492470963699fe7a8485a723" @@ -4134,7 +4221,7 @@ handle-thing@^1.2.5: version "1.2.5" resolved "https://registry.yarnpkg.com/handle-thing/-/handle-thing-1.2.5.tgz#fd7aad726bf1a5fd16dfc29b2f7a6601d27139c4" -handlebars@^4.0.11, handlebars@^4.0.2, handlebars@^4.0.3, handlebars@^4.0.6: +handlebars@4.0.11, handlebars@^4.0.11, handlebars@^4.0.2, handlebars@^4.0.3, handlebars@^4.0.6: version "4.0.11" resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.0.11.tgz#630a35dfe0294bc281edae6ffc5d329fc7982dcc" dependencies: @@ -4159,7 +4246,7 @@ har-validator@~4.2.1: ajv "^4.9.1" har-schema "^1.0.5" -har-validator@~5.0.3: +har-validator@~5.0.2, har-validator@~5.0.3: version "5.0.3" resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-5.0.3.tgz#ba402c266194f15956ef15e0fcf242993f6a7dfd" dependencies: @@ -4344,6 +4431,17 @@ html-entities@^1.2.0: version "1.2.1" resolved "https://registry.yarnpkg.com/html-entities/-/html-entities-1.2.1.tgz#0df29351f0721163515dfb9e5543e5f6eed5162f" +htmlparser2@^3.9.0: + version "3.9.2" + resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-3.9.2.tgz#1bdf87acca0f3f9e53fa4fcceb0f4b4cbb00b338" + dependencies: + domelementtype "^1.3.0" + domhandler "^2.3.0" + domutils "^1.5.1" + entities "^1.1.1" + inherits "^2.0.1" + readable-stream "^2.0.2" + http-deceiver@^1.2.7: version "1.2.7" resolved "https://registry.yarnpkg.com/http-deceiver/-/http-deceiver-1.2.7.tgz#fa7168944ab9a519d337cb0bec7284dc3e723d87" @@ -4377,6 +4475,10 @@ http-proxy@^1.16.2: eventemitter3 "1.x.x" requires-port "1.x.x" +http-reasons@0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/http-reasons/-/http-reasons-0.1.0.tgz#a953ca670078669dde142ce899401b9d6e85d3b4" + http-signature@~1.1.0: version "1.1.1" resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.1.1.tgz#df72e267066cd0ac67fb76adf8e134a8fbcf91bf" @@ -4393,6 +4495,13 @@ http-signature@~1.2.0: jsprim "^1.2.2" sshpk "^1.7.0" +httpntlm@1.7.5: + version "1.7.5" + resolved "https://registry.yarnpkg.com/httpntlm/-/httpntlm-1.7.5.tgz#cd1558ed93125418ece5bf824c1335675feedecc" + dependencies: + httpreq ">=0.4.22" + underscore "~1.7.0" + httpplease@^0.16: version "0.16.4" resolved "https://registry.yarnpkg.com/httpplease/-/httpplease-0.16.4.tgz#d382ebe230ef5079080b4e9ffebf316a9e75c0da" @@ -4401,6 +4510,10 @@ httpplease@^0.16: xmlhttprequest "*" xtend "~3.0.0" +httpreq@>=0.4.22: + version "0.4.24" + resolved "https://registry.yarnpkg.com/httpreq/-/httpreq-0.4.24.tgz#4335ffd82cd969668a39465c929ac61d6393627f" + https-browserify@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-1.0.0.tgz#ec06c10e0a34c0f2faf199f7fd7fc78fffd03c73" @@ -4550,6 +4663,17 @@ inquirer@^3.2.2: strip-ansi "^4.0.0" through "^2.3.6" +intel@1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/intel/-/intel-1.2.0.tgz#11d1147eb6b3f4582bdf5337b37d541584e9e41e" + dependencies: + chalk "^1.1.0" + dbug "~0.4.2" + stack-trace "~0.0.9" + strftime "~0.10.0" + symbol "~0.3.1" + utcstring "~0.1.0" + internal-ip@1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/internal-ip/-/internal-ip-1.2.0.tgz#ae9fbf93b984878785d50a8de1b356956058cf5c" @@ -4578,6 +4702,10 @@ ipaddr.js@1.5.2: version "1.5.2" resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.5.2.tgz#d4b505bde9946987ccf0fc58d9010ff9607e3fa0" +irregular-plurals@^1.0.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/irregular-plurals/-/irregular-plurals-1.4.0.tgz#2ca9b033651111855412f16be5d77c62a458a766" + is-absolute-url@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/is-absolute-url/-/is-absolute-url-2.1.0.tgz#50530dfb84fcc9aa7dbe7852e83a37b93b9f2aa6" @@ -5304,6 +5432,10 @@ liftoff@^2.1.0: rechoir "^0.6.2" resolve "^1.1.7" +liquid-json@0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/liquid-json/-/liquid-json-0.3.1.tgz#9155a18136d8a6b2615e5f16f9a2448ab6b50eea" + load-json-file@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-1.1.0.tgz#956905708d58b4bab4c2261b04f59f31c99374c0" @@ -5438,6 +5570,10 @@ lodash.escape@^3.0.0: dependencies: lodash._root "^3.0.0" +lodash.escaperegexp@^4.1.2: + version "4.1.2" + resolved "https://registry.yarnpkg.com/lodash.escaperegexp/-/lodash.escaperegexp-4.1.2.tgz#64762c48618082518ac3df4ccf5d5886dae20347" + lodash.foreach@^4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.foreach/-/lodash.foreach-4.5.0.tgz#1a6a35eace401280c7f06dddec35165ab27e3e53" @@ -5530,14 +5666,18 @@ lodash.words@^3.0.0: dependencies: lodash._root "^3.0.0" -lodash@^3.3.1, lodash@^3.6.0: - version "3.10.1" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6" +lodash@4.17.2: + version "4.17.2" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.2.tgz#34a3055babe04ce42467b607d700072c7ff6bf42" -lodash@^4.0.0, lodash@^4.1.0, lodash@^4.13.1, lodash@^4.14.0, lodash@^4.17.2, lodash@^4.17.4, lodash@^4.2.0, lodash@^4.2.1, lodash@^4.3.0: +lodash@4.17.4, lodash@^4.0.0, lodash@^4.1.0, lodash@^4.13.1, lodash@^4.14.0, lodash@^4.17.2, lodash@^4.17.4, lodash@^4.2.0, lodash@^4.2.1, lodash@^4.3.0: version "4.17.4" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" +lodash@^3.10.1, lodash@^3.3.1, lodash@^3.6.0: + version "3.10.1" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6" + lodash@~1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/lodash/-/lodash-1.0.2.tgz#8f57560c83b59fc270bd3d561b690043430e2551" @@ -5807,7 +5947,13 @@ mime-db@~1.30.0: version "1.30.0" resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.30.0.tgz#74c643da2dd9d6a45399963465b26d5ca7d71f01" -mime-types@^2.1.12, mime-types@~2.1.15, mime-types@~2.1.16, mime-types@~2.1.17, mime-types@~2.1.7: +mime-format@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/mime-format/-/mime-format-2.0.0.tgz#e29f8891e284d78270246f0050d6834bdbbe1332" + dependencies: + charset "^1.0.0" + +mime-types@2.1.17, mime-types@^2.1.12, mime-types@~2.1.15, mime-types@~2.1.16, mime-types@~2.1.17, mime-types@~2.1.7: version "2.1.17" resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.17.tgz#09d7a393f03e995a79f8af857b70a9e0ab16557a" dependencies: @@ -6014,6 +6160,33 @@ negotiator@0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.1.tgz#2b327184e8992101177b28563fb5e7102acd0ca9" +newman@^3.9.3: + version "3.9.3" + resolved "https://registry.yarnpkg.com/newman/-/newman-3.9.3.tgz#939356026942474ba15482bd37a15c60bb200ca0" + dependencies: + async "2.6.0" + cli-progress "1.7.0" + cli-table2 "0.2.0" + colors "1.1.2" + commander "2.13.0" + csv-parse "1.2.4" + eventemitter3 "3.0.0" + filesize "3.5.11" + handlebars "4.0.11" + lodash "4.17.2" + mkdirp "0.5.1" + parse-json "3.0.0" + postman-collection "3.0.7" + postman-collection-transformer "2.5.4" + postman-request "2.81.1-postman.4" + postman-runtime "7.1.3" + pretty-ms "3.1.0" + semver "5.5.0" + serialised-error "1.1.2" + shelljs "0.8.0" + word-wrap "1.2.3" + xmlbuilder "9.0.4" + nise@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/nise/-/nise-1.2.0.tgz#079d6cadbbcb12ba30e38f1c999f36ad4d6baa53" @@ -6070,6 +6243,12 @@ node-libs-browser@^2.0.0: util "^0.10.3" vm-browserify "0.0.4" +node-oauth1@1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/node-oauth1/-/node-oauth1-1.2.2.tgz#fffb2813a88c2770711332ad0e5487b4927644a4" + dependencies: + crypto-js "3.1.9-1" + node-pre-gyp@0.6.31: version "0.6.31" resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.6.31.tgz#d8a00ddaa301a940615dbcc8caad4024d58f6017" @@ -6100,6 +6279,10 @@ node-pre-gyp@^0.6.39: tar "^2.2.1" tar-pack "^3.4.0" +node-uuid@^1.4.7: + version "1.4.8" + resolved "https://registry.yarnpkg.com/node-uuid/-/node-uuid-1.4.8.tgz#b040eb0923968afabf8d32fb1f17f1167fdab907" + nodemon@^1.11.0: version "1.14.11" resolved "https://registry.yarnpkg.com/nodemon/-/nodemon-1.14.11.tgz#cc0009dd8d82f126f3aba50ace7e753827a8cebc" @@ -6264,6 +6447,10 @@ object-copy@^0.1.0: define-property "^0.2.5" kind-of "^3.0.3" +object-hash@^1.1.2: + version "1.2.0" + resolved "https://registry.yarnpkg.com/object-hash/-/object-hash-1.2.0.tgz#e96af0e96981996a1d47f88ead8f74f1ebc4422b" + object-inspect@~0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-0.4.0.tgz#f5157c116c1455b243b06ee97703392c5ad89fec" @@ -6511,18 +6698,18 @@ parse-headers@^2.0.0: for-each "^0.3.2" trim "0.0.1" +parse-json@3.0.0, parse-json@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-3.0.0.tgz#fa6f47b18e23826ead32f263e744d0e1e847fb13" + dependencies: + error-ex "^1.3.1" + parse-json@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-2.2.0.tgz#f480f40434ef80741f8469099f8dea18f55a4dc9" dependencies: error-ex "^1.2.0" -parse-json@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-3.0.0.tgz#fa6f47b18e23826ead32f263e744d0e1e847fb13" - dependencies: - error-ex "^1.3.1" - parse-json@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-4.0.0.tgz#be35f5425be1f7f6c747184f98a788cb99477ee0" @@ -6530,6 +6717,10 @@ parse-json@^4.0.0: error-ex "^1.3.1" json-parse-better-errors "^1.0.1" +parse-ms@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/parse-ms/-/parse-ms-1.0.1.tgz#56346d4749d78f23430ca0c713850aef91aa361d" + parse-passwd@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/parse-passwd/-/parse-passwd-1.0.0.tgz#6d5b934a456993b23d37f40a382d6f1666a8e5c6" @@ -6682,6 +6873,12 @@ pkginfo@^0.3.0: version "0.3.1" resolved "https://registry.yarnpkg.com/pkginfo/-/pkginfo-0.3.1.tgz#5b29f6a81f70717142e09e765bbeab97b4f81e21" +plur@^2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/plur/-/plur-2.1.2.tgz#7482452c1a0f508e3e344eaec312c91c29dc655a" + dependencies: + irregular-plurals "^1.0.0" + portfinder@^1.0.9: version "1.0.13" resolved "https://registry.yarnpkg.com/portfinder/-/portfinder-1.0.13.tgz#bb32ecd87c27104ae6ee44b5a3ccbf0ebb1aede9" @@ -6940,6 +7137,117 @@ postcss@^6.0.1: source-map "^0.6.1" supports-color "^5.1.0" +postman-collection-transformer@2.5.4: + version "2.5.4" + resolved "https://registry.yarnpkg.com/postman-collection-transformer/-/postman-collection-transformer-2.5.4.tgz#4e715a9913340621a9fc0e9a5a0373b22e9a9d9a" + dependencies: + commander "2.12.2" + inherits "2.0.3" + intel "1.2.0" + lodash "4.17.4" + semver "5.4.1" + strip-json-comments "2.0.1" + +postman-collection@3.0.6: + version "3.0.6" + resolved "https://registry.yarnpkg.com/postman-collection/-/postman-collection-3.0.6.tgz#3bc2307158a783964a473cac82f20d26ffdf5500" + dependencies: + "8fold-marked" "0.3.9" + escape-html "1.0.3" + file-type "3.9.0" + http-reasons "0.1.0" + iconv-lite "0.4.19" + liquid-json "0.3.1" + lodash "4.17.4" + mime-format "2.0.0" + mime-types "2.1.17" + postman-url-encoder "1.0.1" + sanitize-html "1.15.0" + semver "5.4.1" + uuid "3.1.0" + +postman-collection@3.0.7: + version "3.0.7" + resolved "https://registry.yarnpkg.com/postman-collection/-/postman-collection-3.0.7.tgz#699496583ff61443da8a4e0314e58ee6d10442a3" + dependencies: + "8fold-marked" "0.3.9" + escape-html "1.0.3" + file-type "3.9.0" + http-reasons "0.1.0" + iconv-lite "0.4.19" + liquid-json "0.3.1" + lodash "4.17.4" + mime-format "2.0.0" + mime-types "2.1.17" + postman-url-encoder "1.0.1" + sanitize-html "1.15.0" + semver "5.4.1" + uuid "3.1.0" + +postman-request@2.81.1-postman.4: + version "2.81.1-postman.4" + resolved "https://registry.yarnpkg.com/postman-request/-/postman-request-2.81.1-postman.4.tgz#be8f60541539da13739d77b670b9fca6f1aecf83" + dependencies: + aws-sign2 "~0.7.0" + aws4 "^1.2.1" + caseless "~0.12.0" + combined-stream "~1.0.5" + extend "~3.0.0" + forever-agent "~0.6.1" + form-data "~2.1.1" + har-validator "~5.0.2" + hawk "~3.1.3" + http-signature "~1.1.0" + is-typedarray "~1.0.0" + isstream "~0.1.2" + json-stringify-safe "~5.0.1" + mime-types "~2.1.7" + oauth-sign "~0.8.1" + performance-now "^0.2.0" + postman-url-encoder "1.0.1" + qs "~6.4.0" + safe-buffer "^5.0.1" + stream-length "^1.0.2" + stringstream "~0.0.4" + tough-cookie "~2.3.3" + tunnel-agent "^0.6.0" + uuid "^3.0.0" + +postman-runtime@7.1.3: + version "7.1.3" + resolved "https://registry.yarnpkg.com/postman-runtime/-/postman-runtime-7.1.3.tgz#e0c5dfc40dd7d39a2f71519705c97afde35d6f8c" + dependencies: + async "2.6.0" + aws4 "1.6.0" + btoa "1.1.2" + crypto-js "3.1.9-1" + eventemitter3 "3.0.0" + hawk "3.1.3" + http-reasons "0.1.0" + httpntlm "1.7.5" + inherits "2.0.3" + lodash "4.17.4" + node-oauth1 "1.2.2" + postman-collection "3.0.6" + postman-request "2.81.1-postman.4" + postman-sandbox "3.0.4" + resolve-from "4.0.0" + serialised-error "1.1.2" + uuid "3.1.0" + +postman-sandbox@3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/postman-sandbox/-/postman-sandbox-3.0.4.tgz#d011b50d3ec8a8075405d219e1659dbdec354997" + dependencies: + inherits "2.0.3" + lodash "4.17.4" + uuid "3.1.0" + uvm "1.7.0" + +postman-url-encoder@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/postman-url-encoder/-/postman-url-encoder-1.0.1.tgz#a094a42e9415ff0bbfdce0eaa8e6011d449ee83c" + prepend-http@^1.0.0, prepend-http@^1.0.1: version "1.0.4" resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-1.0.4.tgz#d4f4562b0ce3696e41ac52d0e002e57a635dc6dc" @@ -6963,6 +7271,13 @@ pretty-hrtime@^1.0.0: version "1.0.3" resolved "https://registry.yarnpkg.com/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz#b7e3ea42435a4c9b2759d99e0f201eb195802ee1" +pretty-ms@3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/pretty-ms/-/pretty-ms-3.1.0.tgz#e9cac9c76bf6ee52fe942dd9c6c4213153b12881" + dependencies: + parse-ms "^1.0.0" + plur "^2.1.2" + private@^0.1.6, private@^0.1.7: version "0.1.8" resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff" @@ -7785,6 +8100,10 @@ resolve-dir@^1.0.0, resolve-dir@^1.0.1: expand-tilde "^2.0.0" global-modules "^1.0.0" +resolve-from@4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" + resolve-from@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-2.0.0.tgz#9480ab20e94ffa1d9e80a804c7ea147611966b57" @@ -7906,6 +8225,15 @@ samsam@1.x: version "1.3.0" resolved "https://registry.yarnpkg.com/samsam/-/samsam-1.3.0.tgz#8d1d9350e25622da30de3e44ba692b5221ab7c50" +sanitize-html@1.15.0: + version "1.15.0" + resolved "https://registry.yarnpkg.com/sanitize-html/-/sanitize-html-1.15.0.tgz#d101a62c9fe0347486badc6cd6ed72daa0a82ced" + dependencies: + htmlparser2 "^3.9.0" + lodash.escaperegexp "^4.1.2" + srcset "^1.0.0" + xtend "^4.0.0" + sax@^1.2.4, sax@~1.2.1: version "1.2.4" resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9" @@ -7990,10 +8318,14 @@ semver-sort@0.0.4, semver-sort@^0.0.4: semver "^5.0.3" semver-regex "^1.0.0" -"semver@2 || 3 || 4 || 5", semver@^5.0.1, semver@^5.0.3, semver@^5.1.0, semver@^5.3.0, semver@^5.4.1, semver@~5.4.1: +"semver@2 || 3 || 4 || 5", semver@5.4.1, semver@^5.0.1, semver@^5.0.3, semver@^5.1.0, semver@^5.3.0, semver@^5.4.1, semver@~5.4.1: version "5.4.1" resolved "https://registry.yarnpkg.com/semver/-/semver-5.4.1.tgz#e059c09d8571f0540823733433505d3a2f00b18e" +semver@5.5.0: + version "5.5.0" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.0.tgz#dc4bbc7a6ca9d916dee5d43516f0092b58f7b8ab" + semver@^4.1.0: version "4.3.6" resolved "https://registry.yarnpkg.com/semver/-/semver-4.3.6.tgz#300bc6e0e86374f7ba61068b5b1ecd57fc6532da" @@ -8024,6 +8356,14 @@ sequencify@~0.0.7: version "0.0.7" resolved "https://registry.yarnpkg.com/sequencify/-/sequencify-0.0.7.tgz#90cff19d02e07027fd767f5ead3e7b95d1e7380c" +serialised-error@1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/serialised-error/-/serialised-error-1.1.2.tgz#b5c3822196f873feb0c76587e1d6dfa6790ade97" + dependencies: + node-uuid "^1.4.7" + object-hash "^1.1.2" + stack-trace "0.0.9" + serialize-javascript@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-1.4.0.tgz#7c958514db6ac2443a8abc062dc9f7886a7f6005" @@ -8139,6 +8479,14 @@ shell-quote@^1.6.1: array-reduce "~0.0.0" jsonify "~0.0.0" +shelljs@0.8.0: + version "0.8.0" + resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.8.0.tgz#12f561c52ec5d0d3315af15616c011a18ff80d59" + dependencies: + glob "^7.0.0" + interpret "^1.0.0" + rechoir "^0.6.2" + shelljs@^0.7.0, shelljs@^0.7.3: version "0.7.8" resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.7.8.tgz#decbcf874b0d1e5fb72e14b164a9683048e9acb3" @@ -8430,6 +8778,13 @@ sprintf-js@~1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" +srcset@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/srcset/-/srcset-1.0.0.tgz#a5669de12b42f3b1d5e83ed03c71046fc48f41ef" + dependencies: + array-uniq "^1.0.2" + number-is-nan "^1.0.0" + sshpk@^1.7.0: version "1.13.1" resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.13.1.tgz#512df6da6287144316dc4c18fe1cf1d940739be3" @@ -8450,6 +8805,14 @@ ssri@^5.0.0: dependencies: safe-buffer "^5.1.0" +stack-trace@0.0.9: + version "0.0.9" + resolved "https://registry.yarnpkg.com/stack-trace/-/stack-trace-0.0.9.tgz#a8f6eaeca90674c333e7c43953f275b451510695" + +stack-trace@~0.0.9: + version "0.0.10" + resolved "https://registry.yarnpkg.com/stack-trace/-/stack-trace-0.0.10.tgz#547c70b347e8d32b4e108ea1a2a159e5fdde19c0" + static-extend@^0.1.1: version "0.1.2" resolved "https://registry.yarnpkg.com/static-extend/-/static-extend-0.1.2.tgz#60809c39cbff55337226fd5e0b520f341f1fb5c6" @@ -8503,10 +8866,20 @@ stream-http@^2.7.2: to-arraybuffer "^1.0.0" xtend "^4.0.0" +stream-length@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/stream-length/-/stream-length-1.0.2.tgz#8277f3cbee49a4daabcfdb4e2f4a9b5e9f2c9f00" + dependencies: + bluebird "^2.6.2" + stream-shift@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/stream-shift/-/stream-shift-1.0.0.tgz#d5c752825e5367e786f78e18e445ea223a155952" +strftime@~0.10.0: + version "0.10.0" + resolved "https://registry.yarnpkg.com/strftime/-/strftime-0.10.0.tgz#b3f0fa419295202a5a289f6d6be9f4909a617193" + strict-uri-encode@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz#279b225df1d582b1f54e65addd4352e18faa0713" @@ -8617,7 +8990,7 @@ strip-indent@^1.0.1: dependencies: get-stdin "^4.0.1" -strip-json-comments@~2.0.1: +strip-json-comments@2.0.1, strip-json-comments@~2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" @@ -8693,6 +9066,10 @@ symbol-observable@^1.0.3, symbol-observable@^1.0.4: version "1.1.0" resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.1.0.tgz#5c68fd8d54115d9dfb72a84720549222e8db9b32" +symbol@~0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/symbol/-/symbol-0.3.1.tgz#b6f9a900d496a57f02408f22198c109dda063041" + tapable@^0.2.5, tapable@^0.2.7: version "0.2.8" resolved "https://registry.yarnpkg.com/tapable/-/tapable-0.2.8.tgz#99372a5c999bf2df160afc0d74bed4f47948cd22" @@ -9183,6 +9560,10 @@ underscore@1.8.3: version "1.8.3" resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.8.3.tgz#4f3fb53b106e6097fcf9cb4109f2a5e9bdfa5022" +underscore@~1.7.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.7.0.tgz#6bbaf0877500d36be34ecaa584e0db9fef035209" + union-value@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/union-value/-/union-value-1.0.0.tgz#5c71c34cb5bad5dcebe3ea0cd08207ba5aa1aea4" @@ -9328,6 +9709,10 @@ user-home@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/user-home/-/user-home-1.1.1.tgz#2b5be23a32b63a7c9deb8d0f28d485724a3df190" +utcstring@~0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/utcstring/-/utcstring-0.1.0.tgz#430fd510ab7fc95b5d5910c902d79880c208436b" + utf8@2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/utf8/-/utf8-2.1.1.tgz#2e01db02f7d8d0944f77104f1609eb0c304cf768" @@ -9354,13 +9739,22 @@ uuid@3.0.1, uuid@~3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.0.1.tgz#6544bba2dfda8c1cf17e629a3a305e2bb1fee6c1" +uuid@3.1.0, uuid@^3.0.0, uuid@^3.0.1, uuid@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.1.0.tgz#3dd3d3e790abc24d7b0d3a034ffababe28ebbc04" + uuid@^2.0.1: version "2.0.3" resolved "https://registry.yarnpkg.com/uuid/-/uuid-2.0.3.tgz#67e2e863797215530dff318e5bf9dcebfd47b21a" -uuid@^3.0.0, uuid@^3.0.1, uuid@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.1.0.tgz#3dd3d3e790abc24d7b0d3a034ffababe28ebbc04" +uvm@1.7.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/uvm/-/uvm-1.7.0.tgz#685d3a149ec7118fb73a73dfdc158ab46b0f0634" + dependencies: + circular-json "0.3.1" + inherits "2.0.3" + lodash "4.17.4" + uuid "3.0.1" v8flags@^2.0.2: version "2.1.1" @@ -9709,6 +10103,10 @@ window-size@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.2.0.tgz#b4315bb4214a3d7058ebeee892e13fa24d98b075" +word-wrap@1.2.3: + version "1.2.3" + resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c" + wordwrap@0.0.2: version "0.0.2" resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.2.tgz#b79669bb42ecb409f83d583cad52ca17eaa1643f" @@ -9811,6 +10209,10 @@ xml-js@^1.3.2: dependencies: sax "^1.2.4" +xmlbuilder@9.0.4: + version "9.0.4" + resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-9.0.4.tgz#519cb4ca686d005a8420d3496f3f0caeecca580f" + xmlhttprequest@*: version "1.8.0" resolved "https://registry.yarnpkg.com/xmlhttprequest/-/xmlhttprequest-1.8.0.tgz#67fe075c5c24fef39f9d65f5f7b7fe75171968fc" -- cgit From 63f8f469b0967ef606572ba2a92d051030e41c6c Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Thu, 22 Feb 2018 13:54:39 -0800 Subject: Fix @types/lodash version --- packages/sra-report/package.json | 2 +- yarn.lock | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/sra-report/package.json b/packages/sra-report/package.json index 0eaa5277e..8265ceb28 100644 --- a/packages/sra-report/package.json +++ b/packages/sra-report/package.json @@ -32,7 +32,7 @@ }, "devDependencies": { "@0xproject/tslint-config": "^0.4.9", - "@types/lodash": "^4.14.104", + "@types/lodash": "^4.14.86", "@types/node": "^8.0.53", "@types/yargs": "^10.0.0", "shx": "^0.2.2", diff --git a/yarn.lock b/yarn.lock index 3a458565e..c9a5942b4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -113,10 +113,6 @@ version "4.14.92" resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.92.tgz#6e3cb0b71a1e12180a47a42a744e856c3ae99a57" -"@types/lodash@^4.14.104": - version "4.14.104" - resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.104.tgz#53ee2357fa2e6e68379341d92eb2ecea4b11bb80" - "@types/marked@0.0.28": version "0.0.28" resolved "https://registry.yarnpkg.com/@types/marked/-/marked-0.0.28.tgz#44ba754e9fa51432583e8eb30a7c4dd249b52faa" -- cgit From 87b9caa7dc20947f818c9546033e7314e7e78535 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Fri, 23 Feb 2018 11:47:42 -0800 Subject: Fix README typo --- packages/sra-report/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sra-report/README.md b/packages/sra-report/README.md index 18802f06a..49609aeb2 100644 --- a/packages/sra-report/README.md +++ b/packages/sra-report/README.md @@ -9,7 +9,7 @@ This package allows you to generate reports detailing an endpoint's [standard re ## Usage ``` -abi-gen +sra-report Options: --help Show help [boolean] --version Show version number [boolean] -- cgit From 7afe00f06a0cf0bf4f079dcc86e2241cc3dc9832 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Fri, 23 Feb 2018 11:56:50 -0800 Subject: Use Schema interface from @0xproject/json-schemas --- packages/sra-report/src/index.ts | 23 +++++++++++++---------- packages/sra-report/src/types.ts | 3 --- 2 files changed, 13 insertions(+), 13 deletions(-) delete mode 100644 packages/sra-report/src/types.ts diff --git a/packages/sra-report/src/index.ts b/packages/sra-report/src/index.ts index fe100bd42..a24de377a 100644 --- a/packages/sra-report/src/index.ts +++ b/packages/sra-report/src/index.ts @@ -1,7 +1,7 @@ #!/usr/bin/env node import { assert } from '@0xproject/assert'; -import { schemas } from '@0xproject/json-schemas'; +import { Schema, schemas } from '@0xproject/json-schemas'; import chalk from 'chalk'; import * as _ from 'lodash'; import * as newman from 'newman'; @@ -11,7 +11,6 @@ import * as sraReportCollectionJSON from '../postman_configs/collections/sra_rep 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; @@ -74,14 +73,18 @@ function createGlobals(url: string, schemaList: Schema[]) { enabled: true, type: 'text', }; - const schemaGlobalsValues = _.map(schemaList, (schema: Schema) => { - return { - key: convertSchemaIdToKey(schema.id), - value: JSON.stringify(schema), - enabled: true, - type: 'text', - }; - }); + const schemaGlobalsValues = _.compact(_.map(schemaList, (schema: Schema) => { + if (_.isUndefined(schema.id)) { + return undefined; + } else { + return { + key: convertSchemaIdToKey(schema.id), + value: JSON.stringify(schema), + enabled: true, + type: 'text', + }; + } + })); const globalsValues = _.concat(schemaGlobalsValues, urlGlobalsValue); const globals = { values: globalsValues, diff --git a/packages/sra-report/src/types.ts b/packages/sra-report/src/types.ts deleted file mode 100644 index f08ef4042..000000000 --- a/packages/sra-report/src/types.ts +++ /dev/null @@ -1,3 +0,0 @@ -export interface Schema { - id: string; -} -- cgit From e13924cd2dbe14c426ddadd4ab21a872712ae0fd Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Fri, 23 Feb 2018 11:57:33 -0800 Subject: Remove url from kovan environment json --- .../environments/kovan_tokens.postman_environment.json | 6 ------ 1 file changed, 6 deletions(-) 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 index fc2b1a9ff..f5b28aa0f 100644 --- a/packages/sra-report/postman_configs/environments/kovan_tokens.postman_environment.json +++ b/packages/sra-report/postman_configs/environments/kovan_tokens.postman_environment.json @@ -2,12 +2,6 @@ "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", -- cgit From 55f38b9c35bb8b988eb22ee47d4d671475f05a0e Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Fri, 23 Feb 2018 12:58:36 -0800 Subject: Add an array of schemaKeys to the globals --- packages/sra-report/src/index.ts | 44 ++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/packages/sra-report/src/index.ts b/packages/sra-report/src/index.ts index a24de377a..58734182e 100644 --- a/packages/sra-report/src/index.ts +++ b/packages/sra-report/src/index.ts @@ -13,6 +13,13 @@ import * as mainnetTokensEnvironmentJSON from '../postman_configs/environments/m import { utils } from './utils'; +interface GlobalsValue { + key: string; + value: string; + enabled: boolean; + type: string; +} + const DEFAULT_NETWORK_ID = 1; const SUPPORTED_NETWORK_IDS = [1, 42]; @@ -73,19 +80,30 @@ function createGlobals(url: string, schemaList: Schema[]) { enabled: true, type: 'text', }; - const schemaGlobalsValues = _.compact(_.map(schemaList, (schema: Schema) => { - if (_.isUndefined(schema.id)) { - return undefined; - } else { - return { - key: convertSchemaIdToKey(schema.id), - value: JSON.stringify(schema), - enabled: true, - type: 'text', - }; - } - })); - const globalsValues = _.concat(schemaGlobalsValues, urlGlobalsValue); + const schemaGlobalsValues = _.compact( + _.map(schemaList, (schema: Schema) => { + if (_.isUndefined(schema.id)) { + return undefined; + } else { + return { + key: convertSchemaIdToKey(schema.id), + value: JSON.stringify(schema), + enabled: true, + type: 'text', + }; + } + }), + ); + const schemaKeys = _.map(schemaGlobalsValues, (globalsValue: GlobalsValue) => { + return globalsValue.key; + }); + const schemaKeysGlobalsValue = { + key: 'schemaKeys', + value: JSON.stringify(schemaKeys), + enabled: true, + type: 'text', + }; + const globalsValues = _.concat(schemaGlobalsValues, urlGlobalsValue, schemaKeysGlobalsValue); const globals = { values: globalsValues, }; -- cgit From 0b9646136a79f16b4aaaebd99cf27b79f2cec3a4 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Fri, 23 Feb 2018 14:26:24 -0800 Subject: Update postman collection to load json schemas into tv4 before every test run --- .../collections/sra_report.postman_collection.json | 65 ++++++++++++++++++---- 1 file changed, 53 insertions(+), 12 deletions(-) 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 index 861f040f7..8ba1ba894 100644 --- a/packages/sra-report/postman_configs/collections/sra_report.postman_collection.json +++ b/packages/sra-report/postman_configs/collections/sra_report.postman_collection.json @@ -1,6 +1,6 @@ { "info": { - "name": "0x Standard Relayer API", + "name": "sra_report", "_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.", @@ -226,6 +226,27 @@ } ] }, + { + "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": "GET /orderbook", "description": "", @@ -311,32 +332,42 @@ ] }, { - "name": "GET /order", + "name": "POST /fees", "description": "", "item": [ { - "name": "order by order hash", + "name": "Calculate Fees", "request": { - "method": "GET", - "header": [], - "body": {}, + "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/order/{{_orderHash}}", + "raw": "{{url}}/v0/fees", "host": ["{{url}}"], - "path": ["v0", "order", "{{_orderHash}}"] + "path": ["v0", "fees"] }, - "description": "Retrieves a specific order by orderHash." + "description": + "Given an unsigned order without the fee-related properties, returns the required feeRecipient, makerFee, and takerFee of that order." }, "response": [] } ] }, { - "name": "POST /fees", + "name": "POST /order", "description": "", "item": [ { - "name": "Calculate Fees", + "name": "Submit order", "request": { "method": "POST", "header": [ @@ -369,7 +400,17 @@ "script": { "id": "da60f639-df79-4f4d-9861-79219f5fc341", "type": "text/javascript", - "exec": [""] + "exec": [ + "const schemaKeysString = pm.globals.get('schemaKeys');", + "const schemaKeys = JSON.parse(schemaKeysString);", + "", + "_.forEach(schemaKeys, function(schemaKey) {", + " const schemaString = pm.globals.get(schemaKey);", + " const schema = JSON.parse(schemaString);", + " tv4.addSchema(schema);", + "});", + "" + ] } }, { -- cgit From 4b325676f72fce5bd1205a3cca1e38f41580a7f6 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Mon, 26 Feb 2018 13:32:53 -0800 Subject: Add schema validation to each collection folder and flesh out params --- .../collections/sra_report.postman_collection.json | 471 ++++++++++++++++----- 1 file changed, 355 insertions(+), 116 deletions(-) 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 index 8ba1ba894..91faf0c76 100644 --- a/packages/sra-report/postman_configs/collections/sra_report.postman_collection.json +++ b/packages/sra-report/postman_configs/collections/sra_report.postman_collection.json @@ -3,7 +3,7 @@ "name": "sra_report", "_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.", + "[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": [ @@ -12,12 +12,12 @@ "description": "", "item": [ { - "name": "Default", + "name": "default request", "event": [ { "listen": "test", "script": { - "id": "e25cd907-44f8-4d1e-823a-429d6244e6b4", + "id": "e6a00c7a-acc8-4f51-b0c9-11d005ee1dac", "type": "text/javascript", "exec": [""] } @@ -32,18 +32,17 @@ "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." + "description": "" }, "response": [] }, { - "name": "DAI pairs", + "name": "tokenA param", "event": [ { "listen": "test", "script": { - "id": "cb6e73f9-f5a7-4d75-807a-c9db94dda4f3", + "id": "e6a00c7a-acc8-4f51-b0c9-11d005ee1dac", "type": "text/javascript", "exec": [""] } @@ -54,29 +53,28 @@ "header": [], "body": {}, "url": { - "raw": "{{url}}/v0/token_pairs?tokenA={{DAI_address}}", + "raw": "{{url}}/v0/token_pairs?tokenA={{WETH_address}}", "host": ["{{url}}"], "path": ["v0", "token_pairs"], "query": [ { "key": "tokenA", - "value": "{{DAI_address}}", + "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." + "description": "" }, "response": [] }, { - "name": "WETH pairs", + "name": "tokenB param", "event": [ { "listen": "test", "script": { - "id": "cb6e73f9-f5a7-4d75-807a-c9db94dda4f3", + "id": "e6a00c7a-acc8-4f51-b0c9-11d005ee1dac", "type": "text/javascript", "exec": [""] } @@ -87,7 +85,39 @@ "header": [], "body": {}, "url": { - "raw": "{{url}}/v0/token_pairs?tokenA={{WETH_address}}", + "raw": "{{url}}/v0/token_pairs?tokenB={{WETH_address}}", + "host": ["{{url}}"], + "path": ["v0", "token_pairs"], + "query": [ + { + "key": "tokenB", + "value": "{{WETH_address}}", + "equals": true + } + ] + }, + "description": "" + }, + "response": [] + }, + { + "name": "tokenA and tokenB params", + "event": [ + { + "listen": "test", + "script": { + "id": "e6a00c7a-acc8-4f51-b0c9-11d005ee1dac", + "type": "text/javascript", + "exec": [""] + } + } + ], + "request": { + "method": "GET", + "header": [], + "body": {}, + "url": { + "raw": "{{url}}/v0/token_pairs?tokenA={{WETH_address}}&tokenB={{ZRX_address}}", "host": ["{{url}}"], "path": ["v0", "token_pairs"], "query": [ @@ -95,14 +125,44 @@ "key": "tokenA", "value": "{{WETH_address}}", "equals": true + }, + { + "key": "tokenB", + "value": "{{ZRX_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." + "description": "" }, "response": [] } + ], + "event": [ + { + "listen": "prerequest", + "script": { + "id": "3d032e92-6a17-49f0-8115-bae1c7298b55", + "type": "text/javascript", + "exec": [""] + } + }, + { + "listen": "test", + "script": { + "id": "25addb38-bd1c-4eb3-a193-5617119dc0d6", + "type": "text/javascript", + "exec": [ + "const schema = tv4.getSchema('/RelayerApiTokenPairsResponse');", + "const responseJsonData = pm.response.json();", + "", + "pm.test('Schema is valid', function() {", + " pm.expect(tv4.validate(responseJsonData, schema)).to.be.true;", + "});", + "" + ] + } + } ] }, { @@ -110,19 +170,14 @@ "description": "", "item": [ { - "name": "Default", + "name": "default request", "event": [ { "listen": "test", "script": { - "id": "742679e1-5c16-4fe3-8056-dc7d34257564", + "id": "bd42f688-23d2-4a9c-941c-d5bf34f85519", "type": "text/javascript", - "exec": [ - "const orders = JSON.parse(responseBody);", - "const firstOrder = orders[0];", - "const firstOrderHash = _.get(firstOrder, \"orderHash\");", - "pm.globals.set(\"_orderHash\", firstOrderHash);" - ] + "exec": [""] } } ], @@ -141,12 +196,12 @@ "response": [] }, { - "name": "DAI orders", + "name": "exchangeContract param", "event": [ { "listen": "test", "script": { - "id": "a1eabd96-fee3-4328-ae50-4a992f0401ba", + "id": "bd42f688-23d2-4a9c-941c-d5bf34f85519", "type": "text/javascript", "exec": [""] } @@ -157,16 +212,9 @@ "header": [], "body": {}, "url": { - "raw": "{{url}}/v0/orders?tokenAddress={{DAI_address}}", + "raw": "{{url}}/v0/orders", "host": ["{{url}}"], - "path": ["v0", "orders"], - "query": [ - { - "key": "tokenAddress", - "value": "{{DAI_address}}", - "equals": true - } - ] + "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." @@ -174,12 +222,12 @@ "response": [] }, { - "name": "WETH orders", + "name": "tokenAddress param", "event": [ { "listen": "test", "script": { - "id": "1a0acd0e-5e4a-4e08-b4e9-291a4e9c433a", + "id": "bd42f688-23d2-4a9c-941c-d5bf34f85519", "type": "text/javascript", "exec": [""] } @@ -190,16 +238,191 @@ "header": [], "body": {}, "url": { - "raw": "{{url}}/v0/orders?tokenAddress={{WETH_address}}", + "raw": "{{url}}/v0/orders", "host": ["{{url}}"], - "path": ["v0", "orders"], - "query": [ - { - "key": "tokenAddress", - "value": "{{WETH_address}}", - "equals": true - } - ] + "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": "makerTokenAddress param", + "event": [ + { + "listen": "test", + "script": { + "id": "bd42f688-23d2-4a9c-941c-d5bf34f85519", + "type": "text/javascript", + "exec": [""] + } + } + ], + "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": "takerTokenAddress param", + "event": [ + { + "listen": "test", + "script": { + "id": "bd42f688-23d2-4a9c-941c-d5bf34f85519", + "type": "text/javascript", + "exec": [""] + } + } + ], + "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": "maker param", + "event": [ + { + "listen": "test", + "script": { + "id": "bd42f688-23d2-4a9c-941c-d5bf34f85519", + "type": "text/javascript", + "exec": [""] + } + } + ], + "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": "taker param", + "event": [ + { + "listen": "test", + "script": { + "id": "bd42f688-23d2-4a9c-941c-d5bf34f85519", + "type": "text/javascript", + "exec": [""] + } + } + ], + "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": "trader param", + "event": [ + { + "listen": "test", + "script": { + "id": "bd42f688-23d2-4a9c-941c-d5bf34f85519", + "type": "text/javascript", + "exec": [""] + } + } + ], + "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": "feeRecipient param", + "event": [ + { + "listen": "test", + "script": { + "id": "bd42f688-23d2-4a9c-941c-d5bf34f85519", + "type": "text/javascript", + "exec": [""] + } + } + ], + "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": "makerTokenAddress and takerTokenAddress params", + "event": [ + { + "listen": "test", + "script": { + "id": "bd42f688-23d2-4a9c-941c-d5bf34f85519", + "type": "text/javascript", + "exec": [""] + } + } + ], + "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." @@ -221,7 +444,15 @@ "script": { "id": "d28effd1-4a73-4ee8-82cc-21b1ab06928d", "type": "text/javascript", - "exec": [""] + "exec": [ + "const schema = tv4.getSchema('/signedOrdersSchema');", + "const responseJsonData = pm.response.json();", + "", + "pm.test('Schema is valid', function() {", + " pm.expect(tv4.validate(responseJsonData, schema)).to.be.true;", + "});", + "" + ] } } ] @@ -231,7 +462,7 @@ "description": "", "item": [ { - "name": "order by order hash", + "name": "orderHash param", "request": { "method": "GET", "header": [], @@ -245,6 +476,32 @@ }, "response": [] } + ], + "event": [ + { + "listen": "prerequest", + "script": { + "id": "e356d2ff-d105-42c1-b679-d9d917dcd68d", + "type": "text/javascript", + "exec": [""] + } + }, + { + "listen": "test", + "script": { + "id": "8d2d4717-6f76-47ab-8e5a-f383192f6ee4", + "type": "text/javascript", + "exec": [ + "const schema = tv4.getSchema('/SignedOrder');", + "const responseJsonData = pm.response.json();", + "", + "pm.test('Schema is valid', function() {", + " pm.expect(tv4.validate(responseJsonData, schema)).to.be.true;", + "});", + "" + ] + } + } ] }, { @@ -252,7 +509,7 @@ "description": "", "item": [ { - "name": "ZRX/WETH orderbook", + "name": "baseTokenAddress and quoteTokenAddress params", "event": [ { "listen": "test", @@ -289,45 +546,32 @@ "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": "bdf90dbc-9217-4089-8bc0-351baadddd3e", + "type": "text/javascript", + "exec": [""] + } }, { - "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}}"eTokenAddress={{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": [] + "listen": "test", + "script": { + "id": "d5080a34-57c4-4d5d-8e01-5e79599282ec", + "type": "text/javascript", + "exec": [ + "const schema = tv4.getSchema('/RelayerApiOrderBookResponse');", + "const responseJsonData = pm.response.json();", + "", + "pm.test('Schema is valid', function() {", + " pm.expect(tv4.validate(responseJsonData, schema)).to.be.true;", + "});", + "" + ] + } } ] }, @@ -336,7 +580,7 @@ "description": "", "item": [ { - "name": "Calculate Fees", + "name": "default request", "request": { "method": "POST", "header": [ @@ -360,36 +604,31 @@ }, "response": [] } - ] - }, - { - "name": "POST /order", - "description": "", - "item": [ + ], + "event": [ { - "name": "Submit order", - "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": [] + "listen": "prerequest", + "script": { + "id": "75d66506-0fa9-4b0e-982b-ef53bf3310f8", + "type": "text/javascript", + "exec": [""] + } + }, + { + "listen": "test", + "script": { + "id": "4c5f9f7b-8635-4bdb-9240-a74754a2de4f", + "type": "text/javascript", + "exec": [ + "const schema = tv4.getSchema('/RelayerApiFeesResponse');", + "const responseJsonData = pm.response.json();", + "", + "pm.test('Schema is valid', function() {", + " pm.expect(tv4.validate(responseJsonData, schema)).to.be.true;", + "});", + "" + ] + } } ] } -- cgit From bb157eefc622148d7ab3f49b3b94df274deccedb Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Mon, 26 Feb 2018 17:13:14 -0800 Subject: Add exchange contract address to environment files --- .../environments/kovan_tokens.postman_environment.json | 6 ++++++ .../environments/mainnet_tokens.postman_environment.json | 6 ++++++ 2 files changed, 12 insertions(+) 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 index f5b28aa0f..480c1231b 100644 --- a/packages/sra-report/postman_configs/environments/kovan_tokens.postman_environment.json +++ b/packages/sra-report/postman_configs/environments/kovan_tokens.postman_environment.json @@ -19,6 +19,12 @@ "key": "ZRX_address", "value": "0x6ff6c0ff1d68b964901f986d4c9fa3ac68346570", "type": "text" + }, + { + "enabled": true, + "key": "EXCHANGE_CONTRACT_address", + "value": "0x90fe2af704b34e0224bf2299c838e04d4dcf1364", + "type": "text" } ], "timestamp": 1518639440766, 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 index 0040dda95..f18c38f46 100644 --- a/packages/sra-report/postman_configs/environments/mainnet_tokens.postman_environment.json +++ b/packages/sra-report/postman_configs/environments/mainnet_tokens.postman_environment.json @@ -19,6 +19,12 @@ "key": "ZRX_address", "value": "0xe41d2489571d322189246dafa5ebde1f4699f498", "type": "text" + }, + { + "enabled": true, + "key": "EXCHANGE_CONTRACT_address", + "value": "0x12459c951127e0c374ff9105dda097662a027093", + "type": "text" } ], "timestamp": 1518561760642, -- cgit From 9c8501a84e92faf3ef015ae8ab4d1da9354f9a9d Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Tue, 27 Feb 2018 11:51:05 -0800 Subject: Refactor environment factory and promisify newman --- packages/sra-report/package.json | 3 + packages/sra-report/src/index.ts | 87 ++++------------------ .../sra-report/src/postman_environment_factory.ts | 71 ++++++++++++++++++ 3 files changed, 87 insertions(+), 74 deletions(-) create mode 100644 packages/sra-report/src/postman_environment_factory.ts diff --git a/packages/sra-report/package.json b/packages/sra-report/package.json index 8265ceb28..6168c128e 100644 --- a/packages/sra-report/package.json +++ b/packages/sra-report/package.json @@ -23,8 +23,11 @@ }, "homepage": "https://github.com/0xProject/0x.js/packages/abi-gen/README.md", "dependencies": { + "0x.js": "^0.32.4", "@0xproject/assert": "^0.0.20", + "@0xproject/connect": "^0.6.1", "@0xproject/json-schemas": "^0.7.12", + "@0xproject/utils": "^0.3.4", "chalk": "^2.3.0", "lodash": "^4.17.4", "newman": "^3.9.3", diff --git a/packages/sra-report/src/index.ts b/packages/sra-report/src/index.ts index 58734182e..d273d74a4 100644 --- a/packages/sra-report/src/index.ts +++ b/packages/sra-report/src/index.ts @@ -2,23 +2,18 @@ import { assert } from '@0xproject/assert'; import { Schema, schemas } from '@0xproject/json-schemas'; +import { promisify } from '@0xproject/utils'; 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 { postmanEnvironmentFactory } from './postman_environment_factory'; import { utils } from './utils'; -interface GlobalsValue { - key: string; - value: string; - enabled: boolean; - type: string; -} +const newmanRunAsync = promisify(newman.run); const DEFAULT_NETWORK_ID = 1; const SUPPORTED_NETWORK_IDS = [1, 42]; @@ -58,72 +53,16 @@ if (!_.includes(SUPPORTED_NETWORK_IDS, args.networkId)) { utils.log(`${chalk.bold(`Supported network ids:`)} ${SUPPORTED_NETWORK_IDS}`); process.exit(1); } -// run newman -newman.run( - { + +const mainAsync = async () => { + const newmanRunOptions = { 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 = _.compact( - _.map(schemaList, (schema: Schema) => { - if (_.isUndefined(schema.id)) { - return undefined; - } else { - return { - key: convertSchemaIdToKey(schema.id), - value: JSON.stringify(schema), - enabled: true, - type: 'text', - }; - } - }), - ); - const schemaKeys = _.map(schemaGlobalsValues, (globalsValue: GlobalsValue) => { - return globalsValue.key; - }); - const schemaKeysGlobalsValue = { - key: 'schemaKeys', - value: JSON.stringify(schemaKeys), - enabled: true, - type: 'text', - }; - const globalsValues = _.concat(schemaGlobalsValues, urlGlobalsValue, schemaKeysGlobalsValue); - const globals = { - values: globalsValues, + globals: postmanEnvironmentFactory.createGlobalEnvironment(args.url), + environment: postmanEnvironmentFactory.createNetworkEnvironment(args.networkId), }; - 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 {}; - } -} + await newmanRunAsync(newmanRunOptions); +}; + +mainAsync() + .catch(err => utils.log); diff --git a/packages/sra-report/src/postman_environment_factory.ts b/packages/sra-report/src/postman_environment_factory.ts new file mode 100644 index 000000000..697578a2d --- /dev/null +++ b/packages/sra-report/src/postman_environment_factory.ts @@ -0,0 +1,71 @@ +import { Schema, schemas as schemasByName } from '@0xproject/json-schemas'; +import * as _ from 'lodash'; + +import * as kovanTokensEnvironmentJSON from '../postman_configs/environments/kovan_tokens.postman_environment.json'; +import * as mainnetTokensEnvironmentJSON from '../postman_configs/environments/mainnet_tokens.postman_environment.json'; + +interface EnvironmentValue { + key: string; + value: string; + enabled: boolean; + type: string; +} + +export const postmanEnvironmentFactory = { + createGlobalEnvironment(url: string) { + const urlEnvironmentValue = { + key: 'url', + value: url, + enabled: true, + type: 'text', + }; + const schemas: Schema[] = _.values(schemasByName); + const schemaEnvironmentValues = _.compact( + _.map(schemas, (schema: Schema) => { + if (_.isUndefined(schema.id)) { + return undefined; + } else { + return { + key: convertSchemaIdToKey(schema.id), + value: JSON.stringify(schema), + enabled: true, + type: 'text', + }; + } + }), + ); + const schemaKeys = _.map(schemaEnvironmentValues, (environmentValue: EnvironmentValue) => { + return environmentValue.key; + }); + const schemaKeysEnvironmentValue = { + key: 'schemaKeys', + value: JSON.stringify(schemaKeys), + enabled: true, + type: 'text', + }; + const environmentValues = _.concat(schemaEnvironmentValues, urlEnvironmentValue, schemaKeysEnvironmentValue); + const environment = { + values: environmentValues, + }; + return environment; + }, + createNetworkEnvironment(networkId: number) { + switch (networkId) { + case 1: + return mainnetTokensEnvironmentJSON; + case 42: + return kovanTokensEnvironmentJSON; + default: + return {}; + } + }, +}; + +function convertSchemaIdToKey(schemaId: string) { + let result = schemaId; + if (_.startsWith(result, '/')) { + result = result.substr(1); + } + result = `${result}Schema`; + return result; +} -- cgit From e48a3edacba891a18e641e01708e3d73fd6588ac Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Tue, 27 Feb 2018 14:06:33 -0800 Subject: Get orderHash via 0x connect --- packages/sra-report/src/index.ts | 15 ++++++-- .../sra-report/src/postman_environment_factory.ts | 43 +++++++++++----------- 2 files changed, 33 insertions(+), 25 deletions(-) diff --git a/packages/sra-report/src/index.ts b/packages/sra-report/src/index.ts index d273d74a4..bd0615480 100644 --- a/packages/sra-report/src/index.ts +++ b/packages/sra-report/src/index.ts @@ -1,6 +1,8 @@ #!/usr/bin/env node +import { ZeroEx } from '0x.js'; import { assert } from '@0xproject/assert'; +import { HttpClient } from '@0xproject/connect'; import { Schema, schemas } from '@0xproject/json-schemas'; import { promisify } from '@0xproject/utils'; import chalk from 'chalk'; @@ -14,7 +16,6 @@ import { postmanEnvironmentFactory } from './postman_environment_factory'; import { utils } from './utils'; const newmanRunAsync = promisify(newman.run); - const DEFAULT_NETWORK_ID = 1; const SUPPORTED_NETWORK_IDS = [1, 42]; @@ -55,14 +56,20 @@ if (!_.includes(SUPPORTED_NETWORK_IDS, args.networkId)) { } const mainAsync = async () => { + const httpClient = new HttpClient(args.url); + const orders = await httpClient.getOrdersAsync(); + const firstOrder = _.head(orders); + if (_.isUndefined(firstOrder)) { + throw new Error('Could not get any orders from /orders endpoint'); + } + const orderHash = ZeroEx.getOrderHashHex(firstOrder); const newmanRunOptions = { collection: sraReportCollectionJSON, reporters: 'cli', - globals: postmanEnvironmentFactory.createGlobalEnvironment(args.url), + globals: postmanEnvironmentFactory.createGlobalEnvironment(args.url, orderHash), environment: postmanEnvironmentFactory.createNetworkEnvironment(args.networkId), }; await newmanRunAsync(newmanRunOptions); }; -mainAsync() - .catch(err => utils.log); +mainAsync().catch(utils.log); diff --git a/packages/sra-report/src/postman_environment_factory.ts b/packages/sra-report/src/postman_environment_factory.ts index 697578a2d..b0b69ddad 100644 --- a/packages/sra-report/src/postman_environment_factory.ts +++ b/packages/sra-report/src/postman_environment_factory.ts @@ -12,38 +12,32 @@ interface EnvironmentValue { } export const postmanEnvironmentFactory = { - createGlobalEnvironment(url: string) { - const urlEnvironmentValue = { - key: 'url', - value: url, - enabled: true, - type: 'text', - }; + createGlobalEnvironment(url: string, orderHash: string) { + const urlEnvironmentValue = createEnvironmentValue('url', url); + const orderHashEnvironmentValue = createEnvironmentValue('orderHash', orderHash); const schemas: Schema[] = _.values(schemasByName); const schemaEnvironmentValues = _.compact( _.map(schemas, (schema: Schema) => { if (_.isUndefined(schema.id)) { return undefined; } else { - return { - key: convertSchemaIdToKey(schema.id), - value: JSON.stringify(schema), - enabled: true, - type: 'text', - }; + const schemaKey = convertSchemaIdToKey(schema.id); + const stringifiedSchema = JSON.stringify(schema); + const schemaEnvironmentValue = createEnvironmentValue(schemaKey, stringifiedSchema); + return schemaEnvironmentValue; } }), ); const schemaKeys = _.map(schemaEnvironmentValues, (environmentValue: EnvironmentValue) => { return environmentValue.key; }); - const schemaKeysEnvironmentValue = { - key: 'schemaKeys', - value: JSON.stringify(schemaKeys), - enabled: true, - type: 'text', - }; - const environmentValues = _.concat(schemaEnvironmentValues, urlEnvironmentValue, schemaKeysEnvironmentValue); + const schemaKeysEnvironmentValue = createEnvironmentValue('schemaKeys', JSON.stringify(schemaKeys)); + const environmentValues = _.concat( + schemaEnvironmentValues, + urlEnvironmentValue, + schemaKeysEnvironmentValue, + orderHashEnvironmentValue, + ); const environment = { values: environmentValues, }; @@ -60,7 +54,6 @@ export const postmanEnvironmentFactory = { } }, }; - function convertSchemaIdToKey(schemaId: string) { let result = schemaId; if (_.startsWith(result, '/')) { @@ -69,3 +62,11 @@ function convertSchemaIdToKey(schemaId: string) { result = `${result}Schema`; return result; } +function createEnvironmentValue(key: string, value: string) { + return { + key, + value, + enabled: true, + type: 'text', + }; +} -- cgit From 0987c9a7cfb1936469062b4cb6222158b5e110b7 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Tue, 27 Feb 2018 17:12:45 -0800 Subject: Write to provided output directory --- packages/sra-report/src/index.ts | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/packages/sra-report/src/index.ts b/packages/sra-report/src/index.ts index bd0615480..fade07095 100644 --- a/packages/sra-report/src/index.ts +++ b/packages/sra-report/src/index.ts @@ -63,13 +63,27 @@ const mainAsync = async () => { throw new Error('Could not get any orders from /orders endpoint'); } const orderHash = ZeroEx.getOrderHashHex(firstOrder); - const newmanRunOptions = { + const newmanEnvironmentOptions = { collection: sraReportCollectionJSON, - reporters: 'cli', globals: postmanEnvironmentFactory.createGlobalEnvironment(args.url, orderHash), environment: postmanEnvironmentFactory.createNetworkEnvironment(args.networkId), }; + const newmanReporterOptions = !_.isUndefined(args.output) + ? { + reporters: 'json', + reporter: { + json: { + export: args.output, + }, + }, + } + : { + reporters: 'cli', + }; + const newmanRunOptions = { + ...newmanEnvironmentOptions, + ...newmanReporterOptions, + }; await newmanRunAsync(newmanRunOptions); }; - mainAsync().catch(utils.log); -- cgit From a3c7af95e17dda91efaff83824c43f8ffb28f078 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Tue, 27 Feb 2018 17:25:42 -0800 Subject: Add stringified order object into globals --- packages/sra-report/src/index.ts | 5 +---- packages/sra-report/src/postman_environment_factory.ts | 11 +++++++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/sra-report/src/index.ts b/packages/sra-report/src/index.ts index fade07095..bee9db192 100644 --- a/packages/sra-report/src/index.ts +++ b/packages/sra-report/src/index.ts @@ -1,6 +1,4 @@ #!/usr/bin/env node - -import { ZeroEx } from '0x.js'; import { assert } from '@0xproject/assert'; import { HttpClient } from '@0xproject/connect'; import { Schema, schemas } from '@0xproject/json-schemas'; @@ -62,10 +60,9 @@ const mainAsync = async () => { if (_.isUndefined(firstOrder)) { throw new Error('Could not get any orders from /orders endpoint'); } - const orderHash = ZeroEx.getOrderHashHex(firstOrder); const newmanEnvironmentOptions = { collection: sraReportCollectionJSON, - globals: postmanEnvironmentFactory.createGlobalEnvironment(args.url, orderHash), + globals: postmanEnvironmentFactory.createGlobalEnvironment(args.url, firstOrder), environment: postmanEnvironmentFactory.createNetworkEnvironment(args.networkId), }; const newmanReporterOptions = !_.isUndefined(args.output) diff --git a/packages/sra-report/src/postman_environment_factory.ts b/packages/sra-report/src/postman_environment_factory.ts index b0b69ddad..bea805ca6 100644 --- a/packages/sra-report/src/postman_environment_factory.ts +++ b/packages/sra-report/src/postman_environment_factory.ts @@ -1,3 +1,7 @@ +import { + SignedOrder, + ZeroEx, + } from '0x.js'; import { Schema, schemas as schemasByName } from '@0xproject/json-schemas'; import * as _ from 'lodash'; @@ -12,9 +16,11 @@ interface EnvironmentValue { } export const postmanEnvironmentFactory = { - createGlobalEnvironment(url: string, orderHash: string) { - const urlEnvironmentValue = createEnvironmentValue('url', url); + createGlobalEnvironment(url: string, order: SignedOrder) { + const orderHash = ZeroEx.getOrderHashHex(order); + const orderEnvironmentValue = createEnvironmentValue('order', JSON.stringify(order)); const orderHashEnvironmentValue = createEnvironmentValue('orderHash', orderHash); + const urlEnvironmentValue = createEnvironmentValue('url', url); const schemas: Schema[] = _.values(schemasByName); const schemaEnvironmentValues = _.compact( _.map(schemas, (schema: Schema) => { @@ -36,6 +42,7 @@ export const postmanEnvironmentFactory = { schemaEnvironmentValues, urlEnvironmentValue, schemaKeysEnvironmentValue, + orderEnvironmentValue, orderHashEnvironmentValue, ); const environment = { -- cgit From 17328bce53d67da4f99ca8e803b209350f1d2e0d Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Wed, 28 Feb 2018 16:13:03 -0800 Subject: Add more globals --- .../sra-report/src/postman_environment_factory.ts | 25 +++++++++------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/packages/sra-report/src/postman_environment_factory.ts b/packages/sra-report/src/postman_environment_factory.ts index bea805ca6..a8753d9ff 100644 --- a/packages/sra-report/src/postman_environment_factory.ts +++ b/packages/sra-report/src/postman_environment_factory.ts @@ -1,7 +1,4 @@ -import { - SignedOrder, - ZeroEx, - } from '0x.js'; +import { SignedOrder, ZeroEx } from '0x.js'; import { Schema, schemas as schemasByName } from '@0xproject/json-schemas'; import * as _ from 'lodash'; @@ -17,10 +14,6 @@ interface EnvironmentValue { export const postmanEnvironmentFactory = { createGlobalEnvironment(url: string, order: SignedOrder) { - const orderHash = ZeroEx.getOrderHashHex(order); - const orderEnvironmentValue = createEnvironmentValue('order', JSON.stringify(order)); - const orderHashEnvironmentValue = createEnvironmentValue('orderHash', orderHash); - const urlEnvironmentValue = createEnvironmentValue('url', url); const schemas: Schema[] = _.values(schemasByName); const schemaEnvironmentValues = _.compact( _.map(schemas, (schema: Schema) => { @@ -37,16 +30,18 @@ export const postmanEnvironmentFactory = { const schemaKeys = _.map(schemaEnvironmentValues, (environmentValue: EnvironmentValue) => { return environmentValue.key; }); - const schemaKeysEnvironmentValue = createEnvironmentValue('schemaKeys', JSON.stringify(schemaKeys)); - const environmentValues = _.concat( + const allEnvironmentValues = _.concat( schemaEnvironmentValues, - urlEnvironmentValue, - schemaKeysEnvironmentValue, - orderEnvironmentValue, - orderHashEnvironmentValue, + createEnvironmentValue('schemaKeys', JSON.stringify(schemaKeys)), + createEnvironmentValue('url', url), + createEnvironmentValue('order', JSON.stringify(order)), + createEnvironmentValue('orderMaker', order.maker), + createEnvironmentValue('orderTaker', order.taker), + createEnvironmentValue('orderFeeRecipient', order.feeRecipient), + createEnvironmentValue('orderHash', ZeroEx.getOrderHashHex(order)), ); const environment = { - values: environmentValues, + values: allEnvironmentValues, }; return environment; }, -- cgit From 003d43b03ae373ca24d6d728ffa6b0f2dfcda79a Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Wed, 28 Feb 2018 16:59:40 -0800 Subject: Flesh out postman test cases --- .../collections/sra_report.postman_collection.json | 453 +++++++++++++++++---- 1 file changed, 363 insertions(+), 90 deletions(-) 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 index 91faf0c76..569596576 100644 --- a/packages/sra-report/postman_configs/collections/sra_report.postman_collection.json +++ b/packages/sra-report/postman_configs/collections/sra_report.postman_collection.json @@ -17,7 +17,7 @@ { "listen": "test", "script": { - "id": "e6a00c7a-acc8-4f51-b0c9-11d005ee1dac", + "id": "42cb5e3f-6013-4a7c-b341-0d10cb3f2c9c", "type": "text/javascript", "exec": [""] } @@ -28,9 +28,9 @@ "header": [], "body": {}, "url": { - "raw": "{{url}}/v0/token_pairs", + "raw": "{{url}}/token_pairs", "host": ["{{url}}"], - "path": ["v0", "token_pairs"] + "path": ["token_pairs"] }, "description": "" }, @@ -42,9 +42,24 @@ { "listen": "test", "script": { - "id": "e6a00c7a-acc8-4f51-b0c9-11d005ee1dac", + "id": "53ad6be0-4196-47a1-bbf5-fa96e3c5d47e", "type": "text/javascript", - "exec": [""] + "exec": [ + "const filterTokenEnvKey = 'WETH_address';", + "const filterTokenAddress = pm.environment.get(filterTokenEnvKey);", + "const responseJsonData = pm.response.json();", + "pm.test('Token pairs are properly filtered', function() {", + " _.forEach(responseJsonData, function(tokenPair) {", + " const tokenAIsFilterToken = _.get(tokenPair, 'tokenA') === filterTokenAddress;", + " const tokenBIsFilterToken = _.get(tokenPair, 'tokenB') === filterTokenAddress;", + " const condition = tokenAIsFilterToken || tokenBIsFilterToken", + " pm.expect(condition).to.be.true;", + " });", + "});", + "", + "", + "" + ] } } ], @@ -53,9 +68,9 @@ "header": [], "body": {}, "url": { - "raw": "{{url}}/v0/token_pairs?tokenA={{WETH_address}}", + "raw": "{{url}}/token_pairs?tokenA={{WETH_address}}", "host": ["{{url}}"], - "path": ["v0", "token_pairs"], + "path": ["token_pairs"], "query": [ { "key": "tokenA", @@ -74,9 +89,27 @@ { "listen": "test", "script": { - "id": "e6a00c7a-acc8-4f51-b0c9-11d005ee1dac", + "id": "7224b56e-0000-4d77-b355-f9bfd7d6320f", "type": "text/javascript", - "exec": [""] + "exec": [ + "const filterTokenEnvKey = 'WETH_address';", + "const filterTokenAddress = pm.environment.get(filterTokenEnvKey);", + "const responseJsonData = pm.response.json();", + "pm.test('Token pairs are properly filtered', function() {", + " _.forEach(responseJsonData, function(tokenPair) {", + " const tokenAIsFilterToken = _.get(tokenPair, 'tokenA') === filterTokenAddress;", + " const tokenBIsFilterToken = _.get(tokenPair, 'tokenB') === filterTokenAddress;", + " const condition = tokenAIsFilterToken || tokenBIsFilterToken", + " pm.expect(condition).to.be.true;", + " });", + "});", + "", + "", + "", + "", + "", + "" + ] } } ], @@ -85,9 +118,9 @@ "header": [], "body": {}, "url": { - "raw": "{{url}}/v0/token_pairs?tokenB={{WETH_address}}", + "raw": "{{url}}/token_pairs?tokenB={{WETH_address}}", "host": ["{{url}}"], - "path": ["v0", "token_pairs"], + "path": ["token_pairs"], "query": [ { "key": "tokenB", @@ -106,9 +139,26 @@ { "listen": "test", "script": { - "id": "e6a00c7a-acc8-4f51-b0c9-11d005ee1dac", + "id": "32a19952-90c7-4f11-b95c-815b0746ef8b", "type": "text/javascript", - "exec": [""] + "exec": [ + "const filterTokenAEnvKey = 'WETH_address';", + "const filterTokenBEnvKey = 'ZRX_address';", + "const filterTokenAAddress = pm.environment.get(filterTokenAEnvKey);", + "const filterTokenBAddress = pm.environment.get(filterTokenBEnvKey);", + "const responseJsonData = pm.response.json();", + "pm.test('Token pairs are properly filtered', function() {", + " _.forEach(responseJsonData, function(tokenPair) {", + " const tokenAIsFilterTokenA = _.get(tokenPair, 'tokenA') === filterTokenAAddress;", + " const tokenAIsFilterTokenB = _.get(tokenPair, 'tokenA') === filterTokenBAddress;", + " const tokenBIsFilterTokenA = _.get(tokenPair, 'tokenB') === filterTokenAAddress;", + " const tokenBIsFilterTokenB = _.get(tokenPair, 'tokenB') === filterTokenBAddress;", + " const condition = (tokenAIsFilterTokenA && tokenBIsFilterTokenB) || (tokenBIsFilterTokenA && tokenAIsFilterTokenB)", + " pm.expect(condition).to.be.true;", + " });", + "});", + "" + ] } } ], @@ -117,9 +167,9 @@ "header": [], "body": {}, "url": { - "raw": "{{url}}/v0/token_pairs?tokenA={{WETH_address}}&tokenB={{ZRX_address}}", + "raw": "{{url}}/token_pairs?tokenA={{WETH_address}}&tokenB={{ZRX_address}}", "host": ["{{url}}"], - "path": ["v0", "token_pairs"], + "path": ["token_pairs"], "query": [ { "key": "tokenA", @@ -157,7 +207,7 @@ "const responseJsonData = pm.response.json();", "", "pm.test('Schema is valid', function() {", - " pm.expect(tv4.validate(responseJsonData, schema)).to.be.true;", + " pm.expect(tv4.validate(responseJsonData, schema)).to.be.true;", "});", "" ] @@ -175,7 +225,7 @@ { "listen": "test", "script": { - "id": "bd42f688-23d2-4a9c-941c-d5bf34f85519", + "id": "118f47dd-1d93-4288-841f-de88783eff3b", "type": "text/javascript", "exec": [""] } @@ -186,9 +236,9 @@ "header": [], "body": {}, "url": { - "raw": "{{url}}/v0/orders", + "raw": "{{url}}/orders", "host": ["{{url}}"], - "path": ["v0", "orders"] + "path": ["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." @@ -201,9 +251,22 @@ { "listen": "test", "script": { - "id": "bd42f688-23d2-4a9c-941c-d5bf34f85519", + "id": "f10e0a91-3401-4023-afef-5bff93a25232", "type": "text/javascript", - "exec": [""] + "exec": [ + "const exchangeContractEnvKey = 'EXCHANGE_CONTRACT_address';", + "const requestedExchangeContractAddress = pm.environment.get(exchangeContractEnvKey);", + "const responseJsonData = pm.response.json();", + "pm.test('Orders are properly filtered', function() {", + " _.forEach(responseJsonData, function(order) {", + " const returnedExchangeContractAddress = _.get(order, 'exchangeContractAddress');", + " pm.expect(requestedExchangeContractAddress).to.equal(returnedExchangeContractAddress);", + " });", + "});", + "", + "", + "" + ] } } ], @@ -212,9 +275,16 @@ "header": [], "body": {}, "url": { - "raw": "{{url}}/v0/orders", + "raw": "{{url}}/orders?exchangeContractAddress={{EXCHANGE_CONTRACT_address}}", "host": ["{{url}}"], - "path": ["v0", "orders"] + "path": ["orders"], + "query": [ + { + "key": "exchangeContractAddress", + "value": "{{EXCHANGE_CONTRACT_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." @@ -227,9 +297,26 @@ { "listen": "test", "script": { - "id": "bd42f688-23d2-4a9c-941c-d5bf34f85519", + "id": "d915624e-9d71-4499-a133-cc8268199895", "type": "text/javascript", - "exec": [""] + "exec": [ + "const filterTokenEnvKey = 'ZRX_address';", + "const filterTokenAddress = pm.environment.get(filterTokenEnvKey);", + "const responseJsonData = pm.response.json();", + "pm.test('Orders are properly filtered', function() {", + " _.forEach(responseJsonData, function(order) {", + " const makerTokenAddress = _.get(order, 'makerTokenAddress');", + " const takerTokenAddress = _.get(order, 'takerTokenAddress');", + " const makerTokenAddressIsFilterToken = makerTokenAddress === filterTokenAddress;", + " const takerTokenAddressIsFilterToken = takerTokenAddress === filterTokenAddress;", + " const condition = makerTokenAddressIsFilterToken || takerTokenAddressIsFilterToken;", + " pm.expect(condition).to.be.true;", + " });", + "});", + "", + "", + "" + ] } } ], @@ -238,9 +325,16 @@ "header": [], "body": {}, "url": { - "raw": "{{url}}/v0/orders", + "raw": "{{url}}/orders?tokenAddress={{ZRX_address}}", "host": ["{{url}}"], - "path": ["v0", "orders"] + "path": ["orders"], + "query": [ + { + "key": "tokenAddress", + "value": "{{ZRX_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." @@ -253,9 +347,22 @@ { "listen": "test", "script": { - "id": "bd42f688-23d2-4a9c-941c-d5bf34f85519", + "id": "5599a829-b127-4b21-8690-12cc764972a9", "type": "text/javascript", - "exec": [""] + "exec": [ + "const filterTokenEnvKey = 'ZRX_address';", + "const filterTokenAddress = pm.environment.get(filterTokenEnvKey);", + "const responseJsonData = pm.response.json();", + "pm.test('Orders are properly filtered', function() {", + " _.forEach(responseJsonData, function(order) {", + " const makerTokenAddress = _.get(order, 'makerTokenAddress');", + " pm.expect(makerTokenAddress).to.be.equal(filterTokenAddress);", + " });", + "});", + "", + "", + "" + ] } } ], @@ -264,9 +371,16 @@ "header": [], "body": {}, "url": { - "raw": "{{url}}/v0/orders", + "raw": "{{url}}/orders?makerTokenAddress={{ZRX_address}}", "host": ["{{url}}"], - "path": ["v0", "orders"] + "path": ["orders"], + "query": [ + { + "key": "makerTokenAddress", + "value": "{{ZRX_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." @@ -279,9 +393,22 @@ { "listen": "test", "script": { - "id": "bd42f688-23d2-4a9c-941c-d5bf34f85519", + "id": "d5ac5604-b13b-40c2-ba31-3033f52136a2", "type": "text/javascript", - "exec": [""] + "exec": [ + "const filterTokenEnvKey = 'ZRX_address';", + "const filterTokenAddress = pm.environment.get(filterTokenEnvKey);", + "const responseJsonData = pm.response.json();", + "pm.test('Orders are properly filtered', function() {", + " _.forEach(responseJsonData, function(order) {", + " const takerTokenAddress = _.get(order, 'takerTokenAddress');", + " pm.expect(takerTokenAddress).to.be.equal(filterTokenAddress);", + " });", + "});", + "", + "", + "" + ] } } ], @@ -290,9 +417,16 @@ "header": [], "body": {}, "url": { - "raw": "{{url}}/v0/orders", + "raw": "{{url}}/orders?takerTokenAddress={{ZRX_address}}", "host": ["{{url}}"], - "path": ["v0", "orders"] + "path": ["orders"], + "query": [ + { + "key": "takerTokenAddress", + "value": "{{ZRX_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." @@ -305,9 +439,20 @@ { "listen": "test", "script": { - "id": "bd42f688-23d2-4a9c-941c-d5bf34f85519", + "id": "efc85eb8-7791-4b14-9dee-c5e80adec4b8", "type": "text/javascript", - "exec": [""] + "exec": [ + "const orderMakerEnvKey = 'orderMaker';", + "const referenceOrderMakerAddress = pm.globals.get(orderMakerEnvKey);", + "const responseJsonData = pm.response.json();", + "pm.test('Orders are properly filtered', function() {", + " _.forEach(responseJsonData, function(order) {", + " const returnedMakerAddress = _.get(order, 'maker');", + " pm.expect(referenceOrderMakerAddress).to.be.equal(returnedMakerAddress);", + " });", + "});", + "" + ] } } ], @@ -316,9 +461,16 @@ "header": [], "body": {}, "url": { - "raw": "{{url}}/v0/orders", + "raw": "{{url}}/orders?maker={{orderMaker}}", "host": ["{{url}}"], - "path": ["v0", "orders"] + "path": ["orders"], + "query": [ + { + "key": "maker", + "value": "{{orderMaker}}", + "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." @@ -331,9 +483,22 @@ { "listen": "test", "script": { - "id": "bd42f688-23d2-4a9c-941c-d5bf34f85519", + "id": "a299a290-58b9-434c-b5e8-98ef9e5f70da", "type": "text/javascript", - "exec": [""] + "exec": [ + "const orderTakerEnvKey = 'orderTaker';", + "const referenceOrderTakerAddress = pm.globals.get(orderTakerEnvKey);", + "const responseJsonData = pm.response.json();", + "pm.test('Orders are properly filtered', function() {", + " _.forEach(responseJsonData, function(order) {", + " const returnedTakerAddress = _.get(order, 'taker');", + " pm.expect(referenceOrderTakerAddress).to.be.equal(returnedTakerAddress);", + " });", + "});", + "", + "", + "" + ] } } ], @@ -342,9 +507,16 @@ "header": [], "body": {}, "url": { - "raw": "{{url}}/v0/orders", + "raw": "{{url}}/orders?taker={{orderTaker}}", "host": ["{{url}}"], - "path": ["v0", "orders"] + "path": ["orders"], + "query": [ + { + "key": "taker", + "value": "{{orderTaker}}", + "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." @@ -357,9 +529,25 @@ { "listen": "test", "script": { - "id": "bd42f688-23d2-4a9c-941c-d5bf34f85519", + "id": "e80aa474-3352-45dd-87ef-2980bab961fb", "type": "text/javascript", - "exec": [""] + "exec": [ + "const orderTraderEnvKey = 'orderMaker';", + "const referenceOrderTraderAddress = pm.globals.get(orderTraderEnvKey);", + "const responseJsonData = pm.response.json();", + "pm.test('Orders are properly filtered', function() {", + " _.forEach(responseJsonData, function(order) {", + " const returnedMakerAddress = _.get(order, 'maker');", + " const returnedTakerAddress = _.get(order, 'taker');", + " const condition = (referenceOrderTraderAddress === returnedMakerAddress) || (referenceOrderTraderAddress === returnedTakerAddress);", + " pm.expect(condition).to.be.true;", + " });", + "});", + "", + "", + "", + "" + ] } } ], @@ -368,9 +556,16 @@ "header": [], "body": {}, "url": { - "raw": "{{url}}/v0/orders", + "raw": "{{url}}/orders?trader={{orderMaker}}", "host": ["{{url}}"], - "path": ["v0", "orders"] + "path": ["orders"], + "query": [ + { + "key": "trader", + "value": "{{orderMaker}}", + "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." @@ -383,35 +578,23 @@ { "listen": "test", "script": { - "id": "bd42f688-23d2-4a9c-941c-d5bf34f85519", - "type": "text/javascript", - "exec": [""] - } - } - ], - "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": "makerTokenAddress and takerTokenAddress params", - "event": [ - { - "listen": "test", - "script": { - "id": "bd42f688-23d2-4a9c-941c-d5bf34f85519", + "id": "fb34198e-221b-406d-8da4-4e7eed400cbe", "type": "text/javascript", - "exec": [""] + "exec": [ + "const orderFeeRecipientEnvKey = 'orderFeeRecipient';", + "const referenceOrderFeeRecipientAddress = pm.globals.get(orderFeeRecipientEnvKey);", + "const responseJsonData = pm.response.json();", + "pm.test('Orders are properly filtered', function() {", + " _.forEach(responseJsonData, function(order) {", + " const returnedFeeRecipientAddress = _.get(order, 'feeRecipient');", + " pm.expect(referenceOrderFeeRecipientAddress).to.be.equal(returnedFeeRecipientAddress);", + " });", + "});", + "", + "", + "", + "" + ] } } ], @@ -420,9 +603,16 @@ "header": [], "body": {}, "url": { - "raw": "{{url}}/v0/orders", + "raw": "{{url}}/orders?feeRecipient={{orderFeeRecipient}}", "host": ["{{url}}"], - "path": ["v0", "orders"] + "path": ["orders"], + "query": [ + { + "key": "feeRecipient", + "value": "{{orderFeeRecipient}}", + "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." @@ -449,7 +639,7 @@ "const responseJsonData = pm.response.json();", "", "pm.test('Schema is valid', function() {", - " pm.expect(tv4.validate(responseJsonData, schema)).to.be.true;", + " pm.expect(tv4.validate(responseJsonData, schema)).to.be.true;", "});", "" ] @@ -463,14 +653,65 @@ "item": [ { "name": "orderHash param", + "event": [ + { + "listen": "test", + "script": { + "id": "e847f317-6346-4ee5-bd94-7554eb3073b3", + "type": "text/javascript", + "exec": [ + "const orderEnvKey = 'order';", + "const referenceOrderString = pm.globals.get(orderEnvKey);", + "const referenceOrderJson = JSON.parse(referenceOrderString);", + "const orderPropertyNames = [", + " 'maker',", + " 'taker',", + " 'makerFee',", + " 'takerFee',", + " 'makerTokenAmount',", + " 'takerTokenAmount',", + " 'makerTokenAddress',", + " 'takerTokenAddress',", + " 'salt',", + " 'feeRecipient',", + " 'expirationUnixTimestampSec',", + " 'exchangeContractAddress'", + "];", + "const signaturePropertyNames = [", + " 'v',", + " 'r',", + " 's'", + "];", + "const returnedOrderJson = pm.response.json();", + "pm.test('Order is properly retreived', function() {", + " _.forEach(orderPropertyNames, function(propertyName) {", + " const returnedProperty = _.get(returnedOrderJson, propertyName);", + " const referenceProperty = _.get(referenceOrderJson, propertyName);", + " pm.expect(returnedProperty).to.be.equal(referenceProperty);", + " });", + " const returnedSignature = _.get(returnedOrderJson, 'ecSignature');", + " const referenceSignature = _.get(returnedOrderJson, 'ecSignature');", + " _.forEach(signaturePropertyNames, function(propertyName) {", + " const returnedSignatureProperty = _.get(returnedSignature, propertyName);", + " const referenceSignatureProperty = _.get(referenceSignature, propertyName);", + " pm.expect(returnedSignatureProperty).to.be.equal(referenceSignatureProperty);", + " });", + "});", + "", + "", + "" + ] + } + } + ], "request": { "method": "GET", "header": [], "body": {}, "url": { - "raw": "{{url}}/v0/order/{{_orderHash}}", + "raw": "{{url}}/order/{{orderHash}}", "host": ["{{url}}"], - "path": ["v0", "order", "{{_orderHash}}"] + "path": ["order", "{{orderHash}}"] }, "description": "Retrieves a specific order by orderHash." }, @@ -496,7 +737,7 @@ "const responseJsonData = pm.response.json();", "", "pm.test('Schema is valid', function() {", - " pm.expect(tv4.validate(responseJsonData, schema)).to.be.true;", + " pm.expect(tv4.validate(responseJsonData, schema)).to.be.true;", "});", "" ] @@ -514,9 +755,35 @@ { "listen": "test", "script": { - "id": "1a0acd0e-5e4a-4e08-b4e9-291a4e9c433a", + "id": "67d95152-3561-4db2-aaba-d26ceb44b4fd", "type": "text/javascript", - "exec": [""] + "exec": [ + "const baseTokenEnvKey = 'ZRX_address';", + "const quoteTokenEnvKey = 'WETH_address';", + "const baseTokenAddress = pm.environment.get(baseTokenEnvKey);", + "const quoteTokenAddress = pm.environment.get(quoteTokenEnvKey);", + "const responseJsonData = pm.response.json();", + "pm.test('Orderbook is properly filtered', function() {", + " const bids = _.get(responseJsonData, 'bids');", + " const asks = _.get(responseJsonData, 'asks');", + " _.forEach(bids, function(order) {", + " const makerTokenAddress = _.get(order, 'makerTokenAddress');", + " const takerTokenAddress = _.get(order, 'takerTokenAddress');", + " pm.expect(makerTokenAddress).to.be.equal(quoteTokenAddress);", + " pm.expect(takerTokenAddress).to.be.equal(baseTokenAddress);", + " });", + " _.forEach(asks, function(order) {", + " const makerTokenAddress = _.get(order, 'makerTokenAddress');", + " const takerTokenAddress = _.get(order, 'takerTokenAddress');", + " pm.expect(makerTokenAddress).to.be.equal(baseTokenAddress);", + " pm.expect(takerTokenAddress).to.be.equal(quoteTokenAddress);", + " });", + "});", + "", + "", + "", + "" + ] } } ], @@ -526,9 +793,9 @@ "body": {}, "url": { "raw": - "{{url}}/v0/orderbook?baseTokenAddress={{ZRX_address}}"eTokenAddress={{WETH_address}}", + "{{url}}/orderbook?baseTokenAddress={{ZRX_address}}"eTokenAddress={{WETH_address}}", "host": ["{{url}}"], - "path": ["v0", "orderbook"], + "path": ["orderbook"], "query": [ { "key": "baseTokenAddress", @@ -567,7 +834,7 @@ "const responseJsonData = pm.response.json();", "", "pm.test('Schema is valid', function() {", - " pm.expect(tv4.validate(responseJsonData, schema)).to.be.true;", + " pm.expect(tv4.validate(responseJsonData, schema)).to.be.true;", "});", "" ] @@ -595,9 +862,9 @@ "{\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", + "raw": "{{url}}/fees", "host": ["{{url}}"], - "path": ["v0", "fees"] + "path": ["fees"] }, "description": "Given an unsigned order without the fee-related properties, returns the required feeRecipient, makerFee, and takerFee of that order." @@ -642,7 +909,6 @@ "exec": [ "const schemaKeysString = pm.globals.get('schemaKeys');", "const schemaKeys = JSON.parse(schemaKeysString);", - "", "_.forEach(schemaKeys, function(schemaKey) {", " const schemaString = pm.globals.get(schemaKey);", " const schema = JSON.parse(schemaString);", @@ -657,7 +923,14 @@ "script": { "id": "b4917e72-ac87-421d-b7a5-21b64285ba5b", "type": "text/javascript", - "exec": [""] + "exec": [ + "pm.test('Has Content-Type header with value application/json', function () {", + " pm.response.to.have.header('Content-Type');", + " const contentType = postman.getResponseHeader('Content-Type');", + " pm.expect(contentType).to.include('application/json');", + "});", + "" + ] } } ] -- cgit From a74a04c5d50f836a042ff7222f9311e1eec71e40 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Thu, 1 Mar 2018 13:06:08 -0800 Subject: Fix yarn.lock --- yarn.lock | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/yarn.lock b/yarn.lock index 5ac18dc23..4081bbd78 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10224,6 +10224,10 @@ xml-js@^1.3.2: dependencies: sax "^1.2.4" +xmlbuilder@9.0.4: + version "9.0.4" + resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-9.0.4.tgz#519cb4ca686d005a8420d3496f3f0caeecca580f" + xmlhttprequest@*, xmlhttprequest@1.8.0: version "1.8.0" resolved "https://registry.yarnpkg.com/xmlhttprequest/-/xmlhttprequest-1.8.0.tgz#67fe075c5c24fef39f9d65f5f7b7fe75171968fc" -- cgit From 89bfcafb80ddc96659ebeff365a9247c053330fd Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Thu, 1 Mar 2018 13:17:49 -0800 Subject: Add ethers types --- packages/sra-report/tsconfig.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/sra-report/tsconfig.json b/packages/sra-report/tsconfig.json index 3d967d05f..8114d99cd 100644 --- a/packages/sra-report/tsconfig.json +++ b/packages/sra-report/tsconfig.json @@ -3,5 +3,9 @@ "compilerOptions": { "outDir": "lib" }, - "include": ["./src/**/*", "../../node_modules/web3-typescript-typings/index.d.ts"] + "include": [ + "./src/**/*", + "../../node_modules/web3-typescript-typings/index.d.ts", + "../../node_modules/ethers-typescript-typings/index.d.ts" + ] } -- cgit From 92b9dbd706768fd0edfc8f72a90f197abd8b3d66 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Thu, 1 Mar 2018 14:41:16 -0800 Subject: Fix up some postman tests --- .../collections/sra_report.postman_collection.json | 70 +++++++--------------- 1 file changed, 21 insertions(+), 49 deletions(-) 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 index 569596576..d1d384163 100644 --- a/packages/sra-report/postman_configs/collections/sra_report.postman_collection.json +++ b/packages/sra-report/postman_configs/collections/sra_report.postman_collection.json @@ -42,7 +42,7 @@ { "listen": "test", "script": { - "id": "53ad6be0-4196-47a1-bbf5-fa96e3c5d47e", + "id": "1b61aabb-ef9f-4269-9a0c-cb7559afcbd8", "type": "text/javascript", "exec": [ "const filterTokenEnvKey = 'WETH_address';", @@ -50,14 +50,12 @@ "const responseJsonData = pm.response.json();", "pm.test('Token pairs are properly filtered', function() {", " _.forEach(responseJsonData, function(tokenPair) {", - " const tokenAIsFilterToken = _.get(tokenPair, 'tokenA') === filterTokenAddress;", - " const tokenBIsFilterToken = _.get(tokenPair, 'tokenB') === filterTokenAddress;", + " const tokenAIsFilterToken = _.get(tokenPair, 'tokenA.address') === filterTokenAddress;", + " const tokenBIsFilterToken = _.get(tokenPair, 'tokenB.address') === filterTokenAddress;", " const condition = tokenAIsFilterToken || tokenBIsFilterToken", " pm.expect(condition).to.be.true;", " });", "});", - "", - "", "" ] } @@ -89,7 +87,7 @@ { "listen": "test", "script": { - "id": "7224b56e-0000-4d77-b355-f9bfd7d6320f", + "id": "a5f946b1-fc97-4bcf-ae01-e0f97864a6c1", "type": "text/javascript", "exec": [ "const filterTokenEnvKey = 'WETH_address';", @@ -97,17 +95,12 @@ "const responseJsonData = pm.response.json();", "pm.test('Token pairs are properly filtered', function() {", " _.forEach(responseJsonData, function(tokenPair) {", - " const tokenAIsFilterToken = _.get(tokenPair, 'tokenA') === filterTokenAddress;", - " const tokenBIsFilterToken = _.get(tokenPair, 'tokenB') === filterTokenAddress;", + " const tokenAIsFilterToken = _.get(tokenPair, 'tokenA.address') === filterTokenAddress;", + " const tokenBIsFilterToken = _.get(tokenPair, 'tokenB.address') === filterTokenAddress;", " const condition = tokenAIsFilterToken || tokenBIsFilterToken", " pm.expect(condition).to.be.true;", " });", "});", - "", - "", - "", - "", - "", "" ] } @@ -139,7 +132,7 @@ { "listen": "test", "script": { - "id": "32a19952-90c7-4f11-b95c-815b0746ef8b", + "id": "bcd06e4f-aa3a-42f8-9f8c-bc902eb7a075", "type": "text/javascript", "exec": [ "const filterTokenAEnvKey = 'WETH_address';", @@ -149,10 +142,10 @@ "const responseJsonData = pm.response.json();", "pm.test('Token pairs are properly filtered', function() {", " _.forEach(responseJsonData, function(tokenPair) {", - " const tokenAIsFilterTokenA = _.get(tokenPair, 'tokenA') === filterTokenAAddress;", - " const tokenAIsFilterTokenB = _.get(tokenPair, 'tokenA') === filterTokenBAddress;", - " const tokenBIsFilterTokenA = _.get(tokenPair, 'tokenB') === filterTokenAAddress;", - " const tokenBIsFilterTokenB = _.get(tokenPair, 'tokenB') === filterTokenBAddress;", + " const tokenAIsFilterTokenA = _.get(tokenPair, 'tokenA.address') === filterTokenAAddress;", + " const tokenAIsFilterTokenB = _.get(tokenPair, 'tokenA.address') === filterTokenBAddress;", + " const tokenBIsFilterTokenA = _.get(tokenPair, 'tokenB.address') === filterTokenAAddress;", + " const tokenBIsFilterTokenB = _.get(tokenPair, 'tokenB.address') === filterTokenBAddress;", " const condition = (tokenAIsFilterTokenA && tokenBIsFilterTokenB) || (tokenBIsFilterTokenA && tokenAIsFilterTokenB)", " pm.expect(condition).to.be.true;", " });", @@ -251,7 +244,7 @@ { "listen": "test", "script": { - "id": "f10e0a91-3401-4023-afef-5bff93a25232", + "id": "e782ae77-66bf-4096-9190-ef9e7501b316", "type": "text/javascript", "exec": [ "const exchangeContractEnvKey = 'EXCHANGE_CONTRACT_address';", @@ -263,8 +256,6 @@ " pm.expect(requestedExchangeContractAddress).to.equal(returnedExchangeContractAddress);", " });", "});", - "", - "", "" ] } @@ -297,7 +288,7 @@ { "listen": "test", "script": { - "id": "d915624e-9d71-4499-a133-cc8268199895", + "id": "1144a2d6-6175-40a6-8568-d0d3884492a1", "type": "text/javascript", "exec": [ "const filterTokenEnvKey = 'ZRX_address';", @@ -313,8 +304,6 @@ " pm.expect(condition).to.be.true;", " });", "});", - "", - "", "" ] } @@ -347,7 +336,7 @@ { "listen": "test", "script": { - "id": "5599a829-b127-4b21-8690-12cc764972a9", + "id": "01eb5865-edec-4216-8a90-c36d790366fc", "type": "text/javascript", "exec": [ "const filterTokenEnvKey = 'ZRX_address';", @@ -359,8 +348,6 @@ " pm.expect(makerTokenAddress).to.be.equal(filterTokenAddress);", " });", "});", - "", - "", "" ] } @@ -393,7 +380,7 @@ { "listen": "test", "script": { - "id": "d5ac5604-b13b-40c2-ba31-3033f52136a2", + "id": "bbbb6e15-60c7-4666-96be-a0ad56b6058b", "type": "text/javascript", "exec": [ "const filterTokenEnvKey = 'ZRX_address';", @@ -405,8 +392,6 @@ " pm.expect(takerTokenAddress).to.be.equal(filterTokenAddress);", " });", "});", - "", - "", "" ] } @@ -483,7 +468,7 @@ { "listen": "test", "script": { - "id": "a299a290-58b9-434c-b5e8-98ef9e5f70da", + "id": "c9c18715-c7cc-4064-8241-68a362a233fe", "type": "text/javascript", "exec": [ "const orderTakerEnvKey = 'orderTaker';", @@ -495,8 +480,6 @@ " pm.expect(referenceOrderTakerAddress).to.be.equal(returnedTakerAddress);", " });", "});", - "", - "", "" ] } @@ -529,7 +512,7 @@ { "listen": "test", "script": { - "id": "e80aa474-3352-45dd-87ef-2980bab961fb", + "id": "2c9cdb6a-267c-48b3-9ad7-df7abb75ddf4", "type": "text/javascript", "exec": [ "const orderTraderEnvKey = 'orderMaker';", @@ -543,9 +526,6 @@ " pm.expect(condition).to.be.true;", " });", "});", - "", - "", - "", "" ] } @@ -578,7 +558,7 @@ { "listen": "test", "script": { - "id": "fb34198e-221b-406d-8da4-4e7eed400cbe", + "id": "06ea36eb-6a35-4fc7-8017-59876b1a1cb4", "type": "text/javascript", "exec": [ "const orderFeeRecipientEnvKey = 'orderFeeRecipient';", @@ -590,9 +570,6 @@ " pm.expect(referenceOrderFeeRecipientAddress).to.be.equal(returnedFeeRecipientAddress);", " });", "});", - "", - "", - "", "" ] } @@ -657,7 +634,7 @@ { "listen": "test", "script": { - "id": "e847f317-6346-4ee5-bd94-7554eb3073b3", + "id": "3beca3a2-e0ad-45ff-b4d1-eace859af0bf", "type": "text/javascript", "exec": [ "const orderEnvKey = 'order';", @@ -697,8 +674,6 @@ " pm.expect(returnedSignatureProperty).to.be.equal(referenceSignatureProperty);", " });", "});", - "", - "", "" ] } @@ -755,7 +730,7 @@ { "listen": "test", "script": { - "id": "67d95152-3561-4db2-aaba-d26ceb44b4fd", + "id": "0198622e-9705-4ae1-b1f2-0c40b87de856", "type": "text/javascript", "exec": [ "const baseTokenEnvKey = 'ZRX_address';", @@ -772,16 +747,13 @@ " pm.expect(makerTokenAddress).to.be.equal(quoteTokenAddress);", " pm.expect(takerTokenAddress).to.be.equal(baseTokenAddress);", " });", - " _.forEach(asks, function(order) {", + " _.forEach(asks, function(order) {", " const makerTokenAddress = _.get(order, 'makerTokenAddress');", " const takerTokenAddress = _.get(order, 'takerTokenAddress');", " pm.expect(makerTokenAddress).to.be.equal(baseTokenAddress);", " pm.expect(takerTokenAddress).to.be.equal(quoteTokenAddress);", " });", "});", - "", - "", - "", "" ] } -- cgit From d355382f7040550cb82bab57a4935652fb710e71 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Mon, 5 Mar 2018 15:15:03 -0800 Subject: Update 0x package versions and fix yarn.lock --- packages/sra-report/package.json | 18 +++++++++--------- yarn.lock | 16 ++++++++++++++++ 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/packages/sra-report/package.json b/packages/sra-report/package.json index 6168c128e..22297e12e 100644 --- a/packages/sra-report/package.json +++ b/packages/sra-report/package.json @@ -15,26 +15,26 @@ }, "repository": { "type": "git", - "url": "https://github.com/0xProject/0x.js.git" + "url": "https://github.com/0xProject/0x-monorepo.git" }, "license": "Apache-2.0", "bugs": { - "url": "https://github.com/0xProject/0x.js/issues" + "url": "https://github.com/0xProject/0x-monorepo/issues" }, - "homepage": "https://github.com/0xProject/0x.js/packages/abi-gen/README.md", + "homepage": "https://github.com/0xProject/0x-monorepo/packages/sra-report/README.md", "dependencies": { - "0x.js": "^0.32.4", - "@0xproject/assert": "^0.0.20", - "@0xproject/connect": "^0.6.1", - "@0xproject/json-schemas": "^0.7.12", - "@0xproject/utils": "^0.3.4", + "0x.js": "^0.33.0", + "@0xproject/assert": "^0.1.0", + "@0xproject/connect": "^0.6.2", + "@0xproject/json-schemas": "^0.7.13", + "@0xproject/utils": "^0.4.0", "chalk": "^2.3.0", "lodash": "^4.17.4", "newman": "^3.9.3", "yargs": "^10.0.3" }, "devDependencies": { - "@0xproject/tslint-config": "^0.4.9", + "@0xproject/tslint-config": "^0.4.10", "@types/lodash": "^4.14.86", "@types/node": "^8.0.53", "@types/yargs": "^10.0.0", diff --git a/yarn.lock b/yarn.lock index 4c38a471d..114b7f592 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3024,6 +3024,10 @@ enhanced-resolve@^3.4.0: object-assign "^4.0.1" tapable "^0.2.7" +entities@^1.1.1, entities@~1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/entities/-/entities-1.1.1.tgz#6e5c2d0a5621b5dadaecef80b90edfb5cd7772f0" + errno@^0.1.1, errno@^0.1.3, errno@~0.1.1: version "0.1.6" resolved "https://registry.yarnpkg.com/errno/-/errno-0.1.6.tgz#c386ce8a6283f14fc09563b71560908c9bf53026" @@ -8922,6 +8926,14 @@ ssri@^5.0.0: dependencies: safe-buffer "^5.1.0" +stack-trace@0.0.9: + version "0.0.9" + resolved "https://registry.yarnpkg.com/stack-trace/-/stack-trace-0.0.9.tgz#a8f6eaeca90674c333e7c43953f275b451510695" + +stack-trace@~0.0.9: + version "0.0.10" + resolved "https://registry.yarnpkg.com/stack-trace/-/stack-trace-0.0.10.tgz#547c70b347e8d32b4e108ea1a2a159e5fdde19c0" + state-toggle@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/state-toggle/-/state-toggle-1.0.0.tgz#d20f9a616bb4f0c3b98b91922d25b640aa2bc425" @@ -9699,6 +9711,10 @@ underscore@1.8.3: version "1.8.3" resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.8.3.tgz#4f3fb53b106e6097fcf9cb4109f2a5e9bdfa5022" +underscore@~1.7.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.7.0.tgz#6bbaf0877500d36be34ecaa584e0db9fef035209" + unherit@^1.0.4: version "1.1.0" resolved "https://registry.yarnpkg.com/unherit/-/unherit-1.1.0.tgz#6b9aaedfbf73df1756ad9e316dd981885840cd7d" -- cgit From 08ab81c54c1e845a4239648e8cea65a930fcc99d Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Mon, 5 Mar 2018 15:24:55 -0800 Subject: Rename isHttpUrl to isWebUri in assert package --- packages/assert/CHANGELOG.md | 4 ++++ packages/assert/src/index.ts | 4 ++-- packages/assert/test/assert_test.ts | 6 +++--- packages/connect/src/http_client.ts | 2 +- packages/sra-report/src/index.ts | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/assert/CHANGELOG.md b/packages/assert/CHANGELOG.md index b37a810e3..35bf4faef 100644 --- a/packages/assert/CHANGELOG.md +++ b/packages/assert/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## v0.2.0 - _TBD, 2018_ + + * Rename `isHttpUrl` to `isWebUri` (#412) + ## v0.1.0 - _March 4, 2018_ * Remove isETHAddressHex checksum address check and assume address will be lowercased (#373) diff --git a/packages/assert/src/index.ts b/packages/assert/src/index.ts index 40d083cb6..171909c93 100644 --- a/packages/assert/src/index.ts +++ b/packages/assert/src/index.ts @@ -75,9 +75,9 @@ Encountered: ${JSON.stringify(value, null, '\t')} Validation errors: ${validationResult.errors.join(', ')}`; this.assert(!hasValidationErrors, msg); }, - isHttpUrl(variableName: string, value: any): void { + isWebUri(variableName: string, value: any): void { const isValidUrl = !_.isUndefined(validUrl.isWebUri(value)); - this.assert(isValidUrl, this.typeAssertionMessage(variableName, 'http url', value)); + this.assert(isValidUrl, this.typeAssertionMessage(variableName, 'web uri', value)); }, isUri(variableName: string, value: any): void { const isValidUri = !_.isUndefined(validUrl.isUri(value)); diff --git a/packages/assert/test/assert_test.ts b/packages/assert/test/assert_test.ts index b0fa398d6..1d9a34ed9 100644 --- a/packages/assert/test/assert_test.ts +++ b/packages/assert/test/assert_test.ts @@ -183,7 +183,7 @@ describe('Assertions', () => { ); }); }); - describe('#isHttpUrl', () => { + describe('#isWebUri', () => { it('should not throw for valid input', () => { const validInputs = [ 'http://www.google.com', @@ -191,7 +191,7 @@ describe('Assertions', () => { 'https://api.radarrelay.com/0x/v0/', 'https://zeroex.beta.radarrelay.com:8000/0x/v0/', ]; - validInputs.forEach(input => expect(assert.isHttpUrl.bind(assert, variableName, input)).to.not.throw()); + validInputs.forEach(input => expect(assert.isWebUri.bind(assert, variableName, input)).to.not.throw()); }); it('should throw for invalid input', () => { const invalidInputs = [ @@ -205,7 +205,7 @@ describe('Assertions', () => { 'user:password@api.example-relayer.net', '//api.example-relayer.net', ]; - invalidInputs.forEach(input => expect(assert.isHttpUrl.bind(assert, variableName, input)).to.throw()); + invalidInputs.forEach(input => expect(assert.isWebUri.bind(assert, variableName, input)).to.throw()); }); }); describe('#isUri', () => { diff --git a/packages/connect/src/http_client.ts b/packages/connect/src/http_client.ts index cf0aaef0d..a221b54e8 100644 --- a/packages/connect/src/http_client.ts +++ b/packages/connect/src/http_client.ts @@ -61,7 +61,7 @@ export class HttpClient implements Client { * @return An instance of HttpClient */ constructor(url: string) { - assert.isHttpUrl('url', url); + assert.isWebUri('url', url); this._apiEndpointUrl = url.replace(TRAILING_SLASHES_REGEX, ''); // remove trailing slashes } /** diff --git a/packages/sra-report/src/index.ts b/packages/sra-report/src/index.ts index bee9db192..327c495ae 100644 --- a/packages/sra-report/src/index.ts +++ b/packages/sra-report/src/index.ts @@ -42,7 +42,7 @@ const args = yargs .argv; // perform extra validation on command line arguments try { - assert.isHttpUrl('args', args.url); + assert.isWebUri('args', args.url); } catch (err) { utils.log(`${chalk.red(`Invalid url format:`)} ${args.url}`); process.exit(1); -- cgit From cf342dd00eaae8667984e77eb565040c132f160a Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Mon, 5 Mar 2018 15:31:42 -0800 Subject: Change url command line option to endpoint-url --- packages/sra-report/README.md | 2 +- packages/sra-report/src/index.ts | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/sra-report/README.md b/packages/sra-report/README.md index 49609aeb2..53c007e10 100644 --- a/packages/sra-report/README.md +++ b/packages/sra-report/README.md @@ -13,7 +13,7 @@ sra-report Options: --help Show help [boolean] --version Show version number [boolean] - --url, -u API endpoint to test for standard relayer API compliance + --endpoint-url, -e API endpoint url 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 diff --git a/packages/sra-report/src/index.ts b/packages/sra-report/src/index.ts index 327c495ae..c74b5cb40 100644 --- a/packages/sra-report/src/index.ts +++ b/packages/sra-report/src/index.ts @@ -19,9 +19,9 @@ 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', + .option('endpoint-url', { + alias: ['e'], + describe: 'API endpoint url to test for standard relayer API compliance', type: 'string', demandOption: true, }) @@ -38,13 +38,13 @@ const args = yargs type: 'number', default: DEFAULT_NETWORK_ID, }) - .example("$0 --url 'http://api.example.com' --out 'src/contracts/generated/' --network-id 42", 'Full usage example') + .example("$0 --endpoint-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.isWebUri('args', args.url); + assert.isWebUri('args', args.endpointUrl); } catch (err) { - utils.log(`${chalk.red(`Invalid url format:`)} ${args.url}`); + utils.log(`${chalk.red(`Invalid url format:`)} ${args.endpointUrl}`); process.exit(1); } if (!_.includes(SUPPORTED_NETWORK_IDS, args.networkId)) { @@ -54,7 +54,7 @@ if (!_.includes(SUPPORTED_NETWORK_IDS, args.networkId)) { } const mainAsync = async () => { - const httpClient = new HttpClient(args.url); + const httpClient = new HttpClient(args.endpointUrl); const orders = await httpClient.getOrdersAsync(); const firstOrder = _.head(orders); if (_.isUndefined(firstOrder)) { @@ -62,7 +62,7 @@ const mainAsync = async () => { } const newmanEnvironmentOptions = { collection: sraReportCollectionJSON, - globals: postmanEnvironmentFactory.createGlobalEnvironment(args.url, firstOrder), + globals: postmanEnvironmentFactory.createGlobalEnvironment(args.endpointUrl, firstOrder), environment: postmanEnvironmentFactory.createNetworkEnvironment(args.networkId), }; const newmanReporterOptions = !_.isUndefined(args.output) -- cgit From 38a4ccd9f24cd1cd583c17ebc200238e1770e5f8 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Mon, 5 Mar 2018 16:13:47 -0800 Subject: Change all globals in environment variables --- .../collections/sra_report.postman_collection.json | 1881 ++++++++++---------- .../kovan_tokens.postman_environment.json | 34 - .../mainnet_tokens.postman_environment.json | 34 - .../src/contract_addresses/kovan_addresses.ts | 6 + .../src/contract_addresses/mainnet_addresses.ts | 6 + packages/sra-report/src/index.ts | 8 +- .../sra-report/src/postman_environment_factory.ts | 32 +- 7 files changed, 1006 insertions(+), 995 deletions(-) delete mode 100644 packages/sra-report/postman_configs/environments/kovan_tokens.postman_environment.json delete mode 100644 packages/sra-report/postman_configs/environments/mainnet_tokens.postman_environment.json create mode 100644 packages/sra-report/src/contract_addresses/kovan_addresses.ts create mode 100644 packages/sra-report/src/contract_addresses/mainnet_addresses.ts 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 index d1d384163..fc7dd5b65 100644 --- a/packages/sra-report/postman_configs/collections/sra_report.postman_collection.json +++ b/packages/sra-report/postman_configs/collections/sra_report.postman_collection.json @@ -1,909 +1,974 @@ { - "info": { - "name": "sra_report", - "_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 request", - "event": [ - { - "listen": "test", - "script": { - "id": "42cb5e3f-6013-4a7c-b341-0d10cb3f2c9c", - "type": "text/javascript", - "exec": [""] - } - } - ], - "request": { - "method": "GET", - "header": [], - "body": {}, - "url": { - "raw": "{{url}}/token_pairs", - "host": ["{{url}}"], - "path": ["token_pairs"] - }, - "description": "" - }, - "response": [] - }, - { - "name": "tokenA param", - "event": [ - { - "listen": "test", - "script": { - "id": "1b61aabb-ef9f-4269-9a0c-cb7559afcbd8", - "type": "text/javascript", - "exec": [ - "const filterTokenEnvKey = 'WETH_address';", - "const filterTokenAddress = pm.environment.get(filterTokenEnvKey);", - "const responseJsonData = pm.response.json();", - "pm.test('Token pairs are properly filtered', function() {", - " _.forEach(responseJsonData, function(tokenPair) {", - " const tokenAIsFilterToken = _.get(tokenPair, 'tokenA.address') === filterTokenAddress;", - " const tokenBIsFilterToken = _.get(tokenPair, 'tokenB.address') === filterTokenAddress;", - " const condition = tokenAIsFilterToken || tokenBIsFilterToken", - " pm.expect(condition).to.be.true;", - " });", - "});", - "" - ] - } - } - ], - "request": { - "method": "GET", - "header": [], - "body": {}, - "url": { - "raw": "{{url}}/token_pairs?tokenA={{WETH_address}}", - "host": ["{{url}}"], - "path": ["token_pairs"], - "query": [ - { - "key": "tokenA", - "value": "{{WETH_address}}", - "equals": true - } - ] - }, - "description": "" - }, - "response": [] - }, - { - "name": "tokenB param", - "event": [ - { - "listen": "test", - "script": { - "id": "a5f946b1-fc97-4bcf-ae01-e0f97864a6c1", - "type": "text/javascript", - "exec": [ - "const filterTokenEnvKey = 'WETH_address';", - "const filterTokenAddress = pm.environment.get(filterTokenEnvKey);", - "const responseJsonData = pm.response.json();", - "pm.test('Token pairs are properly filtered', function() {", - " _.forEach(responseJsonData, function(tokenPair) {", - " const tokenAIsFilterToken = _.get(tokenPair, 'tokenA.address') === filterTokenAddress;", - " const tokenBIsFilterToken = _.get(tokenPair, 'tokenB.address') === filterTokenAddress;", - " const condition = tokenAIsFilterToken || tokenBIsFilterToken", - " pm.expect(condition).to.be.true;", - " });", - "});", - "" - ] - } - } - ], - "request": { - "method": "GET", - "header": [], - "body": {}, - "url": { - "raw": "{{url}}/token_pairs?tokenB={{WETH_address}}", - "host": ["{{url}}"], - "path": ["token_pairs"], - "query": [ - { - "key": "tokenB", - "value": "{{WETH_address}}", - "equals": true - } - ] - }, - "description": "" - }, - "response": [] - }, - { - "name": "tokenA and tokenB params", - "event": [ - { - "listen": "test", - "script": { - "id": "bcd06e4f-aa3a-42f8-9f8c-bc902eb7a075", - "type": "text/javascript", - "exec": [ - "const filterTokenAEnvKey = 'WETH_address';", - "const filterTokenBEnvKey = 'ZRX_address';", - "const filterTokenAAddress = pm.environment.get(filterTokenAEnvKey);", - "const filterTokenBAddress = pm.environment.get(filterTokenBEnvKey);", - "const responseJsonData = pm.response.json();", - "pm.test('Token pairs are properly filtered', function() {", - " _.forEach(responseJsonData, function(tokenPair) {", - " const tokenAIsFilterTokenA = _.get(tokenPair, 'tokenA.address') === filterTokenAAddress;", - " const tokenAIsFilterTokenB = _.get(tokenPair, 'tokenA.address') === filterTokenBAddress;", - " const tokenBIsFilterTokenA = _.get(tokenPair, 'tokenB.address') === filterTokenAAddress;", - " const tokenBIsFilterTokenB = _.get(tokenPair, 'tokenB.address') === filterTokenBAddress;", - " const condition = (tokenAIsFilterTokenA && tokenBIsFilterTokenB) || (tokenBIsFilterTokenA && tokenAIsFilterTokenB)", - " pm.expect(condition).to.be.true;", - " });", - "});", - "" - ] - } - } - ], - "request": { - "method": "GET", - "header": [], - "body": {}, - "url": { - "raw": "{{url}}/token_pairs?tokenA={{WETH_address}}&tokenB={{ZRX_address}}", - "host": ["{{url}}"], - "path": ["token_pairs"], - "query": [ - { - "key": "tokenA", - "value": "{{WETH_address}}", - "equals": true - }, - { - "key": "tokenB", - "value": "{{ZRX_address}}", - "equals": true - } - ] - }, - "description": "" - }, - "response": [] - } - ], - "event": [ - { - "listen": "prerequest", - "script": { - "id": "3d032e92-6a17-49f0-8115-bae1c7298b55", - "type": "text/javascript", - "exec": [""] - } - }, - { - "listen": "test", - "script": { - "id": "25addb38-bd1c-4eb3-a193-5617119dc0d6", - "type": "text/javascript", - "exec": [ - "const schema = tv4.getSchema('/RelayerApiTokenPairsResponse');", - "const responseJsonData = pm.response.json();", - "", - "pm.test('Schema is valid', function() {", - " pm.expect(tv4.validate(responseJsonData, schema)).to.be.true;", - "});", - "" - ] - } - } - ] - }, - { - "name": "GET /orders", - "description": "", - "item": [ - { - "name": "default request", - "event": [ - { - "listen": "test", - "script": { - "id": "118f47dd-1d93-4288-841f-de88783eff3b", - "type": "text/javascript", - "exec": [""] - } - } - ], - "request": { - "method": "GET", - "header": [], - "body": {}, - "url": { - "raw": "{{url}}/orders", - "host": ["{{url}}"], - "path": ["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": "exchangeContract param", - "event": [ - { - "listen": "test", - "script": { - "id": "e782ae77-66bf-4096-9190-ef9e7501b316", - "type": "text/javascript", - "exec": [ - "const exchangeContractEnvKey = 'EXCHANGE_CONTRACT_address';", - "const requestedExchangeContractAddress = pm.environment.get(exchangeContractEnvKey);", - "const responseJsonData = pm.response.json();", - "pm.test('Orders are properly filtered', function() {", - " _.forEach(responseJsonData, function(order) {", - " const returnedExchangeContractAddress = _.get(order, 'exchangeContractAddress');", - " pm.expect(requestedExchangeContractAddress).to.equal(returnedExchangeContractAddress);", - " });", - "});", - "" - ] - } - } - ], - "request": { - "method": "GET", - "header": [], - "body": {}, - "url": { - "raw": "{{url}}/orders?exchangeContractAddress={{EXCHANGE_CONTRACT_address}}", - "host": ["{{url}}"], - "path": ["orders"], - "query": [ - { - "key": "exchangeContractAddress", - "value": "{{EXCHANGE_CONTRACT_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": "tokenAddress param", - "event": [ - { - "listen": "test", - "script": { - "id": "1144a2d6-6175-40a6-8568-d0d3884492a1", - "type": "text/javascript", - "exec": [ - "const filterTokenEnvKey = 'ZRX_address';", - "const filterTokenAddress = pm.environment.get(filterTokenEnvKey);", - "const responseJsonData = pm.response.json();", - "pm.test('Orders are properly filtered', function() {", - " _.forEach(responseJsonData, function(order) {", - " const makerTokenAddress = _.get(order, 'makerTokenAddress');", - " const takerTokenAddress = _.get(order, 'takerTokenAddress');", - " const makerTokenAddressIsFilterToken = makerTokenAddress === filterTokenAddress;", - " const takerTokenAddressIsFilterToken = takerTokenAddress === filterTokenAddress;", - " const condition = makerTokenAddressIsFilterToken || takerTokenAddressIsFilterToken;", - " pm.expect(condition).to.be.true;", - " });", - "});", - "" - ] - } - } - ], - "request": { - "method": "GET", - "header": [], - "body": {}, - "url": { - "raw": "{{url}}/orders?tokenAddress={{ZRX_address}}", - "host": ["{{url}}"], - "path": ["orders"], - "query": [ - { - "key": "tokenAddress", - "value": "{{ZRX_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": "makerTokenAddress param", - "event": [ - { - "listen": "test", - "script": { - "id": "01eb5865-edec-4216-8a90-c36d790366fc", - "type": "text/javascript", - "exec": [ - "const filterTokenEnvKey = 'ZRX_address';", - "const filterTokenAddress = pm.environment.get(filterTokenEnvKey);", - "const responseJsonData = pm.response.json();", - "pm.test('Orders are properly filtered', function() {", - " _.forEach(responseJsonData, function(order) {", - " const makerTokenAddress = _.get(order, 'makerTokenAddress');", - " pm.expect(makerTokenAddress).to.be.equal(filterTokenAddress);", - " });", - "});", - "" - ] - } - } - ], - "request": { - "method": "GET", - "header": [], - "body": {}, - "url": { - "raw": "{{url}}/orders?makerTokenAddress={{ZRX_address}}", - "host": ["{{url}}"], - "path": ["orders"], - "query": [ - { - "key": "makerTokenAddress", - "value": "{{ZRX_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": "takerTokenAddress param", - "event": [ - { - "listen": "test", - "script": { - "id": "bbbb6e15-60c7-4666-96be-a0ad56b6058b", - "type": "text/javascript", - "exec": [ - "const filterTokenEnvKey = 'ZRX_address';", - "const filterTokenAddress = pm.environment.get(filterTokenEnvKey);", - "const responseJsonData = pm.response.json();", - "pm.test('Orders are properly filtered', function() {", - " _.forEach(responseJsonData, function(order) {", - " const takerTokenAddress = _.get(order, 'takerTokenAddress');", - " pm.expect(takerTokenAddress).to.be.equal(filterTokenAddress);", - " });", - "});", - "" - ] - } - } - ], - "request": { - "method": "GET", - "header": [], - "body": {}, - "url": { - "raw": "{{url}}/orders?takerTokenAddress={{ZRX_address}}", - "host": ["{{url}}"], - "path": ["orders"], - "query": [ - { - "key": "takerTokenAddress", - "value": "{{ZRX_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": "maker param", - "event": [ - { - "listen": "test", - "script": { - "id": "efc85eb8-7791-4b14-9dee-c5e80adec4b8", - "type": "text/javascript", - "exec": [ - "const orderMakerEnvKey = 'orderMaker';", - "const referenceOrderMakerAddress = pm.globals.get(orderMakerEnvKey);", - "const responseJsonData = pm.response.json();", - "pm.test('Orders are properly filtered', function() {", - " _.forEach(responseJsonData, function(order) {", - " const returnedMakerAddress = _.get(order, 'maker');", - " pm.expect(referenceOrderMakerAddress).to.be.equal(returnedMakerAddress);", - " });", - "});", - "" - ] - } - } - ], - "request": { - "method": "GET", - "header": [], - "body": {}, - "url": { - "raw": "{{url}}/orders?maker={{orderMaker}}", - "host": ["{{url}}"], - "path": ["orders"], - "query": [ - { - "key": "maker", - "value": "{{orderMaker}}", - "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": "taker param", - "event": [ - { - "listen": "test", - "script": { - "id": "c9c18715-c7cc-4064-8241-68a362a233fe", - "type": "text/javascript", - "exec": [ - "const orderTakerEnvKey = 'orderTaker';", - "const referenceOrderTakerAddress = pm.globals.get(orderTakerEnvKey);", - "const responseJsonData = pm.response.json();", - "pm.test('Orders are properly filtered', function() {", - " _.forEach(responseJsonData, function(order) {", - " const returnedTakerAddress = _.get(order, 'taker');", - " pm.expect(referenceOrderTakerAddress).to.be.equal(returnedTakerAddress);", - " });", - "});", - "" - ] - } - } - ], - "request": { - "method": "GET", - "header": [], - "body": {}, - "url": { - "raw": "{{url}}/orders?taker={{orderTaker}}", - "host": ["{{url}}"], - "path": ["orders"], - "query": [ - { - "key": "taker", - "value": "{{orderTaker}}", - "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": "trader param", - "event": [ - { - "listen": "test", - "script": { - "id": "2c9cdb6a-267c-48b3-9ad7-df7abb75ddf4", - "type": "text/javascript", - "exec": [ - "const orderTraderEnvKey = 'orderMaker';", - "const referenceOrderTraderAddress = pm.globals.get(orderTraderEnvKey);", - "const responseJsonData = pm.response.json();", - "pm.test('Orders are properly filtered', function() {", - " _.forEach(responseJsonData, function(order) {", - " const returnedMakerAddress = _.get(order, 'maker');", - " const returnedTakerAddress = _.get(order, 'taker');", - " const condition = (referenceOrderTraderAddress === returnedMakerAddress) || (referenceOrderTraderAddress === returnedTakerAddress);", - " pm.expect(condition).to.be.true;", - " });", - "});", - "" - ] - } - } - ], - "request": { - "method": "GET", - "header": [], - "body": {}, - "url": { - "raw": "{{url}}/orders?trader={{orderMaker}}", - "host": ["{{url}}"], - "path": ["orders"], - "query": [ - { - "key": "trader", - "value": "{{orderMaker}}", - "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": "feeRecipient param", - "event": [ - { - "listen": "test", - "script": { - "id": "06ea36eb-6a35-4fc7-8017-59876b1a1cb4", - "type": "text/javascript", - "exec": [ - "const orderFeeRecipientEnvKey = 'orderFeeRecipient';", - "const referenceOrderFeeRecipientAddress = pm.globals.get(orderFeeRecipientEnvKey);", - "const responseJsonData = pm.response.json();", - "pm.test('Orders are properly filtered', function() {", - " _.forEach(responseJsonData, function(order) {", - " const returnedFeeRecipientAddress = _.get(order, 'feeRecipient');", - " pm.expect(referenceOrderFeeRecipientAddress).to.be.equal(returnedFeeRecipientAddress);", - " });", - "});", - "" - ] - } - } - ], - "request": { - "method": "GET", - "header": [], - "body": {}, - "url": { - "raw": "{{url}}/orders?feeRecipient={{orderFeeRecipient}}", - "host": ["{{url}}"], - "path": ["orders"], - "query": [ - { - "key": "feeRecipient", - "value": "{{orderFeeRecipient}}", - "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": [ - "const schema = tv4.getSchema('/signedOrdersSchema');", - "const responseJsonData = pm.response.json();", - "", - "pm.test('Schema is valid', function() {", - " pm.expect(tv4.validate(responseJsonData, schema)).to.be.true;", - "});", - "" - ] - } - } - ] - }, - { - "name": "GET /order", - "description": "", - "item": [ - { - "name": "orderHash param", - "event": [ - { - "listen": "test", - "script": { - "id": "3beca3a2-e0ad-45ff-b4d1-eace859af0bf", - "type": "text/javascript", - "exec": [ - "const orderEnvKey = 'order';", - "const referenceOrderString = pm.globals.get(orderEnvKey);", - "const referenceOrderJson = JSON.parse(referenceOrderString);", - "const orderPropertyNames = [", - " 'maker',", - " 'taker',", - " 'makerFee',", - " 'takerFee',", - " 'makerTokenAmount',", - " 'takerTokenAmount',", - " 'makerTokenAddress',", - " 'takerTokenAddress',", - " 'salt',", - " 'feeRecipient',", - " 'expirationUnixTimestampSec',", - " 'exchangeContractAddress'", - "];", - "const signaturePropertyNames = [", - " 'v',", - " 'r',", - " 's'", - "];", - "const returnedOrderJson = pm.response.json();", - "pm.test('Order is properly retreived', function() {", - " _.forEach(orderPropertyNames, function(propertyName) {", - " const returnedProperty = _.get(returnedOrderJson, propertyName);", - " const referenceProperty = _.get(referenceOrderJson, propertyName);", - " pm.expect(returnedProperty).to.be.equal(referenceProperty);", - " });", - " const returnedSignature = _.get(returnedOrderJson, 'ecSignature');", - " const referenceSignature = _.get(returnedOrderJson, 'ecSignature');", - " _.forEach(signaturePropertyNames, function(propertyName) {", - " const returnedSignatureProperty = _.get(returnedSignature, propertyName);", - " const referenceSignatureProperty = _.get(referenceSignature, propertyName);", - " pm.expect(returnedSignatureProperty).to.be.equal(referenceSignatureProperty);", - " });", - "});", - "" - ] - } - } - ], - "request": { - "method": "GET", - "header": [], - "body": {}, - "url": { - "raw": "{{url}}/order/{{orderHash}}", - "host": ["{{url}}"], - "path": ["order", "{{orderHash}}"] - }, - "description": "Retrieves a specific order by orderHash." - }, - "response": [] - } - ], - "event": [ - { - "listen": "prerequest", - "script": { - "id": "e356d2ff-d105-42c1-b679-d9d917dcd68d", - "type": "text/javascript", - "exec": [""] - } - }, - { - "listen": "test", - "script": { - "id": "8d2d4717-6f76-47ab-8e5a-f383192f6ee4", - "type": "text/javascript", - "exec": [ - "const schema = tv4.getSchema('/SignedOrder');", - "const responseJsonData = pm.response.json();", - "", - "pm.test('Schema is valid', function() {", - " pm.expect(tv4.validate(responseJsonData, schema)).to.be.true;", - "});", - "" - ] - } - } - ] - }, - { - "name": "GET /orderbook", - "description": "", - "item": [ - { - "name": "baseTokenAddress and quoteTokenAddress params", - "event": [ - { - "listen": "test", - "script": { - "id": "0198622e-9705-4ae1-b1f2-0c40b87de856", - "type": "text/javascript", - "exec": [ - "const baseTokenEnvKey = 'ZRX_address';", - "const quoteTokenEnvKey = 'WETH_address';", - "const baseTokenAddress = pm.environment.get(baseTokenEnvKey);", - "const quoteTokenAddress = pm.environment.get(quoteTokenEnvKey);", - "const responseJsonData = pm.response.json();", - "pm.test('Orderbook is properly filtered', function() {", - " const bids = _.get(responseJsonData, 'bids');", - " const asks = _.get(responseJsonData, 'asks');", - " _.forEach(bids, function(order) {", - " const makerTokenAddress = _.get(order, 'makerTokenAddress');", - " const takerTokenAddress = _.get(order, 'takerTokenAddress');", - " pm.expect(makerTokenAddress).to.be.equal(quoteTokenAddress);", - " pm.expect(takerTokenAddress).to.be.equal(baseTokenAddress);", - " });", - " _.forEach(asks, function(order) {", - " const makerTokenAddress = _.get(order, 'makerTokenAddress');", - " const takerTokenAddress = _.get(order, 'takerTokenAddress');", - " pm.expect(makerTokenAddress).to.be.equal(baseTokenAddress);", - " pm.expect(takerTokenAddress).to.be.equal(quoteTokenAddress);", - " });", - "});", - "" - ] - } - } - ], - "request": { - "method": "GET", - "header": [], - "body": {}, - "url": { - "raw": - "{{url}}/orderbook?baseTokenAddress={{ZRX_address}}"eTokenAddress={{WETH_address}}", - "host": ["{{url}}"], - "path": ["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": [] - } - ], - "event": [ - { - "listen": "prerequest", - "script": { - "id": "bdf90dbc-9217-4089-8bc0-351baadddd3e", - "type": "text/javascript", - "exec": [""] - } - }, - { - "listen": "test", - "script": { - "id": "d5080a34-57c4-4d5d-8e01-5e79599282ec", - "type": "text/javascript", - "exec": [ - "const schema = tv4.getSchema('/RelayerApiOrderBookResponse');", - "const responseJsonData = pm.response.json();", - "", - "pm.test('Schema is valid', function() {", - " pm.expect(tv4.validate(responseJsonData, schema)).to.be.true;", - "});", - "" - ] - } - } - ] - }, - { - "name": "POST /fees", - "description": "", - "item": [ - { - "name": "default request", - "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}}/fees", - "host": ["{{url}}"], - "path": ["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": "75d66506-0fa9-4b0e-982b-ef53bf3310f8", - "type": "text/javascript", - "exec": [""] - } - }, - { - "listen": "test", - "script": { - "id": "4c5f9f7b-8635-4bdb-9240-a74754a2de4f", - "type": "text/javascript", - "exec": [ - "const schema = tv4.getSchema('/RelayerApiFeesResponse');", - "const responseJsonData = pm.response.json();", - "", - "pm.test('Schema is valid', function() {", - " pm.expect(tv4.validate(responseJsonData, schema)).to.be.true;", - "});", - "" - ] - } - } - ] - } - ], - "event": [ - { - "listen": "prerequest", - "script": { - "id": "da60f639-df79-4f4d-9861-79219f5fc341", - "type": "text/javascript", - "exec": [ - "const schemaKeysString = pm.globals.get('schemaKeys');", - "const schemaKeys = JSON.parse(schemaKeysString);", - "_.forEach(schemaKeys, function(schemaKey) {", - " const schemaString = pm.globals.get(schemaKey);", - " const schema = JSON.parse(schemaString);", - " tv4.addSchema(schema);", - "});", - "" - ] - } - }, - { - "listen": "test", - "script": { - "id": "b4917e72-ac87-421d-b7a5-21b64285ba5b", - "type": "text/javascript", - "exec": [ - "pm.test('Has Content-Type header with value application/json', function () {", - " pm.response.to.have.header('Content-Type');", - " const contentType = postman.getResponseHeader('Content-Type');", - " pm.expect(contentType).to.include('application/json');", - "});", - "" - ] - } - } - ] -} + "info": { + "name": "sra_report", + "_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 request", + "event": [ + { + "listen": "test", + "script": { + "id": "42cb5e3f-6013-4a7c-b341-0d10cb3f2c9c", + "type": "text/javascript", + "exec": [ + "" + ] + } + } + ], + "request": { + "method": "GET", + "header": [], + "body": {}, + "url": { + "raw": "{{url}}/token_pairs", + "host": [ + "{{url}}" + ], + "path": [ + "token_pairs" + ] + }, + "description": "" + }, + "response": [] + }, + { + "name": "tokenA param", + "event": [ + { + "listen": "test", + "script": { + "id": "1b61aabb-ef9f-4269-9a0c-cb7559afcbd8", + "type": "text/javascript", + "exec": [ + "const filterTokenEnvKey = 'WETH_address';", + "const filterTokenAddress = pm.environment.get(filterTokenEnvKey);", + "const responseJsonData = pm.response.json();", + "pm.test('Token pairs are properly filtered', function() {", + " _.forEach(responseJsonData, function(tokenPair) {", + " const tokenAIsFilterToken = _.get(tokenPair, 'tokenA.address') === filterTokenAddress;", + " const tokenBIsFilterToken = _.get(tokenPair, 'tokenB.address') === filterTokenAddress;", + " const condition = tokenAIsFilterToken || tokenBIsFilterToken", + " pm.expect(condition).to.be.true;", + " });", + "});", + "" + ] + } + } + ], + "request": { + "method": "GET", + "header": [], + "body": {}, + "url": { + "raw": "{{url}}/token_pairs?tokenA={{WETH_address}}", + "host": [ + "{{url}}" + ], + "path": [ + "token_pairs" + ], + "query": [ + { + "key": "tokenA", + "value": "{{WETH_address}}", + "equals": true + } + ] + }, + "description": "" + }, + "response": [] + }, + { + "name": "tokenB param", + "event": [ + { + "listen": "test", + "script": { + "id": "a5f946b1-fc97-4bcf-ae01-e0f97864a6c1", + "type": "text/javascript", + "exec": [ + "const filterTokenEnvKey = 'WETH_address';", + "const filterTokenAddress = pm.environment.get(filterTokenEnvKey);", + "const responseJsonData = pm.response.json();", + "pm.test('Token pairs are properly filtered', function() {", + " _.forEach(responseJsonData, function(tokenPair) {", + " const tokenAIsFilterToken = _.get(tokenPair, 'tokenA.address') === filterTokenAddress;", + " const tokenBIsFilterToken = _.get(tokenPair, 'tokenB.address') === filterTokenAddress;", + " const condition = tokenAIsFilterToken || tokenBIsFilterToken", + " pm.expect(condition).to.be.true;", + " });", + "});", + "" + ] + } + } + ], + "request": { + "method": "GET", + "header": [], + "body": {}, + "url": { + "raw": "{{url}}/token_pairs?tokenB={{WETH_address}}", + "host": [ + "{{url}}" + ], + "path": [ + "token_pairs" + ], + "query": [ + { + "key": "tokenB", + "value": "{{WETH_address}}", + "equals": true + } + ] + }, + "description": "" + }, + "response": [] + }, + { + "name": "tokenA and tokenB params", + "event": [ + { + "listen": "test", + "script": { + "id": "bcd06e4f-aa3a-42f8-9f8c-bc902eb7a075", + "type": "text/javascript", + "exec": [ + "const filterTokenAEnvKey = 'WETH_address';", + "const filterTokenBEnvKey = 'ZRX_address';", + "const filterTokenAAddress = pm.environment.get(filterTokenAEnvKey);", + "const filterTokenBAddress = pm.environment.get(filterTokenBEnvKey);", + "const responseJsonData = pm.response.json();", + "pm.test('Token pairs are properly filtered', function() {", + " _.forEach(responseJsonData, function(tokenPair) {", + " const tokenAIsFilterTokenA = _.get(tokenPair, 'tokenA.address') === filterTokenAAddress;", + " const tokenAIsFilterTokenB = _.get(tokenPair, 'tokenA.address') === filterTokenBAddress;", + " const tokenBIsFilterTokenA = _.get(tokenPair, 'tokenB.address') === filterTokenAAddress;", + " const tokenBIsFilterTokenB = _.get(tokenPair, 'tokenB.address') === filterTokenBAddress;", + " const condition = (tokenAIsFilterTokenA && tokenBIsFilterTokenB) || (tokenBIsFilterTokenA && tokenAIsFilterTokenB)", + " pm.expect(condition).to.be.true;", + " });", + "});", + "" + ] + } + } + ], + "request": { + "method": "GET", + "header": [], + "body": {}, + "url": { + "raw": "{{url}}/token_pairs?tokenA={{WETH_address}}&tokenB={{ZRX_address}}", + "host": [ + "{{url}}" + ], + "path": [ + "token_pairs" + ], + "query": [ + { + "key": "tokenA", + "value": "{{WETH_address}}", + "equals": true + }, + { + "key": "tokenB", + "value": "{{ZRX_address}}", + "equals": true + } + ] + }, + "description": "" + }, + "response": [] + } + ], + "event": [ + { + "listen": "prerequest", + "script": { + "id": "3d032e92-6a17-49f0-8115-bae1c7298b55", + "type": "text/javascript", + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "id": "25addb38-bd1c-4eb3-a193-5617119dc0d6", + "type": "text/javascript", + "exec": [ + "const schema = tv4.getSchema('/RelayerApiTokenPairsResponse');", + "const responseJsonData = pm.response.json();", + "", + "pm.test('Schema is valid', function() {", + " pm.expect(tv4.validate(responseJsonData, schema)).to.be.true;", + "});", + "" + ] + } + } + ] + }, + { + "name": "GET /orders", + "description": "", + "item": [ + { + "name": "default request", + "event": [ + { + "listen": "test", + "script": { + "id": "118f47dd-1d93-4288-841f-de88783eff3b", + "type": "text/javascript", + "exec": [ + "" + ] + } + } + ], + "request": { + "method": "GET", + "header": [], + "body": {}, + "url": { + "raw": "{{url}}/orders", + "host": [ + "{{url}}" + ], + "path": [ + "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": "exchangeContract param", + "event": [ + { + "listen": "test", + "script": { + "id": "e782ae77-66bf-4096-9190-ef9e7501b316", + "type": "text/javascript", + "exec": [ + "const exchangeContractEnvKey = 'EXCHANGE_CONTRACT_address';", + "const requestedExchangeContractAddress = pm.environment.get(exchangeContractEnvKey);", + "const responseJsonData = pm.response.json();", + "pm.test('Orders are properly filtered', function() {", + " _.forEach(responseJsonData, function(order) {", + " const returnedExchangeContractAddress = _.get(order, 'exchangeContractAddress');", + " pm.expect(requestedExchangeContractAddress).to.equal(returnedExchangeContractAddress);", + " });", + "});", + "" + ] + } + } + ], + "request": { + "method": "GET", + "header": [], + "body": {}, + "url": { + "raw": "{{url}}/orders?exchangeContractAddress={{EXCHANGE_CONTRACT_address}}", + "host": [ + "{{url}}" + ], + "path": [ + "orders" + ], + "query": [ + { + "key": "exchangeContractAddress", + "value": "{{EXCHANGE_CONTRACT_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": "tokenAddress param", + "event": [ + { + "listen": "test", + "script": { + "id": "1144a2d6-6175-40a6-8568-d0d3884492a1", + "type": "text/javascript", + "exec": [ + "const filterTokenEnvKey = 'ZRX_address';", + "const filterTokenAddress = pm.environment.get(filterTokenEnvKey);", + "const responseJsonData = pm.response.json();", + "pm.test('Orders are properly filtered', function() {", + " _.forEach(responseJsonData, function(order) {", + " const makerTokenAddress = _.get(order, 'makerTokenAddress');", + " const takerTokenAddress = _.get(order, 'takerTokenAddress');", + " const makerTokenAddressIsFilterToken = makerTokenAddress === filterTokenAddress;", + " const takerTokenAddressIsFilterToken = takerTokenAddress === filterTokenAddress;", + " const condition = makerTokenAddressIsFilterToken || takerTokenAddressIsFilterToken;", + " pm.expect(condition).to.be.true;", + " });", + "});", + "" + ] + } + } + ], + "request": { + "method": "GET", + "header": [], + "body": {}, + "url": { + "raw": "{{url}}/orders?tokenAddress={{ZRX_address}}", + "host": [ + "{{url}}" + ], + "path": [ + "orders" + ], + "query": [ + { + "key": "tokenAddress", + "value": "{{ZRX_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": "makerTokenAddress param", + "event": [ + { + "listen": "test", + "script": { + "id": "01eb5865-edec-4216-8a90-c36d790366fc", + "type": "text/javascript", + "exec": [ + "const filterTokenEnvKey = 'ZRX_address';", + "const filterTokenAddress = pm.environment.get(filterTokenEnvKey);", + "const responseJsonData = pm.response.json();", + "pm.test('Orders are properly filtered', function() {", + " _.forEach(responseJsonData, function(order) {", + " const makerTokenAddress = _.get(order, 'makerTokenAddress');", + " pm.expect(makerTokenAddress).to.be.equal(filterTokenAddress);", + " });", + "});", + "" + ] + } + } + ], + "request": { + "method": "GET", + "header": [], + "body": {}, + "url": { + "raw": "{{url}}/orders?makerTokenAddress={{ZRX_address}}", + "host": [ + "{{url}}" + ], + "path": [ + "orders" + ], + "query": [ + { + "key": "makerTokenAddress", + "value": "{{ZRX_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": "takerTokenAddress param", + "event": [ + { + "listen": "test", + "script": { + "id": "bbbb6e15-60c7-4666-96be-a0ad56b6058b", + "type": "text/javascript", + "exec": [ + "const filterTokenEnvKey = 'ZRX_address';", + "const filterTokenAddress = pm.environment.get(filterTokenEnvKey);", + "const responseJsonData = pm.response.json();", + "pm.test('Orders are properly filtered', function() {", + " _.forEach(responseJsonData, function(order) {", + " const takerTokenAddress = _.get(order, 'takerTokenAddress');", + " pm.expect(takerTokenAddress).to.be.equal(filterTokenAddress);", + " });", + "});", + "" + ] + } + } + ], + "request": { + "method": "GET", + "header": [], + "body": {}, + "url": { + "raw": "{{url}}/orders?takerTokenAddress={{ZRX_address}}", + "host": [ + "{{url}}" + ], + "path": [ + "orders" + ], + "query": [ + { + "key": "takerTokenAddress", + "value": "{{ZRX_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": "maker param", + "event": [ + { + "listen": "test", + "script": { + "id": "1f5960de-117f-44fb-82e0-581626cbf62b", + "type": "text/javascript", + "exec": [ + "const orderMakerEnvKey = 'orderMaker';", + "const referenceOrderMakerAddress = pm.environment.get(orderMakerEnvKey);", + "const responseJsonData = pm.response.json();", + "pm.test('Orders are properly filtered', function() {", + " _.forEach(responseJsonData, function(order) {", + " const returnedMakerAddress = _.get(order, 'maker');", + " pm.expect(referenceOrderMakerAddress).to.be.equal(returnedMakerAddress);", + " });", + "});", + "" + ] + } + } + ], + "request": { + "method": "GET", + "header": [], + "body": {}, + "url": { + "raw": "{{url}}/orders?maker={{orderMaker}}", + "host": [ + "{{url}}" + ], + "path": [ + "orders" + ], + "query": [ + { + "key": "maker", + "value": "{{orderMaker}}", + "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": "taker param", + "event": [ + { + "listen": "test", + "script": { + "id": "f23de2eb-b444-49d3-93b7-14ae712d6502", + "type": "text/javascript", + "exec": [ + "const orderTakerEnvKey = 'orderTaker';", + "const referenceOrderTakerAddress = pm.environment.get(orderTakerEnvKey);", + "const responseJsonData = pm.response.json();", + "pm.test('Orders are properly filtered', function() {", + " _.forEach(responseJsonData, function(order) {", + " const returnedTakerAddress = _.get(order, 'taker');", + " pm.expect(referenceOrderTakerAddress).to.be.equal(returnedTakerAddress);", + " });", + "});", + "" + ] + } + } + ], + "request": { + "method": "GET", + "header": [], + "body": {}, + "url": { + "raw": "{{url}}/orders?taker={{orderTaker}}", + "host": [ + "{{url}}" + ], + "path": [ + "orders" + ], + "query": [ + { + "key": "taker", + "value": "{{orderTaker}}", + "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": "trader param", + "event": [ + { + "listen": "test", + "script": { + "id": "9689639a-47ce-4c3b-8180-859fd28437be", + "type": "text/javascript", + "exec": [ + "const orderTraderEnvKey = 'orderMaker';", + "const referenceOrderTraderAddress = pm.environment.get(orderTraderEnvKey);", + "const responseJsonData = pm.response.json();", + "pm.test('Orders are properly filtered', function() {", + " _.forEach(responseJsonData, function(order) {", + " const returnedMakerAddress = _.get(order, 'maker');", + " const returnedTakerAddress = _.get(order, 'taker');", + " const condition = (referenceOrderTraderAddress === returnedMakerAddress) || (referenceOrderTraderAddress === returnedTakerAddress);", + " pm.expect(condition).to.be.true;", + " });", + "});", + "" + ] + } + } + ], + "request": { + "method": "GET", + "header": [], + "body": {}, + "url": { + "raw": "{{url}}/orders?trader={{orderMaker}}", + "host": [ + "{{url}}" + ], + "path": [ + "orders" + ], + "query": [ + { + "key": "trader", + "value": "{{orderMaker}}", + "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": "feeRecipient param", + "event": [ + { + "listen": "test", + "script": { + "id": "010c0cf6-8d5b-4fe3-8b92-b2009ea43a3e", + "type": "text/javascript", + "exec": [ + "const orderFeeRecipientEnvKey = 'orderFeeRecipient';", + "const referenceOrderFeeRecipientAddress = pm.environment.get(orderFeeRecipientEnvKey);", + "const responseJsonData = pm.response.json();", + "pm.test('Orders are properly filtered', function() {", + " _.forEach(responseJsonData, function(order) {", + " const returnedFeeRecipientAddress = _.get(order, 'feeRecipient');", + " pm.expect(referenceOrderFeeRecipientAddress).to.be.equal(returnedFeeRecipientAddress);", + " });", + "});", + "" + ] + } + } + ], + "request": { + "method": "GET", + "header": [], + "body": {}, + "url": { + "raw": "{{url}}/orders?feeRecipient={{orderFeeRecipient}}", + "host": [ + "{{url}}" + ], + "path": [ + "orders" + ], + "query": [ + { + "key": "feeRecipient", + "value": "{{orderFeeRecipient}}", + "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": [ + "const schema = tv4.getSchema('/signedOrdersSchema');", + "const responseJsonData = pm.response.json();", + "", + "pm.test('Schema is valid', function() {", + " pm.expect(tv4.validate(responseJsonData, schema)).to.be.true;", + "});", + "" + ] + } + } + ] + }, + { + "name": "GET /order", + "description": "", + "item": [ + { + "name": "orderHash param", + "event": [ + { + "listen": "test", + "script": { + "id": "18876df2-384e-43d5-93a1-7e24571e1308", + "type": "text/javascript", + "exec": [ + "const orderEnvKey = 'order';", + "const referenceOrderString = pm.environment.get(orderEnvKey);", + "const referenceOrderJson = JSON.parse(referenceOrderString);", + "const orderPropertyNames = [", + " 'maker',", + " 'taker',", + " 'makerFee',", + " 'takerFee',", + " 'makerTokenAmount',", + " 'takerTokenAmount',", + " 'makerTokenAddress',", + " 'takerTokenAddress',", + " 'salt',", + " 'feeRecipient',", + " 'expirationUnixTimestampSec',", + " 'exchangeContractAddress'", + "];", + "const signaturePropertyNames = [", + " 'v',", + " 'r',", + " 's'", + "];", + "const returnedOrderJson = pm.response.json();", + "pm.test('Order is properly retreived', function() {", + " _.forEach(orderPropertyNames, function(propertyName) {", + " const returnedProperty = _.get(returnedOrderJson, propertyName);", + " const referenceProperty = _.get(referenceOrderJson, propertyName);", + " pm.expect(returnedProperty).to.be.equal(referenceProperty);", + " });", + " const returnedSignature = _.get(returnedOrderJson, 'ecSignature');", + " const referenceSignature = _.get(returnedOrderJson, 'ecSignature');", + " _.forEach(signaturePropertyNames, function(propertyName) {", + " const returnedSignatureProperty = _.get(returnedSignature, propertyName);", + " const referenceSignatureProperty = _.get(referenceSignature, propertyName);", + " pm.expect(returnedSignatureProperty).to.be.equal(referenceSignatureProperty);", + " });", + "});", + "" + ] + } + } + ], + "request": { + "method": "GET", + "header": [], + "body": {}, + "url": { + "raw": "{{url}}/order/{{orderHash}}", + "host": [ + "{{url}}" + ], + "path": [ + "order", + "{{orderHash}}" + ] + }, + "description": "Retrieves a specific order by orderHash." + }, + "response": [] + } + ], + "event": [ + { + "listen": "prerequest", + "script": { + "id": "e356d2ff-d105-42c1-b679-d9d917dcd68d", + "type": "text/javascript", + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "id": "8d2d4717-6f76-47ab-8e5a-f383192f6ee4", + "type": "text/javascript", + "exec": [ + "const schema = tv4.getSchema('/SignedOrder');", + "const responseJsonData = pm.response.json();", + "", + "pm.test('Schema is valid', function() {", + " pm.expect(tv4.validate(responseJsonData, schema)).to.be.true;", + "});", + "" + ] + } + } + ] + }, + { + "name": "GET /orderbook", + "description": "", + "item": [ + { + "name": "baseTokenAddress and quoteTokenAddress params", + "event": [ + { + "listen": "test", + "script": { + "id": "0198622e-9705-4ae1-b1f2-0c40b87de856", + "type": "text/javascript", + "exec": [ + "const baseTokenEnvKey = 'ZRX_address';", + "const quoteTokenEnvKey = 'WETH_address';", + "const baseTokenAddress = pm.environment.get(baseTokenEnvKey);", + "const quoteTokenAddress = pm.environment.get(quoteTokenEnvKey);", + "const responseJsonData = pm.response.json();", + "pm.test('Orderbook is properly filtered', function() {", + " const bids = _.get(responseJsonData, 'bids');", + " const asks = _.get(responseJsonData, 'asks');", + " _.forEach(bids, function(order) {", + " const makerTokenAddress = _.get(order, 'makerTokenAddress');", + " const takerTokenAddress = _.get(order, 'takerTokenAddress');", + " pm.expect(makerTokenAddress).to.be.equal(quoteTokenAddress);", + " pm.expect(takerTokenAddress).to.be.equal(baseTokenAddress);", + " });", + " _.forEach(asks, function(order) {", + " const makerTokenAddress = _.get(order, 'makerTokenAddress');", + " const takerTokenAddress = _.get(order, 'takerTokenAddress');", + " pm.expect(makerTokenAddress).to.be.equal(baseTokenAddress);", + " pm.expect(takerTokenAddress).to.be.equal(quoteTokenAddress);", + " });", + "});", + "" + ] + } + } + ], + "request": { + "method": "GET", + "header": [], + "body": {}, + "url": { + "raw": "{{url}}/orderbook?baseTokenAddress={{ZRX_address}}"eTokenAddress={{WETH_address}}", + "host": [ + "{{url}}" + ], + "path": [ + "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": [] + } + ], + "event": [ + { + "listen": "prerequest", + "script": { + "id": "bdf90dbc-9217-4089-8bc0-351baadddd3e", + "type": "text/javascript", + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "id": "d5080a34-57c4-4d5d-8e01-5e79599282ec", + "type": "text/javascript", + "exec": [ + "const schema = tv4.getSchema('/RelayerApiOrderBookResponse');", + "const responseJsonData = pm.response.json();", + "", + "pm.test('Schema is valid', function() {", + " pm.expect(tv4.validate(responseJsonData, schema)).to.be.true;", + "});", + "" + ] + } + } + ] + }, + { + "name": "POST /fees", + "description": "", + "item": [ + { + "name": "default request", + "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}}/fees", + "host": [ + "{{url}}" + ], + "path": [ + "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": "75d66506-0fa9-4b0e-982b-ef53bf3310f8", + "type": "text/javascript", + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "id": "4c5f9f7b-8635-4bdb-9240-a74754a2de4f", + "type": "text/javascript", + "exec": [ + "const schema = tv4.getSchema('/RelayerApiFeesResponse');", + "const responseJsonData = pm.response.json();", + "", + "pm.test('Schema is valid', function() {", + " pm.expect(tv4.validate(responseJsonData, schema)).to.be.true;", + "});", + "" + ] + } + } + ] + } + ], + "event": [ + { + "listen": "prerequest", + "script": { + "id": "da60f639-df79-4f4d-9861-79219f5fc341", + "type": "text/javascript", + "exec": [ + "const schemaKeysString = pm.environment.get('schemaKeys');", + "const schemaKeys = JSON.parse(schemaKeysString);", + "_.forEach(schemaKeys, function(schemaKey) {", + " const schemaString = pm.environment.get(schemaKey);", + " const schema = JSON.parse(schemaString);", + " tv4.addSchema(schema);", + "});", + "" + ] + } + }, + { + "listen": "test", + "script": { + "id": "b4917e72-ac87-421d-b7a5-21b64285ba5b", + "type": "text/javascript", + "exec": [ + "pm.test('Has Content-Type header with value application/json', function () {", + " pm.response.to.have.header('Content-Type');", + " const contentType = postman.getResponseHeader('Content-Type');", + " pm.expect(contentType).to.include('application/json');", + "});", + "" + ] + } + } + ] +} \ No newline at end of file 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 deleted file mode 100644 index 480c1231b..000000000 --- a/packages/sra-report/postman_configs/environments/kovan_tokens.postman_environment.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "id": "8dab7221-c8b8-2931-92c8-605f6f4072e1", - "name": "Kovan Tokens", - "values": [ - { - "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" - }, - { - "enabled": true, - "key": "EXCHANGE_CONTRACT_address", - "value": "0x90fe2af704b34e0224bf2299c838e04d4dcf1364", - "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 deleted file mode 100644 index f18c38f46..000000000 --- a/packages/sra-report/postman_configs/environments/mainnet_tokens.postman_environment.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "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" - }, - { - "enabled": true, - "key": "EXCHANGE_CONTRACT_address", - "value": "0x12459c951127e0c374ff9105dda097662a027093", - "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/src/contract_addresses/kovan_addresses.ts b/packages/sra-report/src/contract_addresses/kovan_addresses.ts new file mode 100644 index 000000000..e097bf12a --- /dev/null +++ b/packages/sra-report/src/contract_addresses/kovan_addresses.ts @@ -0,0 +1,6 @@ +export const addresses = { + 'DAI_address': '0xb18845c260f680d5b9d84649638813e342e4f8c9', + 'WETH_address': '0xd0a1e359811322d97991e03f863a0c30c2cf029c', + 'ZRX_address': '0x6ff6c0ff1d68b964901f986d4c9fa3ac68346570', + 'EXCHANGE_CONTRACT_address': '0x90fe2af704b34e0224bf2299c838e04d4dcf1364', +}; diff --git a/packages/sra-report/src/contract_addresses/mainnet_addresses.ts b/packages/sra-report/src/contract_addresses/mainnet_addresses.ts new file mode 100644 index 000000000..cbd79a0e7 --- /dev/null +++ b/packages/sra-report/src/contract_addresses/mainnet_addresses.ts @@ -0,0 +1,6 @@ +export const addresses = { + 'DAI_address': '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359', + 'WETH_address': '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', + 'ZRX_address': '0xe41d2489571d322189246dafa5ebde1f4699f498', + 'EXCHANGE_CONTRACT_address': '0x12459c951127e0c374ff9105dda097662a027093', +}; diff --git a/packages/sra-report/src/index.ts b/packages/sra-report/src/index.ts index c74b5cb40..4e93708ee 100644 --- a/packages/sra-report/src/index.ts +++ b/packages/sra-report/src/index.ts @@ -60,11 +60,6 @@ const mainAsync = async () => { if (_.isUndefined(firstOrder)) { throw new Error('Could not get any orders from /orders endpoint'); } - const newmanEnvironmentOptions = { - collection: sraReportCollectionJSON, - globals: postmanEnvironmentFactory.createGlobalEnvironment(args.endpointUrl, firstOrder), - environment: postmanEnvironmentFactory.createNetworkEnvironment(args.networkId), - }; const newmanReporterOptions = !_.isUndefined(args.output) ? { reporters: 'json', @@ -78,7 +73,8 @@ const mainAsync = async () => { reporters: 'cli', }; const newmanRunOptions = { - ...newmanEnvironmentOptions, + collection: sraReportCollectionJSON, + environment: postmanEnvironmentFactory.createPostmanEnvironment(args.endpointUrl, args.networkId, firstOrder), ...newmanReporterOptions, }; await newmanRunAsync(newmanRunOptions); diff --git a/packages/sra-report/src/postman_environment_factory.ts b/packages/sra-report/src/postman_environment_factory.ts index a8753d9ff..7534baaaf 100644 --- a/packages/sra-report/src/postman_environment_factory.ts +++ b/packages/sra-report/src/postman_environment_factory.ts @@ -2,8 +2,8 @@ import { SignedOrder, ZeroEx } from '0x.js'; import { Schema, schemas as schemasByName } from '@0xproject/json-schemas'; import * as _ from 'lodash'; -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 { addresses as kovanAddresses} from './contract_addresses/kovan_addresses'; +import { addresses as mainnetAddresses} from './contract_addresses/mainnet_addresses'; interface EnvironmentValue { key: string; @@ -13,7 +13,7 @@ interface EnvironmentValue { } export const postmanEnvironmentFactory = { - createGlobalEnvironment(url: string, order: SignedOrder) { + createPostmanEnvironment(url: string, networkId: number, order: SignedOrder) { const schemas: Schema[] = _.values(schemasByName); const schemaEnvironmentValues = _.compact( _.map(schemas, (schema: Schema) => { @@ -30,8 +30,14 @@ export const postmanEnvironmentFactory = { const schemaKeys = _.map(schemaEnvironmentValues, (environmentValue: EnvironmentValue) => { return environmentValue.key; }); + const contractAddresses = getContractAddresses(networkId); + const contractAddressEnvironmentValues = _.map(_.keys(contractAddresses), (key: string) => { + const contractAddress = _.get(contractAddresses, key); + return createEnvironmentValue(key, contractAddress); + }); const allEnvironmentValues = _.concat( schemaEnvironmentValues, + contractAddressEnvironmentValues, createEnvironmentValue('schemaKeys', JSON.stringify(schemaKeys)), createEnvironmentValue('url', url), createEnvironmentValue('order', JSON.stringify(order)), @@ -45,17 +51,17 @@ export const postmanEnvironmentFactory = { }; return environment; }, - createNetworkEnvironment(networkId: number) { - switch (networkId) { - case 1: - return mainnetTokensEnvironmentJSON; - case 42: - return kovanTokensEnvironmentJSON; - default: - return {}; - } - }, }; +function getContractAddresses(networkId: number) { + switch (networkId) { + case 1: + return mainnetAddresses; + case 42: + return kovanAddresses; + default: + throw new Error('Unsupported network id'); + } +} function convertSchemaIdToKey(schemaId: string) { let result = schemaId; if (_.startsWith(result, '/')) { -- cgit From 61ad8d4c1055096c98075282514f8a6fad020acc Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Mon, 5 Mar 2018 16:31:39 -0800 Subject: Add comment to environment factory --- packages/sra-report/src/postman_environment_factory.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/sra-report/src/postman_environment_factory.ts b/packages/sra-report/src/postman_environment_factory.ts index 7534baaaf..d32d41e18 100644 --- a/packages/sra-report/src/postman_environment_factory.ts +++ b/packages/sra-report/src/postman_environment_factory.ts @@ -7,12 +7,17 @@ import { addresses as mainnetAddresses} from './contract_addresses/mainnet_addre interface EnvironmentValue { key: string; - value: string; - enabled: boolean; - type: string; } export const postmanEnvironmentFactory = { + /** + * Dynamically generates a postman environment (https://www.getpostman.com/docs/v6/postman/environments_and_globals/manage_environments) + * When running the postman collection via newman, we provide it a set of environment variables + * These variables include: + * - 0x JSON schemas for response body validation + * - Contract addresses based on the network id for making specific queries (ex. baseTokenAddress=ZRX_address) + * - Order properties for making specific queries (ex. maker=orderMaker) + */ createPostmanEnvironment(url: string, networkId: number, order: SignedOrder) { const schemas: Schema[] = _.values(schemasByName); const schemaEnvironmentValues = _.compact( -- cgit From eb201c4084834e06fc8376434e8a7f793f916c24 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Tue, 6 Mar 2018 00:18:58 -0800 Subject: Add options for exporting environment and collection files --- packages/sra-report/src/index.ts | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/packages/sra-report/src/index.ts b/packages/sra-report/src/index.ts index 4e93708ee..37c7a8f04 100644 --- a/packages/sra-report/src/index.ts +++ b/packages/sra-report/src/index.ts @@ -27,7 +27,7 @@ const args = yargs }) .option('output', { alias: ['o', 'out'], - describe: 'Folder where to write the reports', + describe: 'The relative path to write the report generated by the collection run, prints to console by default', type: 'string', normalize: true, demandOption: false, @@ -38,7 +38,21 @@ const args = yargs type: 'number', default: DEFAULT_NETWORK_ID, }) - .example("$0 --endpoint-url 'http://api.example.com' --out 'src/contracts/generated/' --network-id 42", 'Full usage example') + .option('export-collection', { + alias: ['ec'], + describe: 'The relative path to write the postman collection file used by the collection run', + type: 'string', + normalize: true, + demandOption: false, + }) + .option('export-environment', { + alias: ['ee'], + describe: 'The relative path to write the postman environment file used by the collection run', + type: 'string', + normalize: true, + demandOption: false, + }) + .example("$0 --endpoint-url 'http://api.example.com' --out 'path/to/report.json' --network-id 42 --export-environment 'path/to/environment.json' --export-collection 'path/to/collection.json'", 'Full usage example') .argv; // perform extra validation on command line arguments try { @@ -52,7 +66,6 @@ if (!_.includes(SUPPORTED_NETWORK_IDS, args.networkId)) { utils.log(`${chalk.bold(`Supported network ids:`)} ${SUPPORTED_NETWORK_IDS}`); process.exit(1); } - const mainAsync = async () => { const httpClient = new HttpClient(args.endpointUrl); const orders = await httpClient.getOrdersAsync(); @@ -75,6 +88,8 @@ const mainAsync = async () => { const newmanRunOptions = { collection: sraReportCollectionJSON, environment: postmanEnvironmentFactory.createPostmanEnvironment(args.endpointUrl, args.networkId, firstOrder), + exportCollection: args.exportCollection, + exportEnvironment: args.exportEnvironment, ...newmanReporterOptions, }; await newmanRunAsync(newmanRunOptions); -- cgit From 551771235bc80209a1f3aafff56438621885f61a Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Tue, 6 Mar 2018 00:20:36 -0800 Subject: Prettier --- .../collections/sra_report.postman_collection.json | 1881 ++++++++++---------- .../src/contract_addresses/kovan_addresses.ts | 8 +- .../src/contract_addresses/mainnet_addresses.ts | 8 +- packages/sra-report/src/index.ts | 6 +- .../sra-report/src/postman_environment_factory.ts | 4 +- 5 files changed, 922 insertions(+), 985 deletions(-) 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 index fc7dd5b65..04c7bc51f 100644 --- a/packages/sra-report/postman_configs/collections/sra_report.postman_collection.json +++ b/packages/sra-report/postman_configs/collections/sra_report.postman_collection.json @@ -1,974 +1,909 @@ { - "info": { - "name": "sra_report", - "_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 request", - "event": [ - { - "listen": "test", - "script": { - "id": "42cb5e3f-6013-4a7c-b341-0d10cb3f2c9c", - "type": "text/javascript", - "exec": [ - "" - ] - } - } - ], - "request": { - "method": "GET", - "header": [], - "body": {}, - "url": { - "raw": "{{url}}/token_pairs", - "host": [ - "{{url}}" - ], - "path": [ - "token_pairs" - ] - }, - "description": "" - }, - "response": [] - }, - { - "name": "tokenA param", - "event": [ - { - "listen": "test", - "script": { - "id": "1b61aabb-ef9f-4269-9a0c-cb7559afcbd8", - "type": "text/javascript", - "exec": [ - "const filterTokenEnvKey = 'WETH_address';", - "const filterTokenAddress = pm.environment.get(filterTokenEnvKey);", - "const responseJsonData = pm.response.json();", - "pm.test('Token pairs are properly filtered', function() {", - " _.forEach(responseJsonData, function(tokenPair) {", - " const tokenAIsFilterToken = _.get(tokenPair, 'tokenA.address') === filterTokenAddress;", - " const tokenBIsFilterToken = _.get(tokenPair, 'tokenB.address') === filterTokenAddress;", - " const condition = tokenAIsFilterToken || tokenBIsFilterToken", - " pm.expect(condition).to.be.true;", - " });", - "});", - "" - ] - } - } - ], - "request": { - "method": "GET", - "header": [], - "body": {}, - "url": { - "raw": "{{url}}/token_pairs?tokenA={{WETH_address}}", - "host": [ - "{{url}}" - ], - "path": [ - "token_pairs" - ], - "query": [ - { - "key": "tokenA", - "value": "{{WETH_address}}", - "equals": true - } - ] - }, - "description": "" - }, - "response": [] - }, - { - "name": "tokenB param", - "event": [ - { - "listen": "test", - "script": { - "id": "a5f946b1-fc97-4bcf-ae01-e0f97864a6c1", - "type": "text/javascript", - "exec": [ - "const filterTokenEnvKey = 'WETH_address';", - "const filterTokenAddress = pm.environment.get(filterTokenEnvKey);", - "const responseJsonData = pm.response.json();", - "pm.test('Token pairs are properly filtered', function() {", - " _.forEach(responseJsonData, function(tokenPair) {", - " const tokenAIsFilterToken = _.get(tokenPair, 'tokenA.address') === filterTokenAddress;", - " const tokenBIsFilterToken = _.get(tokenPair, 'tokenB.address') === filterTokenAddress;", - " const condition = tokenAIsFilterToken || tokenBIsFilterToken", - " pm.expect(condition).to.be.true;", - " });", - "});", - "" - ] - } - } - ], - "request": { - "method": "GET", - "header": [], - "body": {}, - "url": { - "raw": "{{url}}/token_pairs?tokenB={{WETH_address}}", - "host": [ - "{{url}}" - ], - "path": [ - "token_pairs" - ], - "query": [ - { - "key": "tokenB", - "value": "{{WETH_address}}", - "equals": true - } - ] - }, - "description": "" - }, - "response": [] - }, - { - "name": "tokenA and tokenB params", - "event": [ - { - "listen": "test", - "script": { - "id": "bcd06e4f-aa3a-42f8-9f8c-bc902eb7a075", - "type": "text/javascript", - "exec": [ - "const filterTokenAEnvKey = 'WETH_address';", - "const filterTokenBEnvKey = 'ZRX_address';", - "const filterTokenAAddress = pm.environment.get(filterTokenAEnvKey);", - "const filterTokenBAddress = pm.environment.get(filterTokenBEnvKey);", - "const responseJsonData = pm.response.json();", - "pm.test('Token pairs are properly filtered', function() {", - " _.forEach(responseJsonData, function(tokenPair) {", - " const tokenAIsFilterTokenA = _.get(tokenPair, 'tokenA.address') === filterTokenAAddress;", - " const tokenAIsFilterTokenB = _.get(tokenPair, 'tokenA.address') === filterTokenBAddress;", - " const tokenBIsFilterTokenA = _.get(tokenPair, 'tokenB.address') === filterTokenAAddress;", - " const tokenBIsFilterTokenB = _.get(tokenPair, 'tokenB.address') === filterTokenBAddress;", - " const condition = (tokenAIsFilterTokenA && tokenBIsFilterTokenB) || (tokenBIsFilterTokenA && tokenAIsFilterTokenB)", - " pm.expect(condition).to.be.true;", - " });", - "});", - "" - ] - } - } - ], - "request": { - "method": "GET", - "header": [], - "body": {}, - "url": { - "raw": "{{url}}/token_pairs?tokenA={{WETH_address}}&tokenB={{ZRX_address}}", - "host": [ - "{{url}}" - ], - "path": [ - "token_pairs" - ], - "query": [ - { - "key": "tokenA", - "value": "{{WETH_address}}", - "equals": true - }, - { - "key": "tokenB", - "value": "{{ZRX_address}}", - "equals": true - } - ] - }, - "description": "" - }, - "response": [] - } - ], - "event": [ - { - "listen": "prerequest", - "script": { - "id": "3d032e92-6a17-49f0-8115-bae1c7298b55", - "type": "text/javascript", - "exec": [ - "" - ] - } - }, - { - "listen": "test", - "script": { - "id": "25addb38-bd1c-4eb3-a193-5617119dc0d6", - "type": "text/javascript", - "exec": [ - "const schema = tv4.getSchema('/RelayerApiTokenPairsResponse');", - "const responseJsonData = pm.response.json();", - "", - "pm.test('Schema is valid', function() {", - " pm.expect(tv4.validate(responseJsonData, schema)).to.be.true;", - "});", - "" - ] - } - } - ] - }, - { - "name": "GET /orders", - "description": "", - "item": [ - { - "name": "default request", - "event": [ - { - "listen": "test", - "script": { - "id": "118f47dd-1d93-4288-841f-de88783eff3b", - "type": "text/javascript", - "exec": [ - "" - ] - } - } - ], - "request": { - "method": "GET", - "header": [], - "body": {}, - "url": { - "raw": "{{url}}/orders", - "host": [ - "{{url}}" - ], - "path": [ - "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": "exchangeContract param", - "event": [ - { - "listen": "test", - "script": { - "id": "e782ae77-66bf-4096-9190-ef9e7501b316", - "type": "text/javascript", - "exec": [ - "const exchangeContractEnvKey = 'EXCHANGE_CONTRACT_address';", - "const requestedExchangeContractAddress = pm.environment.get(exchangeContractEnvKey);", - "const responseJsonData = pm.response.json();", - "pm.test('Orders are properly filtered', function() {", - " _.forEach(responseJsonData, function(order) {", - " const returnedExchangeContractAddress = _.get(order, 'exchangeContractAddress');", - " pm.expect(requestedExchangeContractAddress).to.equal(returnedExchangeContractAddress);", - " });", - "});", - "" - ] - } - } - ], - "request": { - "method": "GET", - "header": [], - "body": {}, - "url": { - "raw": "{{url}}/orders?exchangeContractAddress={{EXCHANGE_CONTRACT_address}}", - "host": [ - "{{url}}" - ], - "path": [ - "orders" - ], - "query": [ - { - "key": "exchangeContractAddress", - "value": "{{EXCHANGE_CONTRACT_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": "tokenAddress param", - "event": [ - { - "listen": "test", - "script": { - "id": "1144a2d6-6175-40a6-8568-d0d3884492a1", - "type": "text/javascript", - "exec": [ - "const filterTokenEnvKey = 'ZRX_address';", - "const filterTokenAddress = pm.environment.get(filterTokenEnvKey);", - "const responseJsonData = pm.response.json();", - "pm.test('Orders are properly filtered', function() {", - " _.forEach(responseJsonData, function(order) {", - " const makerTokenAddress = _.get(order, 'makerTokenAddress');", - " const takerTokenAddress = _.get(order, 'takerTokenAddress');", - " const makerTokenAddressIsFilterToken = makerTokenAddress === filterTokenAddress;", - " const takerTokenAddressIsFilterToken = takerTokenAddress === filterTokenAddress;", - " const condition = makerTokenAddressIsFilterToken || takerTokenAddressIsFilterToken;", - " pm.expect(condition).to.be.true;", - " });", - "});", - "" - ] - } - } - ], - "request": { - "method": "GET", - "header": [], - "body": {}, - "url": { - "raw": "{{url}}/orders?tokenAddress={{ZRX_address}}", - "host": [ - "{{url}}" - ], - "path": [ - "orders" - ], - "query": [ - { - "key": "tokenAddress", - "value": "{{ZRX_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": "makerTokenAddress param", - "event": [ - { - "listen": "test", - "script": { - "id": "01eb5865-edec-4216-8a90-c36d790366fc", - "type": "text/javascript", - "exec": [ - "const filterTokenEnvKey = 'ZRX_address';", - "const filterTokenAddress = pm.environment.get(filterTokenEnvKey);", - "const responseJsonData = pm.response.json();", - "pm.test('Orders are properly filtered', function() {", - " _.forEach(responseJsonData, function(order) {", - " const makerTokenAddress = _.get(order, 'makerTokenAddress');", - " pm.expect(makerTokenAddress).to.be.equal(filterTokenAddress);", - " });", - "});", - "" - ] - } - } - ], - "request": { - "method": "GET", - "header": [], - "body": {}, - "url": { - "raw": "{{url}}/orders?makerTokenAddress={{ZRX_address}}", - "host": [ - "{{url}}" - ], - "path": [ - "orders" - ], - "query": [ - { - "key": "makerTokenAddress", - "value": "{{ZRX_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": "takerTokenAddress param", - "event": [ - { - "listen": "test", - "script": { - "id": "bbbb6e15-60c7-4666-96be-a0ad56b6058b", - "type": "text/javascript", - "exec": [ - "const filterTokenEnvKey = 'ZRX_address';", - "const filterTokenAddress = pm.environment.get(filterTokenEnvKey);", - "const responseJsonData = pm.response.json();", - "pm.test('Orders are properly filtered', function() {", - " _.forEach(responseJsonData, function(order) {", - " const takerTokenAddress = _.get(order, 'takerTokenAddress');", - " pm.expect(takerTokenAddress).to.be.equal(filterTokenAddress);", - " });", - "});", - "" - ] - } - } - ], - "request": { - "method": "GET", - "header": [], - "body": {}, - "url": { - "raw": "{{url}}/orders?takerTokenAddress={{ZRX_address}}", - "host": [ - "{{url}}" - ], - "path": [ - "orders" - ], - "query": [ - { - "key": "takerTokenAddress", - "value": "{{ZRX_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": "maker param", - "event": [ - { - "listen": "test", - "script": { - "id": "1f5960de-117f-44fb-82e0-581626cbf62b", - "type": "text/javascript", - "exec": [ - "const orderMakerEnvKey = 'orderMaker';", - "const referenceOrderMakerAddress = pm.environment.get(orderMakerEnvKey);", - "const responseJsonData = pm.response.json();", - "pm.test('Orders are properly filtered', function() {", - " _.forEach(responseJsonData, function(order) {", - " const returnedMakerAddress = _.get(order, 'maker');", - " pm.expect(referenceOrderMakerAddress).to.be.equal(returnedMakerAddress);", - " });", - "});", - "" - ] - } - } - ], - "request": { - "method": "GET", - "header": [], - "body": {}, - "url": { - "raw": "{{url}}/orders?maker={{orderMaker}}", - "host": [ - "{{url}}" - ], - "path": [ - "orders" - ], - "query": [ - { - "key": "maker", - "value": "{{orderMaker}}", - "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": "taker param", - "event": [ - { - "listen": "test", - "script": { - "id": "f23de2eb-b444-49d3-93b7-14ae712d6502", - "type": "text/javascript", - "exec": [ - "const orderTakerEnvKey = 'orderTaker';", - "const referenceOrderTakerAddress = pm.environment.get(orderTakerEnvKey);", - "const responseJsonData = pm.response.json();", - "pm.test('Orders are properly filtered', function() {", - " _.forEach(responseJsonData, function(order) {", - " const returnedTakerAddress = _.get(order, 'taker');", - " pm.expect(referenceOrderTakerAddress).to.be.equal(returnedTakerAddress);", - " });", - "});", - "" - ] - } - } - ], - "request": { - "method": "GET", - "header": [], - "body": {}, - "url": { - "raw": "{{url}}/orders?taker={{orderTaker}}", - "host": [ - "{{url}}" - ], - "path": [ - "orders" - ], - "query": [ - { - "key": "taker", - "value": "{{orderTaker}}", - "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": "trader param", - "event": [ - { - "listen": "test", - "script": { - "id": "9689639a-47ce-4c3b-8180-859fd28437be", - "type": "text/javascript", - "exec": [ - "const orderTraderEnvKey = 'orderMaker';", - "const referenceOrderTraderAddress = pm.environment.get(orderTraderEnvKey);", - "const responseJsonData = pm.response.json();", - "pm.test('Orders are properly filtered', function() {", - " _.forEach(responseJsonData, function(order) {", - " const returnedMakerAddress = _.get(order, 'maker');", - " const returnedTakerAddress = _.get(order, 'taker');", - " const condition = (referenceOrderTraderAddress === returnedMakerAddress) || (referenceOrderTraderAddress === returnedTakerAddress);", - " pm.expect(condition).to.be.true;", - " });", - "});", - "" - ] - } - } - ], - "request": { - "method": "GET", - "header": [], - "body": {}, - "url": { - "raw": "{{url}}/orders?trader={{orderMaker}}", - "host": [ - "{{url}}" - ], - "path": [ - "orders" - ], - "query": [ - { - "key": "trader", - "value": "{{orderMaker}}", - "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": "feeRecipient param", - "event": [ - { - "listen": "test", - "script": { - "id": "010c0cf6-8d5b-4fe3-8b92-b2009ea43a3e", - "type": "text/javascript", - "exec": [ - "const orderFeeRecipientEnvKey = 'orderFeeRecipient';", - "const referenceOrderFeeRecipientAddress = pm.environment.get(orderFeeRecipientEnvKey);", - "const responseJsonData = pm.response.json();", - "pm.test('Orders are properly filtered', function() {", - " _.forEach(responseJsonData, function(order) {", - " const returnedFeeRecipientAddress = _.get(order, 'feeRecipient');", - " pm.expect(referenceOrderFeeRecipientAddress).to.be.equal(returnedFeeRecipientAddress);", - " });", - "});", - "" - ] - } - } - ], - "request": { - "method": "GET", - "header": [], - "body": {}, - "url": { - "raw": "{{url}}/orders?feeRecipient={{orderFeeRecipient}}", - "host": [ - "{{url}}" - ], - "path": [ - "orders" - ], - "query": [ - { - "key": "feeRecipient", - "value": "{{orderFeeRecipient}}", - "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": [ - "const schema = tv4.getSchema('/signedOrdersSchema');", - "const responseJsonData = pm.response.json();", - "", - "pm.test('Schema is valid', function() {", - " pm.expect(tv4.validate(responseJsonData, schema)).to.be.true;", - "});", - "" - ] - } - } - ] - }, - { - "name": "GET /order", - "description": "", - "item": [ - { - "name": "orderHash param", - "event": [ - { - "listen": "test", - "script": { - "id": "18876df2-384e-43d5-93a1-7e24571e1308", - "type": "text/javascript", - "exec": [ - "const orderEnvKey = 'order';", - "const referenceOrderString = pm.environment.get(orderEnvKey);", - "const referenceOrderJson = JSON.parse(referenceOrderString);", - "const orderPropertyNames = [", - " 'maker',", - " 'taker',", - " 'makerFee',", - " 'takerFee',", - " 'makerTokenAmount',", - " 'takerTokenAmount',", - " 'makerTokenAddress',", - " 'takerTokenAddress',", - " 'salt',", - " 'feeRecipient',", - " 'expirationUnixTimestampSec',", - " 'exchangeContractAddress'", - "];", - "const signaturePropertyNames = [", - " 'v',", - " 'r',", - " 's'", - "];", - "const returnedOrderJson = pm.response.json();", - "pm.test('Order is properly retreived', function() {", - " _.forEach(orderPropertyNames, function(propertyName) {", - " const returnedProperty = _.get(returnedOrderJson, propertyName);", - " const referenceProperty = _.get(referenceOrderJson, propertyName);", - " pm.expect(returnedProperty).to.be.equal(referenceProperty);", - " });", - " const returnedSignature = _.get(returnedOrderJson, 'ecSignature');", - " const referenceSignature = _.get(returnedOrderJson, 'ecSignature');", - " _.forEach(signaturePropertyNames, function(propertyName) {", - " const returnedSignatureProperty = _.get(returnedSignature, propertyName);", - " const referenceSignatureProperty = _.get(referenceSignature, propertyName);", - " pm.expect(returnedSignatureProperty).to.be.equal(referenceSignatureProperty);", - " });", - "});", - "" - ] - } - } - ], - "request": { - "method": "GET", - "header": [], - "body": {}, - "url": { - "raw": "{{url}}/order/{{orderHash}}", - "host": [ - "{{url}}" - ], - "path": [ - "order", - "{{orderHash}}" - ] - }, - "description": "Retrieves a specific order by orderHash." - }, - "response": [] - } - ], - "event": [ - { - "listen": "prerequest", - "script": { - "id": "e356d2ff-d105-42c1-b679-d9d917dcd68d", - "type": "text/javascript", - "exec": [ - "" - ] - } - }, - { - "listen": "test", - "script": { - "id": "8d2d4717-6f76-47ab-8e5a-f383192f6ee4", - "type": "text/javascript", - "exec": [ - "const schema = tv4.getSchema('/SignedOrder');", - "const responseJsonData = pm.response.json();", - "", - "pm.test('Schema is valid', function() {", - " pm.expect(tv4.validate(responseJsonData, schema)).to.be.true;", - "});", - "" - ] - } - } - ] - }, - { - "name": "GET /orderbook", - "description": "", - "item": [ - { - "name": "baseTokenAddress and quoteTokenAddress params", - "event": [ - { - "listen": "test", - "script": { - "id": "0198622e-9705-4ae1-b1f2-0c40b87de856", - "type": "text/javascript", - "exec": [ - "const baseTokenEnvKey = 'ZRX_address';", - "const quoteTokenEnvKey = 'WETH_address';", - "const baseTokenAddress = pm.environment.get(baseTokenEnvKey);", - "const quoteTokenAddress = pm.environment.get(quoteTokenEnvKey);", - "const responseJsonData = pm.response.json();", - "pm.test('Orderbook is properly filtered', function() {", - " const bids = _.get(responseJsonData, 'bids');", - " const asks = _.get(responseJsonData, 'asks');", - " _.forEach(bids, function(order) {", - " const makerTokenAddress = _.get(order, 'makerTokenAddress');", - " const takerTokenAddress = _.get(order, 'takerTokenAddress');", - " pm.expect(makerTokenAddress).to.be.equal(quoteTokenAddress);", - " pm.expect(takerTokenAddress).to.be.equal(baseTokenAddress);", - " });", - " _.forEach(asks, function(order) {", - " const makerTokenAddress = _.get(order, 'makerTokenAddress');", - " const takerTokenAddress = _.get(order, 'takerTokenAddress');", - " pm.expect(makerTokenAddress).to.be.equal(baseTokenAddress);", - " pm.expect(takerTokenAddress).to.be.equal(quoteTokenAddress);", - " });", - "});", - "" - ] - } - } - ], - "request": { - "method": "GET", - "header": [], - "body": {}, - "url": { - "raw": "{{url}}/orderbook?baseTokenAddress={{ZRX_address}}"eTokenAddress={{WETH_address}}", - "host": [ - "{{url}}" - ], - "path": [ - "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": [] - } - ], - "event": [ - { - "listen": "prerequest", - "script": { - "id": "bdf90dbc-9217-4089-8bc0-351baadddd3e", - "type": "text/javascript", - "exec": [ - "" - ] - } - }, - { - "listen": "test", - "script": { - "id": "d5080a34-57c4-4d5d-8e01-5e79599282ec", - "type": "text/javascript", - "exec": [ - "const schema = tv4.getSchema('/RelayerApiOrderBookResponse');", - "const responseJsonData = pm.response.json();", - "", - "pm.test('Schema is valid', function() {", - " pm.expect(tv4.validate(responseJsonData, schema)).to.be.true;", - "});", - "" - ] - } - } - ] - }, - { - "name": "POST /fees", - "description": "", - "item": [ - { - "name": "default request", - "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}}/fees", - "host": [ - "{{url}}" - ], - "path": [ - "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": "75d66506-0fa9-4b0e-982b-ef53bf3310f8", - "type": "text/javascript", - "exec": [ - "" - ] - } - }, - { - "listen": "test", - "script": { - "id": "4c5f9f7b-8635-4bdb-9240-a74754a2de4f", - "type": "text/javascript", - "exec": [ - "const schema = tv4.getSchema('/RelayerApiFeesResponse');", - "const responseJsonData = pm.response.json();", - "", - "pm.test('Schema is valid', function() {", - " pm.expect(tv4.validate(responseJsonData, schema)).to.be.true;", - "});", - "" - ] - } - } - ] - } - ], - "event": [ - { - "listen": "prerequest", - "script": { - "id": "da60f639-df79-4f4d-9861-79219f5fc341", - "type": "text/javascript", - "exec": [ - "const schemaKeysString = pm.environment.get('schemaKeys');", - "const schemaKeys = JSON.parse(schemaKeysString);", - "_.forEach(schemaKeys, function(schemaKey) {", - " const schemaString = pm.environment.get(schemaKey);", - " const schema = JSON.parse(schemaString);", - " tv4.addSchema(schema);", - "});", - "" - ] - } - }, - { - "listen": "test", - "script": { - "id": "b4917e72-ac87-421d-b7a5-21b64285ba5b", - "type": "text/javascript", - "exec": [ - "pm.test('Has Content-Type header with value application/json', function () {", - " pm.response.to.have.header('Content-Type');", - " const contentType = postman.getResponseHeader('Content-Type');", - " pm.expect(contentType).to.include('application/json');", - "});", - "" - ] - } - } - ] -} \ No newline at end of file + "info": { + "name": "sra_report", + "_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 request", + "event": [ + { + "listen": "test", + "script": { + "id": "42cb5e3f-6013-4a7c-b341-0d10cb3f2c9c", + "type": "text/javascript", + "exec": [""] + } + } + ], + "request": { + "method": "GET", + "header": [], + "body": {}, + "url": { + "raw": "{{url}}/token_pairs", + "host": ["{{url}}"], + "path": ["token_pairs"] + }, + "description": "" + }, + "response": [] + }, + { + "name": "tokenA param", + "event": [ + { + "listen": "test", + "script": { + "id": "1b61aabb-ef9f-4269-9a0c-cb7559afcbd8", + "type": "text/javascript", + "exec": [ + "const filterTokenEnvKey = 'WETH_address';", + "const filterTokenAddress = pm.environment.get(filterTokenEnvKey);", + "const responseJsonData = pm.response.json();", + "pm.test('Token pairs are properly filtered', function() {", + " _.forEach(responseJsonData, function(tokenPair) {", + " const tokenAIsFilterToken = _.get(tokenPair, 'tokenA.address') === filterTokenAddress;", + " const tokenBIsFilterToken = _.get(tokenPair, 'tokenB.address') === filterTokenAddress;", + " const condition = tokenAIsFilterToken || tokenBIsFilterToken", + " pm.expect(condition).to.be.true;", + " });", + "});", + "" + ] + } + } + ], + "request": { + "method": "GET", + "header": [], + "body": {}, + "url": { + "raw": "{{url}}/token_pairs?tokenA={{WETH_address}}", + "host": ["{{url}}"], + "path": ["token_pairs"], + "query": [ + { + "key": "tokenA", + "value": "{{WETH_address}}", + "equals": true + } + ] + }, + "description": "" + }, + "response": [] + }, + { + "name": "tokenB param", + "event": [ + { + "listen": "test", + "script": { + "id": "a5f946b1-fc97-4bcf-ae01-e0f97864a6c1", + "type": "text/javascript", + "exec": [ + "const filterTokenEnvKey = 'WETH_address';", + "const filterTokenAddress = pm.environment.get(filterTokenEnvKey);", + "const responseJsonData = pm.response.json();", + "pm.test('Token pairs are properly filtered', function() {", + " _.forEach(responseJsonData, function(tokenPair) {", + " const tokenAIsFilterToken = _.get(tokenPair, 'tokenA.address') === filterTokenAddress;", + " const tokenBIsFilterToken = _.get(tokenPair, 'tokenB.address') === filterTokenAddress;", + " const condition = tokenAIsFilterToken || tokenBIsFilterToken", + " pm.expect(condition).to.be.true;", + " });", + "});", + "" + ] + } + } + ], + "request": { + "method": "GET", + "header": [], + "body": {}, + "url": { + "raw": "{{url}}/token_pairs?tokenB={{WETH_address}}", + "host": ["{{url}}"], + "path": ["token_pairs"], + "query": [ + { + "key": "tokenB", + "value": "{{WETH_address}}", + "equals": true + } + ] + }, + "description": "" + }, + "response": [] + }, + { + "name": "tokenA and tokenB params", + "event": [ + { + "listen": "test", + "script": { + "id": "bcd06e4f-aa3a-42f8-9f8c-bc902eb7a075", + "type": "text/javascript", + "exec": [ + "const filterTokenAEnvKey = 'WETH_address';", + "const filterTokenBEnvKey = 'ZRX_address';", + "const filterTokenAAddress = pm.environment.get(filterTokenAEnvKey);", + "const filterTokenBAddress = pm.environment.get(filterTokenBEnvKey);", + "const responseJsonData = pm.response.json();", + "pm.test('Token pairs are properly filtered', function() {", + " _.forEach(responseJsonData, function(tokenPair) {", + " const tokenAIsFilterTokenA = _.get(tokenPair, 'tokenA.address') === filterTokenAAddress;", + " const tokenAIsFilterTokenB = _.get(tokenPair, 'tokenA.address') === filterTokenBAddress;", + " const tokenBIsFilterTokenA = _.get(tokenPair, 'tokenB.address') === filterTokenAAddress;", + " const tokenBIsFilterTokenB = _.get(tokenPair, 'tokenB.address') === filterTokenBAddress;", + " const condition = (tokenAIsFilterTokenA && tokenBIsFilterTokenB) || (tokenBIsFilterTokenA && tokenAIsFilterTokenB)", + " pm.expect(condition).to.be.true;", + " });", + "});", + "" + ] + } + } + ], + "request": { + "method": "GET", + "header": [], + "body": {}, + "url": { + "raw": "{{url}}/token_pairs?tokenA={{WETH_address}}&tokenB={{ZRX_address}}", + "host": ["{{url}}"], + "path": ["token_pairs"], + "query": [ + { + "key": "tokenA", + "value": "{{WETH_address}}", + "equals": true + }, + { + "key": "tokenB", + "value": "{{ZRX_address}}", + "equals": true + } + ] + }, + "description": "" + }, + "response": [] + } + ], + "event": [ + { + "listen": "prerequest", + "script": { + "id": "3d032e92-6a17-49f0-8115-bae1c7298b55", + "type": "text/javascript", + "exec": [""] + } + }, + { + "listen": "test", + "script": { + "id": "25addb38-bd1c-4eb3-a193-5617119dc0d6", + "type": "text/javascript", + "exec": [ + "const schema = tv4.getSchema('/RelayerApiTokenPairsResponse');", + "const responseJsonData = pm.response.json();", + "", + "pm.test('Schema is valid', function() {", + " pm.expect(tv4.validate(responseJsonData, schema)).to.be.true;", + "});", + "" + ] + } + } + ] + }, + { + "name": "GET /orders", + "description": "", + "item": [ + { + "name": "default request", + "event": [ + { + "listen": "test", + "script": { + "id": "118f47dd-1d93-4288-841f-de88783eff3b", + "type": "text/javascript", + "exec": [""] + } + } + ], + "request": { + "method": "GET", + "header": [], + "body": {}, + "url": { + "raw": "{{url}}/orders", + "host": ["{{url}}"], + "path": ["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": "exchangeContract param", + "event": [ + { + "listen": "test", + "script": { + "id": "e782ae77-66bf-4096-9190-ef9e7501b316", + "type": "text/javascript", + "exec": [ + "const exchangeContractEnvKey = 'EXCHANGE_CONTRACT_address';", + "const requestedExchangeContractAddress = pm.environment.get(exchangeContractEnvKey);", + "const responseJsonData = pm.response.json();", + "pm.test('Orders are properly filtered', function() {", + " _.forEach(responseJsonData, function(order) {", + " const returnedExchangeContractAddress = _.get(order, 'exchangeContractAddress');", + " pm.expect(requestedExchangeContractAddress).to.equal(returnedExchangeContractAddress);", + " });", + "});", + "" + ] + } + } + ], + "request": { + "method": "GET", + "header": [], + "body": {}, + "url": { + "raw": "{{url}}/orders?exchangeContractAddress={{EXCHANGE_CONTRACT_address}}", + "host": ["{{url}}"], + "path": ["orders"], + "query": [ + { + "key": "exchangeContractAddress", + "value": "{{EXCHANGE_CONTRACT_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": "tokenAddress param", + "event": [ + { + "listen": "test", + "script": { + "id": "1144a2d6-6175-40a6-8568-d0d3884492a1", + "type": "text/javascript", + "exec": [ + "const filterTokenEnvKey = 'ZRX_address';", + "const filterTokenAddress = pm.environment.get(filterTokenEnvKey);", + "const responseJsonData = pm.response.json();", + "pm.test('Orders are properly filtered', function() {", + " _.forEach(responseJsonData, function(order) {", + " const makerTokenAddress = _.get(order, 'makerTokenAddress');", + " const takerTokenAddress = _.get(order, 'takerTokenAddress');", + " const makerTokenAddressIsFilterToken = makerTokenAddress === filterTokenAddress;", + " const takerTokenAddressIsFilterToken = takerTokenAddress === filterTokenAddress;", + " const condition = makerTokenAddressIsFilterToken || takerTokenAddressIsFilterToken;", + " pm.expect(condition).to.be.true;", + " });", + "});", + "" + ] + } + } + ], + "request": { + "method": "GET", + "header": [], + "body": {}, + "url": { + "raw": "{{url}}/orders?tokenAddress={{ZRX_address}}", + "host": ["{{url}}"], + "path": ["orders"], + "query": [ + { + "key": "tokenAddress", + "value": "{{ZRX_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": "makerTokenAddress param", + "event": [ + { + "listen": "test", + "script": { + "id": "01eb5865-edec-4216-8a90-c36d790366fc", + "type": "text/javascript", + "exec": [ + "const filterTokenEnvKey = 'ZRX_address';", + "const filterTokenAddress = pm.environment.get(filterTokenEnvKey);", + "const responseJsonData = pm.response.json();", + "pm.test('Orders are properly filtered', function() {", + " _.forEach(responseJsonData, function(order) {", + " const makerTokenAddress = _.get(order, 'makerTokenAddress');", + " pm.expect(makerTokenAddress).to.be.equal(filterTokenAddress);", + " });", + "});", + "" + ] + } + } + ], + "request": { + "method": "GET", + "header": [], + "body": {}, + "url": { + "raw": "{{url}}/orders?makerTokenAddress={{ZRX_address}}", + "host": ["{{url}}"], + "path": ["orders"], + "query": [ + { + "key": "makerTokenAddress", + "value": "{{ZRX_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": "takerTokenAddress param", + "event": [ + { + "listen": "test", + "script": { + "id": "bbbb6e15-60c7-4666-96be-a0ad56b6058b", + "type": "text/javascript", + "exec": [ + "const filterTokenEnvKey = 'ZRX_address';", + "const filterTokenAddress = pm.environment.get(filterTokenEnvKey);", + "const responseJsonData = pm.response.json();", + "pm.test('Orders are properly filtered', function() {", + " _.forEach(responseJsonData, function(order) {", + " const takerTokenAddress = _.get(order, 'takerTokenAddress');", + " pm.expect(takerTokenAddress).to.be.equal(filterTokenAddress);", + " });", + "});", + "" + ] + } + } + ], + "request": { + "method": "GET", + "header": [], + "body": {}, + "url": { + "raw": "{{url}}/orders?takerTokenAddress={{ZRX_address}}", + "host": ["{{url}}"], + "path": ["orders"], + "query": [ + { + "key": "takerTokenAddress", + "value": "{{ZRX_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": "maker param", + "event": [ + { + "listen": "test", + "script": { + "id": "1f5960de-117f-44fb-82e0-581626cbf62b", + "type": "text/javascript", + "exec": [ + "const orderMakerEnvKey = 'orderMaker';", + "const referenceOrderMakerAddress = pm.environment.get(orderMakerEnvKey);", + "const responseJsonData = pm.response.json();", + "pm.test('Orders are properly filtered', function() {", + " _.forEach(responseJsonData, function(order) {", + " const returnedMakerAddress = _.get(order, 'maker');", + " pm.expect(referenceOrderMakerAddress).to.be.equal(returnedMakerAddress);", + " });", + "});", + "" + ] + } + } + ], + "request": { + "method": "GET", + "header": [], + "body": {}, + "url": { + "raw": "{{url}}/orders?maker={{orderMaker}}", + "host": ["{{url}}"], + "path": ["orders"], + "query": [ + { + "key": "maker", + "value": "{{orderMaker}}", + "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": "taker param", + "event": [ + { + "listen": "test", + "script": { + "id": "f23de2eb-b444-49d3-93b7-14ae712d6502", + "type": "text/javascript", + "exec": [ + "const orderTakerEnvKey = 'orderTaker';", + "const referenceOrderTakerAddress = pm.environment.get(orderTakerEnvKey);", + "const responseJsonData = pm.response.json();", + "pm.test('Orders are properly filtered', function() {", + " _.forEach(responseJsonData, function(order) {", + " const returnedTakerAddress = _.get(order, 'taker');", + " pm.expect(referenceOrderTakerAddress).to.be.equal(returnedTakerAddress);", + " });", + "});", + "" + ] + } + } + ], + "request": { + "method": "GET", + "header": [], + "body": {}, + "url": { + "raw": "{{url}}/orders?taker={{orderTaker}}", + "host": ["{{url}}"], + "path": ["orders"], + "query": [ + { + "key": "taker", + "value": "{{orderTaker}}", + "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": "trader param", + "event": [ + { + "listen": "test", + "script": { + "id": "9689639a-47ce-4c3b-8180-859fd28437be", + "type": "text/javascript", + "exec": [ + "const orderTraderEnvKey = 'orderMaker';", + "const referenceOrderTraderAddress = pm.environment.get(orderTraderEnvKey);", + "const responseJsonData = pm.response.json();", + "pm.test('Orders are properly filtered', function() {", + " _.forEach(responseJsonData, function(order) {", + " const returnedMakerAddress = _.get(order, 'maker');", + " const returnedTakerAddress = _.get(order, 'taker');", + " const condition = (referenceOrderTraderAddress === returnedMakerAddress) || (referenceOrderTraderAddress === returnedTakerAddress);", + " pm.expect(condition).to.be.true;", + " });", + "});", + "" + ] + } + } + ], + "request": { + "method": "GET", + "header": [], + "body": {}, + "url": { + "raw": "{{url}}/orders?trader={{orderMaker}}", + "host": ["{{url}}"], + "path": ["orders"], + "query": [ + { + "key": "trader", + "value": "{{orderMaker}}", + "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": "feeRecipient param", + "event": [ + { + "listen": "test", + "script": { + "id": "010c0cf6-8d5b-4fe3-8b92-b2009ea43a3e", + "type": "text/javascript", + "exec": [ + "const orderFeeRecipientEnvKey = 'orderFeeRecipient';", + "const referenceOrderFeeRecipientAddress = pm.environment.get(orderFeeRecipientEnvKey);", + "const responseJsonData = pm.response.json();", + "pm.test('Orders are properly filtered', function() {", + " _.forEach(responseJsonData, function(order) {", + " const returnedFeeRecipientAddress = _.get(order, 'feeRecipient');", + " pm.expect(referenceOrderFeeRecipientAddress).to.be.equal(returnedFeeRecipientAddress);", + " });", + "});", + "" + ] + } + } + ], + "request": { + "method": "GET", + "header": [], + "body": {}, + "url": { + "raw": "{{url}}/orders?feeRecipient={{orderFeeRecipient}}", + "host": ["{{url}}"], + "path": ["orders"], + "query": [ + { + "key": "feeRecipient", + "value": "{{orderFeeRecipient}}", + "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": [ + "const schema = tv4.getSchema('/signedOrdersSchema');", + "const responseJsonData = pm.response.json();", + "", + "pm.test('Schema is valid', function() {", + " pm.expect(tv4.validate(responseJsonData, schema)).to.be.true;", + "});", + "" + ] + } + } + ] + }, + { + "name": "GET /order", + "description": "", + "item": [ + { + "name": "orderHash param", + "event": [ + { + "listen": "test", + "script": { + "id": "18876df2-384e-43d5-93a1-7e24571e1308", + "type": "text/javascript", + "exec": [ + "const orderEnvKey = 'order';", + "const referenceOrderString = pm.environment.get(orderEnvKey);", + "const referenceOrderJson = JSON.parse(referenceOrderString);", + "const orderPropertyNames = [", + " 'maker',", + " 'taker',", + " 'makerFee',", + " 'takerFee',", + " 'makerTokenAmount',", + " 'takerTokenAmount',", + " 'makerTokenAddress',", + " 'takerTokenAddress',", + " 'salt',", + " 'feeRecipient',", + " 'expirationUnixTimestampSec',", + " 'exchangeContractAddress'", + "];", + "const signaturePropertyNames = [", + " 'v',", + " 'r',", + " 's'", + "];", + "const returnedOrderJson = pm.response.json();", + "pm.test('Order is properly retreived', function() {", + " _.forEach(orderPropertyNames, function(propertyName) {", + " const returnedProperty = _.get(returnedOrderJson, propertyName);", + " const referenceProperty = _.get(referenceOrderJson, propertyName);", + " pm.expect(returnedProperty).to.be.equal(referenceProperty);", + " });", + " const returnedSignature = _.get(returnedOrderJson, 'ecSignature');", + " const referenceSignature = _.get(returnedOrderJson, 'ecSignature');", + " _.forEach(signaturePropertyNames, function(propertyName) {", + " const returnedSignatureProperty = _.get(returnedSignature, propertyName);", + " const referenceSignatureProperty = _.get(referenceSignature, propertyName);", + " pm.expect(returnedSignatureProperty).to.be.equal(referenceSignatureProperty);", + " });", + "});", + "" + ] + } + } + ], + "request": { + "method": "GET", + "header": [], + "body": {}, + "url": { + "raw": "{{url}}/order/{{orderHash}}", + "host": ["{{url}}"], + "path": ["order", "{{orderHash}}"] + }, + "description": "Retrieves a specific order by orderHash." + }, + "response": [] + } + ], + "event": [ + { + "listen": "prerequest", + "script": { + "id": "e356d2ff-d105-42c1-b679-d9d917dcd68d", + "type": "text/javascript", + "exec": [""] + } + }, + { + "listen": "test", + "script": { + "id": "8d2d4717-6f76-47ab-8e5a-f383192f6ee4", + "type": "text/javascript", + "exec": [ + "const schema = tv4.getSchema('/SignedOrder');", + "const responseJsonData = pm.response.json();", + "", + "pm.test('Schema is valid', function() {", + " pm.expect(tv4.validate(responseJsonData, schema)).to.be.true;", + "});", + "" + ] + } + } + ] + }, + { + "name": "GET /orderbook", + "description": "", + "item": [ + { + "name": "baseTokenAddress and quoteTokenAddress params", + "event": [ + { + "listen": "test", + "script": { + "id": "0198622e-9705-4ae1-b1f2-0c40b87de856", + "type": "text/javascript", + "exec": [ + "const baseTokenEnvKey = 'ZRX_address';", + "const quoteTokenEnvKey = 'WETH_address';", + "const baseTokenAddress = pm.environment.get(baseTokenEnvKey);", + "const quoteTokenAddress = pm.environment.get(quoteTokenEnvKey);", + "const responseJsonData = pm.response.json();", + "pm.test('Orderbook is properly filtered', function() {", + " const bids = _.get(responseJsonData, 'bids');", + " const asks = _.get(responseJsonData, 'asks');", + " _.forEach(bids, function(order) {", + " const makerTokenAddress = _.get(order, 'makerTokenAddress');", + " const takerTokenAddress = _.get(order, 'takerTokenAddress');", + " pm.expect(makerTokenAddress).to.be.equal(quoteTokenAddress);", + " pm.expect(takerTokenAddress).to.be.equal(baseTokenAddress);", + " });", + " _.forEach(asks, function(order) {", + " const makerTokenAddress = _.get(order, 'makerTokenAddress');", + " const takerTokenAddress = _.get(order, 'takerTokenAddress');", + " pm.expect(makerTokenAddress).to.be.equal(baseTokenAddress);", + " pm.expect(takerTokenAddress).to.be.equal(quoteTokenAddress);", + " });", + "});", + "" + ] + } + } + ], + "request": { + "method": "GET", + "header": [], + "body": {}, + "url": { + "raw": + "{{url}}/orderbook?baseTokenAddress={{ZRX_address}}"eTokenAddress={{WETH_address}}", + "host": ["{{url}}"], + "path": ["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": [] + } + ], + "event": [ + { + "listen": "prerequest", + "script": { + "id": "bdf90dbc-9217-4089-8bc0-351baadddd3e", + "type": "text/javascript", + "exec": [""] + } + }, + { + "listen": "test", + "script": { + "id": "d5080a34-57c4-4d5d-8e01-5e79599282ec", + "type": "text/javascript", + "exec": [ + "const schema = tv4.getSchema('/RelayerApiOrderBookResponse');", + "const responseJsonData = pm.response.json();", + "", + "pm.test('Schema is valid', function() {", + " pm.expect(tv4.validate(responseJsonData, schema)).to.be.true;", + "});", + "" + ] + } + } + ] + }, + { + "name": "POST /fees", + "description": "", + "item": [ + { + "name": "default request", + "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}}/fees", + "host": ["{{url}}"], + "path": ["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": "75d66506-0fa9-4b0e-982b-ef53bf3310f8", + "type": "text/javascript", + "exec": [""] + } + }, + { + "listen": "test", + "script": { + "id": "4c5f9f7b-8635-4bdb-9240-a74754a2de4f", + "type": "text/javascript", + "exec": [ + "const schema = tv4.getSchema('/RelayerApiFeesResponse');", + "const responseJsonData = pm.response.json();", + "", + "pm.test('Schema is valid', function() {", + " pm.expect(tv4.validate(responseJsonData, schema)).to.be.true;", + "});", + "" + ] + } + } + ] + } + ], + "event": [ + { + "listen": "prerequest", + "script": { + "id": "da60f639-df79-4f4d-9861-79219f5fc341", + "type": "text/javascript", + "exec": [ + "const schemaKeysString = pm.environment.get('schemaKeys');", + "const schemaKeys = JSON.parse(schemaKeysString);", + "_.forEach(schemaKeys, function(schemaKey) {", + " const schemaString = pm.environment.get(schemaKey);", + " const schema = JSON.parse(schemaString);", + " tv4.addSchema(schema);", + "});", + "" + ] + } + }, + { + "listen": "test", + "script": { + "id": "b4917e72-ac87-421d-b7a5-21b64285ba5b", + "type": "text/javascript", + "exec": [ + "pm.test('Has Content-Type header with value application/json', function () {", + " pm.response.to.have.header('Content-Type');", + " const contentType = postman.getResponseHeader('Content-Type');", + " pm.expect(contentType).to.include('application/json');", + "});", + "" + ] + } + } + ] +} diff --git a/packages/sra-report/src/contract_addresses/kovan_addresses.ts b/packages/sra-report/src/contract_addresses/kovan_addresses.ts index e097bf12a..4d2b76a51 100644 --- a/packages/sra-report/src/contract_addresses/kovan_addresses.ts +++ b/packages/sra-report/src/contract_addresses/kovan_addresses.ts @@ -1,6 +1,6 @@ export const addresses = { - 'DAI_address': '0xb18845c260f680d5b9d84649638813e342e4f8c9', - 'WETH_address': '0xd0a1e359811322d97991e03f863a0c30c2cf029c', - 'ZRX_address': '0x6ff6c0ff1d68b964901f986d4c9fa3ac68346570', - 'EXCHANGE_CONTRACT_address': '0x90fe2af704b34e0224bf2299c838e04d4dcf1364', + DAI_address: '0xb18845c260f680d5b9d84649638813e342e4f8c9', + WETH_address: '0xd0a1e359811322d97991e03f863a0c30c2cf029c', + ZRX_address: '0x6ff6c0ff1d68b964901f986d4c9fa3ac68346570', + EXCHANGE_CONTRACT_address: '0x90fe2af704b34e0224bf2299c838e04d4dcf1364', }; diff --git a/packages/sra-report/src/contract_addresses/mainnet_addresses.ts b/packages/sra-report/src/contract_addresses/mainnet_addresses.ts index cbd79a0e7..4ccbdf12d 100644 --- a/packages/sra-report/src/contract_addresses/mainnet_addresses.ts +++ b/packages/sra-report/src/contract_addresses/mainnet_addresses.ts @@ -1,6 +1,6 @@ export const addresses = { - 'DAI_address': '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359', - 'WETH_address': '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', - 'ZRX_address': '0xe41d2489571d322189246dafa5ebde1f4699f498', - 'EXCHANGE_CONTRACT_address': '0x12459c951127e0c374ff9105dda097662a027093', + DAI_address: '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359', + WETH_address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', + ZRX_address: '0xe41d2489571d322189246dafa5ebde1f4699f498', + EXCHANGE_CONTRACT_address: '0x12459c951127e0c374ff9105dda097662a027093', }; diff --git a/packages/sra-report/src/index.ts b/packages/sra-report/src/index.ts index 37c7a8f04..4419a3ec8 100644 --- a/packages/sra-report/src/index.ts +++ b/packages/sra-report/src/index.ts @@ -52,8 +52,10 @@ const args = yargs normalize: true, demandOption: false, }) - .example("$0 --endpoint-url 'http://api.example.com' --out 'path/to/report.json' --network-id 42 --export-environment 'path/to/environment.json' --export-collection 'path/to/collection.json'", 'Full usage example') - .argv; + .example( + "$0 --endpoint-url 'http://api.example.com' --out 'path/to/report.json' --network-id 42 --export-environment 'path/to/environment.json' --export-collection 'path/to/collection.json'", + 'Full usage example', + ).argv; // perform extra validation on command line arguments try { assert.isWebUri('args', args.endpointUrl); diff --git a/packages/sra-report/src/postman_environment_factory.ts b/packages/sra-report/src/postman_environment_factory.ts index d32d41e18..e4276d4a5 100644 --- a/packages/sra-report/src/postman_environment_factory.ts +++ b/packages/sra-report/src/postman_environment_factory.ts @@ -2,8 +2,8 @@ import { SignedOrder, ZeroEx } from '0x.js'; import { Schema, schemas as schemasByName } from '@0xproject/json-schemas'; import * as _ from 'lodash'; -import { addresses as kovanAddresses} from './contract_addresses/kovan_addresses'; -import { addresses as mainnetAddresses} from './contract_addresses/mainnet_addresses'; +import { addresses as kovanAddresses } from './contract_addresses/kovan_addresses'; +import { addresses as mainnetAddresses } from './contract_addresses/mainnet_addresses'; interface EnvironmentValue { key: string; -- cgit From ddad09a93639f9060db69d131a52ef8dbaf4a3fe Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Tue, 6 Mar 2018 00:44:18 -0800 Subject: Add support for custom environment file --- packages/sra-report/src/index.ts | 21 ++++++++++++--------- .../sra-report/src/postman_environment_factory.ts | 19 +++++++++++++------ 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/packages/sra-report/src/index.ts b/packages/sra-report/src/index.ts index 4419a3ec8..d292f15e1 100644 --- a/packages/sra-report/src/index.ts +++ b/packages/sra-report/src/index.ts @@ -1,6 +1,5 @@ #!/usr/bin/env node import { assert } from '@0xproject/assert'; -import { HttpClient } from '@0xproject/connect'; import { Schema, schemas } from '@0xproject/json-schemas'; import { promisify } from '@0xproject/utils'; import chalk from 'chalk'; @@ -38,6 +37,13 @@ const args = yargs type: 'number', default: DEFAULT_NETWORK_ID, }) + .option('environment', { + alias: ['env'], + describe: 'File path to an environment file for the collection run', + type: 'string', + normalize: true, + demandOption: false, + }) .option('export-collection', { alias: ['ec'], describe: 'The relative path to write the postman collection file used by the collection run', @@ -53,7 +59,7 @@ const args = yargs demandOption: false, }) .example( - "$0 --endpoint-url 'http://api.example.com' --out 'path/to/report.json' --network-id 42 --export-environment 'path/to/environment.json' --export-collection 'path/to/collection.json'", + "$0 --endpoint-url 'http://api.example.com' --out 'path/to/report.json' --network-id 42 --environment 'path/to/custom/environment.json' --export-collection 'path/to/collection.json' --export-environment 'path/to/environment.json'", 'Full usage example', ).argv; // perform extra validation on command line arguments @@ -69,12 +75,6 @@ if (!_.includes(SUPPORTED_NETWORK_IDS, args.networkId)) { process.exit(1); } const mainAsync = async () => { - const httpClient = new HttpClient(args.endpointUrl); - const orders = await httpClient.getOrdersAsync(); - const firstOrder = _.head(orders); - if (_.isUndefined(firstOrder)) { - throw new Error('Could not get any orders from /orders endpoint'); - } const newmanReporterOptions = !_.isUndefined(args.output) ? { reporters: 'json', @@ -87,9 +87,12 @@ const mainAsync = async () => { : { reporters: 'cli', }; + const environment = !_.isUndefined(args.environment) + ? args.environment + : await postmanEnvironmentFactory.createPostmanEnvironmentAsync(args.endpointUrl, args.networkId); const newmanRunOptions = { collection: sraReportCollectionJSON, - environment: postmanEnvironmentFactory.createPostmanEnvironment(args.endpointUrl, args.networkId, firstOrder), + environment, exportCollection: args.exportCollection, exportEnvironment: args.exportEnvironment, ...newmanReporterOptions, diff --git a/packages/sra-report/src/postman_environment_factory.ts b/packages/sra-report/src/postman_environment_factory.ts index e4276d4a5..703132c6a 100644 --- a/packages/sra-report/src/postman_environment_factory.ts +++ b/packages/sra-report/src/postman_environment_factory.ts @@ -1,4 +1,5 @@ import { SignedOrder, ZeroEx } from '0x.js'; +import { HttpClient } from '@0xproject/connect'; import { Schema, schemas as schemasByName } from '@0xproject/json-schemas'; import * as _ from 'lodash'; @@ -18,7 +19,7 @@ export const postmanEnvironmentFactory = { * - Contract addresses based on the network id for making specific queries (ex. baseTokenAddress=ZRX_address) * - Order properties for making specific queries (ex. maker=orderMaker) */ - createPostmanEnvironment(url: string, networkId: number, order: SignedOrder) { + async createPostmanEnvironmentAsync(url: string, networkId: number) { const schemas: Schema[] = _.values(schemasByName); const schemaEnvironmentValues = _.compact( _.map(schemas, (schema: Schema) => { @@ -40,16 +41,22 @@ export const postmanEnvironmentFactory = { const contractAddress = _.get(contractAddresses, key); return createEnvironmentValue(key, contractAddress); }); + const httpClient = new HttpClient(url); + const orders = await httpClient.getOrdersAsync(); + const firstOrder = _.head(orders); + if (_.isUndefined(firstOrder)) { + throw new Error('Could not get any orders from /orders endpoint'); + } const allEnvironmentValues = _.concat( schemaEnvironmentValues, contractAddressEnvironmentValues, createEnvironmentValue('schemaKeys', JSON.stringify(schemaKeys)), createEnvironmentValue('url', url), - createEnvironmentValue('order', JSON.stringify(order)), - createEnvironmentValue('orderMaker', order.maker), - createEnvironmentValue('orderTaker', order.taker), - createEnvironmentValue('orderFeeRecipient', order.feeRecipient), - createEnvironmentValue('orderHash', ZeroEx.getOrderHashHex(order)), + createEnvironmentValue('order', JSON.stringify(firstOrder)), + createEnvironmentValue('orderMaker', firstOrder.maker), + createEnvironmentValue('orderTaker', firstOrder.taker), + createEnvironmentValue('orderFeeRecipient', firstOrder.feeRecipient), + createEnvironmentValue('orderHash', ZeroEx.getOrderHashHex(firstOrder)), ); const environment = { values: allEnvironmentValues, -- cgit From 696f49497b98d3069f1e70d07b4c83414d0bbb99 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Tue, 6 Mar 2018 14:46:32 -0800 Subject: Flesh out README --- packages/sra-report/README.md | 70 ++++++++++++++++++++++++++++++++++------ packages/sra-report/src/index.ts | 2 +- 2 files changed, 62 insertions(+), 10 deletions(-) diff --git a/packages/sra-report/README.md b/packages/sra-report/README.md index 53c007e10..080fa05f2 100644 --- a/packages/sra-report/README.md +++ b/packages/sra-report/README.md @@ -1,25 +1,77 @@ # 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. +This tool allows you to generate reports that detail an endpoint's [standard relayer API HTTP specification](https://github.com/0xProject/standard-relayer-api/blob/master/http/v0.md) compliance. The tool will perform a [Postman collection](https://www.getpostman.com/docs/v6/postman/collections/creating_collections) run and either print a report to the console or save it to disk as a json file. SRA report can also output a Postman collection file and [Postman environment](https://www.getpostman.com/docs/v6/postman/environments_and_globals/manage_environments) file in order to facilitate replication and debugging of collection runs using the [Postman native app](https://www.getpostman.com/docs/v6/postman/launching_postman/installation_and_updates). ## Installation `yarn add -g @0xproject/sra-report` -## Usage +## Options ``` sra-report Options: - --help Show help [boolean] - --version Show version number [boolean] - --endpoint-url, -e API endpoint url 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] + --help Show help [boolean] + --version Show version number [boolean] + --endpoint-url, -e API endpoint url to test for standard relayer API + compliance [string] [required] + --output, -o, --out The relative path to write the report generated by + the collection run, prints to console by default + [string] + --network-id, -n ID of the network that the API is serving orders + from [number] [default: 1] + --environment, --env The relative path to a postman environment file + for the collection run [string] + --export-collection, --ec The relative path to write the postman collection + file used by the collection run [string] + --export-environment, --ee The relative path to write the postman environment + file used by the collection run [string] ``` +## Example Usage + +### Print report to console + +```bash +sra-report --endpoint-url 'http://api.example.com' +``` + +### Save a report to disk + +```bash +sra-report --endpoint-url 'http://api.example.com' --output 'path/to/report.json' +``` + +### Generate report for an endpoint that serves kovan testnet orders + +```bash +sra-report --endpoint-url 'http://kovan.api.example.com' --network-id 42 +``` + +### Write Postman collection and environment files for use in the Postman native app + +```bash +sra-report --endpoint-url 'http://.api.example.com' --export-collection 'path/to/collection.json' --export-environment 'path/to/environment.json' +``` + +### Run the report using a custom environment + +```bash +sra-report --endpoint-url 'http://.api.example.com' --environment 'path/to/custom/environment.json' +``` + +## Custom environments + +When testing your standard relayer API endpoint in development, it may be useful to modify the Postman environment file generated by this tool such that specific query parameters are used during the collection run. For example, by default, this tool will grab the first order it can from the `/orders` endpoint and use properties from that order as query parameters for the rest of the run. Another example is the tool will default to the [WETH](https://etherscan.io/address/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2) and [ZRX](https://etherscan.io/address/0xe41d2489571d322189246dafa5ebde1f4699f498) token contracts when querying some endpoints but you may want to specify these. + +In order to provide a custom environment to the tool, perform the following steps: + +1. Export a Postman environment file using the tool: [example](#Write-Postman-collection-and-environment-files-for-use-in-the-Postman-native-app) +2. Open the Postman environment file using your favorite text editor or in the Postman native app +3. Modify the specific values you want +4. Save the environment file and export it if using the Postman native app +5. Run the tool and supply a path to your modified environment file: [example](#Run-the-report-using-a-custom-environment) + ## 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. diff --git a/packages/sra-report/src/index.ts b/packages/sra-report/src/index.ts index d292f15e1..83fb25d6c 100644 --- a/packages/sra-report/src/index.ts +++ b/packages/sra-report/src/index.ts @@ -39,7 +39,7 @@ const args = yargs }) .option('environment', { alias: ['env'], - describe: 'File path to an environment file for the collection run', + describe: 'The relative path to a postman environment file for the collection run', type: 'string', normalize: true, demandOption: false, -- cgit From 1789025da912aee536f0d9c9cbb66a56492251fc Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Tue, 6 Mar 2018 15:22:56 -0800 Subject: Refactor environment factory and generalize token environment keys --- .../collections/sra_report.postman_collection.json | 73 ++++++++--------- .../src/contract_addresses/kovan_addresses.ts | 7 +- .../src/contract_addresses/mainnet_addresses.ts | 7 +- .../sra-report/src/postman_environment_factory.ts | 91 +++++++++++++--------- 4 files changed, 99 insertions(+), 79 deletions(-) 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 index 04c7bc51f..9a8e8e0fa 100644 --- a/packages/sra-report/postman_configs/collections/sra_report.postman_collection.json +++ b/packages/sra-report/postman_configs/collections/sra_report.postman_collection.json @@ -42,10 +42,10 @@ { "listen": "test", "script": { - "id": "1b61aabb-ef9f-4269-9a0c-cb7559afcbd8", + "id": "0b0712ff-7846-40a3-9253-4bca2551350c", "type": "text/javascript", "exec": [ - "const filterTokenEnvKey = 'WETH_address';", + "const filterTokenEnvKey = 'tokenContractAddress1';", "const filterTokenAddress = pm.environment.get(filterTokenEnvKey);", "const responseJsonData = pm.response.json();", "pm.test('Token pairs are properly filtered', function() {", @@ -66,13 +66,13 @@ "header": [], "body": {}, "url": { - "raw": "{{url}}/token_pairs?tokenA={{WETH_address}}", + "raw": "{{url}}/token_pairs?tokenA={{tokenContractAddress1}}", "host": ["{{url}}"], "path": ["token_pairs"], "query": [ { "key": "tokenA", - "value": "{{WETH_address}}", + "value": "{{tokenContractAddress1}}", "equals": true } ] @@ -87,10 +87,10 @@ { "listen": "test", "script": { - "id": "a5f946b1-fc97-4bcf-ae01-e0f97864a6c1", + "id": "ef0e6be8-06d8-4975-a1c4-2199bc8b5aa6", "type": "text/javascript", "exec": [ - "const filterTokenEnvKey = 'WETH_address';", + "const filterTokenEnvKey = 'tokenContractAddress1';", "const filterTokenAddress = pm.environment.get(filterTokenEnvKey);", "const responseJsonData = pm.response.json();", "pm.test('Token pairs are properly filtered', function() {", @@ -111,13 +111,13 @@ "header": [], "body": {}, "url": { - "raw": "{{url}}/token_pairs?tokenB={{WETH_address}}", + "raw": "{{url}}/token_pairs?tokenB={{tokenContractAddress1}}", "host": ["{{url}}"], "path": ["token_pairs"], "query": [ { "key": "tokenB", - "value": "{{WETH_address}}", + "value": "{{tokenContractAddress1}}", "equals": true } ] @@ -132,11 +132,11 @@ { "listen": "test", "script": { - "id": "bcd06e4f-aa3a-42f8-9f8c-bc902eb7a075", + "id": "9ca4bed3-b8e0-4a90-96ba-42f0da3a7d68", "type": "text/javascript", "exec": [ - "const filterTokenAEnvKey = 'WETH_address';", - "const filterTokenBEnvKey = 'ZRX_address';", + "const filterTokenAEnvKey = 'tokenContractAddress1';", + "const filterTokenBEnvKey = 'tokenContractAddress2';", "const filterTokenAAddress = pm.environment.get(filterTokenAEnvKey);", "const filterTokenBAddress = pm.environment.get(filterTokenBEnvKey);", "const responseJsonData = pm.response.json();", @@ -160,18 +160,19 @@ "header": [], "body": {}, "url": { - "raw": "{{url}}/token_pairs?tokenA={{WETH_address}}&tokenB={{ZRX_address}}", + "raw": + "{{url}}/token_pairs?tokenA={{tokenContractAddress1}}&tokenB={{tokenContractAddress2}}", "host": ["{{url}}"], "path": ["token_pairs"], "query": [ { "key": "tokenA", - "value": "{{WETH_address}}", + "value": "{{tokenContractAddress1}}", "equals": true }, { "key": "tokenB", - "value": "{{ZRX_address}}", + "value": "{{tokenContractAddress2}}", "equals": true } ] @@ -244,10 +245,10 @@ { "listen": "test", "script": { - "id": "e782ae77-66bf-4096-9190-ef9e7501b316", + "id": "374c4b28-5672-400c-8c23-9cb1a3e63117", "type": "text/javascript", "exec": [ - "const exchangeContractEnvKey = 'EXCHANGE_CONTRACT_address';", + "const exchangeContractEnvKey = 'exchangeContractAddress';", "const requestedExchangeContractAddress = pm.environment.get(exchangeContractEnvKey);", "const responseJsonData = pm.response.json();", "pm.test('Orders are properly filtered', function() {", @@ -266,13 +267,13 @@ "header": [], "body": {}, "url": { - "raw": "{{url}}/orders?exchangeContractAddress={{EXCHANGE_CONTRACT_address}}", + "raw": "{{url}}/orders?exchangeContractAddress={{exchangeContractAddress}}", "host": ["{{url}}"], "path": ["orders"], "query": [ { "key": "exchangeContractAddress", - "value": "{{EXCHANGE_CONTRACT_address}}", + "value": "{{exchangeContractAddress}}", "equals": true } ] @@ -288,10 +289,10 @@ { "listen": "test", "script": { - "id": "1144a2d6-6175-40a6-8568-d0d3884492a1", + "id": "e74a9069-18b9-42d3-b2d0-e18580ad73f2", "type": "text/javascript", "exec": [ - "const filterTokenEnvKey = 'ZRX_address';", + "const filterTokenEnvKey = 'tokenContractAddress2';", "const filterTokenAddress = pm.environment.get(filterTokenEnvKey);", "const responseJsonData = pm.response.json();", "pm.test('Orders are properly filtered', function() {", @@ -314,13 +315,13 @@ "header": [], "body": {}, "url": { - "raw": "{{url}}/orders?tokenAddress={{ZRX_address}}", + "raw": "{{url}}/orders?tokenAddress={{tokenContractAddress2}}", "host": ["{{url}}"], "path": ["orders"], "query": [ { "key": "tokenAddress", - "value": "{{ZRX_address}}", + "value": "{{tokenContractAddress2}}", "equals": true } ] @@ -336,10 +337,10 @@ { "listen": "test", "script": { - "id": "01eb5865-edec-4216-8a90-c36d790366fc", + "id": "c539f306-aa03-495d-a90a-0179e1b751aa", "type": "text/javascript", "exec": [ - "const filterTokenEnvKey = 'ZRX_address';", + "const filterTokenEnvKey = 'tokenContractAddress2';", "const filterTokenAddress = pm.environment.get(filterTokenEnvKey);", "const responseJsonData = pm.response.json();", "pm.test('Orders are properly filtered', function() {", @@ -358,13 +359,13 @@ "header": [], "body": {}, "url": { - "raw": "{{url}}/orders?makerTokenAddress={{ZRX_address}}", + "raw": "{{url}}/orders?makerTokenAddress={{tokenContractAddress2}}", "host": ["{{url}}"], "path": ["orders"], "query": [ { "key": "makerTokenAddress", - "value": "{{ZRX_address}}", + "value": "{{tokenContractAddress2}}", "equals": true } ] @@ -380,10 +381,10 @@ { "listen": "test", "script": { - "id": "bbbb6e15-60c7-4666-96be-a0ad56b6058b", + "id": "49b2fcaf-5fe2-471f-ae10-e48a440d4c6d", "type": "text/javascript", "exec": [ - "const filterTokenEnvKey = 'ZRX_address';", + "const filterTokenEnvKey = 'tokenContractAddress2';", "const filterTokenAddress = pm.environment.get(filterTokenEnvKey);", "const responseJsonData = pm.response.json();", "pm.test('Orders are properly filtered', function() {", @@ -402,13 +403,13 @@ "header": [], "body": {}, "url": { - "raw": "{{url}}/orders?takerTokenAddress={{ZRX_address}}", + "raw": "{{url}}/orders?takerTokenAddress={{tokenContractAddress2}}", "host": ["{{url}}"], "path": ["orders"], "query": [ { "key": "takerTokenAddress", - "value": "{{ZRX_address}}", + "value": "{{tokenContractAddress2}}", "equals": true } ] @@ -730,11 +731,11 @@ { "listen": "test", "script": { - "id": "0198622e-9705-4ae1-b1f2-0c40b87de856", + "id": "9ed05327-1a2f-4e50-b4aa-e21f961dbe78", "type": "text/javascript", "exec": [ - "const baseTokenEnvKey = 'ZRX_address';", - "const quoteTokenEnvKey = 'WETH_address';", + "const baseTokenEnvKey = 'tokenContractAddress2';", + "const quoteTokenEnvKey = 'tokenContractAddress1';", "const baseTokenAddress = pm.environment.get(baseTokenEnvKey);", "const quoteTokenAddress = pm.environment.get(quoteTokenEnvKey);", "const responseJsonData = pm.response.json();", @@ -765,18 +766,18 @@ "body": {}, "url": { "raw": - "{{url}}/orderbook?baseTokenAddress={{ZRX_address}}"eTokenAddress={{WETH_address}}", + "{{url}}/orderbook?baseTokenAddress={{tokenContractAddress2}}"eTokenAddress={{tokenContractAddress1}}", "host": ["{{url}}"], "path": ["orderbook"], "query": [ { "key": "baseTokenAddress", - "value": "{{ZRX_address}}", + "value": "{{tokenContractAddress2}}", "equals": true }, { "key": "quoteTokenAddress", - "value": "{{WETH_address}}", + "value": "{{tokenContractAddress1}}", "equals": true } ] diff --git a/packages/sra-report/src/contract_addresses/kovan_addresses.ts b/packages/sra-report/src/contract_addresses/kovan_addresses.ts index 4d2b76a51..e06568f52 100644 --- a/packages/sra-report/src/contract_addresses/kovan_addresses.ts +++ b/packages/sra-report/src/contract_addresses/kovan_addresses.ts @@ -1,6 +1,5 @@ export const addresses = { - DAI_address: '0xb18845c260f680d5b9d84649638813e342e4f8c9', - WETH_address: '0xd0a1e359811322d97991e03f863a0c30c2cf029c', - ZRX_address: '0x6ff6c0ff1d68b964901f986d4c9fa3ac68346570', - EXCHANGE_CONTRACT_address: '0x90fe2af704b34e0224bf2299c838e04d4dcf1364', + WETH: '0xd0a1e359811322d97991e03f863a0c30c2cf029c', + ZRX: '0x6ff6c0ff1d68b964901f986d4c9fa3ac68346570', + EXCHANGE: '0x90fe2af704b34e0224bf2299c838e04d4dcf1364', }; diff --git a/packages/sra-report/src/contract_addresses/mainnet_addresses.ts b/packages/sra-report/src/contract_addresses/mainnet_addresses.ts index 4ccbdf12d..e9aa0f167 100644 --- a/packages/sra-report/src/contract_addresses/mainnet_addresses.ts +++ b/packages/sra-report/src/contract_addresses/mainnet_addresses.ts @@ -1,6 +1,5 @@ export const addresses = { - DAI_address: '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359', - WETH_address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', - ZRX_address: '0xe41d2489571d322189246dafa5ebde1f4699f498', - EXCHANGE_CONTRACT_address: '0x12459c951127e0c374ff9105dda097662a027093', + WETH: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', + ZRX: '0xe41d2489571d322189246dafa5ebde1f4699f498', + EXCHANGE: '0x12459c951127e0c374ff9105dda097662a027093', }; diff --git a/packages/sra-report/src/postman_environment_factory.ts b/packages/sra-report/src/postman_environment_factory.ts index 703132c6a..91fbb5d2c 100644 --- a/packages/sra-report/src/postman_environment_factory.ts +++ b/packages/sra-report/src/postman_environment_factory.ts @@ -20,43 +20,12 @@ export const postmanEnvironmentFactory = { * - Order properties for making specific queries (ex. maker=orderMaker) */ async createPostmanEnvironmentAsync(url: string, networkId: number) { - const schemas: Schema[] = _.values(schemasByName); - const schemaEnvironmentValues = _.compact( - _.map(schemas, (schema: Schema) => { - if (_.isUndefined(schema.id)) { - return undefined; - } else { - const schemaKey = convertSchemaIdToKey(schema.id); - const stringifiedSchema = JSON.stringify(schema); - const schemaEnvironmentValue = createEnvironmentValue(schemaKey, stringifiedSchema); - return schemaEnvironmentValue; - } - }), - ); - const schemaKeys = _.map(schemaEnvironmentValues, (environmentValue: EnvironmentValue) => { - return environmentValue.key; - }); - const contractAddresses = getContractAddresses(networkId); - const contractAddressEnvironmentValues = _.map(_.keys(contractAddresses), (key: string) => { - const contractAddress = _.get(contractAddresses, key); - return createEnvironmentValue(key, contractAddress); - }); - const httpClient = new HttpClient(url); - const orders = await httpClient.getOrdersAsync(); - const firstOrder = _.head(orders); - if (_.isUndefined(firstOrder)) { - throw new Error('Could not get any orders from /orders endpoint'); - } + const orderEnvironmentValues = await createOrderEnvironmentValuesAsync(url); const allEnvironmentValues = _.concat( - schemaEnvironmentValues, - contractAddressEnvironmentValues, - createEnvironmentValue('schemaKeys', JSON.stringify(schemaKeys)), + createSchemaEnvironmentValues(), + createContractAddressEnvironmentValues(networkId), + orderEnvironmentValues, createEnvironmentValue('url', url), - createEnvironmentValue('order', JSON.stringify(firstOrder)), - createEnvironmentValue('orderMaker', firstOrder.maker), - createEnvironmentValue('orderTaker', firstOrder.taker), - createEnvironmentValue('orderFeeRecipient', firstOrder.feeRecipient), - createEnvironmentValue('orderHash', ZeroEx.getOrderHashHex(firstOrder)), ); const environment = { values: allEnvironmentValues, @@ -64,6 +33,58 @@ export const postmanEnvironmentFactory = { return environment; }, }; +function createSchemaEnvironmentValues() { + const schemas: Schema[] = _.values(schemasByName); + const schemaEnvironmentValues = _.compact( + _.map(schemas, (schema: Schema) => { + if (_.isUndefined(schema.id)) { + return undefined; + } else { + const schemaKey = convertSchemaIdToKey(schema.id); + const stringifiedSchema = JSON.stringify(schema); + const schemaEnvironmentValue = createEnvironmentValue(schemaKey, stringifiedSchema); + return schemaEnvironmentValue; + } + }), + ); + const schemaKeys = _.map(schemaEnvironmentValues, (environmentValue: EnvironmentValue) => { + return environmentValue.key; + }); + const result = _.concat(schemaEnvironmentValues, createEnvironmentValue('schemaKeys', JSON.stringify(schemaKeys))); + return result; +} +function createContractAddressEnvironmentValues(networkId: number) { + const contractAddresses = getContractAddresses(networkId); + return [ + createEnvironmentValue('tokenContractAddress1', contractAddresses.WETH), + createEnvironmentValue('tokenContractAddress2', contractAddresses.ZRX), + createEnvironmentValue('exchangeContractAddress', contractAddresses.EXCHANGE), + ]; +} + +async function createOrderEnvironmentValuesAsync(url: string) { + const httpClient = new HttpClient(url); + const orders = await httpClient.getOrdersAsync(); + const orderIfExists = _.head(orders); + if (!_.isUndefined(orderIfExists)) { + return [ + createEnvironmentValue('order', JSON.stringify(orderIfExists)), + createEnvironmentValue('orderMaker', orderIfExists.maker), + createEnvironmentValue('orderTaker', orderIfExists.taker), + createEnvironmentValue('orderFeeRecipient', orderIfExists.feeRecipient), + createEnvironmentValue('orderHash', ZeroEx.getOrderHashHex(orderIfExists)), + ]; + } else { + return [ + createEnvironmentValue('order', ''), + createEnvironmentValue('orderMaker', ''), + createEnvironmentValue('orderTaker', ''), + createEnvironmentValue('orderFeeRecipient', ''), + createEnvironmentValue('orderHash', ''), + ]; + } +} + function getContractAddresses(networkId: number) { switch (networkId) { case 1: -- cgit From d39af6c9eb71501ec3a41bf12a3b0bb5d336ce46 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Tue, 6 Mar 2018 15:34:32 -0800 Subject: Print error message when no orders are found from /orders --- packages/sra-report/src/postman_environment_factory.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/sra-report/src/postman_environment_factory.ts b/packages/sra-report/src/postman_environment_factory.ts index 91fbb5d2c..066e9ac04 100644 --- a/packages/sra-report/src/postman_environment_factory.ts +++ b/packages/sra-report/src/postman_environment_factory.ts @@ -1,10 +1,12 @@ import { SignedOrder, ZeroEx } from '0x.js'; import { HttpClient } from '@0xproject/connect'; import { Schema, schemas as schemasByName } from '@0xproject/json-schemas'; +import chalk from 'chalk'; import * as _ from 'lodash'; import { addresses as kovanAddresses } from './contract_addresses/kovan_addresses'; import { addresses as mainnetAddresses } from './contract_addresses/mainnet_addresses'; +import { utils } from './utils'; interface EnvironmentValue { key: string; @@ -61,7 +63,6 @@ function createContractAddressEnvironmentValues(networkId: number) { createEnvironmentValue('exchangeContractAddress', contractAddresses.EXCHANGE), ]; } - async function createOrderEnvironmentValuesAsync(url: string) { const httpClient = new HttpClient(url); const orders = await httpClient.getOrdersAsync(); @@ -75,6 +76,7 @@ async function createOrderEnvironmentValuesAsync(url: string) { createEnvironmentValue('orderHash', ZeroEx.getOrderHashHex(orderIfExists)), ]; } else { + utils.log(`${chalk.red(`No orders from /orders found`)}`); return [ createEnvironmentValue('order', ''), createEnvironmentValue('orderMaker', ''), -- cgit From 5a670683487584a09382c1ebf9d6a16d7db98e6a Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Tue, 6 Mar 2018 15:39:38 -0800 Subject: Random fixes --- packages/sra-report/scripts/postpublish.js | 2 +- packages/sra-report/src/postman_environment_factory.ts | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/sra-report/scripts/postpublish.js b/packages/sra-report/scripts/postpublish.js index b3e5407c8..639656c7e 100644 --- a/packages/sra-report/scripts/postpublish.js +++ b/packages/sra-report/scripts/postpublish.js @@ -2,4 +2,4 @@ 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 +postpublish_utils.standardPostPublishAsync(subPackageName); diff --git a/packages/sra-report/src/postman_environment_factory.ts b/packages/sra-report/src/postman_environment_factory.ts index 066e9ac04..13991b894 100644 --- a/packages/sra-report/src/postman_environment_factory.ts +++ b/packages/sra-report/src/postman_environment_factory.ts @@ -86,7 +86,6 @@ async function createOrderEnvironmentValuesAsync(url: string) { ]; } } - function getContractAddresses(networkId: number) { switch (networkId) { case 1: -- cgit From 2ff485d2e074d45c31924df1925fe24f6a2b6b5f Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Tue, 6 Mar 2018 16:25:51 -0800 Subject: Add relevant newman typings --- packages/sra-report/src/globals.d.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/sra-report/src/globals.d.ts b/packages/sra-report/src/globals.d.ts index eb09d3fcf..a35aa2036 100644 --- a/packages/sra-report/src/globals.d.ts +++ b/packages/sra-report/src/globals.d.ts @@ -1,4 +1,6 @@ -declare module 'newman'; +declare module 'newman' { + export function run(options: any, callback?: () => void): void; +} declare module '*.json' { const value: any; -- cgit From 6288a720366b30a3969b9087bd3811026896a043 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Tue, 6 Mar 2018 23:55:58 -0800 Subject: Add name to environment --- packages/sra-report/src/postman_environment_factory.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/sra-report/src/postman_environment_factory.ts b/packages/sra-report/src/postman_environment_factory.ts index 13991b894..f4094315e 100644 --- a/packages/sra-report/src/postman_environment_factory.ts +++ b/packages/sra-report/src/postman_environment_factory.ts @@ -8,6 +8,8 @@ import { addresses as kovanAddresses } from './contract_addresses/kovan_addresse import { addresses as mainnetAddresses } from './contract_addresses/mainnet_addresses'; import { utils } from './utils'; +const ENVIRONMENT_NAME = 'SRA Report'; + interface EnvironmentValue { key: string; } @@ -30,6 +32,7 @@ export const postmanEnvironmentFactory = { createEnvironmentValue('url', url), ); const environment = { + name: ENVIRONMENT_NAME, values: allEnvironmentValues, }; return environment; -- cgit From f61b59fa89dbb957c388c9034721c34bcf8ae7df Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Wed, 7 Mar 2018 00:17:39 -0800 Subject: Disable completed docs linting for globals --- packages/sra-report/src/globals.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/sra-report/src/globals.d.ts b/packages/sra-report/src/globals.d.ts index a35aa2036..0d3beb446 100644 --- a/packages/sra-report/src/globals.d.ts +++ b/packages/sra-report/src/globals.d.ts @@ -1,4 +1,5 @@ declare module 'newman' { + // tslint:disable-next-line:completed-docs export function run(options: any, callback?: () => void): void; } -- cgit From 5b5037a844f49c17deeaf695fc8ed57832038da6 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 8 Mar 2018 13:07:19 +0100 Subject: Add publish config to package.json --- packages/sra-report/package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/sra-report/package.json b/packages/sra-report/package.json index 22297e12e..c248cff30 100644 --- a/packages/sra-report/package.json +++ b/packages/sra-report/package.json @@ -41,5 +41,8 @@ "shx": "^0.2.2", "tslint": "5.8.0", "typescript": "2.7.1" + }, + "publishConfig": { + "access": "public" } } -- cgit From 29abc5e921a0eb78234759ca9ec2a72b5e35160e Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Thu, 8 Mar 2018 08:43:53 -0800 Subject: Fix yarn.lock --- yarn.lock | 143 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 139 insertions(+), 4 deletions(-) diff --git a/yarn.lock b/yarn.lock index 5f339d29e..88532729b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,6 +2,10 @@ # yarn lockfile v1 +"8fold-marked@0.3.9": + version "0.3.9" + resolved "https://registry.yarnpkg.com/8fold-marked/-/8fold-marked-0.3.9.tgz#bb89c645612f8ccfaffac1ca6e3c11f168c9cf59" + "@ledgerhq/hw-app-eth@^4.3.0": version "4.3.0" resolved "https://registry.yarnpkg.com/@ledgerhq/hw-app-eth/-/hw-app-eth-4.3.0.tgz#5f365a3560cd78e8cd711737ec56249390cbf5e5" @@ -657,6 +661,12 @@ async-limiter@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.0.tgz#78faed8c3d074ab81f22b4e985d79e8738f720f8" +async@2.6.0, async@^2.0.1, async@^2.1.2, async@^2.4.0, async@^2.5.0: + version "2.6.0" + resolved "https://registry.yarnpkg.com/async/-/async-2.6.0.tgz#61a29abb6fcc026fea77e56d1c6ec53a795951f4" + dependencies: + lodash "^4.14.0" + async@^0.9.0: version "0.9.2" resolved "https://registry.yarnpkg.com/async/-/async-0.9.2.tgz#aea74d5e61c1f899613bf64bda66d4c78f2fd17d" @@ -2054,14 +2064,18 @@ commander@2.11.0: version "2.11.0" resolved "https://registry.yarnpkg.com/commander/-/commander-2.11.0.tgz#157152fd1e7a6c8d98a5b715cf376df928004563" -commander@^2.12.1: - version "2.14.1" - resolved "https://registry.yarnpkg.com/commander/-/commander-2.14.1.tgz#2235123e37af8ca3c65df45b026dbd357b01b9aa" +commander@2.12.2: + version "2.12.2" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.12.2.tgz#0f5946c427ed9ec0d91a46bb9def53e54650e555" -commander@^2.9.0: +commander@2.13.0, commander@^2.9.0: version "2.13.0" resolved "https://registry.yarnpkg.com/commander/-/commander-2.13.0.tgz#6964bca67685df7c1f1430c584f07d7597885b9c" +commander@^2.12.1: + version "2.14.1" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.14.1.tgz#2235123e37af8ca3c65df45b026dbd357b01b9aa" + commondir@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b" @@ -3428,6 +3442,10 @@ eventemitter3@1.x.x: version "1.2.0" resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-1.2.0.tgz#1c86991d816ad1e504750e73874224ecf3bec508" +eventemitter3@3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-3.0.0.tgz#fc29ecf233bd19fbd527bb4089bbf665dc90c1e3" + events@^1.0.0, events@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/events/-/events-1.1.1.tgz#9ebdb7635ad099c70dcc4c2a1f5004288e8bd924" @@ -6388,6 +6406,12 @@ node-libs-browser@^2.0.0: util "^0.10.3" vm-browserify "0.0.4" +node-oauth1@1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/node-oauth1/-/node-oauth1-1.2.2.tgz#fffb2813a88c2770711332ad0e5487b4927644a4" + dependencies: + crypto-js "3.1.9-1" + node-pre-gyp@^0.6.39: version "0.6.39" resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.6.39.tgz#c00e96860b23c0e1420ac7befc5044e1d78d8649" @@ -7277,6 +7301,117 @@ postcss@^6.0.1: source-map "^0.6.1" supports-color "^5.1.0" +postman-collection-transformer@2.5.4: + version "2.5.4" + resolved "https://registry.yarnpkg.com/postman-collection-transformer/-/postman-collection-transformer-2.5.4.tgz#4e715a9913340621a9fc0e9a5a0373b22e9a9d9a" + dependencies: + commander "2.12.2" + inherits "2.0.3" + intel "1.2.0" + lodash "4.17.4" + semver "5.4.1" + strip-json-comments "2.0.1" + +postman-collection@3.0.6: + version "3.0.6" + resolved "https://registry.yarnpkg.com/postman-collection/-/postman-collection-3.0.6.tgz#3bc2307158a783964a473cac82f20d26ffdf5500" + dependencies: + "8fold-marked" "0.3.9" + escape-html "1.0.3" + file-type "3.9.0" + http-reasons "0.1.0" + iconv-lite "0.4.19" + liquid-json "0.3.1" + lodash "4.17.4" + mime-format "2.0.0" + mime-types "2.1.17" + postman-url-encoder "1.0.1" + sanitize-html "1.15.0" + semver "5.4.1" + uuid "3.1.0" + +postman-collection@3.0.7: + version "3.0.7" + resolved "https://registry.yarnpkg.com/postman-collection/-/postman-collection-3.0.7.tgz#699496583ff61443da8a4e0314e58ee6d10442a3" + dependencies: + "8fold-marked" "0.3.9" + escape-html "1.0.3" + file-type "3.9.0" + http-reasons "0.1.0" + iconv-lite "0.4.19" + liquid-json "0.3.1" + lodash "4.17.4" + mime-format "2.0.0" + mime-types "2.1.17" + postman-url-encoder "1.0.1" + sanitize-html "1.15.0" + semver "5.4.1" + uuid "3.1.0" + +postman-request@2.81.1-postman.4: + version "2.81.1-postman.4" + resolved "https://registry.yarnpkg.com/postman-request/-/postman-request-2.81.1-postman.4.tgz#be8f60541539da13739d77b670b9fca6f1aecf83" + dependencies: + aws-sign2 "~0.7.0" + aws4 "^1.2.1" + caseless "~0.12.0" + combined-stream "~1.0.5" + extend "~3.0.0" + forever-agent "~0.6.1" + form-data "~2.1.1" + har-validator "~5.0.2" + hawk "~3.1.3" + http-signature "~1.1.0" + is-typedarray "~1.0.0" + isstream "~0.1.2" + json-stringify-safe "~5.0.1" + mime-types "~2.1.7" + oauth-sign "~0.8.1" + performance-now "^0.2.0" + postman-url-encoder "1.0.1" + qs "~6.4.0" + safe-buffer "^5.0.1" + stream-length "^1.0.2" + stringstream "~0.0.4" + tough-cookie "~2.3.3" + tunnel-agent "^0.6.0" + uuid "^3.0.0" + +postman-runtime@7.1.3: + version "7.1.3" + resolved "https://registry.yarnpkg.com/postman-runtime/-/postman-runtime-7.1.3.tgz#e0c5dfc40dd7d39a2f71519705c97afde35d6f8c" + dependencies: + async "2.6.0" + aws4 "1.6.0" + btoa "1.1.2" + crypto-js "3.1.9-1" + eventemitter3 "3.0.0" + hawk "3.1.3" + http-reasons "0.1.0" + httpntlm "1.7.5" + inherits "2.0.3" + lodash "4.17.4" + node-oauth1 "1.2.2" + postman-collection "3.0.6" + postman-request "2.81.1-postman.4" + postman-sandbox "3.0.4" + resolve-from "4.0.0" + serialised-error "1.1.2" + uuid "3.1.0" + +postman-sandbox@3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/postman-sandbox/-/postman-sandbox-3.0.4.tgz#d011b50d3ec8a8075405d219e1659dbdec354997" + dependencies: + inherits "2.0.3" + lodash "4.17.4" + uuid "3.1.0" + uvm "1.7.0" + +postman-url-encoder@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/postman-url-encoder/-/postman-url-encoder-1.0.1.tgz#a094a42e9415ff0bbfdce0eaa8e6011d449ee83c" + prebuild-install@^2.2.2: version "2.5.1" resolved "https://registry.yarnpkg.com/prebuild-install/-/prebuild-install-2.5.1.tgz#0f234140a73760813657c413cdccdda58296b1da" -- cgit From caf1a22084e9b633f903c493841129c43b8b598b Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Thu, 8 Mar 2018 08:24:37 -0800 Subject: Add support for ropsten and rinkeby --- packages/sra-report/src/contract_addresses/rinkeby_addresses.ts | 5 +++++ packages/sra-report/src/contract_addresses/ropsten_addresses.ts | 5 +++++ packages/sra-report/src/index.ts | 2 +- packages/sra-report/src/postman_environment_factory.ts | 6 ++++++ 4 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 packages/sra-report/src/contract_addresses/rinkeby_addresses.ts create mode 100644 packages/sra-report/src/contract_addresses/ropsten_addresses.ts diff --git a/packages/sra-report/src/contract_addresses/rinkeby_addresses.ts b/packages/sra-report/src/contract_addresses/rinkeby_addresses.ts new file mode 100644 index 000000000..b1e0848d0 --- /dev/null +++ b/packages/sra-report/src/contract_addresses/rinkeby_addresses.ts @@ -0,0 +1,5 @@ +export const addresses = { + WETH: '0xc778417e063141139fce010982780140aa0cd5ab', + ZRX: '0x00f58d6d585f84b2d7267940cede30ce2fe6eae8', + EXCHANGE: '0x1d16ef40fac01cec8adac2ac49427b9384192c05', +}; diff --git a/packages/sra-report/src/contract_addresses/ropsten_addresses.ts b/packages/sra-report/src/contract_addresses/ropsten_addresses.ts new file mode 100644 index 000000000..80e6e5e7e --- /dev/null +++ b/packages/sra-report/src/contract_addresses/ropsten_addresses.ts @@ -0,0 +1,5 @@ +export const addresses = { + WETH: '0xc778417e063141139fce010982780140aa0cd5ab', + ZRX: '0xa8e9fa8f91e5ae138c74648c9c304f1c75003a8d', + EXCHANGE: '0x479cc461fecd078f766ecc58533d6f69580cf3ac', +}; diff --git a/packages/sra-report/src/index.ts b/packages/sra-report/src/index.ts index 83fb25d6c..d23549916 100644 --- a/packages/sra-report/src/index.ts +++ b/packages/sra-report/src/index.ts @@ -14,7 +14,7 @@ import { utils } from './utils'; const newmanRunAsync = promisify(newman.run); const DEFAULT_NETWORK_ID = 1; -const SUPPORTED_NETWORK_IDS = [1, 42]; +const SUPPORTED_NETWORK_IDS = [1, 3, 4, 42]; // extract command line arguments const args = yargs diff --git a/packages/sra-report/src/postman_environment_factory.ts b/packages/sra-report/src/postman_environment_factory.ts index f4094315e..ffac7ac2e 100644 --- a/packages/sra-report/src/postman_environment_factory.ts +++ b/packages/sra-report/src/postman_environment_factory.ts @@ -6,6 +6,8 @@ import * as _ from 'lodash'; import { addresses as kovanAddresses } from './contract_addresses/kovan_addresses'; import { addresses as mainnetAddresses } from './contract_addresses/mainnet_addresses'; +import { addresses as rinkebyAddresses } from './contract_addresses/rinkeby_addresses'; +import { addresses as ropstenAddresses } from './contract_addresses/ropsten_addresses'; import { utils } from './utils'; const ENVIRONMENT_NAME = 'SRA Report'; @@ -93,6 +95,10 @@ function getContractAddresses(networkId: number) { switch (networkId) { case 1: return mainnetAddresses; + case 3: + return ropstenAddresses; + case 4: + return rinkebyAddresses; case 42: return kovanAddresses; default: -- cgit From 583a17d6279e819ab5e37f330500444881e873d7 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Thu, 8 Mar 2018 08:35:25 -0800 Subject: Detail tests in the README --- packages/sra-report/README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/sra-report/README.md b/packages/sra-report/README.md index 080fa05f2..812535f45 100644 --- a/packages/sra-report/README.md +++ b/packages/sra-report/README.md @@ -2,6 +2,19 @@ This tool allows you to generate reports that detail an endpoint's [standard relayer API HTTP specification](https://github.com/0xProject/standard-relayer-api/blob/master/http/v0.md) compliance. The tool will perform a [Postman collection](https://www.getpostman.com/docs/v6/postman/collections/creating_collections) run and either print a report to the console or save it to disk as a json file. SRA report can also output a Postman collection file and [Postman environment](https://www.getpostman.com/docs/v6/postman/environments_and_globals/manage_environments) file in order to facilitate replication and debugging of collection runs using the [Postman native app](https://www.getpostman.com/docs/v6/postman/launching_postman/installation_and_updates). +The tool currently performs the following checks for each endpoint: + +* `application/json` Content-Type header validation +* JSON schema validation +* Correct filtering when a query paramater is provided (ex. when querying for a specific maker address, all orders returned have the same maker address that was provided by the query) + +Features to come: + +* Correct sorting (ex. the `/orderbook` endpoint should return orders in order of price) +* Tests for pagination +* Tests for the `POST /order` endpoint +* Tests for failure cases and errors + ## Installation `yarn add -g @0xproject/sra-report` -- cgit