binding: always import some packages and do it outside

If the contract has no methods, it's probably a broken one.
This commit is contained in:
Roman Khimov 2022-10-26 12:40:59 +03:00
parent 4313b7f0c7
commit d6d4f07280

View file

@ -92,6 +92,9 @@ func Generate(cfg Config) error {
if err != nil { if err != nil {
return err return err
} }
ctr.Imports = append(ctr.Imports, "github.com/nspcc-dev/neo-go/pkg/interop/contract")
ctr.Imports = append(ctr.Imports, "github.com/nspcc-dev/neo-go/pkg/interop/neogointernal")
sort.Strings(ctr.Imports)
tmp, err := template.New("generate").Funcs(template.FuncMap{ tmp, err := template.New("generate").Funcs(template.FuncMap{
"lowerFirst": lowerFirst, "lowerFirst": lowerFirst,
@ -169,9 +172,6 @@ func templateFromManifest(cfg Config) (contractTmpl, error) {
continue continue
} }
imports["github.com/nspcc-dev/neo-go/pkg/interop/contract"] = struct{}{}
imports["github.com/nspcc-dev/neo-go/pkg/interop/neogointernal"] = struct{}{}
// Consider `perform(a)` and `perform(a, b)` methods. // Consider `perform(a)` and `perform(a, b)` methods.
// First, try to export the second method with `Perform2` name. // First, try to export the second method with `Perform2` name.
// If `perform2` is already in the manifest, use `perform_2` with as many underscores // If `perform2` is already in the manifest, use `perform_2` with as many underscores
@ -240,7 +240,6 @@ func templateFromManifest(cfg Config) (contractTmpl, error) {
for imp := range imports { for imp := range imports {
ctr.Imports = append(ctr.Imports, imp) ctr.Imports = append(ctr.Imports, imp)
} }
sort.Strings(ctr.Imports)
return ctr, nil return ctr, nil
} }