mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-28 07:36:44 +00:00
accounts/abi/bind, accounts/abi/bind/v2: move DeployContractRaw into v2 package
This commit is contained in:
parent
9b453b04fe
commit
b896ed2966
3 changed files with 16 additions and 15 deletions
|
|
@ -153,20 +153,6 @@ func DeployContract(opts *TransactOpts, abi abi.ABI, bytecode []byte, backend Co
|
|||
return c.address, tx, c, nil
|
||||
}
|
||||
|
||||
// DeployContractRaw 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.
|
||||
func DeployContractRaw(opts *TransactOpts, bytecode []byte, backend ContractBackend, packedParams []byte) (common.Address, *types.Transaction, *BoundContract, error) {
|
||||
c := NewBoundContract(common.Address{}, abi.ABI{}, backend, backend, backend)
|
||||
|
||||
tx, err := c.transact(opts, nil, append(bytecode, packedParams...))
|
||||
if err != nil {
|
||||
return common.Address{}, nil, nil, err
|
||||
}
|
||||
c.address = crypto.CreateAddress(opts.From, tx.Nonce())
|
||||
return c.address, tx, c, nil
|
||||
}
|
||||
|
||||
// Call invokes the (constant) contract method with params as input values and
|
||||
// sets the output to result. The result type might be a single field for simple
|
||||
// returns, a slice of interfaces for anonymous returns and a struct for named
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import (
|
|||
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/ethereum/go-ethereum/event"
|
||||
)
|
||||
|
||||
|
|
@ -175,3 +176,17 @@ func Call[T any](instance *ContractInstance, opts *bind.CallOpts, packedInput []
|
|||
}
|
||||
return unpack(packedOutput)
|
||||
}
|
||||
|
||||
// DeployContractRaw 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.
|
||||
func DeployContractRaw(opts *bind.TransactOpts, bytecode []byte, backend bind.ContractBackend, packedParams []byte) (common.Address, *types.Transaction, *bind.BoundContract, error) {
|
||||
c := bind.NewBoundContract(common.Address{}, abi.ABI{}, backend, backend, backend)
|
||||
|
||||
tx, err := c.RawTransact(opts, append(bytecode, packedParams...))
|
||||
if err != nil {
|
||||
return common.Address{}, nil, nil, err
|
||||
}
|
||||
address := crypto.CreateAddress(opts.From, tx.Nonce())
|
||||
return address, tx, c, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ func testSetup() (*bind.TransactOpts, *backends.SimulatedBackend, error) {
|
|||
|
||||
func makeTestDeployer(auth *bind.TransactOpts, backend bind.ContractBackend) func(input, deployer []byte) (common.Address, *types.Transaction, error) {
|
||||
return func(input, deployer []byte) (common.Address, *types.Transaction, error) {
|
||||
addr, tx, _, err := bind.DeployContractRaw(auth, deployer, backend, input)
|
||||
addr, tx, _, err := DeployContractRaw(auth, deployer, backend, input)
|
||||
return addr, tx, err
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue