@ton/ton 14.0.0 → 15.1.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 +0 -1
- package/dist/client/TonClient.js +4 -1
- package/dist/client/TonClient4.d.ts +0 -1
- package/dist/client/TonClient4.js +3 -0
- package/dist/client/api/HttpApi.d.ts +0 -1
- package/dist/client/api/HttpApi.js +1 -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/time.js +5 -6
- package/dist/utils/toUrlSafe.js +1 -2
- package/dist/wallets/WalletContractV1R1.d.ts +0 -1
- package/dist/wallets/WalletContractV1R2.d.ts +0 -1
- package/dist/wallets/WalletContractV1R3.d.ts +0 -1
- package/dist/wallets/WalletContractV2R1.d.ts +0 -1
- package/dist/wallets/WalletContractV2R2.d.ts +0 -1
- package/dist/wallets/WalletContractV3R1.d.ts +0 -1
- package/dist/wallets/WalletContractV3R2.d.ts +0 -1
- package/dist/wallets/WalletContractV4.d.ts +0 -1
- 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 +2 -2
- package/dist/wallets/v5beta/WalletContractV5Beta.spec.js +4 -4
- package/dist/wallets/v5beta/WalletV5BetaActions.js +4 -5
- package/dist/wallets/v5beta/WalletV5BetaWalletId.d.ts +1 -2
- package/dist/wallets/v5beta/WalletV5BetaWalletId.js +5 -6
- package/dist/wallets/v5beta/WalletV5BetaWalletId.spec.js +8 -8
- package/dist/wallets/v5beta/WalletV5OutActions.js +2 -3
- package/dist/wallets/v5r1/WalletContractV5R1.d.ts +1 -2
- package/dist/wallets/v5r1/WalletContractV5R1.js +9 -9
- package/dist/wallets/v5r1/WalletV5R1Actions.js +6 -7
- package/dist/wallets/v5r1/WalletV5R1WalletId.d.ts +1 -2
- package/dist/wallets/v5r1/WalletV5R1WalletId.js +6 -7
- package/dist/wallets/v5r1/WalletV5R1WalletId.spec.js +4 -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';
|
package/dist/client/TonClient.js
CHANGED
|
@@ -369,7 +369,10 @@ function createProvider(client, address, init) {
|
|
|
369
369
|
};
|
|
370
370
|
},
|
|
371
371
|
async get(name, args) {
|
|
372
|
-
|
|
372
|
+
if (typeof name !== 'string') {
|
|
373
|
+
throw new Error('Method name must be a string for TonClient provider');
|
|
374
|
+
}
|
|
375
|
+
let method = await client.runMethod(address, name, args);
|
|
373
376
|
return { stack: method.stack };
|
|
374
377
|
},
|
|
375
378
|
async external(message) {
|
|
@@ -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';
|
|
@@ -321,6 +321,9 @@ function createProvider(client, block, address, init) {
|
|
|
321
321
|
};
|
|
322
322
|
},
|
|
323
323
|
async get(name, args) {
|
|
324
|
+
if (typeof name !== 'string') {
|
|
325
|
+
throw new Error('Method name must be a string for TonClient4 provider');
|
|
326
|
+
}
|
|
324
327
|
let sq = block;
|
|
325
328
|
if (sq === null) {
|
|
326
329
|
let res = await client.getLastBlock();
|
|
@@ -150,7 +150,7 @@ class HttpApi {
|
|
|
150
150
|
this.endpoint = endpoint;
|
|
151
151
|
this.cache = new TonCache_1.InMemoryCache();
|
|
152
152
|
this.parameters = {
|
|
153
|
-
timeout: parameters?.timeout || 30000,
|
|
153
|
+
timeout: parameters?.timeout || 30000, // 30 seconds by default
|
|
154
154
|
apiKey: parameters?.apiKey,
|
|
155
155
|
adapter: parameters?.adapter
|
|
156
156
|
};
|
|
@@ -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;
|
package/dist/utils/fees.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.computeStorageFees = computeStorageFees;
|
|
4
|
+
exports.computeFwdFees = computeFwdFees;
|
|
5
|
+
exports.computeGasPrices = computeGasPrices;
|
|
6
|
+
exports.computeExternalMessageFees = computeExternalMessageFees;
|
|
7
|
+
exports.computeMessageForwardFees = computeMessageForwardFees;
|
|
4
8
|
const core_1 = require("@ton/core");
|
|
5
9
|
//
|
|
6
10
|
// Source: https://github.com/ton-foundation/ton/blob/ae5c0720143e231c32c3d2034cfe4e533a16d969/crypto/block/transaction.cpp#L425
|
|
@@ -26,14 +30,12 @@ function computeStorageFees(data) {
|
|
|
26
30
|
}
|
|
27
31
|
return shr16ceil(total);
|
|
28
32
|
}
|
|
29
|
-
exports.computeStorageFees = computeStorageFees;
|
|
30
33
|
//
|
|
31
34
|
// Source: https://github.com/ton-foundation/ton/blob/ae5c0720143e231c32c3d2034cfe4e533a16d969/crypto/block/transaction.cpp#L1218
|
|
32
35
|
//
|
|
33
36
|
function computeFwdFees(msgPrices, cells, bits) {
|
|
34
37
|
return msgPrices.lumpPrice + (shr16ceil(msgPrices.bitPrice * bits + (msgPrices.cellPrice * cells)));
|
|
35
38
|
}
|
|
36
|
-
exports.computeFwdFees = computeFwdFees;
|
|
37
39
|
//
|
|
38
40
|
// Source: https://github.com/ton-foundation/ton/blob/ae5c0720143e231c32c3d2034cfe4e533a16d969/crypto/block/transaction.cpp#L761
|
|
39
41
|
//
|
|
@@ -46,7 +48,6 @@ function computeGasPrices(gasUsed, prices) {
|
|
|
46
48
|
return prices.flatPrice + ((prices.price * (gasUsed - prices.flatLimit)) >> 16n);
|
|
47
49
|
}
|
|
48
50
|
}
|
|
49
|
-
exports.computeGasPrices = computeGasPrices;
|
|
50
51
|
//
|
|
51
52
|
// Source: https://github.com/ton-foundation/ton/blob/ae5c0720143e231c32c3d2034cfe4e533a16d969/crypto/block/transaction.cpp#L530
|
|
52
53
|
//
|
|
@@ -57,7 +58,6 @@ function computeExternalMessageFees(msgPrices, cell) {
|
|
|
57
58
|
storageStats.cells -= 1;
|
|
58
59
|
return computeFwdFees(msgPrices, BigInt(storageStats.cells), BigInt(storageStats.bits));
|
|
59
60
|
}
|
|
60
|
-
exports.computeExternalMessageFees = computeExternalMessageFees;
|
|
61
61
|
function computeMessageForwardFees(msgPrices, cell) {
|
|
62
62
|
let msg = (0, core_1.loadMessageRelaxed)(cell.beginParse());
|
|
63
63
|
let storageStats = { bits: 0, cells: 0 };
|
|
@@ -84,7 +84,6 @@ function computeMessageForwardFees(msgPrices, cell) {
|
|
|
84
84
|
let remaining = fees - res;
|
|
85
85
|
return { fees: res, remaining };
|
|
86
86
|
}
|
|
87
|
-
exports.computeMessageForwardFees = computeMessageForwardFees;
|
|
88
87
|
function collectCellStats(cell) {
|
|
89
88
|
let bits = cell.bits.length;
|
|
90
89
|
let cells = 1;
|
package/dist/utils/fees.spec.js
CHANGED
|
@@ -49,7 +49,7 @@ describe('estimateFees', () => {
|
|
|
49
49
|
const computed = (0, fees_1.computeStorageFees)({
|
|
50
50
|
lastPaid: storageStat.lastPaid,
|
|
51
51
|
masterchain: false,
|
|
52
|
-
now: 1697445678,
|
|
52
|
+
now: 1697445678, // Mon Oct 16 2023 11:42:56 GMT+0300
|
|
53
53
|
special: false,
|
|
54
54
|
storagePrices: config.storage,
|
|
55
55
|
storageStat: {
|
|
@@ -10,7 +10,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
10
10
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.randomTestKey =
|
|
13
|
+
exports.randomTestKey = randomTestKey;
|
|
14
14
|
const prando_1 = __importDefault(require("prando"));
|
|
15
15
|
const crypto_1 = require("@ton/crypto");
|
|
16
16
|
function randomTestKey(seed) {
|
|
@@ -21,4 +21,3 @@ function randomTestKey(seed) {
|
|
|
21
21
|
}
|
|
22
22
|
return (0, crypto_1.keyPairFromSeed)(res);
|
|
23
23
|
}
|
|
24
|
-
exports.randomTestKey = randomTestKey;
|
package/dist/utils/time.js
CHANGED
|
@@ -7,16 +7,18 @@
|
|
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.
|
|
10
|
+
exports.exponentialBackoffDelay = exponentialBackoffDelay;
|
|
11
|
+
exports.delay = delay;
|
|
12
|
+
exports.delayBreakable = delayBreakable;
|
|
13
|
+
exports.forever = forever;
|
|
14
|
+
exports.backoff = backoff;
|
|
11
15
|
function exponentialBackoffDelay(currentFailureCount, minDelay, maxDelay, maxFailureCount) {
|
|
12
16
|
let maxDelayRet = minDelay + ((maxDelay - minDelay) / maxFailureCount) * Math.max(currentFailureCount, maxFailureCount);
|
|
13
17
|
return Math.round(Math.random() * maxDelayRet);
|
|
14
18
|
}
|
|
15
|
-
exports.exponentialBackoffDelay = exponentialBackoffDelay;
|
|
16
19
|
async function delay(ms) {
|
|
17
20
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
18
21
|
}
|
|
19
|
-
exports.delay = delay;
|
|
20
22
|
function delayBreakable(ms) {
|
|
21
23
|
// We can cancel delay from outer code
|
|
22
24
|
let promiseResolver = null;
|
|
@@ -31,12 +33,10 @@ function delayBreakable(ms) {
|
|
|
31
33
|
});
|
|
32
34
|
return { promise, resolver };
|
|
33
35
|
}
|
|
34
|
-
exports.delayBreakable = delayBreakable;
|
|
35
36
|
const promise = new Promise(() => { });
|
|
36
37
|
function forever() {
|
|
37
38
|
return promise;
|
|
38
39
|
}
|
|
39
|
-
exports.forever = forever;
|
|
40
40
|
async function backoff(callback, log) {
|
|
41
41
|
let currentFailureCount = 0;
|
|
42
42
|
const minDelay = 500;
|
|
@@ -60,4 +60,3 @@ async function backoff(callback, log) {
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
exports.backoff = backoff;
|
package/dist/utils/toUrlSafe.js
CHANGED
|
@@ -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.toUrlSafe =
|
|
10
|
+
exports.toUrlSafe = toUrlSafe;
|
|
11
11
|
function toUrlSafe(src) {
|
|
12
12
|
while (src.indexOf('/') >= 0) {
|
|
13
13
|
src = src.replace('/', '_');
|
|
@@ -20,4 +20,3 @@ function toUrlSafe(src) {
|
|
|
20
20
|
}
|
|
21
21
|
return src;
|
|
22
22
|
}
|
|
23
|
-
exports.toUrlSafe = toUrlSafe;
|
|
@@ -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 { Address, Cell, Contract, ContractProvider, MessageRelaxed, Sender, SendMode } from "@ton/core";
|
|
10
9
|
import { Maybe } from "../utils/maybe";
|
|
11
10
|
export declare class WalletContractV1R1 implements Contract {
|
|
@@ -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 { Address, Cell, Contract, ContractProvider, MessageRelaxed, Sender, SendMode } from "@ton/core";
|
|
10
9
|
import { Maybe } from "../utils/maybe";
|
|
11
10
|
export declare class WalletContractV1R2 implements Contract {
|
|
@@ -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 { Address, Cell, Contract, ContractProvider, MessageRelaxed, Sender, SendMode } from "@ton/core";
|
|
10
9
|
import { Maybe } from "../utils/maybe";
|
|
11
10
|
export declare class WalletContractV1R3 implements Contract {
|
|
@@ -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 { Address, Cell, Contract, ContractProvider, MessageRelaxed, Sender, SendMode } from "@ton/core";
|
|
10
9
|
import { Maybe } from "../utils/maybe";
|
|
11
10
|
export declare class WalletContractV2R1 implements Contract {
|
|
@@ -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 { Address, Cell, Contract, ContractProvider, MessageRelaxed, Sender, SendMode } from "@ton/core";
|
|
10
9
|
import { Maybe } from "../utils/maybe";
|
|
11
10
|
export declare class WalletContractV2R2 implements Contract {
|
|
@@ -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 { Address, Cell, Contract, ContractProvider, MessageRelaxed, Sender, SendMode } from "@ton/core";
|
|
10
9
|
import { Maybe } from "../utils/maybe";
|
|
11
10
|
import { WalletV3SendArgsSignable, WalletV3SendArgsSigned } from "./WalletContractV3Types";
|
|
@@ -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 { Address, Cell, Contract, ContractProvider, MessageRelaxed, Sender, SendMode } from "@ton/core";
|
|
10
9
|
import { Maybe } from "../utils/maybe";
|
|
11
10
|
import { WalletV3SendArgsSignable, WalletV3SendArgsSigned } from "./WalletContractV3Types";
|
|
@@ -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 { Address, Cell, Contract, ContractProvider, MessageRelaxed, Sender, SendMode } from "@ton/core";
|
|
10
9
|
import { Maybe } from "../utils/maybe";
|
|
11
10
|
import { SendArgsSignable, SendArgsSigned } from "./signing/singer";
|
|
@@ -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 { Builder, Cell, MessageRelaxed, OutActionSendMsg } from "@ton/core";
|
|
10
9
|
import { Maybe } from "../../utils/maybe";
|
|
11
10
|
import { WalletV5BetaPackedCell, WalletV5BetaSendArgs, WalletV5BetaSendArgsExtensionAuth } from "../v5beta/WalletContractV5Beta";
|
|
@@ -7,7 +7,12 @@
|
|
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.
|
|
10
|
+
exports.createWalletTransferV1 = createWalletTransferV1;
|
|
11
|
+
exports.createWalletTransferV2 = createWalletTransferV2;
|
|
12
|
+
exports.createWalletTransferV3 = createWalletTransferV3;
|
|
13
|
+
exports.createWalletTransferV4 = createWalletTransferV4;
|
|
14
|
+
exports.createWalletTransferV5Beta = createWalletTransferV5Beta;
|
|
15
|
+
exports.createWalletTransferV5R1 = createWalletTransferV5R1;
|
|
11
16
|
const core_1 = require("@ton/core");
|
|
12
17
|
const crypto_1 = require("@ton/crypto");
|
|
13
18
|
const WalletContractV5Beta_1 = require("../v5beta/WalletContractV5Beta");
|
|
@@ -46,7 +51,6 @@ function createWalletTransferV1(args) {
|
|
|
46
51
|
.endCell();
|
|
47
52
|
return body;
|
|
48
53
|
}
|
|
49
|
-
exports.createWalletTransferV1 = createWalletTransferV1;
|
|
50
54
|
function createWalletTransferV2(args) {
|
|
51
55
|
// Check number of messages
|
|
52
56
|
if (args.messages.length > 4) {
|
|
@@ -76,7 +80,6 @@ function createWalletTransferV2(args) {
|
|
|
76
80
|
.endCell();
|
|
77
81
|
return body;
|
|
78
82
|
}
|
|
79
|
-
exports.createWalletTransferV2 = createWalletTransferV2;
|
|
80
83
|
function createWalletTransferV3(args) {
|
|
81
84
|
// Check number of messages
|
|
82
85
|
if (args.messages.length > 4) {
|
|
@@ -100,7 +103,6 @@ function createWalletTransferV3(args) {
|
|
|
100
103
|
}
|
|
101
104
|
return (0, singer_1.signPayload)(args, signingMessage, packSignatureToFront);
|
|
102
105
|
}
|
|
103
|
-
exports.createWalletTransferV3 = createWalletTransferV3;
|
|
104
106
|
function createWalletTransferV4(args) {
|
|
105
107
|
// Check number of messages
|
|
106
108
|
if (args.messages.length > 4) {
|
|
@@ -124,7 +126,6 @@ function createWalletTransferV4(args) {
|
|
|
124
126
|
}
|
|
125
127
|
return (0, singer_1.signPayload)(args, signingMessage, packSignatureToFront);
|
|
126
128
|
}
|
|
127
|
-
exports.createWalletTransferV4 = createWalletTransferV4;
|
|
128
129
|
function createWalletTransferV5Beta(args) {
|
|
129
130
|
// Check number of actions
|
|
130
131
|
if (args.actions.length > 255) {
|
|
@@ -154,7 +155,6 @@ function createWalletTransferV5Beta(args) {
|
|
|
154
155
|
.store((0, WalletV5BetaActions_1.storeOutListExtendedV5Beta)(args.actions));
|
|
155
156
|
return (0, singer_1.signPayload)(args, signingMessage, packSignatureToTail);
|
|
156
157
|
}
|
|
157
|
-
exports.createWalletTransferV5Beta = createWalletTransferV5Beta;
|
|
158
158
|
function createWalletTransferV5R1(args) {
|
|
159
159
|
// Check number of actions
|
|
160
160
|
if (args.actions.length > 255) {
|
|
@@ -187,4 +187,3 @@ function createWalletTransferV5R1(args) {
|
|
|
187
187
|
.store((0, WalletV5R1Actions_1.storeOutListExtendedV5R1)(args.actions));
|
|
188
188
|
return (0, singer_1.signPayload)(args, signingMessage, packSignatureToTail);
|
|
189
189
|
}
|
|
190
|
-
exports.createWalletTransferV5R1 = createWalletTransferV5R1;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.signPayload =
|
|
3
|
+
exports.signPayload = signPayload;
|
|
4
4
|
const crypto_1 = require("@ton/crypto");
|
|
5
5
|
function signPayload(args, signingMessage, packMessage) {
|
|
6
6
|
if ('secretKey' in args) {
|
|
@@ -18,4 +18,3 @@ function signPayload(args, signingMessage, packMessage) {
|
|
|
18
18
|
.then(signature => packMessage(signature, signingMessage));
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
exports.signPayload = signPayload;
|
|
@@ -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 { Address, Cell, Contract, ContractProvider, MessageRelaxed, Sender, SendMode } from "@ton/core";
|
|
10
9
|
import { Maybe } from "../../utils/maybe";
|
|
11
10
|
import { SendArgsSignable, SendArgsSigned } from "../signing/singer";
|
|
@@ -19,7 +19,7 @@ class WalletContractV5Beta {
|
|
|
19
19
|
static create(args) {
|
|
20
20
|
const walletId = {
|
|
21
21
|
networkGlobalId: args.walletId?.networkGlobalId ?? -239,
|
|
22
|
-
|
|
22
|
+
workchain: args?.walletId?.workchain ?? 0,
|
|
23
23
|
subwalletNumber: args?.walletId?.subwalletNumber ?? 0,
|
|
24
24
|
walletVersion: args?.walletId?.walletVersion ?? 'v5'
|
|
25
25
|
};
|
|
@@ -38,7 +38,7 @@ class WalletContractV5Beta {
|
|
|
38
38
|
.storeBit(0) // Empty plugins dict
|
|
39
39
|
.endCell();
|
|
40
40
|
this.init = { code, data };
|
|
41
|
-
this.address = (0, core_1.contractAddress)(this.walletId.
|
|
41
|
+
this.address = (0, core_1.contractAddress)(this.walletId.workchain, { code, data });
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
44
|
* Get Wallet Balance
|
|
@@ -94,7 +94,7 @@ describe('WalletContractV5Beta', () => {
|
|
|
94
94
|
});
|
|
95
95
|
it('should add extension', async () => {
|
|
96
96
|
const extensionKey = (0, randomTestKey_1.randomTestKey)('v5-treasure-extension');
|
|
97
|
-
const extensionContract = client.open(WalletContractV5Beta_1.WalletContractV5Beta.create({ walletId: {
|
|
97
|
+
const extensionContract = client.open(WalletContractV5Beta_1.WalletContractV5Beta.create({ walletId: { workchain: 0, networkGlobalId: -3 }, publicKey: extensionKey.publicKey }));
|
|
98
98
|
let seqno = await wallet.getSeqno();
|
|
99
99
|
const extensions = await getExtensionsArray(wallet);
|
|
100
100
|
const extensionAlreadyAdded = extensions.some(address => address.equals(extensionContract.address));
|
|
@@ -143,7 +143,7 @@ describe('WalletContractV5Beta', () => {
|
|
|
143
143
|
}, 60000);
|
|
144
144
|
it('should remove extension', async () => {
|
|
145
145
|
const extensionKey = (0, randomTestKey_1.randomTestKey)('v5-treasure-extension');
|
|
146
|
-
const extensionContract = client.open(WalletContractV5Beta_1.WalletContractV5Beta.create({ walletId: {
|
|
146
|
+
const extensionContract = client.open(WalletContractV5Beta_1.WalletContractV5Beta.create({ walletId: { workchain: 0, networkGlobalId: -3 }, publicKey: extensionKey.publicKey }));
|
|
147
147
|
const seqno = await wallet.getSeqno();
|
|
148
148
|
const extensions = await getExtensionsArray(wallet);
|
|
149
149
|
const extensionAlreadyAdded = extensions.some(address => address.equals(extensionContract.address));
|
|
@@ -157,7 +157,7 @@ describe('WalletContractV5Beta', () => {
|
|
|
157
157
|
});
|
|
158
158
|
it('should send internal transfer via relayer', async () => {
|
|
159
159
|
const relaerKey = (0, randomTestKey_1.randomTestKey)('v5-treasure-relayer');
|
|
160
|
-
const relayerContract = client.open(WalletContractV5Beta_1.WalletContractV5Beta.create({ walletId: {
|
|
160
|
+
const relayerContract = client.open(WalletContractV5Beta_1.WalletContractV5Beta.create({ walletId: { workchain: 0, networkGlobalId: -3 }, publicKey: relaerKey.publicKey }));
|
|
161
161
|
const seqno = await wallet.getSeqno();
|
|
162
162
|
const relayerSeqno = await relayerContract.getSeqno();
|
|
163
163
|
await relayerContract.sendTransfer({
|
|
@@ -185,7 +185,7 @@ describe('WalletContractV5Beta', () => {
|
|
|
185
185
|
it('should disable secret key auth, send extension-auth tx, and enable it again', async () => {
|
|
186
186
|
/* firstly add an extension that will take the control over the wallet */
|
|
187
187
|
const extensionKey = (0, randomTestKey_1.randomTestKey)('v5-treasure-extension');
|
|
188
|
-
const extensionContract = client.open(WalletContractV5Beta_1.WalletContractV5Beta.create({ walletId: {
|
|
188
|
+
const extensionContract = client.open(WalletContractV5Beta_1.WalletContractV5Beta.create({ walletId: { workchain: 0, networkGlobalId: -3 }, publicKey: extensionKey.publicKey }));
|
|
189
189
|
let seqno = await wallet.getSeqno();
|
|
190
190
|
const extensions = await getExtensionsArray(wallet);
|
|
191
191
|
const extensionAlreadyAdded = extensions.some(address => address.equals(extensionContract.address));
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.storeOutActionExtendedV5Beta = storeOutActionExtendedV5Beta;
|
|
4
|
+
exports.loadOutActionV5BetaExtended = loadOutActionV5BetaExtended;
|
|
5
|
+
exports.storeOutListExtendedV5Beta = storeOutListExtendedV5Beta;
|
|
6
|
+
exports.loadOutListExtendedV5Beta = loadOutListExtendedV5Beta;
|
|
4
7
|
const core_1 = require("@ton/core");
|
|
5
8
|
const WalletV5OutActions_1 = require("./WalletV5OutActions");
|
|
6
9
|
const outActionSetIsPublicKeyEnabledTag = 0x20cbb95a;
|
|
@@ -33,7 +36,6 @@ function storeOutActionExtendedV5Beta(action) {
|
|
|
33
36
|
throw new Error('Unknown action type' + action?.type);
|
|
34
37
|
}
|
|
35
38
|
}
|
|
36
|
-
exports.storeOutActionExtendedV5Beta = storeOutActionExtendedV5Beta;
|
|
37
39
|
function loadOutActionV5BetaExtended(slice) {
|
|
38
40
|
const tag = slice.loadUint(32);
|
|
39
41
|
switch (tag) {
|
|
@@ -56,7 +58,6 @@ function loadOutActionV5BetaExtended(slice) {
|
|
|
56
58
|
throw new Error(`Unknown extended out action tag 0x${tag.toString(16)}`);
|
|
57
59
|
}
|
|
58
60
|
}
|
|
59
|
-
exports.loadOutActionV5BetaExtended = loadOutActionV5BetaExtended;
|
|
60
61
|
function storeOutListExtendedV5Beta(actions) {
|
|
61
62
|
const [action, ...rest] = actions;
|
|
62
63
|
if (!action || !(0, WalletV5OutActions_1.isOutActionExtended)(action)) {
|
|
@@ -75,7 +76,6 @@ function storeOutListExtendedV5Beta(actions) {
|
|
|
75
76
|
.storeRef((0, core_1.beginCell)().store(storeOutListExtendedV5Beta(rest)).endCell());
|
|
76
77
|
};
|
|
77
78
|
}
|
|
78
|
-
exports.storeOutListExtendedV5Beta = storeOutListExtendedV5Beta;
|
|
79
79
|
function loadOutListExtendedV5Beta(slice) {
|
|
80
80
|
const actions = [];
|
|
81
81
|
while (slice.loadUint(1)) {
|
|
@@ -89,4 +89,3 @@ function loadOutListExtendedV5Beta(slice) {
|
|
|
89
89
|
}
|
|
90
90
|
return actions.concat(commonAction);
|
|
91
91
|
}
|
|
92
|
-
exports.loadOutListExtendedV5Beta = loadOutListExtendedV5Beta;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { Builder, Slice } from '@ton/core';
|
|
3
2
|
export interface WalletIdV5Beta {
|
|
4
3
|
readonly walletVersion: 'v5';
|
|
@@ -6,7 +5,7 @@ export interface WalletIdV5Beta {
|
|
|
6
5
|
* -239 is mainnet, -3 is testnet
|
|
7
6
|
*/
|
|
8
7
|
readonly networkGlobalId: number;
|
|
9
|
-
readonly
|
|
8
|
+
readonly workchain: number;
|
|
10
9
|
readonly subwalletNumber: number;
|
|
11
10
|
}
|
|
12
11
|
export declare function loadWalletIdV5Beta(value: bigint | Buffer | Slice): WalletIdV5Beta;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.loadWalletIdV5Beta = loadWalletIdV5Beta;
|
|
4
|
+
exports.storeWalletIdV5Beta = storeWalletIdV5Beta;
|
|
4
5
|
const core_1 = require("@ton/core");
|
|
5
6
|
const walletV5BetaVersionsSerialisation = {
|
|
6
7
|
v5: 0
|
|
@@ -10,22 +11,20 @@ function loadWalletIdV5Beta(value) {
|
|
|
10
11
|
Buffer.from(value.toString(16), 'hex') :
|
|
11
12
|
value instanceof core_1.Slice ? value.loadBuffer(10) : value, 0, 80));
|
|
12
13
|
const networkGlobalId = bitReader.loadInt(32);
|
|
13
|
-
const
|
|
14
|
+
const workchain = bitReader.loadInt(8);
|
|
14
15
|
const walletVersionRaw = bitReader.loadUint(8);
|
|
15
16
|
const subwalletNumber = bitReader.loadUint(32);
|
|
16
17
|
const walletVersion = Object.entries(walletV5BetaVersionsSerialisation).find(([_, value]) => value === walletVersionRaw)?.[0];
|
|
17
18
|
if (walletVersion === undefined) {
|
|
18
19
|
throw new Error(`Can't deserialize walletId: unknown wallet version ${walletVersionRaw}`);
|
|
19
20
|
}
|
|
20
|
-
return { networkGlobalId,
|
|
21
|
+
return { networkGlobalId, workchain, walletVersion, subwalletNumber };
|
|
21
22
|
}
|
|
22
|
-
exports.loadWalletIdV5Beta = loadWalletIdV5Beta;
|
|
23
23
|
function storeWalletIdV5Beta(walletId) {
|
|
24
24
|
return (builder) => {
|
|
25
25
|
builder.storeInt(walletId.networkGlobalId, 32);
|
|
26
|
-
builder.storeInt(walletId.
|
|
26
|
+
builder.storeInt(walletId.workchain, 8);
|
|
27
27
|
builder.storeUint(walletV5BetaVersionsSerialisation[walletId.walletVersion], 8);
|
|
28
28
|
builder.storeUint(walletId.subwalletNumber, 32);
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
-
exports.storeWalletIdV5Beta = storeWalletIdV5Beta;
|
|
@@ -7,13 +7,13 @@ describe('Wallet V5Beta wallet id', () => {
|
|
|
7
7
|
const walletId = {
|
|
8
8
|
walletVersion: 'v5',
|
|
9
9
|
networkGlobalId: -239,
|
|
10
|
-
|
|
10
|
+
workchain: 0,
|
|
11
11
|
subwalletNumber: 0
|
|
12
12
|
};
|
|
13
13
|
const actual = (0, core_1.beginCell)().store((0, WalletV5BetaWalletId_1.storeWalletIdV5Beta)(walletId)).endCell();
|
|
14
14
|
const expected = (0, core_1.beginCell)()
|
|
15
15
|
.storeInt(walletId.networkGlobalId, 32)
|
|
16
|
-
.storeInt(walletId.
|
|
16
|
+
.storeInt(walletId.workchain, 8)
|
|
17
17
|
.storeUint(0, 8)
|
|
18
18
|
.storeUint(walletId.subwalletNumber, 32)
|
|
19
19
|
.endCell();
|
|
@@ -23,12 +23,12 @@ describe('Wallet V5Beta wallet id', () => {
|
|
|
23
23
|
const expected = {
|
|
24
24
|
walletVersion: 'v5',
|
|
25
25
|
networkGlobalId: -239,
|
|
26
|
-
|
|
26
|
+
workchain: 0,
|
|
27
27
|
subwalletNumber: 0
|
|
28
28
|
};
|
|
29
29
|
const actual = (0, WalletV5BetaWalletId_1.loadWalletIdV5Beta)((0, core_1.beginCell)()
|
|
30
30
|
.storeInt(expected.networkGlobalId, 32)
|
|
31
|
-
.storeInt(expected.
|
|
31
|
+
.storeInt(expected.workchain, 8)
|
|
32
32
|
.storeUint(0, 8)
|
|
33
33
|
.storeUint(expected.subwalletNumber, 32)
|
|
34
34
|
.endCell().beginParse());
|
|
@@ -38,13 +38,13 @@ describe('Wallet V5Beta wallet id', () => {
|
|
|
38
38
|
const walletId = {
|
|
39
39
|
walletVersion: 'v5',
|
|
40
40
|
networkGlobalId: -3,
|
|
41
|
-
|
|
41
|
+
workchain: -1,
|
|
42
42
|
subwalletNumber: 1234
|
|
43
43
|
};
|
|
44
44
|
const actual = (0, core_1.beginCell)().store((0, WalletV5BetaWalletId_1.storeWalletIdV5Beta)(walletId)).endCell();
|
|
45
45
|
const expected = (0, core_1.beginCell)()
|
|
46
46
|
.storeInt(walletId.networkGlobalId, 32)
|
|
47
|
-
.storeInt(walletId.
|
|
47
|
+
.storeInt(walletId.workchain, 8)
|
|
48
48
|
.storeUint(0, 8)
|
|
49
49
|
.storeUint(walletId.subwalletNumber, 32)
|
|
50
50
|
.endCell();
|
|
@@ -54,12 +54,12 @@ describe('Wallet V5Beta wallet id', () => {
|
|
|
54
54
|
const expected = {
|
|
55
55
|
walletVersion: 'v5',
|
|
56
56
|
networkGlobalId: -239,
|
|
57
|
-
|
|
57
|
+
workchain: -1,
|
|
58
58
|
subwalletNumber: 1
|
|
59
59
|
};
|
|
60
60
|
const actual = (0, WalletV5BetaWalletId_1.loadWalletIdV5Beta)((0, core_1.beginCell)()
|
|
61
61
|
.storeInt(expected.networkGlobalId, 32)
|
|
62
|
-
.storeInt(expected.
|
|
62
|
+
.storeInt(expected.workchain, 8)
|
|
63
63
|
.storeUint(0, 8)
|
|
64
64
|
.storeUint(expected.subwalletNumber, 32)
|
|
65
65
|
.endCell().beginParse());
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isOutActionExtended = isOutActionExtended;
|
|
4
|
+
exports.isOutActionBasic = isOutActionBasic;
|
|
4
5
|
function isOutActionExtended(action) {
|
|
5
6
|
return (action.type === 'setIsPublicKeyEnabled' || action.type === 'addExtension' || action.type === 'removeExtension');
|
|
6
7
|
}
|
|
7
|
-
exports.isOutActionExtended = isOutActionExtended;
|
|
8
8
|
function isOutActionBasic(action) {
|
|
9
9
|
return !isOutActionExtended(action);
|
|
10
10
|
}
|
|
11
|
-
exports.isOutActionBasic = isOutActionBasic;
|
|
@@ -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 { Address, Cell, Contract, ContractProvider, MessageRelaxed, Sender, SendMode } from "@ton/core";
|
|
10
9
|
import { Maybe } from "../../utils/maybe";
|
|
11
10
|
import { SendArgsSignable, SendArgsSigned } from "../signing/singer";
|
|
@@ -39,7 +38,7 @@ export declare class WalletContractV5R1 implements Contract {
|
|
|
39
38
|
walletId?: Maybe<WalletIdV5R1<C>>;
|
|
40
39
|
publicKey: Buffer;
|
|
41
40
|
} : {
|
|
42
|
-
|
|
41
|
+
workchain?: number;
|
|
43
42
|
publicKey: Buffer;
|
|
44
43
|
walletId?: Maybe<Partial<WalletIdV5R1<C>>>;
|
|
45
44
|
}): WalletContractV5R1;
|
|
@@ -13,23 +13,23 @@ const createWalletTransfer_1 = require("../signing/createWalletTransfer");
|
|
|
13
13
|
const WalletV5R1WalletId_1 = require("./WalletV5R1WalletId");
|
|
14
14
|
class WalletContractV5R1 {
|
|
15
15
|
static create(args) {
|
|
16
|
-
let
|
|
17
|
-
if ('
|
|
18
|
-
|
|
16
|
+
let workchain = 0;
|
|
17
|
+
if ('workchain' in args && args.workchain != undefined) {
|
|
18
|
+
workchain = args.workchain;
|
|
19
19
|
}
|
|
20
|
-
if (args.walletId?.context && (0, WalletV5R1WalletId_1.isWalletIdV5R1ClientContext)(args.walletId.context) && args.walletId.context.
|
|
21
|
-
|
|
20
|
+
if (args.walletId?.context && (0, WalletV5R1WalletId_1.isWalletIdV5R1ClientContext)(args.walletId.context) && args.walletId.context.workchain != undefined) {
|
|
21
|
+
workchain = args.walletId.context.workchain;
|
|
22
22
|
}
|
|
23
|
-
return new WalletContractV5R1(
|
|
23
|
+
return new WalletContractV5R1(workchain, args.publicKey, {
|
|
24
24
|
networkGlobalId: args.walletId?.networkGlobalId ?? -239,
|
|
25
25
|
context: args.walletId?.context ?? {
|
|
26
|
-
|
|
26
|
+
workchain: 0,
|
|
27
27
|
walletVersion: 'v5r1',
|
|
28
28
|
subwalletNumber: 0
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
|
-
constructor(
|
|
32
|
+
constructor(workchain, publicKey, walletId) {
|
|
33
33
|
this.publicKey = publicKey;
|
|
34
34
|
this.walletId = walletId;
|
|
35
35
|
this.walletId = walletId;
|
|
@@ -43,7 +43,7 @@ class WalletContractV5R1 {
|
|
|
43
43
|
.storeBit(0) // Empty plugins dict
|
|
44
44
|
.endCell();
|
|
45
45
|
this.init = { code, data };
|
|
46
|
-
this.address = (0, core_1.contractAddress)(
|
|
46
|
+
this.address = (0, core_1.contractAddress)(workchain, { code, data });
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
49
|
* Get Wallet Balance
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.storeOutActionExtendedV5R1 = storeOutActionExtendedV5R1;
|
|
4
|
+
exports.loadOutActionExtendedV5R1 = loadOutActionExtendedV5R1;
|
|
5
|
+
exports.storeOutListExtendedV5R1 = storeOutListExtendedV5R1;
|
|
6
|
+
exports.loadOutListExtendedV5R1 = loadOutListExtendedV5R1;
|
|
7
|
+
exports.toSafeV5R1SendMode = toSafeV5R1SendMode;
|
|
8
|
+
exports.patchV5R1ActionsSendMode = patchV5R1ActionsSendMode;
|
|
4
9
|
const core_1 = require("@ton/core");
|
|
5
10
|
const WalletV5OutActions_1 = require("../v5beta/WalletV5OutActions");
|
|
6
11
|
const outActionSetIsPublicKeyEnabledTag = 0x04;
|
|
@@ -33,7 +38,6 @@ function storeOutActionExtendedV5R1(action) {
|
|
|
33
38
|
throw new Error('Unknown action type' + action?.type);
|
|
34
39
|
}
|
|
35
40
|
}
|
|
36
|
-
exports.storeOutActionExtendedV5R1 = storeOutActionExtendedV5R1;
|
|
37
41
|
function loadOutActionExtendedV5R1(slice) {
|
|
38
42
|
const tag = slice.loadUint(8);
|
|
39
43
|
switch (tag) {
|
|
@@ -56,7 +60,6 @@ function loadOutActionExtendedV5R1(slice) {
|
|
|
56
60
|
throw new Error(`Unknown extended out action tag 0x${tag.toString(16)}`);
|
|
57
61
|
}
|
|
58
62
|
}
|
|
59
|
-
exports.loadOutActionExtendedV5R1 = loadOutActionExtendedV5R1;
|
|
60
63
|
function storeOutListExtendedV5R1(actions) {
|
|
61
64
|
const extendedActions = actions.filter(WalletV5OutActions_1.isOutActionExtended);
|
|
62
65
|
const basicActions = actions.filter(WalletV5OutActions_1.isOutActionBasic);
|
|
@@ -77,7 +80,6 @@ function storeOutListExtendedV5R1(actions) {
|
|
|
77
80
|
}
|
|
78
81
|
};
|
|
79
82
|
}
|
|
80
|
-
exports.storeOutListExtendedV5R1 = storeOutListExtendedV5R1;
|
|
81
83
|
function packExtendedActionsRec(extendedActions) {
|
|
82
84
|
const [first, ...rest] = extendedActions;
|
|
83
85
|
let builder = (0, core_1.beginCell)()
|
|
@@ -108,7 +110,6 @@ function loadOutListExtendedV5R1(slice) {
|
|
|
108
110
|
}
|
|
109
111
|
return actions;
|
|
110
112
|
}
|
|
111
|
-
exports.loadOutListExtendedV5R1 = loadOutListExtendedV5R1;
|
|
112
113
|
/**
|
|
113
114
|
* Safety rules -- actions of external messages must have +2 in the SendMode. Internal messages actions may have arbitrary SendMode.
|
|
114
115
|
*/
|
|
@@ -118,11 +119,9 @@ function toSafeV5R1SendMode(sendMode, authType) {
|
|
|
118
119
|
}
|
|
119
120
|
return sendMode | core_1.SendMode.IGNORE_ERRORS;
|
|
120
121
|
}
|
|
121
|
-
exports.toSafeV5R1SendMode = toSafeV5R1SendMode;
|
|
122
122
|
function patchV5R1ActionsSendMode(actions, authType) {
|
|
123
123
|
return actions.map(action => action.type === 'sendMsg' ? ({
|
|
124
124
|
...action,
|
|
125
125
|
mode: toSafeV5R1SendMode(action.mode, authType)
|
|
126
126
|
}) : action);
|
|
127
127
|
}
|
|
128
|
-
exports.patchV5R1ActionsSendMode = patchV5R1ActionsSendMode;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { Builder, Slice } from '@ton/core';
|
|
3
2
|
/**
|
|
4
3
|
* schema:
|
|
@@ -31,7 +30,7 @@ export interface WalletIdV5R1<C extends WalletIdV5R1ClientContext | WalletIdV5R1
|
|
|
31
30
|
}
|
|
32
31
|
export interface WalletIdV5R1ClientContext {
|
|
33
32
|
readonly walletVersion: 'v5r1';
|
|
34
|
-
readonly
|
|
33
|
+
readonly workchain: number;
|
|
35
34
|
readonly subwalletNumber: number;
|
|
36
35
|
}
|
|
37
36
|
/**
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isWalletIdV5R1ClientContext = isWalletIdV5R1ClientContext;
|
|
4
|
+
exports.loadWalletIdV5R1 = loadWalletIdV5R1;
|
|
5
|
+
exports.storeWalletIdV5R1 = storeWalletIdV5R1;
|
|
4
6
|
const core_1 = require("@ton/core");
|
|
5
7
|
function isWalletIdV5R1ClientContext(context) {
|
|
6
8
|
return typeof context !== 'number';
|
|
7
9
|
}
|
|
8
|
-
exports.isWalletIdV5R1ClientContext = isWalletIdV5R1ClientContext;
|
|
9
10
|
const walletV5R1VersionsSerialisation = {
|
|
10
11
|
v5r1: 0
|
|
11
12
|
};
|
|
@@ -21,7 +22,7 @@ function loadWalletIdV5R1(value, networkGlobalId) {
|
|
|
21
22
|
const bitReader = (0, core_1.beginCell)().storeInt(context, 32).endCell().beginParse();
|
|
22
23
|
const isClientContext = bitReader.loadUint(1);
|
|
23
24
|
if (isClientContext) {
|
|
24
|
-
const
|
|
25
|
+
const workchain = bitReader.loadInt(8);
|
|
25
26
|
const walletVersionRaw = bitReader.loadUint(8);
|
|
26
27
|
const subwalletNumber = bitReader.loadUint(15);
|
|
27
28
|
const walletVersion = Object.entries(walletV5R1VersionsSerialisation).find(([_, value]) => value === walletVersionRaw)?.[0];
|
|
@@ -32,7 +33,7 @@ function loadWalletIdV5R1(value, networkGlobalId) {
|
|
|
32
33
|
networkGlobalId,
|
|
33
34
|
context: {
|
|
34
35
|
walletVersion,
|
|
35
|
-
|
|
36
|
+
workchain,
|
|
36
37
|
subwalletNumber
|
|
37
38
|
}
|
|
38
39
|
};
|
|
@@ -45,14 +46,13 @@ function loadWalletIdV5R1(value, networkGlobalId) {
|
|
|
45
46
|
};
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
|
-
exports.loadWalletIdV5R1 = loadWalletIdV5R1;
|
|
49
49
|
function storeWalletIdV5R1(walletId) {
|
|
50
50
|
return (builder) => {
|
|
51
51
|
let context;
|
|
52
52
|
if (isWalletIdV5R1ClientContext(walletId.context)) {
|
|
53
53
|
context = (0, core_1.beginCell)()
|
|
54
54
|
.storeUint(1, 1)
|
|
55
|
-
.storeInt(walletId.context.
|
|
55
|
+
.storeInt(walletId.context.workchain, 8)
|
|
56
56
|
.storeUint(walletV5R1VersionsSerialisation[walletId.context.walletVersion], 8)
|
|
57
57
|
.storeUint(walletId.context.subwalletNumber, 15)
|
|
58
58
|
.endCell().beginParse().loadInt(32);
|
|
@@ -66,4 +66,3 @@ function storeWalletIdV5R1(walletId) {
|
|
|
66
66
|
return builder.storeInt(BigInt(walletId.networkGlobalId) ^ BigInt(context), 32);
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
|
-
exports.storeWalletIdV5R1 = storeWalletIdV5R1;
|
|
@@ -8,14 +8,14 @@ describe('Wallet V5R1 wallet id', () => {
|
|
|
8
8
|
networkGlobalId: -239,
|
|
9
9
|
context: {
|
|
10
10
|
walletVersion: 'v5r1',
|
|
11
|
-
|
|
11
|
+
workchain: 0,
|
|
12
12
|
subwalletNumber: 0
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
15
|
const actual = (0, core_1.beginCell)().store((0, WalletV5R1WalletId_1.storeWalletIdV5R1)(walletId)).endCell();
|
|
16
16
|
const context = (0, core_1.beginCell)()
|
|
17
17
|
.storeUint(1, 1)
|
|
18
|
-
.storeInt(walletId.context.
|
|
18
|
+
.storeInt(walletId.context.workchain, 8)
|
|
19
19
|
.storeUint(0, 8)
|
|
20
20
|
.storeUint(walletId.context.subwalletNumber, 15)
|
|
21
21
|
.endCell().beginParse().loadInt(32);
|
|
@@ -27,13 +27,13 @@ describe('Wallet V5R1 wallet id', () => {
|
|
|
27
27
|
networkGlobalId: -239,
|
|
28
28
|
context: {
|
|
29
29
|
walletVersion: 'v5r1',
|
|
30
|
-
|
|
30
|
+
workchain: 0,
|
|
31
31
|
subwalletNumber: 0
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
34
|
const context = (0, core_1.beginCell)()
|
|
35
35
|
.storeUint(1, 1)
|
|
36
|
-
.storeInt(expected.context.
|
|
36
|
+
.storeInt(expected.context.workchain, 8)
|
|
37
37
|
.storeUint(0, 8)
|
|
38
38
|
.storeUint(expected.context.subwalletNumber, 15)
|
|
39
39
|
.endCell().beginParse().loadInt(32);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ton/ton",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "15.1.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": "^5.0.0",
|
|
19
|
-
"@ton/core": "^0.
|
|
19
|
+
"@ton/core": "^0.59.0",
|
|
20
20
|
"@ton/crypto": "3.2.0",
|
|
21
21
|
"@ton/emulator": "^2.1.1",
|
|
22
22
|
"@types/jest": "^27.0.1",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"ts-loader": "^9.2.5",
|
|
37
37
|
"ts-node": "^10.7.0",
|
|
38
38
|
"typedoc": "^0.23.24",
|
|
39
|
-
"typescript": "^
|
|
39
|
+
"typescript": "^5.6.3",
|
|
40
40
|
"webpack": "^5.51.2"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"zod": "^3.21.4"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@ton/core": ">=0.
|
|
50
|
+
"@ton/core": ">=0.59.0",
|
|
51
51
|
"@ton/crypto": ">=3.2.0"
|
|
52
52
|
},
|
|
53
53
|
"publishConfig": {
|