Documentation
¶
Overview ¶
Package parser is used to parse some stuff
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArgEnsDomain ¶
ArgEnsDomain is a type alias to capture ENS domains
func (*ArgEnsDomain) Capture ¶
func (b *ArgEnsDomain) Capture(values []string) error
type ArgHex ¶
ArgHex represents anything that starts with 0x. If the value is a valid address, then it's capture into `base.Address` type, `string` otherwise.
type ContractArgument ¶
type ContractArgument struct {
Tokens []lexer.Token // the token that was parsed for this argument
String *ArgString `parser:"@String"` // the value if it's a string
Number *ArgNumber `parser:"| @Decimal"` // the value if it's a number
Boolean *ArgBool `parser:"| @('true'|'false')"` // the value if it's a boolean
Hex *ArgHex `parser:"| @Hex"` // the value if it's a hex string
EnsAddr *ArgEnsDomain `parser:"| @EnsDomain"` // the value if it's an ENS domain
}
ContractArgument represents input to the smart contract method call, e.g. `true` in `setSomething(true)`
func (*ContractArgument) AbiType ¶
func (a *ContractArgument) AbiType(abiType *abi.Type) (any, error)
func (*ContractArgument) Interface ¶
func (a *ContractArgument) Interface() any
Interface returns the value as interface{} (any)
type ContractCall ¶
type ContractCall struct {
// Four byte selector, e.g.
// 0xcdba2fd4(105)
SelectorCall *SelectorContractCall `parser:"@@"`
// Everything encoded, e.g.
// 0xcdba2fd40000000000000000000000000000000000000000000000000000000000007a69
Encoded string `parser:" | @Hex"`
// Function name, e.g.
// someName(105)
FunctionNameCall *FunctionContractCall `parser:" | @@"`
}
ContractCall is a call to a smart contract in any of the 3 supported forms (see Input syntax above)
func ParseCall ¶
func ParseCall(source string) (*ContractCall, error)
ParseCall turns smart contract method call string and parses it into a nice structures, from which we can easily extract the data to make the call.
type FunctionContractCall ¶
type FunctionContractCall struct {
Name string `parser:"@SolidityIdent '('"`
Arguments []*ContractArgument `parser:" (@@ (',' @@)*)? ')'"`
}
type Selector ¶
type Selector struct {
Value string
}
Selector captures four byte function selector (e.g. 0xcdba2fd4) It's capture method makes sure that the hex value is a valid selector.
type SelectorContractCall ¶
type SelectorContractCall struct {
Selector Selector `parser:"@Hex '('"`
Arguments []*ContractArgument `parser:" (@@ (',' @@)*)? ')'"`
}