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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file eip712-clearsign-1.1.2.tar.gz.
File metadata
- Download URL: eip712-clearsign-1.1.2.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d5e1e81f288adf379185da7cbacb75244983a612d6a744b6e7bc0b7d81e4740
|
|
| MD5 |
47a12595325fb5bf8862a03357050721
|
|
| BLAKE2b-256 |
6c709b1406a644faa7c48b8d0f6564019fe41b09fa6fff1e7e8e00b99c0a4715
|
File details
Details for the file eip712_clearsign-1.1.2-py3-none-any.whl.
File metadata
- Download URL: eip712_clearsign-1.1.2-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c2ba878512f47336089ef62399aa2b3d71c82b9efd1c11895f415fad2729d1d8
|
|
| MD5 |
af250b364fefa7558cf3541ccd52bc69
|
|
| BLAKE2b-256 |
33cba784d203766c1ac2ffaf5ee98aa198e9c34e658872557bed18f2713a9abe
|