Remove sra-report
This commit is contained in:
parent
ea65fa4f65
commit
f8876ab60b
@ -94,7 +94,6 @@ jobs:
|
||||
- run: yarn wsrun test:circleci @0xproject/sol-compiler
|
||||
- run: yarn wsrun test:circleci @0xproject/sol-cov
|
||||
- run: yarn wsrun test:circleci @0xproject/sol-doc
|
||||
- run: yarn wsrun test:circleci @0xproject/sra-report
|
||||
- run: yarn wsrun test:circleci @0xproject/subproviders
|
||||
- run: yarn wsrun test:circleci @0xproject/web3-wrapper
|
||||
- run: yarn wsrun test:circleci @0xproject/utils
|
||||
@ -151,10 +150,6 @@ jobs:
|
||||
key: coverage-sol-doc-{{ .Environment.CIRCLE_SHA1 }}
|
||||
paths:
|
||||
- ~/repo/packages/sol-doc/coverage/lcov.info
|
||||
- save_cache:
|
||||
key: coverage-sra-report-{{ .Environment.CIRCLE_SHA1 }}
|
||||
paths:
|
||||
- ~/repo/packages/sra-report/coverage/lcov.info
|
||||
- save_cache:
|
||||
key: coverage-subproviders-{{ .Environment.CIRCLE_SHA1 }}
|
||||
paths:
|
||||
@ -306,9 +301,6 @@ jobs:
|
||||
- restore_cache:
|
||||
keys:
|
||||
- coverage-sol-doc-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- restore_cache:
|
||||
keys:
|
||||
- coverage-sra-report-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- restore_cache:
|
||||
keys:
|
||||
- coverage-subproviders-{{ .Environment.CIRCLE_SHA1 }}
|
||||
|
@ -36,8 +36,7 @@ If you're developing on 0x now or are interested in using 0x infrastructure in t
|
||||
| [`@0xproject/react-shared`](/packages/react-shared) | [](https://www.npmjs.com/package/@0xproject/react-shared) | 0x shared react components |
|
||||
| [`@0xproject/sol-compiler`](/packages/sol-compiler) | [](https://www.npmjs.com/package/@0xproject/sol-compiler) | A thin wrapper around Solc.js that outputs artifacts, resolves imports, only re-compiles when needed, and other niceties. |
|
||||
| [`@0xproject/sol-cov`](/packages/sol-cov) | [](https://www.npmjs.com/package/@0xproject/sol-cov) | Solidity test coverage tool |
|
||||
| [`@0xproject/sra-spec`](/packages/sra-spec) | [](https://www.npmjs.com/package/@0xproject/sra-spec) | OpenAPI specification for the standard relayer API |
|
||||
| [`@0xproject/sra-report`](/packages/sra-report) | [](https://www.npmjs.com/package/@0xproject/sra-report) | Generate reports for standard relayer API compliance |
|
||||
| [`@0xproject/sra-spec`](/packages/sra-spec) | [](https://www.npmjs.com/package/@0xproject/sra-spec) | OpenAPI specification for the standard relayer API | |
|
||||
| [`@0xproject/subproviders`](/packages/subproviders) | [](https://www.npmjs.com/package/@0xproject/subproviders) | Useful web3 subproviders (e.g LedgerSubprovider) |
|
||||
| [`@0xproject/tslint-config`](/packages/tslint-config) | [](https://www.npmjs.com/package/@0xproject/tslint-config) | Custom 0x development TSLint rules |
|
||||
| [`@0xproject/types`](/packages/types) | [](https://www.npmjs.com/package/@0xproject/types) | Shared type declarations |
|
||||
|
@ -12,12 +12,7 @@ import { Package } from './types';
|
||||
import { utils } from './utils/utils';
|
||||
|
||||
// Packages might not be runnable if they are command-line tools or only run in browsers.
|
||||
const UNRUNNABLE_PACKAGES = [
|
||||
'@0xproject/abi-gen',
|
||||
'@0xproject/sra-report',
|
||||
'@0xproject/react-shared',
|
||||
'@0xproject/react-docs',
|
||||
];
|
||||
const UNRUNNABLE_PACKAGES = ['@0xproject/abi-gen', '@0xproject/react-shared', '@0xproject/react-docs'];
|
||||
|
||||
const mkdirpAsync = promisify(mkdirp);
|
||||
const rimrafAsync = promisify(rimraf);
|
||||
|
@ -1,6 +0,0 @@
|
||||
.*
|
||||
yarn-error.log
|
||||
/src/
|
||||
/scripts/
|
||||
tsconfig.json
|
||||
/lib/monorepo_scripts/
|
@ -1,289 +0,0 @@
|
||||
[
|
||||
{
|
||||
"version": "1.0.13",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
],
|
||||
"timestamp": 1538693146
|
||||
},
|
||||
{
|
||||
"timestamp": 1538157789,
|
||||
"version": "1.0.12",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1537907159,
|
||||
"version": "1.0.11",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1537875740,
|
||||
"version": "1.0.10",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1537541580,
|
||||
"version": "1.0.9",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1536142250,
|
||||
"version": "1.0.8",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1535377027,
|
||||
"version": "1.0.7",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1535133899,
|
||||
"version": "1.0.6",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1534210131,
|
||||
"version": "1.0.5",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1532619515,
|
||||
"version": "1.0.4",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1532614997,
|
||||
"version": "1.0.3",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1532605697,
|
||||
"version": "1.0.2",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1532357734,
|
||||
"version": "1.0.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1532043000,
|
||||
"version": "1.0.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1531919263,
|
||||
"version": "0.1.6",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1531149657,
|
||||
"version": "0.1.5",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1529397769,
|
||||
"version": "0.1.4",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1527617805,
|
||||
"version": "0.1.3",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1527617227,
|
||||
"version": "0.1.2",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1527616612,
|
||||
"version": "0.1.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "0.1.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Properly export the executable binary",
|
||||
"pr": 588
|
||||
}
|
||||
],
|
||||
"timestamp": 1527009133
|
||||
},
|
||||
{
|
||||
"timestamp": 1525477860,
|
||||
"version": "0.0.14",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1525453812,
|
||||
"version": "0.0.13",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1525428773,
|
||||
"version": "0.0.12",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1524079658,
|
||||
"version": "0.0.11",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1524073495,
|
||||
"version": "0.0.10",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1524044013,
|
||||
"version": "0.0.9",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1523462196,
|
||||
"version": "0.0.8",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1522673609,
|
||||
"version": "0.0.7",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "0.0.6",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Added postman collection unit tests",
|
||||
"pr": 451
|
||||
}
|
||||
],
|
||||
"timestamp": 1522658513
|
||||
},
|
||||
{
|
||||
"version": "0.0.2",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Consolidate all `console.log` calls into `logUtils` in the `@0xproject/utils` package",
|
||||
"pr": 452
|
||||
}
|
||||
],
|
||||
"timestamp": 1521298800
|
||||
},
|
||||
{
|
||||
"version": "0.0.1",
|
||||
"changes": [],
|
||||
"timestamp": 1520434800
|
||||
}
|
||||
]
|
@ -1,132 +0,0 @@
|
||||
<!--
|
||||
changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly.
|
||||
Edit the package's CHANGELOG.json file only.
|
||||
-->
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v1.0.13 - _October 4, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.12 - _September 28, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.11 - _September 25, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.10 - _September 25, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.9 - _September 21, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.8 - _September 5, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.7 - _August 27, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.6 - _August 24, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.5 - _August 13, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.4 - _July 26, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.3 - _July 26, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.2 - _July 26, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.1 - _July 23, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.0 - _July 19, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.1.6 - _July 18, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.1.5 - _July 9, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.1.4 - _June 19, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.1.3 - _May 29, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.1.2 - _May 29, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.1.1 - _May 29, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.1.0 - _May 22, 2018_
|
||||
|
||||
* Properly export the executable binary (#588)
|
||||
|
||||
## v0.0.14 - _May 4, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.0.13 - _May 4, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.0.12 - _May 4, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.0.11 - _April 18, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.0.10 - _April 18, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.0.9 - _April 18, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.0.8 - _April 11, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.0.7 - _April 2, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.0.6 - _April 2, 2018_
|
||||
|
||||
* Added postman collection unit tests (#451)
|
||||
|
||||
## v0.0.2 - _March 17, 2018_
|
||||
|
||||
* Consolidate all `console.log` calls into `logUtils` in the `@0xproject/utils` package (#452)
|
||||
|
||||
## v0.0.1 - _March 7, 2018_
|
@ -1,138 +0,0 @@
|
||||
# SRA Report
|
||||
|
||||
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`
|
||||
|
||||
## 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 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 welcome improvements and fixes from the wider community! 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
|
||||
|
||||
To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory:
|
||||
|
||||
```bash
|
||||
PKG=@0xproject/sra-report yarn build
|
||||
```
|
||||
|
||||
Or continuously rebuild on change:
|
||||
|
||||
```bash
|
||||
PKG=@0xproject/sra-report yarn watch
|
||||
```
|
||||
|
||||
### Clean
|
||||
|
||||
```bash
|
||||
yarn clean
|
||||
```
|
||||
|
||||
### Lint
|
||||
|
||||
```bash
|
||||
yarn lint
|
||||
```
|
||||
|
||||
### Run Tests
|
||||
|
||||
```bash
|
||||
yarn test
|
||||
```
|
@ -1,2 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
require('../lib/src/index.js')
|
@ -1,73 +0,0 @@
|
||||
{
|
||||
"name": "@0xproject/sra-report",
|
||||
"version": "1.0.13",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
"description": "Generate reports for standard relayer API compliance",
|
||||
"main": "lib/src/index.js",
|
||||
"types": "lib/src/index.d.ts",
|
||||
"scripts": {
|
||||
"clean": "shx rm -rf lib",
|
||||
"build": "tsc -b",
|
||||
"build:ci": "yarn build",
|
||||
"lint": "tslint --project .",
|
||||
"test:circleci": "yarn test:coverage",
|
||||
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
|
||||
"coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info",
|
||||
"test": "run-s copy_test_environments copy_test_fixtures run_mocha",
|
||||
"rebuild_and_test": "run-s clean build test",
|
||||
"copy_test_fixtures": "copyfiles -u 2 './test/fixtures/**/*.json' ./lib/test/fixtures",
|
||||
"copy_test_environments": "copyfiles -u 2 './test/environments/**/*.json' ./lib/test/environments",
|
||||
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js --exit"
|
||||
},
|
||||
"bin": {
|
||||
"sra-report": "bin/sra-report.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/0xProject/0x-monorepo.git"
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"bugs": {
|
||||
"url": "https://github.com/0xProject/0x-monorepo/issues"
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/sra-report/README.md",
|
||||
"dependencies": {
|
||||
"@0xproject/assert": "^1.0.13",
|
||||
"@0xproject/connect": "1.0.4",
|
||||
"@0xproject/json-schemas": "^0.8.3",
|
||||
"@0xproject/order-utils": "^0.0.9",
|
||||
"@0xproject/types": "^0.8.2",
|
||||
"@0xproject/typescript-typings": "^3.0.2",
|
||||
"@0xproject/utils": "^2.0.2",
|
||||
"chalk": "^2.3.0",
|
||||
"lodash": "^4.17.5",
|
||||
"newman": "^3.9.3",
|
||||
"yargs": "^10.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@0xproject/tslint-config": "^1.0.8",
|
||||
"@types/lodash": "4.14.104",
|
||||
"@types/mocha": "^2.2.48",
|
||||
"@types/newman": "^3.9.0",
|
||||
"@types/nock": "^9.1.2",
|
||||
"@types/node": "*",
|
||||
"@types/yargs": "^10.0.0",
|
||||
"chai": "^4.0.1",
|
||||
"chai-as-promised": "^7.1.0",
|
||||
"copyfiles": "^2.0.0",
|
||||
"dirty-chai": "^2.0.1",
|
||||
"make-promises-safe": "^1.1.0",
|
||||
"mocha": "^4.1.0",
|
||||
"nock": "^9.2.3",
|
||||
"npm-run-all": "^4.1.2",
|
||||
"nyc": "^11.0.1",
|
||||
"shx": "^0.2.2",
|
||||
"tslint": "5.11.0",
|
||||
"typescript": "3.0.1"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
}
|
||||
}
|
@ -1,910 +0,0 @@
|
||||
{
|
||||
"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": "0b0712ff-7846-40a3-9253-4bca2551350c",
|
||||
"type": "text/javascript",
|
||||
"exec": [
|
||||
"const filterTokenEnvKey = 'tokenContractAddress1';",
|
||||
"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={{tokenContractAddress1}}",
|
||||
"host": ["{{url}}"],
|
||||
"path": ["token_pairs"],
|
||||
"query": [
|
||||
{
|
||||
"key": "tokenA",
|
||||
"value": "{{tokenContractAddress1}}",
|
||||
"equals": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"description": ""
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "tokenB param",
|
||||
"event": [
|
||||
{
|
||||
"listen": "test",
|
||||
"script": {
|
||||
"id": "ef0e6be8-06d8-4975-a1c4-2199bc8b5aa6",
|
||||
"type": "text/javascript",
|
||||
"exec": [
|
||||
"const filterTokenEnvKey = 'tokenContractAddress1';",
|
||||
"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={{tokenContractAddress1}}",
|
||||
"host": ["{{url}}"],
|
||||
"path": ["token_pairs"],
|
||||
"query": [
|
||||
{
|
||||
"key": "tokenB",
|
||||
"value": "{{tokenContractAddress1}}",
|
||||
"equals": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"description": ""
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "tokenA and tokenB params",
|
||||
"event": [
|
||||
{
|
||||
"listen": "test",
|
||||
"script": {
|
||||
"id": "9ca4bed3-b8e0-4a90-96ba-42f0da3a7d68",
|
||||
"type": "text/javascript",
|
||||
"exec": [
|
||||
"const filterTokenAEnvKey = 'tokenContractAddress1';",
|
||||
"const filterTokenBEnvKey = 'tokenContractAddress2';",
|
||||
"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={{tokenContractAddress1}}&tokenB={{tokenContractAddress2}}",
|
||||
"host": ["{{url}}"],
|
||||
"path": ["token_pairs"],
|
||||
"query": [
|
||||
{
|
||||
"key": "tokenA",
|
||||
"value": "{{tokenContractAddress1}}",
|
||||
"equals": true
|
||||
},
|
||||
{
|
||||
"key": "tokenB",
|
||||
"value": "{{tokenContractAddress2}}",
|
||||
"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": "374c4b28-5672-400c-8c23-9cb1a3e63117",
|
||||
"type": "text/javascript",
|
||||
"exec": [
|
||||
"const exchangeContractEnvKey = 'exchangeContractAddress';",
|
||||
"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={{exchangeContractAddress}}",
|
||||
"host": ["{{url}}"],
|
||||
"path": ["orders"],
|
||||
"query": [
|
||||
{
|
||||
"key": "exchangeContractAddress",
|
||||
"value": "{{exchangeContractAddress}}",
|
||||
"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": "e74a9069-18b9-42d3-b2d0-e18580ad73f2",
|
||||
"type": "text/javascript",
|
||||
"exec": [
|
||||
"const filterTokenEnvKey = 'tokenContractAddress2';",
|
||||
"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={{tokenContractAddress2}}",
|
||||
"host": ["{{url}}"],
|
||||
"path": ["orders"],
|
||||
"query": [
|
||||
{
|
||||
"key": "tokenAddress",
|
||||
"value": "{{tokenContractAddress2}}",
|
||||
"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": "c539f306-aa03-495d-a90a-0179e1b751aa",
|
||||
"type": "text/javascript",
|
||||
"exec": [
|
||||
"const filterTokenEnvKey = 'tokenContractAddress2';",
|
||||
"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={{tokenContractAddress2}}",
|
||||
"host": ["{{url}}"],
|
||||
"path": ["orders"],
|
||||
"query": [
|
||||
{
|
||||
"key": "makerTokenAddress",
|
||||
"value": "{{tokenContractAddress2}}",
|
||||
"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": "49b2fcaf-5fe2-471f-ae10-e48a440d4c6d",
|
||||
"type": "text/javascript",
|
||||
"exec": [
|
||||
"const filterTokenEnvKey = 'tokenContractAddress2';",
|
||||
"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={{tokenContractAddress2}}",
|
||||
"host": ["{{url}}"],
|
||||
"path": ["orders"],
|
||||
"query": [
|
||||
{
|
||||
"key": "takerTokenAddress",
|
||||
"value": "{{tokenContractAddress2}}",
|
||||
"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": "9ed05327-1a2f-4e50-b4aa-e21f961dbe78",
|
||||
"type": "text/javascript",
|
||||
"exec": [
|
||||
"const baseTokenEnvKey = 'tokenContractAddress2';",
|
||||
"const quoteTokenEnvKey = 'tokenContractAddress1';",
|
||||
"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={{tokenContractAddress2}}"eTokenAddress={{tokenContractAddress1}}",
|
||||
"host": ["{{url}}"],
|
||||
"path": ["orderbook"],
|
||||
"query": [
|
||||
{
|
||||
"key": "baseTokenAddress",
|
||||
"value": "{{tokenContractAddress2}}",
|
||||
"equals": true
|
||||
},
|
||||
{
|
||||
"key": "quoteTokenAddress",
|
||||
"value": "{{tokenContractAddress1}}",
|
||||
"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');",
|
||||
"});",
|
||||
""
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
export const addresses = {
|
||||
WETH: '0xd0a1e359811322d97991e03f863a0c30c2cf029c',
|
||||
ZRX: '0x6ff6c0ff1d68b964901f986d4c9fa3ac68346570',
|
||||
EXCHANGE: '0x90fe2af704b34e0224bf2299c838e04d4dcf1364',
|
||||
};
|
@ -1,5 +0,0 @@
|
||||
export const addresses = {
|
||||
WETH: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
||||
ZRX: '0xe41d2489571d322189246dafa5ebde1f4699f498',
|
||||
EXCHANGE: '0x12459c951127e0c374ff9105dda097662a027093',
|
||||
};
|
@ -1,5 +0,0 @@
|
||||
export const addresses = {
|
||||
WETH: '0xc778417e063141139fce010982780140aa0cd5ab',
|
||||
ZRX: '0x00f58d6d585f84b2d7267940cede30ce2fe6eae8',
|
||||
EXCHANGE: '0x1d16ef40fac01cec8adac2ac49427b9384192c05',
|
||||
};
|
@ -1,5 +0,0 @@
|
||||
export const addresses = {
|
||||
WETH: '0xc778417e063141139fce010982780140aa0cd5ab',
|
||||
ZRX: '0xa8e9fa8f91e5ae138c74648c9c304f1c75003a8d',
|
||||
EXCHANGE: '0x479cc461fecd078f766ecc58533d6f69580cf3ac',
|
||||
};
|
4
packages/sra-report/src/globals.d.ts
vendored
4
packages/sra-report/src/globals.d.ts
vendored
@ -1,4 +0,0 @@
|
||||
declare module '*.json' {
|
||||
const value: any;
|
||||
export default value;
|
||||
}
|
@ -1,111 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
import { assert } from '@0xproject/assert';
|
||||
import { logUtils } from '@0xproject/utils';
|
||||
import chalk from 'chalk';
|
||||
import * as _ from 'lodash';
|
||||
import * as yargs from 'yargs';
|
||||
|
||||
import * as sraReportCollectionJSON from '../../postman_collections/sra_report.postman_collection.json';
|
||||
|
||||
import { postmanEnvironmentFactory } from './postman_environment_factory';
|
||||
import { utils } from './utils';
|
||||
|
||||
const DEFAULT_NETWORK_ID = 1;
|
||||
const networkNameToId: { [networkName: string]: number } = {
|
||||
mainnet: 1,
|
||||
ropsten: 3,
|
||||
rinkeby: 4,
|
||||
kovan: 42,
|
||||
};
|
||||
const SUPPORTED_NETWORK_IDS = [
|
||||
networkNameToId.mainnet,
|
||||
networkNameToId.ropsten,
|
||||
networkNameToId.rinkeby,
|
||||
networkNameToId.kovan,
|
||||
];
|
||||
|
||||
// extract command line arguments
|
||||
const args = yargs
|
||||
.option('endpoint-url', {
|
||||
alias: ['e'],
|
||||
describe: 'API endpoint url to test for standard relayer API compliance',
|
||||
type: 'string',
|
||||
demandOption: true,
|
||||
})
|
||||
.option('output', {
|
||||
alias: ['o', 'out'],
|
||||
describe: 'The relative path to write the report generated by the collection run, prints to console by default',
|
||||
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,
|
||||
})
|
||||
.option('environment', {
|
||||
alias: ['env'],
|
||||
describe: 'The relative path to a postman 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',
|
||||
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 --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
|
||||
try {
|
||||
assert.isWebUri('args', args.endpointUrl);
|
||||
} catch (err) {
|
||||
logUtils.log(`${chalk.red(`Invalid url format:`)} ${args.endpointUrl}`);
|
||||
process.exit(1);
|
||||
}
|
||||
if (!_.includes(SUPPORTED_NETWORK_IDS, args.networkId)) {
|
||||
logUtils.log(`${chalk.red(`Unsupported network id:`)} ${args.networkId}`);
|
||||
logUtils.log(`${chalk.bold(`Supported network ids:`)} ${SUPPORTED_NETWORK_IDS}`);
|
||||
process.exit(1);
|
||||
}
|
||||
const mainAsync = async () => {
|
||||
const newmanReporterOptions = !_.isUndefined(args.output)
|
||||
? {
|
||||
reporters: 'json',
|
||||
reporter: {
|
||||
json: {
|
||||
export: args.output,
|
||||
},
|
||||
},
|
||||
}
|
||||
: {
|
||||
reporters: 'cli',
|
||||
};
|
||||
const environment = !_.isUndefined(args.environment)
|
||||
? args.environment
|
||||
: await postmanEnvironmentFactory.createPostmanEnvironmentAsync(args.endpointUrl, args.networkId);
|
||||
const newmanRunOptions = {
|
||||
collection: sraReportCollectionJSON,
|
||||
environment,
|
||||
exportCollection: args.exportCollection,
|
||||
exportEnvironment: args.exportEnvironment,
|
||||
...newmanReporterOptions,
|
||||
};
|
||||
await utils.newmanRunAsync(newmanRunOptions);
|
||||
};
|
||||
|
||||
mainAsync().catch(logUtils.log.bind(logUtils));
|
@ -1,144 +0,0 @@
|
||||
import { HttpClient } from '@0xproject/connect';
|
||||
import { Schema, schemas as schemasByName } from '@0xproject/json-schemas';
|
||||
import { getOrderHashHex } from '@0xproject/order-utils';
|
||||
import { logUtils } from '@0xproject/utils';
|
||||
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 { addresses as rinkebyAddresses } from './contract_addresses/rinkeby_addresses';
|
||||
import { addresses as ropstenAddresses } from './contract_addresses/ropsten_addresses';
|
||||
|
||||
const ENVIRONMENT_NAME = 'SRA Report';
|
||||
const networkNameToId: { [networkName: string]: number } = {
|
||||
mainnet: 1,
|
||||
ropsten: 3,
|
||||
rinkeby: 4,
|
||||
kovan: 42,
|
||||
};
|
||||
|
||||
export interface EnvironmentValue {
|
||||
key: string;
|
||||
value: string;
|
||||
enabled: true;
|
||||
type: 'text';
|
||||
}
|
||||
|
||||
export interface Environment {
|
||||
name: string;
|
||||
values: EnvironmentValue[];
|
||||
}
|
||||
|
||||
export interface Addresses {
|
||||
WETH: string;
|
||||
ZRX: string;
|
||||
EXCHANGE: 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)
|
||||
*/
|
||||
async createPostmanEnvironmentAsync(url: string, networkId: number): Promise<Environment> {
|
||||
const orderEnvironmentValues = await createOrderEnvironmentValuesAsync(url);
|
||||
const allEnvironmentValues = _.concat(
|
||||
createSchemaEnvironmentValues(),
|
||||
createContractAddressEnvironmentValues(networkId),
|
||||
orderEnvironmentValues,
|
||||
createEnvironmentValue('url', url),
|
||||
);
|
||||
const environment = {
|
||||
name: ENVIRONMENT_NAME,
|
||||
values: allEnvironmentValues,
|
||||
};
|
||||
return environment;
|
||||
},
|
||||
};
|
||||
function createSchemaEnvironmentValues(): EnvironmentValue[] {
|
||||
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): EnvironmentValue[] {
|
||||
const contractAddresses = getContractAddresses(networkId);
|
||||
return [
|
||||
createEnvironmentValue('tokenContractAddress1', contractAddresses.WETH),
|
||||
createEnvironmentValue('tokenContractAddress2', contractAddresses.ZRX),
|
||||
createEnvironmentValue('exchangeContractAddress', contractAddresses.EXCHANGE),
|
||||
];
|
||||
}
|
||||
async function createOrderEnvironmentValuesAsync(url: string): Promise<EnvironmentValue[]> {
|
||||
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', getOrderHashHex(orderIfExists)),
|
||||
];
|
||||
} else {
|
||||
logUtils.log(`${chalk.red(`No orders from /orders found`)}`);
|
||||
return [
|
||||
createEnvironmentValue('order', ''),
|
||||
createEnvironmentValue('orderMaker', ''),
|
||||
createEnvironmentValue('orderTaker', ''),
|
||||
createEnvironmentValue('orderFeeRecipient', ''),
|
||||
createEnvironmentValue('orderHash', ''),
|
||||
];
|
||||
}
|
||||
}
|
||||
function getContractAddresses(networkId: number): Addresses {
|
||||
switch (networkId) {
|
||||
case networkNameToId.mainnet:
|
||||
return mainnetAddresses;
|
||||
case networkNameToId.ropsten:
|
||||
return ropstenAddresses;
|
||||
case networkNameToId.rinkeby:
|
||||
return rinkebyAddresses;
|
||||
case networkNameToId.kovan:
|
||||
return kovanAddresses;
|
||||
default:
|
||||
throw new Error('Unsupported network id');
|
||||
}
|
||||
}
|
||||
function convertSchemaIdToKey(schemaId: string): string {
|
||||
let result = schemaId;
|
||||
if (_.startsWith(result, '/')) {
|
||||
result = result.substr(1);
|
||||
}
|
||||
result = `${result}Schema`;
|
||||
return result;
|
||||
}
|
||||
|
||||
function createEnvironmentValue(key: string, value: string): EnvironmentValue {
|
||||
return {
|
||||
key,
|
||||
value,
|
||||
enabled: true,
|
||||
type: 'text',
|
||||
};
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
import { promisify } from '@0xproject/utils';
|
||||
import { NewmanRunSummary, run as newmanRun } from 'newman';
|
||||
|
||||
export const utils = {
|
||||
newmanRunAsync: promisify<NewmanRunSummary>(newmanRun),
|
||||
};
|
@ -1,223 +0,0 @@
|
||||
{
|
||||
"id": "f23e415f-99a8-4d47-8796-6400af77d85f",
|
||||
"name": "SRA Report",
|
||||
"values": [
|
||||
{
|
||||
"type": "any",
|
||||
"value": "{\"id\":\"/Number\",\"type\":\"string\",\"pattern\":\"^\\\\d+(\\\\.\\\\d+)?$\"}",
|
||||
"key": "NumberSchema"
|
||||
},
|
||||
{
|
||||
"type": "any",
|
||||
"value": "{\"id\":\"/Address\",\"type\":\"string\",\"pattern\":\"^0x[0-9a-f]{40}$\"}",
|
||||
"key": "AddressSchema"
|
||||
},
|
||||
{
|
||||
"type": "any",
|
||||
"value":
|
||||
"{\"id\":\"/ECSignature\",\"properties\":{\"v\":{\"type\":\"number\",\"minimum\":27,\"maximum\":28},\"r\":{\"$ref\":\"/ECSignatureParameter\"},\"s\":{\"$ref\":\"/ECSignatureParameter\"}},\"required\":[\"v\",\"r\",\"s\"],\"type\":\"object\"}",
|
||||
"key": "ECSignatureSchema"
|
||||
},
|
||||
{
|
||||
"type": "any",
|
||||
"value": "{\"id\":\"/ECSignatureParameter\",\"type\":\"string\",\"pattern\":\"^0[xX][0-9A-Fa-f]{64}$\"}",
|
||||
"key": "ECSignatureParameterSchema"
|
||||
},
|
||||
{
|
||||
"type": "any",
|
||||
"value":
|
||||
"{\"id\":\"/IndexFilterValues\",\"additionalProperties\":{\"oneOf\":[{\"$ref\":\"/Number\"},{\"$ref\":\"/Address\"},{\"$ref\":\"/OrderHashSchema\"}]},\"type\":\"object\"}",
|
||||
"key": "IndexFilterValuesSchema"
|
||||
},
|
||||
{
|
||||
"type": "any",
|
||||
"value":
|
||||
"{\"id\":\"/OrderCancellationRequests\",\"type\":\"array\",\"items\":{\"properties\":{\"order\":{\"$ref\":\"/Order\"},\"takerTokenCancelAmount\":{\"$ref\":\"/Number\"}},\"required\":[\"order\",\"takerTokenCancelAmount\"],\"type\":\"object\"}}",
|
||||
"key": "OrderCancellationRequestsSchema"
|
||||
},
|
||||
{
|
||||
"type": "any",
|
||||
"value":
|
||||
"{\"id\":\"/OrderFillOrKillRequests\",\"type\":\"array\",\"items\":{\"properties\":{\"signedOrder\":{\"$ref\":\"/SignedOrder\"},\"fillTakerAmount\":{\"$ref\":\"/Number\"}},\"required\":[\"signedOrder\",\"fillTakerAmount\"],\"type\":\"object\"}}",
|
||||
"key": "OrderFillOrKillRequestsSchema"
|
||||
},
|
||||
{
|
||||
"type": "any",
|
||||
"value":
|
||||
"{\"id\":\"/OrderFillRequests\",\"type\":\"array\",\"items\":{\"properties\":{\"signedOrder\":{\"$ref\":\"/SignedOrder\"},\"takerTokenFillAmount\":{\"$ref\":\"/Number\"}},\"required\":[\"signedOrder\",\"takerTokenFillAmount\"],\"type\":\"object\"}}",
|
||||
"key": "OrderFillRequestsSchema"
|
||||
},
|
||||
{
|
||||
"type": "any",
|
||||
"value": "{\"id\":\"/OrderHashSchema\",\"type\":\"string\",\"pattern\":\"^0x[0-9a-fA-F]{64}$\"}",
|
||||
"key": "OrderHashSchemaSchema"
|
||||
},
|
||||
{
|
||||
"type": "any",
|
||||
"value":
|
||||
"{\"id\":\"/Order\",\"properties\":{\"maker\":{\"$ref\":\"/Address\"},\"taker\":{\"$ref\":\"/Address\"},\"makerFee\":{\"$ref\":\"/Number\"},\"takerFee\":{\"$ref\":\"/Number\"},\"makerTokenAmount\":{\"$ref\":\"/Number\"},\"takerTokenAmount\":{\"$ref\":\"/Number\"},\"makerTokenAddress\":{\"$ref\":\"/Address\"},\"takerTokenAddress\":{\"$ref\":\"/Address\"},\"salt\":{\"$ref\":\"/Number\"},\"feeRecipient\":{\"$ref\":\"/Address\"},\"expirationUnixTimestampSec\":{\"$ref\":\"/Number\"},\"exchangeContractAddress\":{\"$ref\":\"/Address\"}},\"required\":[\"maker\",\"taker\",\"makerFee\",\"takerFee\",\"makerTokenAmount\",\"takerTokenAmount\",\"salt\",\"feeRecipient\",\"expirationUnixTimestampSec\",\"exchangeContractAddress\"],\"type\":\"object\"}",
|
||||
"key": "OrderSchema"
|
||||
},
|
||||
{
|
||||
"type": "any",
|
||||
"value":
|
||||
"{\"id\":\"/SignedOrder\",\"allOf\":[{\"$ref\":\"/Order\"},{\"properties\":{\"ecSignature\":{\"$ref\":\"/ECSignature\"}},\"required\":[\"ecSignature\"]}]}",
|
||||
"key": "SignedOrderSchema"
|
||||
},
|
||||
{
|
||||
"type": "any",
|
||||
"value": "{\"id\":\"/signedOrdersSchema\",\"type\":\"array\",\"items\":{\"$ref\":\"/SignedOrder\"}}",
|
||||
"key": "signedOrdersSchemaSchema"
|
||||
},
|
||||
{
|
||||
"type": "any",
|
||||
"value":
|
||||
"{\"id\":\"/BlockParam\",\"oneOf\":[{\"type\":\"number\"},{\"enum\":[\"latest\",\"earliest\",\"pending\"]}]}",
|
||||
"key": "BlockParamSchema"
|
||||
},
|
||||
{
|
||||
"type": "any",
|
||||
"value":
|
||||
"{\"id\":\"/BlockRange\",\"properties\":{\"fromBlock\":{\"$ref\":\"/BlockParam\"},\"toBlock\":{\"$ref\":\"/BlockParam\"}},\"type\":\"object\"}",
|
||||
"key": "BlockRangeSchema"
|
||||
},
|
||||
{
|
||||
"type": "any",
|
||||
"value":
|
||||
"{\"id\":\"/Token\",\"properties\":{\"name\":{\"type\":\"string\"},\"symbol\":{\"type\":\"string\"},\"decimals\":{\"type\":\"number\"},\"address\":{\"$ref\":\"/Address\"}},\"required\":[\"name\",\"symbol\",\"decimals\",\"address\"],\"type\":\"object\"}",
|
||||
"key": "TokenSchema"
|
||||
},
|
||||
{
|
||||
"type": "any",
|
||||
"value": "{\"id\":\"/JsNumber\",\"type\":\"number\",\"minimum\":0}",
|
||||
"key": "JsNumberSchema"
|
||||
},
|
||||
{
|
||||
"type": "any",
|
||||
"value":
|
||||
"{\"id\":\"/TxData\",\"properties\":{\"from\":{\"$ref\":\"/Address\"},\"to\":{\"$ref\":\"/Address\"},\"value\":{\"oneOf\":[{\"$ref\":\"/Number\"},{\"$ref\":\"/JsNumber\"}]},\"gas\":{\"oneOf\":[{\"$ref\":\"/Number\"},{\"$ref\":\"/JsNumber\"}]},\"gasPrice\":{\"oneOf\":[{\"$ref\":\"/Number\"},{\"$ref\":\"/JsNumber\"}]},\"data\":{\"type\":\"string\",\"pattern\":\"^0x[0-9a-f]*$\"},\"nonce\":{\"type\":\"number\",\"minimum\":0}},\"required\":[\"from\"],\"type\":\"object\",\"additionalProperties\":false}",
|
||||
"key": "TxDataSchema"
|
||||
},
|
||||
{
|
||||
"type": "any",
|
||||
"value":
|
||||
"{\"id\":\"/RelayerApiErrorResponse\",\"type\":\"object\",\"properties\":{\"code\":{\"type\":\"number\"},\"reason\":{\"type\":\"string\"},\"validationErrors\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"field\":{\"type\":\"string\"},\"code\":{\"type\":\"number\"},\"reason\":{\"type\":\"string\"}},\"required\":[\"field\",\"code\",\"reason\"]}}},\"required\":[\"code\",\"reason\"]}",
|
||||
"key": "RelayerApiErrorResponseSchema"
|
||||
},
|
||||
{
|
||||
"type": "any",
|
||||
"value":
|
||||
"{\"id\":\"/RelayerApiFeesPayload\",\"type\":\"object\",\"properties\":{\"exchangeContractAddress\":{\"$ref\":\"/Address\"},\"maker\":{\"$ref\":\"/Address\"},\"taker\":{\"$ref\":\"/Address\"},\"makerTokenAddress\":{\"$ref\":\"/Address\"},\"takerTokenAddress\":{\"$ref\":\"/Address\"},\"makerTokenAmount\":{\"$ref\":\"/Number\"},\"takerTokenAmount\":{\"$ref\":\"/Number\"},\"expirationUnixTimestampSec\":{\"$ref\":\"/Number\"},\"salt\":{\"$ref\":\"/Number\"}},\"required\":[\"exchangeContractAddress\",\"maker\",\"taker\",\"makerTokenAddress\",\"takerTokenAddress\",\"expirationUnixTimestampSec\",\"salt\"]}",
|
||||
"key": "RelayerApiFeesPayloadSchema"
|
||||
},
|
||||
{
|
||||
"type": "any",
|
||||
"value":
|
||||
"{\"id\":\"/RelayerApiFeesResponse\",\"type\":\"object\",\"properties\":{\"makerFee\":{\"$ref\":\"/Number\"},\"takerFee\":{\"$ref\":\"/Number\"},\"feeRecipient\":{\"$ref\":\"/Address\"}},\"required\":[\"makerFee\",\"takerFee\",\"feeRecipient\"]}",
|
||||
"key": "RelayerApiFeesResponseSchema"
|
||||
},
|
||||
{
|
||||
"type": "any",
|
||||
"value":
|
||||
"{\"id\":\"/RelayerApiOrderBookResponse\",\"type\":\"object\",\"properties\":{\"bids\":{\"$ref\":\"/signedOrdersSchema\"},\"asks\":{\"$ref\":\"/signedOrdersSchema\"}},\"required\":[\"bids\",\"asks\"]}",
|
||||
"key": "RelayerApiOrderBookResponseSchema"
|
||||
},
|
||||
{
|
||||
"type": "any",
|
||||
"value":
|
||||
"{\"id\":\"/RelayerApiTokenPairsResponse\",\"type\":\"array\",\"items\":{\"properties\":{\"tokenA\":{\"$ref\":\"/RelayerApiTokenTradeInfo\"},\"tokenB\":{\"$ref\":\"/RelayerApiTokenTradeInfo\"}},\"required\":[\"tokenA\",\"tokenB\"],\"type\":\"object\"}}",
|
||||
"key": "RelayerApiTokenPairsResponseSchema"
|
||||
},
|
||||
{
|
||||
"type": "any",
|
||||
"value":
|
||||
"{\"id\":\"/RelayerApiTokenTradeInfo\",\"type\":\"object\",\"properties\":{\"address\":{\"$ref\":\"/Address\"},\"minAmount\":{\"$ref\":\"/Number\"},\"maxAmount\":{\"$ref\":\"/Number\"},\"precision\":{\"type\":\"number\"}},\"required\":[\"address\"]}",
|
||||
"key": "RelayerApiTokenTradeInfoSchema"
|
||||
},
|
||||
{
|
||||
"type": "any",
|
||||
"value":
|
||||
"{\"id\":\"/RelayerApiOrderbookChannelSubscribe\",\"type\":\"object\",\"properties\":{\"type\":{\"enum\":[\"subscribe\"]},\"channel\":{\"enum\":[\"orderbook\"]},\"requestId\":{\"type\":\"number\"},\"payload\":{\"$ref\":\"/RelayerApiOrderbookChannelSubscribePayload\"}},\"required\":[\"type\",\"channel\",\"requestId\",\"payload\"]}",
|
||||
"key": "RelayerApiOrderbookChannelSubscribeSchema"
|
||||
},
|
||||
{
|
||||
"type": "any",
|
||||
"value":
|
||||
"{\"id\":\"/RelayerApiOrderbookChannelSubscribePayload\",\"type\":\"object\",\"properties\":{\"baseTokenAddress\":{\"$ref\":\"/Address\"},\"quoteTokenAddress\":{\"$ref\":\"/Address\"},\"snapshot\":{\"type\":\"boolean\"},\"limit\":{\"type\":\"number\"}},\"required\":[\"baseTokenAddress\",\"quoteTokenAddress\"]}",
|
||||
"key": "RelayerApiOrderbookChannelSubscribePayloadSchema"
|
||||
},
|
||||
{
|
||||
"type": "any",
|
||||
"value":
|
||||
"{\"id\":\"/RelayerApiOrderbookChannelUpdate\",\"type\":\"object\",\"properties\":{\"type\":{\"enum\":[\"update\"]},\"channel\":{\"enum\":[\"orderbook\"]},\"requestId\":{\"type\":\"number\"},\"payload\":{\"$ref\":\"/SignedOrder\"}},\"required\":[\"type\",\"channel\",\"requestId\",\"payload\"]}",
|
||||
"key": "RelayerApiOrderbookChannelUpdateSchema"
|
||||
},
|
||||
{
|
||||
"type": "any",
|
||||
"value":
|
||||
"{\"id\":\"/RelayerApiOrderbookChannelSnapshot\",\"type\":\"object\",\"properties\":{\"type\":{\"enum\":[\"snapshot\"]},\"channel\":{\"enum\":[\"orderbook\"]},\"requestId\":{\"type\":\"number\"},\"payload\":{\"$ref\":\"/RelayerApiOrderbookChannelSnapshotPayload\"}},\"required\":[\"type\",\"channel\",\"requestId\",\"payload\"]}",
|
||||
"key": "RelayerApiOrderbookChannelSnapshotSchema"
|
||||
},
|
||||
{
|
||||
"type": "any",
|
||||
"value":
|
||||
"{\"id\":\"/RelayerApiOrderbookChannelSnapshotPayload\",\"type\":\"object\",\"properties\":{\"bids\":{\"$ref\":\"/signedOrdersSchema\"},\"asks\":{\"$ref\":\"/signedOrdersSchema\"}},\"required\":[\"bids\",\"asks\"]}",
|
||||
"key": "RelayerApiOrderbookChannelSnapshotPayloadSchema"
|
||||
},
|
||||
{
|
||||
"type": "any",
|
||||
"value":
|
||||
"[\"NumberSchema\",\"AddressSchema\",\"ECSignatureSchema\",\"ECSignatureParameterSchema\",\"IndexFilterValuesSchema\",\"OrderCancellationRequestsSchema\",\"OrderFillOrKillRequestsSchema\",\"OrderFillRequestsSchema\",\"OrderHashSchemaSchema\",\"OrderSchema\",\"SignedOrderSchema\",\"signedOrdersSchemaSchema\",\"BlockParamSchema\",\"BlockRangeSchema\",\"TokenSchema\",\"JsNumberSchema\",\"TxDataSchema\",\"RelayerApiErrorResponseSchema\",\"RelayerApiFeesPayloadSchema\",\"RelayerApiFeesResponseSchema\",\"RelayerApiOrderBookResponseSchema\",\"RelayerApiTokenPairsResponseSchema\",\"RelayerApiTokenTradeInfoSchema\",\"RelayerApiOrderbookChannelSubscribeSchema\",\"RelayerApiOrderbookChannelSubscribePayloadSchema\",\"RelayerApiOrderbookChannelUpdateSchema\",\"RelayerApiOrderbookChannelSnapshotSchema\",\"RelayerApiOrderbookChannelSnapshotPayloadSchema\"]",
|
||||
"key": "schemaKeys"
|
||||
},
|
||||
{
|
||||
"type": "any",
|
||||
"value": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
|
||||
"key": "tokenContractAddress1"
|
||||
},
|
||||
{
|
||||
"type": "any",
|
||||
"value": "0xe41d2489571d322189246dafa5ebde1f4699f498",
|
||||
"key": "tokenContractAddress2"
|
||||
},
|
||||
{
|
||||
"type": "any",
|
||||
"value": "0x12459c951127e0c374ff9105dda097662a027093",
|
||||
"key": "exchangeContractAddress"
|
||||
},
|
||||
{
|
||||
"type": "any",
|
||||
"value":
|
||||
"{\"orderHash\":\"0xe91e990bab4c9c6bd60ff3673222390e3da8b7bd9a50eab98a8cb20723b24ee1\",\"exchangeContractAddress\":\"0x12459c951127e0c374ff9105dda097662a027093\",\"maker\":\"0x93690d55b14d701c259ba7960395c095aa52c3a8\",\"taker\":\"0x0000000000000000000000000000000000000000\",\"makerTokenAddress\":\"0x2956356cd2a2bf3202f771f50d3d14a367b48070\",\"takerTokenAddress\":\"0x0abdace70d3790235af448c88547603b945604ea\",\"feeRecipient\":\"0xa258b39954cef5cb142fd567a46cddb31a670124\",\"makerTokenAmount\":\"2926675830000000000\",\"takerTokenAmount\":\"24386933000000000000000\",\"makerFee\":\"18419638100000000000\",\"takerFee\":\"35812978500000000000\",\"expirationUnixTimestampSec\":\"9223372036854775807\",\"salt\":\"89583415499996246176114840147523733506098603782358761236056286417408784066968\",\"ecSignature\":{\"r\":\"0x32eb5bbf713210274ddd885e6b555699bc0189676ff73a4dc98c4cac41d3a6a6\",\"s\":\"0x193eb9440df49dc7817b6142c0be021cd1f9fc0916d86c7b49e9e07a402f3645\",\"v\":28}}",
|
||||
"key": "order"
|
||||
},
|
||||
{
|
||||
"type": "any",
|
||||
"value": "0x93690d55b14d701c259ba7960395c095aa52c3a8",
|
||||
"key": "orderMaker"
|
||||
},
|
||||
{
|
||||
"type": "any",
|
||||
"value": "0x0000000000000000000000000000000000000000",
|
||||
"key": "orderTaker"
|
||||
},
|
||||
{
|
||||
"type": "any",
|
||||
"value": "0xa258b39954cef5cb142fd567a46cddb31a670124",
|
||||
"key": "orderFeeRecipient"
|
||||
},
|
||||
{
|
||||
"type": "any",
|
||||
"value": "0xe91e990bab4c9c6bd60ff3673222390e3da8b7bd9a50eab98a8cb20723b24ee1",
|
||||
"key": "orderHash"
|
||||
},
|
||||
{
|
||||
"type": "any",
|
||||
"value": "https://example.com",
|
||||
"key": "url"
|
||||
}
|
||||
],
|
||||
"_postman_variable_scope": "environment",
|
||||
"_postman_exported_at": "2018-03-10T23:53:03.913Z",
|
||||
"_postman_exported_using": "Newman/3.9.3"
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,30 +0,0 @@
|
||||
[
|
||||
{
|
||||
"tokenA": {
|
||||
"address": "4a6b4ccb1b6faa2625fe562bdd9a23260359",
|
||||
"minAmount": "1",
|
||||
"maxAmount": "999999999999999999999",
|
||||
"precision": 8
|
||||
},
|
||||
"tokenB": {
|
||||
"address": "0x01b3ec4aae1b8729529beb4965f27d008788b0eb",
|
||||
"minAmount": "1",
|
||||
"maxAmount": 999999999999999999999,
|
||||
"precision": 8
|
||||
}
|
||||
},
|
||||
{
|
||||
"tokenA": {
|
||||
"address": "0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359",
|
||||
"minAmount": "1",
|
||||
"maxAmount": "999999999999999999999",
|
||||
"precision": 8
|
||||
},
|
||||
"tokenX": {
|
||||
"address": "0x0371a82e4a9d0a4312f3ee2ac9c6958512891372",
|
||||
"minAmount": "1",
|
||||
"maxAmount": "999999999999999999999",
|
||||
"precision": 8
|
||||
}
|
||||
}
|
||||
]
|
@ -1,16 +0,0 @@
|
||||
[
|
||||
{
|
||||
"tokenA": {
|
||||
"address": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
|
||||
"minAmount": "1",
|
||||
"maxAmount": "999999999999999999999",
|
||||
"precision": 8
|
||||
},
|
||||
"tokenB": {
|
||||
"address": "0xe41d2489571d322189246dafa5ebde1f4699f498",
|
||||
"minAmount": "1",
|
||||
"maxAmount": "999999999999999999999",
|
||||
"precision": 8
|
||||
}
|
||||
}
|
||||
]
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,76 +0,0 @@
|
||||
import 'mocha';
|
||||
import * as nock from 'nock';
|
||||
|
||||
import * as defaultRequestTokenPairsResponseJSON from './fixtures/v0/token_pairs/default_request.json';
|
||||
import * as malformedTokenPairsResponseJSON from './fixtures/v0/token_pairs/malformed.json';
|
||||
import * as tokenAAndTokenBParamsTokenPairsResponseJSON from './fixtures/v0/token_pairs/token_a_and_token_b_params.json';
|
||||
import * as tokenAParamTokenPairsResponseJSON from './fixtures/v0/token_pairs/token_a_param.json';
|
||||
import * as tokenBParamTokenPairsResponseJSON from './fixtures/v0/token_pairs/token_b_param.json';
|
||||
import { testRunner } from './test_runner';
|
||||
|
||||
describe('Postman Collection v0', () => {
|
||||
const testRelayerUrl = 'https://example.com';
|
||||
const nockScope = nock(testRelayerUrl);
|
||||
afterEach(() => {
|
||||
nock.cleanAll();
|
||||
});
|
||||
describe('GET /token_pairs', () => {
|
||||
const postmanCollectionFolderName = 'GET /token_pairs';
|
||||
const resourcePath = '/token_pairs';
|
||||
describe('default request', () => {
|
||||
const postmanCollectionRequestName = 'default request';
|
||||
const nockInterceptor = nockScope.get(resourcePath);
|
||||
testRunner.runContentTypeTests(nockInterceptor, postmanCollectionFolderName, postmanCollectionRequestName);
|
||||
testRunner.runSchemaTests(
|
||||
nockInterceptor,
|
||||
postmanCollectionFolderName,
|
||||
postmanCollectionRequestName,
|
||||
malformedTokenPairsResponseJSON,
|
||||
defaultRequestTokenPairsResponseJSON,
|
||||
);
|
||||
});
|
||||
describe('tokenA param', () => {
|
||||
const postmanCollectionRequestName = 'tokenA param';
|
||||
const nockInterceptor = nockScope.get(resourcePath).query({
|
||||
tokenA: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
||||
});
|
||||
testRunner.runContentTypeTests(nockInterceptor, postmanCollectionFolderName, postmanCollectionRequestName);
|
||||
testRunner.runSchemaTests(
|
||||
nockInterceptor,
|
||||
postmanCollectionFolderName,
|
||||
postmanCollectionRequestName,
|
||||
malformedTokenPairsResponseJSON,
|
||||
tokenAParamTokenPairsResponseJSON,
|
||||
);
|
||||
});
|
||||
describe('tokenB param', () => {
|
||||
const postmanCollectionRequestName = 'tokenB param';
|
||||
const nockInterceptor = nockScope.get(resourcePath).query({
|
||||
tokenB: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
||||
});
|
||||
testRunner.runContentTypeTests(nockInterceptor, postmanCollectionFolderName, postmanCollectionRequestName);
|
||||
testRunner.runSchemaTests(
|
||||
nockInterceptor,
|
||||
postmanCollectionFolderName,
|
||||
postmanCollectionRequestName,
|
||||
malformedTokenPairsResponseJSON,
|
||||
tokenBParamTokenPairsResponseJSON,
|
||||
);
|
||||
});
|
||||
describe('tokenA and tokenB params', () => {
|
||||
const postmanCollectionRequestName = 'tokenA and tokenB params';
|
||||
const nockInterceptor = nockScope.get(resourcePath).query({
|
||||
tokenA: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
||||
tokenB: '0xe41d2489571d322189246dafa5ebde1f4699f498',
|
||||
});
|
||||
testRunner.runContentTypeTests(nockInterceptor, postmanCollectionFolderName, postmanCollectionRequestName);
|
||||
testRunner.runSchemaTests(
|
||||
nockInterceptor,
|
||||
postmanCollectionFolderName,
|
||||
postmanCollectionRequestName,
|
||||
malformedTokenPairsResponseJSON,
|
||||
tokenAAndTokenBParamsTokenPairsResponseJSON,
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
@ -1,143 +0,0 @@
|
||||
import * as chai from 'chai';
|
||||
import * as chaiAsPromised from 'chai-as-promised';
|
||||
import * as dirtyChai from 'dirty-chai';
|
||||
import * as _ from 'lodash';
|
||||
import 'mocha';
|
||||
import {
|
||||
NewmanRunExecution,
|
||||
NewmanRunExecutionAssertion,
|
||||
NewmanRunExecutionAssertionError,
|
||||
NewmanRunSummary,
|
||||
} from 'newman';
|
||||
import * as nock from 'nock';
|
||||
|
||||
import * as sraReportCollectionJSON from '../../postman_collections/sra_report.postman_collection.json';
|
||||
import { utils } from '../src/utils';
|
||||
|
||||
import * as postmanEnvironmentJSON from './environments/postman_environment.json';
|
||||
|
||||
chai.config.includeStack = true;
|
||||
chai.use(dirtyChai);
|
||||
chai.use(chaiAsPromised);
|
||||
const expect = chai.expect;
|
||||
|
||||
const CONTENT_TYPE_ASSERTION_NAME = 'Has Content-Type header with value application/json';
|
||||
const SCHEMA_ASSERTION_NAME = 'Schema is valid';
|
||||
const SUCCESS_STATUS = 200;
|
||||
const baseNewmanRunOptions = {
|
||||
collection: sraReportCollectionJSON,
|
||||
environment: postmanEnvironmentJSON,
|
||||
reporter: {
|
||||
cli: {
|
||||
noConsole: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const testRunner = {
|
||||
runContentTypeTests(
|
||||
nockInterceptor: nock.Interceptor,
|
||||
postmanCollectionFolderName: string,
|
||||
postmanCollectionRequestName: string,
|
||||
): void {
|
||||
const newmanRunOptions = {
|
||||
...baseNewmanRunOptions,
|
||||
folder: postmanCollectionFolderName,
|
||||
};
|
||||
describe(CONTENT_TYPE_ASSERTION_NAME, () => {
|
||||
it('fails when there are no headers', async () => {
|
||||
nockInterceptor.reply(SUCCESS_STATUS, {});
|
||||
const summary = await utils.newmanRunAsync(newmanRunOptions);
|
||||
const error = findAssertionErrorIfExists(
|
||||
summary,
|
||||
postmanCollectionRequestName,
|
||||
CONTENT_TYPE_ASSERTION_NAME,
|
||||
);
|
||||
const errorMessage = _.get(error, 'message');
|
||||
expect(error).to.not.be.undefined();
|
||||
expect(errorMessage).to.equal(`expected response to have header with key 'Content-Type'`);
|
||||
});
|
||||
it('fails when Content-Type header exists but not with value application/json', async () => {
|
||||
const headers = {
|
||||
'Content-Type': 'text/html',
|
||||
};
|
||||
nockInterceptor.reply(SUCCESS_STATUS, {}, headers);
|
||||
const summary = await utils.newmanRunAsync(newmanRunOptions);
|
||||
const error = findAssertionErrorIfExists(
|
||||
summary,
|
||||
postmanCollectionRequestName,
|
||||
CONTENT_TYPE_ASSERTION_NAME,
|
||||
);
|
||||
const errorMessage = _.get(error, 'message');
|
||||
expect(error).to.not.be.undefined();
|
||||
expect(errorMessage).to.equal(`expected 'text/html' to include 'application/json'`);
|
||||
});
|
||||
it('passes when Content-Type header exists with value application/json', async () => {
|
||||
const headers = {
|
||||
'Content-Type': 'charset=utf-8; application/json',
|
||||
};
|
||||
nockInterceptor.reply(SUCCESS_STATUS, {}, headers);
|
||||
const summary = await utils.newmanRunAsync(newmanRunOptions);
|
||||
const error = findAssertionErrorIfExists(
|
||||
summary,
|
||||
postmanCollectionRequestName,
|
||||
CONTENT_TYPE_ASSERTION_NAME,
|
||||
);
|
||||
expect(error).to.be.undefined();
|
||||
});
|
||||
});
|
||||
},
|
||||
runSchemaTests(
|
||||
nockInterceptor: nock.Interceptor,
|
||||
postmanCollectionFolderName: string,
|
||||
postmanCollectionRequestName: string,
|
||||
malformedJson: object,
|
||||
correctJson: object,
|
||||
): void {
|
||||
const newmanRunOptions = {
|
||||
...baseNewmanRunOptions,
|
||||
folder: postmanCollectionFolderName,
|
||||
};
|
||||
describe(SCHEMA_ASSERTION_NAME, () => {
|
||||
it('fails when schema is invalid', async () => {
|
||||
nockInterceptor.reply(SUCCESS_STATUS, malformedJson);
|
||||
const summary = await utils.newmanRunAsync(newmanRunOptions);
|
||||
const error = findAssertionErrorIfExists(summary, postmanCollectionRequestName, SCHEMA_ASSERTION_NAME);
|
||||
const errorMessage = _.get(error, 'message');
|
||||
expect(error).to.not.be.undefined();
|
||||
expect(errorMessage).to.equal('expected false to be true');
|
||||
});
|
||||
it('passes when schema is valid', async () => {
|
||||
nockInterceptor.reply(SUCCESS_STATUS, correctJson);
|
||||
const summary = await utils.newmanRunAsync(newmanRunOptions);
|
||||
const error = findAssertionErrorIfExists(summary, postmanCollectionRequestName, SCHEMA_ASSERTION_NAME);
|
||||
expect(error).to.be.undefined();
|
||||
});
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
function findAssertionErrorIfExists(
|
||||
summary: NewmanRunSummary,
|
||||
postmanCollectionRequestName: string,
|
||||
postmanCollectionAssertionName: string,
|
||||
): NewmanRunExecutionAssertionError | undefined {
|
||||
const matchingExecutionIfExists = _.find(summary.run.executions, (execution: NewmanRunExecution) => {
|
||||
return execution.item.name === postmanCollectionRequestName;
|
||||
});
|
||||
if (_.isUndefined(matchingExecutionIfExists)) {
|
||||
return undefined;
|
||||
}
|
||||
const matchingAssertionIfExists = _.find(
|
||||
matchingExecutionIfExists.assertions,
|
||||
(assertion: NewmanRunExecutionAssertion) => {
|
||||
return assertion.assertion === postmanCollectionAssertionName;
|
||||
},
|
||||
);
|
||||
if (_.isUndefined(matchingAssertionIfExists)) {
|
||||
return undefined;
|
||||
} else {
|
||||
const error = matchingAssertionIfExists.error;
|
||||
return error;
|
||||
}
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
{
|
||||
"extends": "../../tsconfig",
|
||||
"compilerOptions": {
|
||||
"outDir": "lib",
|
||||
"rootDir": "."
|
||||
},
|
||||
"include": ["./src/**/*", "./test/**/*"]
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
{
|
||||
"extends": ["@0xproject/tslint-config"]
|
||||
}
|
@ -1,7 +1,3 @@
|
||||
# Testing
|
||||
|
||||
Use the [sra-report](https://github.com/0xProject/0x-monorepo/tree/development/packages/sra-report) command line tool to test your API for SRA compliance.
|
||||
|
||||
# Schemas
|
||||
|
||||
The [JSON schemas](http://json-schema.org/) for the API payloads and responses can be found in [@0xproject/json-schemas](https://github.com/0xProject/0x.js/tree/development/packages/json-schemas). Examples of each payload and response can be found in the library's [test suite](https://github.com/0xProject/0x.js/blob/development/packages/json-schemas/test/schema_test.ts#L1).
|
||||
|
@ -45,7 +45,6 @@
|
||||
{ "path": "./packages/sol-compiler" },
|
||||
{ "path": "./packages/sol-cov" },
|
||||
{ "path": "./packages/sol-resolver" },
|
||||
{ "path": "./packages/sra-report" },
|
||||
{ "path": "./packages/sra-spec" },
|
||||
{ "path": "./packages/subproviders" },
|
||||
{ "path": "./packages/testnet-faucets" },
|
||||
|
Loading…
x
Reference in New Issue
Block a user