mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-21 20:26:41 +00:00
accounts/abi/abigen: add GetABI() method to abigen v2 generated bindings
Adds a GetABI() accessor to the generated contract struct so callers in other packages can retrieve the parsed abi.ABI without having to call ParseABI() themselves. Previously the abi field was unexported and inaccessible outside the generated package, forcing users to re-parse the ABI manually. Fixes #34705
This commit is contained in:
parent
4387f433c9
commit
08a7d96c65
22 changed files with 110 additions and 0 deletions
|
|
@ -59,6 +59,11 @@ var (
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *{{.Type}}) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// New{{.Type}} creates a new instance of {{.Type}}.
|
||||
func New{{.Type}}() *{{.Type}} {
|
||||
parsed, err := {{.Type}}MetaData.ParseABI()
|
||||
|
|
|
|||
|
|
@ -36,6 +36,11 @@ type CallbackParam struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *CallbackParam) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewCallbackParam creates a new instance of CallbackParam.
|
||||
func NewCallbackParam() *CallbackParam {
|
||||
parsed, err := CallbackParamMetaData.ParseABI()
|
||||
|
|
|
|||
|
|
@ -36,6 +36,11 @@ type Crowdsale struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *Crowdsale) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewCrowdsale creates a new instance of Crowdsale.
|
||||
func NewCrowdsale() *Crowdsale {
|
||||
parsed, err := CrowdsaleMetaData.ParseABI()
|
||||
|
|
|
|||
5
accounts/abi/abigen/testdata/v2/dao.go.txt
vendored
5
accounts/abi/abigen/testdata/v2/dao.go.txt
vendored
|
|
@ -36,6 +36,11 @@ type DAO struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *DAO) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewDAO creates a new instance of DAO.
|
||||
func NewDAO() *DAO {
|
||||
parsed, err := DAOMetaData.ParseABI()
|
||||
|
|
|
|||
|
|
@ -36,6 +36,11 @@ type DeeplyNestedArray struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *DeeplyNestedArray) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewDeeplyNestedArray creates a new instance of DeeplyNestedArray.
|
||||
func NewDeeplyNestedArray() *DeeplyNestedArray {
|
||||
parsed, err := DeeplyNestedArrayMetaData.ParseABI()
|
||||
|
|
|
|||
5
accounts/abi/abigen/testdata/v2/empty.go.txt
vendored
5
accounts/abi/abigen/testdata/v2/empty.go.txt
vendored
|
|
@ -36,6 +36,11 @@ type Empty struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *Empty) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewEmpty creates a new instance of Empty.
|
||||
func NewEmpty() *Empty {
|
||||
parsed, err := EmptyMetaData.ParseABI()
|
||||
|
|
|
|||
|
|
@ -35,6 +35,11 @@ type EventChecker struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *EventChecker) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewEventChecker creates a new instance of EventChecker.
|
||||
func NewEventChecker() *EventChecker {
|
||||
parsed, err := EventCheckerMetaData.ParseABI()
|
||||
|
|
|
|||
|
|
@ -36,6 +36,11 @@ type Getter struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *Getter) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewGetter creates a new instance of Getter.
|
||||
func NewGetter() *Getter {
|
||||
parsed, err := GetterMetaData.ParseABI()
|
||||
|
|
|
|||
|
|
@ -36,6 +36,11 @@ type IdentifierCollision struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *IdentifierCollision) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewIdentifierCollision creates a new instance of IdentifierCollision.
|
||||
func NewIdentifierCollision() *IdentifierCollision {
|
||||
parsed, err := IdentifierCollisionMetaData.ParseABI()
|
||||
|
|
|
|||
|
|
@ -35,6 +35,11 @@ type InputChecker struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *InputChecker) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewInputChecker creates a new instance of InputChecker.
|
||||
func NewInputChecker() *InputChecker {
|
||||
parsed, err := InputCheckerMetaData.ParseABI()
|
||||
|
|
|
|||
|
|
@ -36,6 +36,11 @@ type Interactor struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *Interactor) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewInteractor creates a new instance of Interactor.
|
||||
func NewInteractor() *Interactor {
|
||||
parsed, err := InteractorMetaData.ParseABI()
|
||||
|
|
|
|||
|
|
@ -42,6 +42,11 @@ type NameConflict struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *NameConflict) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewNameConflict creates a new instance of NameConflict.
|
||||
func NewNameConflict() *NameConflict {
|
||||
parsed, err := NameConflictMetaData.ParseABI()
|
||||
|
|
|
|||
|
|
@ -36,6 +36,11 @@ type NumericMethodName struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *NumericMethodName) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewNumericMethodName creates a new instance of NumericMethodName.
|
||||
func NewNumericMethodName() *NumericMethodName {
|
||||
parsed, err := NumericMethodNameMetaData.ParseABI()
|
||||
|
|
|
|||
|
|
@ -35,6 +35,11 @@ type OutputChecker struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *OutputChecker) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewOutputChecker creates a new instance of OutputChecker.
|
||||
func NewOutputChecker() *OutputChecker {
|
||||
parsed, err := OutputCheckerMetaData.ParseABI()
|
||||
|
|
|
|||
|
|
@ -36,6 +36,11 @@ type Overload struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *Overload) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewOverload creates a new instance of Overload.
|
||||
func NewOverload() *Overload {
|
||||
parsed, err := OverloadMetaData.ParseABI()
|
||||
|
|
|
|||
|
|
@ -36,6 +36,11 @@ type RangeKeyword struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *RangeKeyword) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewRangeKeyword creates a new instance of RangeKeyword.
|
||||
func NewRangeKeyword() *RangeKeyword {
|
||||
parsed, err := RangeKeywordMetaData.ParseABI()
|
||||
|
|
|
|||
|
|
@ -36,6 +36,11 @@ type Slicer struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *Slicer) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewSlicer creates a new instance of Slicer.
|
||||
func NewSlicer() *Slicer {
|
||||
parsed, err := SlicerMetaData.ParseABI()
|
||||
|
|
|
|||
|
|
@ -41,6 +41,11 @@ type Structs struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *Structs) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewStructs creates a new instance of Structs.
|
||||
func NewStructs() *Structs {
|
||||
parsed, err := StructsMetaData.ParseABI()
|
||||
|
|
|
|||
5
accounts/abi/abigen/testdata/v2/token.go.txt
vendored
5
accounts/abi/abigen/testdata/v2/token.go.txt
vendored
|
|
@ -36,6 +36,11 @@ type Token struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *Token) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewToken creates a new instance of Token.
|
||||
func NewToken() *Token {
|
||||
parsed, err := TokenMetaData.ParseABI()
|
||||
|
|
|
|||
5
accounts/abi/abigen/testdata/v2/tuple.go.txt
vendored
5
accounts/abi/abigen/testdata/v2/tuple.go.txt
vendored
|
|
@ -61,6 +61,11 @@ type Tuple struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *Tuple) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewTuple creates a new instance of Tuple.
|
||||
func NewTuple() *Tuple {
|
||||
parsed, err := TupleMetaData.ParseABI()
|
||||
|
|
|
|||
|
|
@ -36,6 +36,11 @@ type Tupler struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *Tupler) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewTupler creates a new instance of Tupler.
|
||||
func NewTupler() *Tupler {
|
||||
parsed, err := TuplerMetaData.ParseABI()
|
||||
|
|
|
|||
|
|
@ -36,6 +36,11 @@ type Underscorer struct {
|
|||
abi abi.ABI
|
||||
}
|
||||
|
||||
// GetABI returns the ABI associated with this contract binding.
|
||||
func (c *Underscorer) GetABI() abi.ABI {
|
||||
return c.abi
|
||||
}
|
||||
|
||||
// NewUnderscorer creates a new instance of Underscorer.
|
||||
func NewUnderscorer() *Underscorer {
|
||||
parsed, err := UnderscorerMetaData.ParseABI()
|
||||
|
|
|
|||
Loading…
Reference in a new issue