Add deploy code to contract struct

This commit is contained in:
Sina Mahmoodi 2023-03-02 15:50:26 +03:30 committed by Felix Lange
parent e2746e7f54
commit f7084f4723
1 changed files with 15 additions and 10 deletions

View File

@ -52,11 +52,6 @@ var (
{{end}}
}
// {{.Type}} is an auto generated Go binding around an Ethereum contract.
type {{.Type}} struct {
abi abi.ABI
}
// {{.Type}}Instance represents a deployed instance of the {{.Type}} contract.
type {{.Type}}Instance struct {
{{.Type}}
@ -76,14 +71,24 @@ var (
return i.backend
}
// {{.Type}} is an auto generated Go binding around an Ethereum contract.
type {{.Type}} struct {
abi abi.ABI
deployCode []byte
}
// New{{.Type}} creates a new instance of {{.Type}}.
func New{{.Type}}() (*{{.Type}}, error) {
parsed, err := {{.Type}}MetaData.GetAbi()
if err != nil {
return nil, err
}
parsed, err := {{.Type}}MetaData.GetAbi()
if err != nil {
return nil, err
}
code := common.Hex2Bytes({{.Type}}MetaData.Bin)
return &{{.Type}}{abi: *parsed, deployCode: code}, nil
}
return &{{.Type}}{abi: *parsed}, nil
func (_{{$contract.Type}} *{{$contract.Type}}) DeployCode() []byte {
return _{{$contract.Type}}.deployCode
}
func (_{{$contract.Type}} *{{$contract.Type}}) PackConstructor({{range .Constructor.Inputs}}, {{.Name}} {{bindtype .Type $structs}} {{end}}) ([]byte, error) {