eip712

package
v0.0.0-...-a2f4e79 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2024 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateEIP712Domain

func CreateEIP712Domain(chainID uint64) apitypes.TypedDataDomain

createEIP712Domain creates the typed data domain for the given chainID.

func CreateEIP712MessagePayload

func CreateEIP712MessagePayload(data []byte, chain string) (eip712MessagePayload, error)

createEIP712MessagePayload generates the EIP-712 message payload corresponding to the input data.

func CreateEIP712Types

func CreateEIP712Types(messagePayload eip712MessagePayload) (apitypes.Types, error)

getEIP712Types creates and returns the EIP-712 types for the given message payload.

func FlattenPayloadMessages

func FlattenPayloadMessages(payload gjson.Result) (gjson.Result, int, error)

FlattenPayloadMessages flattens the input payload's messages, representing them as key-value pairs of "msg{i}": {Msg}, rather than as an array of Msgs. We do this to support messages with different schemas.

func GetEIP712BytesForMsg

func GetEIP712BytesForMsg(signDocBytes []byte) ([]byte, error)

GetEIP712BytesForMsg returns the EIP-712 object bytes for the given SignDoc bytes by decoding the bytes into an EIP-712 object, then converting via WrapTxToTypedData. See https://eips.ethereum.org/EIPS/eip-712 for more.

func GetEIP712TypedDataForMsg

func GetEIP712TypedDataForMsg(signDocBytes []byte) (apitypes.TypedData, error)

GetEIP712TypedDataForMsg returns the EIP-712 TypedData representation for either Amino or Protobuf encoded signature doc bytes.

func GetPopulatedSchemaForMsg

func GetPopulatedSchemaForMsg(msg gjson.Result) (gjson.Result, error)

GetPopulatedSchemaForMsg returns a sample JSON object for a given message type with all potentially optional fields populated

func GetSchemas

func GetSchemas() []string

GetSchemas returns all the schemas for the EIP712 types

func LegacyGetEIP712BytesForMsg

func LegacyGetEIP712BytesForMsg(signDocBytes []byte) ([]byte, error)

LegacyGetEIP712BytesForMsg returns the EIP-712 object bytes for the given SignDoc bytes by decoding the bytes into an EIP-712 object, then converting via LegacyWrapTxToTypedData. See https://eips.ethereum.org/EIPS/eip-712 for more.

func LegacyGetEIP712TypedDataForMsg

func LegacyGetEIP712TypedDataForMsg(signDocBytes []byte) (apitypes.TypedData, error)

LegacyGetEIP712TypedDataForMsg returns the EIP-712 TypedData representation for either Amino or Protobuf encoded signature doc bytes.

func LegacyWrapTxToTypedData

func LegacyWrapTxToTypedData(
	cdc codectypes.AnyUnpacker,
	chainID uint64,
	msg sdk.Msg,
	data []byte,
	feeDelegation *FeeDelegationOptions,
) (apitypes.TypedData, error)

LegacyWrapTxToTypedData is an ultimate method that wraps Amino-encoded Cosmos Tx JSON data into an EIP712-compatible TypedData request.

func NormalizeEIP712TypedData

func NormalizeEIP712TypedData(typedData apitypes.TypedData) (apitypes.TypedData, error)

Recursively iterate through message and populate empty fields with default falsy values

func NormalizeEmptyTypes

func NormalizeEmptyTypes(typedData apitypes.TypedData, typeObjArr []apitypes.Type, mapObject map[string]interface{}) (map[string]interface{}, error)

NormalizeEmptyTypes is a recursive function that adds empty values to fields that are omitted when serialized with Proto and Amino. EIP712 doesn't support optional fields, so we add the omitted empty values back in here. This includes empty strings, when a uint64 is 0, and when a bool is false.

func SetEncodingConfig

func SetEncodingConfig(cfg params.EncodingConfig)

SetEncodingConfig set the encoding config to the singleton codecs (Amino and Protobuf). The process of unmarshaling SignDoc bytes into a SignDoc object requires having a codec populated with all relevant message types. As a result, we must call this method on app initialization with the app's encoding config.

func UnmarshalBytesToJSONObject

func UnmarshalBytesToJSONObject(data []byte) (gjson.Result, error)

unmarshalBytesToJSONObject converts a bytestream into a JSON object, then makes sure the JSON is an object.

func WrapTxToTypedData

func WrapTxToTypedData(
	chainID uint64,
	data []byte,
	chain string,
) (apitypes.TypedData, error)

WrapTxToTypedData wraps an Amino-encoded Cosmos Tx JSON SignDoc bytestream into an EIP712-compatible TypedData request.

Types

type FeeDelegationOptions

type FeeDelegationOptions struct {
	FeePayer sdk.AccAddress
}

Jump to

Keyboard shortcuts

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