Documentation
¶
Index ¶
- Variables
- func Generate(parsed *ParsedABI) (string, error)
- func GenerateGoNameForType(qualifiedName string) string
- func GenerateHeader(packageName string) (string, error)
- func GenerateSnippets(parsed *ParsedABI) (map[string]string, error)
- func HashFromName(name string) (string, error)
- func ParserFunction(goType string) string
- func ShouldGenerateStructType(goName string) bool
- type ABIItemType
- type Enum
- type EnumVariant
- type EventStruct
- type GeneratedEnum
- type GeneratedEvent
- type GeneratedStruct
- type GenerationParameters
- type HeaderParameters
- type IntermediateABI
- type ParsedABI
- type Struct
- type StructMember
Constants ¶
This section is empty.
Variables ¶
var EnumTemplate string = `` /* 821-byte string literal not displayed */
This is the Go template which is used to generate the function corresponding to an Enum. This template should be applied to a GeneratedEnum struct.
var EventParserTemplate string = `` /* 1000-byte string literal not displayed */
This aggregates all event information to generate an event parser for the given ABI. This template should be applied to a []GeneratedEvent list.
var EventTemplate string = `` /* 1212-byte string literal not displayed */
This is the Go template which is used to generate the Go bindings to a Starknet ABI event. This template should be applied to a GeneratedEvent struct.
var EventsCommonCode string = `` /* 3905-byte string literal not displayed */
Common code used in the code generated for events.
var HeaderTemplate string = `` /* 569-byte string literal not displayed */
This is the Go template used to create header information at the top of the generated code. At a bare minimum, the header specifies the version of seer that was used to generate the code. This template should be applied to a HeaderParameters struct.
var StructCommonCode string = `` /* 1368-byte string literal not displayed */
var StructTemplate string = `` /* 928-byte string literal not displayed */
This is the Go template which is used to generate the Go definition of a Starknet ABI struct. This template should be applied to a GeneratedStruct struct.
Functions ¶
func Generate ¶
Generates a single string consisting of the Go code for all the artifacts in a parsed Starknet ABI.
func GenerateGoNameForType ¶
Generates a Go name for a Starknet ABI item given its fully qualified ABI name. Qualified names for Starknet ABI items are of the form: `core::starknet::contract_address::ContractAddress`
func GenerateHeader ¶
Generates the header for the output code.
func GenerateSnippets ¶
Generate generates Go code for each of the items in a Starknet contract ABI. Returns a mapping of the go name of each object to a specification of the generated artifact. Currently supports: - Enums - Structs - Events
ABI names are used to depuplicate code snippets. The assumption is that the Starknet fully qualified name for a type uniquely determines that type across the entire ABI. This way even if the ABI passed into the code generator contains duplicate instances of an ABI item, the Go code will only contain one definition of that item.
func HashFromName ¶
Calculates the Starknet hash corresponding to the name of a Starknet ABI event. This hash is how the event is represented in Starknet event logs.
func ParserFunction ¶
Returns the name of the function that parses the given Go type.
Types ¶
type ABIItemType ¶
Represents a single item in a Starknet ABI.
type Enum ¶
type Enum struct { Type string `json:"type"` Name string `json:"name"` Variants []*EnumVariant `json:"variants"` }
Represents an enum in a Starknet ABI.
type EnumVariant ¶
Represents a particular value in a Starknet ABI enum.
type EventStruct ¶
type EventStruct struct { Type string `json:"type"` Name string `json:"name"` Kind string `json:"kind"` Members []*StructMember `json:"members"` }
Represents a struct in a Starknet ABI which is used as an event.
type GeneratedEnum ¶
type GeneratedEnum struct { GenerationParameters ParserName string EvaluatorName string Definition *Enum Code string }
The output of the code generation process for enum items in a Starknet ABI.
type GeneratedEvent ¶
type GeneratedEvent struct { GenerationParameters ParserName string Definition *EventStruct EventNameVar string EventHashVar string EventHash string Code string }
type GeneratedStruct ¶
type GeneratedStruct struct { GenerationParameters ParserName string Definition *Struct Code string }
The output of the code generation process for struct items in a Starknet ABI.
type GenerationParameters ¶
Common parameters required for the generation of all types of artifacts.
type HeaderParameters ¶
Defines the parameters used to create the header information for the generated code.
type IntermediateABI ¶
type IntermediateABI struct { Types []ABIItemType Messages []json.RawMessage }
Internal representation of a Starknet ABI used while parsing the ABI into its Go representation as a ParsedABI.
type ParsedABI ¶
type ParsedABI struct { Enums []*Enum `json:"enums"` Structs []*Struct `json:"structs"` Events []*EventStruct `json:"events"` }
Represents a parsed Starknet ABI.
type Struct ¶
type Struct struct { Type string `json:"type"` Name string `json:"name"` Members []*StructMember `json:"members"` }
Represents a struct in a Starknet ABI.
type StructMember ¶
type StructMember struct { Name string `json:"name"` Type string `json:"type"` Kind string `json:"kind,omitempty"` }
Represents a member of a Starknet ABI struct.