Merge pull request #819 from nspcc-dev/fix/util160_marshalling

smartcontract: fix uint160 marshalling in smartcontract.Parameter
This commit is contained in:
Roman Khimov 2020-04-01 22:04:30 +03:00 committed by GitHub
commit f64aa201c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 8 deletions

View file

@ -63,9 +63,7 @@ func (p *Parameter) MarshalJSON() ([]byte, error) {
resultErr error
)
switch p.Type {
case Hash160Type:
resultRawValue, resultErr = json.Marshal(p.Value.(util.Uint160).Reverse()) // Hash160 should be marshaled in BE but default marshaler uses LE.
case BoolType, StringType, Hash256Type:
case BoolType, StringType, Hash160Type, Hash256Type:
resultRawValue, resultErr = json.Marshal(p.Value)
case IntegerType:
val, ok := p.Value.(int64)
@ -161,7 +159,7 @@ func (p *Parameter) UnmarshalJSON(data []byte) (err error) {
if err = json.Unmarshal(r.Value, &h); err != nil {
return
}
p.Value = h.Reverse() // Hash160 should be marshaled in BE but default marshaler uses LE.
p.Value = h
case Hash256Type:
var h util.Uint256
if err = json.Unmarshal(r.Value, &h); err != nil {