@ton/blueprint 0.10.0 → 0.13.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.
Files changed (55) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +8 -4
  3. package/dist/build.d.ts +3 -0
  4. package/dist/build.js +57 -0
  5. package/dist/cli/Runner.d.ts +5 -0
  6. package/dist/cli/Runner.js +4 -0
  7. package/dist/cli/build.d.ts +1 -3
  8. package/dist/cli/build.js +5 -46
  9. package/dist/cli/cli.d.ts +0 -5
  10. package/dist/cli/cli.js +47 -5
  11. package/dist/cli/create.d.ts +1 -1
  12. package/dist/cli/create.js +1 -1
  13. package/dist/cli/help.d.ts +2 -1
  14. package/dist/cli/help.js +12 -3
  15. package/dist/cli/run.d.ts +1 -1
  16. package/dist/cli/test.d.ts +1 -1
  17. package/dist/compile/CompilerConfig.d.ts +3 -1
  18. package/dist/compile/OverwritableVirtualFileSystem.d.ts +1 -0
  19. package/dist/compile/OverwritableVirtualFileSystem.js +6 -3
  20. package/dist/compile/compile.d.ts +1 -1
  21. package/dist/compile/compile.js +6 -5
  22. package/dist/config/Config.d.ts +4 -0
  23. package/dist/config/Config.js +2 -0
  24. package/dist/config/Plugin.d.ts +9 -0
  25. package/dist/config/Plugin.js +2 -0
  26. package/dist/index.d.ts +4 -0
  27. package/dist/index.js +4 -1
  28. package/dist/network/NetworkProvider.d.ts +4 -4
  29. package/dist/network/createNetworkProvider.js +45 -16
  30. package/dist/network/send/DeeplinkProvider.d.ts +1 -1
  31. package/dist/network/send/DeeplinkProvider.js +2 -2
  32. package/dist/network/send/MnemonicProvider.d.ts +3 -3
  33. package/dist/network/send/MnemonicProvider.js +6 -6
  34. package/dist/network/send/SendProvider.d.ts +1 -1
  35. package/dist/network/send/TonConnectProvider.d.ts +1 -1
  36. package/dist/network/send/TonConnectProvider.js +4 -4
  37. package/dist/network/send/TonHubProvider.d.ts +1 -1
  38. package/dist/network/send/TonHubProvider.js +4 -4
  39. package/dist/templates/func/common/wrappers/compile.ts.template +1 -1
  40. package/dist/templates/func/counter/scripts/deploy.ts.template +2 -2
  41. package/dist/templates/func/counter/scripts/increment.ts.template +2 -2
  42. package/dist/templates/func/counter/tests/spec.ts.template +6 -5
  43. package/dist/templates/func/counter/wrappers/wrapper.ts.template +1 -1
  44. package/dist/templates/func/empty/scripts/deploy.ts.template +2 -2
  45. package/dist/templates/func/empty/tests/spec.ts.template +6 -5
  46. package/dist/templates/func/empty/wrappers/wrapper.ts.template +1 -1
  47. package/dist/templates/tact/common/wrappers/compile.ts.template +1 -1
  48. package/dist/templates/tact/counter/scripts/deploy.ts.template +2 -2
  49. package/dist/templates/tact/counter/scripts/increment.ts.template +2 -2
  50. package/dist/templates/tact/counter/tests/spec.ts.template +5 -4
  51. package/dist/templates/tact/empty/scripts/deploy.ts.template +2 -2
  52. package/dist/templates/tact/empty/tests/spec.ts.template +5 -4
  53. package/dist/utils.d.ts +1 -1
  54. package/dist/utils.js +2 -2
  55. package/package.json +49 -50
package/CHANGELOG.md CHANGED
@@ -5,6 +5,42 @@ 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.13.0] - 2023-11-05
9
+
10
+ ### Added
11
+
12
+ - Added plugin support
13
+ - Added custom API v2 endpoints
14
+
15
+ ### Changed
16
+
17
+ - Improved docs
18
+ - Changed deployed contract explorer link to use tonviewer
19
+ - Moved `deployer` to the global `describe` context in default tests
20
+
21
+ ## [0.12.1] - 2023-07-31
22
+
23
+ ### Changed
24
+
25
+ - Updated all dependencies to @ton organization packages
26
+
27
+ ## [0.12.0] - 2023-07-14
28
+
29
+ ### Fixed
30
+
31
+ - Fixed TACT imports
32
+ - Fixed missing newlines when printing error messages while building contracts
33
+
34
+ ## [0.11.0] - 2023-07-03
35
+
36
+ ### Added
37
+
38
+ - Added an `options` field to the `tact` variant of `CompilerConfig`, which is of the same type as the `options` of the TACT compiler, and includes fields such as `debug`, `experimental`, etc
39
+
40
+ ### Changed
41
+
42
+ - Updated TACT to 1.1.3
43
+
8
44
  ## [0.10.0] - 2023-06-06
9
45
 
10
46
  ### Added
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)
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)
34
34
 
35
35
   
36
36
 
@@ -42,18 +42,18 @@ npm create ton@latest
42
42
  ### Directory structure
43
43
 
44
44
  * `contracts/` - Source code in [FunC](https://ton.org/docs/develop/func/overview) for all smart contracts and their imports
45
- * `wrappers/` - TypeScript interface classes for all contracts (implementing `Contract` from [ton-core](https://www.npmjs.com/package/ton-core))
45
+ * `wrappers/` - TypeScript interface classes for all contracts (implementing `Contract` from [@ton/core](https://www.npmjs.com/package/@ton/core))
46
46
  * include message [de]serialization primitives, getter wrappers and compilation functions
47
47
  * used by the test suite and client code to interact with the contracts from TypeScript
48
48
  * `tests/` - TypeScript test suite for all contracts (relying on [Sandbox](https://github.com/ton-org/sandbox) for in-process tests)
49
49
  * `scripts/` - Deployment scripts to mainnet/testnet and other scripts interacting with live contracts
50
50
  * `build/` - Compilation artifacts created here after running a build command
51
51
 
52
- ### Build one of the contracts
52
+ ### Build contracts
53
53
 
54
54
  1. You need a compilation script in `wrappers/<CONTRACT>.compile.ts` - [example](/example/wrappers/Counter.compile.ts)
55
55
  2. Run interactive: &nbsp;&nbsp; `npx blueprint build` &nbsp; or &nbsp; `yarn blueprint build`
56
- 3. Non-interactive: &nbsp; `npx/yarn blueprint build <CONTRACT>`
56
+ 3. Non-interactive: &nbsp; `npx/yarn blueprint build <CONTRACT>` &nbsp; OR build all contracts &nbsp; `yarn blueprint build --all`
57
57
  * Example: `yarn blueprint build counter`
58
58
  4. Build results are generated in `build/<CONTRACT>.compiled.json`
59
59
 
@@ -62,6 +62,8 @@ npm create ton@latest
62
62
  1. Run in terminal: &nbsp; `npx blueprint test` &nbsp; or &nbsp; `yarn blueprint test`
63
63
  2. Alternative method: &nbsp; `npm test` &nbsp; or &nbsp; `yarn test`
64
64
 
65
+ > Learn more about writing tests from the Sandbox's documentation - [here](https://github.com/ton-org/sandbox#writing-tests).
66
+
65
67
  ### Deploy one of the contracts
66
68
 
67
69
  1. You need a deploy script in `scripts/deploy<CONTRACT>.ts` - [example](/example/scripts/deployCounter.ts)
@@ -93,6 +95,8 @@ Run in terminal: &nbsp; `npx blueprint help` &nbsp; or &nbsp; `yarn blueprint he
93
95
  1. Implement TypeScript tests in `tests/<CONTRACT>.spec.ts`
94
96
  2. Rely on the wrapper TypeScript class from `wrappers/<CONTRACT>.ts` to interact with the contract
95
97
 
98
+ > Learn more about writing tests from the Sandbox's documentation - [here](https://github.com/ton-org/sandbox#writing-tests).
99
+
96
100
  ### Compilation and deployment
97
101
 
98
102
  1. Implement a compilation script in `wrappers/<CONTRACT>.compile.ts`
@@ -0,0 +1,3 @@
1
+ import { UIProvider } from './ui/UIProvider';
2
+ export declare function buildOne(contract: string, ui?: UIProvider): Promise<void>;
3
+ export declare function buildAll(ui?: UIProvider): Promise<void>;
package/dist/build.js ADDED
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.buildAll = exports.buildOne = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const promises_1 = __importDefault(require("fs/promises"));
9
+ const compile_1 = require("./compile/compile");
10
+ const paths_1 = require("./paths");
11
+ const utils_1 = require("./utils");
12
+ async function buildOne(contract, ui) {
13
+ ui?.write(`Build script running, compiling ${contract}`);
14
+ const buildArtifactPath = path_1.default.join(paths_1.BUILD_DIR, `${contract}.compiled.json`);
15
+ try {
16
+ await promises_1.default.unlink(buildArtifactPath);
17
+ }
18
+ catch (e) { }
19
+ ui?.setActionPrompt('⏳ Compiling...');
20
+ try {
21
+ const result = await (0, compile_1.doCompile)(contract);
22
+ if (result.lang === 'tact') {
23
+ for (const [k, v] of result.fs) {
24
+ await promises_1.default.mkdir(path_1.default.dirname(k), {
25
+ recursive: true,
26
+ });
27
+ await promises_1.default.writeFile(k, v);
28
+ }
29
+ }
30
+ const cell = result.code;
31
+ ui?.clearActionPrompt();
32
+ ui?.write('\n✅ Compiled successfully! Cell BOC hex result:\n\n');
33
+ ui?.write(cell.toBoc().toString('hex'));
34
+ await promises_1.default.mkdir(paths_1.BUILD_DIR, { recursive: true });
35
+ await promises_1.default.writeFile(buildArtifactPath, JSON.stringify({
36
+ hex: cell.toBoc().toString('hex'),
37
+ }));
38
+ ui?.write(`\n✅ Wrote compilation artifact to ${path_1.default.relative(process.cwd(), buildArtifactPath)}`);
39
+ }
40
+ catch (e) {
41
+ if (ui) {
42
+ ui?.clearActionPrompt();
43
+ ui?.write(e.toString());
44
+ process.exit(1);
45
+ }
46
+ else {
47
+ throw e;
48
+ }
49
+ }
50
+ }
51
+ exports.buildOne = buildOne;
52
+ async function buildAll(ui) {
53
+ for (const file of await (0, utils_1.findCompiles)()) {
54
+ await buildOne(file.name, ui);
55
+ }
56
+ }
57
+ exports.buildAll = buildAll;
@@ -0,0 +1,5 @@
1
+ import arg from 'arg';
2
+ import { UIProvider } from '../ui/UIProvider';
3
+ export declare const argSpec: {};
4
+ export type Args = arg.Result<typeof argSpec>;
5
+ export type Runner = (args: Args, ui: UIProvider) => Promise<void>;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.argSpec = void 0;
4
+ exports.argSpec = {};
@@ -1,4 +1,2 @@
1
- import { Runner } from './cli';
2
- import { UIProvider } from '../ui/UIProvider';
3
- export declare function buildOne(contract: string, ui: UIProvider): Promise<void>;
1
+ import { Runner } from './Runner';
4
2
  export declare const build: Runner;
package/dist/cli/build.js CHANGED
@@ -3,66 +3,25 @@ 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.build = exports.buildOne = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- const paths_1 = require("../paths");
6
+ exports.build = void 0;
9
7
  const utils_1 = require("../utils");
10
- const promises_1 = __importDefault(require("fs/promises"));
11
- const compile_1 = require("../compile/compile");
12
8
  const arg_1 = __importDefault(require("arg"));
13
- async function buildOne(contract, ui) {
14
- ui.write(`Build script running, compiling ${contract}`);
15
- const buildArtifactPath = path_1.default.join(paths_1.BUILD_DIR, `${contract}.compiled.json`);
16
- try {
17
- await promises_1.default.unlink(buildArtifactPath);
18
- }
19
- catch (e) { }
20
- ui.setActionPrompt('⏳ Compiling...');
21
- try {
22
- const result = await (0, compile_1.doCompile)(contract);
23
- if (result.lang === 'tact') {
24
- for (const [k, v] of result.fs) {
25
- await promises_1.default.mkdir(path_1.default.dirname(k), {
26
- recursive: true,
27
- });
28
- await promises_1.default.writeFile(k, v);
29
- }
30
- }
31
- const cell = result.code;
32
- ui.clearActionPrompt();
33
- ui.write('\n✅ Compiled successfully! Cell BOC hex result:\n\n');
34
- ui.write(cell.toBoc().toString('hex'));
35
- await promises_1.default.mkdir(paths_1.BUILD_DIR, { recursive: true });
36
- await promises_1.default.writeFile(buildArtifactPath, JSON.stringify({
37
- hex: cell.toBoc().toString('hex'),
38
- }));
39
- ui.write(`\n✅ Wrote compilation artifact to ${path_1.default.relative(process.cwd(), buildArtifactPath)}`);
40
- }
41
- catch (e) {
42
- ui.clearActionPrompt();
43
- ui.write(e.toString());
44
- process.exit(1);
45
- }
46
- }
47
- exports.buildOne = buildOne;
9
+ const build_1 = require("../build");
48
10
  const build = async (args, ui) => {
49
11
  require('ts-node/register');
50
12
  const localArgs = (0, arg_1.default)({
51
13
  '--all': Boolean,
52
14
  });
53
- const files = await (0, utils_1.findCompiles)();
54
15
  if (localArgs['--all']) {
55
- for (const file of files) {
56
- await buildOne(file.name, ui);
57
- }
16
+ await (0, build_1.buildAll)();
58
17
  }
59
18
  else {
60
- const sel = await (0, utils_1.selectFile)(files, {
19
+ const sel = await (0, utils_1.selectFile)(await (0, utils_1.findCompiles)(), {
61
20
  ui,
62
21
  hint: args._.length > 1 && args._[1].length > 0 ? args._[1] : undefined,
63
22
  import: false,
64
23
  });
65
- await buildOne(sel.name, ui);
24
+ await (0, build_1.buildOne)(sel.name, ui);
66
25
  }
67
26
  };
68
27
  exports.build = build;
package/dist/cli/cli.d.ts CHANGED
@@ -1,7 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import arg from 'arg';
3
- import { UIProvider } from '../ui/UIProvider';
4
- declare const argSpec: {};
5
- export type Args = arg.Result<typeof argSpec>;
6
- export type Runner = (args: Args, ui: UIProvider) => Promise<void>;
7
2
  export {};
package/dist/cli/cli.js CHANGED
@@ -37,7 +37,8 @@ const build_1 = require("./build");
37
37
  const test_1 = require("./test");
38
38
  const help_1 = require("./help");
39
39
  const InquirerUIProvider_1 = require("../ui/InquirerUIProvider");
40
- const argSpec = {};
40
+ const Runner_1 = require("./Runner");
41
+ const path_1 = __importDefault(require("path"));
41
42
  const runners = {
42
43
  create: create_1.create,
43
44
  run: run_1.run,
@@ -46,22 +47,63 @@ const runners = {
46
47
  help: help_1.help,
47
48
  };
48
49
  async function main() {
49
- const args = (0, arg_1.default)(argSpec, {
50
+ var _a;
51
+ require('ts-node/register');
52
+ const args = (0, arg_1.default)(Runner_1.argSpec, {
50
53
  permissive: true,
51
54
  });
52
55
  if (args._.length === 0) {
53
56
  showHelp();
54
57
  process.exit(0);
55
58
  }
56
- const runner = runners[args._[0]];
59
+ let effectiveRunners = {};
60
+ try {
61
+ const configModule = await (_a = path_1.default.join(process.cwd(), 'blueprint.config.ts'), Promise.resolve().then(() => __importStar(require(_a))));
62
+ try {
63
+ if ('config' in configModule && typeof configModule.config === 'object') {
64
+ const config = configModule.config;
65
+ for (const plugin of config.plugins) {
66
+ for (const runner of plugin.runners()) {
67
+ effectiveRunners[runner.name] = runner.runner;
68
+ help_1.additionalHelpMessages[runner.name] = runner.help;
69
+ }
70
+ }
71
+ }
72
+ }
73
+ catch (e) {
74
+ // if plugin.runners() throws
75
+ console.error('Could not load one or more plugins');
76
+ console.error(e);
77
+ }
78
+ }
79
+ catch (e) {
80
+ // no config
81
+ }
82
+ effectiveRunners = {
83
+ ...effectiveRunners,
84
+ ...runners,
85
+ };
86
+ const runner = effectiveRunners[args._[0]];
57
87
  if (!runner) {
58
88
  console.log(chalk_1.default.redBright(` Error: command not found.`) + ` Run 'blueprint help' to see available commands\n`);
59
89
  process.exit(1);
60
90
  }
61
91
  const ui = new InquirerUIProvider_1.InquirerUIProvider();
92
+ const waitingForCustomLink = args._.includes('--custom');
62
93
  await runner({
63
94
  ...args,
64
- _: args._.filter((a) => !(a.length > 1 && a[0] === '-')), // filter out the flags pushed by `permissive`
95
+ _: args._.filter((a, inx) => {
96
+ // filter out the flags
97
+ if (a.length > 1 && a[0] === '-')
98
+ return false;
99
+ // and endpoint urls
100
+ if (waitingForCustomLink) {
101
+ if (args._[inx - 1] === '--custom' && // url goes after --custom
102
+ a.startsWith('http'))
103
+ return false;
104
+ }
105
+ return true;
106
+ }),
65
107
  }, ui);
66
108
  ui.close();
67
109
  }
@@ -100,7 +142,7 @@ function showHelp() {
100
142
  console.log(`\t\t\t` + chalk_1.default.gray(`blueprint run deployContractName`));
101
143
  console.log(chalk_1.default.cyanBright(` blueprint help`) +
102
144
  `\t` +
103
- chalk_1.default.whiteBright(`shows more detailed help, also see https://github.com/ton-community/blueprint`));
145
+ chalk_1.default.whiteBright(`shows more detailed help, also see https://github.com/ton-org/blueprint`));
104
146
  console.log(`\t\t\t` + chalk_1.default.gray(`blueprint help`));
105
147
  console.log(``);
106
148
  }
@@ -1,4 +1,4 @@
1
- import { Runner } from './cli';
1
+ import { Runner } from './Runner';
2
2
  export declare const templateTypes: {
3
3
  name: string;
4
4
  value: string;
@@ -9,7 +9,7 @@ const path_1 = __importDefault(require("path"));
9
9
  const template_1 = require("../template");
10
10
  const utils_1 = require("../utils");
11
11
  const arg_1 = __importDefault(require("arg"));
12
- const build_1 = require("./build");
12
+ const build_1 = require("../build");
13
13
  function toSnakeCase(v) {
14
14
  const r = v.replace(/[A-Z]/g, (sub) => '_' + sub.toLowerCase());
15
15
  return r[0] === '_' ? r.substring(1) : r;
@@ -1,2 +1,3 @@
1
- import { Runner } from './cli';
1
+ import { Runner } from './Runner';
2
+ export declare let additionalHelpMessages: Record<string, string>;
2
3
  export declare const help: Runner;
package/dist/cli/help.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.help = void 0;
3
+ exports.help = exports.additionalHelpMessages = void 0;
4
4
  const create_1 = require("./create");
5
5
  const helpMessages = {
6
6
  help: `Usage: blueprint help [command]
@@ -33,8 +33,9 @@ Script name is matched (ignoring case) to a file in the scripts directory. If no
33
33
 
34
34
  Flags:
35
35
  --mainnet, --testnet - specifies the network to use when running the script. If not specified on the command line, it will be asked interactively.
36
+ --custom [api-v2-endpoint] - indicates that a custom API should be used when running the script, and the API URL optionally.
36
37
  --tonconnect, --tonhub, --deeplink, --mnemonic - specifies the deployer to use when running the script. If not specified on the command line, it will be asked interactively.
37
- --tonscan, --tonapi, --toncx, --dton - specifies the network explorer to use when displaying links to the deployed contracts. Default: tonscan.`,
38
+ --tonscan, --tonviewer, --toncx, --dton - specifies the network explorer to use when displaying links to the deployed contracts. Default: tonscan.`,
38
39
  build: `Usage: blueprint build [contract name] [flags]
39
40
 
40
41
  Builds the specified contract according to the respective .compile.ts file. If the contract is written in TACT, all TACT-generated files (wrapper class, etc) will be placed in the build/<contract name> folder.
@@ -47,9 +48,17 @@ Flags:
47
48
 
48
49
  Just runs \`npm test\`, which by default runs \`jest\`.`,
49
50
  };
51
+ exports.additionalHelpMessages = {};
50
52
  const help = async (args, ui) => {
51
53
  const cmd = args._.length >= 2 ? args._[1].toLowerCase() : '';
52
- const helpMessage = cmd in helpMessages ? helpMessages[cmd] : helpMessages['help'];
54
+ const effectiveHelpMessages = {
55
+ ...exports.additionalHelpMessages,
56
+ ...helpMessages,
57
+ };
58
+ for (const k in exports.additionalHelpMessages) {
59
+ effectiveHelpMessages.help += '\n- ' + k;
60
+ }
61
+ const helpMessage = cmd in effectiveHelpMessages ? effectiveHelpMessages[cmd] : effectiveHelpMessages['help'];
53
62
  ui.write(helpMessage);
54
63
  };
55
64
  exports.help = help;
package/dist/cli/run.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { Runner } from './cli';
1
+ import { Runner } from './Runner';
2
2
  export declare const run: Runner;
@@ -1,2 +1,2 @@
1
- import { Runner } from './cli';
1
+ import { Runner } from './Runner';
2
2
  export declare const test: Runner;
@@ -1,5 +1,6 @@
1
1
  import { SourceResolver, SourcesMap, SourcesArray } from '@ton-community/func-js';
2
- import { Cell } from 'ton-core';
2
+ import { Cell } from '@ton/core';
3
+ import { ConfigProject } from '@tact-lang/compiler';
3
4
  export type CommonCompilerConfig = {
4
5
  preCompileHook?: () => Promise<void>;
5
6
  postCompileHook?: (code: Cell) => Promise<void>;
@@ -7,6 +8,7 @@ export type CommonCompilerConfig = {
7
8
  export type TactCompilerConfig = {
8
9
  lang: 'tact';
9
10
  target: string;
11
+ options?: ConfigProject['options'];
10
12
  };
11
13
  export type FuncCompilerConfig = {
12
14
  lang?: 'func';
@@ -3,6 +3,7 @@ import { VirtualFileSystem } from '@tact-lang/compiler';
3
3
  export declare class OverwritableVirtualFileSystem implements VirtualFileSystem {
4
4
  root: string;
5
5
  overwrites: Map<string, Buffer>;
6
+ constructor(root: string);
6
7
  resolve(...path: string[]): string;
7
8
  exists(path: string): boolean;
8
9
  readFile(path: string): Buffer;
@@ -4,12 +4,15 @@ exports.OverwritableVirtualFileSystem = void 0;
4
4
  const path_1 = require("path");
5
5
  const fs_1 = require("fs");
6
6
  class OverwritableVirtualFileSystem {
7
- constructor() {
8
- this.root = '/';
7
+ constructor(root) {
9
8
  this.overwrites = new Map();
9
+ this.root = (0, path_1.normalize)(root);
10
+ if (!this.root.endsWith(path_1.sep)) {
11
+ this.root += path_1.sep;
12
+ }
10
13
  }
11
14
  resolve(...path) {
12
- return (0, path_1.resolve)(...path);
15
+ return (0, path_1.normalize)((0, path_1.resolve)(this.root, ...path));
13
16
  }
14
17
  exists(path) {
15
18
  return (0, fs_1.existsSync)(path);
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { Cell } from 'ton-core';
2
+ import { Cell } from '@ton/core';
3
3
  export type FuncCompileResult = {
4
4
  lang: 'func';
5
5
  code: Cell;
@@ -30,7 +30,7 @@ exports.compile = exports.doCompile = void 0;
30
30
  const func_js_1 = require("@ton-community/func-js");
31
31
  const fs_1 = require("fs");
32
32
  const path_1 = __importDefault(require("path"));
33
- const ton_core_1 = require("ton-core");
33
+ const core_1 = require("@ton/core");
34
34
  const paths_1 = require("../paths");
35
35
  const compiler_1 = require("@tact-lang/compiler");
36
36
  const OverwritableVirtualFileSystem_1 = require("./OverwritableVirtualFileSystem");
@@ -49,7 +49,7 @@ async function doCompileFunc(config) {
49
49
  throw new Error(cr.message);
50
50
  return {
51
51
  lang: 'func',
52
- code: ton_core_1.Cell.fromBase64(cr.codeBoc),
52
+ code: core_1.Cell.fromBase64(cr.codeBoc),
53
53
  };
54
54
  }
55
55
  function findTactBoc(fs) {
@@ -63,15 +63,16 @@ function findTactBoc(fs) {
63
63
  if (buf === undefined) {
64
64
  throw new Error('Could not find boc in tact compilation result');
65
65
  }
66
- return ton_core_1.Cell.fromBoc(buf)[0];
66
+ return core_1.Cell.fromBoc(buf)[0];
67
67
  }
68
68
  async function doCompileTact(config, name) {
69
- const fs = new OverwritableVirtualFileSystem_1.OverwritableVirtualFileSystem();
69
+ const fs = new OverwritableVirtualFileSystem_1.OverwritableVirtualFileSystem(process.cwd());
70
70
  const res = await (0, compiler_1.build)({
71
71
  config: {
72
72
  name: 'tact',
73
- path: path_1.default.join(process.cwd(), config.target),
73
+ path: config.target,
74
74
  output: path_1.default.join(paths_1.BUILD_DIR, name),
75
+ options: config.options,
75
76
  },
76
77
  stdlib: '/stdlib',
77
78
  project: fs,
@@ -0,0 +1,4 @@
1
+ import { Plugin } from './Plugin';
2
+ export interface Config {
3
+ plugins: Plugin[];
4
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,9 @@
1
+ import { Runner } from '../cli/Runner';
2
+ export interface PluginRunner {
3
+ name: string;
4
+ runner: Runner;
5
+ help: string;
6
+ }
7
+ export interface Plugin {
8
+ runners(): PluginRunner[];
9
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/dist/index.d.ts CHANGED
@@ -4,3 +4,7 @@ export { createNetworkProvider } from './network/createNetworkProvider';
4
4
  export { compile } from './compile/compile';
5
5
  export { CompilerConfig } from './compile/CompilerConfig';
6
6
  export { UIProvider } from './ui/UIProvider';
7
+ export { Config } from './config/Config';
8
+ export { Args, Runner } from './cli/Runner';
9
+ export { PluginRunner, Plugin } from './config/Plugin';
10
+ export { buildOne, buildAll } from './build';
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.compile = exports.createNetworkProvider = exports.sleep = exports.tonDeepLink = void 0;
3
+ exports.buildAll = exports.buildOne = exports.compile = exports.createNetworkProvider = exports.sleep = exports.tonDeepLink = void 0;
4
4
  var utils_1 = require("./utils");
5
5
  Object.defineProperty(exports, "tonDeepLink", { enumerable: true, get: function () { return utils_1.tonDeepLink; } });
6
6
  Object.defineProperty(exports, "sleep", { enumerable: true, get: function () { return utils_1.sleep; } });
@@ -8,3 +8,6 @@ var createNetworkProvider_1 = require("./network/createNetworkProvider");
8
8
  Object.defineProperty(exports, "createNetworkProvider", { enumerable: true, get: function () { return createNetworkProvider_1.createNetworkProvider; } });
9
9
  var compile_1 = require("./compile/compile");
10
10
  Object.defineProperty(exports, "compile", { enumerable: true, get: function () { return compile_1.compile; } });
11
+ var build_1 = require("./build");
12
+ Object.defineProperty(exports, "buildOne", { enumerable: true, get: function () { return build_1.buildOne; } });
13
+ Object.defineProperty(exports, "buildAll", { enumerable: true, get: function () { return build_1.buildAll; } });
@@ -1,10 +1,10 @@
1
- import { TonClient4 } from 'ton';
2
- import { Address, Cell, Contract, ContractProvider, OpenedContract, Sender } from 'ton-core';
1
+ import { TonClient, TonClient4 } from '@ton/ton';
2
+ import { Address, Cell, Contract, ContractProvider, OpenedContract, Sender } from '@ton/core';
3
3
  import { UIProvider } from '../ui/UIProvider';
4
4
  export interface NetworkProvider {
5
- network(): 'mainnet' | 'testnet';
5
+ network(): 'mainnet' | 'testnet' | 'custom';
6
6
  sender(): Sender;
7
- api(): TonClient4;
7
+ api(): TonClient4 | TonClient;
8
8
  provider(address: Address, init?: {
9
9
  code?: Cell;
10
10
  data?: Cell;