forked from TrueCloudLab/neoneo-go
manifest: add Offset in method descriptor
This commit is contained in:
parent
e52c39ae7e
commit
a892e3ffa8
3 changed files with 13 additions and 3 deletions
|
@ -270,6 +270,7 @@ func (m *MethodDebugInfo) ToManifestMethod() (manifest.Method, error) {
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
result.Name = strings.ToLower(string(m.Name.Name[0])) + m.Name.Name[1:]
|
result.Name = strings.ToLower(string(m.Name.Name[0])) + m.Name.Name[1:]
|
||||||
|
result.Offset = int(m.Range.Start)
|
||||||
result.Parameters = parameters
|
result.Parameters = parameters
|
||||||
result.ReturnType = returnType
|
result.ReturnType = returnType
|
||||||
return result, nil
|
return result, nil
|
||||||
|
|
|
@ -129,19 +129,22 @@ func unexportedMethod() int { return 1 }
|
||||||
t.Run("convert to Manifest", func(t *testing.T) {
|
t.Run("convert to Manifest", func(t *testing.T) {
|
||||||
actual, err := d.convertToManifest(smartcontract.HasStorage)
|
actual, err := d.convertToManifest(smartcontract.HasStorage)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
// note: offsets are hard to predict, so we just take them from the output
|
||||||
expected := &manifest.Manifest{
|
expected := &manifest.Manifest{
|
||||||
ABI: manifest.ABI{
|
ABI: manifest.ABI{
|
||||||
Hash: hash.Hash160(buf),
|
Hash: hash.Hash160(buf),
|
||||||
Methods: []manifest.Method{
|
Methods: []manifest.Method{
|
||||||
{
|
{
|
||||||
Name: "main",
|
Name: "main",
|
||||||
|
Offset: 0,
|
||||||
Parameters: []manifest.Parameter{
|
Parameters: []manifest.Parameter{
|
||||||
manifest.NewParameter("op", smartcontract.StringType),
|
manifest.NewParameter("op", smartcontract.StringType),
|
||||||
},
|
},
|
||||||
ReturnType: smartcontract.BoolType,
|
ReturnType: smartcontract.BoolType,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "methodInt",
|
Name: "methodInt",
|
||||||
|
Offset: 66,
|
||||||
Parameters: []manifest.Parameter{
|
Parameters: []manifest.Parameter{
|
||||||
{
|
{
|
||||||
Name: "a",
|
Name: "a",
|
||||||
|
@ -152,26 +155,31 @@ func unexportedMethod() int { return 1 }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "methodString",
|
Name: "methodString",
|
||||||
|
Offset: 97,
|
||||||
Parameters: []manifest.Parameter{},
|
Parameters: []manifest.Parameter{},
|
||||||
ReturnType: smartcontract.StringType,
|
ReturnType: smartcontract.StringType,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "methodByteArray",
|
Name: "methodByteArray",
|
||||||
|
Offset: 103,
|
||||||
Parameters: []manifest.Parameter{},
|
Parameters: []manifest.Parameter{},
|
||||||
ReturnType: smartcontract.ByteArrayType,
|
ReturnType: smartcontract.ByteArrayType,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "methodArray",
|
Name: "methodArray",
|
||||||
|
Offset: 108,
|
||||||
Parameters: []manifest.Parameter{},
|
Parameters: []manifest.Parameter{},
|
||||||
ReturnType: smartcontract.ArrayType,
|
ReturnType: smartcontract.ArrayType,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "methodStruct",
|
Name: "methodStruct",
|
||||||
|
Offset: 113,
|
||||||
Parameters: []manifest.Parameter{},
|
Parameters: []manifest.Parameter{},
|
||||||
ReturnType: smartcontract.ArrayType,
|
ReturnType: smartcontract.ArrayType,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "methodConcat",
|
Name: "methodConcat",
|
||||||
|
Offset: 88,
|
||||||
Parameters: []manifest.Parameter{
|
Parameters: []manifest.Parameter{
|
||||||
{
|
{
|
||||||
Name: "a",
|
Name: "a",
|
||||||
|
|
|
@ -38,6 +38,7 @@ type groupAux struct {
|
||||||
// Method represents method's metadata.
|
// Method represents method's metadata.
|
||||||
type Method struct {
|
type Method struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
Offset int `json:"offset"`
|
||||||
Parameters []Parameter `json:"parameters"`
|
Parameters []Parameter `json:"parameters"`
|
||||||
ReturnType smartcontract.ParamType `json:"returntype"`
|
ReturnType smartcontract.ParamType `json:"returntype"`
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue