@@ -843,7 +843,7 @@ fun slice.remainingBitsAndRefsCount(self): (int, int)
843843
844844/// Checks whether a slice is empty (i.e., contains no bits of data and no cell references).
845845@pure
846- fun slice.isEnd (self): bool
846+ fun slice.isEmpty (self): bool
847847 asm "SEMPTY";
848848
849849/// Checks whether a slice has no bits of data.
@@ -1311,14 +1311,53 @@ fun sendRawMessage(msg: cell, mode: int): void
13111311 Receiving and handling messages.
13121312*/
13131313
1314+ /// InMessage is an input for `onInternalMessage` — when your contract accepts a non-bounced message.
1315+ /// Internally, some data exist on the stack, some can be acquired with TVM instructions.
1316+ /// The compiler replaces `in.someField` and gets a value correctly.
1317+ /// Example:
1318+ /// ```
1319+ /// fun onInternalMessage(in: InMessage) {
1320+ /// in.senderAddress // actually calls `INMSG_SRC` asm instruction
1321+ /// in.body // actually gets from a TVM stack
1322+ /// ```
1323+ struct InMessage {
1324+ senderAddress: address; // an internal address from which the message arrived
1325+ valueCoins: coins; // ton amount attached to an incoming message
1326+ valueExtra: dict; // extra currencies attached to an incoming message
1327+ originalForwardFee: coins; // fee that was paid by the sender
1328+ createdLt: uint64; // logical time when a message was created
1329+ createdAt: uint32; // unixtime when a message was created
1330+ body: slice; // message body, parse it with `lazy AllowedMsg.fromSlice(in.body)`
1331+ }
1332+
1333+ /// InMessageBounced is an input for `onBouncedMessage`.
1334+ /// Very similar to a non-bounced input [InMessage].
1335+ /// Note, that `bouncedBody` is currently 256 bits: 0xFFFFFFFF + 224 bits from the originally sent message.
1336+ /// Parse it with care!
1337+ /// Example:
1338+ /// ```
1339+ /// fun onBouncedMessage(in: InMessageBounced) {
1340+ /// in.bouncedBody.skipBouncedPrefix();
1341+ /// val originalOpcode = in.bouncedBody.loadUint(32);
1342+ /// ```
1343+ struct InMessageBounced {
1344+ senderAddress: address; // an internal address from which the message was bounced
1345+ valueCoins: coins; // ton amount attached to a message
1346+ valueExtra: dict; // extra currencies attached to a message
1347+ originalForwardFee: coins; // comission that the sender has payed to send this message
1348+ createdLt: uint64; // logical time when a message was created (and bounced)
1349+ createdAt: uint32; // unixtime when a message was created (and bounced)
1350+ bouncedBody: slice; // currently 256 bits: 0xFFFFFFFF + 224 bits sent originally
1351+ }
1352+
13141353/// Skip 0xFFFFFFFF prefix (when a message is bounced).
13151354@pure
13161355fun slice.skipBouncedPrefix(mutate self): self
13171356 asm "32 LDU" "NIP";
13181357
13191358/// Load msgFlags from incoming message body (4 bits).
13201359@pure
1321- @deprecated("use `onInternalMessage(in: InMessage)` and `in.isBounced` instead of parsing msgCell manually")
1360+ @deprecated("use `onBouncedMessage` handler instead of parsing msgCell flags manually")
13221361fun slice.loadMessageFlags(mutate self): int
13231362 asm( -> 1 0) "4 LDU";
13241363
@@ -1349,3 +1388,4 @@ fun slice.skipMessageQueryId(mutate self): self
13491388fun builder.storeMessageQueryId(mutate self, queryId: int): self
13501389 asm(queryId self) "64 STU";
13511390
1391+
0 commit comments