diff --git a/CHANGELOG.md b/CHANGELOG.md index fcf9784e2..9a2183371 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Ability to specify a compile-time method ID expression for getters: PR [#922](https://github.com/tact-lang/tact/pull/922) and PR [#932](https://github.com/tact-lang/tact/pull/932) - Destructuring of structs and messages: PR [#856](https://github.com/tact-lang/tact/pull/856) - Docs: automatic links to Web IDE from all code blocks: PR [#994](https://github.com/tact-lang/tact/pull/994) +- The `SendDefaultMode` send mode constant to the standard library: PR [#1010](https://github.com/tact-lang/tact/pull/1010) - Docs: initial semi-automated Chinese translation of the documentation: PR [#942](https://github.com/tact-lang/tact/pull/942) - The `replace` and `replaceGet` methods for the `Map` type: PR [#941](https://github.com/tact-lang/tact/pull/941) diff --git a/docs/grammars/grammar-tact.json b/docs/grammars/grammar-tact.json index a1861e2c9..3e3aefdd2 100644 --- a/docs/grammars/grammar-tact.json +++ b/docs/grammars/grammar-tact.json @@ -293,7 +293,7 @@ }, { "comment": "Other constants from the core library", - "match": "(? `SendDefaultMode{:tact}` | Ordinary message (default). $64$ | `SendRemainingValue{:tact}` | Carry all the remaining value of the inbound message in addition to the value initially indicated in the new message. $128$ | `SendRemainingBalance{:tact}` | Carry all the remaining balance of the current smart contract instead of the value originally indicated in the message. diff --git a/src/imports/stdlib.ts b/src/imports/stdlib.ts index defde7255..516eacf2e 100644 --- a/src/imports/stdlib.ts +++ b/src/imports/stdlib.ts @@ -278,32 +278,33 @@ files['std/reserve.tact'] = files['std/send.tact'] = 'YXNtIGZ1biBuYXRpdmVTZW5kTWVzc2FnZShjZWxsOiBDZWxsLCBtb2RlOiBJbnQpIHsgU0VORFJBV01TRyB9Cgphc20gZnVuIG5hdGl2ZVNlbmRNZXNzYWdlUmV0dXJu' + 'Rm9yd2FyZEZlZShtc2c6IENlbGwsIG1vZGU6IEludCk6IEludCB7IFNFTkRNU0cgfQoKY29uc3Qg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F0ZWRfYXQ6dWludDMyCiAgICAvLyAgICAgICAgICAgICAgICAgICAgIG1heWJlOiBzdGF0ZUluaXQgKGZhbHNlKSBib2R5UmVmOiBib29sICh0cnVlKQogICAgbGV0' + + 'IGM6IENlbGwgPSBiZWdpbkNlbGwoKQogICAgICAgIC5zdG9yZVVpbnQoMTUyMTE4MDcyMDI3Mzg3NTI4MTc5NjA0Mzg0NjQ1MTMsIDEwNCkKICAgICAgICAuc3RvcmVS' + + 'ZWYoYm9keSkKICAgICAgICAuZW5kQ2VsbCgpOwogICAgbmF0aXZlU2VuZE1lc3NhZ2UoYywgMCk7Cn0KCmFzbSBmdW4gYWNjZXB0TWVzc2FnZSgpIHsgQUNDRVBUIH0K' + + 'CmFzbSBmdW4gY29tbWl0KCkgeyBDT01NSVQgfQo='; files['std/text.tact'] = 'Ly8KLy8gU3RyaW5nIGJ1aWxkZXIKLy8KCkBuYW1lKF9fdGFjdF9zdHJpbmdfYnVpbGRlcl9zdGFydF9zdHJpbmcpCm5hdGl2ZSBiZWdpblN0cmluZygpOiBTdHJpbmdC' + 'dWlsZGVyOwoKQG5hbWUoX190YWN0X3N0cmluZ19idWlsZGVyX3N0YXJ0X2NvbW1lbnQpCm5hdGl2ZSBiZWdpbkNvbW1lbnQoKTogU3RyaW5nQnVpbGRlcjsKCkBuYW1l' + diff --git a/stdlib/std/send.tact b/stdlib/std/send.tact index 3c740e31a..276814c43 100644 --- a/stdlib/std/send.tact +++ b/stdlib/std/send.tact @@ -4,6 +4,7 @@ asm fun nativeSendMessageReturnForwardFee(msg: Cell, mode: Int): Int { SENDMSG } const SendRemainingBalance: Int = 128; const SendRemainingValue: Int = 64; +const SendDefaultMode: Int = 0; const SendIgnoreErrors: Int = 2; const SendPayGasSeparately: Int = 1; const SendDestroyIfZero: Int = 32;