decoder

package
v0.0.0-...-7328aa0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbiSignatureToName

func AbiSignatureToName(signature string) string

func AbiToSignature

func AbiToSignature(abiFunc abi.Method) string

func CollapseIfTuple

func CollapseIfTuple(input abi.Argument) string

func DecodeEvmAbiFromTypes

func DecodeEvmAbiFromTypes(types []string, data []byte) (interface{}, error)

func FilterEvents

func FilterEvents(contractABI abi.ABI) []abi.Event

func FilterFunctions

func FilterFunctions(contractABI abi.ABI) []abi.Method

func GetParsedAbi

func GetParsedAbi(abi_to_decode json.RawMessage)

func TypeToReadableName

func TypeToReadableName(typ string) string

Types

type ABI

type ABI struct {
	Functions map[string]Function `json:"functions"`
	Events    map[string]Event    `json:"events"`
}

func FromJSON

func FromJSON(abiData []byte, abiName string, additionalData []byte) (ABI, error)

type AbiEventDecoder

type AbiEventDecoder interface {
	Name() string
	Signature() []byte
	ABIName() string
	Priority() int
	IndexedParams() int
	Decode(data [][]byte, keys [][]byte) (*DecodedEventDataclass, error)
	IDStr(fullSignature bool) string
}

type AbiFunctionDecoder

type AbiFunctionDecoder interface {
	Name() string
	Signature() []byte
	ABIName() string
	Priority() int
	Decode(calldata [][]byte, result [][]byte) (*DecodedFuncDataclass, error) //returned DecodedEventDataclass in golang
	IDStr(fullSignature bool) string
}

type CairoEventDecoder

type CairoEventDecoder struct {
	types.AbiEvent
	Priority      int
	AbiName       string
	IndexedParams int
	Name          string
}

func NewCairoEventDecoder

func NewCairoEventDecoder(
	name string,
	parameters []string,
	data map[string]types.StarknetType,
	keys map[string]types.StarknetType,
	abiName string,
	priority int,
) *CairoEventDecoder

func (*CairoEventDecoder) Decode

func (e *CairoEventDecoder) Decode(data [][]byte, keys [][]byte) (types.DecodedEvent, error)
for paramName, starknetType := range d.AbiEvent.Keys {
	decodedValue, err := starknetType.Decode(keys[0])
	if err != nil {
		return nil, err
	}
	decodedData[paramName] = decodedValue
	keys = keys[1:]
}

type CairoFunctionDecoder

type CairoFunctionDecoder struct {
	*types.AbiFunction
	Priority int
	AbiName  string
}

func NewCairoFunctionDecoder

func NewCairoFunctionDecoder(name string, inputs []types.AbiParameter, outputs []types.StarknetType, abiName string, priority int) *CairoFunctionDecoder

func (*CairoFunctionDecoder) Decode

func (cfd *CairoFunctionDecoder) Decode(calldata [][]byte, result [][]byte) (*types.DecodedFunction, error)

func (*CairoFunctionDecoder) IDStr

func (cfd *CairoFunctionDecoder) IDStr(fullSignature bool) string

type DecodedEventDataclass

type DecodedEventDataclass struct {
	ABIName string
	Name    string
	Data    map[string]interface{} // Use map for dict in Python
}

type DecodedFuncDataclass

type DecodedFuncDataclass struct {
	ABIName string
	Name    string
	Input   map[string]interface{} // Use map for dict in Python
	Output  []interface{}          // Use slice for list in Python
}

type Event

type Event struct {
	Name       string                        `json:"name"`
	Parameters []string                      `json:"parameters"`
	Data       map[string]types.StarknetType `json:"data"`
	Keys       map[string]types.StarknetType `json:"keys"`
}

type EventType

type EventType struct {
	Kind    string   `json:"kind"`
	Name    string   `json:"name"`
	Members []Member `json:"members"`
}

type Function

type Function struct {
	Type            string   `json:"type"`
	Name            string   `json:"name"`
	Inputs          []Member `json:"inputs"`
	Outputs         []Output `json:"outputs"`
	StateMutability string   `json:"state_mutability"`
}

type Function1

type Function1 struct {
	Name    string               `json:"name"`
	Inputs  []types.AbiParameter `json:"inputs"`
	Outputs []types.StarknetType `json:"outputs"`
}

type InterfaceType

type InterfaceType struct {
	Type  string     `json:"type"`
	Name  string     `json:"name"`
	Items []Function `json:"items"`
}

type Member

type Member struct {
	Name string `json:"name"`
	Type string `json:"type"`
	Kind string `json:"kind"`
}

type Output

type Output struct {
	Type string `json:"type"`
}

Jump to

Keyboard shortcuts

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