diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ff5389c9..e06c944f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -81,7 +81,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - 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) +- Added a compilation-related page with the description of the compilation report: PR [#1309](https://github.com/tact-lang/tact/pull/1309), PR [#1387](https://github.com/tact-lang/tact/pull/1387) - Documented `BaseTrait` and methods in stdlib code: PR [#1296](https://github.com/tact-lang/tact/pull/1296) ### Release contributors diff --git a/docs/src/assets/contract-dependency-diagram-2.png b/docs/src/assets/contract-dependency-diagram-2.png new file mode 100644 index 000000000..9eedf5cc8 Binary files /dev/null and b/docs/src/assets/contract-dependency-diagram-2.png differ diff --git a/docs/src/assets/contract-dependency-diagram-3.png b/docs/src/assets/contract-dependency-diagram-3.png new file mode 100644 index 000000000..cb523b3d9 Binary files /dev/null and b/docs/src/assets/contract-dependency-diagram-3.png differ diff --git a/docs/src/assets/contract-dependency-diagram.png b/docs/src/assets/contract-dependency-diagram.png new file mode 100644 index 000000000..ff5552931 Binary files /dev/null and b/docs/src/assets/contract-dependency-diagram.png differ diff --git a/docs/src/assets/trait-inheritance-diagram.png b/docs/src/assets/trait-inheritance-diagram.png new file mode 100644 index 000000000..46975ba49 Binary files /dev/null and b/docs/src/assets/trait-inheritance-diagram.png differ diff --git a/docs/src/content/docs/book/compile.mdx b/docs/src/content/docs/book/compile.mdx index 0c214b0fd..d310e0afd 100644 --- a/docs/src/content/docs/book/compile.mdx +++ b/docs/src/content/docs/book/compile.mdx @@ -112,14 +112,43 @@ There, the [exit codes](/book/exit-codes) in the range from $0$ to $255$ are tho #### 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). +This section shows a [Mermaid][mm] diagram of [inherited traits](/book/contracts#traits), including the [`BaseTrait{:tact}`](/ref/core-base). -#### Contract inheritance diagram {#contract-diagram} +For example: + +![Trait inheritance diagram](/src/assets/trait-inheritance-diagram.png) + +There, [`JettonWallet`][code-jetton-wallet] inherits the `WalletExitcodes` and `GasConstant` traits, and all inherit the [`BaseTrait{:tact}`](/ref/core-base). + +#### Contract dependency diagram {#contract-diagram} + +This section shows a [Mermaid][mm] diagram of [contract](/book/contracts) dependencies, i.e. any calls to [`initOf{:tact}`](/book/expressions#initof) in order to compute the initial state of other contracts. + +If the contract has no dependencies, only its name is displayed: + +![Contract dependency diagram without dependencies](/src/assets/contract-dependency-diagram.png) + +However, if the contract, say `FirstOne`, somewhere in its code computes the [initial state](/book/expressions#initof) of another contract, say `SecondOne`, such a relationship is shown in the diagram: -This section shows a [Mermaid][mm] diagram of [contract](/book/contracts) dependencies, i.e. the [traits](/book/types#traits) that it depends upon. +![Contract dependency diagram with a single dependency](/src/assets/contract-dependency-diagram-2.png) + +A real-world example of this would be the [`JettonMinter`][code-jetton-minter] contract, commonly referred to as the [Jetton Master](/cookbook/jettons#jetton-master-contract). Often, `JettonMinter` needs the [initial state](/book/expressions#initof) of the [`JettonWallet`][code-jetton-wallet], which is why `JettonMinter` defines the following [internal function](/book/contracts#internal-functions): + +```tact +inline fun getJettonWalletInit(address: Address): StateInit { + return initOf JettonWallet(address, myAddress()); +} +``` + +Thus, the following dependency diagram is produced: + +![Contract dependency diagram of the JettonMinter](/src/assets/contract-dependency-diagram-3.png) [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/ + +[code-jetton-wallet]: https://github.com/tact-lang/jetton/blob/ef802f95c967f2fd37e80893845c3c3ed7c34c78/sources/jetton_wallet.tact +[code-jetton-minter]: https://github.com/tact-lang/jetton/blob/ef802f95c967f2fd37e80893845c3c3ed7c34c78/sources/jetton_minter_discoverable.tact diff --git a/docs/src/content/docs/book/contracts.mdx b/docs/src/content/docs/book/contracts.mdx index cacab40c2..7aae8237b 100644 --- a/docs/src/content/docs/book/contracts.mdx +++ b/docs/src/content/docs/book/contracts.mdx @@ -33,7 +33,7 @@ Each contract can contain: * [Receiver functions](#receiver-functions) * [Internal functions](#internal-functions) -### Inherited traits, `with{:tact}` {#traits} +### Inherited traits, `with` {#traits} Contracts can inherit all the declarations and definitions from [traits][trait] and override some of their default behaviours. In addition to that, every contract and trait implicitly inherits the special [`BaseTrait{:tact}` trait](/ref/core-base).