diff --git a/internal/testchain/transaction.go b/internal/testchain/transaction.go index c024ad85c..10e71529e 100644 --- a/internal/testchain/transaction.go +++ b/internal/testchain/transaction.go @@ -62,7 +62,7 @@ func NewDeployTx(name string, sender util.Uint160, r gio.Reader) (*transaction.T return nil, util.Uint160{}, err } - m, err := di.ConvertToManifest(name, nil) + m, err := di.ConvertToManifest(&compiler.Options{Name: name}) if err != nil { return nil, util.Uint160{}, err } diff --git a/pkg/compiler/compiler.go b/pkg/compiler/compiler.go index 41fe8d0c8..0d4b5b970 100644 --- a/pkg/compiler/compiler.go +++ b/pkg/compiler/compiler.go @@ -219,7 +219,7 @@ func CompileAndSave(src string, o *Options) ([]byte, error) { } if o.ManifestFile != "" { - m, err := di.ConvertToManifest(o.Name, o.ContractEvents, o.ContractSupportedStandards...) + m, err := di.ConvertToManifest(o) if err != nil { return b, fmt.Errorf("failed to convert debug info to manifest: %w", err) } diff --git a/pkg/compiler/debug.go b/pkg/compiler/debug.go index d82fc688e..4fc221504 100644 --- a/pkg/compiler/debug.go +++ b/pkg/compiler/debug.go @@ -425,7 +425,7 @@ func parsePairJSON(data []byte, sep string) (string, string, error) { // ConvertToManifest converts contract to the manifest.Manifest struct for debugger. // Note: manifest is taken from the external source, however it can be generated ad-hoc. See #1038. -func (di *DebugInfo) ConvertToManifest(name string, events []manifest.Event, supportedStandards ...string) (*manifest.Manifest, error) { +func (di *DebugInfo) ConvertToManifest(o *Options) (*manifest.Manifest, error) { if di.MainPkg == "" { return nil, errors.New("no Main method was found") } @@ -440,16 +440,16 @@ func (di *DebugInfo) ConvertToManifest(name string, events []manifest.Event, sup } } - result := manifest.NewManifest(name) - if supportedStandards != nil { - result.SupportedStandards = supportedStandards - } - if events == nil { - events = make([]manifest.Event, 0) + result := manifest.NewManifest(o.Name) + if o.ContractSupportedStandards != nil { + result.SupportedStandards = o.ContractSupportedStandards } result.ABI = manifest.ABI{ Methods: methods, - Events: events, + Events: o.ContractEvents, + } + if result.ABI.Events == nil { + result.ABI.Events = make([]manifest.Event, 0) } result.Permissions = []manifest.Permission{ { diff --git a/pkg/compiler/debug_test.go b/pkg/compiler/debug_test.go index 3be6ec420..3915c6b63 100644 --- a/pkg/compiler/debug_test.go +++ b/pkg/compiler/debug_test.go @@ -150,7 +150,7 @@ func _deploy(isUpdate bool) {} } t.Run("convert to Manifest", func(t *testing.T) { - actual, err := d.ConvertToManifest("MyCTR", nil) + actual, err := d.ConvertToManifest(&Options{Name: "MyCTR"}) require.NoError(t, err) // note: offsets are hard to predict, so we just take them from the output expected := &manifest.Manifest{ diff --git a/pkg/compiler/interop_test.go b/pkg/compiler/interop_test.go index 6aa603aaa..eb81b717b 100644 --- a/pkg/compiler/interop_test.go +++ b/pkg/compiler/interop_test.go @@ -128,7 +128,7 @@ func TestAppCall(t *testing.T) { }` barCtr, di, err := compiler.CompileWithDebugInfo("bar.go", strings.NewReader(srcDeep)) require.NoError(t, err) - mBar, err := di.ConvertToManifest("Bar", nil) + mBar, err := di.ConvertToManifest(&compiler.Options{Name: "Bar"}) require.NoError(t, err) barH := hash.Hash160(barCtr) @@ -160,7 +160,7 @@ func TestAppCall(t *testing.T) { inner, di, err := compiler.CompileWithDebugInfo("foo.go", strings.NewReader(srcInner)) require.NoError(t, err) - m, err := di.ConvertToManifest("Foo", nil) + m, err := di.ConvertToManifest(&compiler.Options{Name: "Foo"}) require.NoError(t, err) ih := hash.Hash160(inner)