Skip to content

Commit

Permalink
Merge pull request #116 from xssnick/v1-7-1
Browse files Browse the repository at this point in the history
Fixed internal message to cell either conditions
  • Loading branch information
xssnick authored May 16, 2023
2 parents e229d61 + c5e2365 commit 43ee8f9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<img align="right" width="425px" src="https://github.com/xssnick/props/blob/master/logoimg.png?raw=true">

[![Based on TON][ton-svg]][ton]
![Coverage](https://img.shields.io/badge/Coverage-72.4%25-brightgreen)
![Coverage](https://img.shields.io/badge/Coverage-72.3%25-brightgreen)

Golang library for interacting with TON blockchain.

Expand Down
13 changes: 9 additions & 4 deletions tlb/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,17 @@ func (m *InternalMessage) ToCell() (*cell.Cell, error) {
return nil, err
}

b.MustStoreBoolBit(true)
b.MustStoreRef(stateCell)
if int(b.BitsLeft())-2 < int(stateCell.BitsSize()) || int(b.RefsLeft())-1 < int(m.Body.RefsNum()) {
b.MustStoreBoolBit(true)
b.MustStoreRef(stateCell)
} else {
b.MustStoreBoolBit(false)
b.MustStoreBuilder(stateCell.ToBuilder())
}
}

if m.Body != nil {
if int(b.BitsLeft())-1 < int(m.Body.BitsSize()) {
if int(b.BitsLeft())-1 < int(m.Body.BitsSize()) || b.RefsLeft() < m.Body.RefsNum() {
b.MustStoreBoolBit(true)
b.MustStoreRef(m.Body)
} else {
Expand Down Expand Up @@ -242,7 +247,7 @@ func (m *ExternalMessage) ToCell() (*cell.Cell, error) {
return nil, fmt.Errorf("failed to serialize state init: %w", err)
}

if int(builder.BitsLeft())-2 < int(stateCell.BitsSize()) || int(builder.RefsLeft())-2 < int(m.Body.RefsNum()) {
if int(builder.BitsLeft())-2 < int(stateCell.BitsSize()) || int(builder.RefsLeft())-1 < int(m.Body.RefsNum()) {
builder.MustStoreBoolBit(true) // state as ref
builder.MustStoreRef(stateCell)
} else {
Expand Down

0 comments on commit 43ee8f9

Please sign in to comment.