@ton/ton 15.0.0 → 15.2.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/dist/client/TonClient.d.ts +5 -1
- package/dist/client/TonClient.js +14 -1
- package/dist/client/TonClient.spec.js +11 -0
- package/dist/client/TonClient4.d.ts +18 -17
- package/dist/client/TonClient4.js +17 -2
- package/dist/client/TonClient4.spec.js +25 -0
- package/dist/client/api/HttpApi.d.ts +5 -1
- package/dist/client/api/HttpApi.js +6 -1
- package/dist/config/ConfigParser.d.ts +0 -1
- package/dist/config/ConfigParser.js +25 -26
- package/dist/elector/ElectorContract.d.ts +0 -1
- package/dist/multisig/MultisigOrder.d.ts +0 -1
- package/dist/multisig/MultisigWallet.d.ts +0 -1
- package/dist/utils/createTestClient.js +1 -2
- package/dist/utils/createTestClient4.js +1 -2
- package/dist/utils/fees.js +5 -6
- package/dist/utils/fees.spec.js +1 -1
- package/dist/utils/randomTestKey.js +1 -2
- package/dist/utils/testWallets.d.ts +13 -0
- package/dist/utils/testWallets.js +17 -0
- package/dist/utils/time.js +5 -6
- package/dist/utils/toUrlSafe.js +1 -2
- package/dist/wallets/WalletContractV1R1.d.ts +0 -1
- package/dist/wallets/WalletContractV1R1.js +1 -0
- package/dist/wallets/WalletContractV1R1.spec.js +23 -0
- package/dist/wallets/WalletContractV1R2.d.ts +0 -1
- package/dist/wallets/WalletContractV1R2.js +1 -0
- package/dist/wallets/WalletContractV1R2.spec.js +23 -0
- package/dist/wallets/WalletContractV1R3.d.ts +0 -1
- package/dist/wallets/WalletContractV2R1.d.ts +0 -1
- package/dist/wallets/WalletContractV2R1.js +1 -0
- package/dist/wallets/WalletContractV2R1.spec.js +23 -0
- package/dist/wallets/WalletContractV2R2.d.ts +0 -1
- package/dist/wallets/WalletContractV2R2.js +1 -0
- package/dist/wallets/WalletContractV2R2.spec.js +23 -0
- package/dist/wallets/WalletContractV3R1.d.ts +0 -1
- package/dist/wallets/WalletContractV3R1.js +1 -0
- package/dist/wallets/WalletContractV3R1.spec.js +23 -0
- package/dist/wallets/WalletContractV3R2.d.ts +0 -1
- package/dist/wallets/WalletContractV3R2.js +1 -0
- package/dist/wallets/WalletContractV3R2.spec.js +23 -0
- package/dist/wallets/WalletContractV4.d.ts +0 -1
- package/dist/wallets/WalletContractV4.js +1 -0
- package/dist/wallets/WalletContractV4.spec.js +25 -0
- package/dist/wallets/signing/createWalletTransfer.d.ts +0 -1
- package/dist/wallets/signing/createWalletTransfer.js +6 -7
- package/dist/wallets/signing/singer.d.ts +0 -1
- package/dist/wallets/signing/singer.js +1 -2
- package/dist/wallets/v5beta/WalletContractV5Beta.d.ts +0 -1
- package/dist/wallets/v5beta/WalletContractV5Beta.js +1 -0
- package/dist/wallets/v5beta/WalletContractV5Beta.spec.js +19 -0
- package/dist/wallets/v5beta/WalletV5BetaActions.js +4 -5
- package/dist/wallets/v5beta/WalletV5BetaWalletId.d.ts +0 -1
- package/dist/wallets/v5beta/WalletV5BetaWalletId.js +2 -3
- package/dist/wallets/v5beta/WalletV5OutActions.js +2 -3
- package/dist/wallets/v5r1/WalletContractV5R1.d.ts +0 -1
- package/dist/wallets/v5r1/WalletContractV5R1.js +1 -0
- package/dist/wallets/v5r1/WalletContractV5R1.spec.js +19 -0
- package/dist/wallets/v5r1/WalletV5R1Actions.js +6 -7
- package/dist/wallets/v5r1/WalletV5R1WalletId.d.ts +0 -1
- package/dist/wallets/v5r1/WalletV5R1WalletId.js +3 -4
- package/package.json +4 -4
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
|
-
/// <reference types="node" />
|
|
9
8
|
import { HttpApi } from "./api/HttpApi";
|
|
10
9
|
import { AxiosAdapter } from 'axios';
|
|
11
10
|
import { Address, Cell, Contract, ContractProvider, Message, Transaction, TupleItem, TupleReader, StateInit, OpenedContract } from '@ton/core';
|
|
@@ -198,6 +197,11 @@ export declare class TonClient {
|
|
|
198
197
|
*/
|
|
199
198
|
getContractState(address: Address): Promise<{
|
|
200
199
|
balance: bigint;
|
|
200
|
+
extra_currencies: {
|
|
201
|
+
'@type': "extraCurrency";
|
|
202
|
+
id: number;
|
|
203
|
+
amount: string;
|
|
204
|
+
}[];
|
|
201
205
|
state: "active" | "uninitialized" | "frozen";
|
|
202
206
|
code: Buffer | null;
|
|
203
207
|
data: Buffer | null;
|
package/dist/client/TonClient.js
CHANGED
|
@@ -235,6 +235,7 @@ class TonClient {
|
|
|
235
235
|
let state = info.state;
|
|
236
236
|
return {
|
|
237
237
|
balance,
|
|
238
|
+
extra_currencies: info.extra_currencies,
|
|
238
239
|
state,
|
|
239
240
|
code: info.code !== '' ? Buffer.from(info.code, 'base64') : null,
|
|
240
241
|
data: info.data !== '' ? Buffer.from(info.data, 'base64') : null,
|
|
@@ -340,6 +341,7 @@ function createProvider(client, address, init) {
|
|
|
340
341
|
let state = await client.getContractState(address);
|
|
341
342
|
let balance = state.balance;
|
|
342
343
|
let last = state.lastTransaction ? { lt: BigInt(state.lastTransaction.lt), hash: Buffer.from(state.lastTransaction.hash, 'base64') } : null;
|
|
344
|
+
let ecMap = null;
|
|
343
345
|
let storage;
|
|
344
346
|
if (state.state === 'active') {
|
|
345
347
|
storage = {
|
|
@@ -362,14 +364,24 @@ function createProvider(client, address, init) {
|
|
|
362
364
|
else {
|
|
363
365
|
throw Error('Unsupported state');
|
|
364
366
|
}
|
|
367
|
+
if (state.extra_currencies.length > 0) {
|
|
368
|
+
ecMap = {};
|
|
369
|
+
for (let ec of state.extra_currencies) {
|
|
370
|
+
ecMap[ec.id] = BigInt(ec.amount);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
365
373
|
return {
|
|
366
374
|
balance,
|
|
375
|
+
extracurrency: ecMap,
|
|
367
376
|
last,
|
|
368
377
|
state: storage,
|
|
369
378
|
};
|
|
370
379
|
},
|
|
371
380
|
async get(name, args) {
|
|
372
|
-
|
|
381
|
+
if (typeof name !== 'string') {
|
|
382
|
+
throw new Error('Method name must be a string for TonClient provider');
|
|
383
|
+
}
|
|
384
|
+
let method = await client.runMethod(address, name, args);
|
|
373
385
|
return { stack: method.stack };
|
|
374
386
|
},
|
|
375
387
|
async external(message) {
|
|
@@ -427,6 +439,7 @@ function createProvider(client, address, init) {
|
|
|
427
439
|
value,
|
|
428
440
|
bounce,
|
|
429
441
|
sendMode: message.sendMode,
|
|
442
|
+
extracurrency: message.extracurrency,
|
|
430
443
|
init: neededInit,
|
|
431
444
|
body
|
|
432
445
|
});
|
|
@@ -34,6 +34,17 @@ describeConditional('TonClient', () => {
|
|
|
34
34
|
let wcShards = await client.getWorkchainShards(info.latestSeqno);
|
|
35
35
|
console.log(info, shardInfo, wcShards);
|
|
36
36
|
});
|
|
37
|
+
it('should get extra currency info', async () => {
|
|
38
|
+
// EC is rolled out only in testned yet
|
|
39
|
+
let testClient = new TonClient_1.TonClient({
|
|
40
|
+
endpoint: 'https://testnet.toncenter.com/api/v2/jsonRPC'
|
|
41
|
+
});
|
|
42
|
+
let testAddr = core_1.Address.parse("0:D36CFC9E0C57F43C1A719CB9F540ED87A694693AE1535B7654B645F52814AFD7");
|
|
43
|
+
let res = await testClient.getContractState(testAddr);
|
|
44
|
+
let expectedEc = res.extra_currencies.find(e => e.id == 100);
|
|
45
|
+
expect(expectedEc).not.toBeUndefined();
|
|
46
|
+
expect(BigInt(expectedEc.amount)).toBe(10000000n);
|
|
47
|
+
});
|
|
37
48
|
it('should locate source/result tx', async () => {
|
|
38
49
|
let source = core_1.Address.parse('UQDDT0TOC4PMp894jtCo3-d1-8ltSjXMX2EuWww_pCNibsUH');
|
|
39
50
|
let createdLt = '37508996000002';
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
|
-
/// <reference types="node" />
|
|
9
8
|
import { AxiosAdapter, InternalAxiosRequestConfig } from "axios";
|
|
10
9
|
import { Address, Contract, ContractProvider, OpenedContract, StateInit, Transaction, TupleItem, TupleReader } from "@ton/core";
|
|
11
10
|
import { z } from 'zod';
|
|
@@ -97,6 +96,7 @@ export declare class TonClient4 {
|
|
|
97
96
|
account: {
|
|
98
97
|
balance: {
|
|
99
98
|
coins: string;
|
|
99
|
+
currencies: Record<string, string>;
|
|
100
100
|
};
|
|
101
101
|
state: {
|
|
102
102
|
type: "uninit";
|
|
@@ -140,6 +140,7 @@ export declare class TonClient4 {
|
|
|
140
140
|
account: {
|
|
141
141
|
balance: {
|
|
142
142
|
coins: string;
|
|
143
|
+
currencies: Record<string, string>;
|
|
143
144
|
};
|
|
144
145
|
state: {
|
|
145
146
|
type: "uninit";
|
|
@@ -776,6 +777,7 @@ declare const parsedTransactionCodec: z.ZodObject<{
|
|
|
776
777
|
}, "strip", z.ZodTypeAny, {
|
|
777
778
|
status: "success" | "failed" | "pending";
|
|
778
779
|
seqno: number | null;
|
|
780
|
+
amount: string;
|
|
779
781
|
body: {
|
|
780
782
|
type: "comment";
|
|
781
783
|
comment: string;
|
|
@@ -786,12 +788,12 @@ declare const parsedTransactionCodec: z.ZodObject<{
|
|
|
786
788
|
dest: string | null;
|
|
787
789
|
bounced: boolean;
|
|
788
790
|
kind: "out" | "in";
|
|
789
|
-
amount: string;
|
|
790
791
|
resolvedAddress: string;
|
|
791
792
|
mentioned: string[];
|
|
792
793
|
}, {
|
|
793
794
|
status: "success" | "failed" | "pending";
|
|
794
795
|
seqno: number | null;
|
|
796
|
+
amount: string;
|
|
795
797
|
body: {
|
|
796
798
|
type: "comment";
|
|
797
799
|
comment: string;
|
|
@@ -802,7 +804,6 @@ declare const parsedTransactionCodec: z.ZodObject<{
|
|
|
802
804
|
dest: string | null;
|
|
803
805
|
bounced: boolean;
|
|
804
806
|
kind: "out" | "in";
|
|
805
|
-
amount: string;
|
|
806
807
|
resolvedAddress: string;
|
|
807
808
|
mentioned: string[];
|
|
808
809
|
}>;
|
|
@@ -813,20 +814,20 @@ declare const parsedTransactionCodec: z.ZodObject<{
|
|
|
813
814
|
kind: z.ZodLiteral<"ton">;
|
|
814
815
|
amount: z.ZodString;
|
|
815
816
|
}, "strip", z.ZodTypeAny, {
|
|
816
|
-
kind: "ton";
|
|
817
817
|
amount: string;
|
|
818
|
-
}, {
|
|
819
818
|
kind: "ton";
|
|
819
|
+
}, {
|
|
820
820
|
amount: string;
|
|
821
|
+
kind: "ton";
|
|
821
822
|
}>, z.ZodObject<{
|
|
822
823
|
kind: z.ZodLiteral<"token">;
|
|
823
824
|
amount: z.ZodString;
|
|
824
825
|
}, "strip", z.ZodTypeAny, {
|
|
825
|
-
kind: "token";
|
|
826
826
|
amount: string;
|
|
827
|
-
}, {
|
|
828
827
|
kind: "token";
|
|
828
|
+
}, {
|
|
829
829
|
amount: string;
|
|
830
|
+
kind: "token";
|
|
830
831
|
}>]>, "many">;
|
|
831
832
|
op: z.ZodOptional<z.ZodObject<{
|
|
832
833
|
type: z.ZodUnion<[z.ZodLiteral<"jetton::excesses">, z.ZodLiteral<"jetton::transfer">, z.ZodLiteral<"jetton::transfer_notification">, z.ZodLiteral<"deposit">, z.ZodLiteral<"deposit::ok">, z.ZodLiteral<"withdraw">, z.ZodLiteral<"withdraw::all">, z.ZodLiteral<"withdraw::delayed">, z.ZodLiteral<"withdraw::ok">, z.ZodLiteral<"airdrop">]>;
|
|
@@ -840,11 +841,11 @@ declare const parsedTransactionCodec: z.ZodObject<{
|
|
|
840
841
|
}>>;
|
|
841
842
|
}, "strip", z.ZodTypeAny, {
|
|
842
843
|
items: ({
|
|
843
|
-
kind: "ton";
|
|
844
844
|
amount: string;
|
|
845
|
+
kind: "ton";
|
|
845
846
|
} | {
|
|
846
|
-
kind: "token";
|
|
847
847
|
amount: string;
|
|
848
|
+
kind: "token";
|
|
848
849
|
})[];
|
|
849
850
|
address: string;
|
|
850
851
|
comment?: string | undefined;
|
|
@@ -854,11 +855,11 @@ declare const parsedTransactionCodec: z.ZodObject<{
|
|
|
854
855
|
} | undefined;
|
|
855
856
|
}, {
|
|
856
857
|
items: ({
|
|
857
|
-
kind: "ton";
|
|
858
858
|
amount: string;
|
|
859
|
+
kind: "ton";
|
|
859
860
|
} | {
|
|
860
|
-
kind: "token";
|
|
861
861
|
amount: string;
|
|
862
|
+
kind: "token";
|
|
862
863
|
})[];
|
|
863
864
|
address: string;
|
|
864
865
|
comment?: string | undefined;
|
|
@@ -965,6 +966,7 @@ declare const parsedTransactionCodec: z.ZodObject<{
|
|
|
965
966
|
parsed: {
|
|
966
967
|
status: "success" | "failed" | "pending";
|
|
967
968
|
seqno: number | null;
|
|
969
|
+
amount: string;
|
|
968
970
|
body: {
|
|
969
971
|
type: "comment";
|
|
970
972
|
comment: string;
|
|
@@ -975,17 +977,16 @@ declare const parsedTransactionCodec: z.ZodObject<{
|
|
|
975
977
|
dest: string | null;
|
|
976
978
|
bounced: boolean;
|
|
977
979
|
kind: "out" | "in";
|
|
978
|
-
amount: string;
|
|
979
980
|
resolvedAddress: string;
|
|
980
981
|
mentioned: string[];
|
|
981
982
|
};
|
|
982
983
|
operation: {
|
|
983
984
|
items: ({
|
|
984
|
-
kind: "ton";
|
|
985
985
|
amount: string;
|
|
986
|
+
kind: "ton";
|
|
986
987
|
} | {
|
|
987
|
-
kind: "token";
|
|
988
988
|
amount: string;
|
|
989
|
+
kind: "token";
|
|
989
990
|
})[];
|
|
990
991
|
address: string;
|
|
991
992
|
comment?: string | undefined;
|
|
@@ -1092,6 +1093,7 @@ declare const parsedTransactionCodec: z.ZodObject<{
|
|
|
1092
1093
|
parsed: {
|
|
1093
1094
|
status: "success" | "failed" | "pending";
|
|
1094
1095
|
seqno: number | null;
|
|
1096
|
+
amount: string;
|
|
1095
1097
|
body: {
|
|
1096
1098
|
type: "comment";
|
|
1097
1099
|
comment: string;
|
|
@@ -1102,17 +1104,16 @@ declare const parsedTransactionCodec: z.ZodObject<{
|
|
|
1102
1104
|
dest: string | null;
|
|
1103
1105
|
bounced: boolean;
|
|
1104
1106
|
kind: "out" | "in";
|
|
1105
|
-
amount: string;
|
|
1106
1107
|
resolvedAddress: string;
|
|
1107
1108
|
mentioned: string[];
|
|
1108
1109
|
};
|
|
1109
1110
|
operation: {
|
|
1110
1111
|
items: ({
|
|
1111
|
-
kind: "ton";
|
|
1112
1112
|
amount: string;
|
|
1113
|
+
kind: "ton";
|
|
1113
1114
|
} | {
|
|
1114
|
-
kind: "token";
|
|
1115
1115
|
amount: string;
|
|
1116
|
+
kind: "token";
|
|
1116
1117
|
})[];
|
|
1117
1118
|
address: string;
|
|
1118
1119
|
comment?: string | undefined;
|
|
@@ -314,13 +314,25 @@ function createProvider(client, block, address, init) {
|
|
|
314
314
|
else {
|
|
315
315
|
throw Error('Unsupported state');
|
|
316
316
|
}
|
|
317
|
+
let ecMap = null;
|
|
318
|
+
if (state.account.balance.currencies) {
|
|
319
|
+
ecMap = {};
|
|
320
|
+
let currencies = state.account.balance.currencies;
|
|
321
|
+
for (let [k, v] of Object.entries(currencies)) {
|
|
322
|
+
ecMap[Number(k)] = BigInt(v);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
317
325
|
return {
|
|
318
326
|
balance: BigInt(state.account.balance.coins),
|
|
327
|
+
extracurrency: ecMap,
|
|
319
328
|
last: last,
|
|
320
329
|
state: storage
|
|
321
330
|
};
|
|
322
331
|
},
|
|
323
332
|
async get(name, args) {
|
|
333
|
+
if (typeof name !== 'string') {
|
|
334
|
+
throw new Error('Method name must be a string for TonClient4 provider');
|
|
335
|
+
}
|
|
324
336
|
let sq = block;
|
|
325
337
|
if (sq === null) {
|
|
326
338
|
let res = await client.getLastBlock();
|
|
@@ -387,6 +399,7 @@ function createProvider(client, block, address, init) {
|
|
|
387
399
|
await via.send({
|
|
388
400
|
to: address,
|
|
389
401
|
value,
|
|
402
|
+
extracurrency: message.extracurrency,
|
|
390
403
|
bounce,
|
|
391
404
|
sendMode: message.sendMode,
|
|
392
405
|
init: neededInit,
|
|
@@ -488,7 +501,8 @@ const accountCodec = zod_1.z.object({
|
|
|
488
501
|
zod_1.z.object({ type: zod_1.z.literal('frozen'), stateHash: zod_1.z.string() })
|
|
489
502
|
]),
|
|
490
503
|
balance: zod_1.z.object({
|
|
491
|
-
coins: zod_1.z.string()
|
|
504
|
+
coins: zod_1.z.string(),
|
|
505
|
+
currencies: zod_1.z.record(zod_1.z.string(), zod_1.z.string())
|
|
492
506
|
}),
|
|
493
507
|
last: zod_1.z.union([
|
|
494
508
|
zod_1.z.null(),
|
|
@@ -515,7 +529,8 @@ const accountLiteCodec = zod_1.z.object({
|
|
|
515
529
|
zod_1.z.object({ type: zod_1.z.literal('frozen'), stateHash: zod_1.z.string() })
|
|
516
530
|
]),
|
|
517
531
|
balance: zod_1.z.object({
|
|
518
|
-
coins: zod_1.z.string()
|
|
532
|
+
coins: zod_1.z.string(),
|
|
533
|
+
currencies: zod_1.z.record(zod_1.z.string(), zod_1.z.string())
|
|
519
534
|
}),
|
|
520
535
|
last: zod_1.z.union([
|
|
521
536
|
zod_1.z.null(),
|
|
@@ -35,6 +35,31 @@ describeConditional('TonClient', () => {
|
|
|
35
35
|
let result = await client.getBlock(seqno);
|
|
36
36
|
console.log(result);
|
|
37
37
|
});
|
|
38
|
+
it('should get extra currency info', async () => {
|
|
39
|
+
let testAddresses = [
|
|
40
|
+
"-1:0000000000000000000000000000000000000000000000000000000000000000",
|
|
41
|
+
"0:C4CAC12F5BC7EEF4CF5EC84EE68CCF860921A06CA0395EC558E53E37B13C3B08",
|
|
42
|
+
"0:F5FFA780ACEE2A41663C1E32F50D771327275A42FC9D3FAB4F4D9CDE11CCA897"
|
|
43
|
+
].map(a => core_1.Address.parse(a));
|
|
44
|
+
let knownEc = [239, 4294967279];
|
|
45
|
+
let expectedEc = [
|
|
46
|
+
{ 239: 663333333334n, 4294967279: 998444444446n },
|
|
47
|
+
{ 239: 989097920n },
|
|
48
|
+
{ 239: 666666666n, 4294967279: 777777777n }
|
|
49
|
+
];
|
|
50
|
+
for (let i = 0; i < testAddresses.length; i++) {
|
|
51
|
+
let res = await (0, time_1.backoff)(async () => await client.getAccount(seqno, testAddresses[i]), false);
|
|
52
|
+
let resLite = await (0, time_1.backoff)(async () => await client.getAccountLite(seqno, testAddresses[i]), false);
|
|
53
|
+
let expected = expectedEc[i];
|
|
54
|
+
for (let testEc of knownEc) {
|
|
55
|
+
let expCur = expected[testEc];
|
|
56
|
+
if (expCur) {
|
|
57
|
+
expect(BigInt(res.account.balance.currencies[testEc])).toEqual(expCur);
|
|
58
|
+
expect(BigInt(resLite.account.balance.currencies[testEc])).toEqual(expCur);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
});
|
|
38
63
|
it('should run method', async () => {
|
|
39
64
|
let result = await client.runMethod(seqno, testAddress, 'seqno');
|
|
40
65
|
console.log(result);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
/**
|
|
3
2
|
* Copyright (c) Whales Corp.
|
|
4
3
|
* All Rights Reserved.
|
|
@@ -441,6 +440,11 @@ export declare class HttpApi {
|
|
|
441
440
|
data: string;
|
|
442
441
|
code: string;
|
|
443
442
|
balance: string | number;
|
|
443
|
+
extra_currencies: {
|
|
444
|
+
'@type': "extraCurrency";
|
|
445
|
+
id: number;
|
|
446
|
+
amount: string;
|
|
447
|
+
}[];
|
|
444
448
|
state: "active" | "uninitialized" | "frozen";
|
|
445
449
|
last_transaction_id: {
|
|
446
450
|
'@type': "internal.transactionId";
|
|
@@ -26,6 +26,11 @@ const blockIdExt = zod_1.z.object({
|
|
|
26
26
|
});
|
|
27
27
|
const addressInformation = zod_1.z.object({
|
|
28
28
|
balance: zod_1.z.union([zod_1.z.number(), zod_1.z.string()]),
|
|
29
|
+
extra_currencies: zod_1.z.array(zod_1.z.object({
|
|
30
|
+
'@type': zod_1.z.literal("extraCurrency"),
|
|
31
|
+
id: zod_1.z.number(),
|
|
32
|
+
amount: zod_1.z.string()
|
|
33
|
+
})),
|
|
29
34
|
state: zod_1.z.union([zod_1.z.literal('active'), zod_1.z.literal('uninitialized'), zod_1.z.literal('frozen')]),
|
|
30
35
|
data: zod_1.z.string(),
|
|
31
36
|
code: zod_1.z.string(),
|
|
@@ -150,7 +155,7 @@ class HttpApi {
|
|
|
150
155
|
this.endpoint = endpoint;
|
|
151
156
|
this.cache = new TonCache_1.InMemoryCache();
|
|
152
157
|
this.parameters = {
|
|
153
|
-
timeout: parameters?.timeout || 30000,
|
|
158
|
+
timeout: parameters?.timeout || 30000, // 30 seconds by default
|
|
154
159
|
apiKey: parameters?.apiKey,
|
|
155
160
|
adapter: parameters?.adapter
|
|
156
161
|
};
|
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.configParseMasterAddress = configParseMasterAddress;
|
|
4
|
+
exports.parseValidatorSet = parseValidatorSet;
|
|
5
|
+
exports.parseBridge = parseBridge;
|
|
6
|
+
exports.configParseMasterAddressRequired = configParseMasterAddressRequired;
|
|
7
|
+
exports.configParse5 = configParse5;
|
|
8
|
+
exports.configParse13 = configParse13;
|
|
9
|
+
exports.configParse15 = configParse15;
|
|
10
|
+
exports.configParse16 = configParse16;
|
|
11
|
+
exports.configParse17 = configParse17;
|
|
12
|
+
exports.configParse18 = configParse18;
|
|
13
|
+
exports.configParse8 = configParse8;
|
|
14
|
+
exports.configParse40 = configParse40;
|
|
15
|
+
exports.configParseWorkchainDescriptor = configParseWorkchainDescriptor;
|
|
16
|
+
exports.configParse12 = configParse12;
|
|
17
|
+
exports.configParseValidatorSet = configParseValidatorSet;
|
|
18
|
+
exports.configParseBridge = configParseBridge;
|
|
19
|
+
exports.configParseGasLimitsPrices = configParseGasLimitsPrices;
|
|
20
|
+
exports.configParseMsgPrices = configParseMsgPrices;
|
|
21
|
+
exports.configParse28 = configParse28;
|
|
22
|
+
exports.configParse29 = configParse29;
|
|
23
|
+
exports.parseProposalSetup = parseProposalSetup;
|
|
24
|
+
exports.parseVotingSetup = parseVotingSetup;
|
|
25
|
+
exports.loadConfigParamById = loadConfigParamById;
|
|
26
|
+
exports.loadConfigParamsAsSlice = loadConfigParamsAsSlice;
|
|
27
|
+
exports.parseFullConfig = parseFullConfig;
|
|
4
28
|
const core_1 = require("@ton/core");
|
|
5
29
|
function configParseMasterAddress(slice) {
|
|
6
30
|
if (slice) {
|
|
@@ -10,7 +34,6 @@ function configParseMasterAddress(slice) {
|
|
|
10
34
|
return null;
|
|
11
35
|
}
|
|
12
36
|
}
|
|
13
|
-
exports.configParseMasterAddress = configParseMasterAddress;
|
|
14
37
|
function readPublicKey(slice) {
|
|
15
38
|
// 8e81278a
|
|
16
39
|
if (slice.loadUint(32) !== 0x8e81278a) {
|
|
@@ -77,7 +100,6 @@ function parseValidatorSet(slice) {
|
|
|
77
100
|
};
|
|
78
101
|
}
|
|
79
102
|
}
|
|
80
|
-
exports.parseValidatorSet = parseValidatorSet;
|
|
81
103
|
function parseBridge(slice) {
|
|
82
104
|
const bridgeAddress = new core_1.Address(-1, slice.loadBuffer(32));
|
|
83
105
|
const oracleMultisigAddress = new core_1.Address(-1, slice.loadBuffer(32));
|
|
@@ -94,14 +116,12 @@ function parseBridge(slice) {
|
|
|
94
116
|
externalChainAddress
|
|
95
117
|
};
|
|
96
118
|
}
|
|
97
|
-
exports.parseBridge = parseBridge;
|
|
98
119
|
function configParseMasterAddressRequired(slice) {
|
|
99
120
|
if (!slice) {
|
|
100
121
|
throw Error('Invalid config');
|
|
101
122
|
}
|
|
102
123
|
return configParseMasterAddress(slice);
|
|
103
124
|
}
|
|
104
|
-
exports.configParseMasterAddressRequired = configParseMasterAddressRequired;
|
|
105
125
|
function configParse5(slice) {
|
|
106
126
|
if (!slice) {
|
|
107
127
|
throw Error('Invalid config');
|
|
@@ -119,7 +139,6 @@ function configParse5(slice) {
|
|
|
119
139
|
}
|
|
120
140
|
throw new Error('Invalid config');
|
|
121
141
|
}
|
|
122
|
-
exports.configParse5 = configParse5;
|
|
123
142
|
function configParse13(slice) {
|
|
124
143
|
if (!slice) {
|
|
125
144
|
throw Error('Invalid config');
|
|
@@ -137,7 +156,6 @@ function configParse13(slice) {
|
|
|
137
156
|
}
|
|
138
157
|
throw new Error('Invalid config');
|
|
139
158
|
}
|
|
140
|
-
exports.configParse13 = configParse13;
|
|
141
159
|
function configParse15(slice) {
|
|
142
160
|
if (!slice) {
|
|
143
161
|
throw Error('Invalid config');
|
|
@@ -153,7 +171,6 @@ function configParse15(slice) {
|
|
|
153
171
|
stakeHeldFor
|
|
154
172
|
};
|
|
155
173
|
}
|
|
156
|
-
exports.configParse15 = configParse15;
|
|
157
174
|
function configParse16(slice) {
|
|
158
175
|
if (!slice) {
|
|
159
176
|
throw Error('Invalid config');
|
|
@@ -167,7 +184,6 @@ function configParse16(slice) {
|
|
|
167
184
|
minValidators
|
|
168
185
|
};
|
|
169
186
|
}
|
|
170
|
-
exports.configParse16 = configParse16;
|
|
171
187
|
function configParse17(slice) {
|
|
172
188
|
if (!slice) {
|
|
173
189
|
throw Error('Invalid config');
|
|
@@ -183,7 +199,6 @@ function configParse17(slice) {
|
|
|
183
199
|
maxStakeFactor
|
|
184
200
|
};
|
|
185
201
|
}
|
|
186
|
-
exports.configParse17 = configParse17;
|
|
187
202
|
const StoragePricesDictValue = {
|
|
188
203
|
serialize(src, builder) {
|
|
189
204
|
throw Error("not implemented");
|
|
@@ -213,7 +228,6 @@ function configParse18(slice) {
|
|
|
213
228
|
}
|
|
214
229
|
return slice.loadDictDirect(core_1.Dictionary.Keys.Buffer(4), StoragePricesDictValue).values();
|
|
215
230
|
}
|
|
216
|
-
exports.configParse18 = configParse18;
|
|
217
231
|
function configParse8(slice) {
|
|
218
232
|
if (!slice) {
|
|
219
233
|
return {
|
|
@@ -228,7 +242,6 @@ function configParse8(slice) {
|
|
|
228
242
|
capabilities
|
|
229
243
|
};
|
|
230
244
|
}
|
|
231
|
-
exports.configParse8 = configParse8;
|
|
232
245
|
function configParse40(slice) {
|
|
233
246
|
if (!slice) {
|
|
234
247
|
return null;
|
|
@@ -262,7 +275,6 @@ function configParse40(slice) {
|
|
|
262
275
|
mediumProportionalMult
|
|
263
276
|
};
|
|
264
277
|
}
|
|
265
|
-
exports.configParse40 = configParse40;
|
|
266
278
|
function configParseWorkchainDescriptor(slice) {
|
|
267
279
|
if (slice.loadUint(8) !== 0xA6) {
|
|
268
280
|
throw Error('Invalid config');
|
|
@@ -302,7 +314,6 @@ function configParseWorkchainDescriptor(slice) {
|
|
|
302
314
|
}
|
|
303
315
|
};
|
|
304
316
|
}
|
|
305
|
-
exports.configParseWorkchainDescriptor = configParseWorkchainDescriptor;
|
|
306
317
|
const WorkchainDescriptorDictValue = {
|
|
307
318
|
serialize(src, builder) {
|
|
308
319
|
throw Error("not implemented");
|
|
@@ -357,21 +368,18 @@ function configParse12(slice) {
|
|
|
357
368
|
}
|
|
358
369
|
throw Error('No workchains exist');
|
|
359
370
|
}
|
|
360
|
-
exports.configParse12 = configParse12;
|
|
361
371
|
function configParseValidatorSet(slice) {
|
|
362
372
|
if (!slice) {
|
|
363
373
|
return null;
|
|
364
374
|
}
|
|
365
375
|
return parseValidatorSet(slice);
|
|
366
376
|
}
|
|
367
|
-
exports.configParseValidatorSet = configParseValidatorSet;
|
|
368
377
|
function configParseBridge(slice) {
|
|
369
378
|
if (!slice) {
|
|
370
379
|
return null;
|
|
371
380
|
}
|
|
372
381
|
return parseBridge(slice);
|
|
373
382
|
}
|
|
374
|
-
exports.configParseBridge = configParseBridge;
|
|
375
383
|
function parseGasLimitsInternal(slice) {
|
|
376
384
|
const tag = slice.loadUint(8);
|
|
377
385
|
if (tag === 0xde) {
|
|
@@ -431,7 +439,6 @@ function configParseGasLimitsPrices(slice) {
|
|
|
431
439
|
throw Error('Invalid config');
|
|
432
440
|
}
|
|
433
441
|
}
|
|
434
|
-
exports.configParseGasLimitsPrices = configParseGasLimitsPrices;
|
|
435
442
|
function configParseMsgPrices(slice) {
|
|
436
443
|
if (!slice) {
|
|
437
444
|
throw new Error('Invalid config');
|
|
@@ -449,7 +456,6 @@ function configParseMsgPrices(slice) {
|
|
|
449
456
|
nextFrac: slice.loadUint(16)
|
|
450
457
|
};
|
|
451
458
|
}
|
|
452
|
-
exports.configParseMsgPrices = configParseMsgPrices;
|
|
453
459
|
// catchain_config#c1 mc_catchain_lifetime:uint32 shard_catchain_lifetime:uint32
|
|
454
460
|
// shard_validators_lifetime:uint32 shard_validators_num:uint32 = CatchainConfig;
|
|
455
461
|
// catchain_config_new#c2 flags:(## 7) { flags = 0 } shuffle_mc_validators:Bool
|
|
@@ -490,7 +496,6 @@ function configParse28(slice) {
|
|
|
490
496
|
}
|
|
491
497
|
throw new Error('Invalid config');
|
|
492
498
|
}
|
|
493
|
-
exports.configParse28 = configParse28;
|
|
494
499
|
// consensus_config#d6 round_candidates:# { round_candidates >= 1 }
|
|
495
500
|
// next_candidate_delay_ms:uint32 consensus_timeout_ms:uint32
|
|
496
501
|
// fast_attempts:uint32 attempt_duration:uint32 catchain_max_deps:uint32
|
|
@@ -611,7 +616,6 @@ function configParse29(slice) {
|
|
|
611
616
|
}
|
|
612
617
|
throw new Error('Invalid config');
|
|
613
618
|
}
|
|
614
|
-
exports.configParse29 = configParse29;
|
|
615
619
|
// cfg_vote_cfg#36 min_tot_rounds:uint8 max_tot_rounds:uint8 min_wins:uint8 max_losses:uint8 min_store_sec:uint32 max_store_sec:uint32 bit_price:uint32 cell_price:uint32 = ConfigProposalSetup;
|
|
616
620
|
function parseProposalSetup(slice) {
|
|
617
621
|
const magic = slice.loadUint(8);
|
|
@@ -628,7 +632,6 @@ function parseProposalSetup(slice) {
|
|
|
628
632
|
const cellPrice = slice.loadUint(32);
|
|
629
633
|
return { minTotalRounds, maxTotalRounds, minWins, maxLoses, minStoreSec, maxStoreSec, bitPrice, cellPrice };
|
|
630
634
|
}
|
|
631
|
-
exports.parseProposalSetup = parseProposalSetup;
|
|
632
635
|
// cfg_vote_setup#91 normal_params:^ConfigProposalSetup critical_params:^ConfigProposalSetup = ConfigVotingSetup;
|
|
633
636
|
function parseVotingSetup(slice) {
|
|
634
637
|
if (!slice) {
|
|
@@ -642,7 +645,6 @@ function parseVotingSetup(slice) {
|
|
|
642
645
|
const criticalParams = parseProposalSetup(slice.loadRef().beginParse());
|
|
643
646
|
return { normalParams, criticalParams };
|
|
644
647
|
}
|
|
645
|
-
exports.parseVotingSetup = parseVotingSetup;
|
|
646
648
|
function loadConfigParams(configBase64) {
|
|
647
649
|
const comfigMap = core_1.Cell.fromBase64(configBase64).beginParse().loadDictDirect(core_1.Dictionary.Keys.Int(32), core_1.Dictionary.Values.Cell());
|
|
648
650
|
return comfigMap;
|
|
@@ -650,7 +652,6 @@ function loadConfigParams(configBase64) {
|
|
|
650
652
|
function loadConfigParamById(configBase64, id) {
|
|
651
653
|
return loadConfigParams(configBase64).get(id);
|
|
652
654
|
}
|
|
653
|
-
exports.loadConfigParamById = loadConfigParamById;
|
|
654
655
|
function loadConfigParamsAsSlice(configBase64) {
|
|
655
656
|
const pramsAsCells = loadConfigParams(configBase64);
|
|
656
657
|
const params = new Map();
|
|
@@ -659,7 +660,6 @@ function loadConfigParamsAsSlice(configBase64) {
|
|
|
659
660
|
}
|
|
660
661
|
return params;
|
|
661
662
|
}
|
|
662
|
-
exports.loadConfigParamsAsSlice = loadConfigParamsAsSlice;
|
|
663
663
|
function parseFullConfig(configs) {
|
|
664
664
|
return {
|
|
665
665
|
configAddress: configParseMasterAddressRequired(configs.get(0)),
|
|
@@ -708,4 +708,3 @@ function parseFullConfig(configs) {
|
|
|
708
708
|
// TODO: BlockCreateFees = ConfigParam 14
|
|
709
709
|
};
|
|
710
710
|
}
|
|
711
|
-
exports.parseFullConfig = parseFullConfig;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.createTestClient =
|
|
10
|
+
exports.createTestClient = createTestClient;
|
|
11
11
|
const TonClient_1 = require("../client/TonClient");
|
|
12
12
|
function createTestClient(net) {
|
|
13
13
|
return new TonClient_1.TonClient({
|
|
@@ -15,4 +15,3 @@ function createTestClient(net) {
|
|
|
15
15
|
apiKey: net !== 'mainnet' ? '32df40f4ffc11053334bcdf09c7d3a9e6487ee0cb715edf8cf667c543edb10ca' : undefined
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
|
-
exports.createTestClient = createTestClient;
|
|
@@ -7,9 +7,8 @@
|
|
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.createTestClient4 =
|
|
10
|
+
exports.createTestClient4 = createTestClient4;
|
|
11
11
|
const TonClient4_1 = require("../client/TonClient4");
|
|
12
12
|
function createTestClient4(net) {
|
|
13
13
|
return new TonClient4_1.TonClient4({ endpoint: net === 'mainnet' ? 'https://mainnet-v4.tonhubapi.com' : 'https://testnet-v4.tonhubapi.com' });
|
|
14
14
|
}
|
|
15
|
-
exports.createTestClient4 = createTestClient4;
|