mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-28 07:36:44 +00:00
misc template additions I forgot to include in previous commits. introduce 'RawDeploymentTransact' method
This commit is contained in:
parent
f70344216e
commit
1dd531a2ba
7 changed files with 20 additions and 21 deletions
|
|
@ -257,19 +257,19 @@ func (c *BoundContract) Transact(opts *TransactOpts, method string, params ...in
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// todo(rjl493456442) check whether the method is payable or not,
|
||||
// reject invalid transaction at the first place
|
||||
return c.transact(opts, &c.address, input)
|
||||
}
|
||||
|
||||
// RawTransact initiates a transaction with the given raw calldata as the input.
|
||||
// It's usually used to initiate transactions for invoking **Fallback** function.
|
||||
func (c *BoundContract) RawTransact(opts *TransactOpts, calldata []byte) (*types.Transaction, error) {
|
||||
// todo(rjl493456442) check whether the method is payable or not,
|
||||
// reject invalid transaction at the first place
|
||||
return c.transact(opts, &c.address, calldata)
|
||||
}
|
||||
|
||||
func (c *BoundContract) RawCreationTransact(opts *TransactOpts, calldata []byte) (*types.Transaction, error) {
|
||||
return c.transact(opts, nil, calldata)
|
||||
}
|
||||
|
||||
// Transfer initiates a plain transaction to move funds to the contract, calling
|
||||
// its default method if one is available.
|
||||
func (c *BoundContract) Transfer(opts *TransactOpts) (*types.Transaction, error) {
|
||||
|
|
|
|||
|
|
@ -122,8 +122,8 @@ func (d *depTreeDeployer) result() *DeploymentResult {
|
|||
// libraries. If an error occurs, only contracts which were successfully
|
||||
// deployed are returned in the result.
|
||||
func LinkAndDeploy(deployParams *DeploymentParams, deploy DeployFn) (res *DeploymentResult, err error) {
|
||||
//deployParams.inputs = make(map[string][]byte)
|
||||
deployer := newDepTreeDeployer(deployParams, deploy)
|
||||
deployParams.inputs = make(map[string][]byte)
|
||||
for _, contract := range deployParams.contracts {
|
||||
if _, err := deployer.linkAndDeploy(contract); err != nil {
|
||||
return deployer.result(), err
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ var (
|
|||
}
|
||||
{{range $i, $t := .Normalized.Outputs}}
|
||||
{{if ispointertype .Type}}
|
||||
outstruct.{{.Name}} = abi.ConvertType(out[{{$i}}], new({{underlyingbindtype .Type }})).({{underlyingbindtype .Type }})
|
||||
outstruct.{{.Name}} = abi.ConvertType(out[{{$i}}], new({{underlyingbindtype .Type }})).({{bindtype .Type $structs}})
|
||||
{{ else }}
|
||||
outstruct.{{.Name}} = *abi.ConvertType(out[{{$i}}], new({{bindtype .Type $structs}})).(*{{bindtype .Type $structs}})
|
||||
{{ end }}{{end}}
|
||||
|
|
@ -183,7 +183,7 @@ var (
|
|||
func ({{ decapitalise $contract.Type}} *{{$contract.Type}}) Unpack{{.Normalized.Name}}Error(raw []byte) (*{{$contract.Type}}{{.Normalized.Name}}, error) {
|
||||
errName := "{{.Normalized.Name}}"
|
||||
out := new({{$contract.Type}}{{.Normalized.Name}})
|
||||
if err := _{{$contract.Type}}.abi.UnpackIntoInterface(out, errName, raw); err != nil {
|
||||
if err := {{ decapitalise $contract.Type}}.abi.UnpackIntoInterface(out, errName, raw); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
|
|
|
|||
|
|
@ -98,11 +98,11 @@ func (dB *DB) UnpackGetNamedStatParams(data []byte) (GetNamedStatParamsOutput, e
|
|||
return *outstruct, err
|
||||
}
|
||||
|
||||
outstruct.Gets = abi.ConvertType(out[0], new(big.Int)).(big.Int)
|
||||
outstruct.Gets = abi.ConvertType(out[0], new(big.Int)).(*big.Int)
|
||||
|
||||
outstruct.Inserts = abi.ConvertType(out[1], new(big.Int)).(big.Int)
|
||||
outstruct.Inserts = abi.ConvertType(out[1], new(big.Int)).(*big.Int)
|
||||
|
||||
outstruct.Mods = abi.ConvertType(out[2], new(big.Int)).(big.Int)
|
||||
outstruct.Mods = abi.ConvertType(out[2], new(big.Int)).(*big.Int)
|
||||
|
||||
return *outstruct, err
|
||||
|
||||
|
|
@ -129,11 +129,11 @@ func (dB *DB) UnpackGetStatParams(data []byte) (GetStatParamsOutput, error) {
|
|||
return *outstruct, err
|
||||
}
|
||||
|
||||
outstruct.Arg0 = abi.ConvertType(out[0], new(big.Int)).(big.Int)
|
||||
outstruct.Arg0 = abi.ConvertType(out[0], new(big.Int)).(*big.Int)
|
||||
|
||||
outstruct.Arg1 = abi.ConvertType(out[1], new(big.Int)).(big.Int)
|
||||
outstruct.Arg1 = abi.ConvertType(out[1], new(big.Int)).(*big.Int)
|
||||
|
||||
outstruct.Arg2 = abi.ConvertType(out[2], new(big.Int)).(big.Int)
|
||||
outstruct.Arg2 = abi.ConvertType(out[2], new(big.Int)).(*big.Int)
|
||||
|
||||
return *outstruct, err
|
||||
|
||||
|
|
|
|||
|
|
@ -78,11 +78,11 @@ func (c *C) UnpackDoSomethingWithManyArgs(data []byte) (DoSomethingWithManyArgsO
|
|||
return *outstruct, err
|
||||
}
|
||||
|
||||
outstruct.Arg0 = abi.ConvertType(out[0], new(big.Int)).(big.Int)
|
||||
outstruct.Arg0 = abi.ConvertType(out[0], new(big.Int)).(*big.Int)
|
||||
|
||||
outstruct.Arg1 = abi.ConvertType(out[1], new(big.Int)).(big.Int)
|
||||
outstruct.Arg1 = abi.ConvertType(out[1], new(big.Int)).(*big.Int)
|
||||
|
||||
outstruct.Arg2 = abi.ConvertType(out[2], new(big.Int)).(big.Int)
|
||||
outstruct.Arg2 = abi.ConvertType(out[2], new(big.Int)).(*big.Int)
|
||||
|
||||
outstruct.Arg3 = *abi.ConvertType(out[3], new(bool)).(*bool)
|
||||
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ func CBadThingErrorID() common.Hash {
|
|||
func (c *C) UnpackBadThingError(raw []byte) (*CBadThing, error) {
|
||||
errName := "BadThing"
|
||||
out := new(CBadThing)
|
||||
if err := _C.abi.UnpackIntoInterface(out, errName, raw); err != nil {
|
||||
if err := c.abi.UnpackIntoInterface(out, errName, raw); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
|
|
@ -112,7 +112,7 @@ func CBadThing2ErrorID() common.Hash {
|
|||
func (c *C) UnpackBadThing2Error(raw []byte) (*CBadThing2, error) {
|
||||
errName := "BadThing2"
|
||||
out := new(CBadThing2)
|
||||
if err := _C.abi.UnpackIntoInterface(out, errName, raw); err != nil {
|
||||
if err := c.abi.UnpackIntoInterface(out, errName, raw); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
|
|
@ -176,7 +176,7 @@ func C2BadThingErrorID() common.Hash {
|
|||
func (c2 *C2) UnpackBadThingError(raw []byte) (*C2BadThing, error) {
|
||||
errName := "BadThing"
|
||||
out := new(C2BadThing)
|
||||
if err := _C2.abi.UnpackIntoInterface(out, errName, raw); err != nil {
|
||||
if err := c2.abi.UnpackIntoInterface(out, errName, raw); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
|
|
|
|||
|
|
@ -182,8 +182,7 @@ func Call[T any](instance *ContractInstance, opts *bind.CallOpts, packedInput []
|
|||
// 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...))
|
||||
tx, err := c.RawCreationTransact(opts, append(bytecode, packedParams...))
|
||||
if err != nil {
|
||||
return common.Address{}, nil, nil, err
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue