typeddata

package
v0.110.3 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2022 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashTypedDataV4 added in v0.76.4

func HashTypedDataV4(typedData signercore.TypedData, chain *big.Int) (common.Hash, error)

func Sign

func Sign(typed TypedData, prv *ecdsa.PrivateKey, chain *big.Int) ([]byte, error)

Sign TypedData with a given private key. Verify that chainId in the typed data matches currently selected chain.

func SignTypedDataV4 added in v0.76.4

func SignTypedDataV4(typedData signercore.TypedData, prv *ecdsa.PrivateKey, chain *big.Int) (hexutil.Bytes, error)

func ValidateAndHash

func ValidateAndHash(typed TypedData, chain *big.Int) (common.Hash, error)

ValidateAndHash generates a hash of TypedData and verifies that chainId in the typed data matches currently selected chain.

Types

type Field

type Field struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

Field stores name and solidity type of the field.

func (Field) Validate

func (f Field) Validate() error

Validate checks that both name and type are not empty.

type TypedData

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

TypedData defines typed data according to eip-712.

func (TypedData) Validate

func (t TypedData) Validate() error

Validate that required fields are defined. This method doesn't check if dependencies of the main type are defined, it will be validated when type string is computed.

func (TypedData) ValidateChainID

func (t TypedData) ValidateChainID(chain *big.Int) error

ValidateChainID accept chain as big integer and verifies if typed data belongs to the same chain.

type Types

type Types map[string][]Field

Types define fields for each composite type.

Jump to

Keyboard shortcuts

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