@ton/ton 13.5.1

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 (80) hide show
  1. package/CHANGELOG.md +133 -0
  2. package/LICENSE +9 -0
  3. package/README.md +78 -0
  4. package/dist/client/TonClient.d.ts +231 -0
  5. package/dist/client/TonClient.js +392 -0
  6. package/dist/client/TonClient.spec.d.ts +1 -0
  7. package/dist/client/TonClient.spec.js +37 -0
  8. package/dist/client/TonClient4.d.ts +289 -0
  9. package/dist/client/TonClient4.js +514 -0
  10. package/dist/client/TonClient4.spec.d.ts +1 -0
  11. package/dist/client/TonClient4.spec.js +36 -0
  12. package/dist/client/api/HttpApi.d.ts +632 -0
  13. package/dist/client/api/HttpApi.js +297 -0
  14. package/dist/client/api/TonCache.d.ts +16 -0
  15. package/dist/client/api/TonCache.js +33 -0
  16. package/dist/index.d.ts +24 -0
  17. package/dist/index.js +68 -0
  18. package/dist/jetton/JettonMaster.d.ts +21 -0
  19. package/dist/jetton/JettonMaster.js +39 -0
  20. package/dist/jetton/JettonMaster.spec.d.ts +8 -0
  21. package/dist/jetton/JettonMaster.spec.js +27 -0
  22. package/dist/jetton/JettonWallet.d.ts +14 -0
  23. package/dist/jetton/JettonWallet.js +27 -0
  24. package/dist/multisig/MultisigOrder.d.ts +17 -0
  25. package/dist/multisig/MultisigOrder.js +73 -0
  26. package/dist/multisig/MultisigOrder.spec.d.ts +1 -0
  27. package/dist/multisig/MultisigOrder.spec.js +139 -0
  28. package/dist/multisig/MultisigOrderBuilder.d.ts +13 -0
  29. package/dist/multisig/MultisigOrderBuilder.js +37 -0
  30. package/dist/multisig/MultisigWallet.d.ts +26 -0
  31. package/dist/multisig/MultisigWallet.js +120 -0
  32. package/dist/multisig/MultisigWallet.spec.d.ts +1 -0
  33. package/dist/multisig/MultisigWallet.spec.js +230 -0
  34. package/dist/utils/createTestClient.d.ts +9 -0
  35. package/dist/utils/createTestClient.js +18 -0
  36. package/dist/utils/createTestClient4.d.ts +9 -0
  37. package/dist/utils/createTestClient4.js +15 -0
  38. package/dist/utils/maybe.d.ts +8 -0
  39. package/dist/utils/maybe.js +9 -0
  40. package/dist/utils/randomTestKey.d.ts +8 -0
  41. package/dist/utils/randomTestKey.js +24 -0
  42. package/dist/utils/time.d.ts +15 -0
  43. package/dist/utils/time.js +63 -0
  44. package/dist/utils/toUrlSafe.d.ts +8 -0
  45. package/dist/utils/toUrlSafe.js +23 -0
  46. package/dist/wallets/WalletContractV1R1.d.ts +58 -0
  47. package/dist/wallets/WalletContractV1R1.js +100 -0
  48. package/dist/wallets/WalletContractV1R1.spec.d.ts +8 -0
  49. package/dist/wallets/WalletContractV1R1.spec.js +44 -0
  50. package/dist/wallets/WalletContractV1R2.d.ts +58 -0
  51. package/dist/wallets/WalletContractV1R2.js +101 -0
  52. package/dist/wallets/WalletContractV1R2.spec.d.ts +8 -0
  53. package/dist/wallets/WalletContractV1R2.spec.js +44 -0
  54. package/dist/wallets/WalletContractV1R3.d.ts +58 -0
  55. package/dist/wallets/WalletContractV1R3.js +101 -0
  56. package/dist/wallets/WalletContractV1R3.spec.d.ts +8 -0
  57. package/dist/wallets/WalletContractV1R3.spec.js +44 -0
  58. package/dist/wallets/WalletContractV2R1.d.ts +60 -0
  59. package/dist/wallets/WalletContractV2R1.js +102 -0
  60. package/dist/wallets/WalletContractV2R1.spec.d.ts +8 -0
  61. package/dist/wallets/WalletContractV2R1.spec.js +44 -0
  62. package/dist/wallets/WalletContractV2R2.d.ts +60 -0
  63. package/dist/wallets/WalletContractV2R2.js +102 -0
  64. package/dist/wallets/WalletContractV2R2.spec.d.ts +8 -0
  65. package/dist/wallets/WalletContractV2R2.spec.js +44 -0
  66. package/dist/wallets/WalletContractV3R1.d.ts +62 -0
  67. package/dist/wallets/WalletContractV3R1.js +111 -0
  68. package/dist/wallets/WalletContractV3R1.spec.d.ts +8 -0
  69. package/dist/wallets/WalletContractV3R1.spec.js +44 -0
  70. package/dist/wallets/WalletContractV3R2.d.ts +62 -0
  71. package/dist/wallets/WalletContractV3R2.js +111 -0
  72. package/dist/wallets/WalletContractV3R2.spec.d.ts +8 -0
  73. package/dist/wallets/WalletContractV3R2.spec.js +44 -0
  74. package/dist/wallets/WalletContractV4.d.ts +62 -0
  75. package/dist/wallets/WalletContractV4.js +112 -0
  76. package/dist/wallets/WalletContractV4.spec.d.ts +8 -0
  77. package/dist/wallets/WalletContractV4.spec.js +48 -0
  78. package/dist/wallets/signing/createWalletTransfer.d.ts +39 -0
  79. package/dist/wallets/signing/createWalletTransfer.js +122 -0
  80. package/package.json +68 -0
@@ -0,0 +1,514 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Whales Corp.
4
+ * All Rights Reserved.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
10
+ if (kind === "m") throw new TypeError("Private method is not writable");
11
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
12
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
13
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
14
+ };
15
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
16
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
17
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
18
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
19
+ };
20
+ var __importDefault = (this && this.__importDefault) || function (mod) {
21
+ return (mod && mod.__esModule) ? mod : { "default": mod };
22
+ };
23
+ var _TonClient4_endpoint, _TonClient4_timeout, _TonClient4_adapter;
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.TonClient4 = void 0;
26
+ const axios_1 = __importDefault(require("axios"));
27
+ const core_1 = require("@ton/core");
28
+ const toUrlSafe_1 = require("../utils/toUrlSafe");
29
+ const zod_1 = require("zod");
30
+ class TonClient4 {
31
+ constructor(args) {
32
+ _TonClient4_endpoint.set(this, void 0);
33
+ _TonClient4_timeout.set(this, void 0);
34
+ _TonClient4_adapter.set(this, void 0);
35
+ __classPrivateFieldSet(this, _TonClient4_endpoint, args.endpoint, "f");
36
+ __classPrivateFieldSet(this, _TonClient4_timeout, args.timeout || 5000, "f");
37
+ __classPrivateFieldSet(this, _TonClient4_adapter, args.httpAdapter, "f");
38
+ }
39
+ /**
40
+ * Get Last Block
41
+ * @returns last block info
42
+ */
43
+ async getLastBlock() {
44
+ let res = await axios_1.default.get(__classPrivateFieldGet(this, _TonClient4_endpoint, "f") + '/block/latest', { adapter: __classPrivateFieldGet(this, _TonClient4_adapter, "f"), timeout: __classPrivateFieldGet(this, _TonClient4_timeout, "f") });
45
+ let lastBlock = lastBlockCodec.safeParse(res.data);
46
+ if (!lastBlock.success) {
47
+ throw Error('Mailformed response: ' + lastBlock.error.format()._errors.join(', '));
48
+ }
49
+ return lastBlock.data;
50
+ }
51
+ /**
52
+ * Get block info
53
+ * @param seqno block sequence number
54
+ * @returns block info
55
+ */
56
+ async getBlock(seqno) {
57
+ let res = await axios_1.default.get(__classPrivateFieldGet(this, _TonClient4_endpoint, "f") + '/block/' + seqno, { adapter: __classPrivateFieldGet(this, _TonClient4_adapter, "f"), timeout: __classPrivateFieldGet(this, _TonClient4_timeout, "f") });
58
+ let block = blockCodec.safeParse(res.data);
59
+ if (!block.success) {
60
+ throw Error('Mailformed response');
61
+ }
62
+ if (!block.data.exist) {
63
+ throw Error('Block is out of scope');
64
+ }
65
+ return block.data.block;
66
+ }
67
+ /**
68
+ * Get block info by unix timestamp
69
+ * @param ts unix timestamp
70
+ * @returns block info
71
+ */
72
+ async getBlockByUtime(ts) {
73
+ let res = await axios_1.default.get(__classPrivateFieldGet(this, _TonClient4_endpoint, "f") + '/block/utime/' + ts, { adapter: __classPrivateFieldGet(this, _TonClient4_adapter, "f"), timeout: __classPrivateFieldGet(this, _TonClient4_timeout, "f") });
74
+ let block = blockCodec.safeParse(res.data);
75
+ if (!block.success) {
76
+ throw Error('Mailformed response');
77
+ }
78
+ if (!block.data.exist) {
79
+ throw Error('Block is out of scope');
80
+ }
81
+ return block.data.block;
82
+ }
83
+ /**
84
+ * Get block info by unix timestamp
85
+ * @param seqno block sequence number
86
+ * @param address account address
87
+ * @returns account info
88
+ */
89
+ async getAccount(seqno, address) {
90
+ let res = await axios_1.default.get(__classPrivateFieldGet(this, _TonClient4_endpoint, "f") + '/block/' + seqno + '/' + address.toString({ urlSafe: true }), { adapter: __classPrivateFieldGet(this, _TonClient4_adapter, "f"), timeout: __classPrivateFieldGet(this, _TonClient4_timeout, "f") });
91
+ let account = accountCodec.safeParse(res.data);
92
+ if (!account.success) {
93
+ throw Error('Mailformed response');
94
+ }
95
+ return account.data;
96
+ }
97
+ /**
98
+ * Get account lite info (without code and data)
99
+ * @param seqno block sequence number
100
+ * @param address account address
101
+ * @returns account lite info
102
+ */
103
+ async getAccountLite(seqno, address) {
104
+ let res = await axios_1.default.get(__classPrivateFieldGet(this, _TonClient4_endpoint, "f") + '/block/' + seqno + '/' + address.toString({ urlSafe: true }) + '/lite', { adapter: __classPrivateFieldGet(this, _TonClient4_adapter, "f"), timeout: __classPrivateFieldGet(this, _TonClient4_timeout, "f") });
105
+ let account = accountLiteCodec.safeParse(res.data);
106
+ if (!account.success) {
107
+ throw Error('Mailformed response');
108
+ }
109
+ return account.data;
110
+ }
111
+ /**
112
+ * Check if contract is deployed
113
+ * @param address addres to check
114
+ * @returns true if contract is in active state
115
+ */
116
+ async isContractDeployed(seqno, address) {
117
+ let account = await this.getAccountLite(seqno, address);
118
+ return account.account.state.type === 'active';
119
+ }
120
+ /**
121
+ * Check if account was updated since
122
+ * @param seqno block sequence number
123
+ * @param address account address
124
+ * @param lt account last transaction lt
125
+ * @returns account change info
126
+ */
127
+ async isAccountChanged(seqno, address, lt) {
128
+ let res = await axios_1.default.get(__classPrivateFieldGet(this, _TonClient4_endpoint, "f") + '/block/' + seqno + '/' + address.toString({ urlSafe: true }) + '/changed/' + lt.toString(10), { adapter: __classPrivateFieldGet(this, _TonClient4_adapter, "f"), timeout: __classPrivateFieldGet(this, _TonClient4_timeout, "f") });
129
+ let changed = changedCodec.safeParse(res.data);
130
+ if (!changed.success) {
131
+ throw Error('Mailformed response');
132
+ }
133
+ return changed.data;
134
+ }
135
+ /**
136
+ * Load unparsed account transactions
137
+ * @param address address
138
+ * @param lt last transaction lt
139
+ * @param hash last transaction hash
140
+ * @returns unparsed transactions
141
+ */
142
+ async getAccountTransactions(address, lt, hash) {
143
+ let res = await axios_1.default.get(__classPrivateFieldGet(this, _TonClient4_endpoint, "f") + '/account/' + address.toString({ urlSafe: true }) + '/tx/' + lt.toString(10) + '/' + (0, toUrlSafe_1.toUrlSafe)(hash.toString('base64')), { adapter: __classPrivateFieldGet(this, _TonClient4_adapter, "f"), timeout: __classPrivateFieldGet(this, _TonClient4_timeout, "f") });
144
+ let transactions = transactionsCodec.safeParse(res.data);
145
+ if (!transactions.success) {
146
+ throw Error('Mailformed response');
147
+ }
148
+ let data = transactions.data;
149
+ let tx = [];
150
+ let cells = core_1.Cell.fromBoc(Buffer.from(data.boc, 'base64'));
151
+ for (let i = 0; i < data.blocks.length; i++) {
152
+ tx.push({
153
+ block: data.blocks[i],
154
+ tx: (0, core_1.loadTransaction)(cells[i].beginParse())
155
+ });
156
+ }
157
+ return tx;
158
+ }
159
+ /**
160
+ * Get network config
161
+ * @param seqno block sequence number
162
+ * @param ids optional config ids
163
+ * @returns network config
164
+ */
165
+ async getConfig(seqno, ids) {
166
+ let tail = '';
167
+ if (ids && ids.length > 0) {
168
+ tail = '/' + [...ids].sort().join(',');
169
+ }
170
+ let res = await axios_1.default.get(__classPrivateFieldGet(this, _TonClient4_endpoint, "f") + '/block/' + seqno + '/config' + tail, { adapter: __classPrivateFieldGet(this, _TonClient4_adapter, "f"), timeout: __classPrivateFieldGet(this, _TonClient4_timeout, "f") });
171
+ let config = configCodec.safeParse(res.data);
172
+ if (!config.success) {
173
+ throw Error('Mailformed response');
174
+ }
175
+ return config.data;
176
+ }
177
+ /**
178
+ * Execute run method
179
+ * @param seqno block sequence number
180
+ * @param address account address
181
+ * @param name method name
182
+ * @param args method arguments
183
+ * @returns method result
184
+ */
185
+ async runMethod(seqno, address, name, args) {
186
+ let tail = args && args.length > 0 ? '/' + (0, toUrlSafe_1.toUrlSafe)((0, core_1.serializeTuple)(args).toBoc({ idx: false, crc32: false }).toString('base64')) : '';
187
+ let url = __classPrivateFieldGet(this, _TonClient4_endpoint, "f") + '/block/' + seqno + '/' + address.toString({ urlSafe: true }) + '/run/' + name + tail;
188
+ let res = await axios_1.default.get(url, { adapter: __classPrivateFieldGet(this, _TonClient4_adapter, "f"), timeout: __classPrivateFieldGet(this, _TonClient4_timeout, "f") });
189
+ let runMethod = runMethodCodec.safeParse(res.data);
190
+ if (!runMethod.success) {
191
+ throw Error('Mailformed response');
192
+ }
193
+ let resultTuple = runMethod.data.resultRaw ? (0, core_1.parseTuple)(core_1.Cell.fromBoc(Buffer.from(runMethod.data.resultRaw, 'base64'))[0]) : [];
194
+ return {
195
+ exitCode: runMethod.data.exitCode,
196
+ result: resultTuple,
197
+ resultRaw: runMethod.data.resultRaw,
198
+ block: runMethod.data.block,
199
+ shardBlock: runMethod.data.shardBlock,
200
+ reader: new core_1.TupleReader(resultTuple),
201
+ };
202
+ }
203
+ /**
204
+ * Send external message
205
+ * @param message message boc
206
+ * @returns message status
207
+ */
208
+ async sendMessage(message) {
209
+ let res = await axios_1.default.post(__classPrivateFieldGet(this, _TonClient4_endpoint, "f") + '/send', { boc: message.toString('base64') }, { adapter: __classPrivateFieldGet(this, _TonClient4_adapter, "f"), timeout: __classPrivateFieldGet(this, _TonClient4_timeout, "f") });
210
+ let send = sendCodec.safeParse(res.data);
211
+ if (!send.success) {
212
+ throw Error('Mailformed response');
213
+ }
214
+ return { status: res.data.status };
215
+ }
216
+ /**
217
+ * Open smart contract
218
+ * @param contract contract
219
+ * @returns opened contract
220
+ */
221
+ open(contract) {
222
+ return (0, core_1.openContract)(contract, (args) => createProvider(this, null, args.address, args.init));
223
+ }
224
+ /**
225
+ * Open smart contract
226
+ * @param block block number
227
+ * @param contract contract
228
+ * @returns opened contract
229
+ */
230
+ openAt(block, contract) {
231
+ return (0, core_1.openContract)(contract, (args) => createProvider(this, block, args.address, args.init));
232
+ }
233
+ /**
234
+ * Create provider
235
+ * @param address address
236
+ * @param init optional init data
237
+ * @returns provider
238
+ */
239
+ provider(address, init) {
240
+ return createProvider(this, null, address, init ? init : null);
241
+ }
242
+ /**
243
+ * Create provider at specified block number
244
+ * @param block block number
245
+ * @param address address
246
+ * @param init optional init data
247
+ * @returns provider
248
+ */
249
+ providerAt(block, address, init) {
250
+ return createProvider(this, block, address, init ? init : null);
251
+ }
252
+ }
253
+ exports.TonClient4 = TonClient4;
254
+ _TonClient4_endpoint = new WeakMap(), _TonClient4_timeout = new WeakMap(), _TonClient4_adapter = new WeakMap();
255
+ function createProvider(client, block, address, init) {
256
+ return {
257
+ async getState() {
258
+ // Resolve block
259
+ let sq = block;
260
+ if (sq === null) {
261
+ let res = await client.getLastBlock();
262
+ sq = res.last.seqno;
263
+ }
264
+ // Load state
265
+ let state = await client.getAccount(sq, address);
266
+ // Convert state
267
+ let last = state.account.last ? { lt: BigInt(state.account.last.lt), hash: Buffer.from(state.account.last.hash, 'base64') } : null;
268
+ let storage;
269
+ if (state.account.state.type === 'active') {
270
+ storage = {
271
+ type: 'active',
272
+ code: state.account.state.code ? Buffer.from(state.account.state.code, 'base64') : null,
273
+ data: state.account.state.data ? Buffer.from(state.account.state.data, 'base64') : null,
274
+ };
275
+ }
276
+ else if (state.account.state.type === 'uninit') {
277
+ storage = {
278
+ type: 'uninit',
279
+ };
280
+ }
281
+ else if (state.account.state.type === 'frozen') {
282
+ storage = {
283
+ type: 'frozen',
284
+ stateHash: Buffer.from(state.account.state.stateHash, 'base64'),
285
+ };
286
+ }
287
+ else {
288
+ throw Error('Unsupported state');
289
+ }
290
+ return {
291
+ balance: BigInt(state.account.balance.coins),
292
+ last: last,
293
+ state: storage
294
+ };
295
+ },
296
+ async get(name, args) {
297
+ let sq = block;
298
+ if (sq === null) {
299
+ let res = await client.getLastBlock();
300
+ sq = res.last.seqno;
301
+ }
302
+ let method = await client.runMethod(sq, address, name, args);
303
+ if (method.exitCode !== 0 && method.exitCode !== 1) {
304
+ throw Error('Exit code: ' + method.exitCode);
305
+ }
306
+ return {
307
+ stack: new core_1.TupleReader(method.result),
308
+ };
309
+ },
310
+ async external(message) {
311
+ // Resolve last
312
+ let last = await client.getLastBlock();
313
+ // Resolve init
314
+ let neededInit = null;
315
+ if (init && (await client.getAccountLite(last.last.seqno, address)).account.state.type !== 'active') {
316
+ neededInit = init;
317
+ }
318
+ // Send with state init
319
+ const ext = (0, core_1.external)({
320
+ to: address,
321
+ init: neededInit ? { code: neededInit.code, data: neededInit.data } : null,
322
+ body: message
323
+ });
324
+ let pkg = (0, core_1.beginCell)()
325
+ .store((0, core_1.storeMessage)(ext))
326
+ .endCell()
327
+ .toBoc();
328
+ await client.sendMessage(pkg);
329
+ },
330
+ async internal(via, message) {
331
+ // Resolve last
332
+ let last = await client.getLastBlock();
333
+ // Resolve init
334
+ let neededInit = null;
335
+ if (init && (await client.getAccountLite(last.last.seqno, address)).account.state.type !== 'active') {
336
+ neededInit = init;
337
+ }
338
+ // Resolve bounce
339
+ let bounce = true;
340
+ if (message.bounce !== null && message.bounce !== undefined) {
341
+ bounce = message.bounce;
342
+ }
343
+ // Resolve value
344
+ let value;
345
+ if (typeof message.value === 'string') {
346
+ value = (0, core_1.toNano)(message.value);
347
+ }
348
+ else {
349
+ value = message.value;
350
+ }
351
+ // Resolve body
352
+ let body = null;
353
+ if (typeof message.body === 'string') {
354
+ body = (0, core_1.comment)(message.body);
355
+ }
356
+ else if (message.body) {
357
+ body = message.body;
358
+ }
359
+ // Send internal message
360
+ await via.send({
361
+ to: address,
362
+ value,
363
+ bounce,
364
+ sendMode: message.sendMode,
365
+ init: neededInit,
366
+ body
367
+ });
368
+ }
369
+ };
370
+ }
371
+ //
372
+ // Codecs
373
+ //
374
+ const lastBlockCodec = zod_1.z.object({
375
+ last: zod_1.z.object({
376
+ seqno: zod_1.z.number(),
377
+ shard: zod_1.z.string(),
378
+ workchain: zod_1.z.number(),
379
+ fileHash: zod_1.z.string(),
380
+ rootHash: zod_1.z.string()
381
+ }),
382
+ init: zod_1.z.object({
383
+ fileHash: zod_1.z.string(),
384
+ rootHash: zod_1.z.string()
385
+ }),
386
+ stateRootHash: zod_1.z.string(),
387
+ now: zod_1.z.number()
388
+ });
389
+ const blockCodec = zod_1.z.union([zod_1.z.object({
390
+ exist: zod_1.z.literal(false)
391
+ }), zod_1.z.object({
392
+ exist: zod_1.z.literal(true),
393
+ block: zod_1.z.object({
394
+ shards: zod_1.z.array(zod_1.z.object({
395
+ workchain: zod_1.z.number(),
396
+ seqno: zod_1.z.number(),
397
+ shard: zod_1.z.string(),
398
+ rootHash: zod_1.z.string(),
399
+ fileHash: zod_1.z.string(),
400
+ transactions: zod_1.z.array(zod_1.z.object({
401
+ account: zod_1.z.string(),
402
+ hash: zod_1.z.string(),
403
+ lt: zod_1.z.string()
404
+ }))
405
+ }))
406
+ })
407
+ })]);
408
+ // {"lastPaid":1653099243,"duePayment":null,"used":{"bits":119,"cells":1,"publicCells":0}}
409
+ const storageStatCodec = zod_1.z.object({
410
+ lastPaid: zod_1.z.number(),
411
+ duePayment: zod_1.z.union([zod_1.z.null(), zod_1.z.string()]),
412
+ used: zod_1.z.object({
413
+ bits: zod_1.z.number(),
414
+ cells: zod_1.z.number(),
415
+ publicCells: zod_1.z.number()
416
+ })
417
+ });
418
+ const accountCodec = zod_1.z.object({
419
+ account: zod_1.z.object({
420
+ state: zod_1.z.union([
421
+ zod_1.z.object({ type: zod_1.z.literal('uninit') }),
422
+ zod_1.z.object({ type: zod_1.z.literal('active'), code: zod_1.z.union([zod_1.z.string(), zod_1.z.null()]), data: zod_1.z.union([zod_1.z.string(), zod_1.z.null()]) }),
423
+ zod_1.z.object({ type: zod_1.z.literal('frozen'), stateHash: zod_1.z.string() })
424
+ ]),
425
+ balance: zod_1.z.object({
426
+ coins: zod_1.z.string()
427
+ }),
428
+ last: zod_1.z.union([
429
+ zod_1.z.null(),
430
+ zod_1.z.object({
431
+ lt: zod_1.z.string(),
432
+ hash: zod_1.z.string()
433
+ })
434
+ ]),
435
+ storageStat: zod_1.z.union([zod_1.z.null(), storageStatCodec])
436
+ }),
437
+ block: zod_1.z.object({
438
+ workchain: zod_1.z.number(),
439
+ seqno: zod_1.z.number(),
440
+ shard: zod_1.z.string(),
441
+ rootHash: zod_1.z.string(),
442
+ fileHash: zod_1.z.string()
443
+ })
444
+ });
445
+ const accountLiteCodec = zod_1.z.object({
446
+ account: zod_1.z.object({
447
+ state: zod_1.z.union([
448
+ zod_1.z.object({ type: zod_1.z.literal('uninit') }),
449
+ zod_1.z.object({ type: zod_1.z.literal('active'), codeHash: zod_1.z.string(), dataHash: zod_1.z.string() }),
450
+ zod_1.z.object({ type: zod_1.z.literal('frozen'), stateHash: zod_1.z.string() })
451
+ ]),
452
+ balance: zod_1.z.object({
453
+ coins: zod_1.z.string()
454
+ }),
455
+ last: zod_1.z.union([
456
+ zod_1.z.null(),
457
+ zod_1.z.object({
458
+ lt: zod_1.z.string(),
459
+ hash: zod_1.z.string()
460
+ })
461
+ ]),
462
+ storageStat: zod_1.z.union([zod_1.z.null(), storageStatCodec])
463
+ })
464
+ });
465
+ const changedCodec = zod_1.z.object({
466
+ changed: zod_1.z.boolean(),
467
+ block: zod_1.z.object({
468
+ workchain: zod_1.z.number(),
469
+ seqno: zod_1.z.number(),
470
+ shard: zod_1.z.string(),
471
+ rootHash: zod_1.z.string(),
472
+ fileHash: zod_1.z.string()
473
+ })
474
+ });
475
+ const runMethodCodec = zod_1.z.object({
476
+ exitCode: zod_1.z.number(),
477
+ resultRaw: zod_1.z.union([zod_1.z.string(), zod_1.z.null()]),
478
+ block: zod_1.z.object({
479
+ workchain: zod_1.z.number(),
480
+ seqno: zod_1.z.number(),
481
+ shard: zod_1.z.string(),
482
+ rootHash: zod_1.z.string(),
483
+ fileHash: zod_1.z.string()
484
+ }),
485
+ shardBlock: zod_1.z.object({
486
+ workchain: zod_1.z.number(),
487
+ seqno: zod_1.z.number(),
488
+ shard: zod_1.z.string(),
489
+ rootHash: zod_1.z.string(),
490
+ fileHash: zod_1.z.string()
491
+ })
492
+ });
493
+ const configCodec = zod_1.z.object({
494
+ config: zod_1.z.object({
495
+ cell: zod_1.z.string(),
496
+ address: zod_1.z.string(),
497
+ globalBalance: zod_1.z.object({
498
+ coins: zod_1.z.string()
499
+ })
500
+ })
501
+ });
502
+ const sendCodec = zod_1.z.object({
503
+ status: zod_1.z.number()
504
+ });
505
+ const transactionsCodec = zod_1.z.object({
506
+ blocks: zod_1.z.array(zod_1.z.object({
507
+ workchain: zod_1.z.number(),
508
+ seqno: zod_1.z.number(),
509
+ shard: zod_1.z.string(),
510
+ rootHash: zod_1.z.string(),
511
+ fileHash: zod_1.z.string()
512
+ })),
513
+ boc: zod_1.z.string()
514
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@ton/core");
4
+ const TonClient4_1 = require("./TonClient4");
5
+ let describeConditional = process.env.TEST_CLIENTS ? describe : describe.skip;
6
+ describeConditional('TonClient', () => {
7
+ let client = new TonClient4_1.TonClient4({
8
+ endpoint: 'https://mainnet-v4.tonhubapi.com',
9
+ });
10
+ const testAddress = core_1.Address.parse('EQCD39VS5jcptHL8vMjEXrzGaRcCVYto7HUn4bpAOg8xqB2N');
11
+ let seqno;
12
+ beforeAll(async () => {
13
+ let last = await client.getLastBlock();
14
+ seqno = last.last.seqno;
15
+ });
16
+ it('should get account with transactions', async () => {
17
+ let account = await client.getAccount(seqno, testAddress);
18
+ let accountLite = await client.getAccountLite(seqno, testAddress);
19
+ let transactions = await client.getAccountTransactions(testAddress, BigInt(accountLite.account.last.lt), Buffer.from(accountLite.account.last.hash, 'base64'));
20
+ let result = await client.isAccountChanged(seqno, testAddress, BigInt(accountLite.account.last.lt));
21
+ console.log(transactions, result);
22
+ console.log(account, accountLite);
23
+ });
24
+ it('should get config', async () => {
25
+ let config = await client.getConfig(seqno);
26
+ console.log(config);
27
+ });
28
+ it('should get block', async () => {
29
+ let result = await client.getBlock(seqno);
30
+ console.log(result);
31
+ });
32
+ it('should run method', async () => {
33
+ let result = await client.runMethod(seqno, testAddress, 'seqno');
34
+ console.log(result);
35
+ });
36
+ });