From 57ac2f28a43067e51f1db1736b48893189ce9dd0 Mon Sep 17 00:00:00 2001 From: "F. Eugene Aumson" Date: Fri, 14 Dec 2018 16:08:57 -0800 Subject: Add example usage to sra_client README --- python-packages/sra_client/README.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'python-packages/sra_client') diff --git a/python-packages/sra_client/README.md b/python-packages/sra_client/README.md index ab3939b41..279fb41a4 100644 --- a/python-packages/sra_client/README.md +++ b/python-packages/sra_client/README.md @@ -6,6 +6,35 @@ A Python client for interacting with servers conforming to [the Standard Relayer The [JSON schemas](http://json-schema.org/) for the API payloads and responses can be found in [@0xproject/json-schemas](https://github.com/0xProject/0x.js/tree/development/packages/json-schemas). Examples of each payload and response can be found in the 0x.js library's [test suite](https://github.com/0xProject/0x.js/blob/development/packages/json-schemas/test/schema_test.ts#L1). +```bash +pip install 0x-json-schemas +``` + +You can easily validate your API's payloads and responses using the [0x-json-schemas](https://github.com/0xProject/0x.js/tree/development/python-packages/json_schemas) package: + +```python +from zero_ex.json_schemas import assert_valid +from zero_ex.order_utils import Order + +order: Order = { + 'makerAddress': "0x0000000000000000000000000000000000000000", + 'takerAddress': "0x0000000000000000000000000000000000000000", + 'feeRecipientAddress': "0x0000000000000000000000000000000000000000", + 'senderAddress': "0x0000000000000000000000000000000000000000", + 'makerAssetAmount': "1000000000000000000", + 'takerAssetAmount': "1000000000000000000", + 'makerFee': "0", + 'takerFee': "0", + 'expirationTimeSeconds': "12345", + 'salt': "12345", + 'makerAssetData': "0x0000000000000000000000000000000000000000", + 'takerAssetData': "0x0000000000000000000000000000000000000000", + 'exchangeAddress': "0x0000000000000000000000000000000000000000", +} + +assert_valid(order, "/orderSchema") +``` + # Pagination Requests that return potentially large collections should respond to the **?page** and **?perPage** parameters. For example: -- cgit v1.2.3 From aa5af04447dfae24731557c6beead55bd8ff99a9 Mon Sep 17 00:00:00 2001 From: "F. Eugene Aumson" Date: Wed, 9 Jan 2019 09:58:29 -0500 Subject: 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 --- python-packages/sra_client/setup.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'python-packages/sra_client') diff --git a/python-packages/sra_client/setup.py b/python-packages/sra_client/setup.py index b47f71ae7..0921149bd 100755 --- a/python-packages/sra_client/setup.py +++ b/python-packages/sra_client/setup.py @@ -48,6 +48,15 @@ class PublishCommand(distutils.command.build_py.build_py): subprocess.check_call("twine upload dist/*".split()) # nosec +class LintCommand(distutils.command.build_py.build_py): + """No-op lint command to support top-level lint script.""" + + description = "No-op" + + def run(self): + pass + + setup( name=NAME, version=VERSION, @@ -63,5 +72,6 @@ setup( cmdclass={ "test_publish": TestPublishCommand, "publish": PublishCommand, + "lint": LintCommand, }, ) -- cgit v1.2.3