{ "info": { "author": "AJ Grubbs", "author_email": "", "bugtrack_url": null, "classifiers": [], "description": "# EIP-712 Structs [![Build Status](https://travis-ci.org/ajrgrubbs/py-eip712-structs.svg?branch=master)](https://travis-ci.org/ajrgrubbs/py-eip712-structs) [![Coverage Status](https://coveralls.io/repos/github/ajrgrubbs/py-eip712-structs/badge.svg?branch=master)](https://coveralls.io/github/ajrgrubbs/py-eip712-structs?branch=master)\n\nA python interface for simple EIP-712 struct construction.\n\nIn this module, a \"struct\" is structured data as defined in the standard.\nIt is not the same as the Python Standard Library's struct (e.g., `import struct`).\n\nRead the proposal:
\nhttps://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md\n\n#### Supported Python Versions\n- `3.6`\n- `3.7`\n\n## Install\n```bash\npip install eip712-structs\n```\n\n## Usage\nSee [API.md](API.md) for a succinct summary of available methods.\n\nExamples/Details below.\n\n#### Quickstart\nSay we want to represent the following struct, convert it to a message and sign it:\n```text\nstruct MyStruct {\n string some_string;\n uint256 some_number;\n}\n```\n\nWith this module, that would look like:\n```python\n# Make a unique domain\nfrom eip712_structs import make_domain\ndomain = make_domain(name='Some name', version='1.0.0') # Make a Domain Separator\n\n# Define your struct type\nfrom eip712_structs import EIP712Struct, String, Uint\nclass MyStruct(EIP712Struct):\n some_string = String()\n some_number = Uint(256)\n\n# Create an instance with some data\nmine = MyStruct(some_string='hello world', some_number=1234)\n\n# Into a message dict (serializable to JSON) - domain required\nmy_msg = mine.to_message(domain)\n\n# Into signable bytes - domain required\nmy_bytes = mine.signable_bytes(domain)\n```\n\nSee [Member Types](#member-types) for more information on supported types.\n\n#### Dynamic construction\nAttributes may be added dynamically as well. This may be necessary if you\nwant to use a reserved keyword like `from`.\n\n```python\nfrom eip712_structs import EIP712Struct, Address\nclass Message(EIP712Struct):\n pass\n\nMessage.to = Address()\nsetattr(Message, 'from', Address())\n```\n\n#### The domain separator\nEIP-712 specifies a domain struct, to differentiate between identical structs that may be unrelated.\nA helper method exists for this purpose.\nAll values to the `make_domain()`\nfunction are optional - but at least one must be defined. If omitted, the resulting\ndomain struct's definition leaves out the parameter entirely.\n\nThe full signature:
\n`make_domain(name: string, version: string, chainId: uint256, verifyingContract: address, salt: bytes32)`\n\n##### Setting a default domain\nConstantly providing the same domain can be cumbersome. You can optionally set a default, and then forget it.\nIt is automatically used by `.to_message()` and `.signable_bytes()`\n\n```python\nimport eip712_structs\n\nfoo = SomeStruct()\n\nmy_domain = eip712_structs.make_domain(name='hello world')\neip712_structs.default_domain = my_domain\n\nassert foo.to_message() == foo.to_message(my_domain)\nassert foo.signable_bytes() == foo.signable_bytes(my_domain)\n```\n\n## Member Types\n\n### Basic types\nEIP712's basic types map directly to solidity types.\n\n```python\nfrom eip712_structs import Address, Boolean, Bytes, Int, String, Uint\n\nAddress() # Solidity's 'address'\nBoolean() # 'bool'\nBytes() # 'bytes'\nBytes(N) # 'bytesN' - N must be an int from 1 through 32\nInt(N) # 'intN' - N must be a multiple of 8, from 8 to 256\nString() # 'string'\nUint(N) # 'uintN' - N must be a multiple of 8, from 8 to 256\n```\n\nUse like:\n```python\nfrom eip712_structs import EIP712Struct, Address, Bytes\n\nclass Foo(EIP712Struct):\n member_name_0 = Address()\n member_name_1 = Bytes(5)\n # ...etc\n```\n\n### Struct references\nIn addition to holding basic types, EIP712 structs may also hold other structs!\nUsage is almost the same - the difference is you don't \"instantiate\" the class.\n\nExample:\n```python\nfrom eip712_structs import EIP712Struct, String\n\nclass Dog(EIP712Struct):\n name = String()\n breed = String()\n\nclass Person(EIP712Struct):\n name = String()\n dog = Dog # Take note - no parentheses!\n\n# Dog \"stands alone\"\nDog.encode_type() # Dog(string name,string breed)\n\n# But Person knows how to include Dog\nPerson.encode_type() # Person(string name,Dog dog)Dog(string name,string breed)\n```\n\nInstantiating the structs with nested values may be done a couple different ways:\n\n```python\n# Method one: set it to a struct\ndog = Dog(name='Mochi', breed='Corgi')\nperson = Person(name='E.M.', dog=dog)\n\n# Method two: set it to a dict - the underlying struct is built for you\nperson = Person(\n name='E.M.',\n dog={\n 'name': 'Mochi',\n 'breed': 'Corgi',\n }\n)\n```\n\n### Arrays\nArrays are also supported for the standard.\n\n```python\narray_member = Array([, ])\n```\n\n- `` - The basic type or struct that will live in the array\n- `` - If given, the array is set to that length.\n\nFor example:\n```python\ndynamic_array = Array(String()) # String[] dynamic_array\nstatic_array = Array(String(), 10) # String[10] static_array\nstruct_array = Array(MyStruct, 10) # MyStruct[10] - again, don't instantiate structs like the basic types\n```\n\n## Development\nContributions always welcome.\n\nInstall dependencies:\n- `pip install -r requirements.txt`\n\nRun tests:\n- `python setup.py test`\n- Some tests expect an active local ganache chain on http://localhost:8545. Docker will compile the contracts and start the chain for you.\n- Docker is optional, but useful to test the whole suite. If no chain is detected, chain tests are skipped.\n- Usage:\n - `docker-compose up -d` (Starts containers in the background)\n - Note: Contracts are compiled when you run `up`, but won't be deployed until the test is run.\n - Cleanup containers when you're done: `docker-compose down`\n\nDeploying a new version:\n- Bump the version number in `setup.py`, commit it into master.\n- Make a release tag on the master branch in Github. Travis should handle the rest.\n\n\n## Shameless Plug\nWritten by [ConsenSys](https://consensys.net) for ourselves and the community! :heart:", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/ajrgrubbs/py-eip712-structs", "keywords": "ethereum eip712 solidity", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "eip712-structs", "package_url": "https://pypi.org/project/eip712-structs/", "platform": "", "project_url": "https://pypi.org/project/eip712-structs/", "project_urls": { "Homepage": "https://github.com/ajrgrubbs/py-eip712-structs" }, "release_url": "https://pypi.org/project/eip712-structs/1.1.0/", "requires_dist": null, "requires_python": "", "summary": "A python library for EIP712 objects", "version": "1.1.0" }, "last_serial": 5403036, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "a9326f2d6b7678c3fa35ff11b5cc96df", "sha256": "3c58678252b04579c93068302e32d52224e2746d74abca2178145a5dd8909298" }, "downloads": -1, "filename": "eip712_structs-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "a9326f2d6b7678c3fa35ff11b5cc96df", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5317, "upload_time": "2019-03-12T06:07:48", "url": "https://files.pythonhosted.org/packages/f7/77/02cd14eb7719bfcc6508995f1c1c8b2b327810e5dffadbd6c6186344870b/eip712_structs-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3b071dff971aab83cd0525d91f0c73b2", "sha256": "c7dbe904ae87686d1f702bd3bc9ad9f83f283152cc31da40fbe03e63feb81c9b" }, "downloads": -1, "filename": "eip712-structs-0.1.0.tar.gz", "has_sig": false, "md5_digest": "3b071dff971aab83cd0525d91f0c73b2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4210, "upload_time": "2019-03-12T06:07:50", "url": "https://files.pythonhosted.org/packages/a5/b2/fc7a5df23a251045936847cb16424ce0a6027b93e97e82384b7e33628596/eip712-structs-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "5e8c6ba384c4d6ba3455e60505c20012", "sha256": "cfe46d68a31d32441c6d764cadf5ab93377190a1d2746a3f66177fbc37a11300" }, "downloads": -1, "filename": "eip712_structs-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "5e8c6ba384c4d6ba3455e60505c20012", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5944, "upload_time": "2019-03-13T10:42:13", "url": "https://files.pythonhosted.org/packages/23/a0/157105b3ca0e395ca8ae5541098393d9874ffff8e172bb7a2bdc6ec0035e/eip712_structs-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "73b284e089638879e5bb06f8df6917f6", "sha256": "684a4cc54a941ef82c20999e8c9fa26243d67a2328e3207b5ded4384659e2f50" }, "downloads": -1, "filename": "eip712-structs-0.1.1.tar.gz", "has_sig": false, "md5_digest": "73b284e089638879e5bb06f8df6917f6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4815, "upload_time": "2019-03-13T10:42:15", "url": "https://files.pythonhosted.org/packages/f9/29/e418b8b823f5f46e17410d78c52c66b68941dc383b3b8e03080ff842ae85/eip712-structs-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "26ec5ff614d5f13e711d253fa38ef502", "sha256": "c69fbf20ff8c98333cf00a453585c399b5544a11d9e462db153a345a72fa4e1d" }, "downloads": -1, "filename": "eip712_structs-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "26ec5ff614d5f13e711d253fa38ef502", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7023, "upload_time": "2019-03-14T22:08:10", "url": "https://files.pythonhosted.org/packages/98/ae/4de2297a1368d6c03f6a571d5a87454967730164ca01a888019fac999372/eip712_structs-0.1.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f986f1730ed8c64b03193d087ede409d", "sha256": "402f9e622a6cde4d30a64c076c304627e7c92f26f610bcde3fc587ab9c06aaac" }, "downloads": -1, "filename": "eip712-structs-0.1.2.tar.gz", "has_sig": false, "md5_digest": "f986f1730ed8c64b03193d087ede409d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6008, "upload_time": "2019-03-14T22:08:12", "url": "https://files.pythonhosted.org/packages/6f/ec/848c2db7775dec60e85a1e6b8700476b4e8dab13d424af7f95614a8362ca/eip712-structs-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "0bd999d4711a2907c684fead8f336b5b", "sha256": "a5b268422b4c988df7f4372b565b0935a39c8bad79ffa4a151bd3be7d6109378" }, "downloads": -1, "filename": "eip712_structs-0.1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "0bd999d4711a2907c684fead8f336b5b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7025, "upload_time": "2019-03-15T17:31:59", "url": "https://files.pythonhosted.org/packages/dd/d6/46d0457fe15d19ffc3f8991d869a0e0a6bc43fcad308395e38920a6d9e38/eip712_structs-0.1.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7cd6c3e13d07046da922f61835cd4a9f", "sha256": "9fd47f3546b09a525695cfdda2f1b6ede4517fd99a74c1cefe298ab25c110b31" }, "downloads": -1, "filename": "eip712-structs-0.1.3.tar.gz", "has_sig": false, "md5_digest": "7cd6c3e13d07046da922f61835cd4a9f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6413, "upload_time": "2019-03-15T17:32:00", "url": "https://files.pythonhosted.org/packages/10/2f/2ca186ca32161acfa4227ae4c958bf5e924923d894b48c0c2565bd0295a9/eip712-structs-0.1.3.tar.gz" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "88f6464d9680769bd6d85b23953f886d", "sha256": "33b9cc5b85de508455209d8e71100a5c4bc203e2e41ed7cf769c85dc293e9fcc" }, "downloads": -1, "filename": "eip712_structs-0.1.4-py3-none-any.whl", "has_sig": false, "md5_digest": "88f6464d9680769bd6d85b23953f886d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9033, "upload_time": "2019-03-26T18:40:23", "url": "https://files.pythonhosted.org/packages/bf/79/740b3329511bc2dcf4dafabb56a59031d7b2ba745e0e13f1347852d392d8/eip712_structs-0.1.4-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "56d17e9a7cc0b11dbb01b78a19adce4a", "sha256": "b163f47c81cd7bd0bdcc0140785300d20138946f0186895b26f503831409637c" }, "downloads": -1, "filename": "eip712-structs-0.1.4.tar.gz", "has_sig": false, "md5_digest": "56d17e9a7cc0b11dbb01b78a19adce4a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7469, "upload_time": "2019-03-26T18:40:25", "url": "https://files.pythonhosted.org/packages/7d/85/1b998aebb3984338567d637119cfd38ef0ed090b2f9f3069ea8ad260ca96/eip712-structs-0.1.4.tar.gz" } ], "0.1.5": [ { "comment_text": "", "digests": { "md5": "fd6836f4c05e8dbea3779886c40b4daa", "sha256": "9279bb3e93bc5144b03df755383160e50e9fea2a23e6d171b89e9d474103b10c" }, "downloads": -1, "filename": "eip712_structs-0.1.5-py3-none-any.whl", "has_sig": false, "md5_digest": "fd6836f4c05e8dbea3779886c40b4daa", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9034, "upload_time": "2019-05-03T14:01:27", "url": "https://files.pythonhosted.org/packages/cb/ad/d766698216dbd464b995e9166f23a44730d9e0270f466ea1139353b2f079/eip712_structs-0.1.5-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3cfe6d3d3400cb5a6c86ac67a261a51b", "sha256": "d5a3353a5a2594807829c98f21211cad367e5c24be67141ea2a4302689a7005d" }, "downloads": -1, "filename": "eip712-structs-0.1.5.tar.gz", "has_sig": false, "md5_digest": "3cfe6d3d3400cb5a6c86ac67a261a51b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7478, "upload_time": "2019-05-03T14:01:29", "url": "https://files.pythonhosted.org/packages/27/4c/08af611a9315c7af6f3ec59d85ae398928944d6f33b791411971f23eb4db/eip712-structs-0.1.5.tar.gz" } ], "0.1.6": [ { "comment_text": "", "digests": { "md5": "a67e1d3c12674d13ef77310710e483b2", "sha256": "2051692522775a5c5d35a0981c2b3b06e353b525bab1351ac1f93d80268b2c17" }, "downloads": -1, "filename": "eip712_structs-0.1.6-py3-none-any.whl", "has_sig": false, "md5_digest": "a67e1d3c12674d13ef77310710e483b2", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9097, "upload_time": "2019-05-03T18:08:27", "url": "https://files.pythonhosted.org/packages/ed/9b/38aa5bd8713793c195af260a54e0f6d6091ed1882d60919c872f6d0a3554/eip712_structs-0.1.6-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d8cb074cfce0cc5f3e684bd4c110e3ad", "sha256": "7c2b8f7259bff39f1e7813ef69b28d1eba068a20b342bcef4f8b0e2497d50e4a" }, "downloads": -1, "filename": "eip712-structs-0.1.6.tar.gz", "has_sig": false, "md5_digest": "d8cb074cfce0cc5f3e684bd4c110e3ad", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7540, "upload_time": "2019-05-03T18:08:28", "url": "https://files.pythonhosted.org/packages/bf/4d/ca15b08d9786d95900edc2d6f0d2e67a224ef8ab848b0330bcf5eeb11410/eip712-structs-0.1.6.tar.gz" } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "ecb33b7eb9144da23dfea9edac9f3906", "sha256": "ead4fab9f4fa875d86a898ee88fa35c9d56cc57f71c872adcd22129180e1ef84" }, "downloads": -1, "filename": "eip712-structs-1.0.0.tar.gz", "has_sig": false, "md5_digest": "ecb33b7eb9144da23dfea9edac9f3906", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9555, "upload_time": "2019-06-08T07:40:32", "url": "https://files.pythonhosted.org/packages/f7/5f/e91561459b4ecff2ad0a546557f623c98261f87aeef2705d0a9b2bfea78d/eip712-structs-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "90ee573fe853d2afe5812d148c10adeb", "sha256": "15d6c8b1d04466e72cb955e3c209ffc92bf454dd6d7e444f7937eba1d3828df1" }, "downloads": -1, "filename": "eip712-structs-1.0.1.tar.gz", "has_sig": false, "md5_digest": "90ee573fe853d2afe5812d148c10adeb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9763, "upload_time": "2019-06-09T22:41:53", "url": "https://files.pythonhosted.org/packages/a3/b2/2e2e4b7192afcb3f57d9498f321c90dddb38466fc21ce6323d5500a274c5/eip712-structs-1.0.1.tar.gz" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "91b66a28a1e8343dd6fe94312d12aa5d", "sha256": "b24400aef07b4d0287fb9bf8ce02b0abbe80c476d1b67222a7c5158df3a3e38d" }, "downloads": -1, "filename": "eip712-structs-1.1.0.tar.gz", "has_sig": false, "md5_digest": "91b66a28a1e8343dd6fe94312d12aa5d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12853, "upload_time": "2019-06-15T04:54:49", "url": "https://files.pythonhosted.org/packages/36/e0/0c79d27da8918f7642cba8ad4b0e6176ff7a8b4774f363c6ceb2513474be/eip712-structs-1.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "91b66a28a1e8343dd6fe94312d12aa5d", "sha256": "b24400aef07b4d0287fb9bf8ce02b0abbe80c476d1b67222a7c5158df3a3e38d" }, "downloads": -1, "filename": "eip712-structs-1.1.0.tar.gz", "has_sig": false, "md5_digest": "91b66a28a1e8343dd6fe94312d12aa5d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12853, "upload_time": "2019-06-15T04:54:49", "url": "https://files.pythonhosted.org/packages/36/e0/0c79d27da8918f7642cba8ad4b0e6176ff7a8b4774f363c6ceb2513474be/eip712-structs-1.1.0.tar.gz" } ] }