@ton/blueprint 0.25.0 → 0.27.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,18 @@ 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.27.0] - 2024-12-18
9
+
10
+ ### Changed
11
+
12
+ - Updated `@ton-community/func-js` dependency to v0.9.0
13
+
14
+ ## [0.26.0] - 2024-11-26
15
+
16
+ ### Added
17
+
18
+ - Added support for tonapi as an API provider
19
+
8
20
  ## [0.25.0] - 2024-11-02
9
21
 
10
22
  ### Added
package/README.md CHANGED
@@ -188,6 +188,7 @@ export const config: Config = {
188
188
 
189
189
  Here are some of the plugins developed by the community:
190
190
  - [scaffold](https://github.com/1IxI1/blueprint-scaffold) - allows developers to quickly create a simple dapp automatically using the wrappers' code
191
+ - [misti](https://github.com/nowarp/blueprint-misti) - simplifies workflow with the [Misti](https://nowarp.github.io/tools/misti/) static analyzer
191
192
 
192
193
  ### Custom network
193
194
 
@@ -63,11 +63,11 @@ Script name is matched (ignoring case) to a file in the scripts directory. If no
63
63
  Flags:
64
64
  --mainnet, --testnet - specifies the network to use when running the script. If not specified on the command line, it will be asked interactively.
65
65
  --custom [api-endpoint] - indicates that a custom API should be used when running the script, and the API URL optionally. (example: https://testnet.toncenter.com/api/v2/)
66
- --custom-version - specifies the API version to use with the custom API. Options: v2 (defualt), v4.
66
+ --custom-version - specifies the API version to use with the custom API. Options: v2 (default), v4.
67
67
  --custom-key - specifies the API key to use with the custom API, can only be used with API v2.
68
68
  --custom-type - specifies the network type to be indicated to scripts. Options: custom (default), mainnet, testnet.
69
69
  --tonconnect, --deeplink, --mnemonic - specifies the deployer to use when running the script. If not specified on the command line, it will be asked interactively.
70
- --tonscan, --tonviewer, --toncx, --dton - specifies the network explorer to use when displaying links to the deployed contracts. Default: tonscan.`,
70
+ --tonscan, --tonviewer, --toncx, --dton - specifies the network explorer to use when displaying links to the deployed contracts. Default: tonviewer.`,
71
71
  build: `Usage: blueprint build [contract name] [flags]
72
72
 
73
73
  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.
@@ -1,6 +1,6 @@
1
1
  export type CustomNetwork = {
2
2
  endpoint: string;
3
- version?: 'v2' | 'v4';
3
+ version?: 'v2' | 'v4' | 'tonapi';
4
4
  key?: string;
5
5
  type?: 'mainnet' | 'testnet' | 'custom';
6
6
  };
@@ -1,10 +1,12 @@
1
1
  import { TonClient, TonClient4 } from '@ton/ton';
2
2
  import { Address, Cell, Contract, ContractProvider, OpenedContract, Sender } from '@ton/core';
3
+ import { ContractAdapter } from '@ton-api/ton-adapter';
3
4
  import { UIProvider } from '../ui/UIProvider';
5
+ export type BlueprintTonClient = TonClient4 | TonClient | ContractAdapter;
4
6
  export interface NetworkProvider {
5
7
  network(): 'mainnet' | 'testnet' | 'custom';
6
8
  sender(): Sender;
7
- api(): TonClient4 | TonClient;
9
+ api(): BlueprintTonClient;
8
10
  provider(address: Address, init?: {
9
11
  code?: Cell;
10
12
  data?: Cell;
@@ -21,6 +21,8 @@ const DeeplinkProvider_1 = require("./send/DeeplinkProvider");
21
21
  const TonConnectProvider_1 = require("./send/TonConnectProvider");
22
22
  const core_1 = require("@ton/core");
23
23
  const ton_1 = require("@ton/ton");
24
+ const ton_adapter_1 = require("@ton-api/ton-adapter");
25
+ const client_1 = require("@ton-api/client");
24
26
  const FSStorage_1 = require("./storage/FSStorage");
25
27
  const path_1 = __importDefault(require("path"));
26
28
  const paths_1 = require("../paths");
@@ -127,16 +129,15 @@ class NetworkProviderImpl {
127
129
  return __classPrivateFieldGet(this, _NetworkProviderImpl_tc, "f");
128
130
  }
129
131
  provider(address, init) {
130
- const factory = (params) => __classPrivateFieldGet(this, _NetworkProviderImpl_tc, "f").provider(params.address, params.init);
132
+ const factory = (params) => __classPrivateFieldGet(this, _NetworkProviderImpl_tc, "f").provider(params.address, params.init && {
133
+ ...params.init,
134
+ data: params.init.data ?? undefined,
135
+ code: params.init.code ?? undefined,
136
+ });
131
137
  return new WrappedContractProvider(address, factory, init);
132
138
  }
133
139
  async isContractDeployed(address) {
134
- if (__classPrivateFieldGet(this, _NetworkProviderImpl_tc, "f") instanceof ton_1.TonClient4) {
135
- return __classPrivateFieldGet(this, _NetworkProviderImpl_tc, "f").isContractDeployed((await __classPrivateFieldGet(this, _NetworkProviderImpl_tc, "f").getLastBlock()).last.seqno, address);
136
- }
137
- else {
138
- return (await __classPrivateFieldGet(this, _NetworkProviderImpl_tc, "f").getContractState(address)).state === 'active';
139
- }
140
+ return (await __classPrivateFieldGet(this, _NetworkProviderImpl_tc, "f").provider(address).getState()).state.type === 'active';
140
141
  }
141
142
  async waitForDeploy(address, attempts = 20, sleepDuration = 2000) {
142
143
  if (attempts <= 0) {
@@ -328,6 +329,12 @@ class NetworkProviderBuilder {
328
329
  endpoint: configNetwork.endpoint,
329
330
  });
330
331
  }
332
+ else if (configNetwork.version === 'tonapi') {
333
+ tc = new ton_adapter_1.ContractAdapter(new client_1.TonApiClient({
334
+ baseUrl: configNetwork.endpoint,
335
+ apiKey: configNetwork.key,
336
+ }));
337
+ }
331
338
  else {
332
339
  throw new Error('Unknown API version: ' + configNetwork.version);
333
340
  }
@@ -365,7 +372,9 @@ class NetworkProviderBuilder {
365
372
  }
366
373
  };
367
374
  tc = new ton_1.TonClient({
368
- endpoint: network === 'mainnet' ? 'https://toncenter.com/api/v2/jsonRPC' : 'https://testnet.toncenter.com/api/v2/jsonRPC',
375
+ endpoint: network === 'mainnet'
376
+ ? 'https://toncenter.com/api/v2/jsonRPC'
377
+ : 'https://testnet.toncenter.com/api/v2/jsonRPC',
369
378
  httpAdapter,
370
379
  });
371
380
  }
@@ -1,8 +1,8 @@
1
1
  /// <reference types="node" />
2
- import { TonClient, TonClient4 } from '@ton/ton';
3
2
  import { Address, Cell, StateInit } from '@ton/core';
4
3
  import { SendProvider } from './SendProvider';
5
4
  import { UIProvider } from '../../ui/UIProvider';
5
+ import { BlueprintTonClient } from '../NetworkProvider';
6
6
  export type WalletVersion = 'v1r1' | 'v1r2' | 'v1r3' | 'v2r1' | 'v2r2' | 'v3r1' | 'v3r2' | 'v4' | 'v5r1';
7
7
  export declare class MnemonicProvider implements SendProvider {
8
8
  #private;
@@ -10,7 +10,7 @@ export declare class MnemonicProvider implements SendProvider {
10
10
  version: WalletVersion;
11
11
  workchain?: number;
12
12
  secretKey: Buffer;
13
- client: TonClient4 | TonClient;
13
+ client: BlueprintTonClient;
14
14
  ui: UIProvider;
15
15
  });
16
16
  connect(): Promise<void>;
@@ -41,7 +41,11 @@ class MnemonicProvider {
41
41
  __classPrivateFieldSet(this, _MnemonicProvider_wallet, (0, core_1.openContract)(wallets[params.version].create({
42
42
  workchain: params.workchain ?? 0,
43
43
  publicKey: kp.publicKey,
44
- }), (params) => __classPrivateFieldGet(this, _MnemonicProvider_client, "f").provider(params.address, params.init)), "f");
44
+ }), (params) => __classPrivateFieldGet(this, _MnemonicProvider_client, "f").provider(params.address, params.init && {
45
+ ...params.init,
46
+ data: params.init.data ?? undefined,
47
+ code: params.init.code ?? undefined,
48
+ })), "f");
45
49
  __classPrivateFieldSet(this, _MnemonicProvider_secretKey, kp.secretKey, "f");
46
50
  __classPrivateFieldSet(this, _MnemonicProvider_ui, params.ui, "f");
47
51
  }
@@ -18,7 +18,7 @@ function getExplorerLink(address, network, explorer) {
18
18
  case 'dton':
19
19
  return `https://${networkPrefix}dton.io/a/${address}`;
20
20
  default:
21
- return `https://${networkPrefix}tonscan.org/address/${address}`;
21
+ return `https://${networkPrefix}tonviewer.com/${address}`;
22
22
  }
23
23
  }
24
24
  exports.getExplorerLink = getExplorerLink;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ton/blueprint",
3
- "version": "0.25.0",
3
+ "version": "0.27.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,7 +19,7 @@
19
19
  "format": "prettier --write src"
20
20
  },
21
21
  "devDependencies": {
22
- "@ton/core": "^0.58.1",
22
+ "@ton/core": "^0.59.0",
23
23
  "@ton/crypto": "^3.3.0",
24
24
  "@ton/ton": "^15.0.0",
25
25
  "@types/inquirer": "^8.2.6",
@@ -29,13 +29,15 @@
29
29
  "typescript": "^4.9.5"
30
30
  },
31
31
  "peerDependencies": {
32
- "@ton/core": ">=0.58.1",
32
+ "@ton/core": ">=0.59.0",
33
33
  "@ton/crypto": ">=3.3.0",
34
34
  "@ton/ton": ">=15.0.0"
35
35
  },
36
36
  "dependencies": {
37
37
  "@tact-lang/compiler": "^1.4.0",
38
- "@ton-community/func-js": "^0.7.0",
38
+ "@ton-api/client": "^0.2.0",
39
+ "@ton-api/ton-adapter": "^0.2.0",
40
+ "@ton-community/func-js": "^0.9.0",
39
41
  "@ton/tolk-js": "^0.6.0",
40
42
  "@tonconnect/sdk": "^2.2.0",
41
43
  "arg": "^5.0.2",