aboutsummaryrefslogtreecommitdiffstats
path: root/python-packages/contract_demo
diff options
context:
space:
mode:
authorHsuan Lee <hsuan@cobinhood.com>2019-01-19 18:42:04 +0800
committerHsuan Lee <hsuan@cobinhood.com>2019-01-19 18:42:04 +0800
commit7ae38906926dc09bc10670c361af0d2bf0050426 (patch)
tree5fb10ae366b987db09e4ddb4bc3ba0f75404ad08 /python-packages/contract_demo
parentb5fd3c72a08aaa6957917d74c333387a16edf66b (diff)
downloaddexon-sol-tools-7ae38906926dc09bc10670c361af0d2bf0050426.tar
dexon-sol-tools-7ae38906926dc09bc10670c361af0d2bf0050426.tar.gz
dexon-sol-tools-7ae38906926dc09bc10670c361af0d2bf0050426.tar.bz2
dexon-sol-tools-7ae38906926dc09bc10670c361af0d2bf0050426.tar.lz
dexon-sol-tools-7ae38906926dc09bc10670c361af0d2bf0050426.tar.xz
dexon-sol-tools-7ae38906926dc09bc10670c361af0d2bf0050426.tar.zst
dexon-sol-tools-7ae38906926dc09bc10670c361af0d2bf0050426.zip
Update dependency packages
Diffstat (limited to 'python-packages/contract_demo')
-rw-r--r--python-packages/contract_demo/.discharge.json13
-rw-r--r--python-packages/contract_demo/README.md39
-rwxr-xr-xpython-packages/contract_demo/setup.py146
-rw-r--r--python-packages/contract_demo/stubs/__init__.pyi0
-rw-r--r--python-packages/contract_demo/stubs/command/__init__.pyi0
-rw-r--r--python-packages/contract_demo/stubs/command/clean.pyi7
-rw-r--r--python-packages/contract_demo/stubs/distutils/__init__.pyi0
-rw-r--r--python-packages/contract_demo/stubs/distutils/command/__init__.pyi0
-rw-r--r--python-packages/contract_demo/stubs/distutils/command/clean.pyi7
-rw-r--r--python-packages/contract_demo/stubs/eth_utils/__init__.pyi4
-rw-r--r--python-packages/contract_demo/stubs/pytest/__init__.pyi0
-rw-r--r--python-packages/contract_demo/stubs/setuptools/__init__.pyi8
-rw-r--r--python-packages/contract_demo/stubs/setuptools/command/__init__.pyi0
-rw-r--r--python-packages/contract_demo/stubs/setuptools/command/test.pyi3
-rw-r--r--python-packages/contract_demo/stubs/web3/__init__.pyi2
-rw-r--r--python-packages/contract_demo/stubs/web3/utils/__init__.pyi0
-rw-r--r--python-packages/contract_demo/stubs/web3/utils/datatypes.pyi3
-rw-r--r--python-packages/contract_demo/test/__init__.py1
-rw-r--r--python-packages/contract_demo/test/conf.py54
-rw-r--r--python-packages/contract_demo/test/doc_static/.gitkeep0
-rw-r--r--python-packages/contract_demo/test/index.rst18
-rw-r--r--python-packages/contract_demo/test/test_exchange.py65
22 files changed, 0 insertions, 370 deletions
diff --git a/python-packages/contract_demo/.discharge.json b/python-packages/contract_demo/.discharge.json
deleted file mode 100644
index 9d811ae3e..000000000
--- a/python-packages/contract_demo/.discharge.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "domain": "0x-contract-demo-py",
- "build_command": "python setup.py build_sphinx",
- "upload_directory": "build/docs/html",
- "index_key": "index.html",
- "error_key": "index.html",
- "trailing_slashes": true,
- "cache": 3600,
- "aws_profile": "default",
- "aws_region": "us-east-1",
- "cdn": false,
- "dns_configured": true
-}
diff --git a/python-packages/contract_demo/README.md b/python-packages/contract_demo/README.md
deleted file mode 100644
index 3a0f964e3..000000000
--- a/python-packages/contract_demo/README.md
+++ /dev/null
@@ -1,39 +0,0 @@
-## 0x-contract-demo
-
-A demonstration of calling 0x smart contracts from Python.
-
-Read the [documentation](http://0x-contract-demo-py.s3-website-us-east-1.amazonaws.com/)
-
-## Contributing
-
-We welcome improvements and fixes from the wider community! To report bugs within this package, please create an issue in this repository.
-
-Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
-
-### Install Code and Dependencies
-
-Ensure that you have installed Python >=3.6 and Docker. Then:
-
-```bash
-pip install -e .[dev]
-```
-
-### Test
-
-Tests depend on a running ganache instance with the 0x contracts deployed in it. For convenience, a docker container is provided that has ganache-cli and a snapshot containing the necessary contracts. A shortcut is provided to run that docker container: `./setup.py ganache`. With that running, the tests can be run with `./setup.py test`.
-
-### Clean
-
-`./setup.py clean --all`
-
-### Lint
-
-`./setup.py lint`
-
-### Build Documentation
-
-`./setup.py build_sphinx`
-
-### More
-
-See `./setup.py --help-commands` for more info.
diff --git a/python-packages/contract_demo/setup.py b/python-packages/contract_demo/setup.py
deleted file mode 100755
index a7afbd30c..000000000
--- a/python-packages/contract_demo/setup.py
+++ /dev/null
@@ -1,146 +0,0 @@
-#!/usr/bin/env python
-
-"""setuptools module for 0x-contract-demo package."""
-
-import distutils.command.build_py
-from distutils.command.clean import clean
-import subprocess # nosec
-from shutil import rmtree
-from os import environ, path
-from sys import argv
-
-from setuptools import setup
-from setuptools.command.test import test as TestCommand
-
-
-class TestCommandExtension(TestCommand):
- """Run pytest tests."""
-
- def run_tests(self):
- """Invoke pytest."""
- import pytest
-
- exit(pytest.main())
-
-
-class LintCommand(distutils.command.build_py.build_py):
- """Custom setuptools command class for running linters."""
-
- description = "Run linters"
-
- def run(self):
- """Run linter shell commands."""
- lint_commands = [
- # formatter:
- "black --line-length 79 --check --diff test setup.py".split(),
- # style guide checker (formerly pep8):
- "pycodestyle test setup.py".split(),
- # docstring style checker:
- "pydocstyle test setup.py".split(),
- # static type checker:
- "mypy test setup.py".split(),
- # security issue checker:
- "bandit -r ./setup.py".split(),
- # general linter:
- "pylint test setup.py".split(),
- # pylint takes relatively long to run, so it runs last, to enable
- # fast failures.
- ]
-
- # tell mypy where to find interface stubs for 3rd party libs
- environ["MYPYPATH"] = path.join(
- path.dirname(path.realpath(argv[0])), "stubs"
- )
-
- for lint_command in lint_commands:
- print(
- "Running lint command `", " ".join(lint_command).strip(), "`"
- )
- subprocess.check_call(lint_command) # nosec
-
-
-class CleanCommandExtension(clean):
- """Custom command to do custom cleanup."""
-
- def run(self):
- """Run the regular clean, followed by our custom commands."""
- super().run()
- rmtree(".mypy_cache", ignore_errors=True)
- rmtree(".tox", ignore_errors=True)
- rmtree(".pytest_cache", ignore_errors=True)
-
-
-class GanacheCommand(distutils.command.build_py.build_py):
- """Custom command to publish to pypi.org."""
-
- description = "Run ganache daemon to support tests."
-
- def run(self):
- """Run ganache."""
- cmd_line = "docker run -d -p 8545:8545 0xorg/ganache-cli:2.2.2".split()
- subprocess.call(cmd_line) # nosec
-
-
-class PublishDocsCommand(distutils.command.build_py.build_py):
- """Custom command to publish docs to S3."""
-
- description = (
- "Publish docs to "
- + "http://0x-contract-addresses-py.s3-website-us-east-1.amazonaws.com/"
- )
-
- def run(self):
- """Run npm package `discharge` to build & upload docs."""
- subprocess.check_call("discharge deploy".split()) # nosec
-
-
-setup(
- name="0x-contract-demo",
- version="1.0.0",
- description="Demonstration of calling 0x contracts",
- url=(
- "https://github.com/0xProject/0x-monorepo/tree/development"
- + "/python-packages/contract_demo"
- ),
- author="F. Eugene Aumson",
- author_email="feuGeneA@users.noreply.github.com",
- cmdclass={
- "clean": CleanCommandExtension,
- "lint": LintCommand,
- "test": TestCommandExtension,
- "ganache": GanacheCommand,
- "publish_docs": PublishDocsCommand,
- },
- install_requires=[
- "0x-contract-addresses",
- "0x-contract-artifacts",
- "0x-order-utils",
- "0x-web3", # TEMPORARY! pending resolution of our web3.py PR#1147
- "mypy_extensions",
- ],
- extras_require={
- "dev": [
- "bandit",
- "black",
- "coverage",
- "coveralls",
- "mypy",
- "mypy_extensions",
- "pycodestyle",
- "pydocstyle",
- "pylint",
- "pytest",
- "sphinx",
- "tox",
- ]
- },
- python_requires=">=3.6, <4",
- license="Apache 2.0",
- zip_safe=False, # required per mypy
- command_options={
- "build_sphinx": {
- "source_dir": ("setup.py", "test"),
- "build_dir": ("setup.py", "build/docs"),
- }
- },
-)
diff --git a/python-packages/contract_demo/stubs/__init__.pyi b/python-packages/contract_demo/stubs/__init__.pyi
deleted file mode 100644
index e69de29bb..000000000
--- a/python-packages/contract_demo/stubs/__init__.pyi
+++ /dev/null
diff --git a/python-packages/contract_demo/stubs/command/__init__.pyi b/python-packages/contract_demo/stubs/command/__init__.pyi
deleted file mode 100644
index e69de29bb..000000000
--- a/python-packages/contract_demo/stubs/command/__init__.pyi
+++ /dev/null
diff --git a/python-packages/contract_demo/stubs/command/clean.pyi b/python-packages/contract_demo/stubs/command/clean.pyi
deleted file mode 100644
index 46a42ddb1..000000000
--- a/python-packages/contract_demo/stubs/command/clean.pyi
+++ /dev/null
@@ -1,7 +0,0 @@
-from distutils.core import Command
-
-class clean(Command):
- def initialize_options(self: clean) -> None: ...
- def finalize_options(self: clean) -> None: ...
- def run(self: clean) -> None: ...
- ...
diff --git a/python-packages/contract_demo/stubs/distutils/__init__.pyi b/python-packages/contract_demo/stubs/distutils/__init__.pyi
deleted file mode 100644
index e69de29bb..000000000
--- a/python-packages/contract_demo/stubs/distutils/__init__.pyi
+++ /dev/null
diff --git a/python-packages/contract_demo/stubs/distutils/command/__init__.pyi b/python-packages/contract_demo/stubs/distutils/command/__init__.pyi
deleted file mode 100644
index e69de29bb..000000000
--- a/python-packages/contract_demo/stubs/distutils/command/__init__.pyi
+++ /dev/null
diff --git a/python-packages/contract_demo/stubs/distutils/command/clean.pyi b/python-packages/contract_demo/stubs/distutils/command/clean.pyi
deleted file mode 100644
index 46a42ddb1..000000000
--- a/python-packages/contract_demo/stubs/distutils/command/clean.pyi
+++ /dev/null
@@ -1,7 +0,0 @@
-from distutils.core import Command
-
-class clean(Command):
- def initialize_options(self: clean) -> None: ...
- def finalize_options(self: clean) -> None: ...
- def run(self: clean) -> None: ...
- ...
diff --git a/python-packages/contract_demo/stubs/eth_utils/__init__.pyi b/python-packages/contract_demo/stubs/eth_utils/__init__.pyi
deleted file mode 100644
index 4a83338ca..000000000
--- a/python-packages/contract_demo/stubs/eth_utils/__init__.pyi
+++ /dev/null
@@ -1,4 +0,0 @@
-from typing import Union
-
-def to_checksum_address(value: Union[str, bytes]) -> str:
- ...
diff --git a/python-packages/contract_demo/stubs/pytest/__init__.pyi b/python-packages/contract_demo/stubs/pytest/__init__.pyi
deleted file mode 100644
index e69de29bb..000000000
--- a/python-packages/contract_demo/stubs/pytest/__init__.pyi
+++ /dev/null
diff --git a/python-packages/contract_demo/stubs/setuptools/__init__.pyi b/python-packages/contract_demo/stubs/setuptools/__init__.pyi
deleted file mode 100644
index 8ea8d32b7..000000000
--- a/python-packages/contract_demo/stubs/setuptools/__init__.pyi
+++ /dev/null
@@ -1,8 +0,0 @@
-from distutils.dist import Distribution
-from typing import Any, List
-
-def setup(**attrs: Any) -> Distribution: ...
-
-class Command: ...
-
-def find_packages(where: str) -> List[str]: ...
diff --git a/python-packages/contract_demo/stubs/setuptools/command/__init__.pyi b/python-packages/contract_demo/stubs/setuptools/command/__init__.pyi
deleted file mode 100644
index e69de29bb..000000000
--- a/python-packages/contract_demo/stubs/setuptools/command/__init__.pyi
+++ /dev/null
diff --git a/python-packages/contract_demo/stubs/setuptools/command/test.pyi b/python-packages/contract_demo/stubs/setuptools/command/test.pyi
deleted file mode 100644
index c5ec770ad..000000000
--- a/python-packages/contract_demo/stubs/setuptools/command/test.pyi
+++ /dev/null
@@ -1,3 +0,0 @@
-from setuptools import Command
-
-class test(Command): ...
diff --git a/python-packages/contract_demo/stubs/web3/__init__.pyi b/python-packages/contract_demo/stubs/web3/__init__.pyi
deleted file mode 100644
index 21482d598..000000000
--- a/python-packages/contract_demo/stubs/web3/__init__.pyi
+++ /dev/null
@@ -1,2 +0,0 @@
-class Web3:
- ...
diff --git a/python-packages/contract_demo/stubs/web3/utils/__init__.pyi b/python-packages/contract_demo/stubs/web3/utils/__init__.pyi
deleted file mode 100644
index e69de29bb..000000000
--- a/python-packages/contract_demo/stubs/web3/utils/__init__.pyi
+++ /dev/null
diff --git a/python-packages/contract_demo/stubs/web3/utils/datatypes.pyi b/python-packages/contract_demo/stubs/web3/utils/datatypes.pyi
deleted file mode 100644
index 70baff372..000000000
--- a/python-packages/contract_demo/stubs/web3/utils/datatypes.pyi
+++ /dev/null
@@ -1,3 +0,0 @@
-class Contract:
- def call(self): ...
- ...
diff --git a/python-packages/contract_demo/test/__init__.py b/python-packages/contract_demo/test/__init__.py
deleted file mode 100644
index 600f143bf..000000000
--- a/python-packages/contract_demo/test/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-"""Demonstrations of calling 0x smart contracts."""
diff --git a/python-packages/contract_demo/test/conf.py b/python-packages/contract_demo/test/conf.py
deleted file mode 100644
index 45ed4b2a5..000000000
--- a/python-packages/contract_demo/test/conf.py
+++ /dev/null
@@ -1,54 +0,0 @@
-"""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}
diff --git a/python-packages/contract_demo/test/doc_static/.gitkeep b/python-packages/contract_demo/test/doc_static/.gitkeep
deleted file mode 100644
index e69de29bb..000000000
--- a/python-packages/contract_demo/test/doc_static/.gitkeep
+++ /dev/null
diff --git a/python-packages/contract_demo/test/index.rst b/python-packages/contract_demo/test/index.rst
deleted file mode 100644
index c546eccfa..000000000
--- a/python-packages/contract_demo/test/index.rst
+++ /dev/null
@@ -1,18 +0,0 @@
-.. 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`
diff --git a/python-packages/contract_demo/test/test_exchange.py b/python-packages/contract_demo/test/test_exchange.py
deleted file mode 100644
index 07492a403..000000000
--- a/python-packages/contract_demo/test/test_exchange.py
+++ /dev/null
@@ -1,65 +0,0 @@
-"""Test calling methods on the Exchange contract."""
-
-from eth_utils import to_checksum_address
-from web3 import Web3
-from web3.utils import datatypes
-
-from zero_ex.contract_addresses import NETWORK_TO_ADDRESSES, NetworkId
-import zero_ex.contract_artifacts
-from zero_ex.json_schemas import assert_valid
-from zero_ex.order_utils import (
- Order,
- OrderInfo,
- order_to_jsdict,
- generate_order_hash_hex,
-)
-
-
-def test_get_order_info():
- """Demonstrate Exchange.getOrderInfo()."""
- order: Order = {
- "makerAddress": "0x0000000000000000000000000000000000000000",
- "takerAddress": "0x0000000000000000000000000000000000000000",
- "feeRecipientAddress": "0x0000000000000000000000000000000000000000",
- "senderAddress": "0x0000000000000000000000000000000000000000",
- "makerAssetAmount": 1000000000000000000,
- "takerAssetAmount": 1000000000000000000,
- "makerFee": 0,
- "takerFee": 0,
- "expirationTimeSeconds": 12345,
- "salt": 12345,
- "makerAssetData": (b"\x00") * 20,
- "takerAssetData": (b"\x00") * 20,
- }
-
- web3_instance = Web3(Web3.HTTPProvider("http://127.0.0.1:8545"))
-
- # false positive from pylint: disable=no-member
- contract_address = NETWORK_TO_ADDRESSES[
- NetworkId(int(web3_instance.net.version))
- ].exchange
-
- assert_valid(
- order_to_jsdict(order, exchange_address=contract_address),
- "/orderSchema",
- )
-
- # false positive from pylint: disable=no-member
- exchange: datatypes.Contract = web3_instance.eth.contract(
- address=to_checksum_address(contract_address),
- abi=zero_ex.contract_artifacts.abi_by_name("Exchange"),
- )
-
- order_info = OrderInfo(*exchange.call().getOrderInfo(order))
-
- assert isinstance(order_info.order_status, int)
- assert order_info.order_status == 4
-
- assert isinstance(order_info.order_hash, bytes)
- assert order_info.order_hash.hex() == generate_order_hash_hex(
- order,
- exchange_address=NETWORK_TO_ADDRESSES[NetworkId.GANACHE].exchange,
- )
-
- assert isinstance(order_info.order_taker_asset_filled_amount, int)
- assert order_info.order_taker_asset_filled_amount == 0