forked from TrueCloudLab/neoneo-go
compiler: use Options
in ConvertToManifest()
This commit is contained in:
parent
03d32ecd61
commit
9fd8577dd9
5 changed files with 13 additions and 13 deletions
|
@ -62,7 +62,7 @@ func NewDeployTx(name string, sender util.Uint160, r gio.Reader) (*transaction.T
|
||||||
return nil, util.Uint160{}, err
|
return nil, util.Uint160{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
m, err := di.ConvertToManifest(name, nil)
|
m, err := di.ConvertToManifest(&compiler.Options{Name: name})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, util.Uint160{}, err
|
return nil, util.Uint160{}, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -219,7 +219,7 @@ func CompileAndSave(src string, o *Options) ([]byte, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if o.ManifestFile != "" {
|
if o.ManifestFile != "" {
|
||||||
m, err := di.ConvertToManifest(o.Name, o.ContractEvents, o.ContractSupportedStandards...)
|
m, err := di.ConvertToManifest(o)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return b, fmt.Errorf("failed to convert debug info to manifest: %w", err)
|
return b, fmt.Errorf("failed to convert debug info to manifest: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -425,7 +425,7 @@ func parsePairJSON(data []byte, sep string) (string, string, error) {
|
||||||
|
|
||||||
// ConvertToManifest converts contract to the manifest.Manifest struct for debugger.
|
// 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.
|
// 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 == "" {
|
if di.MainPkg == "" {
|
||||||
return nil, errors.New("no Main method was found")
|
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)
|
result := manifest.NewManifest(o.Name)
|
||||||
if supportedStandards != nil {
|
if o.ContractSupportedStandards != nil {
|
||||||
result.SupportedStandards = supportedStandards
|
result.SupportedStandards = o.ContractSupportedStandards
|
||||||
}
|
|
||||||
if events == nil {
|
|
||||||
events = make([]manifest.Event, 0)
|
|
||||||
}
|
}
|
||||||
result.ABI = manifest.ABI{
|
result.ABI = manifest.ABI{
|
||||||
Methods: methods,
|
Methods: methods,
|
||||||
Events: events,
|
Events: o.ContractEvents,
|
||||||
|
}
|
||||||
|
if result.ABI.Events == nil {
|
||||||
|
result.ABI.Events = make([]manifest.Event, 0)
|
||||||
}
|
}
|
||||||
result.Permissions = []manifest.Permission{
|
result.Permissions = []manifest.Permission{
|
||||||
{
|
{
|
||||||
|
|
|
@ -150,7 +150,7 @@ func _deploy(isUpdate bool) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Run("convert to Manifest", func(t *testing.T) {
|
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)
|
require.NoError(t, err)
|
||||||
// note: offsets are hard to predict, so we just take them from the output
|
// note: offsets are hard to predict, so we just take them from the output
|
||||||
expected := &manifest.Manifest{
|
expected := &manifest.Manifest{
|
||||||
|
|
|
@ -128,7 +128,7 @@ func TestAppCall(t *testing.T) {
|
||||||
}`
|
}`
|
||||||
barCtr, di, err := compiler.CompileWithDebugInfo("bar.go", strings.NewReader(srcDeep))
|
barCtr, di, err := compiler.CompileWithDebugInfo("bar.go", strings.NewReader(srcDeep))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
mBar, err := di.ConvertToManifest("Bar", nil)
|
mBar, err := di.ConvertToManifest(&compiler.Options{Name: "Bar"})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
barH := hash.Hash160(barCtr)
|
barH := hash.Hash160(barCtr)
|
||||||
|
@ -160,7 +160,7 @@ func TestAppCall(t *testing.T) {
|
||||||
|
|
||||||
inner, di, err := compiler.CompileWithDebugInfo("foo.go", strings.NewReader(srcInner))
|
inner, di, err := compiler.CompileWithDebugInfo("foo.go", strings.NewReader(srcInner))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
m, err := di.ConvertToManifest("Foo", nil)
|
m, err := di.ConvertToManifest(&compiler.Options{Name: "Foo"})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
ih := hash.Hash160(inner)
|
ih := hash.Hash160(inner)
|
||||||
|
|
Loading…
Reference in a new issue