compiler: do not check Any event parameter for compliance

It's possible that declared manifest event has parameter of AnyT for
those cases when parameter type differs from method to method. If so,
then we don't need to enforce type check after compilation.
This commit is contained in:
Anna Shaleva 2022-09-29 15:13:29 +03:00
parent b2b5303d06
commit 08427f23b6
2 changed files with 14 additions and 0 deletions

View file

@ -13,6 +13,7 @@ import (
"path/filepath"
"strings"
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
"github.com/nspcc-dev/neo-go/pkg/smartcontract/binding"
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest/standard"
@ -363,6 +364,9 @@ func CreateManifest(di *DebugInfo, o *Options) (*manifest.Manifest, error) {
name, len(ev.Parameters), len(argsList[i]))
}
for j := range ev.Parameters {
if ev.Parameters[j].Type == smartcontract.AnyType {
continue
}
expected := ev.Parameters[j].Type.String()
if argsList[i][j] != expected {
return nil, fmt.Errorf("event '%s' should have '%s' as type of %d parameter, "+

View file

@ -174,6 +174,16 @@ func TestEventWarnings(t *testing.T) {
})
require.Error(t, err)
})
t.Run("any parameter type", func(t *testing.T) {
_, err = compiler.CreateManifest(di, &compiler.Options{
ContractEvents: []manifest.Event{{
Name: "Event",
Parameters: []manifest.Parameter{manifest.NewParameter("number", smartcontract.AnyType)},
}},
Name: "payable",
})
require.NoError(t, err)
})
t.Run("good", func(t *testing.T) {
_, err = compiler.CreateManifest(di, &compiler.Options{
ContractEvents: []manifest.Event{{