nef: add Source field

Follow neo-project/neo#2605.
This commit is contained in:
Roman Khimov 2021-09-24 00:19:37 +03:00
parent 0a52c32df3
commit 42a9d3d7b8
20 changed files with 54 additions and 10 deletions

View file

@ -52,6 +52,9 @@ type Options struct {
// Name is contract's name to be written to manifest.
Name string
// SourceURL is contract's source URL to be written to manifest.
SourceURL string
// Runtime notifications.
ContractEvents []manifest.Event
@ -199,6 +202,13 @@ func CompileAndSave(src string, o *Options) ([]byte, error) {
if err != nil {
return nil, fmt.Errorf("error while trying to create .nef file: %w", err)
}
if o.SourceURL != "" {
if len(o.SourceURL) > nef.MaxSourceURLLength {
return nil, errors.New("too long source URL")
}
f.Source = o.SourceURL
f.Checksum = f.CalculateChecksum()
}
bytes, err := f.Bytes()
if err != nil {
return nil, fmt.Errorf("error while serializing .nef file: %w", err)