|
|
@ -90,6 +90,7 @@ package {{.Package}} |
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"math/big" |
|
|
|
"math/big" |
|
|
|
"strings" |
|
|
|
"strings" |
|
|
|
|
|
|
|
"errors" |
|
|
|
|
|
|
|
|
|
|
|
ethereum "github.com/ethereum/go-ethereum" |
|
|
|
ethereum "github.com/ethereum/go-ethereum" |
|
|
|
"github.com/ethereum/go-ethereum/accounts/abi" |
|
|
|
"github.com/ethereum/go-ethereum/accounts/abi" |
|
|
@ -101,6 +102,7 @@ import ( |
|
|
|
|
|
|
|
|
|
|
|
// Reference imports to suppress errors if they are not otherwise used.
|
|
|
|
// Reference imports to suppress errors if they are not otherwise used.
|
|
|
|
var ( |
|
|
|
var ( |
|
|
|
|
|
|
|
_ = errors.New |
|
|
|
_ = big.NewInt |
|
|
|
_ = big.NewInt |
|
|
|
_ = strings.NewReader |
|
|
|
_ = strings.NewReader |
|
|
|
_ = ethereum.NotFound |
|
|
|
_ = ethereum.NotFound |
|
|
@ -120,32 +122,48 @@ var ( |
|
|
|
{{end}} |
|
|
|
{{end}} |
|
|
|
|
|
|
|
|
|
|
|
{{range $contract := .Contracts}} |
|
|
|
{{range $contract := .Contracts}} |
|
|
|
|
|
|
|
// {{.Type}}MetaData contains all meta data concerning the {{.Type}} contract.
|
|
|
|
|
|
|
|
var {{.Type}}MetaData = &bind.MetaData{ |
|
|
|
|
|
|
|
ABI: "{{.InputABI}}", |
|
|
|
|
|
|
|
{{if $contract.FuncSigs -}} |
|
|
|
|
|
|
|
Sigs: map[string]string{ |
|
|
|
|
|
|
|
{{range $strsig, $binsig := .FuncSigs}}"{{$binsig}}": "{{$strsig}}", |
|
|
|
|
|
|
|
{{end}} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{{end -}} |
|
|
|
|
|
|
|
{{if .InputBin -}} |
|
|
|
|
|
|
|
Bin: "0x{{.InputBin}}", |
|
|
|
|
|
|
|
{{end}} |
|
|
|
|
|
|
|
} |
|
|
|
// {{.Type}}ABI is the input ABI used to generate the binding from.
|
|
|
|
// {{.Type}}ABI is the input ABI used to generate the binding from.
|
|
|
|
const {{.Type}}ABI = "{{.InputABI}}" |
|
|
|
// Deprecated: Use {{.Type}}MetaData.ABI instead.
|
|
|
|
|
|
|
|
var {{.Type}}ABI = {{.Type}}MetaData.ABI |
|
|
|
|
|
|
|
|
|
|
|
{{if $contract.FuncSigs}} |
|
|
|
{{if $contract.FuncSigs}} |
|
|
|
|
|
|
|
// Deprecated: Use {{.Type}}MetaData.Sigs instead.
|
|
|
|
// {{.Type}}FuncSigs maps the 4-byte function signature to its string representation.
|
|
|
|
// {{.Type}}FuncSigs maps the 4-byte function signature to its string representation.
|
|
|
|
var {{.Type}}FuncSigs = map[string]string{ |
|
|
|
var {{.Type}}FuncSigs = {{.Type}}MetaData.Sigs |
|
|
|
{{range $strsig, $binsig := .FuncSigs}}"{{$binsig}}": "{{$strsig}}", |
|
|
|
|
|
|
|
{{end}} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
{{end}} |
|
|
|
{{end}} |
|
|
|
|
|
|
|
|
|
|
|
{{if .InputBin}} |
|
|
|
{{if .InputBin}} |
|
|
|
// {{.Type}}Bin is the compiled bytecode used for deploying new contracts.
|
|
|
|
// {{.Type}}Bin is the compiled bytecode used for deploying new contracts.
|
|
|
|
var {{.Type}}Bin = "0x{{.InputBin}}" |
|
|
|
// Deprecated: Use {{.Type}}MetaData.Bin instead.
|
|
|
|
|
|
|
|
var {{.Type}}Bin = {{.Type}}MetaData.Bin |
|
|
|
|
|
|
|
|
|
|
|
// Deploy{{.Type}} deploys a new Ethereum contract, binding an instance of {{.Type}} to it.
|
|
|
|
// Deploy{{.Type}} deploys a new Ethereum contract, binding an instance of {{.Type}} to it.
|
|
|
|
func Deploy{{.Type}}(auth *bind.TransactOpts, backend bind.ContractBackend {{range .Constructor.Inputs}}, {{.Name}} {{bindtype .Type $structs}}{{end}}) (common.Address, *types.Transaction, *{{.Type}}, error) { |
|
|
|
func Deploy{{.Type}}(auth *bind.TransactOpts, backend bind.ContractBackend {{range .Constructor.Inputs}}, {{.Name}} {{bindtype .Type $structs}}{{end}}) (common.Address, *types.Transaction, *{{.Type}}, error) { |
|
|
|
parsed, err := abi.JSON(strings.NewReader({{.Type}}ABI)) |
|
|
|
parsed, err := {{.Type}}MetaData.GetAbi() |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return common.Address{}, nil, nil, err |
|
|
|
return common.Address{}, nil, nil, err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if parsed == nil { |
|
|
|
|
|
|
|
return common.Address{}, nil, nil, errors.New("GetABI returned nil") |
|
|
|
|
|
|
|
} |
|
|
|
{{range $pattern, $name := .Libraries}} |
|
|
|
{{range $pattern, $name := .Libraries}} |
|
|
|
{{decapitalise $name}}Addr, _, _, _ := Deploy{{capitalise $name}}(auth, backend) |
|
|
|
{{decapitalise $name}}Addr, _, _, _ := Deploy{{capitalise $name}}(auth, backend) |
|
|
|
{{$contract.Type}}Bin = strings.Replace({{$contract.Type}}Bin, "__${{$pattern}}$__", {{decapitalise $name}}Addr.String()[2:], -1) |
|
|
|
{{$contract.Type}}Bin = strings.Replace({{$contract.Type}}Bin, "__${{$pattern}}$__", {{decapitalise $name}}Addr.String()[2:], -1) |
|
|
|
{{end}} |
|
|
|
{{end}} |
|
|
|
address, tx, contract, err := bind.DeployContract(auth, parsed, common.FromHex({{.Type}}Bin), backend {{range .Constructor.Inputs}}, {{.Name}}{{end}}) |
|
|
|
address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex({{.Type}}Bin), backend {{range .Constructor.Inputs}}, {{.Name}}{{end}}) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return common.Address{}, nil, nil, err |
|
|
|
return common.Address{}, nil, nil, err |
|
|
|
} |
|
|
|
} |
|
|
|