2020-03-31 12:56:10 +00:00
|
|
|
package compiler
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
"go/ast"
|
|
|
|
"go/types"
|
|
|
|
"strconv"
|
|
|
|
"strings"
|
compiler: add ability to generate .abi.json file
A part of integration with NEO Blockchain Toolkit (see #902). To be
able to deploy smart-contract compiled with neo-go compiler via NEO
Express, we have to generate additional .abi.json file. This file
contains the following information:
- hash of the compiled contract
- smart-contract metadata (title, description, version, author,
email, has-storage, has-dynamic-invoke, is-payable)
- smart-contract entry point
- functions
- events
However, this .abi.json file is slightly different from the one,
described in manifest.go, so we have to add auxilaury stractures for
json marshalling. The .abi.json format used by NEO-Express is described
[here](https://github.com/neo-project/neo-devpack-dotnet/blob/master/src/Neo.Compiler.MSIL/FuncExport.cs#L66).
2020-04-28 16:39:01 +00:00
|
|
|
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
2020-06-25 13:10:08 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
|
compiler: add ability to generate .abi.json file
A part of integration with NEO Blockchain Toolkit (see #902). To be
able to deploy smart-contract compiled with neo-go compiler via NEO
Express, we have to generate additional .abi.json file. This file
contains the following information:
- hash of the compiled contract
- smart-contract metadata (title, description, version, author,
email, has-storage, has-dynamic-invoke, is-payable)
- smart-contract entry point
- functions
- events
However, this .abi.json file is slightly different from the one,
described in manifest.go, so we have to add auxilaury stractures for
json marshalling. The .abi.json format used by NEO-Express is described
[here](https://github.com/neo-project/neo-devpack-dotnet/blob/master/src/Neo.Compiler.MSIL/FuncExport.cs#L66).
2020-04-28 16:39:01 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
2020-03-31 12:56:10 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// DebugInfo represents smart-contract debug information.
|
|
|
|
type DebugInfo struct {
|
2020-07-24 10:40:54 +00:00
|
|
|
MainPkg string `json:"-"`
|
2020-06-24 05:55:24 +00:00
|
|
|
Hash util.Uint160 `json:"hash"`
|
|
|
|
Documents []string `json:"documents"`
|
|
|
|
Methods []MethodDebugInfo `json:"methods"`
|
|
|
|
Events []EventDebugInfo `json:"events"`
|
2020-03-31 12:56:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// MethodDebugInfo represents smart-contract's method debug information.
|
|
|
|
type MethodDebugInfo struct {
|
|
|
|
ID string `json:"id"`
|
|
|
|
// Name is the name of the method together with the namespace it belongs to.
|
|
|
|
Name DebugMethodName `json:"name"`
|
2020-07-03 09:58:41 +00:00
|
|
|
// IsExported defines whether method is exported.
|
|
|
|
IsExported bool `json:"-"`
|
2020-03-31 12:56:10 +00:00
|
|
|
// Range is the range of smart-contract's opcodes corresponding to the method.
|
|
|
|
Range DebugRange `json:"range"`
|
|
|
|
// Parameters is a list of method's parameters.
|
|
|
|
Parameters []DebugParam `json:"params"`
|
|
|
|
// ReturnType is method's return type.
|
2020-06-26 09:08:59 +00:00
|
|
|
ReturnType string `json:"return"`
|
2020-03-31 12:56:10 +00:00
|
|
|
Variables []string `json:"variables"`
|
|
|
|
// SeqPoints is a map between source lines and byte-code instruction offsets.
|
|
|
|
SeqPoints []DebugSeqPoint `json:"sequence-points"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// DebugMethodName is a combination of a namespace and name.
|
|
|
|
type DebugMethodName struct {
|
|
|
|
Namespace string
|
|
|
|
Name string
|
|
|
|
}
|
|
|
|
|
|
|
|
// EventDebugInfo represents smart-contract's event debug information.
|
|
|
|
type EventDebugInfo struct {
|
|
|
|
ID string `json:"id"`
|
|
|
|
// Name is a human-readable event name in a format "{namespace}-{name}".
|
|
|
|
Name string `json:"name"`
|
2020-06-26 09:08:59 +00:00
|
|
|
Parameters []DebugParam `json:"params"`
|
2020-03-31 12:56:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// DebugSeqPoint represents break-point for debugger.
|
|
|
|
type DebugSeqPoint struct {
|
|
|
|
// Opcode is an opcode's address.
|
|
|
|
Opcode int
|
|
|
|
// Document is an index of file where sequence point occurs.
|
|
|
|
Document int
|
|
|
|
// StartLine is the first line of the break-pointed statement.
|
|
|
|
StartLine int
|
|
|
|
// StartCol is the first column of the break-pointed statement.
|
|
|
|
StartCol int
|
|
|
|
// EndLine is the last line of the break-pointed statement.
|
|
|
|
EndLine int
|
|
|
|
// EndCol is the last column of the break-pointed statement.
|
|
|
|
EndCol int
|
|
|
|
}
|
|
|
|
|
|
|
|
// DebugRange represents method's section in bytecode.
|
|
|
|
type DebugRange struct {
|
|
|
|
Start uint16
|
|
|
|
End uint16
|
|
|
|
}
|
|
|
|
|
|
|
|
// DebugParam represents variables's name and type.
|
|
|
|
type DebugParam struct {
|
compiler: add ability to generate .abi.json file
A part of integration with NEO Blockchain Toolkit (see #902). To be
able to deploy smart-contract compiled with neo-go compiler via NEO
Express, we have to generate additional .abi.json file. This file
contains the following information:
- hash of the compiled contract
- smart-contract metadata (title, description, version, author,
email, has-storage, has-dynamic-invoke, is-payable)
- smart-contract entry point
- functions
- events
However, this .abi.json file is slightly different from the one,
described in manifest.go, so we have to add auxilaury stractures for
json marshalling. The .abi.json format used by NEO-Express is described
[here](https://github.com/neo-project/neo-devpack-dotnet/blob/master/src/Neo.Compiler.MSIL/FuncExport.cs#L66).
2020-04-28 16:39:01 +00:00
|
|
|
Name string `json:"name"`
|
|
|
|
Type string `json:"type"`
|
|
|
|
}
|
|
|
|
|
2020-03-31 13:57:35 +00:00
|
|
|
func (c *codegen) saveSequencePoint(n ast.Node) {
|
2020-05-07 08:54:35 +00:00
|
|
|
if c.scope == nil {
|
|
|
|
// do not save globals for now
|
|
|
|
return
|
|
|
|
}
|
2020-03-31 13:57:35 +00:00
|
|
|
fset := c.buildInfo.program.Fset
|
|
|
|
start := fset.Position(n.Pos())
|
|
|
|
end := fset.Position(n.End())
|
|
|
|
c.sequencePoints[c.scope.name] = append(c.sequencePoints[c.scope.name], DebugSeqPoint{
|
|
|
|
Opcode: c.prog.Len(),
|
|
|
|
StartLine: start.Line,
|
|
|
|
StartCol: start.Offset,
|
|
|
|
EndLine: end.Line,
|
|
|
|
EndCol: end.Offset,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-06-24 04:22:33 +00:00
|
|
|
func (c *codegen) emitDebugInfo(contract []byte) *DebugInfo {
|
2020-03-31 12:56:10 +00:00
|
|
|
d := &DebugInfo{
|
2020-07-24 10:40:54 +00:00
|
|
|
MainPkg: c.mainPkg.Pkg.Name(),
|
|
|
|
Hash: hash.Hash160(contract),
|
|
|
|
Events: []EventDebugInfo{},
|
|
|
|
}
|
|
|
|
if c.initEndOffset > 0 {
|
|
|
|
d.Methods = append(d.Methods, MethodDebugInfo{
|
|
|
|
ID: manifest.MethodInit,
|
|
|
|
Name: DebugMethodName{
|
|
|
|
Name: manifest.MethodInit,
|
|
|
|
Namespace: c.mainPkg.Pkg.Name(),
|
|
|
|
},
|
|
|
|
IsExported: true,
|
|
|
|
Range: DebugRange{
|
|
|
|
Start: 0,
|
|
|
|
End: uint16(c.initEndOffset),
|
|
|
|
},
|
|
|
|
ReturnType: "Void",
|
|
|
|
})
|
2020-03-31 12:56:10 +00:00
|
|
|
}
|
|
|
|
for name, scope := range c.funcs {
|
|
|
|
m := c.methodInfoFromScope(name, scope)
|
|
|
|
if m.Range.Start == m.Range.End {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
d.Methods = append(d.Methods, *m)
|
|
|
|
}
|
|
|
|
return d
|
|
|
|
}
|
|
|
|
|
2020-04-02 13:36:11 +00:00
|
|
|
func (c *codegen) registerDebugVariable(name string, expr ast.Expr) {
|
2020-05-07 08:54:35 +00:00
|
|
|
if c.scope == nil {
|
|
|
|
// do not save globals for now
|
|
|
|
return
|
|
|
|
}
|
2020-04-02 13:36:11 +00:00
|
|
|
typ := c.scTypeFromExpr(expr)
|
|
|
|
c.scope.variables = append(c.scope.variables, name+","+typ)
|
|
|
|
}
|
|
|
|
|
2020-03-31 12:56:10 +00:00
|
|
|
func (c *codegen) methodInfoFromScope(name string, scope *funcScope) *MethodDebugInfo {
|
|
|
|
ps := scope.decl.Type.Params
|
|
|
|
params := make([]DebugParam, 0, ps.NumFields())
|
2020-04-29 13:32:07 +00:00
|
|
|
for i := range ps.List {
|
2020-03-31 12:56:10 +00:00
|
|
|
for j := range ps.List[i].Names {
|
|
|
|
params = append(params, DebugParam{
|
|
|
|
Name: ps.List[i].Names[j].Name,
|
|
|
|
Type: c.scTypeFromExpr(ps.List[i].Type),
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2020-07-29 14:20:00 +00:00
|
|
|
ss := strings.Split(name, ".")
|
|
|
|
name = ss[len(ss)-1]
|
2020-03-31 12:56:10 +00:00
|
|
|
return &MethodDebugInfo{
|
2020-07-07 08:49:14 +00:00
|
|
|
ID: name,
|
|
|
|
Name: DebugMethodName{
|
|
|
|
Name: name,
|
|
|
|
Namespace: scope.pkg.Name(),
|
|
|
|
},
|
2020-07-03 09:58:41 +00:00
|
|
|
IsExported: scope.decl.Name.IsExported(),
|
2020-03-31 12:56:10 +00:00
|
|
|
Range: scope.rng,
|
|
|
|
Parameters: params,
|
|
|
|
ReturnType: c.scReturnTypeFromScope(scope),
|
2020-03-31 13:57:35 +00:00
|
|
|
SeqPoints: c.sequencePoints[name],
|
2020-04-02 13:36:11 +00:00
|
|
|
Variables: scope.variables,
|
2020-03-31 12:56:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *codegen) scReturnTypeFromScope(scope *funcScope) string {
|
|
|
|
results := scope.decl.Type.Results
|
|
|
|
switch results.NumFields() {
|
|
|
|
case 0:
|
|
|
|
return "Void"
|
|
|
|
case 1:
|
|
|
|
return c.scTypeFromExpr(results.List[0].Type)
|
|
|
|
default:
|
|
|
|
// multiple return values are not supported in debugger
|
|
|
|
return "Any"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *codegen) scTypeFromExpr(typ ast.Expr) string {
|
2020-05-13 15:09:55 +00:00
|
|
|
t := c.typeOf(typ)
|
|
|
|
if c.typeOf(typ) == nil {
|
|
|
|
return "Any"
|
|
|
|
}
|
|
|
|
switch t := t.Underlying().(type) {
|
2020-03-31 12:56:10 +00:00
|
|
|
case *types.Basic:
|
|
|
|
info := t.Info()
|
|
|
|
switch {
|
|
|
|
case info&types.IsInteger != 0:
|
|
|
|
return "Integer"
|
|
|
|
case info&types.IsBoolean != 0:
|
|
|
|
return "Boolean"
|
|
|
|
case info&types.IsString != 0:
|
|
|
|
return "String"
|
|
|
|
default:
|
|
|
|
return "Any"
|
|
|
|
}
|
|
|
|
case *types.Map:
|
|
|
|
return "Map"
|
|
|
|
case *types.Struct:
|
|
|
|
return "Struct"
|
|
|
|
case *types.Slice:
|
2020-05-13 15:09:55 +00:00
|
|
|
if isByte(t.Elem()) {
|
2020-07-29 09:13:07 +00:00
|
|
|
return "ByteString"
|
2020-03-31 12:56:10 +00:00
|
|
|
}
|
|
|
|
return "Array"
|
|
|
|
default:
|
|
|
|
return "Any"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// MarshalJSON implements json.Marshaler interface.
|
|
|
|
func (d *DebugRange) MarshalJSON() ([]byte, error) {
|
|
|
|
return []byte(`"` + strconv.FormatUint(uint64(d.Start), 10) + `-` +
|
|
|
|
strconv.FormatUint(uint64(d.End), 10) + `"`), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// UnmarshalJSON implements json.Unmarshaler interface.
|
|
|
|
func (d *DebugRange) UnmarshalJSON(data []byte) error {
|
|
|
|
startS, endS, err := parsePairJSON(data, "-")
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
start, err := strconv.ParseUint(startS, 10, 16)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
end, err := strconv.ParseUint(endS, 10, 16)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
d.Start = uint16(start)
|
|
|
|
d.End = uint16(end)
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// MarshalJSON implements json.Marshaler interface.
|
|
|
|
func (d *DebugParam) MarshalJSON() ([]byte, error) {
|
|
|
|
return []byte(`"` + d.Name + `,` + d.Type + `"`), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// UnmarshalJSON implements json.Unmarshaler interface.
|
|
|
|
func (d *DebugParam) UnmarshalJSON(data []byte) error {
|
|
|
|
startS, endS, err := parsePairJSON(data, ",")
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
d.Name = startS
|
|
|
|
d.Type = endS
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-06-25 13:10:08 +00:00
|
|
|
// ToManifestParameter converts DebugParam to manifest.Parameter
|
|
|
|
func (d *DebugParam) ToManifestParameter() (manifest.Parameter, error) {
|
|
|
|
pType, err := smartcontract.ParseParamType(d.Type)
|
|
|
|
if err != nil {
|
|
|
|
return manifest.Parameter{}, err
|
|
|
|
}
|
|
|
|
return manifest.Parameter{
|
|
|
|
Name: d.Name,
|
|
|
|
Type: pType,
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ToManifestMethod converts MethodDebugInfo to manifest.Method
|
|
|
|
func (m *MethodDebugInfo) ToManifestMethod() (manifest.Method, error) {
|
|
|
|
var (
|
|
|
|
result manifest.Method
|
|
|
|
err error
|
|
|
|
)
|
|
|
|
parameters := make([]manifest.Parameter, len(m.Parameters))
|
|
|
|
for i, p := range m.Parameters {
|
|
|
|
parameters[i], err = p.ToManifestParameter()
|
|
|
|
if err != nil {
|
|
|
|
return result, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
returnType, err := smartcontract.ParseParamType(m.ReturnType)
|
|
|
|
if err != nil {
|
|
|
|
return result, err
|
|
|
|
}
|
2020-07-07 09:01:39 +00:00
|
|
|
result.Name = strings.ToLower(string(m.Name.Name[0])) + m.Name.Name[1:]
|
2020-07-23 13:12:41 +00:00
|
|
|
result.Offset = int(m.Range.Start)
|
2020-06-25 13:10:08 +00:00
|
|
|
result.Parameters = parameters
|
|
|
|
result.ReturnType = returnType
|
|
|
|
return result, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ToManifestEvent converts EventDebugInfo to manifest.Event
|
|
|
|
func (e *EventDebugInfo) ToManifestEvent() (manifest.Event, error) {
|
|
|
|
var (
|
|
|
|
result manifest.Event
|
|
|
|
err error
|
|
|
|
)
|
|
|
|
parameters := make([]manifest.Parameter, len(e.Parameters))
|
|
|
|
for i, p := range e.Parameters {
|
|
|
|
parameters[i], err = p.ToManifestParameter()
|
|
|
|
if err != nil {
|
|
|
|
return result, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
result.Name = e.Name
|
|
|
|
result.Parameters = parameters
|
|
|
|
return result, nil
|
|
|
|
}
|
|
|
|
|
2020-03-31 12:56:10 +00:00
|
|
|
// MarshalJSON implements json.Marshaler interface.
|
|
|
|
func (d *DebugMethodName) MarshalJSON() ([]byte, error) {
|
|
|
|
return []byte(`"` + d.Namespace + `,` + d.Name + `"`), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// UnmarshalJSON implements json.Unmarshaler interface.
|
|
|
|
func (d *DebugMethodName) UnmarshalJSON(data []byte) error {
|
|
|
|
startS, endS, err := parsePairJSON(data, ",")
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
d.Namespace = startS
|
|
|
|
d.Name = endS
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// MarshalJSON implements json.Marshaler interface.
|
|
|
|
func (d *DebugSeqPoint) MarshalJSON() ([]byte, error) {
|
|
|
|
s := fmt.Sprintf("%d[%d]%d:%d-%d:%d", d.Opcode, d.Document,
|
|
|
|
d.StartLine, d.StartCol, d.EndLine, d.EndCol)
|
|
|
|
return []byte(`"` + s + `"`), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// UnmarshalJSON implements json.Unmarshaler interface.
|
|
|
|
func (d *DebugSeqPoint) UnmarshalJSON(data []byte) error {
|
|
|
|
_, err := fmt.Sscanf(string(data), `"%d[%d]%d:%d-%d:%d"`,
|
|
|
|
&d.Opcode, &d.Document, &d.StartLine, &d.StartCol, &d.EndLine, &d.EndCol)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func parsePairJSON(data []byte, sep string) (string, string, error) {
|
|
|
|
var s string
|
|
|
|
if err := json.Unmarshal(data, &s); err != nil {
|
|
|
|
return "", "", err
|
|
|
|
}
|
|
|
|
ss := strings.SplitN(s, sep, 2)
|
|
|
|
if len(ss) != 2 {
|
|
|
|
return "", "", errors.New("invalid range format")
|
|
|
|
}
|
|
|
|
return ss[0], ss[1], nil
|
|
|
|
}
|
compiler: add ability to generate .abi.json file
A part of integration with NEO Blockchain Toolkit (see #902). To be
able to deploy smart-contract compiled with neo-go compiler via NEO
Express, we have to generate additional .abi.json file. This file
contains the following information:
- hash of the compiled contract
- smart-contract metadata (title, description, version, author,
email, has-storage, has-dynamic-invoke, is-payable)
- smart-contract entry point
- functions
- events
However, this .abi.json file is slightly different from the one,
described in manifest.go, so we have to add auxilaury stractures for
json marshalling. The .abi.json format used by NEO-Express is described
[here](https://github.com/neo-project/neo-devpack-dotnet/blob/master/src/Neo.Compiler.MSIL/FuncExport.cs#L66).
2020-04-28 16:39:01 +00:00
|
|
|
|
2020-07-23 14:01:51 +00:00
|
|
|
// ConvertToManifest converts contract to the manifest.Manifest struct for debugger.
|
2020-06-09 13:12:58 +00:00
|
|
|
// Note: manifest is taken from the external source, however it can be generated ad-hoc. See #1038.
|
2020-08-04 09:55:36 +00:00
|
|
|
func (di *DebugInfo) ConvertToManifest(fs smartcontract.PropertyState, supportedStandards ...string) (*manifest.Manifest, error) {
|
2020-07-24 10:40:54 +00:00
|
|
|
var err error
|
|
|
|
if di.MainPkg == "" {
|
2020-06-25 13:10:08 +00:00
|
|
|
return nil, errors.New("no Main method was found")
|
|
|
|
}
|
2020-07-03 09:58:41 +00:00
|
|
|
methods := make([]manifest.Method, 0)
|
2020-06-25 13:10:08 +00:00
|
|
|
for _, method := range di.Methods {
|
2020-07-24 10:40:54 +00:00
|
|
|
if method.IsExported && method.Name.Namespace == di.MainPkg {
|
2020-06-25 13:10:08 +00:00
|
|
|
mMethod, err := method.ToManifestMethod()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
methods = append(methods, mMethod)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
events := make([]manifest.Event, len(di.Events))
|
compiler: add ability to generate .abi.json file
A part of integration with NEO Blockchain Toolkit (see #902). To be
able to deploy smart-contract compiled with neo-go compiler via NEO
Express, we have to generate additional .abi.json file. This file
contains the following information:
- hash of the compiled contract
- smart-contract metadata (title, description, version, author,
email, has-storage, has-dynamic-invoke, is-payable)
- smart-contract entry point
- functions
- events
However, this .abi.json file is slightly different from the one,
described in manifest.go, so we have to add auxilaury stractures for
json marshalling. The .abi.json format used by NEO-Express is described
[here](https://github.com/neo-project/neo-devpack-dotnet/blob/master/src/Neo.Compiler.MSIL/FuncExport.cs#L66).
2020-04-28 16:39:01 +00:00
|
|
|
for i, event := range di.Events {
|
2020-06-25 13:10:08 +00:00
|
|
|
events[i], err = event.ToManifestEvent()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
compiler: add ability to generate .abi.json file
A part of integration with NEO Blockchain Toolkit (see #902). To be
able to deploy smart-contract compiled with neo-go compiler via NEO
Express, we have to generate additional .abi.json file. This file
contains the following information:
- hash of the compiled contract
- smart-contract metadata (title, description, version, author,
email, has-storage, has-dynamic-invoke, is-payable)
- smart-contract entry point
- functions
- events
However, this .abi.json file is slightly different from the one,
described in manifest.go, so we have to add auxilaury stractures for
json marshalling. The .abi.json format used by NEO-Express is described
[here](https://github.com/neo-project/neo-devpack-dotnet/blob/master/src/Neo.Compiler.MSIL/FuncExport.cs#L66).
2020-04-28 16:39:01 +00:00
|
|
|
}
|
|
|
|
}
|
2020-06-25 13:10:08 +00:00
|
|
|
|
|
|
|
result := manifest.NewManifest(di.Hash)
|
|
|
|
result.Features = fs
|
2020-08-04 09:55:36 +00:00
|
|
|
if supportedStandards != nil {
|
|
|
|
result.SupportedStandards = supportedStandards
|
|
|
|
}
|
2020-06-25 13:10:08 +00:00
|
|
|
result.ABI = manifest.ABI{
|
2020-07-23 13:03:00 +00:00
|
|
|
Hash: di.Hash,
|
|
|
|
Methods: methods,
|
|
|
|
Events: events,
|
compiler: add ability to generate .abi.json file
A part of integration with NEO Blockchain Toolkit (see #902). To be
able to deploy smart-contract compiled with neo-go compiler via NEO
Express, we have to generate additional .abi.json file. This file
contains the following information:
- hash of the compiled contract
- smart-contract metadata (title, description, version, author,
email, has-storage, has-dynamic-invoke, is-payable)
- smart-contract entry point
- functions
- events
However, this .abi.json file is slightly different from the one,
described in manifest.go, so we have to add auxilaury stractures for
json marshalling. The .abi.json format used by NEO-Express is described
[here](https://github.com/neo-project/neo-devpack-dotnet/blob/master/src/Neo.Compiler.MSIL/FuncExport.cs#L66).
2020-04-28 16:39:01 +00:00
|
|
|
}
|
2020-06-25 13:10:08 +00:00
|
|
|
result.Permissions = []manifest.Permission{
|
|
|
|
{
|
|
|
|
Contract: manifest.PermissionDesc{
|
|
|
|
Type: manifest.PermissionWildcard,
|
|
|
|
},
|
|
|
|
Methods: manifest.WildStrings{},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
return result, nil
|
compiler: add ability to generate .abi.json file
A part of integration with NEO Blockchain Toolkit (see #902). To be
able to deploy smart-contract compiled with neo-go compiler via NEO
Express, we have to generate additional .abi.json file. This file
contains the following information:
- hash of the compiled contract
- smart-contract metadata (title, description, version, author,
email, has-storage, has-dynamic-invoke, is-payable)
- smart-contract entry point
- functions
- events
However, this .abi.json file is slightly different from the one,
described in manifest.go, so we have to add auxilaury stractures for
json marshalling. The .abi.json format used by NEO-Express is described
[here](https://github.com/neo-project/neo-devpack-dotnet/blob/master/src/Neo.Compiler.MSIL/FuncExport.cs#L66).
2020-04-28 16:39:01 +00:00
|
|
|
}
|