From 9666e99a17cba213387e63fd800c2ea2a5128f12 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Tue, 17 Mar 2020 16:04:49 +0300 Subject: [PATCH] smartcontract: marshal Integer values to JSON-strings It is done so in C# implementation, we better be as compatible as possible. Closes #770. --- pkg/smartcontract/parameter.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/smartcontract/parameter.go b/pkg/smartcontract/parameter.go index fd306709d..0a5c8b9ff 100644 --- a/pkg/smartcontract/parameter.go +++ b/pkg/smartcontract/parameter.go @@ -63,8 +63,16 @@ func (p *Parameter) MarshalJSON() ([]byte, error) { resultErr error ) switch p.Type { - case BoolType, IntegerType, StringType, Hash256Type, Hash160Type: + case BoolType, StringType, Hash256Type, Hash160Type: resultRawValue, resultErr = json.Marshal(p.Value) + case IntegerType: + val, ok := p.Value.(int64) + if !ok { + resultErr = errors.New("invalid integer value") + break + } + valStr := strconv.FormatInt(val, 10) + resultRawValue = json.RawMessage(`"` + valStr + `"`) case PublicKeyType, ByteArrayType, SignatureType: if p.Value == nil { resultRawValue = []byte("null")