@ton/blueprint 0.16.0 → 0.18.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 +22 -1
- package/README.md +5 -0
- package/dist/build.js +9 -5
- package/dist/cli/cli.js +2 -0
- package/dist/cli/help.js +4 -0
- package/dist/cli/set.d.ts +2 -0
- package/dist/cli/set.js +104 -0
- package/dist/network/createNetworkProvider.js +16 -12
- package/dist/templates/tact/counter/contracts/contract.tact.template +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,27 @@ 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.18.0] - 2024-03-13
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- Changed `@tact-lang/compiler` dependency to be `^1.2.0` instead of `^1.1.5`
|
|
13
|
+
- Updated the Tact counter template to use the new `+=` operator from Tact v1.2.0
|
|
14
|
+
|
|
15
|
+
## [0.17.0] - 2024-03-01
|
|
16
|
+
|
|
17
|
+
This release contains a breaking change.
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
- Blueprint no longer automatically adds `jsonRPC` to custom v2 endpoints
|
|
22
|
+
|
|
23
|
+
### Added
|
|
24
|
+
|
|
25
|
+
- Added `set` command which can currently set func version (run `blueprint set func`)
|
|
26
|
+
- Added `open` and `getTransactions` to `WrappedContractProvider`
|
|
27
|
+
- Added cell hash to build artifacts
|
|
28
|
+
|
|
8
29
|
## [0.16.0] - 2024-02-15
|
|
9
30
|
|
|
10
31
|
### Added
|
|
@@ -223,4 +244,4 @@ This release contains a breaking change.
|
|
|
223
244
|
|
|
224
245
|
### Fixed
|
|
225
246
|
|
|
226
|
-
- File selection (compilation files in `build` and scripts in `run`) now accepts CLI argument hints in any case
|
|
247
|
+
- File selection (compilation files in `build` and scripts in `run`) now accepts CLI argument hints in any case
|
package/README.md
CHANGED
|
@@ -151,6 +151,11 @@ export const config: Config = {
|
|
|
151
151
|
};
|
|
152
152
|
```
|
|
153
153
|
|
|
154
|
+
The above config parameters are equivalent to the arguments in the following command:
|
|
155
|
+
```bash
|
|
156
|
+
npx blueprint run --custom https://toncenter.com/api/v2/ --custom-version v2 --custom-type mainnet --custom-key YOUR_API_KEY
|
|
157
|
+
```
|
|
158
|
+
|
|
154
159
|
Properties of the `network` object have the same semantics as the `--custom` flags with respective names (see `blueprint help run`).
|
|
155
160
|
|
|
156
161
|
## Contributors
|
package/dist/build.js
CHANGED
|
@@ -28,13 +28,17 @@ async function buildOne(contract, ui) {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
const cell = result.code;
|
|
31
|
+
const rHash = cell.hash();
|
|
32
|
+
const res = {
|
|
33
|
+
hash: rHash.toString('hex'),
|
|
34
|
+
hashBase64: rHash.toString('base64'),
|
|
35
|
+
hex: cell.toBoc().toString('hex')
|
|
36
|
+
};
|
|
31
37
|
ui?.clearActionPrompt();
|
|
32
|
-
ui?.write('\n✅ Compiled successfully! Cell BOC
|
|
33
|
-
ui?.write(
|
|
38
|
+
ui?.write('\n✅ Compiled successfully! Cell BOC result:\n\n');
|
|
39
|
+
ui?.write(JSON.stringify(res, null, 2));
|
|
34
40
|
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
|
-
}));
|
|
41
|
+
await promises_1.default.writeFile(buildArtifactPath, JSON.stringify(res));
|
|
38
42
|
ui?.write(`\n✅ Wrote compilation artifact to ${path_1.default.relative(process.cwd(), buildArtifactPath)}`);
|
|
39
43
|
}
|
|
40
44
|
catch (e) {
|
package/dist/cli/cli.js
CHANGED
|
@@ -34,6 +34,7 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
34
34
|
const create_1 = require("./create");
|
|
35
35
|
const run_1 = require("./run");
|
|
36
36
|
const build_1 = require("./build");
|
|
37
|
+
const set_1 = require("./set");
|
|
37
38
|
const test_1 = require("./test");
|
|
38
39
|
const verify_1 = require("./verify");
|
|
39
40
|
const convert_1 = require("./convert");
|
|
@@ -45,6 +46,7 @@ const runners = {
|
|
|
45
46
|
create: create_1.create,
|
|
46
47
|
run: run_1.run,
|
|
47
48
|
build: build_1.build,
|
|
49
|
+
set: set_1.set,
|
|
48
50
|
test: test_1.test,
|
|
49
51
|
help: help_1.help,
|
|
50
52
|
verify: verify_1.verify,
|
package/dist/cli/help.js
CHANGED
|
@@ -13,6 +13,7 @@ List of available commands:
|
|
|
13
13
|
- create
|
|
14
14
|
- run
|
|
15
15
|
- build
|
|
16
|
+
- custom
|
|
16
17
|
- help
|
|
17
18
|
- test
|
|
18
19
|
- verify
|
|
@@ -49,6 +50,9 @@ If contract name is not specified on the command line, the buildable contracts (
|
|
|
49
50
|
|
|
50
51
|
Flags:
|
|
51
52
|
--all - builds all buildable contracts instead of just one.`,
|
|
53
|
+
set: `Usage: blueprint set <key> [value]
|
|
54
|
+
Available keys:
|
|
55
|
+
- func - overrides @ton-community/func-js-bin version, effectively setting the func version. The required version may be passed as the value, otherwise available versions will be displayed.`,
|
|
52
56
|
test: `Usage: blueprint test
|
|
53
57
|
|
|
54
58
|
Just runs \`npm test\`, which by default runs \`jest\`.`,
|
package/dist/cli/set.js
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
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.set = void 0;
|
|
7
|
+
const promises_1 = require("fs/promises");
|
|
8
|
+
const node_child_process_1 = require("node:child_process");
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const getVersions = (pkg, ui) => {
|
|
11
|
+
return new Promise((resolve, reject) => {
|
|
12
|
+
(0, node_child_process_1.exec)(`npm view ${pkg} versions --json`, (error, stdout, stderr) => {
|
|
13
|
+
if (stderr) {
|
|
14
|
+
ui.write(stderr);
|
|
15
|
+
}
|
|
16
|
+
if (stdout) {
|
|
17
|
+
if (error === null) {
|
|
18
|
+
try {
|
|
19
|
+
const resJson = JSON.parse(stdout);
|
|
20
|
+
if (Array.isArray(resJson)) {
|
|
21
|
+
resolve(resJson);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
reject(new TypeError("Expect json array on stdout, but got:\n" + stdout));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
catch (e) {
|
|
28
|
+
reject(e);
|
|
29
|
+
}
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
ui.write(stdout);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (error) {
|
|
37
|
+
ui.write("Failed to get func-js-bin package versions!");
|
|
38
|
+
reject(error);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
const install = (cmd, ui) => {
|
|
44
|
+
return new Promise((resolve, reject) => {
|
|
45
|
+
(0, node_child_process_1.exec)(cmd, (error, stdout, stderr) => {
|
|
46
|
+
if (stderr) {
|
|
47
|
+
ui.write(stderr);
|
|
48
|
+
}
|
|
49
|
+
if (stdout) {
|
|
50
|
+
ui.write(stdout);
|
|
51
|
+
}
|
|
52
|
+
if (error) {
|
|
53
|
+
reject(error);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
resolve();
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
const set = async (args, ui) => {
|
|
61
|
+
if (args._.length < 2) {
|
|
62
|
+
throw new Error('Please pass a key');
|
|
63
|
+
}
|
|
64
|
+
switch (args._[1]) {
|
|
65
|
+
case 'func': {
|
|
66
|
+
const pkg = '@ton-community/func-js-bin';
|
|
67
|
+
const funcVersions = await getVersions(pkg, ui);
|
|
68
|
+
let version = args._.length > 2 ? args._[2] : '';
|
|
69
|
+
if (!funcVersions.includes(version)) {
|
|
70
|
+
version = await ui.choose('Choose FunC version', funcVersions, (s) => s);
|
|
71
|
+
}
|
|
72
|
+
const packagePath = path_1.default.join(process.cwd(), 'package.json');
|
|
73
|
+
const packageContents = (await (0, promises_1.readFile)(packagePath)).toString('utf-8');
|
|
74
|
+
const parsedPackage = JSON.parse(packageContents);
|
|
75
|
+
const packageManager = await ui.choose('Choose your package manager', ['npm', 'yarn', 'pnpm', 'other'], (s) => s);
|
|
76
|
+
if (packageManager === 'other') {
|
|
77
|
+
ui.write(`Please find out how to override @ton-community/func-js-bin version to ${version} using your package manager, do that, and then install the packages`);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const overrideKey = packageManager === 'yarn' ? 'resolutions' : 'overrides';
|
|
81
|
+
parsedPackage[overrideKey] = {
|
|
82
|
+
...parsedPackage[overrideKey],
|
|
83
|
+
[pkg]: version,
|
|
84
|
+
};
|
|
85
|
+
ui.write('Updating package.json...');
|
|
86
|
+
await (0, promises_1.writeFile)(packagePath, JSON.stringify(parsedPackage, null, 4));
|
|
87
|
+
const installCmd = packageManager === 'yarn' ? 'yarn' : `${packageManager} i`;
|
|
88
|
+
try {
|
|
89
|
+
ui.write('Installing dependencies...');
|
|
90
|
+
await install(installCmd, ui);
|
|
91
|
+
}
|
|
92
|
+
catch (e) {
|
|
93
|
+
ui.write('Failed to install dependencies, rolling back package.json');
|
|
94
|
+
await (0, promises_1.writeFile)(packagePath, packageContents);
|
|
95
|
+
throw e;
|
|
96
|
+
}
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
default: {
|
|
100
|
+
throw new Error('Unknown key: ' + args._[1]);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
exports.set = set;
|
|
@@ -13,7 +13,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
13
13
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
|
-
var _SendProviderSender_provider, _WrappedContractProvider_address, _WrappedContractProvider_provider, _WrappedContractProvider_init, _NetworkProviderImpl_tc, _NetworkProviderImpl_sender, _NetworkProviderImpl_network, _NetworkProviderImpl_explorer, _NetworkProviderImpl_ui;
|
|
16
|
+
var _SendProviderSender_provider, _WrappedContractProvider_address, _WrappedContractProvider_provider, _WrappedContractProvider_init, _WrappedContractProvider_factory, _NetworkProviderImpl_tc, _NetworkProviderImpl_sender, _NetworkProviderImpl_network, _NetworkProviderImpl_explorer, _NetworkProviderImpl_ui;
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.createNetworkProvider = exports.argSpec = void 0;
|
|
19
19
|
const utils_1 = require("../utils");
|
|
@@ -63,13 +63,15 @@ class SendProviderSender {
|
|
|
63
63
|
}
|
|
64
64
|
_SendProviderSender_provider = new WeakMap();
|
|
65
65
|
class WrappedContractProvider {
|
|
66
|
-
constructor(address,
|
|
66
|
+
constructor(address, factory, init) {
|
|
67
67
|
_WrappedContractProvider_address.set(this, void 0);
|
|
68
68
|
_WrappedContractProvider_provider.set(this, void 0);
|
|
69
69
|
_WrappedContractProvider_init.set(this, void 0);
|
|
70
|
+
_WrappedContractProvider_factory.set(this, void 0);
|
|
70
71
|
__classPrivateFieldSet(this, _WrappedContractProvider_address, address, "f");
|
|
71
|
-
__classPrivateFieldSet(this, _WrappedContractProvider_provider,
|
|
72
|
+
__classPrivateFieldSet(this, _WrappedContractProvider_provider, factory({ address, init }), "f");
|
|
72
73
|
__classPrivateFieldSet(this, _WrappedContractProvider_init, init, "f");
|
|
74
|
+
__classPrivateFieldSet(this, _WrappedContractProvider_factory, factory, "f");
|
|
73
75
|
}
|
|
74
76
|
async getState() {
|
|
75
77
|
return await __classPrivateFieldGet(this, _WrappedContractProvider_provider, "f").getState();
|
|
@@ -91,8 +93,14 @@ class WrappedContractProvider {
|
|
|
91
93
|
body: typeof args.body === 'string' ? (0, core_1.comment)(args.body) : args.body,
|
|
92
94
|
});
|
|
93
95
|
}
|
|
96
|
+
open(contract) {
|
|
97
|
+
return (0, core_1.openContract)(contract, (params) => new WrappedContractProvider(params.address, __classPrivateFieldGet(this, _WrappedContractProvider_factory, "f"), params.init));
|
|
98
|
+
}
|
|
99
|
+
getTransactions(address, lt, hash, limit) {
|
|
100
|
+
return __classPrivateFieldGet(this, _WrappedContractProvider_provider, "f").getTransactions(address, lt, hash, limit);
|
|
101
|
+
}
|
|
94
102
|
}
|
|
95
|
-
_WrappedContractProvider_address = new WeakMap(), _WrappedContractProvider_provider = new WeakMap(), _WrappedContractProvider_init = new WeakMap();
|
|
103
|
+
_WrappedContractProvider_address = new WeakMap(), _WrappedContractProvider_provider = new WeakMap(), _WrappedContractProvider_init = new WeakMap(), _WrappedContractProvider_factory = new WeakMap();
|
|
96
104
|
class NetworkProviderImpl {
|
|
97
105
|
constructor(tc, sender, network, explorer, ui) {
|
|
98
106
|
_NetworkProviderImpl_tc.set(this, void 0);
|
|
@@ -119,12 +127,8 @@ class NetworkProviderImpl {
|
|
|
119
127
|
return __classPrivateFieldGet(this, _NetworkProviderImpl_tc, "f");
|
|
120
128
|
}
|
|
121
129
|
provider(address, init) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
return new WrappedContractProvider(address, __classPrivateFieldGet(this, _NetworkProviderImpl_tc, "f").provider(address, { code: init?.code ?? new core_1.Cell(), data: init?.data ?? new core_1.Cell() }), init);
|
|
127
|
-
}
|
|
130
|
+
const factory = (params) => __classPrivateFieldGet(this, _NetworkProviderImpl_tc, "f").provider(params.address, params.init);
|
|
131
|
+
return new WrappedContractProvider(address, factory, init);
|
|
128
132
|
}
|
|
129
133
|
async isContractDeployed(address) {
|
|
130
134
|
if (__classPrivateFieldGet(this, _NetworkProviderImpl_tc, "f") instanceof ton_1.TonClient4) {
|
|
@@ -176,7 +180,7 @@ class NetworkProviderImpl {
|
|
|
176
180
|
await this.waitForDeploy(contract.address, waitAttempts);
|
|
177
181
|
}
|
|
178
182
|
open(contract) {
|
|
179
|
-
return (0, core_1.openContract)(contract, (params) => this.provider(params.address, params.init ??
|
|
183
|
+
return (0, core_1.openContract)(contract, (params) => this.provider(params.address, params.init ?? null));
|
|
180
184
|
}
|
|
181
185
|
ui() {
|
|
182
186
|
return __classPrivateFieldGet(this, _NetworkProviderImpl_ui, "f");
|
|
@@ -322,7 +326,7 @@ class NetworkProviderBuilder {
|
|
|
322
326
|
}
|
|
323
327
|
if (configNetwork.version === undefined || configNetwork.version === 'v2') {
|
|
324
328
|
tc = new ton_1.TonClient({
|
|
325
|
-
endpoint: configNetwork.endpoint
|
|
329
|
+
endpoint: configNetwork.endpoint,
|
|
326
330
|
apiKey: configNetwork.key,
|
|
327
331
|
});
|
|
328
332
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ton/blueprint",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "Framework for development of TON smart contracts",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": "./dist/cli/cli.js",
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"format": "prettier --write src"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@ton/core": "^0.
|
|
22
|
+
"@ton/core": "^0.56.0",
|
|
23
23
|
"@ton/crypto": "^3.2.0",
|
|
24
|
-
"@ton/ton": "^13.
|
|
24
|
+
"@ton/ton": "^13.11.0",
|
|
25
25
|
"@types/inquirer": "^8.2.6",
|
|
26
26
|
"@types/node": "^20.2.5",
|
|
27
27
|
"@types/qrcode-terminal": "^0.12.0",
|
|
@@ -29,13 +29,13 @@
|
|
|
29
29
|
"typescript": "^4.9.5"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"@ton/core": ">=0.
|
|
32
|
+
"@ton/core": ">=0.56.0",
|
|
33
33
|
"@ton/crypto": ">=3.2.0",
|
|
34
|
-
"@ton/ton": ">=13.
|
|
34
|
+
"@ton/ton": ">=13.11.0"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@orbs-network/ton-access": "^2.3.3",
|
|
38
|
-
"@tact-lang/compiler": "^1.
|
|
38
|
+
"@tact-lang/compiler": "^1.2.0",
|
|
39
39
|
"@ton-community/func-js": "^0.6.3",
|
|
40
40
|
"@tonconnect/sdk": "^2.1.3",
|
|
41
41
|
"arg": "^5.0.2",
|