Skip to content

Commit d9808e0

Browse files
authored
Merge branch 'main' into tact-template-yaml
2 parents 792c196 + 63731b4 commit d9808e0

34 files changed

+510
-474
lines changed

dev-docs/CHANGELOG.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4747
- Better error message for `extend function without parameters` error: PR [#1624](https://github.com/tact-lang/tact/pull/1624)
4848
- Don't generate `lazy_deployment_completed` by default: PR [#1717](https://github.com/tact-lang/tact/pull/1717)
4949
- Optimized `emptyCell()` and `emptySlice()` functions: PR [#1696](https://github.com/tact-lang/tact/pull/1696)
50+
- Rearrange parameters of some asm methods in order described in `AsmShuffle`: PR [#1702](https://github.com/tact-lang/tact/pull/1702)
51+
- Error message for invalid type for function argument now shows expected type: PR [#1738](https://github.com/tact-lang/tact/pull/1738)
5052

5153
### Fixed
5254

@@ -85,13 +87,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8587
- Support overriding constants and methods of BaseTrait: PR [#1591](https://github.com/tact-lang/tact/pull/1591)
8688
- Forbid traits inherit implicitly from BaseTrait: PR [#1591](https://github.com/tact-lang/tact/pull/1591)
8789
- Forbid the `override` modifier for constants without the corresponding super-constant: PR [#1591](https://github.com/tact-lang/tact/pull/1591)
90+
- Remove "remainder" from error messages: PR [#1699](https://github.com/tact-lang/tact/pull/1699)
8891

8992
### Docs
9093

9194
- Added the `description` property to the frontmatter of the each page for better SEO: PR [#916](https://github.com/tact-lang/tact/pull/916)
9295
- Added Google Analytics tags per every page: PR [#921](https://github.com/tact-lang/tact/pull/921)
9396
- Added Ston.fi cookbook: PR [#956](https://github.com/tact-lang/tact/pull/956)
94-
- Added NFTs cookbook: PR [#958](https://github.com/tact-lang/tact/pull/958)
97+
- Added NFTs cookbook: PR [#958](https://github.com/tact-lang/tact/pull/958), PR [#1747](https://github.com/tact-lang/tact/pull/1747)
9598
- Added security best practices: PR [#1070](https://github.com/tact-lang/tact/pull/1070)
9699
- Added automatic links to Web IDE from all code blocks: PR [#994](https://github.com/tact-lang/tact/pull/994)
97100
- Added initial semi-automated Chinese translation of the documentation: PR [#942](https://github.com/tact-lang/tact/pull/942)

docs/src/content/docs/cookbook/nfts.mdx

+9-6
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ Notification message of assigned NFT ownership has the following structure:
1111

1212
```tact
1313
message(0x05138d91) NFTOwnershipAssigned {
14-
previousOwner: Address;
15-
forwardPayload: Slice as remaining;
14+
queryId: Int as uint64;
15+
previousOwner:Address;
16+
forwardPayload:Slice as remaining;
1617
}
1718
```
1819

@@ -32,8 +33,9 @@ Validation can be done in two ways:
3233
import "@stdlib/deploy";
3334
3435
message(0x05138d91) NFTOwnershipAssigned {
35-
previousOwner: Address;
36-
forwardPayload: Slice as remaining;
36+
queryId: Int as uint64;
37+
previousOwner:Address;
38+
forwardPayload:Slice as remaining;
3739
}
3840
3941
contract SingleNft with Deployable {
@@ -57,8 +59,9 @@ contract SingleNft with Deployable {
5759
import "@stdlib/deploy";
5860
5961
message(0x05138d91) NFTOwnershipAssigned {
60-
previousOwner: Address;
61-
forwardPayload: Slice as remaining;
62+
queryId: Int as uint64;
63+
previousOwner:Address;
64+
forwardPayload:Slice as remaining;
6265
}
6366
6467
struct NFTItemInitData {

docs/src/content/docs/zh-cn/book/cells.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ description: Cells、Builders 和 Slices 是 TON 区块链的底层单元
5555

5656
标准 [`Cell{:tact}`](#cells) 表示法是 [tvm.pdf](https://docs.ton.org/tvm.pdf) 中首次描述的 cells 通用序列化格式。 它的算法以八进制(字节)序列表示cell,首先将称为描述符的第一个 $2$ 字节序列化:
5757

58-
- _引用描述符_(Refs descriptor)根据以下公式计算:$r + 8 _ k + 32 _ l$,其中 $r$ 是 cell 中包含的引用数量(介于 $0$ 和 $4$ 之间),$k$ 是 cell 类型的标志($0$ 表示[普通](#cells-kinds),$1$ 表示[特殊](#cells-kinds)),$l$ 是
58+
- _引用描述符_(Refs descriptor)根据以下公式计算:$r + 8 _ k + 32 _ l$,其中 $r$ 是 cell 中包含的引用数量(介于 $0$ 和 $4$ 之间),$k$ 是 cell 类型的标志($0$ 表示[普通](#cells-kinds),$1$ 表示[特殊](#cells-kinds)),$l$ 是
5959
cell 的[层级](#cells-levels)(介于 $0$ 和 $3$ 之间)。
6060
- _位描述符_(Bits descriptor)根据以下公式计算:$\lfloor\frac{b}{8}\rfloor + \lceil\frac{b}{8}\rceil$,其中 $b$ 是 cell 中的位数(介于 $0$ 和 $1023$ 之间)。
6161

src/ast/ast.ts

-1
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ export type AstStatementCondition = {
269269
readonly condition: AstExpression;
270270
readonly trueStatements: readonly AstStatement[];
271271
readonly falseStatements: readonly AstStatement[] | null;
272-
readonly elseif: AstStatementCondition | null;
273272
readonly id: number;
274273
readonly loc: SrcInfo;
275274
};

src/ast/clone.ts

-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ export function cloneNode<T extends AstNode>(
4343
falseStatements: src.falseStatements
4444
? src.falseStatements.map(recurse)
4545
: null,
46-
elseif: src.elseif ? recurse(src.elseif) : null,
4746
});
4847
} else if (src.kind === "statement_block") {
4948
return cloneNode({

src/ast/compare.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -400,19 +400,16 @@ export class AstComparator {
400400
condition: cond1,
401401
trueStatements: true1,
402402
falseStatements: false1,
403-
elseif: condElseIf1,
404403
} = node1 as A.AstStatementCondition;
405404
const {
406405
condition: cond2,
407406
trueStatements: true2,
408407
falseStatements: false2,
409-
elseif: condElseIf2,
410408
} = node2 as A.AstStatementCondition;
411409
return (
412410
this.compare(cond1, cond2) &&
413411
this.compareArray(true1, true2) &&
414-
this.compareNullableArray(false1, false2) &&
415-
this.compareNullableNodes(condElseIf1, condElseIf2)
412+
this.compareNullableArray(false1, false2)
416413
);
417414
}
418415

src/ast/getAstSchema.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -333,19 +333,17 @@ export const getAstSchema = (
333333
expression,
334334
loc: toSrcInfo(loc),
335335
}),
336-
Condition: (
336+
StatementCondition: (
337337
condition: A.AstExpression,
338338
trueStatements: A.AstStatement[],
339339
falseStatements: A.AstStatement[] | null,
340-
elseif: A.AstStatementCondition | null,
341340
loc: Loc,
342341
): A.AstStatementCondition =>
343342
createNode<A.AstStatementCondition>({
344343
kind: "statement_condition",
345344
condition,
346345
trueStatements,
347346
falseStatements,
348-
elseif,
349347
loc: toSrcInfo(loc),
350348
}),
351349
StatementWhile: (

src/ast/hash.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,7 @@ export class AstHasher {
9090
const falseStatementsHash = node.falseStatements
9191
? this.hashStatements(node.falseStatements)
9292
: "null";
93-
const elseifHash = node.elseif
94-
? this.hash(node.elseif)
95-
: "null";
96-
return `${node.kind}|${this.hash(node.condition)}|${trueStatementsHash}|${falseStatementsHash}|${elseifHash}`;
93+
return `${node.kind}|${this.hash(node.condition)}|${trueStatementsHash}|${falseStatementsHash}`;
9794
}
9895
case "statement_while":
9996
return `${node.kind}|${this.hash(node.condition)}|${this.hashStatements(node.statements)}`;

src/ast/iterators.ts

-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ export function traverseAndCheck(
203203
traverseAndCheck(e, callback);
204204
});
205205
}
206-
if (node.elseif) traverseAndCheck(node.elseif, callback);
207206
break;
208207
case "statement_while":
209208
case "statement_until":

src/ast/rename.ts

-5
Original file line numberDiff line numberDiff line change
@@ -373,11 +373,6 @@ export class AstRenamer {
373373
falseStatements: stmt.falseStatements
374374
? this.renameStatements(stmt.falseStatements)
375375
: null,
376-
elseif: stmt.elseif
377-
? (this.renameStatement(
378-
stmt.elseif,
379-
) as A.AstStatementCondition)
380-
: null,
381376
};
382377
case "statement_while":
383378
case "statement_until":

src/cli/tact/index.ts

+20-46
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import { readFileSync } from "fs";
2-
import { basename, dirname, join, normalize, resolve } from "path";
3-
import { execFileSync } from "child_process";
4-
import { z, ZodError } from "zod";
1+
import { basename, dirname, normalize, resolve } from "path";
2+
import { ZodError } from "zod";
53
import { createNodeFileSystem } from "../../vfs/createNodeFileSystem";
64
import { createVirtualFileSystem } from "../../vfs/createVirtualFileSystem";
75
import { parseAndEvalExpression } from "../../optimizer/interpreter";
@@ -18,6 +16,7 @@ import { build } from "../../pipeline/build";
1816
import { TactErrorCollection } from "../../error/errors";
1917
import files from "../../stdlib/stdlib";
2018
import { cwd } from "process";
19+
import { getVersion, showCommit } from "../version";
2120

2221
export const main = async () => {
2322
const Log = CliLogger();
@@ -46,7 +45,7 @@ const processArgs = async (Errors: CliErrors, argv: string[]) => {
4645

4746
await parseArgs(Errors, Args);
4847
} else {
49-
showHelp();
48+
await showHelp();
5049
}
5150
};
5251

@@ -64,7 +63,7 @@ const ArgSchema = (Parser: ArgParser) => {
6463
.add(Parser.immediate).end;
6564
};
6665

67-
const showHelp = () => {
66+
const showHelp = async () => {
6867
console.log(`Usage
6968
$ tact [...flags] (--config CONFIG | FILE)
7069
@@ -81,7 +80,7 @@ Flags
8180
8281
Examples
8382
$ tact --version
84-
${getVersion()}
83+
${await getVersion()}
8584
8685
Learn more about Tact: https://docs.tact-lang.org
8786
Join Telegram group: https://t.me/tactlang
@@ -92,22 +91,23 @@ type Args = ArgConsumer<GetParserResult<ReturnType<typeof ArgSchema>>>;
9291

9392
const parseArgs = async (Errors: CliErrors, Args: Args) => {
9493
if (Args.single("help")) {
95-
if (noUnknownParams(Errors, Args)) {
96-
showHelp();
94+
if (await noUnknownParams(Errors, Args)) {
95+
await showHelp();
9796
}
9897
return;
9998
}
10099

101100
if (Args.single("version")) {
102-
if (noUnknownParams(Errors, Args)) {
103-
showVersion();
101+
if (await noUnknownParams(Errors, Args)) {
102+
console.log(await getVersion());
103+
showCommit();
104104
}
105105
return;
106106
}
107107

108108
const expression = Args.single("eval");
109109
if (expression) {
110-
if (noUnknownParams(Errors, Args)) {
110+
if (await noUnknownParams(Errors, Args)) {
111111
evaluate(expression);
112112
}
113113
return;
@@ -146,8 +146,8 @@ const parseArgs = async (Errors: CliErrors, Args: Args) => {
146146
return;
147147
}
148148

149-
if (noUnknownParams(Errors, Args)) {
150-
showHelp();
149+
if (await noUnknownParams(Errors, Args)) {
150+
await showHelp();
151151
}
152152
};
153153

@@ -228,7 +228,7 @@ const compile = async (
228228

229229
const stdlib = createVirtualFileSystem("@stdlib", files);
230230

231-
if (noUnknownParams(Errors, Args)) {
231+
if (await noUnknownParams(Errors, Args)) {
232232
// TODO: all flags on the cli should take precedence over flags in the config
233233
// Make a nice model for it instead of the current mess
234234
// Consider making overwrites right here or something.
@@ -306,7 +306,10 @@ const setConfigOptions = (config: Config, options: ExtraOptions): void => {
306306
}
307307
};
308308

309-
const noUnknownParams = (Errors: CliErrors, Args: Args): boolean => {
309+
const noUnknownParams = async (
310+
Errors: CliErrors,
311+
Args: Args,
312+
): Promise<boolean> => {
310313
const leftoverArgs = Args.leftover();
311314

312315
if (leftoverArgs.length === 0) {
@@ -316,25 +319,10 @@ const noUnknownParams = (Errors: CliErrors, Args: Args): boolean => {
316319
for (const argument of leftoverArgs) {
317320
Errors.unexpectedArgument(argument);
318321
}
319-
showHelp();
322+
await showHelp();
320323
return false;
321324
};
322325

323-
const showVersion = () => {
324-
console.log(getVersion());
325-
// if working inside a git repository
326-
// also print the current git commit hash
327-
try {
328-
const gitCommit = execFileSync("git", ["rev-parse", "HEAD"], {
329-
encoding: "utf8",
330-
stdio: ["ignore", "pipe", "ignore"],
331-
}).trim();
332-
console.log(`git commit: ${gitCommit}`);
333-
} finally {
334-
process.exit(0);
335-
}
336-
};
337-
338326
const evaluate = (expression: string) => {
339327
const result = parseAndEvalExpression(expression);
340328
switch (result.kind) {
@@ -348,17 +336,3 @@ const evaluate = (expression: string) => {
348336
}
349337
}
350338
};
351-
352-
const getVersion = () => {
353-
const packageSchema = z.object({
354-
version: z.string(),
355-
});
356-
357-
const packageJsonPath = join(__dirname, "..", "..", "..", "package.json");
358-
359-
const pkg = packageSchema.parse(
360-
JSON.parse(readFileSync(packageJsonPath, "utf-8")),
361-
);
362-
363-
return pkg.version;
364-
};

src/cli/unboc/index.ts

+3-17
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { execFileSync } from "child_process";
21
import { readFileSync } from "fs";
32
import { decompileAll } from "@tact-lang/opcode";
43
import { ArgConsumer } from "../arg-consumer";
54
import { ArgParser, GetParserResult } from "../arg-parser";
65
import { CliLogger } from "../logger";
76
import { UnbocErrors } from "./error-schema";
7+
import { showCommit } from "../version";
88

99
const unbocVersion = "0.0.1";
1010

@@ -72,7 +72,8 @@ const parseArgs = (Errors: UnbocErrors, Args: Args) => {
7272

7373
if (Args.single("version")) {
7474
if (noUnknownParams(Errors, Args)) {
75-
showVersion();
75+
console.log(unbocVersion);
76+
showCommit();
7677
}
7778
return;
7879
}
@@ -103,18 +104,3 @@ const noUnknownParams = (Errors: UnbocErrors, Args: Args): boolean => {
103104
showHelp();
104105
return false;
105106
};
106-
107-
const showVersion = () => {
108-
console.log(unbocVersion);
109-
// if working inside a git repository
110-
// also print the current git commit hash
111-
try {
112-
const gitCommit = execFileSync("git", ["rev-parse", "HEAD"], {
113-
encoding: "utf8",
114-
stdio: ["ignore", "pipe", "ignore"],
115-
}).trim();
116-
console.log(`git commit: ${gitCommit}`);
117-
} finally {
118-
process.exit(0);
119-
}
120-
};

src/cli/version.ts

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { join } from "path";
2+
import { execFileSync } from "child_process";
3+
import { z } from "zod";
4+
import { readFile } from "fs/promises";
5+
6+
const rootPath = join(__dirname, "..", "..");
7+
8+
export function showCommit() {
9+
// if working inside a git repository
10+
// also print the current git commit hash
11+
try {
12+
const gitCommit = execFileSync(
13+
"git",
14+
[`--git-dir=${join(rootPath, ".git")}`, "rev-parse", "HEAD"],
15+
{
16+
encoding: "utf8",
17+
stdio: ["ignore", "pipe", "ignore"],
18+
cwd: rootPath,
19+
},
20+
).trim();
21+
console.log(`git commit: ${gitCommit}`);
22+
} finally {
23+
process.exit(0);
24+
}
25+
}
26+
27+
export async function getVersion() {
28+
const packageSchema = z.object({
29+
version: z.string(),
30+
});
31+
32+
const packageJsonPath = join(rootPath, "package.json");
33+
34+
const pkg = packageSchema.parse(
35+
JSON.parse(await readFile(packageJsonPath, "utf-8")),
36+
);
37+
38+
return pkg.version;
39+
}

0 commit comments

Comments
 (0)