Skip to content

Commit

Permalink
implement marshal tlb for inMsgBody
Browse files Browse the repository at this point in the history
  • Loading branch information
erokhinav committed Oct 3, 2024
1 parent 7e3e5c2 commit 1390980
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions abi/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,26 @@ type InMsgBody struct {
Value any
}

func (body InMsgBody) MarshalTLB(c *boc.Cell, encoder *tlb.Encoder) error {
if body.SumType == EmptyMsgOp {
return nil
}
if body.SumType == UnknownMsgOp {
c, ok := body.Value.(*boc.Cell)
if !ok {
return fmt.Errorf("unknown MsgBody should be Cell")
}
return tlb.Marshal(c, body.Value)
}
if body.OpCode != nil {
err := c.WriteUint(uint64(*body.OpCode), 32)
if err != nil {
return err
}
}
return tlb.Marshal(c, body.Value)
}

func (body *InMsgBody) UnmarshalTLB(cell *boc.Cell, decoder *tlb.Decoder) error {
body.SumType = UnknownMsgOp
tag, name, value, err := InternalMessageDecoder(cell, nil)
Expand Down Expand Up @@ -139,7 +159,7 @@ func (body InMsgBody) MarshalJSON() ([]byte, error) {
return buf.Bytes(), nil
}
if KnownMsgInTypes[body.SumType] == nil {
return nil, fmt.Errorf("unknown MsgBosy type %v", body.SumType)
return nil, fmt.Errorf("unknown MsgBody type %v", body.SumType)
}
b, err := json.Marshal(body.Value)
if err != nil {
Expand Down Expand Up @@ -238,7 +258,7 @@ func (body ExtOutMsgBody) MarshalJSON() ([]byte, error) {
return buf.Bytes(), nil
}
if KnownMsgExtOutTypes[body.SumType] == nil {
return nil, fmt.Errorf("unknown MsgBosy type %v", body.SumType)
return nil, fmt.Errorf("unknown MsgBody type %v", body.SumType)
}
b, err := json.Marshal(body.Value)
if err != nil {
Expand Down

0 comments on commit 1390980

Please sign in to comment.