Skip to content

packages.valory.contracts.gnosis_safe.encode

ETH encoder.

encode

def encode(ledger_api: EthereumApi, typ: t.Any, arg: t.Any) -> bytes

Encode a single value of the given ABI type.

web3 bundles eth_abi and exposes its default codec via ledger_api.api.codec; reaching through to the codec's _registry gives us the same per-type encoder the contract used to import directly from eth_abi.default_codec._registry, without adding eth-abi as a declared dep.

to_string

def to_string(value: t.Union[bytes, str, int]) -> bytes

Convert to byte string.

sha3_256

def sha3_256(ledger_api: EthereumApi, x: bytes) -> bytes

Calculate keccak-256 hash (Ethereum's SHA3 variant).

sha3

def sha3(ledger_api: EthereumApi, seed: t.Union[bytes, str, int]) -> bytes

Calculate keccak-256 hash over seed (coerced to bytes).

scan_bin

def scan_bin(v: str) -> bytes

Scan bytes.

create_struct_definition

def create_struct_definition(name: str, schema: t.List[t.Dict[str,
                                                              str]]) -> str

Create the struct definition string.

find_dependencies

def find_dependencies(name: str, types: t.Dict[str, t.Any],
                      dependencies: t.Set) -> None

Find dependencies.

create_schema

def create_schema(name: str, types: t.Dict) -> str

Create schema.

create_schema_hash

def create_schema_hash(ledger_api: EthereumApi, name: str,
                       types: t.Dict) -> bytes

Create schema hash.

encode_value

def encode_value(ledger_api: EthereumApi, data_type: str, value: t.Any,
                 types: t.Dict) -> bytes

Encode value.

encode_data

def encode_data(ledger_api: EthereumApi, name: str,
                data: t.Dict[str, t.Dict[str, str]], types: t.Dict) -> bytes

Encode data.

create_struct_hash

def create_struct_hash(ledger_api: EthereumApi, name: str,
                       data: t.Dict[str, t.Dict[str,
                                                str]], types: t.Dict) -> bytes

Create struct hash.

encode_typed_data

def encode_typed_data(ledger_api: EthereumApi, data: t.Dict[str,
                                                            t.Any]) -> bytes

Encode typed data.