From 1390980f0d64de6a6c95db69cfaefbca05ecdbb1 Mon Sep 17 00:00:00 2001 From: Victoria Erokhina Date: Thu, 3 Oct 2024 19:42:40 +0000 Subject: [PATCH] implement marshal tlb for inMsgBody --- abi/messages.go | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/abi/messages.go b/abi/messages.go index 8b612397..89dfd16c 100644 --- a/abi/messages.go +++ b/abi/messages.go @@ -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) @@ -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 { @@ -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 {