mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-01-11 01:20:37 +00:00
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:
parent
c6ae954e4e
commit
fed95e0069
1 changed files with 2 additions and 2 deletions
|
@ -85,7 +85,7 @@ func (p *Parameter) MarshalJSON() ([]byte, error) {
|
||||||
case MapType:
|
case MapType:
|
||||||
ppair := p.Value.([]ParameterPair)
|
ppair := p.Value.([]ParameterPair)
|
||||||
resultRawValue, resultErr = json.Marshal(ppair)
|
resultRawValue, resultErr = json.Marshal(ppair)
|
||||||
case InteropInterfaceType:
|
case InteropInterfaceType, AnyType:
|
||||||
resultRawValue = []byte("null")
|
resultRawValue = []byte("null")
|
||||||
default:
|
default:
|
||||||
resultErr = errors.Errorf("Marshaller for type %s not implemented", p.Type)
|
resultErr = errors.Errorf("Marshaller for type %s not implemented", p.Type)
|
||||||
|
@ -168,7 +168,7 @@ func (p *Parameter) UnmarshalJSON(data []byte) (err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
p.Value = h
|
p.Value = h
|
||||||
case InteropInterfaceType:
|
case InteropInterfaceType, AnyType:
|
||||||
// stub, ignore value, it can only be null
|
// stub, ignore value, it can only be null
|
||||||
p.Value = nil
|
p.Value = nil
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue