Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: switch from + to | for send modes #274

Merged
merged 3 commits into from
Apr 22, 2024
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `newAddress` function now evaluates to a constant value if possible: PR [#237](https://github.com/tact-lang/tact/pull/237)
- The `dump()` and `dumpStack()` functions now print the file path, line number, and column number in addition to the data: PR [#271](https://github.com/tact-lang/tact/pull/271).
- `pow` function is now in the standard library, allowing its use at runtime. If constant arguments are used, the result is evaluated at compile-time: PR [#267](https://github.com/tact-lang/tact/pull/267)
- Use `|` instead of `+` for send mode flags because the bitwise OR operation is idempotent and hence safer: PR [#274](https://github.com/tact-lang/tact/pull/274)

### Fixed

Expand Down
4 changes: 2 additions & 2 deletions examples/multisig.tact
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ contract MultisigSigner {
send(SendParameters{
value: 0,
to: self.master,
mode: SendRemainingBalance + SendIgnoreErrors,
mode: SendRemainingBalance | SendIgnoreErrors,
bounce: false,
body: Signed{ request: self.request }.toCell()
});
Expand Down Expand Up @@ -95,7 +95,7 @@ contract Multisig {
send(SendParameters{
value: 0,
to: opAddress,
mode: SendRemainingValue + SendIgnoreErrors,
mode: SendRemainingValue | SendIgnoreErrors,
bounce: true,
code: opInit.code,
data: opInit.data
Expand Down
6 changes: 3 additions & 3 deletions examples/payouts.tact
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ contract Payouts with OwnableTransferable {
send(SendParameters{
to: address,
value: 0,
mode: SendRemainingValue + SendIgnoreErrors,
mode: SendRemainingValue | SendIgnoreErrors,
bounce: true,
body: CanPayout{amount: amount}.toCell()
});
Expand All @@ -102,15 +102,15 @@ contract Payouts with OwnableTransferable {
send(SendParameters{
to: msg.address,
value: msg.amount,
mode: SendRemainingValue + SendIgnoreErrors,
mode: SendRemainingValue | SendIgnoreErrors,
bounce: false,
body: "Success".asComment()
});
} else {
send(SendParameters{
to: msg.address,
value: 0,
mode: SendRemainingValue + SendIgnoreErrors,
mode: SendRemainingValue | SendIgnoreErrors,
bounce: false,
body: "Already paid".asComment()
});
Expand Down
4 changes: 2 additions & 2 deletions src/imports/stdlib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ files['std/base.tact'] =
'ICAgICBsZXQgY3R4OiBDb250ZXh0ID0gY29udGV4dCgpOwogICAgICAgICAgICBsZXQgYmFsYW5jZTogSW50ID0gbXlCYWxhbmNlKCk7CiAgICAgICAgICAgIGxldCBi' +
'YWxhbmNlQmVmb3JlTWVzc2FnZTogSW50ID0gYmFsYW5jZSAtIGN0eC52YWx1ZTsKICAgICAgICAgICAgaWYgKGJhbGFuY2VCZWZvcmVNZXNzYWdlIDwgc2VsZi5zdG9y' +
'YWdlUmVzZXJ2ZSkgewogICAgICAgICAgICAgICAgbmF0aXZlUmVzZXJ2ZShzZWxmLnN0b3JhZ2VSZXNlcnZlLCBSZXNlcnZlRXhhY3QpOwogICAgICAgICAgICAgICAg' +
'c2VuZChTZW5kUGFyYW1ldGVyc3tib3VuY2U6IGJvdW5jZSwgdG86IHRvLCB2YWx1ZTogMCwgbW9kZTogU2VuZFJlbWFpbmluZ0JhbGFuY2UgKyBTZW5kSWdub3JlRXJy' +
'c2VuZChTZW5kUGFyYW1ldGVyc3tib3VuY2U6IGJvdW5jZSwgdG86IHRvLCB2YWx1ZTogMCwgbW9kZTogU2VuZFJlbWFpbmluZ0JhbGFuY2UgfCBTZW5kSWdub3JlRXJy' +
'b3JzLCBib2R5OiBib2R5LCBjb2RlOiBjb2RlLCBkYXRhOiBkYXRhIH0pOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICB9CiAgICAgICAgfQoKICAg' +
'ICAgICAvLyBKdXN0IHNlbmQgd2l0aCByZW1haW5pbmcgYmFsYW5jZQogICAgICAgIHNlbmQoU2VuZFBhcmFtZXRlcnN7Ym91bmNlOiBib3VuY2UsIHRvOiB0bywgdmFs' +
'dWU6IDAsIG1vZGU6IFNlbmRSZW1haW5pbmdWYWx1ZSArIFNlbmRJZ25vcmVFcnJvcnMsIGJvZHk6IGJvZHksIGNvZGU6IGNvZGUsIGRhdGE6IGRhdGEgfSk7CiAgICB9' +
'dWU6IDAsIG1vZGU6IFNlbmRSZW1haW5pbmdWYWx1ZSB8IFNlbmRJZ25vcmVFcnJvcnMsIGJvZHk6IGJvZHksIGNvZGU6IGNvZGUsIGRhdGE6IGRhdGEgfSk7CiAgICB9' +
'Cn0=';
files['std/cells.tact'] =
'Ly8KLy8gQnVpbGRlcgovLwoKQG5hbWUoYmVnaW5fY2VsbCkKbmF0aXZlIGJlZ2luQ2VsbCgpOiBCdWlsZGVyOwoKQG5hbWUoc3RvcmVfaW50KQpleHRlbmRzIG5hdGl2' +
Expand Down
2 changes: 1 addition & 1 deletion src/test/bugs/issue43.tact
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ trait Jetton with Ownable {
to: msg.response_destination!!,
value: 0,
bounce: false,
mode: SendRemainingValue + SendIgnoreErrors,
mode: SendRemainingValue | SendIgnoreErrors,
body: TokenExcesses{
queryId: msg.queryId
}.toCell()
Expand Down
6 changes: 3 additions & 3 deletions src/test/features/deep-sequence.tact
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ contract A {
send(SendParameters{
value: 0,
to: address,
mode: SendRemainingValue + SendIgnoreErrors,
mode: SendRemainingValue | SendIgnoreErrors,
bounce: true,
code: init.code,
data: init.data,
Expand All @@ -35,7 +35,7 @@ contract B {
send(SendParameters{
value: 0,
to: address,
mode: SendRemainingValue + SendIgnoreErrors,
mode: SendRemainingValue | SendIgnoreErrors,
bounce: true,
code: init.code,
data: init.data,
Expand All @@ -60,7 +60,7 @@ contract C {
send(SendParameters{
value: 0,
to: address,
mode: SendRemainingValue + SendIgnoreErrors,
mode: SendRemainingValue | SendIgnoreErrors,
bounce: true,
code: init.code,
data: init.data,
Expand Down
4 changes: 2 additions & 2 deletions stdlib/std/base.tact
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ trait BaseTrait {
let balanceBeforeMessage: Int = balance - ctx.value;
if (balanceBeforeMessage < self.storageReserve) {
nativeReserve(self.storageReserve, ReserveExact);
send(SendParameters{bounce: bounce, to: to, value: 0, mode: SendRemainingBalance + SendIgnoreErrors, body: body, code: code, data: data });
send(SendParameters{bounce: bounce, to: to, value: 0, mode: SendRemainingBalance | SendIgnoreErrors, body: body, code: code, data: data });
return;
}
}

// Just send with remaining balance
send(SendParameters{bounce: bounce, to: to, value: 0, mode: SendRemainingValue + SendIgnoreErrors, body: body, code: code, data: data });
send(SendParameters{bounce: bounce, to: to, value: 0, mode: SendRemainingValue | SendIgnoreErrors, body: body, code: code, data: data });
}
}
Loading