mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-03 23:02:27 +00:00
compiler, cli: introduce *.manifest.json
Add ability to generate NEO3-compatable *.manifest.json into compiler. This file represets contract manifest and includes ABI information, so we don't need to create separate *.abi.json file. NEO3 debugger also needs *.manifest.json only. So, switched from *.abi.json to *.manifest.json file.
This commit is contained in:
parent
1c1818d97e
commit
2f6065f541
4 changed files with 175 additions and 50 deletions
|
@ -6,6 +6,7 @@ import (
|
|||
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
|
||||
"github.com/nspcc-dev/neo-go/pkg/internal/testserdes"
|
||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/opcode"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
@ -121,29 +122,73 @@ func methodStruct() struct{} { return struct{}{} }
|
|||
require.EqualValues(t, opcode.RET, buf[index])
|
||||
}
|
||||
|
||||
t.Run("convert to ABI", func(t *testing.T) {
|
||||
actual := d.convertToABI(smartcontract.HasStorage)
|
||||
expected := ABI{
|
||||
Hash: hash.Hash160(buf),
|
||||
Metadata: Metadata{
|
||||
HasStorage: true,
|
||||
HasDynamicInvocation: false,
|
||||
IsPayable: false,
|
||||
},
|
||||
EntryPoint: mainIdent,
|
||||
Functions: []Method{
|
||||
{
|
||||
Name: mainIdent,
|
||||
Parameters: []DebugParam{
|
||||
t.Run("convert to Manifest", func(t *testing.T) {
|
||||
actual, err := d.convertToManifest(smartcontract.HasStorage)
|
||||
require.NoError(t, err)
|
||||
expected := &manifest.Manifest{
|
||||
ABI: manifest.ABI{
|
||||
Hash: hash.Hash160(buf),
|
||||
EntryPoint: manifest.Method{
|
||||
Name: "Main",
|
||||
Parameters: []manifest.Parameter{
|
||||
{
|
||||
Name: "op",
|
||||
Type: "String",
|
||||
Type: smartcontract.StringType,
|
||||
},
|
||||
},
|
||||
ReturnType: "Boolean",
|
||||
ReturnType: smartcontract.BoolType,
|
||||
},
|
||||
Methods: []manifest.Method{
|
||||
{
|
||||
Name: "methodInt",
|
||||
Parameters: []manifest.Parameter{
|
||||
{
|
||||
Name: "a",
|
||||
Type: smartcontract.StringType,
|
||||
},
|
||||
},
|
||||
ReturnType: smartcontract.IntegerType,
|
||||
},
|
||||
{
|
||||
Name: "methodString",
|
||||
Parameters: []manifest.Parameter{},
|
||||
ReturnType: smartcontract.StringType,
|
||||
},
|
||||
{
|
||||
Name: "methodByteArray",
|
||||
Parameters: []manifest.Parameter{},
|
||||
ReturnType: smartcontract.ByteArrayType,
|
||||
},
|
||||
{
|
||||
Name: "methodArray",
|
||||
Parameters: []manifest.Parameter{},
|
||||
ReturnType: smartcontract.ArrayType,
|
||||
},
|
||||
{
|
||||
Name: "methodStruct",
|
||||
Parameters: []manifest.Parameter{},
|
||||
ReturnType: smartcontract.ArrayType,
|
||||
},
|
||||
},
|
||||
Events: []manifest.Event{},
|
||||
},
|
||||
Groups: []manifest.Group{},
|
||||
Features: smartcontract.HasStorage,
|
||||
Permissions: []manifest.Permission{
|
||||
{
|
||||
Contract: manifest.PermissionDesc{
|
||||
Type: manifest.PermissionWildcard,
|
||||
},
|
||||
Methods: manifest.WildStrings{},
|
||||
},
|
||||
},
|
||||
Events: []Event{},
|
||||
Trusts: manifest.WildUint160s{
|
||||
Value: []util.Uint160{},
|
||||
},
|
||||
SafeMethods: manifest.WildStrings{
|
||||
Value: []string{},
|
||||
},
|
||||
Extra: nil,
|
||||
}
|
||||
require.True(t, expected.ABI.Hash.Equals(actual.ABI.Hash))
|
||||
require.ElementsMatch(t, expected.ABI.Methods, actual.ABI.Methods)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue