From c0abc61613cdf0497bdb32e820995833ca34e5d9 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Fri, 21 Jul 2023 13:18:08 +0300 Subject: [PATCH] smartcontract: allow to pass nil as parameter to (*Invoker).Call Signed-off-by: Anna Shaleva --- pkg/smartcontract/parameter.go | 2 ++ pkg/smartcontract/parameter_test.go | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/pkg/smartcontract/parameter.go b/pkg/smartcontract/parameter.go index 06556eca1..c591f5f0d 100644 --- a/pkg/smartcontract/parameter.go +++ b/pkg/smartcontract/parameter.go @@ -360,6 +360,8 @@ func NewParameterFromValue(value interface{}) (Parameter, error) { } result.Type = ArrayType result.Value = arr + case nil: + result.Type = AnyType default: return result, fmt.Errorf("unsupported parameter %T", value) } diff --git a/pkg/smartcontract/parameter_test.go b/pkg/smartcontract/parameter_test.go index 295ed8f93..2ec7a0108 100644 --- a/pkg/smartcontract/parameter_test.go +++ b/pkg/smartcontract/parameter_test.go @@ -690,6 +690,11 @@ func TestParameterFromValue(t *testing.T) { expType: PublicKeyType, expVal: pk2.PublicKey().Bytes(), }, + { + value: nil, + expType: AnyType, + expVal: nil, + }, { value: [][]byte{{1, 2, 3}, {3, 2, 1}}, expType: ArrayType,