Python contract demo, with lots of refactoring (#1485)
* Refine Order for Web3 compat. & add conversions Changed some of the fields in the Order class so that it can be passed to our contracts via Web3. Added conversion utilities so that an Order can be easily converted to and from a JSON-compatible dict (specifically by encoding/decoding the `bytes` fields), to facilitate validation against the JSON schema. Also modified JSON order schema to accept integers in addition to stringified integers. * Fixes for json_schemas Has-types indicator file, py.typed, was not being included in package. Schemas were not being properly gathered into package installation. * Add test/demo of Exchange.getOrderInfo() * web3 bug workaround * Fix problem packaging contract artifacts * Move contract addresses to their own package * Move contract artifacts to their own package * Add scripts to install, test & lint all components * prettierignore files in local python dev env * Correct missing coverage analysis for sra_client * CI cache lint: don't save, re-use from test-python * tag hacks as hacks * correct merge mistake * remove local strip_0x() in favor of eth_utils * remove json schemas from old order_utils location * correct merge mistake * doctest json schemas via command-line, not code
This commit is contained in:
parent
5b7eff217e
commit
aa5af04447
@ -200,46 +200,30 @@ jobs:
|
|||||||
key: deps9-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}
|
key: deps9-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
- run:
|
- run:
|
||||||
command: |
|
command: |
|
||||||
cd python-packages/json_schemas
|
cd python-packages
|
||||||
python -m ensurepip
|
python -m ensurepip
|
||||||
python -m pip install .[dev]
|
./install
|
||||||
# HACK! installing the package should do the following
|
|
||||||
# copy for us, but it's not working in CircleCI for some
|
|
||||||
# reason. Zendesk support ticket raised (#43979) with
|
|
||||||
# CircleCI.
|
|
||||||
mkdir /usr/local/lib/python3.7/site-packages/zero_ex/json_schemas/schemas
|
|
||||||
cp -R src/zero_ex/json_schemas/schemas/* /usr/local/lib/python3.7/site-packages/zero_ex/json_schemas/schemas
|
|
||||||
- run:
|
|
||||||
command: |
|
|
||||||
cd python-packages/order_utils
|
|
||||||
python -m ensurepip
|
|
||||||
python -m pip install .[dev]
|
|
||||||
- run:
|
|
||||||
command: |
|
|
||||||
cd python-packages/sra_client
|
|
||||||
python -m ensurepip
|
|
||||||
python -m pip install .[dev]
|
|
||||||
- save_cache:
|
- save_cache:
|
||||||
key: deps9-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}
|
key: deps9-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
paths:
|
paths:
|
||||||
- '/usr/local/bin'
|
- '/usr/local/bin'
|
||||||
- '/usr/local/lib/python3.7/site-packages'
|
- '/usr/local/lib/python3.7/site-packages'
|
||||||
- '.eggs'
|
|
||||||
- '.mypy_cache'
|
|
||||||
- '.pytest_cache'
|
|
||||||
- '.tox'
|
|
||||||
- run:
|
- run:
|
||||||
command: |
|
command: |
|
||||||
cd python-packages/json_schemas
|
cd python-packages
|
||||||
coverage run setup.py test
|
./cmd_pkgs_in_dep_order.py coverage run setup.py test
|
||||||
- run:
|
- save_cache:
|
||||||
command: |
|
key: coverage-python-contract-addresses-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
cd python-packages/order_utils
|
paths:
|
||||||
coverage run setup.py test
|
- ~/repo/python-packages/contract_addresses/.coverage
|
||||||
- run:
|
- save_cache:
|
||||||
command: |
|
key: coverage-python-contract-artifacts-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
cd python-packages/sra_client
|
paths:
|
||||||
coverage run setup.py test
|
- ~/repo/python-packages/contract_artifacts/.coverage
|
||||||
|
- save_cache:
|
||||||
|
key: coverage-python-contract-demo-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
|
paths:
|
||||||
|
- ~/repo/python-packages/contract_demo/.coverage
|
||||||
- save_cache:
|
- save_cache:
|
||||||
key: coverage-python-json-schemas-{{ .Environment.CIRCLE_SHA1 }}
|
key: coverage-python-json-schemas-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
paths:
|
paths:
|
||||||
@ -292,27 +276,10 @@ jobs:
|
|||||||
key: deps9-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}
|
key: deps9-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
- run:
|
- run:
|
||||||
command: |
|
command: |
|
||||||
cd python-packages/json_schemas
|
|
||||||
python -m ensurepip
|
python -m ensurepip
|
||||||
python -m pip install .[dev]
|
cd python-packages
|
||||||
- run:
|
./install
|
||||||
command: |
|
./lint
|
||||||
cd python-packages/order_utils
|
|
||||||
python -m ensurepip
|
|
||||||
python -m pip install .[dev]
|
|
||||||
- save_cache:
|
|
||||||
key: deps9-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}
|
|
||||||
paths:
|
|
||||||
- '/usr/local/bin'
|
|
||||||
- '/usr/local/lib/python3.7/site-packages'
|
|
||||||
- run:
|
|
||||||
command: |
|
|
||||||
cd python-packages/json_schemas
|
|
||||||
python setup.py lint
|
|
||||||
- run:
|
|
||||||
command: |
|
|
||||||
cd python-packages/order_utils
|
|
||||||
python setup.py lint
|
|
||||||
static-tests:
|
static-tests:
|
||||||
working_directory: ~/repo
|
working_directory: ~/repo
|
||||||
docker:
|
docker:
|
||||||
@ -384,6 +351,18 @@ jobs:
|
|||||||
- restore_cache:
|
- restore_cache:
|
||||||
keys:
|
keys:
|
||||||
- coverage-python-json-schemas-{{ .Environment.CIRCLE_SHA1 }}
|
- coverage-python-json-schemas-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
|
- restore_cache:
|
||||||
|
keys:
|
||||||
|
- coverage-python-contract-addresses-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
|
- restore_cache:
|
||||||
|
keys:
|
||||||
|
- coverage-python-contract-artifacts-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
|
- restore_cache:
|
||||||
|
keys:
|
||||||
|
- coverage-python-contract-demo-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
|
- restore_cache:
|
||||||
|
keys:
|
||||||
|
- coverage-python-sra-client-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
keys:
|
keys:
|
||||||
- coverage-python-order-utils-{{ .Environment.CIRCLE_SHA1 }}
|
- coverage-python-order-utils-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
@ -421,7 +400,9 @@ workflows:
|
|||||||
requires:
|
requires:
|
||||||
- test-rest
|
- test-rest
|
||||||
- test-python
|
- test-python
|
||||||
|
- static-tests-python:
|
||||||
|
requires:
|
||||||
|
- test-python
|
||||||
- test-python
|
- test-python
|
||||||
- static-tests-python
|
|
||||||
# skip python tox run for now, as we don't yet have multiple test environments to support.
|
# skip python tox run for now, as we don't yet have multiple test environments to support.
|
||||||
#- test-rest-python
|
#- test-rest-python
|
||||||
|
@ -18,7 +18,7 @@ lib
|
|||||||
/contracts/extensions/generated-artifacts
|
/contracts/extensions/generated-artifacts
|
||||||
/packages/abi-gen-wrappers/src/generated-wrappers
|
/packages/abi-gen-wrappers/src/generated-wrappers
|
||||||
/packages/contract-artifacts/artifacts
|
/packages/contract-artifacts/artifacts
|
||||||
/python-packages/order_utils/src/zero_ex/contract_artifacts/artifacts
|
/python-packages/contract_artifacts/src/zero_ex/contract_artifacts/artifacts
|
||||||
/packages/json-schemas/schemas
|
/packages/json-schemas/schemas
|
||||||
/python-packages/json_schemas/src/zero_ex/json_schemas/schemas
|
/python-packages/json_schemas/src/zero_ex/json_schemas/schemas
|
||||||
/packages/metacoin/src/contract_wrappers
|
/packages/metacoin/src/contract_wrappers
|
||||||
|
@ -25,7 +25,9 @@ Visit our [developer portal](https://0xproject.com/docs/order-utils) for a compr
|
|||||||
### Python Packages
|
### Python Packages
|
||||||
|
|
||||||
| Package | Version | Description |
|
| Package | Version | Description |
|
||||||
| -------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
|
| -------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
|
||||||
|
| [`0x-contract-addresses`](/python-packages/contract_addresses) | [](https://pypi.org/project/0x-contract-addresses/) | A tiny utility library for getting known deployed contract addresses for a particular network |
|
||||||
|
| [`0x-contract-artifacts`](/python-packages/contract_artifacts) | [](https://pypi.org/project/0x-contract-artifacts/) | 0x smart contract compilation artifacts |
|
||||||
| [`0x-json-schemas`](/python-packages/json_schemas) | [](https://pypi.org/project/0x-json-schemas/) | 0x-related JSON schemas |
|
| [`0x-json-schemas`](/python-packages/json_schemas) | [](https://pypi.org/project/0x-json-schemas/) | 0x-related JSON schemas |
|
||||||
| [`0x-order-utils`](/python-packages/order_utils) | [](https://pypi.org/project/0x-order-utils/) | A set of utilities for generating, parsing, signing and validating 0x orders |
|
| [`0x-order-utils`](/python-packages/order_utils) | [](https://pypi.org/project/0x-order-utils/) | A set of utilities for generating, parsing, signing and validating 0x orders |
|
||||||
| [`0x-sra-client`](/python-packages/sra_client) | [](https://pypi.org/project/0x-sra-client/) | A Python client for interacting with servers conforming to the Standard Relayer API specification |
|
| [`0x-sra-client`](/python-packages/sra_client) | [](https://pypi.org/project/0x-sra-client/) | A Python client for interacting with servers conforming to the Standard Relayer API specification |
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
{
|
{
|
||||||
"id": "/wholeNumberSchema",
|
"id": "/wholeNumberSchema",
|
||||||
|
"anyOf": [
|
||||||
|
{
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"pattern": "^\\d+$"
|
"pattern": "^\\d+$"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
25
python-packages/cmd_pkgs_in_dep_order.py
Executable file
25
python-packages/cmd_pkgs_in_dep_order.py
Executable file
@ -0,0 +1,25 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
"""Run a command in every package, in order of increasing dependency."""
|
||||||
|
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
PACKAGE_DEPENDENCY_LIST = [
|
||||||
|
# Order matters! Packages must be handled in dependency order (most
|
||||||
|
# independent first) in order for them to resolve properly.
|
||||||
|
"contract_addresses",
|
||||||
|
"contract_artifacts",
|
||||||
|
"json_schemas",
|
||||||
|
"sra_client",
|
||||||
|
"order_utils",
|
||||||
|
"contract_demo"
|
||||||
|
]
|
||||||
|
|
||||||
|
for package in PACKAGE_DEPENDENCY_LIST:
|
||||||
|
print(f"Running command `{sys.argv[1:]}` in package {package}")
|
||||||
|
os.chdir(package)
|
||||||
|
subprocess.check_call(sys.argv[1:])
|
||||||
|
os.chdir("..")
|
13
python-packages/contract_addresses/.discharge.json
Normal file
13
python-packages/contract_addresses/.discharge.json
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"domain": "0x-contract-addresses-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
|
||||||
|
}
|
45
python-packages/contract_addresses/README.md
Normal file
45
python-packages/contract_addresses/README.md
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
## 0x-contract-addresses
|
||||||
|
|
||||||
|
Addresses at which the 0x smart contracts have been deployed.
|
||||||
|
|
||||||
|
Read the [documentation](http://0x-contract-addresses-py.s3-website-us-east-1.amazonaws.com/)
|
||||||
|
|
||||||
|
## Installing
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install 0x-contract-addresses
|
||||||
|
```
|
||||||
|
|
||||||
|
## 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.
|
181
python-packages/contract_addresses/setup.py
Executable file
181
python-packages/contract_addresses/setup.py
Executable file
@ -0,0 +1,181 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
"""setuptools module for contract_addresses package."""
|
||||||
|
|
||||||
|
import subprocess # nosec
|
||||||
|
from shutil import rmtree
|
||||||
|
from os import environ, path
|
||||||
|
from sys import argv
|
||||||
|
|
||||||
|
from distutils.command.clean import clean
|
||||||
|
import distutils.command.build_py
|
||||||
|
from setuptools import find_packages, setup
|
||||||
|
|
||||||
|
|
||||||
|
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 src setup.py".split(),
|
||||||
|
# style guide checker (formerly pep8):
|
||||||
|
"pycodestyle --show-source --show-pep8 src setup.py".split(),
|
||||||
|
# docstring style checker:
|
||||||
|
"pydocstyle src setup.py".split(),
|
||||||
|
# static type checker:
|
||||||
|
"mypy src setup.py".split(),
|
||||||
|
# security issue checker:
|
||||||
|
"bandit -r src ./setup.py".split(),
|
||||||
|
# run doctests:
|
||||||
|
"pytest --doctest-modules".split(),
|
||||||
|
# general linter:
|
||||||
|
"pylint src 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("dist", ignore_errors=True)
|
||||||
|
rmtree(".mypy_cache", ignore_errors=True)
|
||||||
|
rmtree(".tox", ignore_errors=True)
|
||||||
|
rmtree(".pytest_cache", ignore_errors=True)
|
||||||
|
rmtree("src/0x_contract_addresses.egg-info", ignore_errors=True)
|
||||||
|
|
||||||
|
|
||||||
|
class TestPublishCommand(distutils.command.build_py.build_py):
|
||||||
|
"""Custom command to publish to test.pypi.org."""
|
||||||
|
|
||||||
|
description = (
|
||||||
|
"Publish dist/* to test.pypi.org. Run sdist & bdist_wheel first."
|
||||||
|
)
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
"""Run twine to upload to test.pypi.org."""
|
||||||
|
subprocess.check_call( # nosec
|
||||||
|
(
|
||||||
|
"twine upload --repository-url https://test.pypi.org/legacy/"
|
||||||
|
+ " --verbose dist/*"
|
||||||
|
).split()
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class PublishCommand(distutils.command.build_py.build_py):
|
||||||
|
"""Custom command to publish to pypi.org."""
|
||||||
|
|
||||||
|
description = "Publish dist/* to pypi.org. Run sdist & bdist_wheel first."
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
"""Run twine to upload to pypi.org."""
|
||||||
|
subprocess.check_call("twine upload dist/*".split()) # 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
|
||||||
|
|
||||||
|
|
||||||
|
with open("README.md", "r") as file_handle:
|
||||||
|
README_MD = file_handle.read()
|
||||||
|
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name="0x-contract-addresses",
|
||||||
|
version="2.0.0",
|
||||||
|
description="Addresses at which the 0x smart contracts have been deployed",
|
||||||
|
long_description=README_MD,
|
||||||
|
long_description_content_type="text/markdown",
|
||||||
|
url=(
|
||||||
|
"https://github.com/0xproject/0x-monorepo/tree/development"
|
||||||
|
+ "/python-packages/contract_addresses"
|
||||||
|
),
|
||||||
|
author="F. Eugene Aumson",
|
||||||
|
author_email="feuGeneA@users.noreply.github.com",
|
||||||
|
cmdclass={
|
||||||
|
"clean": CleanCommandExtension,
|
||||||
|
"lint": LintCommand,
|
||||||
|
"test_publish": TestPublishCommand,
|
||||||
|
"publish": PublishCommand,
|
||||||
|
"publish_docs": PublishDocsCommand,
|
||||||
|
},
|
||||||
|
install_requires=["mypy_extensions"],
|
||||||
|
extras_require={
|
||||||
|
"dev": [
|
||||||
|
"bandit",
|
||||||
|
"black",
|
||||||
|
"coverage",
|
||||||
|
"coveralls",
|
||||||
|
"mypy",
|
||||||
|
"mypy_extensions",
|
||||||
|
"pycodestyle",
|
||||||
|
"pydocstyle",
|
||||||
|
"pylint",
|
||||||
|
"pytest",
|
||||||
|
"sphinx",
|
||||||
|
"tox",
|
||||||
|
"twine",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
python_requires=">=3.6, <4",
|
||||||
|
package_data={"zero_ex.contract_addresses": ["py.typed"]},
|
||||||
|
package_dir={"": "src"},
|
||||||
|
license="Apache 2.0",
|
||||||
|
keywords=(
|
||||||
|
"ethereum cryptocurrency 0x decentralized blockchain dex exchange"
|
||||||
|
),
|
||||||
|
namespace_packages=["zero_ex"],
|
||||||
|
packages=find_packages("src"),
|
||||||
|
classifiers=[
|
||||||
|
"Development Status :: 5 - Production/Stable",
|
||||||
|
"Intended Audience :: Developers",
|
||||||
|
"Intended Audience :: Financial and Insurance Industry",
|
||||||
|
"License :: OSI Approved :: Apache Software License",
|
||||||
|
"Natural Language :: English",
|
||||||
|
"Operating System :: OS Independent",
|
||||||
|
"Programming Language :: Python",
|
||||||
|
"Programming Language :: Python :: 3 :: Only",
|
||||||
|
"Programming Language :: Python :: 3.6",
|
||||||
|
"Programming Language :: Python :: 3.7",
|
||||||
|
"Topic :: Internet :: WWW/HTTP",
|
||||||
|
"Topic :: Office/Business :: Financial",
|
||||||
|
"Topic :: Other/Nonlisted Topic",
|
||||||
|
"Topic :: Security :: Cryptography",
|
||||||
|
"Topic :: Software Development :: Libraries",
|
||||||
|
"Topic :: Utilities",
|
||||||
|
],
|
||||||
|
zip_safe=False, # required per mypy
|
||||||
|
command_options={
|
||||||
|
"build_sphinx": {
|
||||||
|
"source_dir": ("setup.py", "src"),
|
||||||
|
"build_dir": ("setup.py", "build/docs"),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
54
python-packages/contract_addresses/src/conf.py
Normal file
54
python-packages/contract_addresses/src/conf.py
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
"""Configuration file for the Sphinx documentation builder."""
|
||||||
|
|
||||||
|
# Reference: http://www.sphinx-doc.org/en/master/config
|
||||||
|
|
||||||
|
from typing import List
|
||||||
|
import pkg_resources
|
||||||
|
|
||||||
|
|
||||||
|
# pylint: disable=invalid-name
|
||||||
|
# because these variables are not named in upper case, as globals should be.
|
||||||
|
|
||||||
|
project = "0x-contract-addresses"
|
||||||
|
# pylint: disable=redefined-builtin
|
||||||
|
copyright = "2018, ZeroEx, Intl."
|
||||||
|
author = "F. Eugene Aumson"
|
||||||
|
version = pkg_resources.get_distribution("0x-contract-addresses").version
|
||||||
|
release = "" # The full version, including alpha/beta/rc tags
|
||||||
|
|
||||||
|
extensions = [
|
||||||
|
"sphinx.ext.autodoc",
|
||||||
|
"sphinx.ext.doctest",
|
||||||
|
"sphinx.ext.intersphinx",
|
||||||
|
"sphinx.ext.coverage",
|
||||||
|
"sphinx.ext.viewcode",
|
||||||
|
]
|
||||||
|
|
||||||
|
templates_path = ["doc_templates"]
|
||||||
|
|
||||||
|
source_suffix = ".rst"
|
||||||
|
# eg: source_suffix = [".rst", ".md"]
|
||||||
|
|
||||||
|
master_doc = "index" # The master toctree document.
|
||||||
|
|
||||||
|
language = None
|
||||||
|
|
||||||
|
exclude_patterns: List[str] = []
|
||||||
|
|
||||||
|
# The name of the Pygments (syntax highlighting) style to use.
|
||||||
|
pygments_style = None
|
||||||
|
|
||||||
|
html_theme = "alabaster"
|
||||||
|
|
||||||
|
html_static_path = ["doc_static"]
|
||||||
|
# Add any paths that contain custom static files (such as style sheets) here,
|
||||||
|
# relative to this directory. They are copied after the builtin static files,
|
||||||
|
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||||
|
|
||||||
|
# Output file base name for HTML help builder.
|
||||||
|
htmlhelp_basename = "contract_addressespydoc"
|
||||||
|
|
||||||
|
# -- Extension configuration:
|
||||||
|
|
||||||
|
# Example configuration for intersphinx: refer to the Python standard library.
|
||||||
|
intersphinx_mapping = {"https://docs.python.org/": None}
|
25
python-packages/contract_addresses/src/index.rst
Normal file
25
python-packages/contract_addresses/src/index.rst
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
.. source for the sphinx-generated build/docs/web/index.html
|
||||||
|
|
||||||
|
Python zero_ex.contract_addresses
|
||||||
|
=================================
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:maxdepth: 2
|
||||||
|
:caption: Contents:
|
||||||
|
|
||||||
|
.. autoclass:: zero_ex.contract_addresses.NetworkId
|
||||||
|
|
||||||
|
See source for enum members.
|
||||||
|
|
||||||
|
.. autoclass:: zero_ex.contract_addresses.ContractAddresses
|
||||||
|
:members:
|
||||||
|
|
||||||
|
.. autodata:: zero_ex.contract_addresses.NETWORK_TO_ADDRESSES
|
||||||
|
:annotation:
|
||||||
|
|
||||||
|
Indices and tables
|
||||||
|
==================
|
||||||
|
|
||||||
|
* :ref:`genindex`
|
||||||
|
* :ref:`modindex`
|
||||||
|
* :ref:`search`
|
@ -0,0 +1,2 @@
|
|||||||
|
"""0x Python API."""
|
||||||
|
__import__("pkg_resources").declare_namespace(__name__)
|
@ -0,0 +1,93 @@
|
|||||||
|
"""Addresses at which the 0x smart contracts have been deployed."""
|
||||||
|
|
||||||
|
from enum import Enum
|
||||||
|
from typing import Dict, NamedTuple
|
||||||
|
|
||||||
|
|
||||||
|
class ContractAddresses(NamedTuple): # noqa
|
||||||
|
"""An abstract record listing all the contracts that have addresses."""
|
||||||
|
|
||||||
|
erc20_proxy: str
|
||||||
|
erc721_proxy: str
|
||||||
|
zrx_token: str
|
||||||
|
ether_token: str
|
||||||
|
exchange: str
|
||||||
|
asset_proxy_owner: str
|
||||||
|
forwarder: str
|
||||||
|
order_validator: str
|
||||||
|
|
||||||
|
|
||||||
|
class NetworkId(Enum):
|
||||||
|
"""Network names correlated to their network identification numbers.
|
||||||
|
|
||||||
|
>>> NetworkId.MAINNET
|
||||||
|
<NetworkId.MAINNET: 1>
|
||||||
|
"""
|
||||||
|
|
||||||
|
MAINNET = 1
|
||||||
|
ROPSTEN = 3
|
||||||
|
RINKEBY = 4
|
||||||
|
KOVAN = 42
|
||||||
|
GANACHE = 50
|
||||||
|
|
||||||
|
|
||||||
|
NETWORK_TO_ADDRESSES: Dict[NetworkId, ContractAddresses] = {
|
||||||
|
NetworkId.MAINNET: ContractAddresses(
|
||||||
|
erc20_proxy="0x2240dab907db71e64d3e0dba4800c83b5c502d4e",
|
||||||
|
erc721_proxy="0x208e41fb445f1bb1b6780d58356e81405f3e6127",
|
||||||
|
zrx_token="0xe41d2489571d322189246dafa5ebde1f4699f498",
|
||||||
|
ether_token="0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
|
||||||
|
exchange="0x4f833a24e1f95d70f028921e27040ca56e09ab0b",
|
||||||
|
asset_proxy_owner="0x17992e4ffb22730138e4b62aaa6367fa9d3699a6",
|
||||||
|
forwarder="0x5468a1dc173652ee28d249c271fa9933144746b1",
|
||||||
|
order_validator="0x9463e518dea6810309563c81d5266c1b1d149138",
|
||||||
|
),
|
||||||
|
NetworkId.ROPSTEN: ContractAddresses(
|
||||||
|
erc20_proxy="0xb1408f4c245a23c31b98d2c626777d4c0d766caa",
|
||||||
|
erc721_proxy="0xe654aac058bfbf9f83fcaee7793311dd82f6ddb4",
|
||||||
|
zrx_token="0xff67881f8d12f372d91baae9752eb3631ff0ed00",
|
||||||
|
ether_token="0xc778417e063141139fce010982780140aa0cd5ab",
|
||||||
|
exchange="0x4530c0483a1633c7a1c97d2c53721caff2caaaaf",
|
||||||
|
asset_proxy_owner="0xf5fa5b5fed2727a0e44ac67f6772e97977aa358b",
|
||||||
|
forwarder="0x2240dab907db71e64d3e0dba4800c83b5c502d4e",
|
||||||
|
order_validator="0x90431a90516ab49af23a0530e04e8c7836e7122f",
|
||||||
|
),
|
||||||
|
NetworkId.RINKEBY: ContractAddresses(
|
||||||
|
exchange="0xbce0b5f6eb618c565c3e5f5cd69652bbc279f44e",
|
||||||
|
erc20_proxy="0x2f5ae4f6106e89b4147651688a92256885c5f410",
|
||||||
|
erc721_proxy="0x7656d773e11ff7383a14dcf09a9c50990481cd10",
|
||||||
|
zrx_token="0x8080c7e4b81ecf23aa6f877cfbfd9b0c228c6ffa",
|
||||||
|
ether_token="0xc778417e063141139fce010982780140aa0cd5ab",
|
||||||
|
asset_proxy_owner="0xe1703da878afcebff5b7624a826902af475b9c03",
|
||||||
|
forwarder="0x2d40589abbdee84961f3a7656b9af7adb0ee5ab4",
|
||||||
|
order_validator="0x0c5173a51e26b29d6126c686756fb9fbef71f762",
|
||||||
|
),
|
||||||
|
NetworkId.KOVAN: ContractAddresses(
|
||||||
|
erc20_proxy="0xf1ec01d6236d3cd881a0bf0130ea25fe4234003e",
|
||||||
|
erc721_proxy="0x2a9127c745688a165106c11cd4d647d2220af821",
|
||||||
|
zrx_token="0x2002d3812f58e35f0ea1ffbf80a75a38c32175fa",
|
||||||
|
ether_token="0xd0a1e359811322d97991e03f863a0c30c2cf029c",
|
||||||
|
exchange="0x35dd2932454449b14cee11a94d3674a936d5d7b2",
|
||||||
|
asset_proxy_owner="0x2c824d2882baa668e0d5202b1e7f2922278703f8",
|
||||||
|
forwarder="0x17992e4ffb22730138e4b62aaa6367fa9d3699a6",
|
||||||
|
order_validator="0xb389da3d204b412df2f75c6afb3d0a7ce0bc283d",
|
||||||
|
),
|
||||||
|
NetworkId.GANACHE: ContractAddresses(
|
||||||
|
exchange="0x48bacb9266a570d521063ef5dd96e61686dbe788",
|
||||||
|
erc20_proxy="0x1dc4c1cefef38a777b15aa20260a54e584b16c48",
|
||||||
|
erc721_proxy="0x1d7022f5b17d2f8b695918fb48fa1089c9f85401",
|
||||||
|
zrx_token="0x871dd7c2b4b25e1aa18728e9d5f2af4c4e431f5c",
|
||||||
|
ether_token="0x0b1ba0af832d7c05fd64161e0db78e85978e8082",
|
||||||
|
asset_proxy_owner="0x34d402f14d58e001d8efbe6585051bf9706aa064",
|
||||||
|
forwarder="0xb69e673309512a9d726f87304c6984054f87a93b",
|
||||||
|
order_validator="0xe86bb98fcf9bff3512c74589b78fb168200cc546",
|
||||||
|
),
|
||||||
|
}
|
||||||
|
"""A mapping from instances of NetworkId to instances of ContractAddresses.
|
||||||
|
|
||||||
|
Addresses under NetworkId.Ganache are from our Ganache snapshot generated from
|
||||||
|
migrations.
|
||||||
|
|
||||||
|
>>> NETWORK_TO_ADDRESSES[NetworkId.MAINNET].exchange
|
||||||
|
0x4f833a24e1f95d70f028921e27040ca56e09ab0b
|
||||||
|
"""
|
@ -0,0 +1,7 @@
|
|||||||
|
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: ...
|
||||||
|
...
|
@ -0,0 +1,8 @@
|
|||||||
|
from distutils.dist import Distribution
|
||||||
|
from typing import Any, List
|
||||||
|
|
||||||
|
def setup(**attrs: Any) -> Distribution: ...
|
||||||
|
|
||||||
|
class Command: ...
|
||||||
|
|
||||||
|
def find_packages(where: str) -> List[str]: ...
|
@ -0,0 +1,3 @@
|
|||||||
|
from setuptools import Command
|
||||||
|
|
||||||
|
class test(Command): ...
|
12
python-packages/contract_addresses/tox.ini
Normal file
12
python-packages/contract_addresses/tox.ini
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# tox (https://tox.readthedocs.io/) is a tool for running tests
|
||||||
|
# in multiple virtualenvs. This configuration file will run the
|
||||||
|
# test suite on all supported python versions. To use it, "pip install tox"
|
||||||
|
# and then run "tox" from this directory.
|
||||||
|
|
||||||
|
[tox]
|
||||||
|
envlist = py37
|
||||||
|
|
||||||
|
[testenv]
|
||||||
|
commands =
|
||||||
|
pip install -e .[dev]
|
||||||
|
python setup.py lint
|
13
python-packages/contract_artifacts/.discharge.json
Normal file
13
python-packages/contract_artifacts/.discharge.json
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"domain": "0x-contract-artifacts-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
|
||||||
|
}
|
3
python-packages/contract_artifacts/.pylintrc
Normal file
3
python-packages/contract_artifacts/.pylintrc
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[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`.
|
45
python-packages/contract_artifacts/README.md
Normal file
45
python-packages/contract_artifacts/README.md
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
## 0x-contract-artifacts
|
||||||
|
|
||||||
|
0x smart contract compilation artifacts
|
||||||
|
|
||||||
|
Read the [documentation](http://0x-contract-artifacts-py.s3-website-us-east-1.amazonaws.com/)
|
||||||
|
|
||||||
|
## Installing
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install 0x-contract-artifacts
|
||||||
|
```
|
||||||
|
|
||||||
|
## 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.
|
188
python-packages/contract_artifacts/setup.py
Executable file
188
python-packages/contract_artifacts/setup.py
Executable file
@ -0,0 +1,188 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
"""setuptools module for contract_artifacts package."""
|
||||||
|
|
||||||
|
import subprocess # nosec
|
||||||
|
from shutil import rmtree
|
||||||
|
from os import environ, path
|
||||||
|
from sys import argv
|
||||||
|
|
||||||
|
from distutils.command.clean import clean
|
||||||
|
import distutils.command.build_py
|
||||||
|
from setuptools import find_packages, setup
|
||||||
|
|
||||||
|
|
||||||
|
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 src setup.py".split(),
|
||||||
|
# style guide checker (formerly pep8):
|
||||||
|
"pycodestyle --show-source --show-pep8 src setup.py".split(),
|
||||||
|
# docstring style checker:
|
||||||
|
"pydocstyle src setup.py".split(),
|
||||||
|
# static type checker:
|
||||||
|
"mypy src setup.py".split(),
|
||||||
|
# security issue checker:
|
||||||
|
"bandit -r src ./setup.py".split(),
|
||||||
|
# HACK: ensure contract artifacts match the authoritative copies:
|
||||||
|
# this is a hack. ideally we would symlink to the authoritative
|
||||||
|
# copies, but a problem with setuptools is preventing it from
|
||||||
|
# following symlinks when gathering package_data. see
|
||||||
|
# https://github.com/pypa/setuptools/issues/415.
|
||||||
|
(
|
||||||
|
"diff src/zero_ex/contract_artifacts/artifacts"
|
||||||
|
+ " ../../packages/contract-artifacts/artifacts"
|
||||||
|
).split(),
|
||||||
|
# general linter:
|
||||||
|
"pylint src 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("dist", ignore_errors=True)
|
||||||
|
rmtree(".mypy_cache", ignore_errors=True)
|
||||||
|
rmtree(".tox", ignore_errors=True)
|
||||||
|
rmtree(".pytest_cache", ignore_errors=True)
|
||||||
|
rmtree("src/0x_contract_artifacts.egg-info", ignore_errors=True)
|
||||||
|
|
||||||
|
|
||||||
|
class TestPublishCommand(distutils.command.build_py.build_py):
|
||||||
|
"""Custom command to publish to test.pypi.org."""
|
||||||
|
|
||||||
|
description = (
|
||||||
|
"Publish dist/* to test.pypi.org. Run sdist & bdist_wheel first."
|
||||||
|
)
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
"""Run twine to upload to test.pypi.org."""
|
||||||
|
subprocess.check_call( # nosec
|
||||||
|
(
|
||||||
|
"twine upload --repository-url https://test.pypi.org/legacy/"
|
||||||
|
+ " --verbose dist/*"
|
||||||
|
).split()
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class PublishCommand(distutils.command.build_py.build_py):
|
||||||
|
"""Custom command to publish to pypi.org."""
|
||||||
|
|
||||||
|
description = "Publish dist/* to pypi.org. Run sdist & bdist_wheel first."
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
"""Run twine to upload to pypi.org."""
|
||||||
|
subprocess.check_call("twine upload dist/*".split()) # nosec
|
||||||
|
|
||||||
|
|
||||||
|
class PublishDocsCommand(distutils.command.build_py.build_py):
|
||||||
|
"""Custom command to publish docs to S3."""
|
||||||
|
|
||||||
|
description = (
|
||||||
|
"Publish docs to "
|
||||||
|
+ "http://0x-contract-artifacts-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
|
||||||
|
|
||||||
|
|
||||||
|
with open("README.md", "r") as file_handle:
|
||||||
|
README_MD = file_handle.read()
|
||||||
|
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name="0x-contract-artifacts",
|
||||||
|
version="2.0.0",
|
||||||
|
description="0x smart contract compilation artifacts",
|
||||||
|
long_description=README_MD,
|
||||||
|
long_description_content_type="text/markdown",
|
||||||
|
url=(
|
||||||
|
"https://github.com/0xproject/0x-monorepo/tree/development"
|
||||||
|
+ "/python-packages/contract_artifacts"
|
||||||
|
),
|
||||||
|
author="F. Eugene Aumson",
|
||||||
|
author_email="feuGeneA@users.noreply.github.com",
|
||||||
|
cmdclass={
|
||||||
|
"clean": CleanCommandExtension,
|
||||||
|
"lint": LintCommand,
|
||||||
|
"test_publish": TestPublishCommand,
|
||||||
|
"publish": PublishCommand,
|
||||||
|
"publish_docs": PublishDocsCommand,
|
||||||
|
},
|
||||||
|
install_requires=["mypy_extensions"],
|
||||||
|
extras_require={
|
||||||
|
"dev": [
|
||||||
|
"bandit",
|
||||||
|
"black",
|
||||||
|
"coverage",
|
||||||
|
"coveralls",
|
||||||
|
"mypy",
|
||||||
|
"mypy_extensions",
|
||||||
|
"pycodestyle",
|
||||||
|
"pydocstyle",
|
||||||
|
"pylint",
|
||||||
|
"pytest",
|
||||||
|
"sphinx",
|
||||||
|
"tox",
|
||||||
|
"twine",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
python_requires=">=3.6, <4",
|
||||||
|
package_data={"zero_ex.contract_artifacts": ["py.typed", "artifacts/*"]},
|
||||||
|
package_dir={"": "src"},
|
||||||
|
license="Apache 2.0",
|
||||||
|
keywords=(
|
||||||
|
"ethereum cryptocurrency 0x decentralized blockchain dex exchange"
|
||||||
|
),
|
||||||
|
namespace_packages=["zero_ex"],
|
||||||
|
packages=find_packages("src"),
|
||||||
|
classifiers=[
|
||||||
|
"Development Status :: 5 - Production/Stable",
|
||||||
|
"Intended Audience :: Developers",
|
||||||
|
"Intended Audience :: Financial and Insurance Industry",
|
||||||
|
"License :: OSI Approved :: Apache Software License",
|
||||||
|
"Natural Language :: English",
|
||||||
|
"Operating System :: OS Independent",
|
||||||
|
"Programming Language :: Python",
|
||||||
|
"Programming Language :: Python :: 3 :: Only",
|
||||||
|
"Programming Language :: Python :: 3.6",
|
||||||
|
"Programming Language :: Python :: 3.7",
|
||||||
|
"Topic :: Internet :: WWW/HTTP",
|
||||||
|
"Topic :: Office/Business :: Financial",
|
||||||
|
"Topic :: Other/Nonlisted Topic",
|
||||||
|
"Topic :: Security :: Cryptography",
|
||||||
|
"Topic :: Software Development :: Libraries",
|
||||||
|
"Topic :: Utilities",
|
||||||
|
],
|
||||||
|
zip_safe=False, # required per mypy
|
||||||
|
command_options={
|
||||||
|
"build_sphinx": {
|
||||||
|
"source_dir": ("setup.py", "src"),
|
||||||
|
"build_dir": ("setup.py", "build/docs"),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
54
python-packages/contract_artifacts/src/conf.py
Normal file
54
python-packages/contract_artifacts/src/conf.py
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
"""Configuration file for the Sphinx documentation builder."""
|
||||||
|
|
||||||
|
# Reference: http://www.sphinx-doc.org/en/master/config
|
||||||
|
|
||||||
|
from typing import List
|
||||||
|
import pkg_resources
|
||||||
|
|
||||||
|
|
||||||
|
# pylint: disable=invalid-name
|
||||||
|
# because these variables are not named in upper case, as globals should be.
|
||||||
|
|
||||||
|
project = "0x-contract-artifacts"
|
||||||
|
# pylint: disable=redefined-builtin
|
||||||
|
copyright = "2018, ZeroEx, Intl."
|
||||||
|
author = "F. Eugene Aumson"
|
||||||
|
version = pkg_resources.get_distribution("0x-contract-artifacts").version
|
||||||
|
release = "" # The full version, including alpha/beta/rc tags
|
||||||
|
|
||||||
|
extensions = [
|
||||||
|
"sphinx.ext.autodoc",
|
||||||
|
"sphinx.ext.doctest",
|
||||||
|
"sphinx.ext.intersphinx",
|
||||||
|
"sphinx.ext.coverage",
|
||||||
|
"sphinx.ext.viewcode",
|
||||||
|
]
|
||||||
|
|
||||||
|
templates_path = ["doc_templates"]
|
||||||
|
|
||||||
|
source_suffix = ".rst"
|
||||||
|
# eg: source_suffix = [".rst", ".md"]
|
||||||
|
|
||||||
|
master_doc = "index" # The master toctree document.
|
||||||
|
|
||||||
|
language = None
|
||||||
|
|
||||||
|
exclude_patterns: List[str] = []
|
||||||
|
|
||||||
|
# The name of the Pygments (syntax highlighting) style to use.
|
||||||
|
pygments_style = None
|
||||||
|
|
||||||
|
html_theme = "alabaster"
|
||||||
|
|
||||||
|
html_static_path = ["doc_static"]
|
||||||
|
# Add any paths that contain custom static files (such as style sheets) here,
|
||||||
|
# relative to this directory. They are copied after the builtin static files,
|
||||||
|
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||||
|
|
||||||
|
# Output file base name for HTML help builder.
|
||||||
|
htmlhelp_basename = "contract_artifactspydoc"
|
||||||
|
|
||||||
|
# -- Extension configuration:
|
||||||
|
|
||||||
|
# Example configuration for intersphinx: refer to the Python standard library.
|
||||||
|
intersphinx_mapping = {"https://docs.python.org/": None}
|
18
python-packages/contract_artifacts/src/index.rst
Normal file
18
python-packages/contract_artifacts/src/index.rst
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
.. source for the sphinx-generated build/docs/web/index.html
|
||||||
|
|
||||||
|
Python zero_ex.contract_artifacts
|
||||||
|
=================================
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:maxdepth: 2
|
||||||
|
:caption: Contents:
|
||||||
|
|
||||||
|
.. automodule:: zero_ex.contract_artifacts
|
||||||
|
:members:
|
||||||
|
|
||||||
|
Indices and tables
|
||||||
|
==================
|
||||||
|
|
||||||
|
* :ref:`genindex`
|
||||||
|
* :ref:`modindex`
|
||||||
|
* :ref:`search`
|
@ -0,0 +1,2 @@
|
|||||||
|
"""0x Python API."""
|
||||||
|
__import__("pkg_resources").declare_namespace(__name__)
|
@ -0,0 +1,35 @@
|
|||||||
|
"""0x smart contract compilation artifacts."""
|
||||||
|
|
||||||
|
import json
|
||||||
|
from typing import Dict
|
||||||
|
from pkg_resources import resource_string
|
||||||
|
|
||||||
|
|
||||||
|
class _ArtifactCache:
|
||||||
|
"""A cache to facilitate lazy & singular loading of contract artifacts."""
|
||||||
|
|
||||||
|
_contract_name_to_abi: Dict[str, Dict] = {} # class data, not instance
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def contract_name_to_abi(cls, contract_name: str) -> Dict:
|
||||||
|
"""Return the ABI for the given contract name.
|
||||||
|
|
||||||
|
First tries to get data from the class level storage
|
||||||
|
`_contract_name_to_abi`. If it's not there, loads it from disk, stores
|
||||||
|
it in the class data (for the next caller), and then returns it.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
return cls._contract_name_to_abi[contract_name]
|
||||||
|
except KeyError:
|
||||||
|
cls._contract_name_to_abi[contract_name] = json.loads(
|
||||||
|
resource_string(
|
||||||
|
"zero_ex.contract_artifacts",
|
||||||
|
f"artifacts/{contract_name}.json",
|
||||||
|
)
|
||||||
|
)["compilerOutput"]["abi"]
|
||||||
|
return cls._contract_name_to_abi[contract_name]
|
||||||
|
|
||||||
|
|
||||||
|
def abi_by_name(contract_name: str) -> Dict:
|
||||||
|
"""Return the ABI for the named contract."""
|
||||||
|
return _ArtifactCache.contract_name_to_abi(contract_name)
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,189 @@
|
|||||||
|
{
|
||||||
|
"schemaVersion": "2.0.0",
|
||||||
|
"contractName": "ERC20Token",
|
||||||
|
"compilerOutput": {
|
||||||
|
"abi": [
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "_spender",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "_value",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "approve",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "bool"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"stateMutability": "nonpayable",
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [],
|
||||||
|
"name": "totalSupply",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"stateMutability": "view",
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "_from",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "_to",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "_value",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "transferFrom",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "bool"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"stateMutability": "nonpayable",
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "_owner",
|
||||||
|
"type": "address"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "balanceOf",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"stateMutability": "view",
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "_to",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "_value",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "transfer",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "bool"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"stateMutability": "nonpayable",
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "_owner",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "_spender",
|
||||||
|
"type": "address"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "allowance",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"stateMutability": "view",
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"anonymous": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"name": "_from",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"name": "_to",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"name": "_value",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "Transfer",
|
||||||
|
"type": "event"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"anonymous": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"name": "_owner",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"name": "_spender",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"name": "_value",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "Approval",
|
||||||
|
"type": "event"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"evm": {
|
||||||
|
"bytecode": {
|
||||||
|
"linkReferences": {},
|
||||||
|
"object":
|
||||||
|
"0x608060405234801561001057600080fd5b506106a0806100206000396000f3006080604052600436106100775763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663095ea7b3811461007c57806318160ddd146100c157806323b872dd146100e857806370a082311461011f578063a9059cbb1461014d578063dd62ed3e1461017e575b600080fd5b34801561008857600080fd5b506100ad73ffffffffffffffffffffffffffffffffffffffff600435166024356101b2565b604080519115158252519081900360200190f35b3480156100cd57600080fd5b506100d6610225565b60408051918252519081900360200190f35b3480156100f457600080fd5b506100ad73ffffffffffffffffffffffffffffffffffffffff6004358116906024351660443561022b565b34801561012b57600080fd5b506100d673ffffffffffffffffffffffffffffffffffffffff60043516610487565b34801561015957600080fd5b506100ad73ffffffffffffffffffffffffffffffffffffffff600435166024356104af565b34801561018a57600080fd5b506100d673ffffffffffffffffffffffffffffffffffffffff6004358116906024351661063c565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b60025490565b73ffffffffffffffffffffffffffffffffffffffff83166000908152602081905260408120548211156102bf57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f45524332305f494e53554646494349454e545f42414c414e4345000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8416600090815260016020908152604080832033845290915290205482111561035e57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f45524332305f494e53554646494349454e545f414c4c4f57414e434500000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff831660009081526020819052604090205482810110156103f457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f55494e543235365f4f564552464c4f5700000000000000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff80841660008181526020818152604080832080548801905593881680835284832080548890039055600182528483203384528252918490208054879003905583518681529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35060019392505050565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205490565b3360009081526020819052604081205482111561052d57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f45524332305f494e53554646494349454e545f42414c414e4345000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff831660009081526020819052604090205482810110156105c357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f55494e543235365f4f564552464c4f5700000000000000000000000000000000604482015290519081900360640190fd5b336000818152602081815260408083208054879003905573ffffffffffffffffffffffffffffffffffffffff871680845292819020805487019055805186815290519293927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a350600192915050565b73ffffffffffffffffffffffffffffffffffffffff9182166000908152600160209081526040808320939094168252919091522054905600a165627a7a72305820203a592c9390a8a005821d7dffa1c27ae97bf827d8ef17cfee3a8a70776b22d90029"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"networks": {}
|
||||||
|
}
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,41 @@
|
|||||||
|
{
|
||||||
|
"schemaVersion": "2.0.0",
|
||||||
|
"contractName": "IValidator",
|
||||||
|
"compilerOutput": {
|
||||||
|
"abi": [
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "hash",
|
||||||
|
"type": "bytes32"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "signerAddress",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "signature",
|
||||||
|
"type": "bytes"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "isValidSignature",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "isValid",
|
||||||
|
"type": "bool"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"stateMutability": "view",
|
||||||
|
"type": "function"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"evm": {
|
||||||
|
"bytecode": {
|
||||||
|
"object": "0x"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"networks": {}
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
{
|
||||||
|
"schemaVersion": "2.0.0",
|
||||||
|
"contractName": "IWallet",
|
||||||
|
"compilerOutput": {
|
||||||
|
"abi": [
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "hash",
|
||||||
|
"type": "bytes32"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "signature",
|
||||||
|
"type": "bytes"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "isValidSignature",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "isValid",
|
||||||
|
"type": "bool"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"stateMutability": "view",
|
||||||
|
"type": "function"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"evm": {
|
||||||
|
"bytecode": {
|
||||||
|
"object": "0x"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"networks": {}
|
||||||
|
}
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,293 @@
|
|||||||
|
{
|
||||||
|
"schemaVersion": "2.0.0",
|
||||||
|
"contractName": "WETH9",
|
||||||
|
"compilerOutput": {
|
||||||
|
"abi": [
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [],
|
||||||
|
"name": "name",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"stateMutability": "view",
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "guy",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "wad",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "approve",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "bool"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"stateMutability": "nonpayable",
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [],
|
||||||
|
"name": "totalSupply",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"stateMutability": "view",
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "src",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "dst",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "wad",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "transferFrom",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "bool"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"stateMutability": "nonpayable",
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "wad",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "withdraw",
|
||||||
|
"outputs": [],
|
||||||
|
"payable": false,
|
||||||
|
"stateMutability": "nonpayable",
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [],
|
||||||
|
"name": "decimals",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "uint8"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"stateMutability": "view",
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "address"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "balanceOf",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"stateMutability": "view",
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [],
|
||||||
|
"name": "symbol",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"stateMutability": "view",
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "dst",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "wad",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "transfer",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "bool"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"stateMutability": "nonpayable",
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"inputs": [],
|
||||||
|
"name": "deposit",
|
||||||
|
"outputs": [],
|
||||||
|
"payable": true,
|
||||||
|
"stateMutability": "payable",
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "address"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "allowance",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"stateMutability": "view",
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"payable": true,
|
||||||
|
"stateMutability": "payable",
|
||||||
|
"type": "fallback"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"anonymous": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"name": "_owner",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"name": "_spender",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"name": "_value",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "Approval",
|
||||||
|
"type": "event"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"anonymous": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"name": "_from",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"name": "_to",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"name": "_value",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "Transfer",
|
||||||
|
"type": "event"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"anonymous": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"name": "_owner",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"name": "_value",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "Deposit",
|
||||||
|
"type": "event"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"anonymous": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"name": "_owner",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"name": "_value",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "Withdrawal",
|
||||||
|
"type": "event"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"evm": {
|
||||||
|
"bytecode": {
|
||||||
|
"linkReferences": {},
|
||||||
|
"object":
|
||||||
|
"0x60c0604052600d60808190527f577261707065642045746865720000000000000000000000000000000000000060a090815261003e91600091906100a3565b506040805180820190915260048082527f57455448000000000000000000000000000000000000000000000000000000006020909201918252610083916001916100a3565b506002805460ff1916601217905534801561009d57600080fd5b5061013e565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106100e457805160ff1916838001178555610111565b82800160010185558215610111579182015b828111156101115782518255916020019190600101906100f6565b5061011d929150610121565b5090565b61013b91905b8082111561011d5760008155600101610127565b90565b6107688061014d6000396000f3006080604052600436106100ae5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde0381146100b8578063095ea7b31461014257806318160ddd1461018757806323b872dd146101ae5780632e1a7d4d146101e5578063313ce567146101fd57806370a082311461022857806395d89b4114610256578063a9059cbb1461026b578063d0e30db0146100ae578063dd62ed3e1461029c575b6100b66102d0565b005b3480156100c457600080fd5b506100cd61031f565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101075781810151838201526020016100ef565b50505050905090810190601f1680156101345780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561014e57600080fd5b5061017373ffffffffffffffffffffffffffffffffffffffff600435166024356103cb565b604080519115158252519081900360200190f35b34801561019357600080fd5b5061019c61043e565b60408051918252519081900360200190f35b3480156101ba57600080fd5b5061017373ffffffffffffffffffffffffffffffffffffffff60043581169060243516604435610443565b3480156101f157600080fd5b506100b66004356105e3565b34801561020957600080fd5b50610212610678565b6040805160ff9092168252519081900360200190f35b34801561023457600080fd5b5061019c73ffffffffffffffffffffffffffffffffffffffff60043516610681565b34801561026257600080fd5b506100cd610693565b34801561027757600080fd5b5061017373ffffffffffffffffffffffffffffffffffffffff6004351660243561070b565b3480156102a857600080fd5b5061019c73ffffffffffffffffffffffffffffffffffffffff6004358116906024351661071f565b33600081815260036020908152604091829020805434908101909155825190815291517fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c9281900390910190a2565b6000805460408051602060026001851615610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190941693909304601f810184900484028201840190925281815292918301828280156103c35780601f10610398576101008083540402835291602001916103c3565b820191906000526020600020905b8154815290600101906020018083116103a657829003601f168201915b505050505081565b33600081815260046020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b303190565b73ffffffffffffffffffffffffffffffffffffffff831660009081526003602052604081205482111561047557600080fd5b73ffffffffffffffffffffffffffffffffffffffff841633148015906104eb575073ffffffffffffffffffffffffffffffffffffffff841660009081526004602090815260408083203384529091529020547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff14155b156105655773ffffffffffffffffffffffffffffffffffffffff8416600090815260046020908152604080832033845290915290205482111561052d57600080fd5b73ffffffffffffffffffffffffffffffffffffffff841660009081526004602090815260408083203384529091529020805483900390555b73ffffffffffffffffffffffffffffffffffffffff808516600081815260036020908152604080832080548890039055938716808352918490208054870190558351868152935191937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929081900390910190a35060019392505050565b336000908152600360205260409020548111156105ff57600080fd5b33600081815260036020526040808220805485900390555183156108fc0291849190818181858888f1935050505015801561063e573d6000803e3d6000fd5b5060408051828152905133917f7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65919081900360200190a250565b60025460ff1681565b60036020526000908152604090205481565b60018054604080516020600284861615610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190941693909304601f810184900484028201840190925281815292918301828280156103c35780601f10610398576101008083540402835291602001916103c3565b6000610718338484610443565b9392505050565b6004602090815260009283526040808420909152908252902054815600a165627a7a72305820228981f11f47ad9630080069b0a81423fcfba5aa8e0f478a579c4bc080ba7e820029"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"networks": {}
|
||||||
|
}
|
@ -0,0 +1,227 @@
|
|||||||
|
{
|
||||||
|
"schemaVersion": "2.0.0",
|
||||||
|
"contractName": "ZRXToken",
|
||||||
|
"compilerOutput": {
|
||||||
|
"abi": [
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [],
|
||||||
|
"name": "name",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "_spender",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "_value",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "approve",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "bool"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [],
|
||||||
|
"name": "totalSupply",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "_from",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "_to",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "_value",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "transferFrom",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "bool"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [],
|
||||||
|
"name": "decimals",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "uint8"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "_owner",
|
||||||
|
"type": "address"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "balanceOf",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [],
|
||||||
|
"name": "symbol",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "_to",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "_value",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "transfer",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "bool"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constant": true,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "_owner",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "_spender",
|
||||||
|
"type": "address"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "allowance",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"payable": false,
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"inputs": [],
|
||||||
|
"payable": false,
|
||||||
|
"type": "constructor"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"anonymous": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"name": "_from",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"name": "_to",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"name": "_value",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "Transfer",
|
||||||
|
"type": "event"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"anonymous": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"name": "_owner",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": true,
|
||||||
|
"name": "_spender",
|
||||||
|
"type": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"indexed": false,
|
||||||
|
"name": "_value",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "Approval",
|
||||||
|
"type": "event"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"evm": {
|
||||||
|
"bytecode": {
|
||||||
|
"linkReferences": {},
|
||||||
|
"object":
|
||||||
|
"0x60606040526b033b2e3c9fd0803ce8000000600355341561001c57fe5b5b600354600160a060020a0333166000908152602081905260409020555b5b61078d8061004a6000396000f300606060405236156100965763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde038114610098578063095ea7b31461014657806318160ddd1461018657806323b872dd146101a8578063313ce567146101ee57806370a082311461021457806395d89b411461024f578063a9059cbb146102fd578063dd62ed3e1461033d575bfe5b34156100a057fe5b6100a861037e565b60408051602080825283518183015283519192839290830191850190808383821561010c575b80518252602083111561010c577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016100ce565b505050905090810190601f1680156101385780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561014e57fe5b61017273ffffffffffffffffffffffffffffffffffffffff600435166024356103b5565b604080519115158252519081900360200190f35b341561018e57fe5b61019661042d565b60408051918252519081900360200190f35b34156101b057fe5b61017273ffffffffffffffffffffffffffffffffffffffff60043581169060243516604435610433565b604080519115158252519081900360200190f35b34156101f657fe5b6101fe6105d4565b6040805160ff9092168252519081900360200190f35b341561021c57fe5b61019673ffffffffffffffffffffffffffffffffffffffff600435166105d9565b60408051918252519081900360200190f35b341561025757fe5b6100a8610605565b60408051602080825283518183015283519192839290830191850190808383821561010c575b80518252602083111561010c577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016100ce565b505050905090810190601f1680156101385780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561030557fe5b61017273ffffffffffffffffffffffffffffffffffffffff6004351660243561063c565b604080519115158252519081900360200190f35b341561034557fe5b61019673ffffffffffffffffffffffffffffffffffffffff60043581169060243516610727565b60408051918252519081900360200190f35b60408051808201909152601181527f30782050726f746f636f6c20546f6b656e000000000000000000000000000000602082015281565b73ffffffffffffffffffffffffffffffffffffffff338116600081815260016020908152604080832094871680845294825280832086905580518681529051929493927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060015b92915050565b60035481565b73ffffffffffffffffffffffffffffffffffffffff808416600081815260016020908152604080832033909516835293815283822054928252819052918220548390108015906104835750828110155b80156104b6575073ffffffffffffffffffffffffffffffffffffffff841660009081526020819052604090205483810110155b156105c65773ffffffffffffffffffffffffffffffffffffffff808516600090815260208190526040808220805487019055918716815220805484900390557fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8110156105585773ffffffffffffffffffffffffffffffffffffffff808616600090815260016020908152604080832033909416835292905220805484900390555b8373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3600191506105cb565b600091505b5b509392505050565b601281565b73ffffffffffffffffffffffffffffffffffffffff81166000908152602081905260409020545b919050565b60408051808201909152600381527f5a52580000000000000000000000000000000000000000000000000000000000602082015281565b73ffffffffffffffffffffffffffffffffffffffff3316600090815260208190526040812054829010801590610699575073ffffffffffffffffffffffffffffffffffffffff831660009081526020819052604090205482810110155b156107185773ffffffffffffffffffffffffffffffffffffffff33811660008181526020818152604080832080548890039055938716808352918490208054870190558351868152935191937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929081900390910190a3506001610427565b506000610427565b5b92915050565b73ffffffffffffffffffffffffffffffffffffffff8083166000908152600160209081526040808320938516835292905220545b929150505600a165627a7a723058201b5b70cf82a73dec658c2e60ab9a0f8e2ba01a74b66a6f5b0402f56d2ea0ffcf0029"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"networks": {}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
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: ...
|
||||||
|
...
|
@ -0,0 +1,8 @@
|
|||||||
|
from distutils.dist import Distribution
|
||||||
|
from typing import Any, List
|
||||||
|
|
||||||
|
def setup(**attrs: Any) -> Distribution: ...
|
||||||
|
|
||||||
|
class Command: ...
|
||||||
|
|
||||||
|
def find_packages(where: str) -> List[str]: ...
|
@ -0,0 +1,3 @@
|
|||||||
|
from setuptools import Command
|
||||||
|
|
||||||
|
class test(Command): ...
|
12
python-packages/contract_artifacts/tox.ini
Normal file
12
python-packages/contract_artifacts/tox.ini
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# tox (https://tox.readthedocs.io/) is a tool for running tests
|
||||||
|
# in multiple virtualenvs. This configuration file will run the
|
||||||
|
# test suite on all supported python versions. To use it, "pip install tox"
|
||||||
|
# and then run "tox" from this directory.
|
||||||
|
|
||||||
|
[tox]
|
||||||
|
envlist = py37
|
||||||
|
|
||||||
|
[testenv]
|
||||||
|
commands =
|
||||||
|
pip install -e .[dev]
|
||||||
|
python setup.py lint
|
13
python-packages/contract_demo/.discharge.json
Normal file
13
python-packages/contract_demo/.discharge.json
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"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
|
||||||
|
}
|
39
python-packages/contract_demo/README.md
Normal file
39
python-packages/contract_demo/README.md
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
## 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.
|
146
python-packages/contract_demo/setup.py
Executable file
146
python-packages/contract_demo/setup.py
Executable file
@ -0,0 +1,146 @@
|
|||||||
|
#!/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"),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
0
python-packages/contract_demo/stubs/__init__.pyi
Normal file
0
python-packages/contract_demo/stubs/__init__.pyi
Normal file
7
python-packages/contract_demo/stubs/command/clean.pyi
Normal file
7
python-packages/contract_demo/stubs/command/clean.pyi
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
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: ...
|
||||||
|
...
|
@ -0,0 +1,7 @@
|
|||||||
|
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: ...
|
||||||
|
...
|
@ -0,0 +1,4 @@
|
|||||||
|
from typing import Union
|
||||||
|
|
||||||
|
def to_checksum_address(value: Union[str, bytes]) -> str:
|
||||||
|
...
|
@ -0,0 +1,8 @@
|
|||||||
|
from distutils.dist import Distribution
|
||||||
|
from typing import Any, List
|
||||||
|
|
||||||
|
def setup(**attrs: Any) -> Distribution: ...
|
||||||
|
|
||||||
|
class Command: ...
|
||||||
|
|
||||||
|
def find_packages(where: str) -> List[str]: ...
|
@ -0,0 +1,3 @@
|
|||||||
|
from setuptools import Command
|
||||||
|
|
||||||
|
class test(Command): ...
|
2
python-packages/contract_demo/stubs/web3/__init__.pyi
Normal file
2
python-packages/contract_demo/stubs/web3/__init__.pyi
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
class Web3:
|
||||||
|
...
|
@ -0,0 +1,3 @@
|
|||||||
|
class Contract:
|
||||||
|
def call(self): ...
|
||||||
|
...
|
1
python-packages/contract_demo/test/__init__.py
Normal file
1
python-packages/contract_demo/test/__init__.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
"""Demonstrations of calling 0x smart contracts."""
|
54
python-packages/contract_demo/test/conf.py
Normal file
54
python-packages/contract_demo/test/conf.py
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
"""Configuration file for the Sphinx documentation builder."""
|
||||||
|
|
||||||
|
# Reference: http://www.sphinx-doc.org/en/master/config
|
||||||
|
|
||||||
|
from typing import List
|
||||||
|
import pkg_resources
|
||||||
|
|
||||||
|
|
||||||
|
# pylint: disable=invalid-name
|
||||||
|
# because these variables are not named in upper case, as globals should be.
|
||||||
|
|
||||||
|
project = "0x-contract-demo"
|
||||||
|
# pylint: disable=redefined-builtin
|
||||||
|
copyright = "2018, ZeroEx, Intl."
|
||||||
|
author = "F. Eugene Aumson"
|
||||||
|
version = pkg_resources.get_distribution("0x-contract-demo").version
|
||||||
|
release = "" # The full version, including alpha/beta/rc tags
|
||||||
|
|
||||||
|
extensions = [
|
||||||
|
"sphinx.ext.autodoc",
|
||||||
|
"sphinx.ext.doctest",
|
||||||
|
"sphinx.ext.intersphinx",
|
||||||
|
"sphinx.ext.coverage",
|
||||||
|
"sphinx.ext.viewcode",
|
||||||
|
]
|
||||||
|
|
||||||
|
templates_path = ["doc_templates"]
|
||||||
|
|
||||||
|
source_suffix = ".rst"
|
||||||
|
# eg: source_suffix = [".rst", ".md"]
|
||||||
|
|
||||||
|
master_doc = "index" # The master toctree document.
|
||||||
|
|
||||||
|
language = None
|
||||||
|
|
||||||
|
exclude_patterns: List[str] = []
|
||||||
|
|
||||||
|
# The name of the Pygments (syntax highlighting) style to use.
|
||||||
|
pygments_style = None
|
||||||
|
|
||||||
|
html_theme = "alabaster"
|
||||||
|
|
||||||
|
html_static_path = ["doc_static"]
|
||||||
|
# Add any paths that contain custom static files (such as style sheets) here,
|
||||||
|
# relative to this directory. They are copied after the builtin static files,
|
||||||
|
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||||
|
|
||||||
|
# Output file base name for HTML help builder.
|
||||||
|
htmlhelp_basename = "contract_demopydoc"
|
||||||
|
|
||||||
|
# -- Extension configuration:
|
||||||
|
|
||||||
|
# Example configuration for intersphinx: refer to the Python standard library.
|
||||||
|
intersphinx_mapping = {"https://docs.python.org/": None}
|
18
python-packages/contract_demo/test/index.rst
Normal file
18
python-packages/contract_demo/test/index.rst
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
.. source for the sphinx-generated build/docs/web/index.html
|
||||||
|
|
||||||
|
Python demo of 0x Smart Contracts
|
||||||
|
=================================
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:maxdepth: 2
|
||||||
|
:caption: Contents:
|
||||||
|
|
||||||
|
.. automodule:: test.test_exchange
|
||||||
|
:members:
|
||||||
|
|
||||||
|
Indices and tables
|
||||||
|
==================
|
||||||
|
|
||||||
|
* :ref:`genindex`
|
||||||
|
* :ref:`modindex`
|
||||||
|
* :ref:`search`
|
65
python-packages/contract_demo/test/test_exchange.py
Normal file
65
python-packages/contract_demo/test/test_exchange.py
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
"""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
|
13
python-packages/install
Executable file
13
python-packages/install
Executable file
@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
"""Install all packages in non-editable mode (no -e on pip install)."""
|
||||||
|
|
||||||
|
from os import path
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
# install all packages
|
||||||
|
subprocess.check_call(
|
||||||
|
(
|
||||||
|
path.join(".", "cmd_pkgs_in_dep_order.py") + " pip install .[dev]"
|
||||||
|
).split()
|
||||||
|
)
|
13
python-packages/install_editable
Executable file
13
python-packages/install_editable
Executable file
@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
"""Script to install all packages in editable mode (pip install -e .)."""
|
||||||
|
|
||||||
|
from os import path
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
# install all packages
|
||||||
|
subprocess.check_call(
|
||||||
|
(
|
||||||
|
path.join(".", "cmd_pkgs_in_dep_order.py") + " pip install -e .[dev]"
|
||||||
|
).split()
|
||||||
|
)
|
@ -20,7 +20,7 @@ class TestCommandExtension(TestCommand):
|
|||||||
"""Invoke pytest."""
|
"""Invoke pytest."""
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
exit(pytest.main())
|
exit(pytest.main(["--doctest-modules"]))
|
||||||
|
|
||||||
|
|
||||||
class LintCommand(distutils.command.build_py.build_py):
|
class LintCommand(distutils.command.build_py.build_py):
|
||||||
@ -41,6 +41,15 @@ class LintCommand(distutils.command.build_py.build_py):
|
|||||||
"mypy src test setup.py".split(),
|
"mypy src test setup.py".split(),
|
||||||
# security issue checker:
|
# security issue checker:
|
||||||
"bandit -r src ./setup.py".split(),
|
"bandit -r src ./setup.py".split(),
|
||||||
|
# HACK: ensure json schemas don't differ from the authoritative
|
||||||
|
# copies: this is a hack. ideally we would symlink to the
|
||||||
|
# authoritative copies, but a problem with setuptools is preventing
|
||||||
|
# it from following symlinks when gathering package_data. see
|
||||||
|
# https://github.com/pypa/setuptools/issues/415.
|
||||||
|
(
|
||||||
|
"diff src/zero_ex/json_schemas/schemas"
|
||||||
|
+ " ../../packages/json-schemas/schemas"
|
||||||
|
).split(),
|
||||||
# general linter:
|
# general linter:
|
||||||
"pylint src test setup.py".split(),
|
"pylint src test setup.py".split(),
|
||||||
# pylint takes relatively long to run, so it runs last, to enable
|
# pylint takes relatively long to run, so it runs last, to enable
|
||||||
|
@ -1 +0,0 @@
|
|||||||
../../../../../packages/json-schemas/schemas/
|
|
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"id": "/addressSchema",
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^0x[0-9a-f]{40}$"
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"id": "/AssetPairsRequestOptsSchema",
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"assetDataA": { "$ref": "/hexSchema" },
|
||||||
|
"assetDataB": { "$ref": "/hexSchema" }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"id": "/blockParamSchema",
|
||||||
|
"oneOf": [
|
||||||
|
{
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"enum": ["latest", "earliest", "pending"]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"id": "/blockRangeSchema",
|
||||||
|
"properties": {
|
||||||
|
"fromBlock": { "$ref": "/blockParamSchema" },
|
||||||
|
"toBlock": { "$ref": "/blockParamSchema" }
|
||||||
|
},
|
||||||
|
"type": "object"
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"id": "/callDataSchema",
|
||||||
|
"properties": {
|
||||||
|
"from": { "$ref": "/addressSchema" },
|
||||||
|
"to": { "$ref": "/addressSchema" },
|
||||||
|
"value": {
|
||||||
|
"oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/jsNumberSchema" }]
|
||||||
|
},
|
||||||
|
"gas": {
|
||||||
|
"oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/jsNumberSchema" }]
|
||||||
|
},
|
||||||
|
"gasPrice": {
|
||||||
|
"oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/jsNumberSchema" }]
|
||||||
|
},
|
||||||
|
"data": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^0x[0-9a-f]*$"
|
||||||
|
},
|
||||||
|
"nonce": {
|
||||||
|
"type": "number",
|
||||||
|
"minimum": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [],
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"id": "/ecSignatureParameterSchema",
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^0[xX][0-9A-Fa-f]{64}$"
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"id": "/ecSignatureSchema",
|
||||||
|
"properties": {
|
||||||
|
"v": {
|
||||||
|
"type": "number",
|
||||||
|
"minimum": 27,
|
||||||
|
"maximum": 28
|
||||||
|
},
|
||||||
|
"r": { "$ref": "/ecSignatureParameterSchema" },
|
||||||
|
"s": { "$ref": "/ecSignatureParameterSchema" }
|
||||||
|
},
|
||||||
|
"required": ["v", "r", "s"],
|
||||||
|
"type": "object"
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
"id": "/eip712TypedDataSchema",
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"types": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"EIP712Domain": { "type": "array" }
|
||||||
|
},
|
||||||
|
"additionalProperties": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"name": { "type": "string" },
|
||||||
|
"type": { "type": "string" }
|
||||||
|
},
|
||||||
|
"required": ["name", "type"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": ["EIP712Domain"]
|
||||||
|
},
|
||||||
|
"primaryType": { "type": "string" },
|
||||||
|
"domain": { "type": "object" },
|
||||||
|
"message": { "type": "object" }
|
||||||
|
},
|
||||||
|
"required": ["types", "primaryType", "domain", "message"]
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"id": "/hexSchema",
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^0x(([0-9a-f][0-9a-f])+)?$"
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"id": "/indexFilterValuesSchema",
|
||||||
|
"additionalProperties": {
|
||||||
|
"oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/addressSchema" }, { "$ref": "/orderHashSchema" }]
|
||||||
|
},
|
||||||
|
"type": "object"
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"id": "/jsNumberSchema",
|
||||||
|
"type": "number",
|
||||||
|
"minimum": 0
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"id": "/numberSchema",
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^\\d+(\\.\\d+)?$"
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"id": "/orderCancellationRequestsSchema",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"properties": {
|
||||||
|
"order": { "$ref": "/orderSchema" },
|
||||||
|
"takerTokenCancelAmount": { "$ref": "/wholeNumberSchema" }
|
||||||
|
},
|
||||||
|
"required": ["order", "takerTokenCancelAmount"],
|
||||||
|
"type": "object"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"id": "/OrderConfigRequestSchema",
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"makerAddress": { "$ref": "/addressSchema" },
|
||||||
|
"takerAddress": { "$ref": "/addressSchema" },
|
||||||
|
"makerAssetAmount": { "$ref": "/wholeNumberSchema" },
|
||||||
|
"takerAssetAmount": { "$ref": "/wholeNumberSchema" },
|
||||||
|
"makerAssetData": { "$ref": "/hexSchema" },
|
||||||
|
"takerAssetData": { "$ref": "/hexSchema" },
|
||||||
|
"exchangeAddress": { "$ref": "/addressSchema" },
|
||||||
|
"expirationTimeSeconds": { "$ref": "/wholeNumberSchema" }
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"makerAddress",
|
||||||
|
"takerAddress",
|
||||||
|
"makerAssetAmount",
|
||||||
|
"takerAssetAmount",
|
||||||
|
"makerAssetData",
|
||||||
|
"takerAssetData",
|
||||||
|
"exchangeAddress",
|
||||||
|
"expirationTimeSeconds"
|
||||||
|
]
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"id": "/orderFillOrKillRequestsSchema",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"properties": {
|
||||||
|
"signedOrder": { "$ref": "/signedOrderSchema" },
|
||||||
|
"fillTakerAmount": { "$ref": "/wholeNumberSchema" }
|
||||||
|
},
|
||||||
|
"required": ["signedOrder", "fillTakerAmount"],
|
||||||
|
"type": "object"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"id": "/orderFillRequestsSchema",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"properties": {
|
||||||
|
"signedOrder": { "$ref": "/signedOrderSchema" },
|
||||||
|
"takerTokenFillAmount": { "$ref": "/wholeNumberSchema" }
|
||||||
|
},
|
||||||
|
"required": ["signedOrder", "takerTokenFillAmount"],
|
||||||
|
"type": "object"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"id": "/orderHashSchema",
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^0x[0-9a-fA-F]{64}$"
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
{
|
||||||
|
"id": "/orderSchema",
|
||||||
|
"properties": {
|
||||||
|
"makerAddress": { "$ref": "/addressSchema" },
|
||||||
|
"takerAddress": { "$ref": "/addressSchema" },
|
||||||
|
"makerFee": { "$ref": "/wholeNumberSchema" },
|
||||||
|
"takerFee": { "$ref": "/wholeNumberSchema" },
|
||||||
|
"senderAddress": { "$ref": "/addressSchema" },
|
||||||
|
"makerAssetAmount": { "$ref": "/wholeNumberSchema" },
|
||||||
|
"takerAssetAmount": { "$ref": "/wholeNumberSchema" },
|
||||||
|
"makerAssetData": { "$ref": "/hexSchema" },
|
||||||
|
"takerAssetData": { "$ref": "/hexSchema" },
|
||||||
|
"salt": { "$ref": "/wholeNumberSchema" },
|
||||||
|
"exchangeAddress": { "$ref": "/addressSchema" },
|
||||||
|
"feeRecipientAddress": { "$ref": "/addressSchema" },
|
||||||
|
"expirationTimeSeconds": { "$ref": "/wholeNumberSchema" }
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"makerAddress",
|
||||||
|
"takerAddress",
|
||||||
|
"makerFee",
|
||||||
|
"takerFee",
|
||||||
|
"senderAddress",
|
||||||
|
"makerAssetAmount",
|
||||||
|
"takerAssetAmount",
|
||||||
|
"makerAssetData",
|
||||||
|
"takerAssetData",
|
||||||
|
"salt",
|
||||||
|
"exchangeAddress",
|
||||||
|
"feeRecipientAddress",
|
||||||
|
"expirationTimeSeconds"
|
||||||
|
],
|
||||||
|
"type": "object"
|
||||||
|
}
|
@ -0,0 +1,52 @@
|
|||||||
|
{
|
||||||
|
"id": "/orderWatcherWebSocketRequestSchema",
|
||||||
|
"type": "object",
|
||||||
|
"definitions": {
|
||||||
|
"signedOrderParam": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"signedOrder": { "$ref": "/signedOrderSchema" }
|
||||||
|
},
|
||||||
|
"required": ["signedOrder"]
|
||||||
|
},
|
||||||
|
"orderHashParam": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"orderHash": { "$ref": "/hexSchema" }
|
||||||
|
},
|
||||||
|
"required": ["orderHash"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"oneOf": [
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"id": { "type": "number" },
|
||||||
|
"jsonrpc": { "type": "string" },
|
||||||
|
"method": { "enum": ["ADD_ORDER"] },
|
||||||
|
"params": { "$ref": "#/definitions/signedOrderParam" }
|
||||||
|
},
|
||||||
|
"required": ["id", "jsonrpc", "method", "params"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"id": { "type": "number" },
|
||||||
|
"jsonrpc": { "type": "string" },
|
||||||
|
"method": { "enum": ["REMOVE_ORDER"] },
|
||||||
|
"params": { "$ref": "#/definitions/orderHashParam" }
|
||||||
|
},
|
||||||
|
"required": ["id", "jsonrpc", "method", "params"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"id": { "type": "number" },
|
||||||
|
"jsonrpc": { "type": "string" },
|
||||||
|
"method": { "enum": ["GET_STATS"] },
|
||||||
|
"params": {}
|
||||||
|
},
|
||||||
|
"required": ["id", "jsonrpc", "method"]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"id": "/orderWatcherWebSocketUtf8MessageSchema",
|
||||||
|
"properties": {
|
||||||
|
"utf8Data": { "type": "string" }
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"utf8Data"
|
||||||
|
],
|
||||||
|
"type": "object"
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"id": "/OrderbookRequestSchema",
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"baseAssetData": { "$ref": "/hexSchema" },
|
||||||
|
"quoteAssetData": { "$ref": "/hexSchema" }
|
||||||
|
},
|
||||||
|
"required": ["baseAssetData", "quoteAssetData"]
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user