smartcontract: (un)marshal AnyType value as null

Neo 3 can emit Null in its transfer notifications in `from` or `to` fields
when minting/burning tokens (unlike Neo 2 that emitted util.Uint256{} for this
case), then it gets converted to Parameter as AnyType and we have to JSONize
it somehow for proper RPC functioning.
This commit is contained in:
Roman Khimov 2020-06-03 18:56:20 +03:00
parent c6ae954e4e
commit fed95e0069

View file

@ -85,7 +85,7 @@ func (p *Parameter) MarshalJSON() ([]byte, error) {
case MapType:
ppair := p.Value.([]ParameterPair)
resultRawValue, resultErr = json.Marshal(ppair)
case InteropInterfaceType:
case InteropInterfaceType, AnyType:
resultRawValue = []byte("null")
default:
resultErr = errors.Errorf("Marshaller for type %s not implemented", p.Type)
@ -168,7 +168,7 @@ func (p *Parameter) UnmarshalJSON(data []byte) (err error) {
return
}
p.Value = h
case InteropInterfaceType:
case InteropInterfaceType, AnyType:
// stub, ignore value, it can only be null
p.Value = nil
default: