accounts/abi/bind/v2: add Transact utility method for v2. There is already an identical Transact member method on the BoundContract struct. I just add this one to ensure that user code which performs transactions doesn't have to use both the v1 BoundContract methods and the utility methods provided in v2/lib.go

This commit is contained in:
Jared Wasinger 2025-02-06 15:02:14 -08:00
parent a3b95f014c
commit 2241fbb5f4
2 changed files with 7 additions and 1 deletions

View file

@ -175,6 +175,12 @@ func Call[T any](c *BoundContract, opts *CallOpts, packedInput []byte, unpack fu
return res, err
}
// Transact initiates a transaction with the given raw calldata as the input.
func Transact(c *BoundContract, opt *TransactOpts, packedInput []byte) (*types.Transaction, error) {
addr := c.address
return c.transact(opt, &addr, packedInput)
}
// DeployContract deploys a contract onto the Ethereum blockchain and binds the
// deployment address with a Go wrapper. It expects its parameters to be abi-encoded
// bytes.

View file

@ -236,7 +236,7 @@ func TestEvents(t *testing.T) {
defer sub2.Unsubscribe()
packedInput := c.PackEmitMulti()
tx, err := instance.RawTransact(defaultTxAuth(), packedInput)
tx, err := bind.Transact(instance, defaultTxAuth(), packedInput)
if err != nil {
t.Fatalf("failed to send transaction: %v", err)
}