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
13 changes: 13 additions & 0 deletions src/benchmarks/results_gas.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,19 @@
"claimWallet": "3984"
},
"summary": "80094"
},
{
"label": "Rewritten checkEitherForwardPayload in Tact",
"pr": "https://github.com/tact-lang/jetton/pull/181",
"gas": {
"transfer": "34098",
"mint": "18866",
"burn": "12846",
"discovery": "5945",
"reportBalance": "4308",
"claimWallet": "3984"
},
"summary": "80047"
}
]
}
16 changes: 5 additions & 11 deletions src/contracts/utils.tact
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
// SPDX-License-Identifier: MIT
// Copyright © 2025 TON Studio

asm fun checkEitherForwardPayload(forwardPayload: Slice) {
LDDICT // Throws 9 if Either bit = 1 and ref is not present
SWAP
ISNULL
<{
DROP
}> PUSHCONT
<{
ENDS // Also throws 9 if slice is not empty
}> PUSHCONT
IFELSE
inline fun checkEitherForwardPayload(forwardPayload: Slice) {
if (forwardPayload.preloadUint(1) == 1) {
let bitsAndRefs = calculateSliceBitsAndRefs(forwardPayload);
throwUnless(9, (bitsAndRefs.refs == 1) && (bitsAndRefs.bits == 1));
}
}

asm fun emptyAddress(): Address { b{00} PUSHSLICE }
Expand Down