Documentation
¶
Index ¶
- Constants
- Variables
- func BuildTypeGraph(typeDefs []map[string]interface{}) map[string]map[string]bool
- func DecodeCoreTypes(decodeType StarknetCoreType, callData *[]*big.Int) (interface{}, error)
- func DecodeFromParams(params []AbiParameter, callData *[]*big.Int) (map[string]interface{}, error)
- func DecodeFromTypes(types []StarknetType, callData *[]*big.Int) ([]interface{}, error)
- func EncodeCoreType(encodeType StarknetCoreType, value interface{}) ([]*big.Int, error)
- func EncodeFromParams(params []AbiParameter, encodeValues map[string]interface{}) ([]*big.Int, error)
- func EncodeFromTypes(types []StarknetType, values []interface{}) ([]*big.Int, error)
- func GroupAbiByType(abiJson []map[string]interface{}) map[AbiMemberType][]map[string]interface{}
- func ParseEnumsAndStructs(abiStructs []map[string]interface{}) (map[string]interface{}, error)
- func StarknetKeccak(data []byte) []byte
- func TopoSortTypeDefs(typeDefs []map[string]interface{}) ([]map[string]interface{}, error)
- func TopologicalSort(graph map[string][]string) []string
- type AbiEvent
- type AbiFunction
- type AbiInterface
- type AbiMemberType
- type AbiParameter
- type DecodedEvent
- type DecodedFunction
- type DispatcherDecodeError
- type InvalidAbiError
- type InvalidCalldataError
- type StarknetABI
- type StarknetAbiEventKind
- type StarknetArray
- type StarknetCoreType
- type StarknetEnum
- type StarknetNonZero
- type StarknetOption
- type StarknetStruct
- type StarknetTuple
- type StarknetType
- type TypeDecodeError
- type TypeEncodeError
Constants ¶
const FIRST_CLASS_ABI = `` /* 3127-byte string literal not displayed */
const FIRST_CLASS_HASH = "0x010455c752b86932ce552f2b0fe81a880746649b9aee7e0d842bf3f52378f9f8"
const NO_STRUCT_ABI_DEFINITION = `` /* 1217-byte string literal not displayed */
const NO_STRUCT_CLASS_HASH = "0x03c5ace9d7b61e976247182246cf11ff0df039ecee1e0e37296b73bcb207b77d"
const STARKNET_ETH_ABI = `` /* 14945-byte string literal not displayed */
const STARKNET_ETH_CLASS_HASH = "0x05ffbcfeb50d200a0677c48a129a11245a3fc519d1d98d76882d1c9a1b19c6ed"
const STARKNET_USDC_ABI = `` /* 14945-byte string literal not displayed */
const STARKNET_USDC_CLASS_HASH = "0x05ffbcfeb50d200a0677c48a129a11245a3fc519d1d98d76882d1c9a1b19c6ed"
const VERSION_0_ABI_DEFINITION = `` /* 2005-byte string literal not displayed */
const VERSION_0_CLASS_HASH = "0x0305ee7a74fc480b0ec54bb306ab32d23da2b6c9b307423d23370eb5351220c3"
Variables ¶
var StarknetCoreTypes = map[string]struct{}{
"felt": {},
"felt*": {},
"core::integer::u128": {},
"core::integer::u64": {},
"core::integer::u32": {},
"core::integer::u16": {},
"core::integer::u8": {},
"core::felt252": {},
"core::bool": {},
"core::starknet::contract_address::ContractAddress": {},
"core::starknet::class_hash::ClassHash": {},
"core::starknet::eth_address::EthAddress": {},
}
Non-Struct Defined Types Used for Topological Sorting abi struct and enum definitions of incorrectly ordered abis
Functions ¶
func BuildTypeGraph ¶
The function takes in a list of type definitions (dict) and returns a dict of sets (map[string]bool)
func DecodeCoreTypes ¶
func DecodeCoreTypes(decodeType StarknetCoreType, callData *[]*big.Int) (interface{}, error)
Decodes Calldata using Starknet Core Type. The function Takes in two parameters, a StarknetCoreType, and a mutable reference to a calldata array and returns either a string, an int or a bool(hence we have taken return type as an interface). When decoding, calldata is popped off the top of the calldata array. This reference to the calldata array is recursively passed between type decoders, so this array is modified during decoding.
func DecodeFromParams ¶
func DecodeFromParams(params []AbiParameter, callData *[]*big.Int) (map[string]interface{}, error)
Decodes Calldata using AbiParameters, which have names and types
func DecodeFromTypes ¶
func DecodeFromTypes(types []StarknetType, callData *[]*big.Int) ([]interface{}, error)
Decodes calldata array using a list of StarknetTypes.
func EncodeCoreType ¶
func EncodeCoreType(encodeType StarknetCoreType, value interface{}) ([]*big.Int, error)
func EncodeFromParams ¶
func EncodeFromParams(params []AbiParameter, encodeValues map[string]interface{}) ([]*big.Int, error)
func EncodeFromTypes ¶
func EncodeFromTypes(types []StarknetType, values []interface{}) ([]*big.Int, error)
func GroupAbiByType ¶
func GroupAbiByType(abiJson []map[string]interface{}) map[AbiMemberType][]map[string]interface{}
Groups ABI JSON by ABI Type. If type is 'struct' or 'enum', it is grouped as a 'type_def'
func ParseEnumsAndStructs ¶
Parses an **ordered** array of ABI structs into a dictionary of StarknetStructs, mapping struct name to struct. return value is a map from string to StarknetStruct or StarknetEnum
func StarknetKeccak ¶
func TopoSortTypeDefs ¶
func TopologicalSort ¶
Types ¶
type AbiEvent ¶
type AbiEvent struct {
// contains filtered or unexported fields
}
func NewAbiEvent ¶
func NewAbiEvent(name string, parameters []string, data map[string]StarknetType, keys interface{}, abiName interface{}) *AbiEvent
keys can be either map[string]StarknetType or nil and abiName can be either string or Nil
func ParseAbiEvent ¶
type AbiFunction ¶
type AbiFunction struct {
// contains filtered or unexported fields
}
class Representing an ABI Function. Includes a function name, the function signature, and the input and output parameters.
func NewAbiFunction ¶
func NewAbiFunction(name string, inputs []AbiParameter, outputs []StarknetType, abiName string) *AbiFunction
func ParseAbiFunction ¶
func ParseAbiFunction(abiFunction map[string]interface{}, customTypes map[string]interface{}) (*AbiFunction, error)
func (*AbiFunction) Decode ¶
func (af *AbiFunction) Decode(callData []*big.Int, result interface{}) (*DecodedFunction, error)
decode the calldata and result of a function result can either be nil or []big.Int
type AbiInterface ¶
type AbiInterface struct {
// contains filtered or unexported fields
}
class Representing an ABI Interface. Includes a name and a list of functions.
type AbiMemberType ¶
type AbiMemberType string
const ( Function AbiMemberType = "function" L1Handler AbiMemberType = "l1_handler" AbiStruct AbiMemberType = "struct" Constructor AbiMemberType = "constructor" Event AbiMemberType = "event" Interface AbiMemberType = "interface" Impl AbiMemberType = "impl" TypeDef AbiMemberType = "type_def" // Internal Definition: typeDef = Union[struct, enum] )
type AbiParameter ¶
type AbiParameter struct { Name string Type StarknetType }
type DecodedEvent ¶
type DecodedEvent struct {
// contains filtered or unexported fields
}
class representing the result of decoding an ABI Event
type DecodedFunction ¶
type DecodedFunction struct {
// contains filtered or unexported fields
}
class representing the result of decoding an ABI
type DispatcherDecodeError ¶
type DispatcherDecodeError struct {
Msg string
}
DispatcherDecodeError is raised when there is an error decoding Functions, Events, or User Operations using the decoding dispatcher.
func (*DispatcherDecodeError) Error ¶
func (e *DispatcherDecodeError) Error() string
type InvalidAbiError ¶
type InvalidAbiError struct {
Msg string
}
InvalidAbiError is raised when malformed ABI JSON is supplied to the parser.
func (*InvalidAbiError) Error ¶
func (e *InvalidAbiError) Error() string
type InvalidCalldataError ¶
type InvalidCalldataError struct {
Msg string
}
InvalidCalldataError is raised when there is not enough calldata to decode the type.
func (*InvalidCalldataError) Error ¶
func (e *InvalidCalldataError) Error() string
type StarknetABI ¶
type StarknetABI struct { ABIName *string ClassHash []byte Functions map[string]AbiFunction Events map[string]AbiEvent Constructor []AbiParameter L1Handler *AbiFunction ImplementedInterfaces map[string]AbiInterface }
func StarknetAbiFromJSON ¶
func StarknetAbiFromJSON(abiJson []map[string]interface{}, abiName string, classHash []byte) (*StarknetABI, error)
Parse Starknet ABI from JSON @param abiJSON @param abiname @param classHash
type StarknetAbiEventKind ¶
type StarknetAbiEventKind string
const ( Enum StarknetAbiEventKind = "enum" Struct StarknetAbiEventKind = "struct" Data StarknetAbiEventKind = "data" Nested StarknetAbiEventKind = "nested" Key StarknetAbiEventKind = "key" Flat StarknetAbiEventKind = "flat" )
type StarknetArray ¶
type StarknetArray struct {
InnerType StarknetType
}
Dataclass representing a Starknet ABI Array. Both core::array::Array and core::array::Span are mapped to this dataclass since their ABI Encoding & Decoding are identical
type StarknetCoreType ¶
type StarknetCoreType int
const ( U8 StarknetCoreType = 1 U16 StarknetCoreType = 2 U32 StarknetCoreType = 4 U64 StarknetCoreType = 8 U128 StarknetCoreType = 16 U256 StarknetCoreType = 32 // Random Enum values for the rest Bool StarknetCoreType = 3 Felt StarknetCoreType = 5 ContractAddress StarknetCoreType = 6 EthAddress StarknetCoreType = 7 ClassHash StarknetCoreType = 9 StorageAddress StarknetCoreType = 10 Bytes31 StarknetCoreType = 11 NoneType StarknetCoreType = 12 )
func (StarknetCoreType) String ¶
func (t StarknetCoreType) String() string
type StarknetEnum ¶
type StarknetEnum struct { Name string Variants []struct { Name string Type StarknetType } }
type StarknetNonZero ¶
type StarknetNonZero struct {
InnerType StarknetType
}
type StarknetOption ¶
type StarknetOption struct {
InnerType StarknetType
}
type StarknetStruct ¶
type StarknetStruct struct { Name string Members []AbiParameter }
type StarknetTuple ¶
type StarknetTuple struct {
Members []StarknetType
}
func ParseTuple ¶
func ParseTuple(abiType string, customTypes map[string]interface{}) (StarknetTuple, error)
customTypes is a map from string to StarknetStruct or StarknetEnum
type StarknetType ¶
type StarknetType interface {
// contains filtered or unexported methods
}
func GetEnumIndex ¶
func GetEnumIndex(enumType StarknetEnum, enumKey string) (int, StarknetType, error)
func ParseAbiTypes ¶
func ParseAbiTypes(types []string, customTypes map[string]interface{}) ([]StarknetType, error)
type TypeDecodeError ¶
type TypeDecodeError struct {
Msg string
}
TypeDecodeError is raised when a type cannot be decoded from the calldata.
func (*TypeDecodeError) Error ¶
func (e *TypeDecodeError) Error() string
type TypeEncodeError ¶
type TypeEncodeError struct {
Msg string
}
TypeEncodeError is raised when a type cannot be encoded from the calldata.
func (*TypeEncodeError) Error ¶
func (e *TypeEncodeError) Error() string