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
eip712_clearsign-1.1.3.tar.gz
(5.7 kB
view hashes)
Built Distribution
Close
Hashes for eip712_clearsign-1.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 949c3cfda3bfc6c20abbe7395c140e03be49f28d9ff1e02906802b989b2aec8b |
|
MD5 | 4438f72a755d669919d15a6cf09d5cd8 |
|
BLAKE2b-256 | 1e3af98f5a4ca7d0b53755346560984c3fc8b0493ea706a2b025fb43f768af9c |