Skip to main content

Parse eip712 clear sign descriptors

Project description

python-eip712

Parse eip712 clear sign descriptors.

Install

pip install eip712-clearsign

Run tests

pyenv install 3.10.6
pyenv local 3.10.6
python -m venv venv
source venv/bin/activate
pip install -r requirements-dev.txt
pip install .
pytest -s --cov=./eip712

Generate an EIP712 parser

You can generate a base parser file using the following python code:

import json
from eip712 import (
    EIP712ContractDescriptor,
    EIP712DAppDescriptor,
)

eip712_dapp = EIP712DAppDescriptor(
    blockchainName="ethereum", chainId=1, name="MyDApp", contracts=[]
)
contract = EIP712ContractDescriptor(
    address="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
    contractName="MyCoolContract_V1",
    messages=[],
)
schemas = [
    {
        "EIP712Domain": [
            {"name": "chainId", "type": "uint256"},
            {"name": "name", "type": "string"},
            {"name": "verifyingContract", "type": "address"},
            {"name": "version", "type": "string"},
        ],
        "Mail": [
            {"name": "contents", "type": "string"},
            {"name": "from", "type": "Person"},
            {"name": "to", "type": "Person"},
        ],
        "Person": [
            {"name": "name", "type": "string"},
            {"name": "wallets", "type": "Wallet[]"},
        ],
        "Wallet": [
            {"name": "name", "type": "string"},
            {"name": "addr", "type": "address"},
        ],
    },
    ...
]

for schema in schemas:
    eip712_dapp.add_message(target_contract=contract, schema=schema)

with open("eip712.json", "w+") as f:
    json.dump(eip712_dapp.dict(by_alias=True), f, indent=4, sort_keys=True, ensure_ascii=False)

This will create one mapper field per element in your schemas, with auto generated names. You should then:

  • Remove the fields you don't want to display on the Nano
  • Rename the fields that you want to keep, with names that are as meaningful as possible

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

eip712_clearsign-2.1.0rc2.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

eip712_clearsign-2.1.0rc2-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file eip712_clearsign-2.1.0rc2.tar.gz.

File metadata

  • Download URL: eip712_clearsign-2.1.0rc2.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.10.14

File hashes

Hashes for eip712_clearsign-2.1.0rc2.tar.gz
Algorithm Hash digest
SHA256 3b55e7932bba4c04b8b576603d7ef895a1c70898d14afa5efe83e8b08c6520bf
MD5 f48786ee56007e2e4f5aa06da9432dda
BLAKE2b-256 c06bf3ab4b42e5fff87334af4af4fa477ef9ca39206707c02ce8ad096763760a

See more details on using hashes here.

File details

Details for the file eip712_clearsign-2.1.0rc2-py3-none-any.whl.

File metadata

File hashes

Hashes for eip712_clearsign-2.1.0rc2-py3-none-any.whl
Algorithm Hash digest
SHA256 6abdcac45419bfb6565e6ef8d34c338acb6b769e228dd1b71ca180c4cc5758d2
MD5 5afe26823c117efac7cf27aba64f1c09
BLAKE2b-256 43e22994e83668078d2ae16d35020cd49474dda7321a4f2664ede3a328522226

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page