@tonappchain/sdk 0.5.7 → 0.6.1-spb.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,17 +1,17 @@
1
1
  import { Address, Cell } from '@ton/ton';
2
2
  import { AbiCoder } from 'ethers';
3
- import { EvmProxyMsg, TransactionLinker } from '../structs/Struct';
3
+ import { EvmProxyMsg, TransactionLinker, ValidExecutors } from '../structs/Struct';
4
4
  import { RandomNumberByTimestamp } from '../structs/InternalStruct';
5
5
  export declare const sleep: (ms: number) => Promise<unknown>;
6
6
  export declare function generateRandomNumber(interval: number): number;
7
7
  export declare function generateRandomNumberByTimestamp(): RandomNumberByTimestamp;
8
8
  export declare function calculateContractAddress(code: Cell, data: Cell): Promise<Address>;
9
- export declare function buildEvmDataCell(transactionLinker: TransactionLinker, evmProxyMsg: EvmProxyMsg): Cell;
9
+ export declare function buildEvmDataCell(transactionLinker: TransactionLinker, evmProxyMsg: EvmProxyMsg, validExecutors: ValidExecutors): Cell;
10
10
  export declare function formatSolidityMethodName(methodName?: string): string;
11
11
  export declare function generateTransactionLinker(caller: string, shardCount: number): TransactionLinker;
12
12
  export declare function validateTVMAddress(address: string): void;
13
13
  export declare function validateEVMAddress(address: string): void;
14
- export declare function calculateEVMTokenAddress(abiCoder: AbiCoder, tokenUtilsAddress: string, crossChainLayerTokenBytecode: string, crossChainLayerAddress: string, l1Address: string): string;
14
+ export declare function calculateEVMTokenAddress(abiCoder: AbiCoder, tokenUtilsAddress: string, crossChainLayerTokenBytecode: string, crossChainLayerAddress: string, tvmAddress: string): string;
15
15
  export declare const convertKeysToCamelCase: <T>(data: T) => T;
16
16
  export declare const calculateRawAmount: (amount: number, decimals: number) => bigint;
17
17
  export declare const calculateAmount: (rawAmount: bigint, decimals: number) => number;
package/dist/sdk/Utils.js CHANGED
@@ -30,7 +30,7 @@ async function calculateContractAddress(code, data) {
30
30
  const stateInit = (0, ton_1.beginCell)().store((0, ton_1.storeStateInit)({ code, data })).endCell();
31
31
  return new ton_1.Address(0, stateInit.hash());
32
32
  }
33
- function buildEvmDataCell(transactionLinker, evmProxyMsg) {
33
+ function buildEvmDataCell(transactionLinker, evmProxyMsg, validExecutors) {
34
34
  const evmArguments = evmProxyMsg.encodedParameters
35
35
  ? Buffer.from(evmProxyMsg.encodedParameters.split('0x')[1], 'hex').toString('base64')
36
36
  : null;
@@ -43,6 +43,8 @@ function buildEvmDataCell(transactionLinker, evmProxyMsg) {
43
43
  },
44
44
  shardsKey: transactionLinker.shardsKey,
45
45
  shardCount: transactionLinker.shardCount,
46
+ evmValidExecutors: validExecutors.tac,
47
+ tvmValidExecutors: validExecutors.ton,
46
48
  });
47
49
  return (0, ton_1.beginCell)().storeStringTail(json).endCell();
48
50
  }
@@ -76,8 +78,8 @@ function validateEVMAddress(address) {
76
78
  throw (0, errors_1.evmAddressError)(address);
77
79
  }
78
80
  }
79
- function calculateEVMTokenAddress(abiCoder, tokenUtilsAddress, crossChainLayerTokenBytecode, crossChainLayerAddress, l1Address) {
80
- const salt = ethers_1.ethers.keccak256(ethers_1.ethers.solidityPacked(['string'], [l1Address]));
81
+ function calculateEVMTokenAddress(abiCoder, tokenUtilsAddress, crossChainLayerTokenBytecode, crossChainLayerAddress, tvmAddress) {
82
+ const salt = ethers_1.ethers.keccak256(ethers_1.ethers.solidityPacked(['string'], [tvmAddress]));
81
83
  const initCode = ethers_1.ethers.solidityPacked(['bytes', 'bytes'], [crossChainLayerTokenBytecode, abiCoder.encode(['address'], [crossChainLayerAddress])]);
82
84
  const initCodeHash = ethers_1.ethers.keccak256(initCode);
83
85
  return ethers_1.ethers.getCreate2Address(tokenUtilsAddress, salt, initCodeHash);
@@ -6,6 +6,7 @@ export declare class RawSender implements SenderAbstraction {
6
6
  private wallet;
7
7
  private secretKey;
8
8
  constructor(wallet: WalletInstance, secretKey: Buffer);
9
+ sendShardTransactions(shardTransactions: ShardTransaction[], delay: number, chain: Network, contractOpener: ContractOpener): Promise<unknown>;
9
10
  getSenderAddress(): string;
10
11
  sendShardTransaction(shardTransaction: ShardTransaction, delay: number, _chain: Network, contractOpener: ContractOpener): Promise<void | (import("@ton/sandbox").SendMessageResult & {
11
12
  result: void;
@@ -4,11 +4,44 @@ exports.RawSender = void 0;
4
4
  const ton_1 = require("@ton/ton");
5
5
  const ton_2 = require("@ton/ton");
6
6
  const SenderAbstraction_1 = require("./SenderAbstraction");
7
+ const HighloadWalletV3_1 = require("../wrappers/HighloadWalletV3");
7
8
  class RawSender {
8
9
  constructor(wallet, secretKey) {
9
10
  this.wallet = wallet;
10
11
  this.secretKey = secretKey;
11
12
  }
13
+ async sendShardTransactions(shardTransactions, delay, chain, contractOpener) {
14
+ const walletContract = contractOpener.open(this.wallet);
15
+ const isBatchSendSupported = walletContract instanceof HighloadWalletV3_1.HighloadWalletV3 || walletContract instanceof ton_1.WalletContractV5R1;
16
+ if (isBatchSendSupported) {
17
+ const messages = [];
18
+ for (const shardTx of shardTransactions) {
19
+ for (const message of shardTx.messages) {
20
+ messages.push((0, ton_1.internal)({
21
+ to: message.address,
22
+ value: (0, ton_1.fromNano)(message.value),
23
+ bounce: true,
24
+ body: message.payload,
25
+ }));
26
+ }
27
+ }
28
+ const seqno = await walletContract.getSeqno();
29
+ await (0, SenderAbstraction_1.sleep)(delay * 1000);
30
+ return walletContract.sendTransfer({
31
+ seqno,
32
+ secretKey: this.secretKey,
33
+ messages,
34
+ sendMode: ton_2.SendMode.PAY_GAS_SEPARATELY,
35
+ });
36
+ }
37
+ else {
38
+ const results = [];
39
+ for (const shardTx of shardTransactions) {
40
+ results.push(await this.sendShardTransaction(shardTx, delay, chain, contractOpener));
41
+ }
42
+ return results;
43
+ }
44
+ }
12
45
  getSenderAddress() {
13
46
  return this.wallet.address.toString();
14
47
  }
@@ -15,5 +15,6 @@ export interface WalletInstance extends Contract {
15
15
  }
16
16
  export interface SenderAbstraction {
17
17
  sendShardTransaction(shardTransaction: ShardTransaction, delay: number, chain?: Network, contractOpener?: ContractOpener): Promise<unknown>;
18
+ sendShardTransactions(shardTransactions: ShardTransaction[], delay: number, chain?: Network, contractOpener?: ContractOpener): Promise<unknown>;
18
19
  getSenderAddress(): string;
19
20
  }
@@ -1,11 +1,12 @@
1
1
  import { TonConnectUI } from '@tonconnect/ui';
2
2
  import type { ShardTransaction } from '../structs/InternalStruct';
3
- import { Network } from '../structs/Struct';
3
+ import { ContractOpener, Network } from '../structs/Struct';
4
4
  import { SenderAbstraction } from './SenderAbstraction';
5
5
  import { SendTransactionResponse } from '@tonconnect/sdk';
6
6
  export declare class TonConnectSender implements SenderAbstraction {
7
7
  readonly tonConnect: TonConnectUI;
8
8
  constructor(tonConnect: TonConnectUI);
9
+ sendShardTransactions(shardTransactions: ShardTransaction[], delay: number, chain?: Network, contractOpener?: ContractOpener): Promise<SendTransactionResponse[]>;
9
10
  getSenderAddress(): string;
10
11
  sendShardTransaction(shardTransaction: ShardTransaction, delay: number, chain: Network): Promise<SendTransactionResponse>;
11
12
  }
@@ -9,6 +9,28 @@ class TonConnectSender {
9
9
  constructor(tonConnect) {
10
10
  this.tonConnect = tonConnect;
11
11
  }
12
+ async sendShardTransactions(shardTransactions, delay, chain, contractOpener) {
13
+ const allMessages = [];
14
+ let minValidUntil = 0;
15
+ for (const transaction of shardTransactions) {
16
+ for (const message of transaction.messages) {
17
+ allMessages.push({
18
+ address: message.address,
19
+ amount: message.value.toString(),
20
+ payload: protocol_1.Base64.encode(message.payload.toBoc()).toString(),
21
+ });
22
+ }
23
+ minValidUntil = Math.min(minValidUntil, transaction.validUntil);
24
+ }
25
+ const transaction = {
26
+ validUntil: minValidUntil,
27
+ messages: allMessages,
28
+ network: chain == Struct_1.Network.TESTNET ? ui_1.CHAIN.TESTNET : ui_1.CHAIN.MAINNET,
29
+ };
30
+ await (0, SenderAbstraction_1.sleep)(delay * 1000);
31
+ const response = await this.tonConnect.sendTransaction(transaction);
32
+ return [response];
33
+ }
12
34
  getSenderAddress() {
13
35
  return this.tonConnect.account?.address?.toString() || '';
14
36
  }
@@ -1,6 +1,7 @@
1
1
  import { Cell } from '@ton/ton';
2
- import { ContractOpener, TACSimulationResults, ExecutionStagesByOperationId, Network, OperationIdsByShardsKey, RawAssetBridgingData, StatusInfosByOperationId, OperationType } from './Struct';
2
+ import { ContractOpener, TACSimulationResult, ExecutionStagesByOperationId, Network, OperationIdsByShardsKey, RawAssetBridgingData, StatusInfosByOperationId, OperationType, AssetType } from './Struct';
3
3
  import { AbstractProvider, ethers, Interface, InterfaceAbi } from 'ethers';
4
+ import { mainnet, testnet } from '@tonappchain/artifacts';
4
5
  export type ShardMessage = {
5
6
  address: string;
6
7
  value: bigint;
@@ -13,35 +14,62 @@ export type ShardTransaction = {
13
14
  };
14
15
  export declare enum AssetOpType {
15
16
  JETTON_BURN = "JETTON_BURN",
16
- JETTON_TRANSFER = "JETTON_TRANSFER"
17
+ JETTON_TRANSFER = "JETTON_TRANSFER",
18
+ NFT_BURN = "NFT_BURN",
19
+ NFT_TRANSFER = "NFT_TRANSFER"
17
20
  }
18
21
  export type RandomNumberByTimestamp = {
19
22
  timestamp: number;
20
23
  randomNumber: number;
21
24
  };
22
25
  export type JettonBridgingData = RawAssetBridgingData & {
26
+ type: AssetType.FT;
23
27
  address: string;
24
28
  };
25
29
  export type JettonTransferData = JettonBridgingData;
26
30
  export type JettonBurnData = JettonBridgingData & {
27
31
  notificationReceiverAddress: string;
28
32
  };
33
+ export type NFTBridgingData = RawAssetBridgingData & {
34
+ type: AssetType.NFT;
35
+ address: string;
36
+ };
37
+ export type NFTTransferData = NFTBridgingData & {
38
+ to: string;
39
+ responseAddress: string;
40
+ evmData: Cell;
41
+ crossChainTonAmount?: bigint;
42
+ feeData?: Cell;
43
+ };
44
+ export type NFTBurnData = NFTBridgingData & {
45
+ notificationReceiverAddress: string;
46
+ evmData: Cell;
47
+ crossChainTonAmount?: bigint;
48
+ feeData?: Cell;
49
+ };
29
50
  export type InternalTONParams = {
30
51
  contractOpener: ContractOpener;
31
52
  jettonProxyAddress: string;
53
+ nftProxyAddress: string;
32
54
  crossChainLayerAddress: string;
33
55
  jettonMinterCode: Cell;
34
56
  jettonWalletCode: Cell;
57
+ nftItemCode: Cell;
58
+ nftCollectionCode: Cell;
35
59
  };
36
60
  export type InternalTACParams = {
37
61
  provider: AbstractProvider;
38
- settingsAddress: string;
39
- tokenUtilsAddress: string;
62
+ crossChainLayer: testnet.tac.wrappers.CrossChainLayerTAC | mainnet.tac.wrappers.CrossChainLayerTAC;
63
+ settings: testnet.tac.wrappers.SettingsTAC | testnet.tac.wrappers.SettingsTAC;
64
+ tokenUtils: testnet.tac.wrappers.TokenUtilsTAC | mainnet.tac.wrappers.TokenUtilsTAC;
65
+ trustedTACExecutors: string[];
66
+ trustedTONExecutors: string[];
40
67
  abiCoder: ethers.AbiCoder;
41
68
  crossChainLayerABI: Interface | InterfaceAbi;
42
- crossChainLayerAddress: string;
43
69
  crossChainLayerTokenABI: Interface | InterfaceAbi;
44
70
  crossChainLayerTokenBytecode: string;
71
+ crossChainLayerNFTABI: Interface | InterfaceAbi;
72
+ crossChainLayerNFTBytecode: string;
45
73
  };
46
74
  export type ResponseBase<T> = {
47
75
  response: T;
@@ -51,4 +79,4 @@ export type OperationTypeResponse = ResponseBase<OperationType>;
51
79
  export type StatusesResponse = ResponseBase<StatusInfosByOperationId>;
52
80
  export type OperationIdsByShardsKeyResponse = ResponseBase<OperationIdsByShardsKey>;
53
81
  export type StageProfilingResponse = ResponseBase<ExecutionStagesByOperationId>;
54
- export type TACSimulationResponse = ResponseBase<TACSimulationResults>;
82
+ export type TACSimulationResponse = ResponseBase<TACSimulationResult>;
@@ -5,4 +5,6 @@ var AssetOpType;
5
5
  (function (AssetOpType) {
6
6
  AssetOpType["JETTON_BURN"] = "JETTON_BURN";
7
7
  AssetOpType["JETTON_TRANSFER"] = "JETTON_TRANSFER";
8
+ AssetOpType["NFT_BURN"] = "NFT_BURN";
9
+ AssetOpType["NFT_TRANSFER"] = "NFT_TRANSFER";
8
10
  })(AssetOpType || (exports.AssetOpType = AssetOpType = {}));
@@ -1,5 +1,5 @@
1
1
  import { SandboxContract } from '@ton/sandbox';
2
- import type { Address, Contract, OpenedContract } from '@ton/ton';
2
+ import type { Address, Cell, Contract, OpenedContract } from '@ton/ton';
3
3
  import { AbstractProvider, Addressable, Interface, InterfaceAbi } from 'ethers';
4
4
  export interface ContractOpener {
5
5
  open<T extends Contract>(src: T): OpenedContract<T> | SandboxContract<T>;
@@ -57,6 +57,14 @@ export type TACParams = {
57
57
  * bytecode of TAC CrossChainLayerToken contract. Use only for tests.
58
58
  */
59
59
  crossChainLayerTokenBytecode?: string;
60
+ /**
61
+ * ABI of TAC CrossChainLayerNFT contract. Use only for tests.
62
+ */
63
+ crossChainLayerNFTABI?: Interface | InterfaceAbi;
64
+ /**
65
+ * bytecode of TAC CrossChainLayerNFT contract. Use only for tests.
66
+ */
67
+ crossChainLayerNFTBytecode?: string;
60
68
  };
61
69
  export type TONParams = {
62
70
  /**
@@ -90,17 +98,46 @@ export type SDKParams = {
90
98
  */
91
99
  customLiteSequencerEndpoints?: string[];
92
100
  };
93
- export type WithAddress = {
101
+ export declare enum AssetType {
102
+ NFT = "NFT",
103
+ FT = "FT"
104
+ }
105
+ export declare enum NFTAddressType {
106
+ ITEM = "ITEM",
107
+ COLLECTION = "COLLECTION"
108
+ }
109
+ export type WithAddressFT = {
110
+ type: AssetType.FT;
94
111
  /**
95
112
  * Address of TAC or TON token.
96
113
  * Empty if sending native TON coin.
97
114
  */
98
115
  address?: string;
99
116
  };
100
- export type RawAssetBridgingData = {
117
+ export type WithAddressNFT_Item = {
118
+ type: AssetType.NFT;
119
+ /**
120
+ * Address NFT item token.
121
+ */
122
+ address: string;
123
+ };
124
+ export type WithAddressNFT_CollectionItem = {
125
+ type: AssetType.NFT;
126
+ /**
127
+ * Address NFT collection.
128
+ */
129
+ collectionAddress: string;
130
+ /**
131
+ * Index of NFT item in collection.
132
+ */
133
+ itemIndex: bigint;
134
+ };
135
+ export type WithAddressNFT = WithAddressNFT_Item | WithAddressNFT_CollectionItem;
136
+ export type WithAddress = WithAddressFT | WithAddressNFT;
137
+ export type RawAssetBridgingData<NFTFormatRequired extends WithAddressNFT = WithAddressNFT_Item> = {
101
138
  /** Raw format, e.g. 12340000000 (=12.34 tokens if decimals is 9) */
102
139
  rawAmount: bigint;
103
- } & WithAddress;
140
+ } & (WithAddressFT | NFTFormatRequired);
104
141
  export type UserFriendlyAssetBridgingData = {
105
142
  /**
106
143
  * User friendly format, e.g. 12.34 tokens
@@ -142,12 +179,14 @@ export type TACSimulationRequest = {
142
179
  methodName: string;
143
180
  target: string;
144
181
  };
182
+ evmValidExecutors: string[];
145
183
  extraData: string;
146
184
  feeAssetAddress: string;
147
185
  shardsKey: string;
148
186
  tonAssets: {
149
187
  amount: string;
150
188
  tokenAddress: string;
189
+ assetType: string;
151
190
  }[];
152
191
  tonCaller: string;
153
192
  };
@@ -182,8 +221,35 @@ export type ProfilingStageData = {
182
221
  exists: boolean;
183
222
  stageData: StageData | null;
184
223
  };
224
+ export type InitialCallerInfo = {
225
+ address: string;
226
+ blockchainType: BlockchainType;
227
+ };
228
+ export type ValidExecutors = {
229
+ tac: string[];
230
+ ton: string[];
231
+ };
232
+ export declare enum TokenSymbol {
233
+ TAC_SYMBOL = "TAC",
234
+ TON_SYMBOL = "TON"
235
+ }
236
+ export type GeneralFeeInfo = {
237
+ protocolFee: string;
238
+ executorFee: string;
239
+ tokenFeeSymbol: TokenSymbol;
240
+ };
241
+ export type FeeInfo = {
242
+ tac: GeneralFeeInfo;
243
+ ton: GeneralFeeInfo;
244
+ };
245
+ export type MetaInfo = {
246
+ initialCaller: InitialCallerInfo;
247
+ validExecutors: ValidExecutors;
248
+ feeInfo: FeeInfo;
249
+ };
185
250
  export type ExecutionStages = {
186
251
  operationType: OperationType;
252
+ metaInfo: MetaInfo;
187
253
  } & Record<StageName, ProfilingStageData>;
188
254
  export type ExecutionStagesByOperationId = Record<string, ExecutionStages>;
189
255
  export type StatusInfosByOperationId = Record<string, StatusInfo>;
@@ -191,9 +257,8 @@ export type OperationIds = {
191
257
  operationIds: string[];
192
258
  };
193
259
  export type OperationIdsByShardsKey = Record<string, OperationIds>;
194
- export type TACSimulationResults = {
260
+ export type TACSimulationResult = {
195
261
  estimatedGas: bigint;
196
- estimatedJettonFeeAmount: string;
197
262
  feeParams: {
198
263
  currentBaseFee: string;
199
264
  isEip1559: boolean;
@@ -215,9 +280,19 @@ export type TACSimulationResults = {
215
280
  amount: string;
216
281
  tokenAddress: string;
217
282
  }[];
283
+ nftBurned: {
284
+ amount: string;
285
+ tokenAddress: string;
286
+ }[];
287
+ nftLocked: {
288
+ amount: string;
289
+ tokenAddress: string;
290
+ }[];
218
291
  }[] | null;
219
292
  simulationError: string;
220
293
  simulationStatus: boolean;
294
+ suggestedTonExecutionFee: string;
295
+ suggestedTacExecutionFee: string;
221
296
  debugInfo: {
222
297
  from: string;
223
298
  to: string;
@@ -225,3 +300,35 @@ export type TACSimulationResults = {
225
300
  blockNumber: number;
226
301
  };
227
302
  };
303
+ export type FeeParams = {
304
+ isRoundTrip: boolean;
305
+ gasLimit: bigint;
306
+ protocolFee: bigint;
307
+ evmExecutorFee: bigint;
308
+ tvmExecutorFee: bigint;
309
+ };
310
+ export type CrossChainTransactionOptions = {
311
+ forceSend?: boolean;
312
+ isRoundTrip?: boolean;
313
+ protocolFee?: bigint;
314
+ evmValidExecutors?: string[];
315
+ evmExecutorFee?: bigint;
316
+ tvmValidExecutors?: string[];
317
+ tvmExecutorFee?: bigint;
318
+ };
319
+ export type ExecutionFeeEstimationResult = {
320
+ feeParams: FeeParams;
321
+ simulation: TACSimulationResult;
322
+ };
323
+ export type CrosschainTx = {
324
+ evmProxyMsg: EvmProxyMsg;
325
+ assets?: AssetBridgingData[];
326
+ options?: CrossChainTransactionOptions;
327
+ };
328
+ export type NFTItemData = {
329
+ init: boolean;
330
+ index: number;
331
+ collectionAddress: Address;
332
+ ownerAddress: Address | null;
333
+ content: Cell | null;
334
+ };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StageName = exports.OperationType = exports.BlockchainType = exports.Network = exports.SimplifiedStatuses = void 0;
3
+ exports.TokenSymbol = exports.StageName = exports.NFTAddressType = exports.AssetType = exports.OperationType = exports.BlockchainType = exports.Network = exports.SimplifiedStatuses = void 0;
4
4
  var SimplifiedStatuses;
5
5
  (function (SimplifiedStatuses) {
6
6
  SimplifiedStatuses["PENDING"] = "PENDING";
@@ -27,6 +27,16 @@ var OperationType;
27
27
  OperationType["TAC_TON"] = "TAC-TON";
28
28
  OperationType["UNKNOWN"] = "UNKNOWN";
29
29
  })(OperationType || (exports.OperationType = OperationType = {}));
30
+ var AssetType;
31
+ (function (AssetType) {
32
+ AssetType["NFT"] = "NFT";
33
+ AssetType["FT"] = "FT";
34
+ })(AssetType || (exports.AssetType = AssetType = {}));
35
+ var NFTAddressType;
36
+ (function (NFTAddressType) {
37
+ NFTAddressType["ITEM"] = "ITEM";
38
+ NFTAddressType["COLLECTION"] = "COLLECTION";
39
+ })(NFTAddressType || (exports.NFTAddressType = NFTAddressType = {}));
30
40
  var StageName;
31
41
  (function (StageName) {
32
42
  StageName["COLLECTED_IN_TAC"] = "collectedInTAC";
@@ -36,3 +46,8 @@ var StageName;
36
46
  StageName["INCLUDED_IN_TON_CONSENSUS"] = "includedInTONConsensus";
37
47
  StageName["EXECUTED_IN_TON"] = "executedInTON";
38
48
  })(StageName || (exports.StageName = StageName = {}));
49
+ var TokenSymbol;
50
+ (function (TokenSymbol) {
51
+ TokenSymbol["TAC_SYMBOL"] = "TAC";
52
+ TokenSymbol["TON_SYMBOL"] = "TON";
53
+ })(TokenSymbol || (exports.TokenSymbol = TokenSymbol = {}));
@@ -42,7 +42,7 @@ export declare class HighloadWalletV3 implements WalletInstance {
42
42
  subwalletId: number;
43
43
  timeout: number;
44
44
  }): Promise<void>;
45
- sendBatch(provider: ContractProvider, secretKey: Buffer, messages: OutActionSendMsg[], subwallet: number, queryId: HighloadQueryId, timeout: number, createdAt?: number, value?: bigint): Promise<void>;
45
+ sendBatch(provider: ContractProvider, secretKey: Buffer, messages: OutActionSendMsg[], subwallet: number, timeout: number, createdAt?: number, value?: bigint): Promise<void>;
46
46
  static createInternalTransferBody(opts: {
47
47
  actions: OutAction[] | Cell;
48
48
  queryId: HighloadQueryId;
@@ -38,13 +38,12 @@ class HighloadWalletV3 {
38
38
  const isActive = state.state.type === 'active';
39
39
  const subwalletId = isActive ? await this.getSubwalletId(provider) : exports.DEFAULT_SUBWALLET_ID;
40
40
  const timeout = isActive ? await this.getTimeout(provider) : exports.DEFAULT_TIMEOUT;
41
- const queryId = new HighloadQueryId_1.HighloadQueryId();
42
41
  const actions = args.messages.map((msg) => ({
43
42
  type: 'sendMsg',
44
43
  mode: args.sendMode,
45
44
  outMsg: msg,
46
45
  }));
47
- await this.sendBatch(provider, args.secretKey, actions, subwalletId, queryId, timeout);
46
+ await this.sendBatch(provider, args.secretKey, actions, subwalletId, timeout);
48
47
  }
49
48
  static create(config, code = HIGHLOAD_V3_CODE, workchain = 0) {
50
49
  const data = highloadWalletV3ConfigToCell(config);
@@ -72,10 +71,11 @@ class HighloadWalletV3 {
72
71
  .endCell();
73
72
  await provider.external((0, ton_1.beginCell)().storeBuffer((0, ton_crypto_1.sign)(messageInner.hash(), secretKey)).storeRef(messageInner).endCell());
74
73
  }
75
- async sendBatch(provider, secretKey, messages, subwallet, queryId, timeout, createdAt, value = 0n) {
74
+ async sendBatch(provider, secretKey, messages, subwallet, timeout, createdAt, value = 0n) {
76
75
  if (createdAt == undefined) {
77
- createdAt = Math.floor(Date.now() / 1000) - 20; // -20 is used to pass check created_at <= now() in smart contract for sure
76
+ createdAt = Math.floor(Date.now() / 1000) - 40; // -40 is used to pass check created_at <= now() in smart contract for sure
78
77
  }
78
+ const queryId = HighloadQueryId_1.HighloadQueryId.fromQueryId(BigInt(createdAt) % 8388608n);
79
79
  return await this.sendExternalMessage(provider, secretKey, {
80
80
  message: this.packActions(messages, value, queryId),
81
81
  mode: value > 0n ? ton_1.SendMode.PAY_GAS_SEPARATELY : ton_1.SendMode.CARRY_ALL_REMAINING_BALANCE,
@@ -20,5 +20,5 @@ export declare class JettonMaster implements Contract {
20
20
  constructor(address: Address);
21
21
  getWalletAddress(provider: ContractProvider, owner: string): Promise<string>;
22
22
  getJettonData(provider: ContractProvider): Promise<JettonMasterData>;
23
- getL2Address(provider: ContractProvider): Promise<string>;
23
+ getEVMAddress(provider: ContractProvider): Promise<string>;
24
24
  }
@@ -45,8 +45,8 @@ class JettonMaster {
45
45
  jettonWalletCode,
46
46
  };
47
47
  }
48
- async getL2Address(provider) {
49
- const result = await provider.get('get_l2_token_address', []);
48
+ async getEVMAddress(provider) {
49
+ const result = await provider.get('get_evm_token_address', []);
50
50
  return result.stack.readString();
51
51
  }
52
52
  }
@@ -23,15 +23,16 @@ export declare class JettonWallet implements Contract {
23
23
  } | undefined);
24
24
  static createFromAddress(address: Address): JettonWallet;
25
25
  static createFromConfig(config: JettonWalletData, code: Cell, workchain?: number): JettonWallet;
26
- static burnMessage(jettonAmount: bigint, receiverAddress?: string, crossChainTonAmount?: bigint, crossChainPayload?: Cell | null, queryId?: number): Cell;
26
+ static burnMessage(jettonAmount: bigint, receiverAddress?: string, crossChainTonAmount?: bigint, feeData?: Cell | null, crossChainPayload?: Cell | null, queryId?: number): Cell;
27
27
  sendBurn(provider: ContractProvider, via: Sender, value: bigint, opts: {
28
28
  queryId?: number;
29
29
  jettonAmount: bigint;
30
30
  receiverAddress?: string;
31
31
  crossChainTonAmount?: bigint;
32
+ feeData?: Cell | null;
32
33
  crossChainPayload?: Cell | null;
33
34
  }): Promise<void>;
34
- static transferMessage(jettonAmount: bigint, to: string, responseAddress: string | null, forwardTonAmount?: bigint, crossChainTonAmount?: bigint, crossChainPayload?: Cell | null, queryId?: number): Cell;
35
+ static transferMessage(jettonAmount: bigint, to: string, responseAddress: string | null, forwardTonAmount?: bigint, crossChainTonAmount?: bigint, feeData?: Cell | null, crossChainPayload?: Cell | null, queryId?: number): Cell;
35
36
  sendTransfer(provider: ContractProvider, via: Sender, value: bigint, opts: {
36
37
  queryId?: number;
37
38
  jettonAmount: bigint;
@@ -28,7 +28,7 @@ class JettonWallet {
28
28
  const init = { code, data };
29
29
  return new JettonWallet((0, ton_1.contractAddress)(workchain, init), init);
30
30
  }
31
- static burnMessage(jettonAmount, receiverAddress, crossChainTonAmount, crossChainPayload, queryId) {
31
+ static burnMessage(jettonAmount, receiverAddress, crossChainTonAmount, feeData, crossChainPayload, queryId) {
32
32
  const body = (0, ton_1.beginCell)()
33
33
  .storeUint(JettonWalletOpCodes.burn, 32)
34
34
  .storeUint(queryId || 0, 64)
@@ -37,6 +37,7 @@ class JettonWallet {
37
37
  if (crossChainTonAmount || crossChainPayload) {
38
38
  body.storeMaybeRef((0, ton_1.beginCell)()
39
39
  .storeCoins(crossChainTonAmount ?? 0n)
40
+ .storeMaybeRef(feeData)
40
41
  .storeMaybeRef(crossChainPayload)
41
42
  .endCell());
42
43
  }
@@ -46,14 +47,14 @@ class JettonWallet {
46
47
  return body.endCell();
47
48
  }
48
49
  async sendBurn(provider, via, value, opts) {
49
- const body = JettonWallet.burnMessage(opts.jettonAmount, opts.receiverAddress, opts.crossChainTonAmount, opts.crossChainPayload, opts.queryId);
50
+ const body = JettonWallet.burnMessage(opts.jettonAmount, opts.receiverAddress, opts.crossChainTonAmount, opts.feeData, opts.crossChainPayload, opts.queryId);
50
51
  await provider.internal(via, {
51
52
  value,
52
53
  sendMode: ton_1.SendMode.PAY_GAS_SEPARATELY,
53
54
  body: body,
54
55
  });
55
56
  }
56
- static transferMessage(jettonAmount, to, responseAddress, forwardTonAmount, crossChainTonAmount, crossChainPayload, queryId) {
57
+ static transferMessage(jettonAmount, to, responseAddress, forwardTonAmount, crossChainTonAmount, feeData, crossChainPayload, queryId) {
57
58
  return (0, ton_1.beginCell)()
58
59
  .storeUint(JettonWalletOpCodes.transfer, 32)
59
60
  .storeUint(queryId ?? 0, 64)
@@ -61,9 +62,12 @@ class JettonWallet {
61
62
  .storeAddress(ton_1.Address.parse(to))
62
63
  .storeAddress(responseAddress ? ton_1.Address.parse(responseAddress) : null)
63
64
  .storeMaybeRef(null)
64
- .storeCoins((forwardTonAmount || 0n) + (crossChainTonAmount || 0n))
65
+ .storeCoins((forwardTonAmount || 0n))
66
+ .storeMaybeRef((0, ton_1.beginCell)()
65
67
  .storeCoins(crossChainTonAmount ?? 0n)
68
+ .storeMaybeRef(feeData)
66
69
  .storeMaybeRef(crossChainPayload)
70
+ .endCell())
67
71
  .endCell();
68
72
  }
69
73
  async sendTransfer(provider, via, value, opts) {