fix Event schema + cbor-gen.
This commit is contained in:
parent
5249a35212
commit
476a9331f8
@ -1852,8 +1852,9 @@ func (t *Event) MarshalCBOR(w io.Writer) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// t.Emitter (address.Address) (struct)
|
// t.Emitter (abi.ActorID) (uint64)
|
||||||
if err := t.Emitter.MarshalCBOR(cw); err != nil {
|
|
||||||
|
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.Emitter)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1896,13 +1897,18 @@ func (t *Event) UnmarshalCBOR(r io.Reader) (err error) {
|
|||||||
return fmt.Errorf("cbor input had wrong number of fields")
|
return fmt.Errorf("cbor input had wrong number of fields")
|
||||||
}
|
}
|
||||||
|
|
||||||
// t.Emitter (address.Address) (struct)
|
// t.Emitter (abi.ActorID) (uint64)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
if err := t.Emitter.UnmarshalCBOR(cr); err != nil {
|
maj, extra, err = cr.ReadHeader()
|
||||||
return xerrors.Errorf("unmarshaling t.Emitter: %w", err)
|
if err != nil {
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
if maj != cbg.MajUnsignedInt {
|
||||||
|
return fmt.Errorf("wrong type for uint64 field")
|
||||||
|
}
|
||||||
|
t.Emitter = abi.ActorID(extra)
|
||||||
|
|
||||||
}
|
}
|
||||||
// t.Entries ([]types.EventEntry) (slice)
|
// t.Entries ([]types.EventEntry) (slice)
|
||||||
@ -1956,16 +1962,15 @@ func (t *EventEntry) MarshalCBOR(w io.Writer) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// t.Key ([]uint8) (slice)
|
// t.Key (string) (string)
|
||||||
if len(t.Key) > cbg.ByteArrayMaxLen {
|
if len(t.Key) > cbg.MaxLength {
|
||||||
return xerrors.Errorf("Byte array in field t.Key was too long")
|
return xerrors.Errorf("Value in field t.Key was too long")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := cw.WriteMajorTypeHeader(cbg.MajByteString, uint64(len(t.Key))); err != nil {
|
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Key))); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if _, err := io.WriteString(w, string(t.Key)); err != nil {
|
||||||
if _, err := cw.Write(t.Key[:]); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2020,26 +2025,15 @@ func (t *EventEntry) UnmarshalCBOR(r io.Reader) (err error) {
|
|||||||
return fmt.Errorf("integer in input was too large for uint8 field")
|
return fmt.Errorf("integer in input was too large for uint8 field")
|
||||||
}
|
}
|
||||||
t.Flags = uint8(extra)
|
t.Flags = uint8(extra)
|
||||||
// t.Key ([]uint8) (slice)
|
// t.Key (string) (string)
|
||||||
|
|
||||||
maj, extra, err = cr.ReadHeader()
|
{
|
||||||
|
sval, err := cbg.ReadString(cr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if extra > cbg.ByteArrayMaxLen {
|
t.Key = string(sval)
|
||||||
return fmt.Errorf("t.Key: byte array too large (%d)", extra)
|
|
||||||
}
|
|
||||||
if maj != cbg.MajByteString {
|
|
||||||
return fmt.Errorf("expected byte array")
|
|
||||||
}
|
|
||||||
|
|
||||||
if extra > 0 {
|
|
||||||
t.Key = make([]uint8, extra)
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, err := io.ReadFull(cr, t.Key[:]); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
// t.Value ([]uint8) (slice)
|
// t.Value ([]uint8) (slice)
|
||||||
|
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package types
|
package types
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Event struct {
|
type Event struct {
|
||||||
// The ID of the actor that emitted this event.
|
// The ID of the actor that emitted this event.
|
||||||
Emitter address.Address
|
Emitter abi.ActorID
|
||||||
|
|
||||||
// Key values making up this event.
|
// Key values making up this event.
|
||||||
Entries []EventEntry
|
Entries []EventEntry
|
||||||
@ -17,7 +17,7 @@ type EventEntry struct {
|
|||||||
Flags uint8
|
Flags uint8
|
||||||
|
|
||||||
// The key of this event entry
|
// The key of this event entry
|
||||||
Key []byte
|
Key string
|
||||||
|
|
||||||
// Any DAG-CBOR encodeable type.
|
// Any DAG-CBOR encodeable type.
|
||||||
Value []byte
|
Value []byte
|
||||||
|
Loading…
Reference in New Issue
Block a user