Skip to content

Commit

Permalink
Merge branch 'main' into fast-check
Browse files Browse the repository at this point in the history
  • Loading branch information
xpyctumo authored Jan 20, 2025
2 parents 0d532ab + 9c12481 commit db495e8
Show file tree
Hide file tree
Showing 88 changed files with 2,789 additions and 1,534 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ dist/
coverage/
**/output/
src/test/**/output/
src/test/e2e-emulated/map-tests/build
src/func/funcfiftlib.js
**/grammar.ohm*.ts
**/grammar.ohm*.js
Expand All @@ -11,3 +12,4 @@ jest.setup.js
jest.globalSetup.js
jest.teardown.js
/docs
version.build.ts
8 changes: 1 addition & 7 deletions .github/workflows/tact.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
yarn gen
yarn build
- name: Check there are no errors to be fixed in package.json and no uncommited changes
- name: Check there are no errors to be fixed in package.json and no uncommitted changes
run: |
npm pkg fix && git diff --exit-code
Expand Down Expand Up @@ -98,12 +98,6 @@ jobs:
run: |
yarn knip
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
if: runner.os != 'Windows'
with:
scandir: "./scripts"

- name: Show an example .pkg file on Windows
if: runner.os == 'Windows'
run: |
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ output/
**/grammar.ohm-bundle.d.ts
src/func/funcfiftlib.wasm.js
src/test/contracts/pretty-printer-output
src/test/e2e-emulated/map-tests/build

2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
/src/grammar/prev/grammar.ohm-bundle.d.ts
/src/grammar/prev/grammar.ohm-bundle.js
src/grammar/next/grammar.ts
/src/imports/stdlib.ts
/src/stdlib/stdlib.ts
/grammar
/docs
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- 'The "remainder" field can only be the last field:' inspection now shows location: PR [#1300](https://github.com/tact-lang/tact/pull/1300)
- Forbid "remainder" field at the middle of a contract storage: PR [#1301](https://github.com/tact-lang/tact/pull/1301)
- Forbid the `override` modifier for functions without the corresponding super-function: PR [#1302](https://github.com/tact-lang/tact/pull/1302)
- Format empty blocks without extra empty line: PR [#1346](https://github.com/tact-lang/tact/pull/1346)
- Remove duplicate line and column info from error messages: PR [#1362](https://github.com/tact-lang/tact/pull/1362)
- Support `AstTypedParameter` AST node in pretty printer: PR [#1347](https://github.com/tact-lang/tact/pull/1347)

### Docs

Expand All @@ -77,6 +80,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added a note on 255 being the maximum number of messages that can be sent during action phase: PR [#1237](https://github.com/tact-lang/tact/pull/1237)
- Added onchain metadata creation for NFTs and Jettons to the cookbook: PR [#1236](https://github.com/tact-lang/tact/pull/1236)
- Document that identifiers cannot start with `__gen` or `__tact`, and cannot contain Unicode characters apart from the small subset `a-zA-Z0-9_`: PR [#1312](https://github.com/tact-lang/tact/pull/1312)
- Added signatures for map methods, such as `.get()`, `.exists()`, `.set()`, `.replace()`, `.replaceGet()`, `.del()`, `.isEmpty()`, `.deepEquals()`, `.asCell()`: PR [#1352](https://github.com/tact-lang/tact/pull/1352)
- Added a compilation-related page with the description of the compilation report: PR [#1309](https://github.com/tact-lang/tact/pull/1309)
- Documented `BaseTrait` and methods in stdlib code: PR [#1296](https://github.com/tact-lang/tact/pull/1296)

### Release contributors

Expand Down Expand Up @@ -821,7 +827,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Tact contracts are now [Argument-addressable](https://docs.tact-lang.org/evolution/OTP-005) meaning that they depend on init arguments and code hash only. Init function is now called when first valid message is received.
- Tact contracts are now [Argument-addressable](https://docs.tact-lang.org/ref/evolution/otp-005) meaning that they depend on init arguments and code hash only. Init function is now called when first valid message is received.
- Refactoring of allocator
- Moving contract's load function to the beginning of the execution
- Moving contract's save function to the end of the execution
Expand Down
2 changes: 1 addition & 1 deletion ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ This version will be the first stable release of TACT. It will be released when
- Ability to receive messages from other contracts
- Limited Strings and Maps support
- Importing `func` files
- [Arguments-addressable contracts](https://docs.tact-lang.org/evolution/OTP-005)
- [Arguments-addressable contracts](https://docs.tact-lang.org/ref/evolution/otp-005)
- TypeScript bindings for Node, Browser and React Native

## ✍️ Version v2
Expand Down
23 changes: 15 additions & 8 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
"Brujin",
"cleanall",
"codegen",
"comptime",
"Compilables",
"compilables",
"Compilables",
"comptime",
"Daniil",
"decompilation",
"decompile",
Expand All @@ -44,10 +44,10 @@
"elseifnot",
"forall",
"formedness",
"frontmatter",
"funcfiftlib",
"funcid",
"funs",
"frontmatter",
"Georgiy",
"getsimpleforwardfee",
"gettest",
Expand All @@ -56,6 +56,7 @@
"infixl",
"infixr",
"initof",
"Ints",
"ipfs",
"ipld",
"Jesús",
Expand Down Expand Up @@ -109,25 +110,29 @@
"stdlib",
"stmts",
"Ston",
"storer",
"struct",
"structs",
"styleguide",
"subtyping",
"supertypes",
"Tarjan",
"testdata",
"Topup",
"Toncoin",
"Toncoins",
"tonstudio",
"Topup",
"Trunov",
"typechecker",
"uintptr",
"uints",
"unboc",
"uninit",
"unixfs",
"untypable",
"varint",
"varuint",
"viiii",
"varint",
"storer",
"Ints",
Expand All @@ -150,18 +155,19 @@
"*.spec.ts.snap",
"node_modules",
"dist",
"func",
"grammar/sample.json",
"src/generator/writers/writeStdlib.ts",
"src/func/funcfiftlib.*",
"src/grammar/grammar.ohm-bundle.d.ts",
"src/grammar/test/items-native-fun-funcid.tact",
"src/grammar/test/items-asm-funs.tact",
"src/grammar/test-asm/*.tact",
"src/grammar/test-failed/funcid-*.tact",
"src/grammar/next/grammar.gg",
"src/grammar/next/grammar.ts",
"src/imports/stdlib.ts",
"/src/test/compilation-failed/const-eval-failed.spec.ts",
"src/stdlib/stdlib.ts",
"src/stdlib/stdlib/stdlib.fc",
"src/test/compilation-failed/const-eval-failed.spec.ts",
"src/test/e2e-emulated/address.spec.ts",
"src/test/e2e-emulated/intrinsics.spec.ts",
"src/test/e2e-emulated/optionals.spec.ts",
Expand All @@ -172,7 +178,8 @@
"src/test/compilation-fail/fail-const-eval.spec.ts",
"src/test/e2e-emulated/getter-names-conflict.spec.ts",
"src/test/exit-codes/contracts/compute-phase-errors.tact",
"stdlib/stdlib.fc",
"src/test/e2e-emulated/map-tests/build",
"src/test/e2e-emulated/map-tests/map-properties-key-value-types.ts",
"/docs"
]
}
5 changes: 3 additions & 2 deletions docs/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,11 @@ export default defineConfig({
label: 'Going places',
translations: { 'zh-CN': '前往各地' },
attrs: { class: 'sidebar-separator' },
link: 'book/deploy#',
link: 'book/compile#',
},
{ slug: 'book/deploy' },
{ slug: 'book/compile' },
{ slug: 'book/debug' },
{ slug: 'book/deploy' },
{ slug: 'book/upgrades' },
{ slug: 'book/import' },
{ slug: 'book/config' },
Expand Down
24 changes: 16 additions & 8 deletions docs/src/content/docs/book/cells.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,22 @@ contract SerializationExample {

There, `^cell`, `^builder` and `^slice` in [TL-B][tlb] syntax mean the reference to [`Cell{:tact}`](#cells), [`Builder{:tact}`](#builders) and [`Slice{:tact}`](#slices) values respectively, while the `remainder<…>` of `cell`, `builder` or `slice` tells that the given value would be stored as a `Slice{:tact}` directly and not as a reference.

Now, to give a real-world example, imagine that you need to notice and react to inbound [jetton][jetton] transfers in your smart contract. The appropriate [Message][message] structure for doing so would look something like this:
Now, to give a real-world example, imagine that you need to notice and react to inbound [Jetton][jetton] transfers in your smart contract. The appropriate [Message][message] structure for doing so would look like this:

```tact /remaining/
message(0x7362d09c) JettonTransferNotification {
queryId: Int as uint64; // arbitrary request number to prevent replay attacks
amount: Int as coins; // amount of jettons transferred
sender: Address; // address of the sender of the jettons
forwardPayload: Slice as remaining; // optional custom payload
// Unique identifier used to trace transactions across multiple contracts
// Defaults to 0, which means we don't mark messages to trace their chains
queryId: Int as uint64 = 0;
// Amount of Jettons transferred
amount: Int as coins;
// Address of the sender of the Jettons
sender: Address;
// Optional custom payload
forwardPayload: Slice as remaining;
}
```

Expand All @@ -197,9 +205,9 @@ receive(msg: JettonTransferNotification) {
}
```

Upon receiving a [jetton][jetton] transfer notification message, its cell body is converted into a [`Slice{:tact}`](#slices) and then parsed as a `JettonTransferNotification{:tact}` [Message][message]. At the end of this process, the `forwardPayload` will have all the remaining data of the original message cell.
Upon receiving a [Jetton][jetton] transfer notification message, its cell body is converted into a [`Slice{:tact}`](#slices) and then parsed as a `JettonTransferNotification{:tact}` [Message][message]. At the end of this process, the `forwardPayload` will have all the remaining data of the original message cell.

Here, it's not possible to violate the [jetton][jetton] standard by placing the `forwardPayload: Slice as remaining` field in any other position in the `JettonTransferNotification{:tact}` [Message][message]. That's because Tact prohibits usage of `as remaining{:tact}` for any but the last field of the [Structs][struct] and [Messages][message] to prevent misuse of the contract storage and reduce gas consumption.
Here, it's not possible to violate the [Jetton][jetton] standard by placing the `forwardPayload: Slice as remaining` field in any other position in the `JettonTransferNotification{:tact}` [Message][message]. That's because Tact prohibits usage of `as remaining{:tact}` for any but the last field of the [Structs][struct] and [Messages][message] to prevent misuse of the contract storage and reduce gas consumption.

:::note

Expand Down Expand Up @@ -436,10 +444,10 @@ let areSlicesNotEqual = aSlice.hash() != bSlice.hash(); // false
[struct]: /book/structs-and-messages#structs
[message]: /book/structs-and-messages#messages
[recv]: /book/contracts#receiver-functions
[jetton]: /cookbook/jettons

[tvm]: https://docs.ton.org/learn/tvm-instructions/tvm-overview
[tlb]: https://docs.ton.org/develop/data-formats/tl-b-language
[jetton]: https://docs.ton.org/develop/dapps/asset-processing/jettons
[sha-2]: https://en.wikipedia.org/wiki/SHA-2#Hash_standard

[quadtree]: https://en.wikipedia.org/wiki/Quadtree
Expand Down
125 changes: 125 additions & 0 deletions docs/src/content/docs/book/compile.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
---
title: Compilation
description: "How to compile Tact smart contracts, as well as details on the build artifacts that are provided."
prev:
link: /book/message-mode
label: Message mode
---

import { Badge } from '@astrojs/starlight/components';

:::note

This page is still being written as per [#1136](https://github.com/tact-lang/tact/issues/1136).

:::

The Tact compiler can produce various outputs, ranging from the [BoC](/book/cells#cells-boc) of the compiled contract to various supplementary files, such as the [compilation report](#report) or the [contract package](/ref/evolution/otp-006), which is the JSON file with the `.pkg` extension that one can use to [verify the smart contract's origin](https://verifier.ton.org).

With the proper [configuration settings](/book/config), you can customize the behavior of the compiler to skip the generation of some or all the [build artifacts](#artifacts), and even control the addition or exclusion of [getters for supported interfaces](/book/contracts#interfaces).

Since the Tact compiler is a command-line program, some of the configuration settings can be set directly. When inside a folder with a Tact-based project, such as one created using the [Blueprint](https://github.com/ton-org/blueprint) or from the [tact-template](https://github.com/tact-lang/tact-template), refer to the `npx tact --help{:shell}` command for further instructions.

## Build artifacts {#artifacts}

A number of build artifacts can be produced per compilation of each contract. Some of the artifacts can be omitted using [configuration settings](/book/config).

The location of the artifacts depends on the [`output`](/book/config#projects-output) field of the [`tact.config.json`](/book/config). In [Blueprint][bp]-based projects, `output` is not used and all generated files are always placed in `build/ProjectName/`.

### Compilation report, `.md` {#report}

Every markdown compilation report first features the name of the contract that it was prepared for and then the byte size of the contract compiled to [BoC](/book/cells#cells-boc).

The following sub-headings describe the respective sections of the `.md` report.

#### Structures {#structures}

<Badge text="Written as '# Types' prior to Tact 1.6" variant="tip" size="medium"/><p/>

The first section introduces the present structures, i.e. some of the [composite types](/book/types#composite-types), [Structs and Messages](/book/structs-and-messages) that are declared or imported directly in the contract code, as well as those exposed from the Core standard library.

Along with the number of structures present, each of the [Structs][struct] and [Messages][message] are described with their respective signatures and [TL-B schemas][tlb], which include the [message opcodes](/book/structs-and-messages#message-opcodes).

For example:

```md
Total structures: 10

### StateInit
TL-B: `_ code:^cell data:^cell = StateInit`
Signature: `StateInit{code:^cell,data:^cell}`

### Deploy
TL-B: `deploy#946a98b6 queryId:uint64 = Deploy`
Signature: `Deploy{queryId:uint64}`

...etc.
```

[TL-B schema][tlb] of each [Message][message] contains its opcode, which is handy for looking up the auto-generated opcodes as well as confirming the [manually provided ones](/book/structs-and-messages#message-opcodes). For example, the following [Message][message] declarations:

```tact
message GeneratedOpcode { }
message(0x12345678) ManuallySpecifiedOpcode { }
```

translate to their respective [TL-B schemas][tlb]:

```md
### GeneratedOpcode
TL-B: `generated_opcode#6dfea180 = GeneratedOpcode`
Signature: `GeneratedOpcode{}`

### ManuallySpecifiedOpcode
TL-B: `manually_specified_opcode#12345678 = ManuallySpecifiedOpcode`
Signature: `ManuallySpecifiedOpcode{}`
```

where `6dfea180` and `12345678` specified after the `#` in the [constructor definitions](https://docs.ton.org/v3/documentation/data-formats/tlb/tl-b-language#constructors) are opcodes written in hexadecimal notation, representing $32$-bit unsigned integers. Thus, the automatically generated `6dfea180` opcode of the `GeneratedOpcode{:tact}` [Message][message] represents the decimal value of $1845404032$, and the manually provided `12345678` opcode of the `ManuallySpecifiedOpcode{:tact}` [Message][message] represents the decimal value of $305419896$, and **not** $12345678$ as it might appear.

#### Get methods {#getters}

This section specifies the number of available get methods or [getter functions](/book/functions#getter-functions) and outlines them with their argument names, if any.

For example:

```md
Total get methods: 2

## lshift
Argument: x

## gas
```

There, the `lshift(){:tact}` getter has a single argument `x`, whereas the `gas(){:tact}` getter has no arguments.

#### Exit codes {#exit-codes}

This section lists all default [exit codes](/book/exit-codes), as well as those generated from the error messages of the [`require(){:tact}`](/ref/core-debug#require), along with those messages for your convenience.

For example:

```md
* 2: Stack underflow
* 3: Stack overflow
...etc.
* 135: Code of a contract was not found
* 42933: Hey, I'm the error message of require()
```

There, the [exit codes](/book/exit-codes) in the range from $0$ to $255$ are those reserved by TON Blockchain or Tact compiler, while the exit code of $42933$ is produced by the respective call to the [`require(){:tact}`](/ref/core-debug#require) function.

#### Trait inheritance diagram {#trait-diagram}

This section shows a [Mermaid][mm] diagram of inherited [traits](/book/types#traits), including the [`BaseTrait{:tact}`](/ref/core-base).

#### Contract inheritance diagram {#contract-diagram}

This section shows a [Mermaid][mm] diagram of [contract](/book/contracts) dependencies, i.e. the [traits](/book/types#traits) that it depends upon.

[struct]: /book/structs-and-messages#structs
[message]: /book/structs-and-messages#messages

[tlb]: https://docs.ton.org/develop/data-formats/tl-b-language
[mm]: https://mermaid.js.org/
4 changes: 2 additions & 2 deletions docs/src/content/docs/book/debug.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Debugging Tact contracts
description: "Various ways to reveal problems or bugs in Tact code"
title: Debugging and testing
description: "Various ways to reveal and prevent problems or bugs in Tact code"
---

import { LinkCard, CardGrid, Steps, Tabs, TabItem } from '@astrojs/starlight/components';
Expand Down
3 changes: 0 additions & 3 deletions docs/src/content/docs/book/deploy.mdx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
---
title: Deployment
description: "Common ways to deploy Tact contracts to testnet or mainnet of TON Blockchain"
prev:
link: /book/message-mode
label: Message mode
---

Tact Deployer is a small library that integrates with [TON Verifier](https://verifier.ton.org) that allows you to deploy your contracts safely using your favorite wallet without needing to manage keys or deploy contracts manually. Tact Deployer also automatically verifies your contract's source code and you can be sure that your compiler is not compromised.
Expand Down
Loading

0 comments on commit db495e8

Please sign in to comment.