From a5e921a752dc3063bb1fad869ffc3ef350412b44 Mon Sep 17 00:00:00 2001 From: Bartek Tofel Date: Thu, 12 Sep 2024 10:45:41 +0200 Subject: [PATCH] add functional options that allow to set 'from' and 'signerFn' fields on transaction options (#1131) --- seth/client.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/seth/client.go b/seth/client.go index fca6debd3..febfdb0c6 100644 --- a/seth/client.go +++ b/seth/client.go @@ -648,6 +648,20 @@ func WithGasTipCap(gasTipCap *big.Int) TransactOpt { } } +// WithSignerFn sets signerFn option for bind.TransactOpts +func WithSignerFn(signerFn bind.SignerFn) TransactOpt { + return func(o *bind.TransactOpts) { + o.Signer = signerFn + } +} + +// WithFrom sets from option for bind.TransactOpts +func WithFrom(fromAddress common.Address) TransactOpt { + return func(o *bind.TransactOpts) { + o.From = fromAddress + } +} + type ContextErrorKey struct{} // NewTXOpts returns a new transaction options wrapper,