/
libgen_template.go
36 lines (29 loc) · 1.14 KB
/
libgen_template.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Package gen contains all the components for code generation.
package gen
const libgenTmpl = `
// Code generated by 'gen/libgen' DO NOT EDIT.
// IT SHOULD NOT BE EDITED BY HAND AS ANY CHANGES MAY BE OVERWRITTEN
// Please reference 'gen/libgen' for more details
// File was generated at {{.GenTime}}
package {{.PackageName}}
import (
"strings"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
)
const {{.ContractTypeName}}ABI = "{{.AbiString}}"
const {{.ContractTypeName}}Bin = ` + "`" + `{{.BinString}}` + "`" + `
func Deploy{{.ContractTypeName}}(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *bind.BoundContract, error) {
parsed, err := abi.JSON(strings.NewReader({{.ContractTypeName}}ABI))
if err != nil {
return common.Address{}, nil, nil, err
}
address, tx, contract, err := bind.DeployContract(auth, parsed, common.FromHex({{.ContractTypeName}}Bin), backend)
if err != nil {
return common.Address{}, nil, nil, err
}
return address, tx, contract, nil
}
`