mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-03 23:02:27 +00:00
compiler: check supported standards
Check that emitted manifest complies with supported standards. This can be made a separate flag.
This commit is contained in:
parent
279b769fa3
commit
25f1db6de0
7 changed files with 90 additions and 14 deletions
|
@ -14,6 +14,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
|
||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest/standard"
|
||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/nef"
|
||||
"golang.org/x/tools/go/loader"
|
||||
)
|
||||
|
@ -34,6 +35,10 @@ type Options struct {
|
|||
// The name of the output for contract manifest file.
|
||||
ManifestFile string
|
||||
|
||||
// NoStandardCheck specifies if supported standards compliance needs to be checked.
|
||||
// This setting has effect only if manifest is emitted.
|
||||
NoStandardCheck bool
|
||||
|
||||
// Name is contract's name to be written to manifest.
|
||||
Name string
|
||||
|
||||
|
@ -214,6 +219,11 @@ func CompileAndSave(src string, o *Options) ([]byte, error) {
|
|||
if err != nil {
|
||||
return b, fmt.Errorf("failed to convert debug info to manifest: %w", err)
|
||||
}
|
||||
if !o.NoStandardCheck {
|
||||
if err := standard.Check(m, o.ContractSupportedStandards...); err != nil {
|
||||
return b, err
|
||||
}
|
||||
}
|
||||
mData, err := json.Marshal(m)
|
||||
if err != nil {
|
||||
return b, fmt.Errorf("failed to marshal manifest to JSON: %w", err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue