-
Notifications
You must be signed in to change notification settings - Fork 117
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
feat(docs): compilation report #1309
Open
novusnota
wants to merge
5
commits into
main
Choose a base branch
from
closes-1094-comp-rep
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+144
−25
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2ad6e85
feat(docs): compilation report
novusnota 33a2ea7
fix: suggestions from the code review
novusnota 364e779
whoopsie
novusnota dd98e94
not a Tact signature, strictly speaking
novusnota e6eb264
Merge branch 'main' into closes-1094-comp-rep
anton-trunov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
--- | ||
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 [TL-B schemas][tlb] and signatures. | ||
|
||
For example: | ||
|
||
```md | ||
Total structures: 10 | ||
|
||
### StateInit | ||
TL-B: `_ code:^cell data:^cell = StateInit` | ||
Signature: `StateInit{code:^cell,data:^cell}` | ||
|
||
### StdAddress | ||
TL-B: `_ workchain:int8 address:uint256 = StdAddress` | ||
Signature: `StdAddress{workchain:int8,address:uint256}` | ||
|
||
...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: | ||
|
||
```md | ||
### Deploy | ||
TL-B: `deploy#946a98b6 queryId:uint64 = Deploy` | ||
Signature: `Deploy{queryId:uint64}` | ||
|
||
### Seven | ||
TL-B: `seven#00000007 = Seven` | ||
Signature: `Seven{}` | ||
``` | ||
|
||
#### 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} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should link this subsection from the exit codes page |
||
|
||
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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's
0x946a98b6
and0x00000007
are the opcodesfoobar#94609816