@ton/ton 13.10.0 → 13.11.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.
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
/// <reference types="node" />
|
|
9
9
|
import { HttpApi } from "./api/HttpApi";
|
|
10
10
|
import { AxiosAdapter } from 'axios';
|
|
11
|
-
import { Address, Cell, Contract, ContractProvider, Message, Transaction, TupleItem, TupleReader } from '@ton/core';
|
|
11
|
+
import { Address, Cell, Contract, ContractProvider, Message, Transaction, TupleItem, TupleReader, StateInit, OpenedContract } from '@ton/core';
|
|
12
12
|
export declare type TonClientParameters = {
|
|
13
13
|
/**
|
|
14
14
|
* API Endpoint
|
|
@@ -216,15 +216,12 @@ export declare class TonClient {
|
|
|
216
216
|
* @param src source contract
|
|
217
217
|
* @returns contract
|
|
218
218
|
*/
|
|
219
|
-
open<T extends Contract>(src: T):
|
|
219
|
+
open<T extends Contract>(src: T): OpenedContract<T>;
|
|
220
220
|
/**
|
|
221
221
|
* Create a provider
|
|
222
222
|
* @param address address
|
|
223
223
|
* @param init optional init
|
|
224
224
|
* @returns provider
|
|
225
225
|
*/
|
|
226
|
-
provider(address: Address, init:
|
|
227
|
-
code: Cell | null;
|
|
228
|
-
data: Cell | null;
|
|
229
|
-
} | null): ContractProvider;
|
|
226
|
+
provider(address: Address, init?: StateInit | null): ContractProvider;
|
|
230
227
|
}
|
package/dist/client/TonClient.js
CHANGED
|
@@ -211,7 +211,7 @@ class TonClient {
|
|
|
211
211
|
else {
|
|
212
212
|
const message = (0, core_1.external)({
|
|
213
213
|
to: contract.address,
|
|
214
|
-
init:
|
|
214
|
+
init: contract.init,
|
|
215
215
|
body: src
|
|
216
216
|
});
|
|
217
217
|
await this.sendMessage(message);
|
|
@@ -265,7 +265,7 @@ class TonClient {
|
|
|
265
265
|
* @returns provider
|
|
266
266
|
*/
|
|
267
267
|
provider(address, init) {
|
|
268
|
-
return createProvider(this, address, init);
|
|
268
|
+
return createProvider(this, address, init ?? null);
|
|
269
269
|
}
|
|
270
270
|
}
|
|
271
271
|
exports.TonClient = TonClient;
|
|
@@ -375,7 +375,7 @@ function createProvider(client, address, init) {
|
|
|
375
375
|
//
|
|
376
376
|
const ext = (0, core_1.external)({
|
|
377
377
|
to: address,
|
|
378
|
-
init: neededInit
|
|
378
|
+
init: neededInit,
|
|
379
379
|
body: message
|
|
380
380
|
});
|
|
381
381
|
let boc = (0, core_1.beginCell)()
|
|
@@ -420,6 +420,12 @@ function createProvider(client, address, init) {
|
|
|
420
420
|
init: neededInit,
|
|
421
421
|
body
|
|
422
422
|
});
|
|
423
|
+
},
|
|
424
|
+
open(contract) {
|
|
425
|
+
return (0, core_1.openContract)(contract, (args) => createProvider(client, args.address, args.init ?? null));
|
|
426
|
+
},
|
|
427
|
+
getTransactions(address, lt, hash, limit) {
|
|
428
|
+
return client.getTransactions(address, { limit: limit ?? 100, lt: lt.toString(), hash: hash.toString('base64'), inclusive: true });
|
|
423
429
|
}
|
|
424
430
|
};
|
|
425
431
|
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
/// <reference types="node" />
|
|
9
9
|
import { AxiosAdapter } from "axios";
|
|
10
|
-
import { Address,
|
|
10
|
+
import { Address, Contract, ContractProvider, OpenedContract, StateInit, Transaction, TupleItem, TupleReader } from "@ton/core";
|
|
11
11
|
import { z } from 'zod';
|
|
12
12
|
export declare type TonClient4Parameters = {
|
|
13
13
|
/**
|
|
@@ -267,24 +267,21 @@ export declare class TonClient4 {
|
|
|
267
267
|
* @param contract contract
|
|
268
268
|
* @returns opened contract
|
|
269
269
|
*/
|
|
270
|
-
open<T extends Contract>(contract: T):
|
|
270
|
+
open<T extends Contract>(contract: T): OpenedContract<T>;
|
|
271
271
|
/**
|
|
272
272
|
* Open smart contract
|
|
273
273
|
* @param block block number
|
|
274
274
|
* @param contract contract
|
|
275
275
|
* @returns opened contract
|
|
276
276
|
*/
|
|
277
|
-
openAt<T extends Contract>(block: number, contract: T):
|
|
277
|
+
openAt<T extends Contract>(block: number, contract: T): OpenedContract<T>;
|
|
278
278
|
/**
|
|
279
279
|
* Create provider
|
|
280
280
|
* @param address address
|
|
281
281
|
* @param init optional init data
|
|
282
282
|
* @returns provider
|
|
283
283
|
*/
|
|
284
|
-
provider(address: Address, init?:
|
|
285
|
-
code: Cell;
|
|
286
|
-
data: Cell;
|
|
287
|
-
} | null): ContractProvider;
|
|
284
|
+
provider(address: Address, init?: StateInit | null): ContractProvider;
|
|
288
285
|
/**
|
|
289
286
|
* Create provider at specified block number
|
|
290
287
|
* @param block block number
|
|
@@ -292,10 +289,7 @@ export declare class TonClient4 {
|
|
|
292
289
|
* @param init optional init data
|
|
293
290
|
* @returns provider
|
|
294
291
|
*/
|
|
295
|
-
providerAt(block: number, address: Address, init?:
|
|
296
|
-
code: Cell;
|
|
297
|
-
data: Cell;
|
|
298
|
-
} | null): ContractProvider;
|
|
292
|
+
providerAt(block: number, address: Address, init?: StateInit | null): ContractProvider;
|
|
299
293
|
}
|
|
300
294
|
declare const blocksCodec: z.ZodArray<z.ZodObject<{
|
|
301
295
|
workchain: z.ZodNumber;
|
|
@@ -259,7 +259,7 @@ class TonClient4 {
|
|
|
259
259
|
* @returns provider
|
|
260
260
|
*/
|
|
261
261
|
provider(address, init) {
|
|
262
|
-
return createProvider(this, null, address, init
|
|
262
|
+
return createProvider(this, null, address, init ?? null);
|
|
263
263
|
}
|
|
264
264
|
/**
|
|
265
265
|
* Create provider at specified block number
|
|
@@ -269,7 +269,7 @@ class TonClient4 {
|
|
|
269
269
|
* @returns provider
|
|
270
270
|
*/
|
|
271
271
|
providerAt(block, address, init) {
|
|
272
|
-
return createProvider(this, block, address, init
|
|
272
|
+
return createProvider(this, block, address, init ?? null);
|
|
273
273
|
}
|
|
274
274
|
}
|
|
275
275
|
exports.TonClient4 = TonClient4;
|
|
@@ -340,7 +340,7 @@ function createProvider(client, block, address, init) {
|
|
|
340
340
|
// Send with state init
|
|
341
341
|
const ext = (0, core_1.external)({
|
|
342
342
|
to: address,
|
|
343
|
-
init: neededInit
|
|
343
|
+
init: neededInit,
|
|
344
344
|
body: message
|
|
345
345
|
});
|
|
346
346
|
let pkg = (0, core_1.beginCell)()
|
|
@@ -387,6 +387,44 @@ function createProvider(client, block, address, init) {
|
|
|
387
387
|
init: neededInit,
|
|
388
388
|
body
|
|
389
389
|
});
|
|
390
|
+
},
|
|
391
|
+
open(contract) {
|
|
392
|
+
return (0, core_1.openContract)(contract, (args) => createProvider(client, block, args.address, args.init ?? null));
|
|
393
|
+
},
|
|
394
|
+
async getTransactions(address, lt, hash, limit) {
|
|
395
|
+
// Resolve last
|
|
396
|
+
const useLimit = typeof limit === 'number';
|
|
397
|
+
if (useLimit && limit <= 0) {
|
|
398
|
+
return [];
|
|
399
|
+
}
|
|
400
|
+
// Load transactions
|
|
401
|
+
let transactions = [];
|
|
402
|
+
do {
|
|
403
|
+
const txs = await client.getAccountTransactions(address, lt, hash);
|
|
404
|
+
const firstTx = txs[0].tx;
|
|
405
|
+
const [firstLt, firstHash] = [firstTx.lt, firstTx.hash()];
|
|
406
|
+
const needSkipFirst = transactions.length > 0 && firstLt === lt && firstHash.equals(hash);
|
|
407
|
+
if (needSkipFirst) {
|
|
408
|
+
txs.shift();
|
|
409
|
+
}
|
|
410
|
+
if (txs.length === 0) {
|
|
411
|
+
break;
|
|
412
|
+
}
|
|
413
|
+
const lastTx = txs[txs.length - 1].tx;
|
|
414
|
+
const [lastLt, lastHash] = [lastTx.lt, lastTx.hash()];
|
|
415
|
+
if (lastLt === lt && lastHash.equals(hash)) {
|
|
416
|
+
break;
|
|
417
|
+
}
|
|
418
|
+
transactions.push(...txs.map(tx => tx.tx));
|
|
419
|
+
lt = lastLt;
|
|
420
|
+
hash = lastHash;
|
|
421
|
+
} while (useLimit && transactions.length < limit);
|
|
422
|
+
// Apply limit
|
|
423
|
+
if (useLimit) {
|
|
424
|
+
transactions = transactions.slice(0, limit);
|
|
425
|
+
}
|
|
426
|
+
// Return transactions
|
|
427
|
+
return transactions;
|
|
390
428
|
}
|
|
391
429
|
};
|
|
392
430
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ton/ton",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.11.0",
|
|
4
4
|
"repository": "https://github.com/ton-org/ton.git",
|
|
5
5
|
"author": "Whales Corp. <developers@whalescorp.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@release-it/keep-a-changelog": "^3.1.0",
|
|
19
|
-
"@ton/core": "^0.
|
|
19
|
+
"@ton/core": "^0.56.0",
|
|
20
20
|
"@ton/crypto": "3.2.0",
|
|
21
21
|
"@ton/emulator": "^2.1.1",
|
|
22
22
|
"@types/jest": "^27.0.1",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"zod": "^3.21.4"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@ton/core": ">=0.
|
|
50
|
+
"@ton/core": ">=0.56.0",
|
|
51
51
|
"@ton/crypto": ">=3.2.0"
|
|
52
52
|
},
|
|
53
53
|
"publishConfig": {
|