1414// You should have received a copy of the GNU Lesser General Public License
1515// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
1616
17- package v2
17+ package bind
1818
1919import (
2020 "context"
@@ -27,12 +27,12 @@ import (
2727 "testing"
2828 "time"
2929
30+ bind1 "github.com/ethereum/go-ethereum/accounts/abi/bind"
3031 "github.com/ethereum/go-ethereum/accounts/abi/bind/v2/internal/contracts/events"
3132 "github.com/ethereum/go-ethereum/accounts/abi/bind/v2/internal/contracts/nested_libraries"
3233 "github.com/ethereum/go-ethereum/accounts/abi/bind/v2/internal/contracts/solc_errors"
3334
3435 "github.com/ethereum/go-ethereum/accounts/abi"
35- "github.com/ethereum/go-ethereum/accounts/abi/bind"
3636 "github.com/ethereum/go-ethereum/accounts/abi/bind/backends"
3737 "github.com/ethereum/go-ethereum/cmd/utils"
3838 "github.com/ethereum/go-ethereum/common"
@@ -59,7 +59,7 @@ func JSON(reader io.Reader) (abi.ABI, error) {
5959 return instance , nil
6060}
6161
62- func testSetup () (* bind. TransactOpts , * backends.SimulatedBackend , error ) {
62+ func testSetup () (* TransactOpts , * backends.SimulatedBackend , error ) {
6363 testAddr := crypto .PubkeyToAddress (testKey .PublicKey )
6464 backend := simulated .NewBackend (
6565 types.GenesisAlloc {
@@ -71,7 +71,7 @@ func testSetup() (*bind.TransactOpts, *backends.SimulatedBackend, error) {
7171 )
7272
7373 signer := types .LatestSigner (params .AllDevChainProtocolChanges )
74- opts := & bind. TransactOpts {
74+ opts := & TransactOpts {
7575 From : testAddr ,
7676 Nonce : nil ,
7777 Signer : func (address common.Address , tx * types.Transaction ) (* types.Transaction , error ) {
@@ -97,7 +97,7 @@ func testSetup() (*bind.TransactOpts, *backends.SimulatedBackend, error) {
9797 return opts , & bindBackend , nil
9898}
9999
100- func makeTestDeployer (auth * bind. TransactOpts , backend bind. ContractBackend ) func (input , deployer []byte ) (common.Address , * types.Transaction , error ) {
100+ func makeTestDeployer (auth * TransactOpts , backend ContractBackend ) func (input , deployer []byte ) (common.Address , * types.Transaction , error ) {
101101 return func (input , deployer []byte ) (common.Address , * types.Transaction , error ) {
102102 addr , tx , _ , err := DeployContractRaw (auth , deployer , backend , input )
103103 return addr , tx , err
@@ -119,9 +119,9 @@ func TestDeploymentLibraries(t *testing.T) {
119119 }
120120
121121 constructorInput := ctrct .PackConstructor (big .NewInt (42 ), big .NewInt (1 ))
122- deploymentParams := bind .NewDeploymentParams ([]* bind. MetaData {& nested_libraries .C1MetaData }, map [string ][]byte {nested_libraries .C1MetaData .Pattern : constructorInput }, nil )
122+ deploymentParams := bind1 .NewDeploymentParams ([]* MetaData {& nested_libraries .C1MetaData }, map [string ][]byte {nested_libraries .C1MetaData .Pattern : constructorInput }, nil )
123123
124- res , err := bind .LinkAndDeploy (deploymentParams , makeTestDeployer (opts , bindBackend ))
124+ res , err := bind1 .LinkAndDeploy (deploymentParams , makeTestDeployer (opts , bindBackend ))
125125 if err != nil {
126126 t .Fatalf ("err: %+v\n " , err )
127127 }
@@ -131,7 +131,7 @@ func TestDeploymentLibraries(t *testing.T) {
131131 t .Fatalf ("deployment should have generated 5 addresses. got %d" , len (res .Addrs ))
132132 }
133133 for _ , tx := range res .Txs {
134- _ , err = bind .WaitDeployed (context .Background (), bindBackend , tx )
134+ _ , err = bind1 .WaitDeployed (context .Background (), bindBackend , tx )
135135 if err != nil {
136136 t .Fatalf ("error deploying library: %+v" , err )
137137 }
@@ -146,7 +146,7 @@ func TestDeploymentLibraries(t *testing.T) {
146146 }
147147
148148 contractAddr := res .Addrs [nested_libraries .C1MetaData .Pattern ]
149- callOpts := & bind. CallOpts {
149+ callOpts := & CallOpts {
150150 From : common.Address {},
151151 Context : context .Background (),
152152 }
@@ -174,9 +174,9 @@ func TestDeploymentWithOverrides(t *testing.T) {
174174 defer bindBackend .Backend .Close ()
175175
176176 // deploy all the library dependencies of our target contract, but not the target contract itself.
177- deploymentParams := bind .NewDeploymentParams (nested_libraries .C1MetaData .Deps , nil , nil )
177+ deploymentParams := bind1 .NewDeploymentParams (nested_libraries .C1MetaData .Deps , nil , nil )
178178
179- res , err := bind .LinkAndDeploy (deploymentParams , makeTestDeployer (opts , bindBackend ))
179+ res , err := bind1 .LinkAndDeploy (deploymentParams , makeTestDeployer (opts , bindBackend ))
180180 if err != nil {
181181 t .Fatalf ("err: %+v\n " , err )
182182 }
@@ -186,7 +186,7 @@ func TestDeploymentWithOverrides(t *testing.T) {
186186 t .Fatalf ("deployment should have generated 4 addresses. got %d" , len (res .Addrs ))
187187 }
188188 for _ , tx := range res .Txs {
189- _ , err = bind .WaitDeployed (context .Background (), bindBackend , tx )
189+ _ , err = bind1 .WaitDeployed (context .Background (), bindBackend , tx )
190190 if err != nil {
191191 t .Fatalf ("error deploying library: %+v" , err )
192192 }
@@ -199,8 +199,8 @@ func TestDeploymentWithOverrides(t *testing.T) {
199199 constructorInput := ctrct .PackConstructor (big .NewInt (42 ), big .NewInt (1 ))
200200 overrides := res .Addrs
201201 // deploy the contract
202- deploymentParams = bind .NewDeploymentParams ([]* bind. MetaData {& nested_libraries .C1MetaData }, map [string ][]byte {nested_libraries .C1MetaData .Pattern : constructorInput }, overrides )
203- res , err = bind .LinkAndDeploy (deploymentParams , makeTestDeployer (opts , bindBackend ))
202+ deploymentParams = bind1 .NewDeploymentParams ([]* MetaData {& nested_libraries .C1MetaData }, map [string ][]byte {nested_libraries .C1MetaData .Pattern : constructorInput }, overrides )
203+ res , err = bind1 .LinkAndDeploy (deploymentParams , makeTestDeployer (opts , bindBackend ))
204204 if err != nil {
205205 t .Fatalf ("err: %+v\n " , err )
206206 }
@@ -210,7 +210,7 @@ func TestDeploymentWithOverrides(t *testing.T) {
210210 t .Fatalf ("deployment should have generated 1 address. got %d" , len (res .Addrs ))
211211 }
212212 for _ , tx := range res .Txs {
213- _ , err = bind .WaitDeployed (context .Background (), bindBackend , tx )
213+ _ , err = bind1 .WaitDeployed (context .Background (), bindBackend , tx )
214214 if err != nil {
215215 t .Fatalf ("error deploying library: %+v" , err )
216216 }
@@ -231,8 +231,8 @@ func TestDeploymentWithOverrides(t *testing.T) {
231231 t .Fatalf ("error getting abi object: %v" , err )
232232 }
233233 contractAddr := res .Addrs [nested_libraries .C1MetaData .Pattern ]
234- boundContract := bind .NewBoundContract (contractAddr , * cABI , bindBackend , bindBackend , bindBackend )
235- callOpts := & bind. CallOpts {
234+ boundContract := bind1 .NewBoundContract (contractAddr , * cABI , bindBackend , bindBackend , bindBackend )
235+ callOpts := & CallOpts {
236236 From : common.Address {},
237237 Context : context .Background (),
238238 }
@@ -256,14 +256,14 @@ func TestEvents(t *testing.T) {
256256 t .Fatalf ("error setting up testing env: %v" , err )
257257 }
258258
259- deploymentParams := bind .NewDeploymentParams ([]* bind. MetaData {& events .CMetaData }, nil , nil )
260- res , err := bind .LinkAndDeploy (deploymentParams , makeTestDeployer (txAuth , backend ))
259+ deploymentParams := bind1 .NewDeploymentParams ([]* MetaData {& events .CMetaData }, nil , nil )
260+ res , err := bind1 .LinkAndDeploy (deploymentParams , makeTestDeployer (txAuth , backend ))
261261 if err != nil {
262262 t .Fatalf ("error deploying contract for testing: %v" , err )
263263 }
264264
265265 backend .Commit ()
266- if _ , err := bind .WaitDeployed (context .Background (), backend , res .Txs [events .CMetaData .Pattern ]); err != nil {
266+ if _ , err := bind1 .WaitDeployed (context .Background (), backend , res .Txs [events .CMetaData .Pattern ]); err != nil {
267267 t .Fatalf ("WaitDeployed failed %v" , err )
268268 }
269269
@@ -281,7 +281,7 @@ func TestEvents(t *testing.T) {
281281
282282 newCBasic1Ch := make (chan * events.CBasic1 )
283283 newCBasic2Ch := make (chan * events.CBasic2 )
284- watchOpts := & bind .WatchOpts {
284+ watchOpts := & bind1 .WatchOpts {
285285 Start : nil ,
286286 Context : context .Background (),
287287 }
@@ -302,7 +302,7 @@ func TestEvents(t *testing.T) {
302302 t .Fatalf ("failed to send transaction: %v" , err )
303303 }
304304 backend .Commit ()
305- if _ , err := bind .WaitMined (context .Background (), backend , tx ); err != nil {
305+ if _ , err := bind1 .WaitMined (context .Background (), backend , tx ); err != nil {
306306 t .Fatalf ("error waiting for tx to be mined: %v" , err )
307307 }
308308
@@ -332,7 +332,7 @@ done:
332332
333333 // now, test that we can filter those same logs after they were included in the chain
334334
335- filterOpts := & bind. FilterOpts {
335+ filterOpts := & FilterOpts {
336336 Start : 0 ,
337337 Context : context .Background (),
338338 }
@@ -367,21 +367,21 @@ func TestErrors(t *testing.T) {
367367 t .Fatalf ("error setting up testing env: %v" , err )
368368 }
369369
370- deploymentParams := bind .NewDeploymentParams ([]* bind. MetaData {& solc_errors .CMetaData }, nil , nil )
371- res , err := bind .LinkAndDeploy (deploymentParams , makeTestDeployer (txAuth , backend ))
370+ deploymentParams := bind1 .NewDeploymentParams ([]* MetaData {& solc_errors .CMetaData }, nil , nil )
371+ res , err := bind1 .LinkAndDeploy (deploymentParams , makeTestDeployer (txAuth , backend ))
372372 if err != nil {
373373 t .Fatalf ("error deploying contract for testing: %v" , err )
374374 }
375375
376376 backend .Commit ()
377- if _ , err := bind .WaitDeployed (context .Background (), backend , res .Txs [solc_errors .CMetaData .Pattern ]); err != nil {
377+ if _ , err := bind1 .WaitDeployed (context .Background (), backend , res .Txs [solc_errors .CMetaData .Pattern ]); err != nil {
378378 t .Fatalf ("WaitDeployed failed %v" , err )
379379 }
380380
381381 ctrct , _ := solc_errors .NewC ()
382382
383383 var packedInput []byte
384- opts := & bind. CallOpts {
384+ opts := & CallOpts {
385385 From : res .Addrs [solc_errors .CMetaData .Pattern ],
386386 }
387387 packedInput , _ = ctrct .PackFoo ()
@@ -467,7 +467,7 @@ func TestBindingGeneration(t *testing.T) {
467467 libPattern := crypto .Keccak256Hash ([]byte (name )).String ()[2 :36 ] // the first 2 chars are 0x
468468 libs [libPattern ] = typeName
469469 }
470- code , err := bind .BindV2 (types , abis , bins , dir , libs , make (map [string ]string ))
470+ code , err := bind1 .BindV2 (types , abis , bins , dir , libs , make (map [string ]string ))
471471 if err != nil {
472472 t .Fatalf ("error creating bindings for package %s: %v" , dir , err )
473473 }
0 commit comments