@ton/blueprint 0.19.0 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,29 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.20.0] - 2024-05-07
9
+
10
+ ### Added
11
+
12
+ - Added auto-sourcing of root `tact.config.json` files for merging compilation options with `wrappers/*.compile.ts`
13
+ - Added a warning for disabling `debug` in contract wrappers of Tact before doing production deployments
14
+
15
+ ### Changed
16
+
17
+ - Changed `@tact-lang/compiler` dependency to be `^1.3.0` instead of `^1.2.0`
18
+ - Changed `compile.ts.template` template for Tact to have `debug` set to `true` by default
19
+ - Changed `contract.tact.template` empty template for Tact to mention implicit empty `init()` function
20
+
21
+ ## [0.19.1] - 2024-04-12
22
+
23
+ ### Fixed
24
+
25
+ - Fixed `verify` command
26
+
27
+ ### Changed
28
+
29
+ - Updated readme to reflect the fact that blueprint no longer automatically adds `jsonRPC` to custom v2 endpoints
30
+
8
31
  ## [0.19.0] - 2024-03-27
9
32
 
10
33
  ### Changed
package/README.md CHANGED
@@ -30,7 +30,7 @@ npm create ton@latest
30
30
  ### Requirements
31
31
 
32
32
  * [Node.js](https://nodejs.org) with a recent version like v18, verify version with `node -v`
33
- * IDE with TypeScript and FunC support like [Visual Studio Code](https://code.visualstudio.com/) with the [FunC plugin](https://marketplace.visualstudio.com/items?itemName=tonwhales.func-vscode) or [IntelliJ Idea](https://www.jetbrains.com/idea/) with the [TON Development plugin](https://plugins.jetbrains.com/plugin/18541-ton-development)
33
+ * IDE with TypeScript and FunC support like [Visual Studio Code](https://code.visualstudio.com/) with the [FunC plugin](https://marketplace.visualstudio.com/items?itemName=tonwhales.func-vscode) or [IntelliJ IDEA](https://www.jetbrains.com/idea/) with the [TON Development plugin](https://plugins.jetbrains.com/plugin/23382-ton)
34
34
 
35
35
   
36
36
 
@@ -143,7 +143,7 @@ import { Config } from '@ton/blueprint';
143
143
 
144
144
  export const config: Config = {
145
145
  network: {
146
- endpoint: 'https://toncenter.com/api/v2/',
146
+ endpoint: 'https://toncenter.com/api/v2/jsonRPC',
147
147
  type: 'mainnet',
148
148
  version: 'v2',
149
149
  key: 'YOUR_API_KEY',
@@ -153,11 +153,17 @@ export const config: Config = {
153
153
 
154
154
  The above config parameters are equivalent to the arguments in the following command:
155
155
  ```bash
156
- npx blueprint run --custom https://toncenter.com/api/v2/ --custom-version v2 --custom-type mainnet --custom-key YOUR_API_KEY
156
+ npx blueprint run --custom https://toncenter.com/api/v2/jsonRPC --custom-version v2 --custom-type mainnet --custom-key YOUR_API_KEY
157
157
  ```
158
158
 
159
159
  Properties of the `network` object have the same semantics as the `--custom` flags with respective names (see `blueprint help run`).
160
160
 
161
+ You can also use custom network to verify contracts, like so:
162
+ ```bash
163
+ npx blueprint verify --custom https://toncenter.com/api/v2/jsonRPC --custom-version v2 --custom-type mainnet --custom-key YOUR_API_KEY
164
+ ```
165
+ (or similarly using the config), however custom type MUST be specified as either `mainnet` or `testnet` when verifying.
166
+
161
167
  ## Contributors
162
168
 
163
169
  Special thanks to [@qdevstudio](https://t.me/qdevstudio) for their logo for blueprint.
package/dist/build.js CHANGED
@@ -26,13 +26,17 @@ async function buildOne(contract, ui) {
26
26
  });
27
27
  await promises_1.default.writeFile(k, v);
28
28
  }
29
+ if (result.options !== undefined && result.options?.debug === true) {
30
+ ui?.clearActionPrompt();
31
+ ui?.write('\n⚠️ Make sure to disable debug mode in contract wrappers before doing production deployments!');
32
+ }
29
33
  }
30
34
  const cell = result.code;
31
35
  const rHash = cell.hash();
32
36
  const res = {
33
37
  hash: rHash.toString('hex'),
34
38
  hashBase64: rHash.toString('base64'),
35
- hex: cell.toBoc().toString('hex')
39
+ hex: cell.toBoc().toString('hex'),
36
40
  };
37
41
  ui?.clearActionPrompt();
38
42
  ui?.write('\n✅ Compiled successfully! Cell BOC result:\n\n');
@@ -13,7 +13,7 @@ const utils_1 = require("../utils");
13
13
  const arg_1 = __importDefault(require("arg"));
14
14
  const backends = {
15
15
  mainnet: {
16
- verifierRegistry: core_1.Address.parse('EQDS0AW7NV1w3nFwx-mmryfpH4OGQ3PXnoFGOJA_8PTHuLrw'),
16
+ sourceRegistry: core_1.Address.parse('EQD-BJSVUJviud_Qv7Ymfd3qzXdrmV525e3YDzWQoHIAiInL'),
17
17
  backends: [
18
18
  'https://ton-source-prod-1.herokuapp.com',
19
19
  'https://ton-source-prod-2.herokuapp.com',
@@ -22,7 +22,7 @@ const backends = {
22
22
  id: 'orbs.com',
23
23
  },
24
24
  testnet: {
25
- verifierRegistry: core_1.Address.parse('EQB--CRXUbqYbqJKScEWeOrnk0TKJxB071M-WwvMpMEvq6Ed'),
25
+ sourceRegistry: core_1.Address.parse('EQCsdKYwUaXkgJkz2l0ol6qT_WxeRbE_wBCwnEybmR0u5TO8'),
26
26
  backends: ['https://ton-source-prod-testnet-1.herokuapp.com'],
27
27
  id: 'orbs-testnet',
28
28
  },
@@ -58,6 +58,15 @@ class VerifierRegistry {
58
58
  });
59
59
  }
60
60
  }
61
+ class SourceRegistry {
62
+ constructor(address) {
63
+ this.address = address;
64
+ }
65
+ async getVerifierRegistry(provider) {
66
+ const { stack } = await provider.get('get_verifier_registry_address', []);
67
+ return stack.readAddress();
68
+ }
69
+ }
61
70
  async function lookupCodeHash(hash, ui, retryCount = 5) {
62
71
  let queryResponse;
63
72
  let foundAddr;
@@ -210,7 +219,8 @@ const verify = async (args, ui, context) => {
210
219
  type: 'application/json',
211
220
  }), 'blob');
212
221
  const backend = backends[network];
213
- const verifierRegistry = networkProvider.open(new VerifierRegistry(backend.verifierRegistry));
222
+ const sourceRegistry = networkProvider.open(new SourceRegistry(backend.sourceRegistry));
223
+ const verifierRegistry = networkProvider.open(new VerifierRegistry(await sourceRegistry.getVerifierRegistry()));
214
224
  const verifier = (await verifierRegistry.getVerifiers()).find((v) => v.name === backend.id);
215
225
  if (verifier === undefined) {
216
226
  throw new Error('Could not find verifier');
@@ -248,7 +258,7 @@ const verify = async (args, ui, context) => {
248
258
  }
249
259
  const c = core_1.Cell.fromBoc(Buffer.from(msgCell.data))[0];
250
260
  await networkProvider.sender().send({
251
- to: backend.verifierRegistry,
261
+ to: verifierRegistry.address,
252
262
  value: (0, core_1.toNano)('0.5'),
253
263
  body: c,
254
264
  });
@@ -1,6 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import { SourcesArray } from '@ton-community/func-js';
3
3
  import { Cell } from '@ton/core';
4
+ import { TactCompilerConfig } from './CompilerConfig';
4
5
  export type FuncCompileResult = {
5
6
  lang: 'func';
6
7
  code: Cell;
@@ -12,6 +13,7 @@ export type TactCompileResult = {
12
13
  lang: 'tact';
13
14
  fs: Map<string, Buffer>;
14
15
  code: Cell;
16
+ options?: TactCompilerConfig['options'];
15
17
  };
16
18
  export type CompileResult = TactCompileResult | FuncCompileResult;
17
19
  export declare function doCompile(name: string, opts?: CompileOpts): Promise<CompileResult>;
@@ -32,7 +32,7 @@ const fs_1 = require("fs");
32
32
  const path_1 = __importDefault(require("path"));
33
33
  const core_1 = require("@ton/core");
34
34
  const paths_1 = require("../paths");
35
- const compiler_1 = require("@tact-lang/compiler");
35
+ const Tact = __importStar(require("@tact-lang/compiler"));
36
36
  const OverwritableVirtualFileSystem_1 = require("./OverwritableVirtualFileSystem");
37
37
  async function getCompilerConfigForContract(name) {
38
38
  var _a;
@@ -74,18 +74,32 @@ function findTactBoc(fs) {
74
74
  }
75
75
  return core_1.Cell.fromBoc(buf)[0];
76
76
  }
77
+ function getRootTactConfigOptionsForContract(name) {
78
+ if (!(0, fs_1.existsSync)(paths_1.TACT_ROOT_CONFIG)) {
79
+ return undefined;
80
+ }
81
+ const config = Tact.parseConfig((0, fs_1.readFileSync)(paths_1.TACT_ROOT_CONFIG).toString());
82
+ for (const project of config.projects) {
83
+ if (project.name === name) {
84
+ return project.options;
85
+ }
86
+ }
87
+ return undefined;
88
+ }
77
89
  async function doCompileTact(config, name) {
90
+ const rootConfigOptions = getRootTactConfigOptionsForContract(name);
78
91
  const fs = new OverwritableVirtualFileSystem_1.OverwritableVirtualFileSystem(process.cwd());
79
- const res = await (0, compiler_1.build)({
92
+ const buildConfig = {
80
93
  config: {
81
94
  name: 'tact',
82
95
  path: config.target,
83
96
  output: path_1.default.join(paths_1.BUILD_DIR, name),
84
- options: config.options,
97
+ options: { ...rootConfigOptions, ...config.options },
85
98
  },
86
99
  stdlib: '/stdlib',
87
100
  project: fs,
88
- });
101
+ };
102
+ const res = await Tact.build(buildConfig);
89
103
  if (!res) {
90
104
  throw new Error('Could not compile tact');
91
105
  }
@@ -94,6 +108,7 @@ async function doCompileTact(config, name) {
94
108
  lang: 'tact',
95
109
  fs: fs.overwrites,
96
110
  code,
111
+ options: buildConfig.config.options,
97
112
  };
98
113
  }
99
114
  async function doCompileInner(name, config) {
package/dist/paths.d.ts CHANGED
@@ -10,3 +10,4 @@ export declare const BUILD_DIR: string;
10
10
  export declare const TEMP_DIR: string;
11
11
  export declare const CONTRACTS_DIR: string;
12
12
  export declare const TESTS_DIR: string;
13
+ export declare const TACT_ROOT_CONFIG: string;
package/dist/paths.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.TESTS_DIR = exports.CONTRACTS_DIR = exports.TEMP_DIR = exports.BUILD_DIR = exports.SCRIPTS_DIR = exports.WRAPPERS_DIR = exports.BUILD = exports.TEMP = exports.SCRIPTS = exports.WRAPPERS = exports.TESTS = exports.CONTRACTS = void 0;
6
+ exports.TACT_ROOT_CONFIG = exports.TESTS_DIR = exports.CONTRACTS_DIR = exports.TEMP_DIR = exports.BUILD_DIR = exports.SCRIPTS_DIR = exports.WRAPPERS_DIR = exports.BUILD = exports.TEMP = exports.SCRIPTS = exports.WRAPPERS = exports.TESTS = exports.CONTRACTS = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  exports.CONTRACTS = 'contracts';
9
9
  exports.TESTS = 'tests';
@@ -17,3 +17,4 @@ exports.BUILD_DIR = path_1.default.join(process.cwd(), exports.BUILD);
17
17
  exports.TEMP_DIR = path_1.default.join(process.cwd(), exports.TEMP);
18
18
  exports.CONTRACTS_DIR = path_1.default.join(process.cwd(), exports.CONTRACTS);
19
19
  exports.TESTS_DIR = path_1.default.join(process.cwd(), exports.TESTS);
20
+ exports.TACT_ROOT_CONFIG = path_1.default.join(process.cwd(), 'tact.config.json');
@@ -4,4 +4,7 @@ import { CompilerConfig } from '@ton/blueprint';
4
4
  export const compile: CompilerConfig = {
5
5
  lang: 'tact',
6
6
  target: '{{contractPath}}',
7
+ options: {
8
+ debug: true,
9
+ },
7
10
  };
@@ -2,7 +2,8 @@
2
2
  import "@stdlib/deploy";
3
3
 
4
4
  contract {{name}} with Deployable {
5
- init() {
6
-
7
- }
5
+ // Empty init() function is present by default in all Tact contracts
6
+ // since v1.3.0, so the following may be omitted:
7
+ //
8
+ // init() {}
8
9
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ton/blueprint",
3
- "version": "0.19.0",
3
+ "version": "0.20.0",
4
4
  "description": "Framework for development of TON smart contracts",
5
5
  "main": "dist/index.js",
6
6
  "bin": "./dist/cli/cli.js",
@@ -35,7 +35,7 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@orbs-network/ton-access": "^2.3.3",
38
- "@tact-lang/compiler": "^1.2.0",
38
+ "@tact-lang/compiler": "^1.3.0",
39
39
  "@ton-community/func-js": "^0.7.0",
40
40
  "@tonconnect/sdk": "^2.2.0",
41
41
  "arg": "^5.0.2",