diff --git a/pkg/compiler/debug.go b/pkg/compiler/debug.go index b96d60abc..352ad0b85 100644 --- a/pkg/compiler/debug.go +++ b/pkg/compiler/debug.go @@ -270,6 +270,7 @@ func (m *MethodDebugInfo) ToManifestMethod() (manifest.Method, error) { return result, err } result.Name = strings.ToLower(string(m.Name.Name[0])) + m.Name.Name[1:] + result.Offset = int(m.Range.Start) result.Parameters = parameters result.ReturnType = returnType return result, nil diff --git a/pkg/compiler/debug_test.go b/pkg/compiler/debug_test.go index 8301c88fe..f76f09cde 100644 --- a/pkg/compiler/debug_test.go +++ b/pkg/compiler/debug_test.go @@ -129,19 +129,22 @@ func unexportedMethod() int { return 1 } t.Run("convert to Manifest", func(t *testing.T) { actual, err := d.convertToManifest(smartcontract.HasStorage) require.NoError(t, err) + // note: offsets are hard to predict, so we just take them from the output expected := &manifest.Manifest{ ABI: manifest.ABI{ Hash: hash.Hash160(buf), Methods: []manifest.Method{ { - Name: "main", + Name: "main", + Offset: 0, Parameters: []manifest.Parameter{ manifest.NewParameter("op", smartcontract.StringType), }, ReturnType: smartcontract.BoolType, }, { - Name: "methodInt", + Name: "methodInt", + Offset: 66, Parameters: []manifest.Parameter{ { Name: "a", @@ -152,26 +155,31 @@ func unexportedMethod() int { return 1 } }, { Name: "methodString", + Offset: 97, Parameters: []manifest.Parameter{}, ReturnType: smartcontract.StringType, }, { Name: "methodByteArray", + Offset: 103, Parameters: []manifest.Parameter{}, ReturnType: smartcontract.ByteArrayType, }, { Name: "methodArray", + Offset: 108, Parameters: []manifest.Parameter{}, ReturnType: smartcontract.ArrayType, }, { Name: "methodStruct", + Offset: 113, Parameters: []manifest.Parameter{}, ReturnType: smartcontract.ArrayType, }, { - Name: "methodConcat", + Name: "methodConcat", + Offset: 88, Parameters: []manifest.Parameter{ { Name: "a", diff --git a/pkg/smartcontract/manifest/method.go b/pkg/smartcontract/manifest/method.go index 37d7fa4d5..30ad923f0 100644 --- a/pkg/smartcontract/manifest/method.go +++ b/pkg/smartcontract/manifest/method.go @@ -38,6 +38,7 @@ type groupAux struct { // Method represents method's metadata. type Method struct { Name string `json:"name"` + Offset int `json:"offset"` Parameters []Parameter `json:"parameters"` ReturnType smartcontract.ParamType `json:"returntype"` }