smartcontract: marshal Integer values to JSON-strings

It is done so in C# implementation, we better be
as compatible as possible.
Closes #770.
This commit is contained in:
Evgenii Stratonikov 2020-03-17 16:04:49 +03:00
parent 1e7b47ec05
commit 9666e99a17

View file

@ -63,8 +63,16 @@ func (p *Parameter) MarshalJSON() ([]byte, error) {
resultErr error resultErr error
) )
switch p.Type { switch p.Type {
case BoolType, IntegerType, StringType, Hash256Type, Hash160Type: case BoolType, StringType, Hash256Type, Hash160Type:
resultRawValue, resultErr = json.Marshal(p.Value) 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: case PublicKeyType, ByteArrayType, SignatureType:
if p.Value == nil { if p.Value == nil {
resultRawValue = []byte("null") resultRawValue = []byte("null")