diff --git a/pkg/smartcontract/parameter.go b/pkg/smartcontract/parameter.go index dbd3c5342..e5799b82e 100644 --- a/pkg/smartcontract/parameter.go +++ b/pkg/smartcontract/parameter.go @@ -311,6 +311,18 @@ func NewParameterFromValue(value interface{}) (Parameter, error) { result.Type = Hash160Type case util.Uint256: result.Type = Hash256Type + case *util.Uint160: + if v != nil { + return NewParameterFromValue(*v) + } + result.Type = AnyType + result.Value = nil + case *util.Uint256: + if v != nil { + return NewParameterFromValue(*v) + } + result.Type = AnyType + result.Value = nil case keys.PublicKey: return NewParameterFromValue(&v) case *keys.PublicKey: @@ -387,7 +399,7 @@ func ExpandParameterToEmitable(param Parameter) (interface{}, error) { } } return res, nil - case MapType, InteropInterfaceType, UnknownType, AnyType, VoidType: + case MapType, InteropInterfaceType, UnknownType, VoidType: return nil, fmt.Errorf("unsupported parameter type: %s", t.String()) default: return param.Value, nil diff --git a/pkg/smartcontract/parameter_test.go b/pkg/smartcontract/parameter_test.go index 72b1070f7..01aa977d8 100644 --- a/pkg/smartcontract/parameter_test.go +++ b/pkg/smartcontract/parameter_test.go @@ -484,6 +484,10 @@ func TestExpandParameterToEmitable(t *testing.T) { In: Parameter{Type: SignatureType, Value: []byte{1, 2, 3}}, Expected: []byte{1, 2, 3}, }, + { + In: Parameter{Type: AnyType}, + Expected: nil, + }, { In: Parameter{Type: ArrayType, Value: []Parameter{ { @@ -517,7 +521,6 @@ func TestExpandParameterToEmitable(t *testing.T) { require.NoError(t, bw.Err) } errCases := []Parameter{ - {Type: AnyType}, {Type: UnknownType}, {Type: MapType}, {Type: InteropInterfaceType}, @@ -636,6 +639,24 @@ func TestParameterFromValue(t *testing.T) { expType: Hash256Type, expVal: util.Uint256{3, 2, 1}, }, + { + value: (*util.Uint160)(nil), + expType: AnyType, + }, + { + value: &util.Uint160{1, 2, 3}, + expType: Hash160Type, + expVal: util.Uint160{1, 2, 3}, + }, + { + value: (*util.Uint256)(nil), + expType: AnyType, + }, + { + value: &util.Uint256{3, 2, 1}, + expType: Hash256Type, + expVal: util.Uint256{3, 2, 1}, + }, { value: pk1.PublicKey(), expType: PublicKeyType,