mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-11 22:43:47 +00:00
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:
parent
a3b95f014c
commit
2241fbb5f4
2 changed files with 7 additions and 1 deletions
|
|
@ -175,6 +175,12 @@ func Call[T any](c *BoundContract, opts *CallOpts, packedInput []byte, unpack fu
|
||||||
return res, err
|
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
|
// 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
|
// deployment address with a Go wrapper. It expects its parameters to be abi-encoded
|
||||||
// bytes.
|
// bytes.
|
||||||
|
|
|
||||||
|
|
@ -236,7 +236,7 @@ func TestEvents(t *testing.T) {
|
||||||
defer sub2.Unsubscribe()
|
defer sub2.Unsubscribe()
|
||||||
|
|
||||||
packedInput := c.PackEmitMulti()
|
packedInput := c.PackEmitMulti()
|
||||||
tx, err := instance.RawTransact(defaultTxAuth(), packedInput)
|
tx, err := bind.Transact(instance, defaultTxAuth(), packedInput)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to send transaction: %v", err)
|
t.Fatalf("failed to send transaction: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue