Skip to content

Commit

Permalink
Fix DispatchError decode for rc6 (#162)
Browse files Browse the repository at this point in the history
* Patch prep rc6.3

* readd test
  • Loading branch information
mikiquantum authored Jun 15, 2021
1 parent 068769d commit 871581b
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions types/event_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,12 +399,16 @@ func (d *DispatchError) Decode(decoder scale.Decoder) error {
if b == 3 {
d.HasModule = true
err = decoder.Decode(&d.Module)
}
if err != nil {
return err
if err != nil {
return err
}
return decoder.Decode(&d.Error)
}

return decoder.Decode(&d.Error)
// Since the rest are enum errors, there is no further data to decode, just set enum byte as error
d.Error = b

return nil
}

func (d DispatchError) Encode(encoder scale.Encoder) error {
Expand All @@ -415,15 +419,13 @@ func (d DispatchError) Encode(encoder scale.Encoder) error {
return err
}
err = encoder.Encode(d.Module)
} else {
err = encoder.PushByte(0)
}

if err != nil {
return err
if err != nil {
return err
}
return encoder.Encode(&d.Error)
}

return encoder.Encode(&d.Error)
return encoder.PushByte(d.Error)
}

type EventID [2]byte

0 comments on commit 871581b

Please sign in to comment.