Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

abi.decodeMsg to always return tag when possible #231

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions abi/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,11 @@ func decodeMsg(tag tlb.Tag, name MsgOpName, bodyType any) msgDecoderFunc {
uintTag = pointer(uint32(readTag))
}
body := reflect.New(reflect.TypeOf(bodyType))
err = tlb.Unmarshal(cell, body.Interface())
if err == nil {
return uintTag, pointer(name), body.Elem().Interface(), nil
if err := tlb.Unmarshal(cell, body.Interface()); err != nil {
cell.ResetCounters()
return uintTag, nil, nil, err
}
cell.ResetCounters()
return nil, nil, nil, err
return uintTag, pointer(name), body.Elem().Interface(), nil
}
}

Expand Down Expand Up @@ -245,7 +244,7 @@ func (body ExtOutMsgBody) MarshalJSON() ([]byte, error) {

type msgDecoderFunc func(cell *boc.Cell) (*uint32, *MsgOpName, any, error)

// MessageDecoder takes in a message body as a cell and tries to decode it based on the contract type or the first 4 bytes.
// InternalMessageDecoder takes in a message body as a cell and tries to decode it based on the contract type or the first 4 bytes.
// It returns an opcode, an operation name and a decoded body.
func InternalMessageDecoder(cell *boc.Cell, interfaces []ContractInterface) (*MsgOpCode, *MsgOpName, any, error) {
if cell.BitsAvailableForRead() < 32 {
Expand Down
Loading