eip712

package
v1.1.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const EIP712Domain = "EIP712Domain"

Variables

This section is empty.

Functions

func EncodeTypedDataV4

func EncodeTypedDataV4(ctx context.Context, payload *TypedData) (encoded ethtypes.HexBytes0xPrefix, err error)

func HashStruct added in v1.1.14

func HashStruct(ctx context.Context, typeName string, v interface{}, allTypes TypeSet) (result ethtypes.HexBytes0xPrefix, err error)

HashStruct allows hashing of an individual structure, without the EIP-712 domain

Types

type Type

type Type []*TypeMember

func (Type) Encode

func (t Type) Encode(name string) string

A type is encoded as:

> name ‖ "(" ‖ member₁ ‖ "," ‖ member₂ ‖ "," ‖ … ‖ memberₙ ")"

type TypeMember

type TypeMember struct {
	Name string
	Type string
}

func (*TypeMember) Encode

func (tm *TypeMember) Encode() string

An individual member is encoded as:

> type ‖ " " ‖ name

type TypeSet

type TypeSet map[string]Type

func ABItoTypedDataV4

func ABItoTypedDataV4(ctx context.Context, tc abi.TypeComponent) (primaryType string, typeSet TypeSet, err error)

Convert an ABI tuple definition, into the EIP-712 structure that's embedded into the "eth_signTypedData" signing request payload. It's a much simpler structure that flattens out a map of types (requiring each type to be named by a struct definition)

func (TypeSet) Encode

func (ts TypeSet) Encode(primaryType string) string

A map from type names to types is encoded per encodeType:

> If the struct type references other struct types (and these in turn reference even more struct types), > then the set of referenced struct types is collected, sorted by name and appended to the encoding.

type TypedData

type TypedData struct {
	Types       TypeSet                `ffstruct:"TypedData" json:"types"`
	PrimaryType string                 `ffstruct:"TypedData" json:"primaryType"`
	Domain      map[string]interface{} `ffstruct:"TypedData" json:"domain"`
	Message     map[string]interface{} `ffstruct:"TypedData" json:"message"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL