Skip to content
Open
Show file tree
Hide file tree
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
21 changes: 21 additions & 0 deletions src/boc/Cell.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,27 @@ class Cell {
this.isExotic = false;
}

/**
* @return {number}
*/
get max_refs() {
return 4;
}

/**
* @return {number}
*/
getFreeRefs() {
return this.max_refs - this.refs.length;
}

/**
* @return {number}
*/
getUsedRefs() {
return this.refs.length;
}

/**
* @param serializedBoc {string | Uint8Array} hex or bytearray
* @return {Cell[]} root cells
Expand Down
7 changes: 5 additions & 2 deletions src/contract/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,12 @@ class Contract {
} else {
commonMsgInfo.bits.writeBit(false);
}
// TODO we also should check for free refs here

if (body) {
if (commonMsgInfo.bits.getFreeBits() >= body.bits.getUsedBits()) {
if (
commonMsgInfo.bits.getFreeBits() >= body.bits.getUsedBits() &&
commonMsgInfo.getFreeRefs() >= body.getUsedRefs()
) {
commonMsgInfo.bits.writeBit(false);
commonMsgInfo.writeCell(body);
} else {
Expand Down