diff --git a/python-packages/cmd_pkgs_in_dep_order.py b/python-packages/cmd_pkgs_in_dep_order.py
index 0a989fb1c7..dbc0814846 100755
--- a/python-packages/cmd_pkgs_in_dep_order.py
+++ b/python-packages/cmd_pkgs_in_dep_order.py
@@ -17,7 +17,6 @@ PACKAGE_DEPENDENCY_LIST = [
"sra_client",
"order_utils",
"middlewares",
- "contract_demo"
]
for package in PACKAGE_DEPENDENCY_LIST:
diff --git a/python-packages/contract_demo/.discharge.json b/python-packages/contract_demo/.discharge.json
deleted file mode 100644
index 9d811ae3e6..0000000000
--- a/python-packages/contract_demo/.discharge.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "domain": "0x-contract-demo-py",
- "build_command": "python setup.py build_sphinx",
- "upload_directory": "build/docs/html",
- "index_key": "index.html",
- "error_key": "index.html",
- "trailing_slashes": true,
- "cache": 3600,
- "aws_profile": "default",
- "aws_region": "us-east-1",
- "cdn": false,
- "dns_configured": true
-}
diff --git a/python-packages/contract_demo/README.md b/python-packages/contract_demo/README.md
deleted file mode 100644
index 3a0f964e30..0000000000
--- a/python-packages/contract_demo/README.md
+++ /dev/null
@@ -1,39 +0,0 @@
-## 0x-contract-demo
-
-A demonstration of calling 0x smart contracts from Python.
-
-Read the [documentation](http://0x-contract-demo-py.s3-website-us-east-1.amazonaws.com/)
-
-## 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 Code and Dependencies
-
-Ensure that you have installed Python >=3.6 and Docker. Then:
-
-```bash
-pip install -e .[dev]
-```
-
-### Test
-
-Tests depend on a running ganache instance with the 0x contracts deployed in it. For convenience, a docker container is provided that has ganache-cli and a snapshot containing the necessary contracts. A shortcut is provided to run that docker container: `./setup.py ganache`. With that running, the tests can be run with `./setup.py test`.
-
-### Clean
-
-`./setup.py clean --all`
-
-### Lint
-
-`./setup.py lint`
-
-### Build Documentation
-
-`./setup.py build_sphinx`
-
-### More
-
-See `./setup.py --help-commands` for more info.
diff --git a/python-packages/contract_demo/setup.py b/python-packages/contract_demo/setup.py
deleted file mode 100755
index a7afbd30c8..0000000000
--- a/python-packages/contract_demo/setup.py
+++ /dev/null
@@ -1,146 +0,0 @@
-#!/usr/bin/env python
-
-"""setuptools module for 0x-contract-demo package."""
-
-import distutils.command.build_py
-from distutils.command.clean import clean
-import subprocess # nosec
-from shutil import rmtree
-from os import environ, path
-from sys import argv
-
-from setuptools import setup
-from setuptools.command.test import test as TestCommand
-
-
-class TestCommandExtension(TestCommand):
- """Run pytest tests."""
-
- def run_tests(self):
- """Invoke pytest."""
- import pytest
-
- exit(pytest.main())
-
-
-class LintCommand(distutils.command.build_py.build_py):
- """Custom setuptools command class for running linters."""
-
- description = "Run linters"
-
- def run(self):
- """Run linter shell commands."""
- lint_commands = [
- # formatter:
- "black --line-length 79 --check --diff test setup.py".split(),
- # style guide checker (formerly pep8):
- "pycodestyle test setup.py".split(),
- # docstring style checker:
- "pydocstyle test setup.py".split(),
- # static type checker:
- "mypy test setup.py".split(),
- # security issue checker:
- "bandit -r ./setup.py".split(),
- # general linter:
- "pylint test setup.py".split(),
- # pylint takes relatively long to run, so it runs last, to enable
- # fast failures.
- ]
-
- # tell mypy where to find interface stubs for 3rd party libs
- environ["MYPYPATH"] = path.join(
- path.dirname(path.realpath(argv[0])), "stubs"
- )
-
- for lint_command in lint_commands:
- print(
- "Running lint command `", " ".join(lint_command).strip(), "`"
- )
- subprocess.check_call(lint_command) # nosec
-
-
-class CleanCommandExtension(clean):
- """Custom command to do custom cleanup."""
-
- def run(self):
- """Run the regular clean, followed by our custom commands."""
- super().run()
- rmtree(".mypy_cache", ignore_errors=True)
- rmtree(".tox", ignore_errors=True)
- rmtree(".pytest_cache", ignore_errors=True)
-
-
-class GanacheCommand(distutils.command.build_py.build_py):
- """Custom command to publish to pypi.org."""
-
- description = "Run ganache daemon to support tests."
-
- def run(self):
- """Run ganache."""
- cmd_line = "docker run -d -p 8545:8545 0xorg/ganache-cli:2.2.2".split()
- subprocess.call(cmd_line) # nosec
-
-
-class PublishDocsCommand(distutils.command.build_py.build_py):
- """Custom command to publish docs to S3."""
-
- description = (
- "Publish docs to "
- + "http://0x-contract-addresses-py.s3-website-us-east-1.amazonaws.com/"
- )
-
- def run(self):
- """Run npm package `discharge` to build & upload docs."""
- subprocess.check_call("discharge deploy".split()) # nosec
-
-
-setup(
- name="0x-contract-demo",
- version="1.0.0",
- description="Demonstration of calling 0x contracts",
- url=(
- "https://github.com/0xProject/0x-monorepo/tree/development"
- + "/python-packages/contract_demo"
- ),
- author="F. Eugene Aumson",
- author_email="feuGeneA@users.noreply.github.com",
- cmdclass={
- "clean": CleanCommandExtension,
- "lint": LintCommand,
- "test": TestCommandExtension,
- "ganache": GanacheCommand,
- "publish_docs": PublishDocsCommand,
- },
- install_requires=[
- "0x-contract-addresses",
- "0x-contract-artifacts",
- "0x-order-utils",
- "0x-web3", # TEMPORARY! pending resolution of our web3.py PR#1147
- "mypy_extensions",
- ],
- extras_require={
- "dev": [
- "bandit",
- "black",
- "coverage",
- "coveralls",
- "mypy",
- "mypy_extensions",
- "pycodestyle",
- "pydocstyle",
- "pylint",
- "pytest",
- "sphinx",
- "tox",
- ]
- },
- python_requires=">=3.6, <4",
- license="Apache 2.0",
- zip_safe=False, # required per mypy
- command_options={
- "build_sphinx": {
- "source_dir": ("setup.py", "test"),
- "build_dir": ("setup.py", "build/docs"),
- }
- },
-)
diff --git a/python-packages/contract_demo/stubs/command/__init__.pyi b/python-packages/contract_demo/stubs/command/__init__.pyi
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/python-packages/contract_demo/stubs/command/clean.pyi b/python-packages/contract_demo/stubs/command/clean.pyi
deleted file mode 100644
index 46a42ddb13..0000000000
--- a/python-packages/contract_demo/stubs/command/clean.pyi
+++ /dev/null
@@ -1,7 +0,0 @@
-from distutils.core import Command
-
-class clean(Command):
- def initialize_options(self: clean) -> None: ...
- def finalize_options(self: clean) -> None: ...
- def run(self: clean) -> None: ...
- ...
diff --git a/python-packages/contract_demo/stubs/distutils/__init__.pyi b/python-packages/contract_demo/stubs/distutils/__init__.pyi
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/python-packages/contract_demo/stubs/distutils/command/__init__.pyi b/python-packages/contract_demo/stubs/distutils/command/__init__.pyi
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/python-packages/contract_demo/stubs/distutils/command/clean.pyi b/python-packages/contract_demo/stubs/distutils/command/clean.pyi
deleted file mode 100644
index 46a42ddb13..0000000000
--- a/python-packages/contract_demo/stubs/distutils/command/clean.pyi
+++ /dev/null
@@ -1,7 +0,0 @@
-from distutils.core import Command
-
-class clean(Command):
- def initialize_options(self: clean) -> None: ...
- def finalize_options(self: clean) -> None: ...
- def run(self: clean) -> None: ...
- ...
diff --git a/python-packages/contract_demo/stubs/eth_utils/__init__.pyi b/python-packages/contract_demo/stubs/eth_utils/__init__.pyi
deleted file mode 100644
index 4a83338cad..0000000000
--- a/python-packages/contract_demo/stubs/eth_utils/__init__.pyi
+++ /dev/null
@@ -1,4 +0,0 @@
-from typing import Union
-
-def to_checksum_address(value: Union[str, bytes]) -> str:
- ...
diff --git a/python-packages/contract_demo/stubs/pytest/__init__.pyi b/python-packages/contract_demo/stubs/pytest/__init__.pyi
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/python-packages/contract_demo/stubs/setuptools/__init__.pyi b/python-packages/contract_demo/stubs/setuptools/__init__.pyi
deleted file mode 100644
index 8ea8d32b7e..0000000000
--- a/python-packages/contract_demo/stubs/setuptools/__init__.pyi
+++ /dev/null
@@ -1,8 +0,0 @@
-from distutils.dist import Distribution
-from typing import Any, List
-
-def setup(**attrs: Any) -> Distribution: ...
-
-class Command: ...
-
-def find_packages(where: str) -> List[str]: ...
diff --git a/python-packages/contract_demo/stubs/setuptools/command/__init__.pyi b/python-packages/contract_demo/stubs/setuptools/command/__init__.pyi
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/python-packages/contract_demo/stubs/setuptools/command/test.pyi b/python-packages/contract_demo/stubs/setuptools/command/test.pyi
deleted file mode 100644
index c5ec770ad3..0000000000
--- a/python-packages/contract_demo/stubs/setuptools/command/test.pyi
+++ /dev/null
@@ -1,3 +0,0 @@
-from setuptools import Command
-
-class test(Command): ...
diff --git a/python-packages/contract_demo/stubs/web3/__init__.pyi b/python-packages/contract_demo/stubs/web3/__init__.pyi
deleted file mode 100644
index 21482d598a..0000000000
--- a/python-packages/contract_demo/stubs/web3/__init__.pyi
+++ /dev/null
@@ -1,2 +0,0 @@
-class Web3:
- ...
diff --git a/python-packages/contract_demo/stubs/web3/utils/__init__.pyi b/python-packages/contract_demo/stubs/web3/utils/__init__.pyi
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/python-packages/contract_demo/stubs/web3/utils/datatypes.pyi b/python-packages/contract_demo/stubs/web3/utils/datatypes.pyi
deleted file mode 100644
index 70baff3728..0000000000
--- a/python-packages/contract_demo/stubs/web3/utils/datatypes.pyi
+++ /dev/null
@@ -1,3 +0,0 @@
-class Contract:
- def call(self): ...
- ...
diff --git a/python-packages/contract_demo/test/__init__.py b/python-packages/contract_demo/test/__init__.py
deleted file mode 100644
index 600f143bf1..0000000000
--- a/python-packages/contract_demo/test/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-"""Demonstrations of calling 0x smart contracts."""
diff --git a/python-packages/contract_demo/test/test_exchange.py b/python-packages/contract_demo/test/test_exchange.py
deleted file mode 100644
index e47fcc78fd..0000000000
--- a/python-packages/contract_demo/test/test_exchange.py
+++ /dev/null
@@ -1,117 +0,0 @@
-"""Test calling methods on the Exchange contract."""
-
-from eth_utils import to_checksum_address
-from web3 import Web3
-from web3.utils import datatypes
-
-from zero_ex.contract_addresses import NETWORK_TO_ADDRESSES, NetworkId
-import zero_ex.contract_artifacts
-from zero_ex.json_schemas import assert_valid
-from zero_ex.order_utils import (
- Order,
- OrderInfo,
- order_to_jsdict,
- generate_order_hash_hex,
-)
-
-
-def test_get_order_info():
- """Demonstrate Exchange.getOrderInfo()."""
- order: Order = {
- "makerAddress": "0x0000000000000000000000000000000000000000",
- "takerAddress": "0x0000000000000000000000000000000000000000",
- "feeRecipientAddress": "0x0000000000000000000000000000000000000000",
- "senderAddress": "0x0000000000000000000000000000000000000000",
- "makerAssetAmount": 1000000000000000000,
- "takerAssetAmount": 1000000000000000000,
- "makerFee": 0,
- "takerFee": 0,
- "expirationTimeSeconds": 12345,
- "salt": 12345,
- "makerAssetData": (b"\x00") * 20,
- "takerAssetData": (b"\x00") * 20,
- }
-
- web3_instance = Web3(Web3.HTTPProvider("http://127.0.0.1:8545"))
-
- # false positive from pylint: disable=no-member
- contract_address = NETWORK_TO_ADDRESSES[
- NetworkId(int(web3_instance.net.version))
- ].exchange
-
- assert_valid(
- order_to_jsdict(order, exchange_address=contract_address),
- "/orderSchema",
- )
-
- # false positive from pylint: disable=no-member
- exchange: datatypes.Contract = web3_instance.eth.contract(
- address=to_checksum_address(contract_address),
- abi=zero_ex.contract_artifacts.abi_by_name("Exchange"),
- )
-
- order_info = OrderInfo(*exchange.call().getOrderInfo(order))
-
- assert isinstance(order_info.order_status, int)
- assert order_info.order_status == 4
-
- assert isinstance(order_info.order_hash, bytes)
- assert order_info.order_hash.hex() == generate_order_hash_hex(
- order,
- exchange_address=NETWORK_TO_ADDRESSES[NetworkId.GANACHE].exchange,
- )
-
- assert isinstance(order_info.order_taker_asset_filled_amount, int)
- assert order_info.order_taker_asset_filled_amount == 0
-
-
-def test_get_orders_info():
- """Demonstrate Exchange.getOrderInfo()."""
- order: Order = {
- "makerAddress": "0x0000000000000000000000000000000000000000",
- "takerAddress": "0x0000000000000000000000000000000000000000",
- "feeRecipientAddress": "0x0000000000000000000000000000000000000000",
- "senderAddress": "0x0000000000000000000000000000000000000000",
- "makerAssetAmount": 1000000000000000000,
- "takerAssetAmount": 1000000000000000000,
- "makerFee": 0,
- "takerFee": 0,
- "expirationTimeSeconds": 12345,
- "salt": 12345,
- "makerAssetData": (b"\x00") * 20,
- "takerAssetData": (b"\x00") * 20,
- }
-
- web3_instance = Web3(Web3.HTTPProvider("http://127.0.0.1:8545"))
-
- # false positive from pylint: disable=no-member
- contract_address = NETWORK_TO_ADDRESSES[
- NetworkId(int(web3_instance.net.version))
- ].exchange
-
- assert_valid(
- order_to_jsdict(order, exchange_address=contract_address),
- "/orderSchema",
- )
-
- # false positive from pylint: disable=no-member
- exchange: datatypes.Contract = web3_instance.eth.contract(
- address=to_checksum_address(contract_address),
- abi=zero_ex.contract_artifacts.abi_by_name("Exchange"),
- )
-
- orders_info = exchange.call().getOrdersInfo([order])
-
- for order_info in orders_info:
- order_info = OrderInfo(*order_info)
- assert isinstance(order_info.order_status, int)
- assert order_info.order_status == 4
-
- assert isinstance(order_info.order_hash, bytes)
- assert order_info.order_hash.hex() == generate_order_hash_hex(
- order,
- exchange_address=NETWORK_TO_ADDRESSES[NetworkId.GANACHE].exchange,
- )
-
- assert isinstance(order_info.order_taker_asset_filled_amount, int)
- assert order_info.order_taker_asset_filled_amount == 0
diff --git a/python-packages/json_schemas/src/zero_ex/json_schemas/__init__.py b/python-packages/json_schemas/src/zero_ex/json_schemas/__init__.py
index 10c564b99c..de7507016b 100644
--- a/python-packages/json_schemas/src/zero_ex/json_schemas/__init__.py
+++ b/python-packages/json_schemas/src/zero_ex/json_schemas/__init__.py
@@ -1,4 +1,31 @@
-"""JSON schemas and associated utilities."""
+"""JSON schemas and associated utilities.
+
+Validating a 0x Order
+---------------------
+
+Here is an example on how to validate a 0x order.
+
+>>> from zero_ex.json_schemas import assert_valid
+>>> example_order = {
+... 'makerAddress': '0x5409ed021d9299bf6814279a6a1411a7e866a631',
+... 'takerAddress': '0x0000000000000000000000000000000000000000',
+... 'senderAddress': '0x0000000000000000000000000000000000000000',
+... 'exchangeAddress': '0x4f833a24e1f95d70f028921e27040ca56e09ab0b',
+... 'feeRecipientAddress':
+... '0x0000000000000000000000000000000000000000',
+... 'makerAssetData': '0xf47261b0000000000000000000000000'
+... 'c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
+... 'takerAssetData': '0xf47261b0000000000000000000000000'
+... 'e41d2489571d322189246dafa5ebde1f4699f498',
+... 'salt': 123456789,
+... 'makerFee': 0,
+... 'takerFee': 0,
+... 'makerAssetAmount': 1000000000000000000,
+... 'takerAssetAmount': 500000000000000000000,
+... 'expirationTimeSeconds': 1553553429
+... }
+>>> assert_valid(example_order, "/orderSchema")
+"""
from os import path
import json
diff --git a/python-packages/order_utils/src/zero_ex/order_utils/__init__.py b/python-packages/order_utils/src/zero_ex/order_utils/__init__.py
index 39d4115077..c1fea8c21c 100644
--- a/python-packages/order_utils/src/zero_ex/order_utils/__init__.py
+++ b/python-packages/order_utils/src/zero_ex/order_utils/__init__.py
@@ -6,7 +6,55 @@ For local testing one may construct such a provider pointing at an instance of
contracts deployed on it. For convenience, a docker container is provided for
just this purpose. To start it:
`docker run -d -p 8545:8545 0xorg/ganache-cli:2.2.2`:code:.
-"""
+
+Creating a 0x Order
+--------------------
+
+Here is a short demonstration on how to create a 0x order.
+
+>>> import pprint
+>>> from zero_ex.contract_addresses import (
+... NETWORK_TO_ADDRESSES, NetworkId)
+>>> from zero_ex.order_utils import asset_data_utils, Order
+>>> NULL_ADDRESS = "0x0000000000000000000000000000000000000000"
+>>> my_address = "0x5409ed021d9299bf6814279a6a1411a7e866a631"
+>>> exchange_address = NETWORK_TO_ADDRESSES[NetworkId.MAINNET].exchange
+>>> weth_address = NETWORK_TO_ADDRESSES[NetworkId.MAINNET].ether_token
+>>> zrx_address = NETWORK_TO_ADDRESSES[NetworkId.MAINNET].zrx_token
+>>> maker_asset_data = (
+... asset_data_utils.encode_erc20_asset_data(weth_address))
+>>> taker_asset_data = (
+... asset_data_utils.encode_erc20_asset_data(zrx_address))
+>>> example_order: Order = {
+... "makerAddress": my_address,
+... "takerAddress": NULL_ADDRESS,
+... "exchangeAddress": exchange_address,
+... "senderAddress": NULL_ADDRESS,
+... "feeRecipientAddress": NULL_ADDRESS,
+... "makerAssetData": maker_asset_data,
+... "takerAssetData": taker_asset_data,
+... "salt": 123456789,
+... "makerFee": 0,
+... "takerFee": 0,
+... "makerAssetAmount": 1 * 10 ** 18, # Converting token amount to base unit with 18 decimals
+... "takerAssetAmount": 500 * 10 ** 18, # Converting token amount to base unit with 18 decimals
+... "expirationTimeSeconds": 1553553429,
+... }
+>>> pprint.pprint(example_order)
+{'exchangeAddress': '0x4f833a24e1f95d70f028921e27040ca56e09ab0b',
+ 'expirationTimeSeconds': 1553553429,
+ 'feeRecipientAddress': '0x0000000000000000000000000000000000000000',
+ 'makerAddress': '0x5409ed021d9299bf6814279a6a1411a7e866a631',
+ 'makerAssetAmount': 1000000000000000000,
+ 'makerAssetData': '0xf47261b0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
+ 'makerFee': 0,
+ 'salt': 123456789,
+ 'senderAddress': '0x0000000000000000000000000000000000000000',
+ 'takerAddress': '0x0000000000000000000000000000000000000000',
+ 'takerAssetAmount': 500000000000000000000,
+ 'takerAssetData': '0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498',
+ 'takerFee': 0}
+""" # noqa E501
from copy import copy
from enum import auto, Enum
diff --git a/python-packages/sra_client/.pylintrc b/python-packages/sra_client/.pylintrc
new file mode 100644
index 0000000000..ef108c01fc
--- /dev/null
+++ b/python-packages/sra_client/.pylintrc
@@ -0,0 +1,4 @@
+[MESSAGES CONTROL]
+disable=C0330,line-too-long,fixme,too-few-public-methods,too-many-ancestors
+# C0330 is "bad hanging indent". we use indents per `black`.
+
diff --git a/python-packages/sra_client/CHANGELOG.json b/python-packages/sra_client/CHANGELOG.json
index 7d6d2c4bb0..0016c0e04f 100644
--- a/python-packages/sra_client/CHANGELOG.json
+++ b/python-packages/sra_client/CHANGELOG.json
@@ -1,11 +1,22 @@
[
{
- "timestamp": 1553491629,
"version": "1.0.1",
"changes": [
{
- "note": "Fix regex validation on numeric values"
+ "note": "Fix regex validation on numeric values",
+ "pr": 1731
}
- ]
+ ],
+ "timestamp": 1553491629
+ },
+ {
+ "version": "1.0.1",
+ "changes": [
+ {
+ "note": "Added new devdependencies, and linting commands to `setup.py`. Added sphinx docs to demonstrate how to use sra_client.",
+ "pr": 1734
+ }
+ ],
+ "timestamp": 1553183790
}
]
diff --git a/python-packages/contract_demo/test/conf.py b/python-packages/sra_client/conf.py
similarity index 89%
rename from python-packages/contract_demo/test/conf.py
rename to python-packages/sra_client/conf.py
index 45ed4b2a53..3b6477c5de 100644
--- a/python-packages/contract_demo/test/conf.py
+++ b/python-packages/sra_client/conf.py
@@ -9,11 +9,11 @@ import pkg_resources
# pylint: disable=invalid-name
# because these variables are not named in upper case, as globals should be.
-project = "0x-contract-demo"
+project = "0x-sra-client"
# pylint: disable=redefined-builtin
copyright = "2018, ZeroEx, Intl."
author = "F. Eugene Aumson"
-version = pkg_resources.get_distribution("0x-contract-demo").version
+version = pkg_resources.get_distribution("0x-sra-client").version
release = "" # The full version, including alpha/beta/rc tags
extensions = [
@@ -22,6 +22,7 @@ extensions = [
"sphinx.ext.intersphinx",
"sphinx.ext.coverage",
"sphinx.ext.viewcode",
+ "sphinx_autodoc_typehints",
]
templates_path = ["doc_templates"]
@@ -46,7 +47,7 @@ html_static_path = ["doc_static"]
# so a file named "default.css" will overwrite the builtin "default.css".
# Output file base name for HTML help builder.
-htmlhelp_basename = "contract_demopydoc"
+htmlhelp_basename = "sraclientpydoc"
# -- Extension configuration:
diff --git a/python-packages/contract_demo/test/doc_static/.gitkeep b/python-packages/sra_client/doc_static/.gitkeep
similarity index 100%
rename from python-packages/contract_demo/test/doc_static/.gitkeep
rename to python-packages/sra_client/doc_static/.gitkeep
diff --git a/python-packages/contract_demo/stubs/__init__.pyi b/python-packages/sra_client/doc_template/.gitkeep
similarity index 100%
rename from python-packages/contract_demo/stubs/__init__.pyi
rename to python-packages/sra_client/doc_template/.gitkeep
diff --git a/python-packages/contract_demo/test/index.rst b/python-packages/sra_client/index.rst
similarity index 58%
rename from python-packages/contract_demo/test/index.rst
rename to python-packages/sra_client/index.rst
index c546eccfa3..27c814b316 100644
--- a/python-packages/contract_demo/test/index.rst
+++ b/python-packages/sra_client/index.rst
@@ -1,13 +1,20 @@
.. source for the sphinx-generated build/docs/web/index.html
-Python demo of 0x Smart Contracts
-=================================
+Python zero_ex.sra_client.api_client
+====================================
.. toctree::
:maxdepth: 2
:caption: Contents:
-.. automodule:: test.test_exchange
+.. automodule:: sra_client
+
+----
+
+API
+---
+
+.. automodule:: sra_client.api.default_api
:members:
Indices and tables
diff --git a/python-packages/sra_client/setup.py b/python-packages/sra_client/setup.py
index 0921149bd4..5d3c10d3c2 100755
--- a/python-packages/sra_client/setup.py
+++ b/python-packages/sra_client/setup.py
@@ -1,14 +1,16 @@
#!/usr/bin/env python
# coding: utf-8
+"""setuptools module for sra_client package."""
-import subprocess
+import subprocess # nosec
import distutils.command.build_py
from setuptools import setup, find_packages # noqa: H301
+from setuptools.command.test import test as TestCommand
NAME = "0x-sra-client"
-VERSION = "1.0.0"
+VERSION = "1.0.1"
# To install the library, run the following
#
# python setup.py install
@@ -21,6 +23,17 @@ with open("README.md", "r") as file_handle:
REQUIRES = ["urllib3 >= 1.15", "six >= 1.10", "certifi", "python-dateutil"]
+
+class TestCommandExtension(TestCommand):
+ """Run pytest tests."""
+
+ def run_tests(self):
+ """Invoke pytest."""
+ import pytest
+
+ exit(pytest.main(["--doctest-modules"]))
+
+
class TestPublishCommand(distutils.command.build_py.build_py):
"""Custom command to publish to test.pypi.org."""
@@ -38,6 +51,59 @@ class TestPublishCommand(distutils.command.build_py.build_py):
)
+class GanacheCommand(distutils.command.build_py.build_py):
+ """Custom command to publish to pypi.org."""
+
+ description = "Run ganache daemon to support tests."
+
+ def run(self):
+ """Run ganache."""
+ cmd_line = (
+ "docker run -d -p 8545:8545 0xorg/ganache-cli:2.2.2"
+ ).split()
+ subprocess.call(cmd_line) # nosec
+
+
+class LaunchKitCommand(distutils.command.build_py.build_py):
+ """Custom command to boot up a local 0x-launch-kit in docker."""
+
+ description = "Run launch-kit daemon to support sra_client demos."
+
+ def run(self):
+ """Run 0x-launch-kit."""
+ cmd_line = ("docker run -d -p 3000:3000 0xorg/launch-kit-ci").split()
+ subprocess.call(cmd_line) # nosec
+
+
+class LintCommand(distutils.command.build_py.build_py):
+ """Custom setuptools command class for running linters."""
+
+ description = "Run linters"
+
+ def run(self):
+ """Run linter shell commands."""
+ lint_commands = [
+ # formatter:
+ "black --line-length 79 --check --diff test sra_client/__init__.py setup.py".split(), # noqa: E501 (line too long)
+ # style guide checker (formerly pep8):
+ "pycodestyle test sra_client/__init__.py setup.py".split(),
+ # docstring style checker:
+ "pydocstyle src test sra_client/__init__.py setup.py".split(),
+ # static type checker:
+ "bandit -r test sra_client/__init__.py setup.py".split(),
+ # general linter:
+ "pylint test sra_client/__init__.py setup.py".split(),
+ # pylint takes relatively long to run, so it runs last, to enable
+ # fast failures.
+ ]
+
+ for lint_command in lint_commands:
+ print(
+ "Running lint command `", " ".join(lint_command).strip(), "`"
+ )
+ subprocess.check_call(lint_command) # nosec
+
+
class PublishCommand(distutils.command.build_py.build_py):
"""Custom command to publish to pypi.org."""
@@ -48,13 +114,17 @@ class PublishCommand(distutils.command.build_py.build_py):
subprocess.check_call("twine upload dist/*".split()) # nosec
-class LintCommand(distutils.command.build_py.build_py):
- """No-op lint command to support top-level lint script."""
+class PublishDocsCommand(distutils.command.build_py.build_py):
+ """Custom command to publish docs to S3."""
- description = "No-op"
+ description = (
+ "Publish docs to "
+ + "http://0x-sra-demos-py.s3-website-us-east-1.amazonaws.com/"
+ )
def run(self):
- pass
+ """Run npm package `discharge` to build & upload docs."""
+ subprocess.check_call("discharge deploy".split()) # nosec
setup(
@@ -72,6 +142,33 @@ setup(
cmdclass={
"test_publish": TestPublishCommand,
"publish": PublishCommand,
+ "launch_kit": LaunchKitCommand,
"lint": LintCommand,
+ "publish_docs": PublishDocsCommand,
+ "test": TestCommandExtension,
+ "ganache": GanacheCommand,
+ },
+ extras_require={
+ "dev": [
+ "0x-contract-addresses",
+ "0x-order-utils",
+ "0x-web3",
+ "bandit",
+ "black",
+ "coverage",
+ "coveralls",
+ "pycodestyle",
+ "pydocstyle",
+ "pylint",
+ "pytest",
+ "sphinx",
+ "sphinx-autodoc-typehints",
+ ]
+ },
+ command_options={
+ "build_sphinx": {
+ "source_dir": ("setup.py", "."),
+ "build_dir": ("setup.py", "build/docs"),
+ }
},
)
diff --git a/python-packages/sra_client/sra_client/__init__.py b/python-packages/sra_client/sra_client/__init__.py
index fc02976a57..8f8bb79e8c 100644
--- a/python-packages/sra_client/sra_client/__init__.py
+++ b/python-packages/sra_client/sra_client/__init__.py
@@ -2,6 +2,167 @@
# flake8: noqa
+"""Python api client to interact with SRA compatible 0x relayers.
+
+0x Protocol is an open standard. Many relayers opt-in to implementing a set of
+`standard relayer API endpoints `_
+to make it easier for anyone to source liquidity that conforms to the 0x order format.
+Here, we will show you how you can use our `sra_client
+`_
+module to interact with 0x relayers that implements the Standard Relayer API.
+
+Setup
+=====
+Install the sra-client package with pip:
+
+`pip install 0x-sra-client`:code:
+
+To interact with a 0x Relayer, you need the HTTP endpoint of the Relayer you'd like to
+connect to (i.e. https://api.radarrelay.com/0x/v2).
+
+For local testing one can use the `0x-launch-kit
+`_
+to host orders locally. For convenience, a docker container is provided
+for just this purpose. To start it:
+
+`docker run -d -p 3000:3000 0xorg/launch-kit-ci`:code:
+
+and then connect to the http server running at http://localhost:3000.
+
+----
+
+Configure and create an API client instance
+--------------------------------------------
+
+>>> from sra_client import ApiClient, Configuration
+>>> from sra_client.api import DefaultApi
+>>> config = Configuration()
+>>> config.host = "http://localhost:3000"
+>>> relayer_api = DefaultApi(ApiClient(config))
+
+Post Order
+-----------
+Post an order to an SRA-compliant Relayer.
+
+>>> from web3 import HTTPProvider, Web3
+>>> from zero_ex.contract_addresses import (
+... NETWORK_TO_ADDRESSES, NetworkId)
+>>> from zero_ex.order_utils import (
+... asset_data_utils,
+... generate_order_hash_hex,
+... jsdict_order_to_struct,
+... sign_hash)
+>>> provider = HTTPProvider("http://localhost:8545")
+>>> maker_address = "0x5409ed021d9299bf6814279a6a1411a7e866a631"
+>>> exchange_address = NETWORK_TO_ADDRESSES[NetworkId.KOVAN].exchange
+>>> weth_address = NETWORK_TO_ADDRESSES[NetworkId.KOVAN].ether_token
+>>> zrx_address = NETWORK_TO_ADDRESSES[NetworkId.KOVAN].zrx_token
+>>> weth_asset_data = asset_data_utils.encode_erc20_asset_data(weth_address)
+>>> zrx_asset_data = asset_data_utils.encode_erc20_asset_data(zrx_address)
+>>> example_order = {
+... "makerAddress": maker_address,
+... "takerAddress": "0x0000000000000000000000000000000000000000",
+... "senderAddress": "0x0000000000000000000000000000000000000000",
+... "exchangeAddress": exchange_address,
+... "feeRecipientAddress":
+... "0x0000000000000000000000000000000000000000",
+... "makerAssetData": weth_asset_data,
+... "takerAssetData": zrx_asset_data,
+... "salt": "2362734632784682376287462",
+... "makerFee": "0",
+... "takerFee": "0",
+... "makerAssetAmount": "1000000000000000000",
+... "takerAssetAmount": "500000000000000000000",
+... "expirationTimeSeconds": "999999999999999999999"}
+>>> order_hash = generate_order_hash_hex(
+... jsdict_order_to_struct(example_order), exchange_address)
+>>> example_order["signature"] = sign_hash(
+... provider, Web3.toChecksumAddress(maker_address), order_hash)
+>>> relayer_api.post_order_with_http_info(
+... network_id=42, signed_order_schema=example_order)[1]
+200
+
+Get Orders
+-----------
+Get orders from an SRA-compliant Relayer.
+
+>>> relayer_api.get_orders()
+{'records': [{'meta_data': {},
+ 'order': {'exchange_address': '0x35dd2932454449b14cee11a94d3674a936d5d7b2',
+ 'expiration_time_seconds': '1000000000000000000000',
+ 'fee_recipient_address': '0x0000000000000000000000000000000000000000',
+ 'maker_address': '0x5409ed021d9299bf6814279a6a1411a7e866a631',
+ 'maker_asset_amount': '1000000000000000000',
+ 'maker_asset_data': '0xf47261b0000000000000000000000000d0a1e359811322d97991e03f863a0c30c2cf029c',
+ 'maker_fee': '0',
+ 'salt': '2362734632784682376287462',
+ 'sender_address': '0x0000000000000000000000000000000000000000',
+ 'taker_address': '0x0000000000000000000000000000000000000000',
+ 'taker_asset_amount': '500000000000000000000',
+ 'taker_asset_data': '0xf47261b00000000000000000000000002002d3812f58e35f0ea1ffbf80a75a38c32175fa',
+ 'taker_fee': '0'}}]}
+
+Get Order
+---------
+Get an order by hash from an SRA-compliant Relayer.
+
+>>> relayer_api.get_order(order_hash) # doctest: +SKIP
+{'meta_data': {},
+'order': {'exchange_address': '0x35dd2932454449b14cee11a94d3674a936d5d7b2',
+ 'expiration_time_seconds': '1000000000000000000000',
+ 'fee_recipient_address': '0x0000000000000000000000000000000000000000',
+ 'maker_address': '0x5409ed021d9299bf6814279a6a1411a7e866a631',
+ 'maker_asset_amount': '1000000000000000000',
+ 'maker_asset_data': '0xf47261b0000000000000000000000000d0a1e359811322d97991e03f863a0c30c2cf029c',
+ 'maker_fee': '0',
+ 'salt': '2362734632784682376287462',
+ 'sender_address': '0x0000000000000000000000000000000000000000',
+ 'taker_address': '0x0000000000000000000000000000000000000000',
+ 'taker_asset_amount': '500000000000000000000',
+ 'taker_asset_data': '0xf47261b00000000000000000000000002002d3812f58e35f0ea1ffbf80a75a38c32175fa',
+ 'taker_fee': '0'}},
+
+Get Asset Pair
+---------------
+Get available asset pairs from an SRA-compliant Relayer.
+
+>>> relayer_api.get_asset_pairs()
+{'records': [{'assetDataA': {'assetData': '0xf47261b0000000000000000000000000d0a1e359811322d97991e03f863a0c30c2cf029c',
+ 'maxAmount': '115792089237316195423570985008687907853269984665640564039457584007913129639936',
+ 'minAmount': '0',
+ 'precision': 18},
+ 'assetDataB': {'assetData': '0xf47261b00000000000000000000000002002d3812f58e35f0ea1ffbf80a75a38c32175fa',
+ 'maxAmount': '115792089237316195423570985008687907853269984665640564039457584007913129639936',
+ 'minAmount': '0',
+ 'precision': 18}}]}
+
+Get Orderbook
+-------------
+Get the orderbook for the WETH/ZRX asset pair from an SRA-compliant Relayer.
+
+>>> relayer_api.get_orderbook(
+... base_asset_data=weth_asset_data,
+... quote_asset_data=zrx_asset_data)
+{'asks': {'records': [{'meta_data': {},
+ 'order': {'exchange_address': '0x35dd2932454449b14cee11a94d3674a936d5d7b2',
+ 'expiration_time_seconds': '1000000000000000000000',
+ 'fee_recipient_address': '0x0000000000000000000000000000000000000000',
+ 'maker_address': '0x5409ed021d9299bf6814279a6a1411a7e866a631',
+ 'maker_asset_amount': '1000000000000000000',
+ 'maker_asset_data': '0xf47261b0000000000000000000000000d0a1e359811322d97991e03f863a0c30c2cf029c',
+ 'maker_fee': '0',
+ 'salt': '2362734632784682376287462',
+ 'sender_address': '0x0000000000000000000000000000000000000000',
+ 'taker_address': '0x0000000000000000000000000000000000000000',
+ 'taker_asset_amount': '500000000000000000000',
+ 'taker_asset_data': '0xf47261b00000000000000000000000002002d3812f58e35f0ea1ffbf80a75a38c32175fa',
+ 'taker_fee': '0'}}]},
+ 'bids': {'records': []}}
+""" # noqa: E501 (line too long)
+
+# NOTE: Bug in get_order method.
+# Sra_client not deserialzing order from server properly, need fix!
+
from __future__ import absolute_import
@@ -28,7 +189,7 @@ from sra_client.models.relayer_api_asset_data_trade_info_schema import (
from sra_client.models.relayer_api_error_response_schema import (
RelayerApiErrorResponseSchema,
)
-from sra_client.models.relayer_api_error_response_schema_validation_errors import (
+from sra_client.models.relayer_api_error_response_schema_validation_errors import ( # noqa: E501 (line too long)
RelayerApiErrorResponseSchemaValidationErrors,
)
from sra_client.models.relayer_api_fee_recipients_response_schema import (
@@ -44,7 +205,7 @@ from sra_client.models.relayer_api_order_schema import RelayerApiOrderSchema
from sra_client.models.relayer_api_orderbook_response_schema import (
RelayerApiOrderbookResponseSchema,
)
-from sra_client.models.relayer_api_orders_channel_subscribe_payload_schema import (
+from sra_client.models.relayer_api_orders_channel_subscribe_payload_schema import ( # noqa: E501 (line too long)
RelayerApiOrdersChannelSubscribePayloadSchema,
)
from sra_client.models.relayer_api_orders_channel_subscribe_schema import (
diff --git a/python-packages/sra_client/sra_client/api/default_api.py b/python-packages/sra_client/sra_client/api/default_api.py
index 2d65db6095..4e1fac032b 100644
--- a/python-packages/sra_client/sra_client/api/default_api.py
+++ b/python-packages/sra_client/sra_client/api/default_api.py
@@ -9,66 +9,74 @@ import re # noqa: F401
import six
from sra_client.api_client import ApiClient
+from sra_client.models.relayer_api_order_config_payload_schema import (
+ RelayerApiOrderConfigPayloadSchema,
+)
class DefaultApi(object):
- """NOTE: This class is auto generated by OpenAPI Generator
- Ref: https://openapi-generator.tech
+ """Default API for SRA compliant 0x relayers."""
- Do not edit the class manually.
- """
+ # NOTE: This class is auto generated by OpenAPI Generator
+ # Ref: https://openapi-generator.tech
+
+ # Do not edit the class manually.
def __init__(self, api_client=None):
if api_client is None:
api_client = ApiClient()
self.api_client = api_client
- def get_asset_pairs(self, **kwargs): # noqa: E501
- """get_asset_pairs # noqa: E501
+ def get_asset_pairs(self, **kwargs):
+ """get_asset_pairs
- Retrieves a list of available asset pairs and the information required to trade them (in any order). Setting only `assetDataA` or `assetDataB` returns pairs filtered by that asset only. # noqa: E501
+ Retrieves a list of available asset pairs and the information
+ required to trade them (in any order). Setting only `assetDataA` or
+ `assetDataB` returns pairs filtered by that asset only.
This method makes a synchronous HTTP request by default. To make an
- asynchronous HTTP request, please pass async_req=True
- >>> thread = api.get_asset_pairs(async_req=True)
- >>> result = thread.get()
+ asynchronous HTTP request, please pass `async_req` = **True**
- :param async_req bool
+ >>> thread = api.get_asset_pairs(async_req=True) # doctest: +SKIP
+ >>> result = thread.get() # doctest: +SKIP
+
+ :param bool async_req: Whether request should be asynchronous.
:param str asset_data_a: The assetData value for the first asset in the pair.
:param str asset_data_b: The assetData value for the second asset in the pair.
:param float network_id: The id of the Ethereum network
:param float page: The number of the page to request in the collection.
:param float per_page: The number of records to return per page.
- :return: RelayerApiAssetDataPairsResponseSchema
- If the method is called asynchronously,
- returns the request thread.
+
+ :return: :class:`RelayerApiAssetDataPairsResponseSchema`.
+ If the method is called asynchronously returns the request thread.
"""
kwargs["_return_http_data_only"] = True
if kwargs.get("async_req"):
- return self.get_asset_pairs_with_http_info(**kwargs) # noqa: E501
+ return self.get_asset_pairs_with_http_info(**kwargs)
else:
- (data) = self.get_asset_pairs_with_http_info(
- **kwargs
- ) # noqa: E501
+ (data) = self.get_asset_pairs_with_http_info(**kwargs)
return data
- def get_asset_pairs_with_http_info(self, **kwargs): # noqa: E501
- """get_asset_pairs # noqa: E501
+ def get_asset_pairs_with_http_info(self, **kwargs):
+ """get_asset_pairs
- Retrieves a list of available asset pairs and the information required to trade them (in any order). Setting only `assetDataA` or `assetDataB` returns pairs filtered by that asset only. # noqa: E501
+ Retrieves a list of available asset pairs and the information
+ required to trade them (in any order). Setting only `assetDataA` or
+ `assetDataB` returns pairs filtered by that asset only.
This method makes a synchronous HTTP request by default. To make an
- asynchronous HTTP request, please pass async_req=True
- >>> thread = api.get_asset_pairs_with_http_info(async_req=True)
- >>> result = thread.get()
+ asynchronous HTTP request, please pass `async_req` = **True**
- :param async_req bool
+ >>> thread = api.get_asset_pairs_with_http_info(async_req=True) # doctest: +SKIP
+ >>> result = thread.get() # doctest: +SKIP
+
+ :param bool async_req: Whether request should be asynchronous.
:param str asset_data_a: The assetData value for the first asset in the pair.
:param str asset_data_b: The assetData value for the second asset in the pair.
:param float network_id: The id of the Ethereum network
:param float page: The number of the page to request in the collection.
:param float per_page: The number of records to return per page.
- :return: RelayerApiAssetDataPairsResponseSchema
- If the method is called asynchronously,
- returns the request thread.
+
+ :return: :class:`RelayerApiAssetDataPairsResponseSchema`.
+ If the method is called asynchronously returns the request thread.
"""
local_var_params = locals()
@@ -79,7 +87,7 @@ class DefaultApi(object):
"network_id",
"page",
"per_page",
- ] # noqa: E501
+ ]
all_params.append("async_req")
all_params.append("_return_http_data_only")
all_params.append("_preload_content")
@@ -102,23 +110,17 @@ class DefaultApi(object):
if "asset_data_a" in local_var_params:
query_params.append(
("assetDataA", local_var_params["asset_data_a"])
- ) # noqa: E501
+ )
if "asset_data_b" in local_var_params:
query_params.append(
("assetDataB", local_var_params["asset_data_b"])
- ) # noqa: E501
+ )
if "network_id" in local_var_params:
- query_params.append(
- ("networkId", local_var_params["network_id"])
- ) # noqa: E501
+ query_params.append(("networkId", local_var_params["network_id"]))
if "page" in local_var_params:
- query_params.append(
- ("page", local_var_params["page"])
- ) # noqa: E501
+ query_params.append(("page", local_var_params["page"]))
if "per_page" in local_var_params:
- query_params.append(
- ("perPage", local_var_params["per_page"])
- ) # noqa: E501
+ query_params.append(("perPage", local_var_params["per_page"]))
header_params = {}
@@ -129,10 +131,10 @@ class DefaultApi(object):
# HTTP header `Accept`
header_params["Accept"] = self.api_client.select_header_accept(
["application/json"]
- ) # noqa: E501
+ )
# Authentication setting
- auth_settings = [] # noqa: E501
+ auth_settings = []
return self.api_client.call_api(
"/v2/asset_pairs",
@@ -143,66 +145,66 @@ class DefaultApi(object):
body=body_params,
post_params=form_params,
files=local_var_files,
- response_type="RelayerApiAssetDataPairsResponseSchema", # noqa: E501
+ response_type="RelayerApiAssetDataPairsResponseSchema",
auth_settings=auth_settings,
async_req=local_var_params.get("async_req"),
_return_http_data_only=local_var_params.get(
"_return_http_data_only"
- ), # noqa: E501
+ ),
_preload_content=local_var_params.get("_preload_content", True),
_request_timeout=local_var_params.get("_request_timeout"),
collection_formats=collection_formats,
)
- def get_fee_recipients(self, **kwargs): # noqa: E501
- """get_fee_recipients # noqa: E501
+ def get_fee_recipients(self, **kwargs):
+ """get_fee_recipients
- Retrieves a collection of all fee recipient addresses for a relayer. This endpoint should be [paginated](#section/Pagination). # noqa: E501
+ Retrieves a collection of all fee recipient addresses for a relayer.
+ This endpoint should be paginated.
This method makes a synchronous HTTP request by default. To make an
- asynchronous HTTP request, please pass async_req=True
- >>> thread = api.get_fee_recipients(async_req=True)
- >>> result = thread.get()
+ asynchronous HTTP request, please pass `async_req` = **True**
- :param async_req bool
+ >>> thread = api.get_fee_recipients(async_req=True) # doctest: +SKIP
+ >>> result = thread.get() # doctest: +SKIP
+
+ :param bool async_req: Whether request should be asynchronous.
:param float network_id: The id of the Ethereum network
:param float page: The number of the page to request in the collection.
:param float per_page: The number of records to return per page.
- :return: RelayerApiFeeRecipientsResponseSchema
- If the method is called asynchronously,
- returns the request thread.
+
+ :return: :class:`RelayerApiFeeRecipientsResponseSchema`.
+ If the method is called asynchronously, returns the request thread.
"""
kwargs["_return_http_data_only"] = True
if kwargs.get("async_req"):
- return self.get_fee_recipients_with_http_info(
- **kwargs
- ) # noqa: E501
+ return self.get_fee_recipients_with_http_info(**kwargs)
else:
- (data) = self.get_fee_recipients_with_http_info(
- **kwargs
- ) # noqa: E501
+ (data) = self.get_fee_recipients_with_http_info(**kwargs)
return data
- def get_fee_recipients_with_http_info(self, **kwargs): # noqa: E501
- """get_fee_recipients # noqa: E501
+ def get_fee_recipients_with_http_info(self, **kwargs):
+ """get_fee_recipients
- Retrieves a collection of all fee recipient addresses for a relayer. This endpoint should be [paginated](#section/Pagination). # noqa: E501
+ Retrieves a collection of all fee recipient addresses for a relayer.
+ This endpoint should be paginated.
This method makes a synchronous HTTP request by default. To make an
- asynchronous HTTP request, please pass async_req=True
- >>> thread = api.get_fee_recipients_with_http_info(async_req=True)
- >>> result = thread.get()
+ asynchronous HTTP request, please pass `async_req` = **True**
- :param async_req bool
+ >>> thread = api.get_fee_recipients_with_http_info(async_req=True) # doctest: +SKIP
+ >>> result = thread.get() # doctest: +SKIP
+
+ :param bool async_req: Whether request should be asynchronous.
:param float network_id: The id of the Ethereum network
:param float page: The number of the page to request in the collection.
:param float per_page: The number of records to return per page.
- :return: RelayerApiFeeRecipientsResponseSchema
- If the method is called asynchronously,
- returns the request thread.
+
+ :return: :class:`RelayerApiFeeRecipientsResponseSchema`.
+ If the method is called asynchronously, returns the request thread.
"""
local_var_params = locals()
- all_params = ["network_id", "page", "per_page"] # noqa: E501
+ all_params = ["network_id", "page", "per_page"]
all_params.append("async_req")
all_params.append("_return_http_data_only")
all_params.append("_preload_content")
@@ -223,17 +225,11 @@ class DefaultApi(object):
query_params = []
if "network_id" in local_var_params:
- query_params.append(
- ("networkId", local_var_params["network_id"])
- ) # noqa: E501
+ query_params.append(("networkId", local_var_params["network_id"]))
if "page" in local_var_params:
- query_params.append(
- ("page", local_var_params["page"])
- ) # noqa: E501
+ query_params.append(("page", local_var_params["page"]))
if "per_page" in local_var_params:
- query_params.append(
- ("perPage", local_var_params["per_page"])
- ) # noqa: E501
+ query_params.append(("perPage", local_var_params["per_page"]))
header_params = {}
@@ -244,10 +240,10 @@ class DefaultApi(object):
# HTTP header `Accept`
header_params["Accept"] = self.api_client.select_header_accept(
["application/json"]
- ) # noqa: E501
+ )
# Authentication setting
- auth_settings = [] # noqa: E501
+ auth_settings = []
return self.api_client.call_api(
"/v2/fee_recipients",
@@ -258,64 +254,62 @@ class DefaultApi(object):
body=body_params,
post_params=form_params,
files=local_var_files,
- response_type="RelayerApiFeeRecipientsResponseSchema", # noqa: E501
+ response_type="RelayerApiFeeRecipientsResponseSchema",
auth_settings=auth_settings,
async_req=local_var_params.get("async_req"),
_return_http_data_only=local_var_params.get(
"_return_http_data_only"
- ), # noqa: E501
+ ),
_preload_content=local_var_params.get("_preload_content", True),
_request_timeout=local_var_params.get("_request_timeout"),
collection_formats=collection_formats,
)
- def get_order(self, order_hash, **kwargs): # noqa: E501
- """get_order # noqa: E501
+ def get_order(self, order_hash, **kwargs):
+ """get_order
- Retrieves the 0x order with meta info that is associated with the hash. # noqa: E501
+ Retrieves the 0x order with meta info that is associated with the hash.
This method makes a synchronous HTTP request by default. To make an
- asynchronous HTTP request, please pass async_req=True
- >>> thread = api.get_order(order_hash, async_req=True)
- >>> result = thread.get()
+ asynchronous HTTP request, please pass `async_req` = **True**
- :param async_req bool
+ >>> thread = api.get_order(async_req=True) # doctest: +SKIP
+ >>> result = thread.get() # doctest: +SKIP
+
+ :param bool async_req: Whether request should be asynchronous.
:param str order_hash: The hash of the desired 0x order. (required)
:param float network_id: The id of the Ethereum network
- :return: RelayerApiOrderSchema
- If the method is called asynchronously,
- returns the request thread.
+
+ :return: :class:`RelayerApiOrderSchema`.
+ If the method is called asynchronously, returns the request thread.
"""
kwargs["_return_http_data_only"] = True
if kwargs.get("async_req"):
- return self.get_order_with_http_info(
- order_hash, **kwargs
- ) # noqa: E501
+ return self.get_order_with_http_info(order_hash, **kwargs)
else:
- (data) = self.get_order_with_http_info(
- order_hash, **kwargs
- ) # noqa: E501
+ (data) = self.get_order_with_http_info(order_hash, **kwargs)
return data
- def get_order_with_http_info(self, order_hash, **kwargs): # noqa: E501
- """get_order # noqa: E501
+ def get_order_with_http_info(self, order_hash, **kwargs):
+ """get_order
- Retrieves the 0x order with meta info that is associated with the hash. # noqa: E501
+ Retrieves the 0x order with meta info that is associated with the hash.
This method makes a synchronous HTTP request by default. To make an
- asynchronous HTTP request, please pass async_req=True
- >>> thread = api.get_order_with_http_info(order_hash, async_req=True)
- >>> result = thread.get()
+ asynchronous HTTP request, please pass `async_req` = **True**
- :param async_req bool
+ >>> thread = api.get_order_with_http_info(async_req=True) # doctest: +SKIP
+ >>> result = thread.get() # doctest: +SKIP
+
+ :param bool async_req: Whether request should be asynchronous.
:param str order_hash: The hash of the desired 0x order. (required)
:param float network_id: The id of the Ethereum network
- :return: RelayerApiOrderSchema
- If the method is called asynchronously,
- returns the request thread.
+
+ :return: :class:`RelayerApiOrderSchema`.
+ If the method is called asynchronously returns the request thread.
"""
local_var_params = locals()
- all_params = ["order_hash", "network_id"] # noqa: E501
+ all_params = ["order_hash", "network_id"]
all_params.append("async_req")
all_params.append("_return_http_data_only")
all_params.append("_preload_content")
@@ -336,21 +330,17 @@ class DefaultApi(object):
):
raise ValueError(
"Missing the required parameter `order_hash` when calling `get_order`"
- ) # noqa: E501
+ )
collection_formats = {}
path_params = {}
if "order_hash" in local_var_params:
- path_params["orderHash"] = local_var_params[
- "order_hash"
- ] # noqa: E501
+ path_params["orderHash"] = local_var_params["order_hash"]
query_params = []
if "network_id" in local_var_params:
- query_params.append(
- ("networkId", local_var_params["network_id"])
- ) # noqa: E501
+ query_params.append(("networkId", local_var_params["network_id"]))
header_params = {}
@@ -361,10 +351,10 @@ class DefaultApi(object):
# HTTP header `Accept`
header_params["Accept"] = self.api_client.select_header_accept(
["application/json"]
- ) # noqa: E501
+ )
# Authentication setting
- auth_settings = [] # noqa: E501
+ auth_settings = []
return self.api_client.call_api(
"/v2/order/{orderHash}",
@@ -375,65 +365,84 @@ class DefaultApi(object):
body=body_params,
post_params=form_params,
files=local_var_files,
- response_type="RelayerApiOrderSchema", # noqa: E501
+ response_type="RelayerApiOrderSchema",
auth_settings=auth_settings,
async_req=local_var_params.get("async_req"),
_return_http_data_only=local_var_params.get(
"_return_http_data_only"
- ), # noqa: E501
+ ),
_preload_content=local_var_params.get("_preload_content", True),
_request_timeout=local_var_params.get("_request_timeout"),
collection_formats=collection_formats,
)
- def get_order_config(self, **kwargs): # noqa: E501
- """get_order_config # noqa: E501
+ def get_order_config(self, **kwargs):
+ """get_order_config
- Relayers have full discretion over the orders that they are willing to host on their orderbooks (e.g what fees they charge, etc...). In order for traders to discover their requirements programmatically, they can send an incomplete order to this endpoint and receive the missing fields, specifc to that order. This gives relayers a large amount of flexibility to tailor fees to unique traders, trading pairs and volume amounts. Submit a partial order and receive information required to complete the order: `senderAddress`, `feeRecipientAddress`, `makerFee`, `takerFee`. # noqa: E501
+ Relayers have full discretion over the orders that they are willing
+ to host on their orderbooks (e.g what fees they charge, etc...). In
+ order for traders to discover their requirements programmatically,
+ they can send an incomplete order to this endpoint and receive the
+ missing fields, specifc to that order. This gives relayers a large
+ amount of flexibility to tailor fees to unique traders, trading pairs
+ and volume amounts. Submit a partial order and receive information
+ required to complete the order: `senderAddress`,
+ `feeRecipientAddress`, `makerFee`, `takerFee`.
This method makes a synchronous HTTP request by default. To make an
- asynchronous HTTP request, please pass async_req=True
- >>> thread = api.get_order_config(async_req=True)
- >>> result = thread.get()
+ asynchronous HTTP request, please pass `async_req` = **True**
- :param async_req bool
+ >>> thread = api.get_order_config(async_req=True) # doctest: +SKIP
+ >>> result = thread.get() # doctest: +SKIP
+
+ :param bool async_req: Whether request should be asynchronous.
:param float network_id: The id of the Ethereum network
- :param RelayerApiOrderConfigPayloadSchema relayer_api_order_config_payload_schema: The fields of a 0x order the relayer may want to decide what configuration to send back.
- :return: RelayerApiOrderConfigResponseSchema
- If the method is called asynchronously,
- returns the request thread.
+ :param relayer_api_order_config_payload_schema: instance of
+ :class:`RelayerApiOrderConfigPayloadSchema`. The fields of a 0x
+ order the relayer may want to decide what configuration to send
+ back.
+
+ :return: :class:`RelayerApiOrderConfigResponseSchema`.
+ If the method is called asynchronously returns the request thread.
"""
kwargs["_return_http_data_only"] = True
if kwargs.get("async_req"):
- return self.get_order_config_with_http_info(**kwargs) # noqa: E501
+ return self.get_order_config_with_http_info(**kwargs)
else:
- (data) = self.get_order_config_with_http_info(
- **kwargs
- ) # noqa: E501
+ (data) = self.get_order_config_with_http_info(**kwargs)
return data
- def get_order_config_with_http_info(self, **kwargs): # noqa: E501
- """get_order_config # noqa: E501
+ def get_order_config_with_http_info(self, **kwargs):
+ """get_order_config
- Relayers have full discretion over the orders that they are willing to host on their orderbooks (e.g what fees they charge, etc...). In order for traders to discover their requirements programmatically, they can send an incomplete order to this endpoint and receive the missing fields, specifc to that order. This gives relayers a large amount of flexibility to tailor fees to unique traders, trading pairs and volume amounts. Submit a partial order and receive information required to complete the order: `senderAddress`, `feeRecipientAddress`, `makerFee`, `takerFee`. # noqa: E501
+ Relayers have full discretion over the orders that they are willing
+ to host on their orderbooks (e.g what fees they charge, etc...). In
+ order for traders to discover their requirements programmatically,
+ they can send an incomplete order to this endpoint and receive the
+ missing fields, specifc to that order. This gives relayers a large
+ amount of flexibility to tailor fees to unique traders, trading pairs
+ and volume amounts. Submit a partial order and receive information
+ required to complete the order: `senderAddress`,
+ `feeRecipientAddress`, `makerFee`, `takerFee`.
This method makes a synchronous HTTP request by default. To make an
- asynchronous HTTP request, please pass async_req=True
- >>> thread = api.get_order_config_with_http_info(async_req=True)
- >>> result = thread.get()
+ asynchronous HTTP request, please pass `async_req` = **True**
- :param async_req bool
+ >>> thread = api.get_order_config_with_http_info(async_req=True) # doctest: +SKIP
+ >>> result = thread.get() # doctest: +SKIP
+
+ :param bool async_req: Whether request should be asynchronous.
:param float network_id: The id of the Ethereum network
- :param RelayerApiOrderConfigPayloadSchema relayer_api_order_config_payload_schema: The fields of a 0x order the relayer may want to decide what configuration to send back.
- :return: RelayerApiOrderConfigResponseSchema
- If the method is called asynchronously,
- returns the request thread.
+ :param relayer_api_order_config_payload_schema: instance of
+ :class: `RelayerApiOrderConfigPayloadSchema`. The fields of a 0x
+ order the relayer may want to decide what configuration to send
+ back.
+
+ :return: :class:`RelayerApiOrderConfigResponseSchema`.
+ If the method is called asynchronously returns the request thread.
"""
local_var_params = locals()
- all_params = [
- "network_id",
- "relayer_api_order_config_payload_schema",
- ] # noqa: E501
+ all_params = ["network_id", "relayer_api_order_config_payload_schema"]
all_params.append("async_req")
all_params.append("_return_http_data_only")
all_params.append("_preload_content")
@@ -454,9 +463,7 @@ class DefaultApi(object):
query_params = []
if "network_id" in local_var_params:
- query_params.append(
- ("networkId", local_var_params["network_id"])
- ) # noqa: E501
+ query_params.append(("networkId", local_var_params["network_id"]))
header_params = {}
@@ -471,17 +478,15 @@ class DefaultApi(object):
# HTTP header `Accept`
header_params["Accept"] = self.api_client.select_header_accept(
["application/json"]
- ) # noqa: E501
+ )
# HTTP header `Content-Type`
header_params[
"Content-Type"
- ] = self.api_client.select_header_content_type( # noqa: E501
- ["application/json"]
- ) # noqa: E501
+ ] = self.api_client.select_header_content_type(["application/json"])
# Authentication setting
- auth_settings = [] # noqa: E501
+ auth_settings = []
return self.api_client.call_api(
"/v2/order_config",
@@ -492,69 +497,101 @@ class DefaultApi(object):
body=body_params,
post_params=form_params,
files=local_var_files,
- response_type="RelayerApiOrderConfigResponseSchema", # noqa: E501
+ response_type="RelayerApiOrderConfigResponseSchema",
auth_settings=auth_settings,
async_req=local_var_params.get("async_req"),
_return_http_data_only=local_var_params.get(
"_return_http_data_only"
- ), # noqa: E501
+ ),
_preload_content=local_var_params.get("_preload_content", True),
_request_timeout=local_var_params.get("_request_timeout"),
collection_formats=collection_formats,
)
- def get_orderbook(
- self, base_asset_data, quote_asset_data, **kwargs
- ): # noqa: E501
- """get_orderbook # noqa: E501
+ def get_orderbook(self, base_asset_data, quote_asset_data, **kwargs):
+ """get_orderbook
- Retrieves the orderbook for a given asset pair. This endpoint should be [paginated](#section/Pagination). Bids will be sorted in descending order by price, and asks will be sorted in ascending order by price. Within the price sorted orders, the orders are further sorted by _taker fee price_ which is defined as the **takerFee** divided by **takerTokenAmount**. After _taker fee price_, orders are to be sorted by expiration in ascending order. The way pagination works for this endpoint is that the **page** and **perPage** query params apply to both `bids` and `asks` collections, and if `page` * `perPage` > `total` for a certain collection, the `records` for that collection should just be empty. # noqa: E501
+ Retrieves the orderbook for a given asset pair. This endpoint should
+ be paginated. Bids will be sorted in
+ descending order by price, and asks will be sorted in ascending order
+ by price. Within the price sorted orders, the orders are further
+ sorted by **taker fee price** which is defined as the **takerFee**
+ divided by **takerTokenAmount**. After **taker fee price**, orders are
+ to be sorted by expiration in ascending order. The way pagination
+ works for this endpoint is that the **page** and **perPage** query
+ params apply to both `bids` and `asks` collections, and if `page` *
+ `perPage` = `total` for a certain collection, the `records` for that
+ collection should just be empty.
This method makes a synchronous HTTP request by default. To make an
- asynchronous HTTP request, please pass async_req=True
- >>> thread = api.get_orderbook(base_asset_data, quote_asset_data, async_req=True)
- >>> result = thread.get()
+ asynchronous HTTP request, please pass `async_req` = **True**
- :param async_req bool
- :param str base_asset_data: assetData (makerAssetData or takerAssetData) designated as the base currency in the [currency pair calculation](https://en.wikipedia.org/wiki/Currency_pair) of price. (required)
- :param str quote_asset_data: assetData (makerAssetData or takerAssetData) designated as the quote currency in the currency pair calculation of price (required). (required)
+ >>> thread = api.get_orderbook(async_req=True) # doctest: +SKIP
+ >>> result = thread.get() # doctest: +SKIP
+
+ :param bool async_req: Whether request should be asynchronous.
+ :param str base_asset_data: assetData (makerAssetData or
+ takerAssetData) designated as the base currency in the
+ `currency pair calculation
+ `__
+ of price. (required)
+ :param str quote_asset_data: assetData (makerAssetData or
+ takerAssetData) designated as the quote currency in the currency
+ pair calculation of price. (required)
:param float network_id: The id of the Ethereum network
:param float page: The number of the page to request in the collection.
:param float per_page: The number of records to return per page.
- :return: RelayerApiOrderbookResponseSchema
- If the method is called asynchronously,
- returns the request thread.
+
+ :return: :class:`RelayerApiOrderbookResponseSchema`.
+ If the method is called asynchronously, returns the request thread.
"""
kwargs["_return_http_data_only"] = True
if kwargs.get("async_req"):
return self.get_orderbook_with_http_info(
base_asset_data, quote_asset_data, **kwargs
- ) # noqa: E501
+ )
else:
(data) = self.get_orderbook_with_http_info(
base_asset_data, quote_asset_data, **kwargs
- ) # noqa: E501
+ )
return data
def get_orderbook_with_http_info(
self, base_asset_data, quote_asset_data, **kwargs
- ): # noqa: E501
- """get_orderbook # noqa: E501
+ ):
+ """get_orderbook
- Retrieves the orderbook for a given asset pair. This endpoint should be [paginated](#section/Pagination). Bids will be sorted in descending order by price, and asks will be sorted in ascending order by price. Within the price sorted orders, the orders are further sorted by _taker fee price_ which is defined as the **takerFee** divided by **takerTokenAmount**. After _taker fee price_, orders are to be sorted by expiration in ascending order. The way pagination works for this endpoint is that the **page** and **perPage** query params apply to both `bids` and `asks` collections, and if `page` * `perPage` > `total` for a certain collection, the `records` for that collection should just be empty. # noqa: E501
+ Retrieves the orderbook for a given asset pair. This endpoint should
+ be paginated. Bids will be sorted in
+ descending order by price, and asks will be sorted in ascending order
+ by price. Within the price sorted orders, the orders are further
+ sorted by **taker fee price** which is defined as the **takerFee**
+ divided by **takerTokenAmount**. After **taker fee price**, orders are
+ to be sorted by expiration in ascending order. The way pagination
+ works for this endpoint is that the **page** and **perPage** query
+ params apply to both `bids` and `asks` collections, and if `page` *
+ `perPage` = `total` for a certain collection, the `records` for that
+ collection should just be empty.
This method makes a synchronous HTTP request by default. To make an
- asynchronous HTTP request, please pass async_req=True
- >>> thread = api.get_orderbook_with_http_info(base_asset_data, quote_asset_data, async_req=True)
- >>> result = thread.get()
+ asynchronous HTTP request, please pass `async_req` = **True**
- :param async_req bool
- :param str base_asset_data: assetData (makerAssetData or takerAssetData) designated as the base currency in the [currency pair calculation](https://en.wikipedia.org/wiki/Currency_pair) of price. (required)
- :param str quote_asset_data: assetData (makerAssetData or takerAssetData) designated as the quote currency in the currency pair calculation of price (required). (required)
+ >>> thread = api.get_orderbook_with_http_info(async_req=True) # doctest: +SKIP
+ >>> result = thread.get() # doctest: +SKIP
+
+ :param bool async_req: Whether request should be asynchronous.
+ :param str base_asset_data: assetData (makerAssetData or
+ takerAssetData) designated as the base currency in the
+ `currency pair calculation
+ `__
+ of price. (required)
+ :param str quote_asset_data: assetData (makerAssetData or
+ takerAssetData) designated as the quote currency in the currency
+ pair calculation of price. (required)
:param float network_id: The id of the Ethereum network
:param float page: The number of the page to request in the collection.
:param float per_page: The number of records to return per page.
- :return: RelayerApiOrderbookResponseSchema
- If the method is called asynchronously,
- returns the request thread.
+
+ :return: :class:`RelayerApiOrderbookResponseSchema`.
+ If the method is called asynchronously, returns the request thread.
"""
local_var_params = locals()
@@ -565,7 +602,7 @@ class DefaultApi(object):
"network_id",
"page",
"per_page",
- ] # noqa: E501
+ ]
all_params.append("async_req")
all_params.append("_return_http_data_only")
all_params.append("_preload_content")
@@ -585,16 +622,18 @@ class DefaultApi(object):
or local_var_params["base_asset_data"] is None
):
raise ValueError(
- "Missing the required parameter `base_asset_data` when calling `get_orderbook`"
- ) # noqa: E501
+ "Missing the required parameter `base_asset_data`"
+ "when calling `get_orderbook`"
+ )
# verify the required parameter 'quote_asset_data' is set
if (
"quote_asset_data" not in local_var_params
or local_var_params["quote_asset_data"] is None
):
raise ValueError(
- "Missing the required parameter `quote_asset_data` when calling `get_orderbook`"
- ) # noqa: E501
+ "Missing the required parameter `quote_asset_data`"
+ " when calling `get_orderbook`"
+ )
collection_formats = {}
@@ -604,23 +643,17 @@ class DefaultApi(object):
if "base_asset_data" in local_var_params:
query_params.append(
("baseAssetData", local_var_params["base_asset_data"])
- ) # noqa: E501
+ )
if "quote_asset_data" in local_var_params:
query_params.append(
("quoteAssetData", local_var_params["quote_asset_data"])
- ) # noqa: E501
+ )
if "network_id" in local_var_params:
- query_params.append(
- ("networkId", local_var_params["network_id"])
- ) # noqa: E501
+ query_params.append(("networkId", local_var_params["network_id"]))
if "page" in local_var_params:
- query_params.append(
- ("page", local_var_params["page"])
- ) # noqa: E501
+ query_params.append(("page", local_var_params["page"]))
if "per_page" in local_var_params:
- query_params.append(
- ("perPage", local_var_params["per_page"])
- ) # noqa: E501
+ query_params.append(("perPage", local_var_params["per_page"]))
header_params = {}
@@ -631,10 +664,10 @@ class DefaultApi(object):
# HTTP header `Accept`
header_params["Accept"] = self.api_client.select_header_accept(
["application/json"]
- ) # noqa: E501
+ )
# Authentication setting
- auth_settings = [] # noqa: E501
+ auth_settings = []
return self.api_client.call_api(
"/v2/orderbook",
@@ -645,83 +678,163 @@ class DefaultApi(object):
body=body_params,
post_params=form_params,
files=local_var_files,
- response_type="RelayerApiOrderbookResponseSchema", # noqa: E501
+ response_type="RelayerApiOrderbookResponseSchema",
auth_settings=auth_settings,
async_req=local_var_params.get("async_req"),
_return_http_data_only=local_var_params.get(
"_return_http_data_only"
- ), # noqa: E501
+ ),
_preload_content=local_var_params.get("_preload_content", True),
_request_timeout=local_var_params.get("_request_timeout"),
collection_formats=collection_formats,
)
- def get_orders(self, **kwargs): # noqa: E501
- """get_orders # noqa: E501
+ def get_orders(self, **kwargs):
+ """get_orders
- Retrieves a list of orders given query parameters. This endpoint should be [paginated](#section/Pagination). For querying an entire orderbook snapshot, the [orderbook endpoint](#operation/getOrderbook) is recommended. If both makerAssetData and takerAssetData are specified, returned orders will be sorted by price determined by (takerTokenAmount/makerTokenAmount) in ascending order. By default, orders returned by this endpoint are unsorted. # noqa: E501
+ Retrieves a list of orders given query parameters. This endpoint
+ should be paginated. For querying an entire
+ orderbook snapshot, the orderbook endpoint
+ is recommended. If both makerAssetData and takerAssetData are
+ specified, returned orders will be sorted by price determined by
+ (takerTokenAmount/makerTokenAmount) in ascending order. By default,
+ orders returned by this endpoint are unsorted.
This method makes a synchronous HTTP request by default. To make an
- asynchronous HTTP request, please pass async_req=True
- >>> thread = api.get_orders(async_req=True)
- >>> result = thread.get()
+ asynchronous HTTP request, please pass `async_req` = **True**
- :param async_req bool
- :param str maker_asset_proxy_id: The maker [asset proxy id](https://0xproject.com/docs/0x.js#types-AssetProxyId) (example: \"0xf47261b0\" for ERC20, \"0x02571792\" for ERC721).
- :param str taker_asset_proxy_id: The taker asset [asset proxy id](https://0xproject.com/docs/0x.js#types-AssetProxyId) (example: \"0xf47261b0\" for ERC20, \"0x02571792\" for ERC721).
+ >>> thread = api.get_orders(async_req=True) # doctest: +SKIP
+ >>> result = thread.get() # doctest: +SKIP
+
+ :param bool async_req: Whether request should be asynchronous.
+ :param str maker_asset_proxy_id: The maker
+ `asset proxy id
+ `__
+ (example: "0xf47261b0" for ERC20, "0x02571792" for ERC721).
+ :param str taker_asset_proxy_id: The taker asset
+ `asset proxy id
+ `__
+ (example: "0xf47261b0" for ERC20, "0x02571792" for ERC721).
:param str maker_asset_address: The contract address for the maker asset.
:param str taker_asset_address: The contract address for the taker asset.
- :param str exchange_address: Same as exchangeAddress in the [0x Protocol v2 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#order-message-format)
- :param str sender_address: Same as senderAddress in the [0x Protocol v2 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#order-message-format)
- :param str maker_asset_data: Same as makerAssetData in the [0x Protocol v2 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#order-message-format)
- :param str taker_asset_data: Same as takerAssetData in the [0x Protocol v2 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#order-message-format)
- :param str trader_asset_data: Same as traderAssetData in the [0x Protocol v2 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#order-message-format)
- :param str maker_address: Same as makerAddress in the [0x Protocol v2 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#order-message-format)
- :param str taker_address: Same as takerAddress in the [0x Protocol v2 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#order-message-format)
- :param str trader_address: Same as traderAddress in the [0x Protocol v2 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#order-message-format)
- :param str fee_recipient_address: Same as feeRecipientAddress in the [0x Protocol v2 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#order-message-format)
+ :param str exchange_address: Same as exchangeAddress in the
+ `0x Protocol v2 Specification
+ `__
+ :param str sender_address: Same as senderAddress in the
+ `0x Protocol v2 Specification
+ `__
+ :param str maker_asset_data: Same as makerAssetData in the
+ `0x Protocol v2 Specification
+ `__
+ :param str taker_asset_data: Same as takerAssetData in the
+ `0x Protocol v2 Specification
+ `__
+ :param str trader_asset_data: Same as traderAssetData in the [0x
+ `0x Protocol v2 Specification
+ `__
+ :param str maker_address: Same as makerAddress in the
+ `0x Protocol v2 Specification
+ `__
+ :param str taker_address: Same as takerAddress in the
+ `0x Protocol v2 Specification
+ `__
+ :param str trader_address: Same as traderAddress in the
+ `0x Protocol v2 Specification
+ `__
+ :param str fee_recipient_address: Same as feeRecipientAddress in the
+ `0x Protocol v2 Specification
+ `__
:param float network_id: The id of the Ethereum network
:param float page: The number of the page to request in the collection.
:param float per_page: The number of records to return per page.
- :return: RelayerApiOrdersResponseSchema
- If the method is called asynchronously,
- returns the request thread.
+
+ :return: :class:`RelayerApiOrdersResponseSchema`.
+ If the method is called asynchronously, returns the request thread.
"""
kwargs["_return_http_data_only"] = True
if kwargs.get("async_req"):
- return self.get_orders_with_http_info(**kwargs) # noqa: E501
+ return self.get_orders_with_http_info(**kwargs)
else:
- (data) = self.get_orders_with_http_info(**kwargs) # noqa: E501
+ (data) = self.get_orders_with_http_info(**kwargs)
return data
- def get_orders_with_http_info(self, **kwargs): # noqa: E501
- """get_orders # noqa: E501
+ def get_orders_with_http_info(self, **kwargs):
+ """get_orders
- Retrieves a list of orders given query parameters. This endpoint should be [paginated](#section/Pagination). For querying an entire orderbook snapshot, the [orderbook endpoint](#operation/getOrderbook) is recommended. If both makerAssetData and takerAssetData are specified, returned orders will be sorted by price determined by (takerTokenAmount/makerTokenAmount) in ascending order. By default, orders returned by this endpoint are unsorted. # noqa: E501
+ Retrieves a list of orders given query parameters. This endpoint
+ should be paginated. For querying an entire
+ orderbook snapshot, the orderbook endpoint
+ is recommended. If both makerAssetData and takerAssetData are
+ specified, returned orders will be sorted by price determined by
+ (takerTokenAmount/makerTokenAmount) in ascending order. By default,
+ orders returned by this endpoint are unsorted.
This method makes a synchronous HTTP request by default. To make an
- asynchronous HTTP request, please pass async_req=True
- >>> thread = api.get_orders_with_http_info(async_req=True)
- >>> result = thread.get()
+ asynchronous HTTP request, please pass `async_req` = **True**
- :param async_req bool
- :param str maker_asset_proxy_id: The maker [asset proxy id](https://0xproject.com/docs/0x.js#types-AssetProxyId) (example: \"0xf47261b0\" for ERC20, \"0x02571792\" for ERC721).
- :param str taker_asset_proxy_id: The taker asset [asset proxy id](https://0xproject.com/docs/0x.js#types-AssetProxyId) (example: \"0xf47261b0\" for ERC20, \"0x02571792\" for ERC721).
+ >>> thread = api.get_orders_with_http_info(async_req=True) # doctest: +SKIP
+ >>> result = thread.get() # doctest: +SKIP
+
+ :param bool async_req: Whether request should be asynchronous.
+ :param str maker_asset_proxy_id: The maker
+ `asset proxy id
+ `__
+ (example: "0xf47261b0" for ERC20, "0x02571792" for ERC721).
+ :param str taker_asset_proxy_id: The taker asset
+ `asset proxy id
+ `__
+ (example: "0xf47261b0" for ERC20, "0x02571792" for ERC721).
:param str maker_asset_address: The contract address for the maker asset.
:param str taker_asset_address: The contract address for the taker asset.
- :param str exchange_address: Same as exchangeAddress in the [0x Protocol v2 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#order-message-format)
- :param str sender_address: Same as senderAddress in the [0x Protocol v2 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#order-message-format)
- :param str maker_asset_data: Same as makerAssetData in the [0x Protocol v2 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#order-message-format)
- :param str taker_asset_data: Same as takerAssetData in the [0x Protocol v2 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#order-message-format)
- :param str trader_asset_data: Same as traderAssetData in the [0x Protocol v2 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#order-message-format)
- :param str maker_address: Same as makerAddress in the [0x Protocol v2 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#order-message-format)
- :param str taker_address: Same as takerAddress in the [0x Protocol v2 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#order-message-format)
- :param str trader_address: Same as traderAddress in the [0x Protocol v2 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#order-message-format)
- :param str fee_recipient_address: Same as feeRecipientAddress in the [0x Protocol v2 Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#order-message-format)
+ :param str exchange_address: Same as exchangeAddress in the [0x
+ `0x Protocol v2 Specification
+ `__
+ :param str sender_address: Same as senderAddress in the
+ `0x Protocol v2 Specification
+ `__
+ :param str maker_asset_data: Same as makerAssetData in the
+ `0x Protocol v2 Specification
+ `__
+ :param str taker_asset_data: Same as takerAssetData in the
+ `0x Protocol v2 Specification
+ `__
+ :param str trader_asset_data: Same as traderAssetData in the
+ `0x Protocol v2 Specification
+ `__
+ :param str maker_address: Same as makerAddress in the
+ `0x Protocol v2 Specification
+ `__
+ :param str taker_address: Same as takerAddress in the
+ `0x Protocol v2 Specification
+ `__
+ :param str trader_address: Same as traderAddress in the
+ `0x Protocol v2 Specification
+ `__
+ :param str fee_recipient_address: Same as feeRecipientAddress in the
+ `0x Protocol v2 Specification
+ `__
:param float network_id: The id of the Ethereum network
:param float page: The number of the page to request in the collection.
:param float per_page: The number of records to return per page.
- :return: RelayerApiOrdersResponseSchema
- If the method is called asynchronously,
- returns the request thread.
+
+ :return: RelayerApiOrdersResponseSchema.
+ If the method is called asynchronously, returns the request thread.
"""
local_var_params = locals()
@@ -743,7 +856,7 @@ class DefaultApi(object):
"network_id",
"page",
"per_page",
- ] # noqa: E501
+ ]
all_params.append("async_req")
all_params.append("_return_http_data_only")
all_params.append("_preload_content")
@@ -766,70 +879,64 @@ class DefaultApi(object):
if "maker_asset_proxy_id" in local_var_params:
query_params.append(
("makerAssetProxyId", local_var_params["maker_asset_proxy_id"])
- ) # noqa: E501
+ )
if "taker_asset_proxy_id" in local_var_params:
query_params.append(
("takerAssetProxyId", local_var_params["taker_asset_proxy_id"])
- ) # noqa: E501
+ )
if "maker_asset_address" in local_var_params:
query_params.append(
("makerAssetAddress", local_var_params["maker_asset_address"])
- ) # noqa: E501
+ )
if "taker_asset_address" in local_var_params:
query_params.append(
("takerAssetAddress", local_var_params["taker_asset_address"])
- ) # noqa: E501
+ )
if "exchange_address" in local_var_params:
query_params.append(
("exchangeAddress", local_var_params["exchange_address"])
- ) # noqa: E501
+ )
if "sender_address" in local_var_params:
query_params.append(
("senderAddress", local_var_params["sender_address"])
- ) # noqa: E501
+ )
if "maker_asset_data" in local_var_params:
query_params.append(
("makerAssetData", local_var_params["maker_asset_data"])
- ) # noqa: E501
+ )
if "taker_asset_data" in local_var_params:
query_params.append(
("takerAssetData", local_var_params["taker_asset_data"])
- ) # noqa: E501
+ )
if "trader_asset_data" in local_var_params:
query_params.append(
("traderAssetData", local_var_params["trader_asset_data"])
- ) # noqa: E501
+ )
if "maker_address" in local_var_params:
query_params.append(
("makerAddress", local_var_params["maker_address"])
- ) # noqa: E501
+ )
if "taker_address" in local_var_params:
query_params.append(
("takerAddress", local_var_params["taker_address"])
- ) # noqa: E501
+ )
if "trader_address" in local_var_params:
query_params.append(
("traderAddress", local_var_params["trader_address"])
- ) # noqa: E501
+ )
if "fee_recipient_address" in local_var_params:
query_params.append(
(
"feeRecipientAddress",
local_var_params["fee_recipient_address"],
)
- ) # noqa: E501
+ )
if "network_id" in local_var_params:
- query_params.append(
- ("networkId", local_var_params["network_id"])
- ) # noqa: E501
+ query_params.append(("networkId", local_var_params["network_id"]))
if "page" in local_var_params:
- query_params.append(
- ("page", local_var_params["page"])
- ) # noqa: E501
+ query_params.append(("page", local_var_params["page"]))
if "per_page" in local_var_params:
- query_params.append(
- ("perPage", local_var_params["per_page"])
- ) # noqa: E501
+ query_params.append(("perPage", local_var_params["per_page"]))
header_params = {}
@@ -840,10 +947,10 @@ class DefaultApi(object):
# HTTP header `Accept`
header_params["Accept"] = self.api_client.select_header_accept(
["application/json"]
- ) # noqa: E501
+ )
# Authentication setting
- auth_settings = [] # noqa: E501
+ auth_settings = []
return self.api_client.call_api(
"/v2/orders",
@@ -854,60 +961,64 @@ class DefaultApi(object):
body=body_params,
post_params=form_params,
files=local_var_files,
- response_type="RelayerApiOrdersResponseSchema", # noqa: E501
+ response_type="RelayerApiOrdersResponseSchema",
auth_settings=auth_settings,
async_req=local_var_params.get("async_req"),
_return_http_data_only=local_var_params.get(
"_return_http_data_only"
- ), # noqa: E501
+ ),
_preload_content=local_var_params.get("_preload_content", True),
_request_timeout=local_var_params.get("_request_timeout"),
collection_formats=collection_formats,
)
- def post_order(self, **kwargs): # noqa: E501
- """post_order # noqa: E501
+ def post_order(self, **kwargs):
+ """post_order
- Submit a signed order to the relayer. # noqa: E501
+ Submit a signed order to the relayer.
This method makes a synchronous HTTP request by default. To make an
- asynchronous HTTP request, please pass async_req=True
- >>> thread = api.post_order(async_req=True)
- >>> result = thread.get()
+ asynchronous HTTP request, please pass `async_req` = **True**
- :param async_req bool
+ >>> thread = api.post_order(async_req=True) # doctest: +SKIP
+ >>> result = thread.get() # doctest: +SKIP
+
+ :param bool async_req: Whether request should be asynchronous.
:param float network_id: The id of the Ethereum network
- :param SignedOrderSchema signed_order_schema: A valid signed 0x order based on the schema.
- :return: None
- If the method is called asynchronously,
- returns the request thread.
+ :param signed_order_schema: Instance of :class:`SignedOrderSchema`.
+ A valid signed 0x order based on the schema.
+
+ :return: None.
+ If the method is called asynchronously, returns the request thread.
"""
kwargs["_return_http_data_only"] = True
if kwargs.get("async_req"):
- return self.post_order_with_http_info(**kwargs) # noqa: E501
+ return self.post_order_with_http_info(**kwargs)
else:
- (data) = self.post_order_with_http_info(**kwargs) # noqa: E501
+ (data) = self.post_order_with_http_info(**kwargs)
return data
- def post_order_with_http_info(self, **kwargs): # noqa: E501
- """post_order # noqa: E501
+ def post_order_with_http_info(self, **kwargs):
+ """post_order
- Submit a signed order to the relayer. # noqa: E501
+ Submit a signed order to the relayer.
This method makes a synchronous HTTP request by default. To make an
- asynchronous HTTP request, please pass async_req=True
- >>> thread = api.post_order_with_http_info(async_req=True)
- >>> result = thread.get()
+ asynchronous HTTP request, please pass `async_req` = **True**
- :param async_req bool
+ >>> thread = api.post_order_with_http_info(async_req=True) # doctest: +SKIP
+ >>> result = thread.get() # doctest: +SKIP
+
+ :param bool async_req: Whether request should be asynchronous.
:param float network_id: The id of the Ethereum network
- :param SignedOrderSchema signed_order_schema: A valid signed 0x order based on the schema.
- :return: None
- If the method is called asynchronously,
- returns the request thread.
+ :param signed_order_schema: Instance of :class:`SignedOrderSchema`
+ A valid signed 0x order based on the schema.
+
+ :return: None.
+ If the method is called asynchronously, returns the request thread.
"""
local_var_params = locals()
- all_params = ["network_id", "signed_order_schema"] # noqa: E501
+ all_params = ["network_id", "signed_order_schema"]
all_params.append("async_req")
all_params.append("_return_http_data_only")
all_params.append("_preload_content")
@@ -928,9 +1039,7 @@ class DefaultApi(object):
query_params = []
if "network_id" in local_var_params:
- query_params.append(
- ("networkId", local_var_params["network_id"])
- ) # noqa: E501
+ query_params.append(("networkId", local_var_params["network_id"]))
header_params = {}
@@ -943,17 +1052,15 @@ class DefaultApi(object):
# HTTP header `Accept`
header_params["Accept"] = self.api_client.select_header_accept(
["application/json"]
- ) # noqa: E501
+ )
# HTTP header `Content-Type`
header_params[
"Content-Type"
- ] = self.api_client.select_header_content_type( # noqa: E501
- ["application/json"]
- ) # noqa: E501
+ ] = self.api_client.select_header_content_type(["application/json"])
# Authentication setting
- auth_settings = [] # noqa: E501
+ auth_settings = []
return self.api_client.call_api(
"/v2/order",
@@ -964,12 +1071,12 @@ class DefaultApi(object):
body=body_params,
post_params=form_params,
files=local_var_files,
- response_type=None, # noqa: E501
+ response_type=None,
auth_settings=auth_settings,
async_req=local_var_params.get("async_req"),
_return_http_data_only=local_var_params.get(
"_return_http_data_only"
- ), # noqa: E501
+ ),
_preload_content=local_var_params.get("_preload_content", True),
_request_timeout=local_var_params.get("_request_timeout"),
collection_formats=collection_formats,
diff --git a/python-packages/sra_client/sra_client/api_client.py b/python-packages/sra_client/sra_client/api_client.py
index 6139fdb425..ad2b6385bf 100644
--- a/python-packages/sra_client/sra_client/api_client.py
+++ b/python-packages/sra_client/sra_client/api_client.py
@@ -207,8 +207,7 @@ class ApiClient(object):
If obj is None, return None.
If obj is str, int, long, float, bool, return directly.
- If obj is datetime.datetime, datetime.date
- convert to string in iso8601 format.
+ If obj is datetime.datetime, datetime.date convert to string in iso8601 format.
If obj is list, sanitize each element in the list.
If obj is dict, return the dict.
If obj is OpenAPI model, return the properties dict.
diff --git a/python-packages/sra_client/test/__init__.py b/python-packages/sra_client/test/__init__.py
index e69de29bb2..789ac3d7e7 100644
--- a/python-packages/sra_client/test/__init__.py
+++ b/python-packages/sra_client/test/__init__.py
@@ -0,0 +1 @@
+"""Test for sra_client."""
diff --git a/python-packages/sra_client/test/test_default_api.py b/python-packages/sra_client/test/test_default_api.py
index d23c6173fc..ec583c7b5b 100644
--- a/python-packages/sra_client/test/test_default_api.py
+++ b/python-packages/sra_client/test/test_default_api.py
@@ -1,3 +1,4 @@
+"""Test the default api client"""
# coding: utf-8
@@ -5,30 +6,92 @@ from __future__ import absolute_import
import unittest
-import sra_client
-from sra_client.api.default_api import DefaultApi # noqa: E501
-from sra_client.models.relayer_api_asset_data_pairs_response_schema import (
- RelayerApiAssetDataPairsResponseSchema
-)
-from sra_client.rest import ApiException
+from sra_client import ApiClient, Configuration
+from sra_client.api import DefaultApi
class TestDefaultApi(unittest.TestCase):
"""DefaultApi unit test stubs"""
def setUp(self):
- self.api = sra_client.api.default_api.DefaultApi() # noqa: E501
+ config = Configuration()
+ config.host = "http://localhost:3000"
+ self.api = DefaultApi(ApiClient(config))
def tearDown(self):
pass
+ # pylint: disable=too-many-locals
def test_get_asset_pairs(self):
"""Test case for get_asset_pairs
"""
- expected = RelayerApiAssetDataPairsResponseSchema([])
+ expected = {
+ "records": [
+ {
+ "assetDataA": {
+ "assetData": "0xf47261b0000000000000000000000000"
+ "d0a1e359811322d97991e03f863a0c30c2cf029c",
+ "maxAmount": "115792089237316195423570985008687907853"
+ "269984665640564039457584007913129639936",
+ "minAmount": "0",
+ "precision": 18,
+ },
+ "assetDataB": {
+ "assetData": "0xf47261b0000000000000000000000000"
+ "2002d3812f58e35f0ea1ffbf80a75a38c32175fa",
+ "maxAmount": "115792089237316195423570985008687907853"
+ "269984665640564039457584007913129639936",
+ "minAmount": "0",
+ "precision": 18,
+ },
+ }
+ ]
+ }
+
actual = self.api.get_asset_pairs()
- self.assertEqual(actual, expected)
+
+ acutal_asset_data_a = actual.records[0]["assetDataA"]["assetData"]
+ expected_asset_data_a = expected["records"][0]["assetDataA"][
+ "assetData"
+ ]
+ self.assertEqual(acutal_asset_data_a, expected_asset_data_a)
+ acutal_max_amount_a = actual.records[0]["assetDataA"]["maxAmount"]
+ expected_max_amount_a = expected["records"][0]["assetDataA"][
+ "maxAmount"
+ ]
+ self.assertEqual(acutal_max_amount_a, expected_max_amount_a)
+ acutal_min_amount_a = actual.records[0]["assetDataA"]["minAmount"]
+ expected_min_amount_a = expected["records"][0]["assetDataA"][
+ "minAmount"
+ ]
+ self.assertEqual(acutal_min_amount_a, expected_min_amount_a)
+ acutal_precision_a = actual.records[0]["assetDataA"]["precision"]
+ expected_precision_a = expected["records"][0]["assetDataA"][
+ "precision"
+ ]
+ self.assertEqual(acutal_precision_a, expected_precision_a)
+
+ acutal_asset_data_b = actual.records[0]["assetDataB"]["assetData"]
+ expected_asset_data_b = expected["records"][0]["assetDataB"][
+ "assetData"
+ ]
+ self.assertEqual(acutal_asset_data_b, expected_asset_data_b)
+ acutal_max_amount_b = actual.records[0]["assetDataB"]["maxAmount"]
+ expected_max_amount_b = expected["records"][0]["assetDataB"][
+ "maxAmount"
+ ]
+ self.assertEqual(acutal_max_amount_b, expected_max_amount_b)
+ acutal_min_amount_b = actual.records[0]["assetDataB"]["minAmount"]
+ expected_min_amount_b = expected["records"][0]["assetDataB"][
+ "minAmount"
+ ]
+ self.assertEqual(acutal_min_amount_b, expected_min_amount_b)
+ acutal_precision_b = actual.records[0]["assetDataB"]["precision"]
+ expected_precision_b = expected["records"][0]["assetDataB"][
+ "precision"
+ ]
+ self.assertEqual(acutal_precision_b, expected_precision_b)
if __name__ == "__main__":