From fd862fb6df398b97b9bb79188c6473e61d45d8cb Mon Sep 17 00:00:00 2001 From: Moshe Malawach Date: Tue, 21 Apr 2026 21:30:47 +0200 Subject: [PATCH] accounts/abi/abigen: add ABI method to v2 bindings Expose the parsed abi.ABI held by generated v2 contract bindings via a public ABI() method. This lets callers access event and error metadata (for example to build FilterQuery topics spanning multiple contracts) without re-parsing the ABI via ContractMetaData.ParseABI(). The method is named ABI() rather than GetABI() (as originally proposed in the issue) to follow the Go getter naming convention used elsewhere in this repository and in the standard library. Closes #34705. --- accounts/abi/abigen/source2.go.tpl | 7 +++ .../abigen/testdata/v2/callbackparam.go.txt | 7 +++ .../abi/abigen/testdata/v2/crowdsale.go.txt | 7 +++ accounts/abi/abigen/testdata/v2/dao.go.txt | 7 +++ .../testdata/v2/deeplynestedarray.go.txt | 7 +++ accounts/abi/abigen/testdata/v2/empty.go.txt | 7 +++ .../abigen/testdata/v2/eventchecker.go.txt | 7 +++ accounts/abi/abigen/testdata/v2/getter.go.txt | 7 +++ .../testdata/v2/identifiercollision.go.txt | 7 +++ .../abigen/testdata/v2/inputchecker.go.txt | 7 +++ .../abi/abigen/testdata/v2/interactor.go.txt | 7 +++ .../abigen/testdata/v2/nameconflict.go.txt | 7 +++ .../testdata/v2/numericmethodname.go.txt | 7 +++ .../abigen/testdata/v2/outputchecker.go.txt | 7 +++ .../abi/abigen/testdata/v2/overload.go.txt | 7 +++ .../abigen/testdata/v2/rangekeyword.go.txt | 7 +++ accounts/abi/abigen/testdata/v2/slicer.go.txt | 7 +++ .../abi/abigen/testdata/v2/structs.go.txt | 7 +++ accounts/abi/abigen/testdata/v2/token.go.txt | 7 +++ accounts/abi/abigen/testdata/v2/tuple.go.txt | 7 +++ accounts/abi/abigen/testdata/v2/tupler.go.txt | 7 +++ .../abi/abigen/testdata/v2/underscorer.go.txt | 7 +++ .../bind/v2/internal/contracts/db/bindings.go | 7 +++ .../v2/internal/contracts/events/bindings.go | 7 +++ .../contracts/nested_libraries/bindings.go | 56 +++++++++++++++++++ .../contracts/solc_errors/bindings.go | 14 +++++ .../contracts/uint256arrayreturn/bindings.go | 7 +++ 27 files changed, 245 insertions(+) diff --git a/accounts/abi/abigen/source2.go.tpl b/accounts/abi/abigen/source2.go.tpl index c517caf6f4..1dadfc0ff3 100644 --- a/accounts/abi/abigen/source2.go.tpl +++ b/accounts/abi/abigen/source2.go.tpl @@ -68,6 +68,13 @@ var ( return &{{.Type}}{abi: *parsed} } + // ABI returns the parsed ABI of the contract. The returned value shares + // its internal maps (Methods, Events, Errors) with the binding, so callers + // must not mutate it. + func (c *{{.Type}}) ABI() abi.ABI { + return c.abi + } + // Instance creates a wrapper for a deployed contract instance at the given address. // Use this to create the instance object passed to abigen v2 library functions Call, Transact, etc. func (c *{{.Type}}) Instance(backend bind.ContractBackend, addr common.Address) *bind.BoundContract { diff --git a/accounts/abi/abigen/testdata/v2/callbackparam.go.txt b/accounts/abi/abigen/testdata/v2/callbackparam.go.txt index d22b978486..8d6777c7a8 100644 --- a/accounts/abi/abigen/testdata/v2/callbackparam.go.txt +++ b/accounts/abi/abigen/testdata/v2/callbackparam.go.txt @@ -45,6 +45,13 @@ func NewCallbackParam() *CallbackParam { return &CallbackParam{abi: *parsed} } +// ABI returns the parsed ABI of the contract. The returned value shares +// its internal maps (Methods, Events, Errors) with the binding, so callers +// must not mutate it. +func (c *CallbackParam) ABI() abi.ABI { + return c.abi +} + // Instance creates a wrapper for a deployed contract instance at the given address. // Use this to create the instance object passed to abigen v2 library functions Call, Transact, etc. func (c *CallbackParam) Instance(backend bind.ContractBackend, addr common.Address) *bind.BoundContract { diff --git a/accounts/abi/abigen/testdata/v2/crowdsale.go.txt b/accounts/abi/abigen/testdata/v2/crowdsale.go.txt index f0bba246ab..f439aab3db 100644 --- a/accounts/abi/abigen/testdata/v2/crowdsale.go.txt +++ b/accounts/abi/abigen/testdata/v2/crowdsale.go.txt @@ -45,6 +45,13 @@ func NewCrowdsale() *Crowdsale { return &Crowdsale{abi: *parsed} } +// ABI returns the parsed ABI of the contract. The returned value shares +// its internal maps (Methods, Events, Errors) with the binding, so callers +// must not mutate it. +func (c *Crowdsale) ABI() abi.ABI { + return c.abi +} + // Instance creates a wrapper for a deployed contract instance at the given address. // Use this to create the instance object passed to abigen v2 library functions Call, Transact, etc. func (c *Crowdsale) Instance(backend bind.ContractBackend, addr common.Address) *bind.BoundContract { diff --git a/accounts/abi/abigen/testdata/v2/dao.go.txt b/accounts/abi/abigen/testdata/v2/dao.go.txt index 0e9adba31e..86125ad5b6 100644 --- a/accounts/abi/abigen/testdata/v2/dao.go.txt +++ b/accounts/abi/abigen/testdata/v2/dao.go.txt @@ -45,6 +45,13 @@ func NewDAO() *DAO { return &DAO{abi: *parsed} } +// ABI returns the parsed ABI of the contract. The returned value shares +// its internal maps (Methods, Events, Errors) with the binding, so callers +// must not mutate it. +func (c *DAO) ABI() abi.ABI { + return c.abi +} + // Instance creates a wrapper for a deployed contract instance at the given address. // Use this to create the instance object passed to abigen v2 library functions Call, Transact, etc. func (c *DAO) Instance(backend bind.ContractBackend, addr common.Address) *bind.BoundContract { diff --git a/accounts/abi/abigen/testdata/v2/deeplynestedarray.go.txt b/accounts/abi/abigen/testdata/v2/deeplynestedarray.go.txt index 302f1d736f..a7b3d8701e 100644 --- a/accounts/abi/abigen/testdata/v2/deeplynestedarray.go.txt +++ b/accounts/abi/abigen/testdata/v2/deeplynestedarray.go.txt @@ -45,6 +45,13 @@ func NewDeeplyNestedArray() *DeeplyNestedArray { return &DeeplyNestedArray{abi: *parsed} } +// ABI returns the parsed ABI of the contract. The returned value shares +// its internal maps (Methods, Events, Errors) with the binding, so callers +// must not mutate it. +func (c *DeeplyNestedArray) ABI() abi.ABI { + return c.abi +} + // Instance creates a wrapper for a deployed contract instance at the given address. // Use this to create the instance object passed to abigen v2 library functions Call, Transact, etc. func (c *DeeplyNestedArray) Instance(backend bind.ContractBackend, addr common.Address) *bind.BoundContract { diff --git a/accounts/abi/abigen/testdata/v2/empty.go.txt b/accounts/abi/abigen/testdata/v2/empty.go.txt index 7082e20799..0ea9c8bfe5 100644 --- a/accounts/abi/abigen/testdata/v2/empty.go.txt +++ b/accounts/abi/abigen/testdata/v2/empty.go.txt @@ -45,6 +45,13 @@ func NewEmpty() *Empty { return &Empty{abi: *parsed} } +// ABI returns the parsed ABI of the contract. The returned value shares +// its internal maps (Methods, Events, Errors) with the binding, so callers +// must not mutate it. +func (c *Empty) ABI() abi.ABI { + return c.abi +} + // Instance creates a wrapper for a deployed contract instance at the given address. // Use this to create the instance object passed to abigen v2 library functions Call, Transact, etc. func (c *Empty) Instance(backend bind.ContractBackend, addr common.Address) *bind.BoundContract { diff --git a/accounts/abi/abigen/testdata/v2/eventchecker.go.txt b/accounts/abi/abigen/testdata/v2/eventchecker.go.txt index d0600d7c3e..c16832993c 100644 --- a/accounts/abi/abigen/testdata/v2/eventchecker.go.txt +++ b/accounts/abi/abigen/testdata/v2/eventchecker.go.txt @@ -44,6 +44,13 @@ func NewEventChecker() *EventChecker { return &EventChecker{abi: *parsed} } +// ABI returns the parsed ABI of the contract. The returned value shares +// its internal maps (Methods, Events, Errors) with the binding, so callers +// must not mutate it. +func (c *EventChecker) ABI() abi.ABI { + return c.abi +} + // Instance creates a wrapper for a deployed contract instance at the given address. // Use this to create the instance object passed to abigen v2 library functions Call, Transact, etc. func (c *EventChecker) Instance(backend bind.ContractBackend, addr common.Address) *bind.BoundContract { diff --git a/accounts/abi/abigen/testdata/v2/getter.go.txt b/accounts/abi/abigen/testdata/v2/getter.go.txt index 69a4fb54c8..72f9007ea0 100644 --- a/accounts/abi/abigen/testdata/v2/getter.go.txt +++ b/accounts/abi/abigen/testdata/v2/getter.go.txt @@ -45,6 +45,13 @@ func NewGetter() *Getter { return &Getter{abi: *parsed} } +// ABI returns the parsed ABI of the contract. The returned value shares +// its internal maps (Methods, Events, Errors) with the binding, so callers +// must not mutate it. +func (c *Getter) ABI() abi.ABI { + return c.abi +} + // Instance creates a wrapper for a deployed contract instance at the given address. // Use this to create the instance object passed to abigen v2 library functions Call, Transact, etc. func (c *Getter) Instance(backend bind.ContractBackend, addr common.Address) *bind.BoundContract { diff --git a/accounts/abi/abigen/testdata/v2/identifiercollision.go.txt b/accounts/abi/abigen/testdata/v2/identifiercollision.go.txt index e7301521f4..f3a94547ce 100644 --- a/accounts/abi/abigen/testdata/v2/identifiercollision.go.txt +++ b/accounts/abi/abigen/testdata/v2/identifiercollision.go.txt @@ -45,6 +45,13 @@ func NewIdentifierCollision() *IdentifierCollision { return &IdentifierCollision{abi: *parsed} } +// ABI returns the parsed ABI of the contract. The returned value shares +// its internal maps (Methods, Events, Errors) with the binding, so callers +// must not mutate it. +func (c *IdentifierCollision) ABI() abi.ABI { + return c.abi +} + // Instance creates a wrapper for a deployed contract instance at the given address. // Use this to create the instance object passed to abigen v2 library functions Call, Transact, etc. func (c *IdentifierCollision) Instance(backend bind.ContractBackend, addr common.Address) *bind.BoundContract { diff --git a/accounts/abi/abigen/testdata/v2/inputchecker.go.txt b/accounts/abi/abigen/testdata/v2/inputchecker.go.txt index 1743f336db..1d6936f982 100644 --- a/accounts/abi/abigen/testdata/v2/inputchecker.go.txt +++ b/accounts/abi/abigen/testdata/v2/inputchecker.go.txt @@ -44,6 +44,13 @@ func NewInputChecker() *InputChecker { return &InputChecker{abi: *parsed} } +// ABI returns the parsed ABI of the contract. The returned value shares +// its internal maps (Methods, Events, Errors) with the binding, so callers +// must not mutate it. +func (c *InputChecker) ABI() abi.ABI { + return c.abi +} + // Instance creates a wrapper for a deployed contract instance at the given address. // Use this to create the instance object passed to abigen v2 library functions Call, Transact, etc. func (c *InputChecker) Instance(backend bind.ContractBackend, addr common.Address) *bind.BoundContract { diff --git a/accounts/abi/abigen/testdata/v2/interactor.go.txt b/accounts/abi/abigen/testdata/v2/interactor.go.txt index f33c95b639..cff97ed650 100644 --- a/accounts/abi/abigen/testdata/v2/interactor.go.txt +++ b/accounts/abi/abigen/testdata/v2/interactor.go.txt @@ -45,6 +45,13 @@ func NewInteractor() *Interactor { return &Interactor{abi: *parsed} } +// ABI returns the parsed ABI of the contract. The returned value shares +// its internal maps (Methods, Events, Errors) with the binding, so callers +// must not mutate it. +func (c *Interactor) ABI() abi.ABI { + return c.abi +} + // Instance creates a wrapper for a deployed contract instance at the given address. // Use this to create the instance object passed to abigen v2 library functions Call, Transact, etc. func (c *Interactor) Instance(backend bind.ContractBackend, addr common.Address) *bind.BoundContract { diff --git a/accounts/abi/abigen/testdata/v2/nameconflict.go.txt b/accounts/abi/abigen/testdata/v2/nameconflict.go.txt index 5e4a9ecaf0..05e11c3c31 100644 --- a/accounts/abi/abigen/testdata/v2/nameconflict.go.txt +++ b/accounts/abi/abigen/testdata/v2/nameconflict.go.txt @@ -51,6 +51,13 @@ func NewNameConflict() *NameConflict { return &NameConflict{abi: *parsed} } +// ABI returns the parsed ABI of the contract. The returned value shares +// its internal maps (Methods, Events, Errors) with the binding, so callers +// must not mutate it. +func (c *NameConflict) ABI() abi.ABI { + return c.abi +} + // Instance creates a wrapper for a deployed contract instance at the given address. // Use this to create the instance object passed to abigen v2 library functions Call, Transact, etc. func (c *NameConflict) Instance(backend bind.ContractBackend, addr common.Address) *bind.BoundContract { diff --git a/accounts/abi/abigen/testdata/v2/numericmethodname.go.txt b/accounts/abi/abigen/testdata/v2/numericmethodname.go.txt index 0af31a1cfb..728697e769 100644 --- a/accounts/abi/abigen/testdata/v2/numericmethodname.go.txt +++ b/accounts/abi/abigen/testdata/v2/numericmethodname.go.txt @@ -45,6 +45,13 @@ func NewNumericMethodName() *NumericMethodName { return &NumericMethodName{abi: *parsed} } +// ABI returns the parsed ABI of the contract. The returned value shares +// its internal maps (Methods, Events, Errors) with the binding, so callers +// must not mutate it. +func (c *NumericMethodName) ABI() abi.ABI { + return c.abi +} + // Instance creates a wrapper for a deployed contract instance at the given address. // Use this to create the instance object passed to abigen v2 library functions Call, Transact, etc. func (c *NumericMethodName) Instance(backend bind.ContractBackend, addr common.Address) *bind.BoundContract { diff --git a/accounts/abi/abigen/testdata/v2/outputchecker.go.txt b/accounts/abi/abigen/testdata/v2/outputchecker.go.txt index f1c98f536e..b9eb0743c3 100644 --- a/accounts/abi/abigen/testdata/v2/outputchecker.go.txt +++ b/accounts/abi/abigen/testdata/v2/outputchecker.go.txt @@ -44,6 +44,13 @@ func NewOutputChecker() *OutputChecker { return &OutputChecker{abi: *parsed} } +// ABI returns the parsed ABI of the contract. The returned value shares +// its internal maps (Methods, Events, Errors) with the binding, so callers +// must not mutate it. +func (c *OutputChecker) ABI() abi.ABI { + return c.abi +} + // Instance creates a wrapper for a deployed contract instance at the given address. // Use this to create the instance object passed to abigen v2 library functions Call, Transact, etc. func (c *OutputChecker) Instance(backend bind.ContractBackend, addr common.Address) *bind.BoundContract { diff --git a/accounts/abi/abigen/testdata/v2/overload.go.txt b/accounts/abi/abigen/testdata/v2/overload.go.txt index 563edf7842..e245540116 100644 --- a/accounts/abi/abigen/testdata/v2/overload.go.txt +++ b/accounts/abi/abigen/testdata/v2/overload.go.txt @@ -45,6 +45,13 @@ func NewOverload() *Overload { return &Overload{abi: *parsed} } +// ABI returns the parsed ABI of the contract. The returned value shares +// its internal maps (Methods, Events, Errors) with the binding, so callers +// must not mutate it. +func (c *Overload) ABI() abi.ABI { + return c.abi +} + // Instance creates a wrapper for a deployed contract instance at the given address. // Use this to create the instance object passed to abigen v2 library functions Call, Transact, etc. func (c *Overload) Instance(backend bind.ContractBackend, addr common.Address) *bind.BoundContract { diff --git a/accounts/abi/abigen/testdata/v2/rangekeyword.go.txt b/accounts/abi/abigen/testdata/v2/rangekeyword.go.txt index 296de1fccc..4aeb102d32 100644 --- a/accounts/abi/abigen/testdata/v2/rangekeyword.go.txt +++ b/accounts/abi/abigen/testdata/v2/rangekeyword.go.txt @@ -45,6 +45,13 @@ func NewRangeKeyword() *RangeKeyword { return &RangeKeyword{abi: *parsed} } +// ABI returns the parsed ABI of the contract. The returned value shares +// its internal maps (Methods, Events, Errors) with the binding, so callers +// must not mutate it. +func (c *RangeKeyword) ABI() abi.ABI { + return c.abi +} + // Instance creates a wrapper for a deployed contract instance at the given address. // Use this to create the instance object passed to abigen v2 library functions Call, Transact, etc. func (c *RangeKeyword) Instance(backend bind.ContractBackend, addr common.Address) *bind.BoundContract { diff --git a/accounts/abi/abigen/testdata/v2/slicer.go.txt b/accounts/abi/abigen/testdata/v2/slicer.go.txt index 379f136453..8e3a9faca8 100644 --- a/accounts/abi/abigen/testdata/v2/slicer.go.txt +++ b/accounts/abi/abigen/testdata/v2/slicer.go.txt @@ -45,6 +45,13 @@ func NewSlicer() *Slicer { return &Slicer{abi: *parsed} } +// ABI returns the parsed ABI of the contract. The returned value shares +// its internal maps (Methods, Events, Errors) with the binding, so callers +// must not mutate it. +func (c *Slicer) ABI() abi.ABI { + return c.abi +} + // Instance creates a wrapper for a deployed contract instance at the given address. // Use this to create the instance object passed to abigen v2 library functions Call, Transact, etc. func (c *Slicer) Instance(backend bind.ContractBackend, addr common.Address) *bind.BoundContract { diff --git a/accounts/abi/abigen/testdata/v2/structs.go.txt b/accounts/abi/abigen/testdata/v2/structs.go.txt index 4d8864cf6e..4df6066764 100644 --- a/accounts/abi/abigen/testdata/v2/structs.go.txt +++ b/accounts/abi/abigen/testdata/v2/structs.go.txt @@ -50,6 +50,13 @@ func NewStructs() *Structs { return &Structs{abi: *parsed} } +// ABI returns the parsed ABI of the contract. The returned value shares +// its internal maps (Methods, Events, Errors) with the binding, so callers +// must not mutate it. +func (c *Structs) ABI() abi.ABI { + return c.abi +} + // Instance creates a wrapper for a deployed contract instance at the given address. // Use this to create the instance object passed to abigen v2 library functions Call, Transact, etc. func (c *Structs) Instance(backend bind.ContractBackend, addr common.Address) *bind.BoundContract { diff --git a/accounts/abi/abigen/testdata/v2/token.go.txt b/accounts/abi/abigen/testdata/v2/token.go.txt index 3bd60a6cdd..14f3de2c30 100644 --- a/accounts/abi/abigen/testdata/v2/token.go.txt +++ b/accounts/abi/abigen/testdata/v2/token.go.txt @@ -45,6 +45,13 @@ func NewToken() *Token { return &Token{abi: *parsed} } +// ABI returns the parsed ABI of the contract. The returned value shares +// its internal maps (Methods, Events, Errors) with the binding, so callers +// must not mutate it. +func (c *Token) ABI() abi.ABI { + return c.abi +} + // Instance creates a wrapper for a deployed contract instance at the given address. // Use this to create the instance object passed to abigen v2 library functions Call, Transact, etc. func (c *Token) Instance(backend bind.ContractBackend, addr common.Address) *bind.BoundContract { diff --git a/accounts/abi/abigen/testdata/v2/tuple.go.txt b/accounts/abi/abigen/testdata/v2/tuple.go.txt index 10b634f3db..e5773d9870 100644 --- a/accounts/abi/abigen/testdata/v2/tuple.go.txt +++ b/accounts/abi/abigen/testdata/v2/tuple.go.txt @@ -70,6 +70,13 @@ func NewTuple() *Tuple { return &Tuple{abi: *parsed} } +// ABI returns the parsed ABI of the contract. The returned value shares +// its internal maps (Methods, Events, Errors) with the binding, so callers +// must not mutate it. +func (c *Tuple) ABI() abi.ABI { + return c.abi +} + // Instance creates a wrapper for a deployed contract instance at the given address. // Use this to create the instance object passed to abigen v2 library functions Call, Transact, etc. func (c *Tuple) Instance(backend bind.ContractBackend, addr common.Address) *bind.BoundContract { diff --git a/accounts/abi/abigen/testdata/v2/tupler.go.txt b/accounts/abi/abigen/testdata/v2/tupler.go.txt index 8643487042..f1e71ca765 100644 --- a/accounts/abi/abigen/testdata/v2/tupler.go.txt +++ b/accounts/abi/abigen/testdata/v2/tupler.go.txt @@ -45,6 +45,13 @@ func NewTupler() *Tupler { return &Tupler{abi: *parsed} } +// ABI returns the parsed ABI of the contract. The returned value shares +// its internal maps (Methods, Events, Errors) with the binding, so callers +// must not mutate it. +func (c *Tupler) ABI() abi.ABI { + return c.abi +} + // Instance creates a wrapper for a deployed contract instance at the given address. // Use this to create the instance object passed to abigen v2 library functions Call, Transact, etc. func (c *Tupler) Instance(backend bind.ContractBackend, addr common.Address) *bind.BoundContract { diff --git a/accounts/abi/abigen/testdata/v2/underscorer.go.txt b/accounts/abi/abigen/testdata/v2/underscorer.go.txt index 13ec968508..bc5b21f585 100644 --- a/accounts/abi/abigen/testdata/v2/underscorer.go.txt +++ b/accounts/abi/abigen/testdata/v2/underscorer.go.txt @@ -45,6 +45,13 @@ func NewUnderscorer() *Underscorer { return &Underscorer{abi: *parsed} } +// ABI returns the parsed ABI of the contract. The returned value shares +// its internal maps (Methods, Events, Errors) with the binding, so callers +// must not mutate it. +func (c *Underscorer) ABI() abi.ABI { + return c.abi +} + // Instance creates a wrapper for a deployed contract instance at the given address. // Use this to create the instance object passed to abigen v2 library functions Call, Transact, etc. func (c *Underscorer) Instance(backend bind.ContractBackend, addr common.Address) *bind.BoundContract { diff --git a/accounts/abi/bind/v2/internal/contracts/db/bindings.go b/accounts/abi/bind/v2/internal/contracts/db/bindings.go index 2fc57fba6d..fd6ab77cef 100644 --- a/accounts/abi/bind/v2/internal/contracts/db/bindings.go +++ b/accounts/abi/bind/v2/internal/contracts/db/bindings.go @@ -52,6 +52,13 @@ func NewDB() *DB { return &DB{abi: *parsed} } +// ABI returns the parsed ABI of the contract. The returned value shares +// its internal maps (Methods, Events, Errors) with the binding, so callers +// must not mutate it. +func (c *DB) ABI() abi.ABI { + return c.abi +} + // Instance creates a wrapper for a deployed contract instance at the given address. // Use this to create the instance object passed to abigen v2 library functions Call, Transact, etc. func (c *DB) Instance(backend bind.ContractBackend, addr common.Address) *bind.BoundContract { diff --git a/accounts/abi/bind/v2/internal/contracts/events/bindings.go b/accounts/abi/bind/v2/internal/contracts/events/bindings.go index 2eb5751f23..25f3e5834b 100644 --- a/accounts/abi/bind/v2/internal/contracts/events/bindings.go +++ b/accounts/abi/bind/v2/internal/contracts/events/bindings.go @@ -45,6 +45,13 @@ func NewC() *C { return &C{abi: *parsed} } +// ABI returns the parsed ABI of the contract. The returned value shares +// its internal maps (Methods, Events, Errors) with the binding, so callers +// must not mutate it. +func (c *C) ABI() abi.ABI { + return c.abi +} + // Instance creates a wrapper for a deployed contract instance at the given address. // Use this to create the instance object passed to abigen v2 library functions Call, Transact, etc. func (c *C) Instance(backend bind.ContractBackend, addr common.Address) *bind.BoundContract { diff --git a/accounts/abi/bind/v2/internal/contracts/nested_libraries/bindings.go b/accounts/abi/bind/v2/internal/contracts/nested_libraries/bindings.go index d1cb08116b..8e90beb761 100644 --- a/accounts/abi/bind/v2/internal/contracts/nested_libraries/bindings.go +++ b/accounts/abi/bind/v2/internal/contracts/nested_libraries/bindings.go @@ -49,6 +49,13 @@ func NewC1() *C1 { return &C1{abi: *parsed} } +// ABI returns the parsed ABI of the contract. The returned value shares +// its internal maps (Methods, Events, Errors) with the binding, so callers +// must not mutate it. +func (c *C1) ABI() abi.ABI { + return c.abi +} + // Instance creates a wrapper for a deployed contract instance at the given address. // Use this to create the instance object passed to abigen v2 library functions Call, Transact, etc. func (c *C1) Instance(backend bind.ContractBackend, addr common.Address) *bind.BoundContract { @@ -127,6 +134,13 @@ func NewC2() *C2 { return &C2{abi: *parsed} } +// ABI returns the parsed ABI of the contract. The returned value shares +// its internal maps (Methods, Events, Errors) with the binding, so callers +// must not mutate it. +func (c *C2) ABI() abi.ABI { + return c.abi +} + // Instance creates a wrapper for a deployed contract instance at the given address. // Use this to create the instance object passed to abigen v2 library functions Call, Transact, etc. func (c *C2) Instance(backend bind.ContractBackend, addr common.Address) *bind.BoundContract { @@ -201,6 +215,13 @@ func NewL1() *L1 { return &L1{abi: *parsed} } +// ABI returns the parsed ABI of the contract. The returned value shares +// its internal maps (Methods, Events, Errors) with the binding, so callers +// must not mutate it. +func (c *L1) ABI() abi.ABI { + return c.abi +} + // Instance creates a wrapper for a deployed contract instance at the given address. // Use this to create the instance object passed to abigen v2 library functions Call, Transact, etc. func (c *L1) Instance(backend bind.ContractBackend, addr common.Address) *bind.BoundContract { @@ -266,6 +287,13 @@ func NewL2() *L2 { return &L2{abi: *parsed} } +// ABI returns the parsed ABI of the contract. The returned value shares +// its internal maps (Methods, Events, Errors) with the binding, so callers +// must not mutate it. +func (c *L2) ABI() abi.ABI { + return c.abi +} + // Instance creates a wrapper for a deployed contract instance at the given address. // Use this to create the instance object passed to abigen v2 library functions Call, Transact, etc. func (c *L2) Instance(backend bind.ContractBackend, addr common.Address) *bind.BoundContract { @@ -331,6 +359,13 @@ func NewL2b() *L2b { return &L2b{abi: *parsed} } +// ABI returns the parsed ABI of the contract. The returned value shares +// its internal maps (Methods, Events, Errors) with the binding, so callers +// must not mutate it. +func (c *L2b) ABI() abi.ABI { + return c.abi +} + // Instance creates a wrapper for a deployed contract instance at the given address. // Use this to create the instance object passed to abigen v2 library functions Call, Transact, etc. func (c *L2b) Instance(backend bind.ContractBackend, addr common.Address) *bind.BoundContract { @@ -393,6 +428,13 @@ func NewL3() *L3 { return &L3{abi: *parsed} } +// ABI returns the parsed ABI of the contract. The returned value shares +// its internal maps (Methods, Events, Errors) with the binding, so callers +// must not mutate it. +func (c *L3) ABI() abi.ABI { + return c.abi +} + // Instance creates a wrapper for a deployed contract instance at the given address. // Use this to create the instance object passed to abigen v2 library functions Call, Transact, etc. func (c *L3) Instance(backend bind.ContractBackend, addr common.Address) *bind.BoundContract { @@ -459,6 +501,13 @@ func NewL4() *L4 { return &L4{abi: *parsed} } +// ABI returns the parsed ABI of the contract. The returned value shares +// its internal maps (Methods, Events, Errors) with the binding, so callers +// must not mutate it. +func (c *L4) ABI() abi.ABI { + return c.abi +} + // Instance creates a wrapper for a deployed contract instance at the given address. // Use this to create the instance object passed to abigen v2 library functions Call, Transact, etc. func (c *L4) Instance(backend bind.ContractBackend, addr common.Address) *bind.BoundContract { @@ -524,6 +573,13 @@ func NewL4b() *L4b { return &L4b{abi: *parsed} } +// ABI returns the parsed ABI of the contract. The returned value shares +// its internal maps (Methods, Events, Errors) with the binding, so callers +// must not mutate it. +func (c *L4b) ABI() abi.ABI { + return c.abi +} + // Instance creates a wrapper for a deployed contract instance at the given address. // Use this to create the instance object passed to abigen v2 library functions Call, Transact, etc. func (c *L4b) Instance(backend bind.ContractBackend, addr common.Address) *bind.BoundContract { diff --git a/accounts/abi/bind/v2/internal/contracts/solc_errors/bindings.go b/accounts/abi/bind/v2/internal/contracts/solc_errors/bindings.go index 627b86f1b9..9c13f629a6 100644 --- a/accounts/abi/bind/v2/internal/contracts/solc_errors/bindings.go +++ b/accounts/abi/bind/v2/internal/contracts/solc_errors/bindings.go @@ -45,6 +45,13 @@ func NewC() *C { return &C{abi: *parsed} } +// ABI returns the parsed ABI of the contract. The returned value shares +// its internal maps (Methods, Events, Errors) with the binding, so callers +// must not mutate it. +func (c *C) ABI() abi.ABI { + return c.abi +} + // Instance creates a wrapper for a deployed contract instance at the given address. // Use this to create the instance object passed to abigen v2 library functions Call, Transact, etc. func (c *C) Instance(backend bind.ContractBackend, addr common.Address) *bind.BoundContract { @@ -182,6 +189,13 @@ func NewC2() *C2 { return &C2{abi: *parsed} } +// ABI returns the parsed ABI of the contract. The returned value shares +// its internal maps (Methods, Events, Errors) with the binding, so callers +// must not mutate it. +func (c *C2) ABI() abi.ABI { + return c.abi +} + // Instance creates a wrapper for a deployed contract instance at the given address. // Use this to create the instance object passed to abigen v2 library functions Call, Transact, etc. func (c *C2) Instance(backend bind.ContractBackend, addr common.Address) *bind.BoundContract { diff --git a/accounts/abi/bind/v2/internal/contracts/uint256arrayreturn/bindings.go b/accounts/abi/bind/v2/internal/contracts/uint256arrayreturn/bindings.go index 19d09bdd6a..cf04629e75 100644 --- a/accounts/abi/bind/v2/internal/contracts/uint256arrayreturn/bindings.go +++ b/accounts/abi/bind/v2/internal/contracts/uint256arrayreturn/bindings.go @@ -45,6 +45,13 @@ func NewMyContract() *MyContract { return &MyContract{abi: *parsed} } +// ABI returns the parsed ABI of the contract. The returned value shares +// its internal maps (Methods, Events, Errors) with the binding, so callers +// must not mutate it. +func (c *MyContract) ABI() abi.ABI { + return c.abi +} + // Instance creates a wrapper for a deployed contract instance at the given address. // Use this to create the instance object passed to abigen v2 library functions Call, Transact, etc. func (c *MyContract) Instance(backend bind.ContractBackend, addr common.Address) *bind.BoundContract {