From c926d53869f7e38bd71aad35d1d2f053fc36daf3 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 afe48dba6..758b86bd1 100644 --- a/pkg/smartcontract/parameter.go +++ b/pkg/smartcontract/parameter.go @@ -360,6 +360,8 @@ func NewParameterFromValue(value any) (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 1150e9cbc..c93179a2a 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,