From 780f809f3217e3755061da3ac53261e4357882dc Mon Sep 17 00:00:00 2001 From: Martin Date: Fri, 5 Mar 2021 23:56:19 -0500 Subject: [PATCH 1/3] abi/bind: add an option to dry run a transaction --- accounts/abi/bind/base.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/accounts/abi/bind/base.go b/accounts/abi/bind/base.go index f5a6fe22fc24..a955205c0fc7 100644 --- a/accounts/abi/bind/base.go +++ b/accounts/abi/bind/base.go @@ -54,6 +54,8 @@ type TransactOpts struct { GasLimit uint64 // Gas limit to set for the transaction execution (0 = estimate) Context context.Context // Network context to support cancellation and timeouts (nil = no timeout) + + DryRun bool // Do all transact steps but do not send the transaction } // FilterOpts is the collection of options to fine tune filtering for events @@ -260,6 +262,10 @@ func (c *BoundContract) transact(opts *TransactOpts, contract *common.Address, i if err != nil { return nil, err } + if opts.DryRun { + fmt.Println ( "dryrun") + return signedTx, nil + } if err := c.transactor.SendTransaction(ensureContext(opts.Context), signedTx); err != nil { return nil, err } From 4d8f6360410cf23043724a0afc22a6baee6c4a19 Mon Sep 17 00:00:00 2001 From: Martin Date: Sat, 6 Mar 2021 00:16:34 -0500 Subject: [PATCH 2/3] abi/bind: add an option to dry run a transaction removed Println --- accounts/abi/bind/base.go | 1 - 1 file changed, 1 deletion(-) diff --git a/accounts/abi/bind/base.go b/accounts/abi/bind/base.go index a955205c0fc7..8b6733a3c426 100644 --- a/accounts/abi/bind/base.go +++ b/accounts/abi/bind/base.go @@ -263,7 +263,6 @@ func (c *BoundContract) transact(opts *TransactOpts, contract *common.Address, i return nil, err } if opts.DryRun { - fmt.Println ( "dryrun") return signedTx, nil } if err := c.transactor.SendTransaction(ensureContext(opts.Context), signedTx); err != nil { From 6cace71efbd2a0051c1f858f5c463e7c7e920f42 Mon Sep 17 00:00:00 2001 From: Martin Date: Tue, 9 Mar 2021 14:47:28 -0500 Subject: [PATCH 3/3] abi/bind: add an option to dry run a transaction change option name: DryRun -> NoSend, a better description --- accounts/abi/bind/base.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/accounts/abi/bind/base.go b/accounts/abi/bind/base.go index 8b6733a3c426..55aca31a1a46 100644 --- a/accounts/abi/bind/base.go +++ b/accounts/abi/bind/base.go @@ -55,7 +55,7 @@ type TransactOpts struct { Context context.Context // Network context to support cancellation and timeouts (nil = no timeout) - DryRun bool // Do all transact steps but do not send the transaction + NoSend bool // Do all transact steps but do not send the transaction } // FilterOpts is the collection of options to fine tune filtering for events @@ -262,7 +262,7 @@ func (c *BoundContract) transact(opts *TransactOpts, contract *common.Address, i if err != nil { return nil, err } - if opts.DryRun { + if opts.NoSend { return signedTx, nil } if err := c.transactor.SendTransaction(ensureContext(opts.Context), signedTx); err != nil {