@layerzerolabs/ton-sdk-tools 3.0.71 → 3.0.73

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/index.d.mts CHANGED
@@ -49,8 +49,12 @@ interface TonViewFunctionsDict {
49
49
  }
50
50
  declare function mergeConstructorDicts(result: TonObjectsDict, added: TonObjectsDict): TonObjectsDict;
51
51
  declare function parseDirectory(directoryPath: string): TonObjectsDict;
52
- declare function saveTonContractWrapper(tonObjects: TonObjectsDict, directory: string, baseWrapper?: string): void;
52
+ declare function saveBaseEventHandler(directory: string): void;
53
+ declare function saveLzEventHandler(directory: string): void;
54
+ declare function saveClasslibWrapper(directory: string, baseWrapper?: string): void;
55
+ declare function saveTonContractWrapper(tonObjects: TonObjectsDict, directory: string): void;
53
56
  declare function saveAllTypes(tonObjects: TonObjectsDict, directory: string): void;
57
+ declare function saveLzGasTracker(directory: string, opcodesImportPath?: string): void;
54
58
  declare function saveTonObjectUnwrapper(tonObjects: TonObjectsDict, directory: string): void;
55
59
  declare function generateConstructorCode(className: string, tonClasses: TonObjectsDict): TonObjectsDict;
56
60
  declare function generateAllConstructorCodes(tonClasses: TonObjectsDict): TonObjectsDict;
@@ -434,4 +438,4 @@ declare function printTransactionTrace(transactions: Transaction[], opcodeInfo:
434
438
  [p: string]: string;
435
439
  }, callerStack?: string, profile?: Profile): void;
436
440
 
437
- export { type Action, type Attribute, BASE_CHAIN_ID, BaseWrapper, type ConstructorArgs, type ConstructorCallGenerator, Errors, type FieldMap, type GasInfo, type InverseFieldMap, JettonMinter, type JettonMinterConfig, type JettonMinterContent, JettonWallet, type JettonWalletConfig, MASTER_CHAIN_ID, MASTER_CHAIN_SHARD, type Module, MultiSigErrors, MultiSigOpCodes, MultiSigParams, Multisig, type MultisigConfig, type MultisigData, Op, Order, type OrderFullConfig, type OrderInitConfig, type Profile, type SendRequestOptions, type TonObject, type TonObjectsDict, type TonViewFunction, type TonViewFunctionsDict, type TransferRequest, Txiterator, type UpdateRequest, addressToBigInt, bigintToAddress, buildOnchainMetadata, cellFromArtifact, computedGeneric, differentAddress, executeFrom, executeTill, extractErrors, extractEvents, extractOpcodes, findDeepestCell, findTransaction, formatCoinsPure, generateAllConstructorCodes, generateAllDeconstructorCodes, generateAllTonClassTypes, generateAllViewFunctions, generateCommonTestUtils, generateConstructorCode, generateDeconstructorCode, generateSmlTestUtils, generateTonClassType, generateUlnTestUtils, getMsgPrices, getOpcodeCRC, getRandom, getRandomInt, getSpecificFiles, jettonContentToCell, jettonMinterConfigToCell, jettonWalletConfigToCell, makeSnakeCell, mergeConstructorDicts, multisigConfigToCell, orderConfigToCell, parseDirectory, printTransactionTrace, saveAllTypes, saveConstantsFile, saveEventsFile, saveObjectsAsTS, saveTonContractWrapper, saveTonObjectUnwrapper, saveViewFunctions, storageCollected, to32ByteBuffer };
441
+ export { type Action, type Attribute, BASE_CHAIN_ID, BaseWrapper, type ConstructorArgs, type ConstructorCallGenerator, Errors, type FieldMap, type GasInfo, type InverseFieldMap, JettonMinter, type JettonMinterConfig, type JettonMinterContent, JettonWallet, type JettonWalletConfig, MASTER_CHAIN_ID, MASTER_CHAIN_SHARD, type Module, MultiSigErrors, MultiSigOpCodes, MultiSigParams, Multisig, type MultisigConfig, type MultisigData, Op, Order, type OrderFullConfig, type OrderInitConfig, type Profile, type SendRequestOptions, type TonObject, type TonObjectsDict, type TonViewFunction, type TonViewFunctionsDict, type TransferRequest, Txiterator, type UpdateRequest, addressToBigInt, bigintToAddress, buildOnchainMetadata, cellFromArtifact, computedGeneric, differentAddress, executeFrom, executeTill, extractErrors, extractEvents, extractOpcodes, findDeepestCell, findTransaction, formatCoinsPure, generateAllConstructorCodes, generateAllDeconstructorCodes, generateAllTonClassTypes, generateAllViewFunctions, generateCommonTestUtils, generateConstructorCode, generateDeconstructorCode, generateSmlTestUtils, generateTonClassType, generateUlnTestUtils, getMsgPrices, getOpcodeCRC, getRandom, getRandomInt, getSpecificFiles, jettonContentToCell, jettonMinterConfigToCell, jettonWalletConfigToCell, makeSnakeCell, mergeConstructorDicts, multisigConfigToCell, orderConfigToCell, parseDirectory, printTransactionTrace, saveAllTypes, saveBaseEventHandler, saveClasslibWrapper, saveConstantsFile, saveEventsFile, saveLzEventHandler, saveLzGasTracker, saveObjectsAsTS, saveTonContractWrapper, saveTonObjectUnwrapper, saveViewFunctions, storageCollected, to32ByteBuffer };
package/dist/index.d.ts CHANGED
@@ -49,8 +49,12 @@ interface TonViewFunctionsDict {
49
49
  }
50
50
  declare function mergeConstructorDicts(result: TonObjectsDict, added: TonObjectsDict): TonObjectsDict;
51
51
  declare function parseDirectory(directoryPath: string): TonObjectsDict;
52
- declare function saveTonContractWrapper(tonObjects: TonObjectsDict, directory: string, baseWrapper?: string): void;
52
+ declare function saveBaseEventHandler(directory: string): void;
53
+ declare function saveLzEventHandler(directory: string): void;
54
+ declare function saveClasslibWrapper(directory: string, baseWrapper?: string): void;
55
+ declare function saveTonContractWrapper(tonObjects: TonObjectsDict, directory: string): void;
53
56
  declare function saveAllTypes(tonObjects: TonObjectsDict, directory: string): void;
57
+ declare function saveLzGasTracker(directory: string, opcodesImportPath?: string): void;
54
58
  declare function saveTonObjectUnwrapper(tonObjects: TonObjectsDict, directory: string): void;
55
59
  declare function generateConstructorCode(className: string, tonClasses: TonObjectsDict): TonObjectsDict;
56
60
  declare function generateAllConstructorCodes(tonClasses: TonObjectsDict): TonObjectsDict;
@@ -434,4 +438,4 @@ declare function printTransactionTrace(transactions: Transaction[], opcodeInfo:
434
438
  [p: string]: string;
435
439
  }, callerStack?: string, profile?: Profile): void;
436
440
 
437
- export { type Action, type Attribute, BASE_CHAIN_ID, BaseWrapper, type ConstructorArgs, type ConstructorCallGenerator, Errors, type FieldMap, type GasInfo, type InverseFieldMap, JettonMinter, type JettonMinterConfig, type JettonMinterContent, JettonWallet, type JettonWalletConfig, MASTER_CHAIN_ID, MASTER_CHAIN_SHARD, type Module, MultiSigErrors, MultiSigOpCodes, MultiSigParams, Multisig, type MultisigConfig, type MultisigData, Op, Order, type OrderFullConfig, type OrderInitConfig, type Profile, type SendRequestOptions, type TonObject, type TonObjectsDict, type TonViewFunction, type TonViewFunctionsDict, type TransferRequest, Txiterator, type UpdateRequest, addressToBigInt, bigintToAddress, buildOnchainMetadata, cellFromArtifact, computedGeneric, differentAddress, executeFrom, executeTill, extractErrors, extractEvents, extractOpcodes, findDeepestCell, findTransaction, formatCoinsPure, generateAllConstructorCodes, generateAllDeconstructorCodes, generateAllTonClassTypes, generateAllViewFunctions, generateCommonTestUtils, generateConstructorCode, generateDeconstructorCode, generateSmlTestUtils, generateTonClassType, generateUlnTestUtils, getMsgPrices, getOpcodeCRC, getRandom, getRandomInt, getSpecificFiles, jettonContentToCell, jettonMinterConfigToCell, jettonWalletConfigToCell, makeSnakeCell, mergeConstructorDicts, multisigConfigToCell, orderConfigToCell, parseDirectory, printTransactionTrace, saveAllTypes, saveConstantsFile, saveEventsFile, saveObjectsAsTS, saveTonContractWrapper, saveTonObjectUnwrapper, saveViewFunctions, storageCollected, to32ByteBuffer };
441
+ export { type Action, type Attribute, BASE_CHAIN_ID, BaseWrapper, type ConstructorArgs, type ConstructorCallGenerator, Errors, type FieldMap, type GasInfo, type InverseFieldMap, JettonMinter, type JettonMinterConfig, type JettonMinterContent, JettonWallet, type JettonWalletConfig, MASTER_CHAIN_ID, MASTER_CHAIN_SHARD, type Module, MultiSigErrors, MultiSigOpCodes, MultiSigParams, Multisig, type MultisigConfig, type MultisigData, Op, Order, type OrderFullConfig, type OrderInitConfig, type Profile, type SendRequestOptions, type TonObject, type TonObjectsDict, type TonViewFunction, type TonViewFunctionsDict, type TransferRequest, Txiterator, type UpdateRequest, addressToBigInt, bigintToAddress, buildOnchainMetadata, cellFromArtifact, computedGeneric, differentAddress, executeFrom, executeTill, extractErrors, extractEvents, extractOpcodes, findDeepestCell, findTransaction, formatCoinsPure, generateAllConstructorCodes, generateAllDeconstructorCodes, generateAllTonClassTypes, generateAllViewFunctions, generateCommonTestUtils, generateConstructorCode, generateDeconstructorCode, generateSmlTestUtils, generateTonClassType, generateUlnTestUtils, getMsgPrices, getOpcodeCRC, getRandom, getRandomInt, getSpecificFiles, jettonContentToCell, jettonMinterConfigToCell, jettonWalletConfigToCell, makeSnakeCell, mergeConstructorDicts, multisigConfigToCell, orderConfigToCell, parseDirectory, printTransactionTrace, saveAllTypes, saveBaseEventHandler, saveClasslibWrapper, saveConstantsFile, saveEventsFile, saveLzEventHandler, saveLzGasTracker, saveObjectsAsTS, saveTonContractWrapper, saveTonObjectUnwrapper, saveViewFunctions, storageCollected, to32ByteBuffer };
package/dist/index.mjs CHANGED
@@ -323,8 +323,156 @@ function parseClasses(strInput) {
323
323
  }
324
324
  return results;
325
325
  }
326
- function saveTonContractWrapper(tonObjects, directory, baseWrapper) {
327
- const generatedMethods = Object.entries(tonObjects).map(([_, tonObject]) => tonObject.constructorCode ?? "").join("\n");
326
+ function saveBaseEventHandler(directory) {
327
+ const allTypes = ["ExtendedContract", "ActionEvent", "Md", "nameMap"].sort();
328
+ const savedCode = `${file_signature_header}
329
+ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
330
+ /* eslint-disable @typescript-eslint/no-unnecessary-condition */
331
+
332
+ import { Cell, Transaction, TransactionComputeVm, TransactionDescriptionGeneric, beginCell } from '@ton/core'
333
+ import { BlockchainTransaction, EventMessageSent, SendMessageResult } from '@ton/sandbox'
334
+ import { flattenTransaction } from '@ton/test-utils'
335
+
336
+ import { OPCODES } from '../constants'
337
+
338
+ import { getLzDict,
339
+ ${allTypes.map((type) => " " + type + ",\n").join("")}} from './allTypes'
340
+
341
+ import { TonObjectUnwrapper } from './TonObjectUnwrapper'
342
+ import { TonContractWrapper } from './TonContractWrapper'
343
+
344
+ export class LzEvent {
345
+ private _eventPromise: Promise<ActionEvent>
346
+ private _event: ActionEvent | null
347
+ public topic: string
348
+ public body: Md
349
+ public bodyName: string
350
+ public initialStorage: Cell
351
+ public initialized: boolean
352
+
353
+ constructor(wrapper: ExtendedContract<TonContractWrapper>, cell: Cell) {
354
+ this._eventPromise = TonObjectUnwrapper.getActionEventToTS(wrapper, cell)
355
+ this._event = null
356
+ this.topic = ''
357
+ this.body = {}
358
+ this.initialStorage = beginCell().endCell()
359
+ this.initialized = false
360
+ this.bodyName = ''
361
+ }
362
+
363
+ async load(wrapper: ExtendedContract<TonContractWrapper>): Promise<boolean> {
364
+ this._event = await this._eventPromise
365
+ this.topic = TonContractWrapper.bigintToAsciiString(this._event.topic)
366
+ this.bodyName = await TonObjectUnwrapper.getTypeOf(wrapper, this._event.body)
367
+ const tsCasterName = 'get' + nameMap[this.bodyName] + 'ToTS'
368
+
369
+ const method = TonObjectUnwrapper[tsCasterName as keyof typeof TonObjectUnwrapper]
370
+ if (typeof method === 'function') {
371
+ this.body = await method(wrapper, this._event.body)
372
+ } else {
373
+ console.log('Method' + tsCasterName + 'does not exist.')
374
+ }
375
+
376
+ this.initialStorage = this._event.initialStorage
377
+ this.initialized = true
378
+ return this.initialized
379
+ }
380
+ }
381
+
382
+ export class BaseEventHandler {
383
+ public allFailures = {
384
+ txList: [] as BlockchainTransaction[],
385
+ events: [] as EventMessageSent[],
386
+ }
387
+ public allVictories = {
388
+ txList: [] as BlockchainTransaction[],
389
+ eventObjects: [] as LzEvent[],
390
+ }
391
+
392
+ async postProcessSuccess(event: LzEvent, tx: BlockchainTransaction & Transaction): Promise<void> {
393
+ // base case: do nothing
394
+ }
395
+
396
+ async postProcessFailure(event: EventMessageSent, tx: BlockchainTransaction & Transaction): Promise<void> {
397
+ // base case: do nothing
398
+ }
399
+
400
+ async addCurrentEventsToAllEvents(
401
+ results: SendMessageResult,
402
+ contract: ExtendedContract<TonContractWrapper>
403
+ ): Promise<void> {
404
+ for (let i = 0; i < results.transactions.length; i++) {
405
+ const tx: BlockchainTransaction & Transaction = results.transactions[i]
406
+ const desc = tx.description
407
+ if (desc.type !== 'generic' || desc.computePhase.type !== 'skipped') continue
408
+
409
+ const eventBody = tx.inMessage?.body
410
+ if (eventBody === undefined) continue
411
+ const eventBodySlice = eventBody.beginParse()
412
+ // the event body is empty if we are sending a payment with no corresponding payload
413
+ if (eventBodySlice.remainingBits < 32) continue
414
+ const opCode = eventBodySlice.loadUint(32)
415
+ if (opCode === Number(OPCODES.BaseInterface_OP_EVENT)) {
416
+ if (eventBody.refs.length > 0) {
417
+ const eventInnerCell = eventBody.refs[0]
418
+ const newLzEvent = new LzEvent(contract, eventInnerCell)
419
+ await newLzEvent.load(contract)
420
+ this.allVictories.txList.push(tx)
421
+ this.allVictories.eventObjects.push(newLzEvent)
422
+ await this.postProcessSuccess(newLzEvent, tx)
423
+ }
424
+ } else {
425
+ const failureEvent = results.events[i] as EventMessageSent
426
+ this.allFailures.txList.push(tx)
427
+ this.allFailures.events.push(failureEvent)
428
+ await this.postProcessFailure(failureEvent, tx)
429
+ }
430
+ }
431
+ }
432
+ }
433
+ `;
434
+ fs.writeFileSync(path.join(directory, "BaseEventHandler.ts"), savedCode);
435
+ }
436
+ function saveLzEventHandler(directory) {
437
+ const savedCode = `${file_signature_header}
438
+ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
439
+ /* eslint-disable @typescript-eslint/no-unnecessary-condition */
440
+
441
+ import { Cell, Transaction } from '@ton/core'
442
+ import { BlockchainTransaction, EventMessageSent, SendMessageResult } from '@ton/sandbox'
443
+
444
+ import { Md, MdPacketSent } from './allTypes'
445
+ import { BaseEventHandler, LzEvent } from './BaseEventHandler'
446
+
447
+ export class LzEventHandler extends BaseEventHandler {
448
+ public allVictories = {
449
+ txList: [] as BlockchainTransaction[],
450
+ eventObjects: [] as LzEvent[],
451
+ packetsSent: [] as MdPacketSent[],
452
+ }
453
+
454
+ async postProcessSuccess(event: LzEvent, tx: BlockchainTransaction & Transaction): Promise<void> {
455
+ if (event.topic === 'Channel::event::PACKET_SENT' && this.isMdPacketSent(event.body)) {
456
+ this.allVictories.packetsSent.push(event.body)
457
+ }
458
+ await Promise.resolve()
459
+ }
460
+
461
+ isMdPacketSent(md: Md): md is MdPacketSent {
462
+ return (
463
+ 'nativeFee' in md &&
464
+ 'zroFee' in md &&
465
+ 'extraOptions' in md &&
466
+ 'enforcedOptions' in md &&
467
+ 'packetEncoded' in md &&
468
+ 'nonce' in md
469
+ )
470
+ }
471
+ }
472
+ `;
473
+ fs.writeFileSync(path.join(directory, "LzEventHandler.ts"), savedCode);
474
+ }
475
+ function saveClasslibWrapper(directory, baseWrapper) {
328
476
  if (baseWrapper === void 0) {
329
477
  baseWrapper = `import { BaseWrapper, SendRequestOptions } from '@layerzerolabs/ton-sdk-tools'`;
330
478
  }
@@ -355,10 +503,10 @@ export type GetIntFnNames =
355
503
  | 'cl::get<bool>'
356
504
  | 'cl::get<address>'
357
505
 
358
- export class TonContractWrapper extends BaseWrapper {
359
- static create(code: Cell, data: Cell, workchain = 0): TonContractWrapper {
506
+ export class ClasslibWrapper extends BaseWrapper {
507
+ static create(code: Cell, data: Cell, workchain = 0): ClasslibWrapper {
360
508
  const init = { code, data }
361
- return new TonContractWrapper(contractAddress(workchain, init), init)
509
+ return new ClasslibWrapper(contractAddress(workchain, init), init)
362
510
  }
363
511
 
364
512
  buildRequest(
@@ -485,8 +633,46 @@ export class TonContractWrapper extends BaseWrapper {
485
633
  const ret = await provider.get('cl::dict256::setRef', args)
486
634
  return ret.stack.readCell()
487
635
  }
636
+ }
637
+ `;
638
+ fs.writeFileSync(path.join(directory, "ClasslibWrapper.ts"), savedCode);
639
+ }
640
+ function saveTonContractWrapper(tonObjects, directory) {
641
+ const generatedMethods = Object.entries(tonObjects).map(([_, tonObject]) => tonObject.constructorCode ?? "").join("\n");
642
+ const savedCode = `${file_signature_header}
643
+
644
+ import {
645
+ Address,
646
+ Cell,
647
+ ContractProvider,
648
+ ContractState,
649
+ Sender,
650
+ SenderArguments,
651
+ TupleItem,
652
+ TupleReader,
653
+ contractAddress,
654
+ beginCell,
655
+ } from '@ton/core'
656
+
657
+ import { ClasslibWrapper } from './ClasslibWrapper'
658
+
659
+ export class TonContractWrapper extends ClasslibWrapper {
660
+ static create(code: Cell, data: Cell, workchain = 0): TonContractWrapper {
661
+ const init = { code, data }
662
+ return new TonContractWrapper(contractAddress(workchain, init), init)
663
+ }
664
+
665
+ static bigintToAsciiString(num: bigint): string {
666
+ let result = ''
667
+ while (num > 0n) {
668
+ const charCode = Number(num & 255n)
669
+ result = String.fromCharCode(charCode) + result
670
+ num = num >> 8n
671
+ }
672
+ return result
673
+ }
488
674
 
489
- ${generatedMethods}
675
+ ${generatedMethods}
490
676
  }
491
677
  `;
492
678
  fs.writeFileSync(path.join(directory, "TonContractWrapper.ts"), savedCode);
@@ -552,6 +738,11 @@ export class LzDict {
552
738
  }
553
739
  }
554
740
 
741
+ export async function getLzDict(obj: Cell, fieldName: bigint, wrapper: ExtendedContract<TonContractWrapper>): Promise<LzDict> {
742
+ const dictCell = await wrapper.getClDict(obj, fieldName)
743
+ return new LzDict(dictCell)
744
+ }
745
+
555
746
  export interface Md {}
556
747
 
557
748
  ${generatedTypes}
@@ -560,14 +751,8 @@ ${generatedNameMaps}
560
751
  `;
561
752
  fs.writeFileSync(path.join(directory, "allTypes.ts"), savedCode);
562
753
  }
563
- function saveTonObjectUnwrapper(tonObjects, directory) {
564
- const allTypes = [
565
- ...Object.values(tonObjects).map((obj) => obj.tsTypeName).filter((name) => name !== void 0),
566
- "ExtendedContract",
567
- "LzDict",
568
- "Md",
569
- "nameMap"
570
- ].sort();
754
+ function saveLzGasTracker(directory, opcodesImportPath) {
755
+ opcodesImportPath = opcodesImportPath ?? "../constants";
571
756
  const savedCode = `${file_signature_header}
572
757
  /* eslint-disable @typescript-eslint/no-unsafe-assignment */
573
758
  /* eslint-disable @typescript-eslint/no-unnecessary-condition */
@@ -576,106 +761,9 @@ import { Cell, Transaction, TransactionComputeVm, TransactionDescriptionGeneric,
576
761
  import { BlockchainTransaction, EventMessageSent, SendMessageResult } from '@ton/sandbox'
577
762
  import { flattenTransaction } from '@ton/test-utils'
578
763
 
579
- import { OPCODES } from '../constants'
580
-
581
- import {
582
- ${allTypes.map((type) => " " + type + ",\n").join("")}} from './allTypes'
583
- import { TonContractWrapper } from './TonContractWrapper'
584
-
585
- function bigintToAsciiString(num: bigint): string {
586
- let result = ''
587
- while (num > 0n) {
588
- const charCode = Number(num & 255n)
589
- result = String.fromCharCode(charCode) + result
590
- num = num >> 8n
591
- }
592
- return result
593
- }
594
-
595
- export class LzEvent {
596
- private _eventPromise: Promise<ActionEvent>
597
- private _event: ActionEvent | null
598
- public topic: string
599
- public body: Md
600
- public bodyName: string
601
- public initialStorage: Cell
602
- public initialized: boolean
603
-
604
- constructor(wrapper: ExtendedContract<TonContractWrapper>, cell: Cell) {
605
- this._eventPromise = TonObjectUnwrapper.getActionEventToTS(wrapper, cell)
606
- this._event = null
607
- this.topic = ''
608
- this.body = {}
609
- this.initialStorage = beginCell().endCell()
610
- this.initialized = false
611
- this.bodyName = ''
612
- }
613
-
614
- async load(wrapper: ExtendedContract<TonContractWrapper>): Promise<boolean> {
615
- this._event = await this._eventPromise
616
- this.topic = bigintToAsciiString(this._event.topic)
617
- this.bodyName = await TonObjectUnwrapper.getTypeOf(wrapper, this._event.body)
618
- const tsCasterName = 'get' + nameMap[this.bodyName] + 'ToTS'
619
-
620
- const method = TonObjectUnwrapper[tsCasterName as keyof typeof TonObjectUnwrapper]
621
- if (typeof method === 'function') {
622
- this.body = await method(wrapper, this._event.body)
623
- } else {
624
- console.log('Method' + tsCasterName + 'does not exist.')
625
- }
626
-
627
- this.initialStorage = this._event.initialStorage
628
- this.initialized = true
629
- return this.initialized
630
- }
631
- }
764
+ import { OPCODES } from '${opcodesImportPath}'
632
765
 
633
- export class LzEventHandler {
634
- public allFailures = {
635
- txList: [] as BlockchainTransaction[],
636
- events: [] as EventMessageSent[],
637
- }
638
- public allVictories = {
639
- txList: [] as BlockchainTransaction[],
640
- eventObjects: [] as LzEvent[],
641
- packetsSent: [] as MdPacketSent[],
642
- }
643
- async addCurrentEventsToAllEvents(results: SendMessageResult, contract: ExtendedContract<TonContractWrapper>): Promise<void> {
644
- for (let i = 0; i < results.transactions.length; i++) {
645
- const tx: BlockchainTransaction & Transaction = results.transactions[i]
646
- const desc = tx.description
647
- if (desc.type !== 'generic' || desc.computePhase.type !== 'skipped') continue
648
-
649
- const eventBody = tx.inMessage?.body
650
- if (eventBody === undefined) continue
651
- const eventBodySlice = eventBody.beginParse()
652
- // the event body is empty if we are sending a payment with no corresponding payload
653
- if (eventBodySlice.remainingBits < 32) continue
654
- const opCode = eventBodySlice.loadUint(32)
655
- if (opCode === Number(OPCODES.BaseInterface_OP_EVENT)) {
656
- if (eventBody.refs.length > 0) {
657
- const eventInnerCell = eventBody.refs[0]
658
- const newLzEvent = new LzEvent(contract, eventInnerCell)
659
- await newLzEvent.load(contract)
660
- this.allVictories.txList.push(tx)
661
- this.allVictories.eventObjects.push(newLzEvent)
662
- if (newLzEvent.topic === 'Channel::event::PACKET_SENT' && this.isMdPacketSent(newLzEvent.body)) {
663
- this.allVictories.packetsSent.push(newLzEvent.body)
664
- // getMdLzSendToTS(contract, newLzEvent.body.lzSend)
665
- }
666
- }
667
- } else {
668
- this.allFailures.txList.push(tx)
669
- this.allFailures.events.push(results.events[i] as EventMessageSent)
670
- }
671
- }
672
- }
673
- isMdPacketSent(md: Md): md is MdPacketSent {
674
- return 'nativeFee' in md && 'zroFee' in md && 'extraOptions' in md && 'enforcedOptions' in md && 'packetEncoded' in md && 'nonce' in md
675
- }
676
- }
677
-
678
- interface GasStructure {
766
+ export interface GasStructure {
679
767
  actionFee: bigint
680
768
  forwardFee: bigint
681
769
  computeFee: bigint
@@ -791,17 +879,35 @@ export class LzGasTracker {
791
879
  // Log the entire table
792
880
  return tableString
793
881
  }
882
+ }`;
883
+ fs.writeFileSync(path.join(directory, "LzGasTracker.ts"), savedCode);
794
884
  }
885
+ function saveTonObjectUnwrapper(tonObjects, directory) {
886
+ const allTypes = [
887
+ ...Object.values(tonObjects).map((obj) => obj.tsTypeName).filter((name) => name !== void 0),
888
+ "ExtendedContract",
889
+ "LzDict",
890
+ "Md",
891
+ "nameMap"
892
+ ].sort();
893
+ const savedCode = `${file_signature_header}
894
+ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
895
+ /* eslint-disable @typescript-eslint/no-unnecessary-condition */
795
896
 
796
- async function getLzDict( obj: Cell, fieldName: bigint, wrapper: ExtendedContract<TonContractWrapper>): Promise<LzDict> {
797
- const dictCell = await wrapper.getClDict(obj, fieldName)
798
- return new LzDict(dictCell)
799
- }
897
+ import { Cell, Transaction, TransactionComputeVm, TransactionDescriptionGeneric, beginCell } from '@ton/core'
898
+ import { BlockchainTransaction, EventMessageSent, SendMessageResult } from '@ton/sandbox'
899
+ import { flattenTransaction } from '@ton/test-utils'
900
+
901
+ import { OPCODES } from '../constants'
902
+
903
+ import { getLzDict,
904
+ ${allTypes.map((type) => " " + type + ",\n").join("")}} from './allTypes'
905
+ import { TonContractWrapper } from './TonContractWrapper'
800
906
 
801
907
  export class TonObjectUnwrapper {
802
908
  static async getTypeOf(provider: ExtendedContract<TonContractWrapper>, obj_cell: Cell): Promise<string> {
803
909
  const ret = await provider.getViewFunction('cl::typeof', [{ type: 'cell', cell: obj_cell }])
804
- return bigintToAsciiString(ret.readBigNumber())
910
+ return TonContractWrapper.bigintToAsciiString(ret.readBigNumber())
805
911
  }
806
912
  ${Array.from(
807
913
  new Map(
@@ -6194,6 +6300,6 @@ function printTransactionTrace(transactions, opcodeInfo, callerStack, profile) {
6194
6300
  if (profile?.profileGas) sortAndSave(filePath, gasInfo);
6195
6301
  }
6196
6302
 
6197
- export { BASE_CHAIN_ID, BaseWrapper, Errors, JettonMinter, JettonWallet, MASTER_CHAIN_ID, MASTER_CHAIN_SHARD, MultiSigErrors, MultiSigOpCodes, MultiSigParams, Multisig, Op, Order, Txiterator, addressToBigInt, bigintToAddress, buildOnchainMetadata, cellFromArtifact, computedGeneric, differentAddress, executeFrom, executeTill, extractErrors, extractEvents, extractOpcodes, findDeepestCell, findTransaction, formatCoinsPure, generateAllConstructorCodes, generateAllDeconstructorCodes, generateAllTonClassTypes, generateAllViewFunctions, generateCommonTestUtils, generateConstructorCode, generateDeconstructorCode, generateSmlTestUtils, generateTonClassType, generateUlnTestUtils, getMsgPrices, getOpcodeCRC, getRandom, getRandomInt, getSpecificFiles, jettonContentToCell, jettonMinterConfigToCell, jettonWalletConfigToCell, makeSnakeCell, mergeConstructorDicts, multisigConfigToCell, orderConfigToCell, parseDirectory, printTransactionTrace, saveAllTypes, saveConstantsFile, saveEventsFile, saveObjectsAsTS, saveTonContractWrapper, saveTonObjectUnwrapper, saveViewFunctions, storageCollected, to32ByteBuffer };
6303
+ export { BASE_CHAIN_ID, BaseWrapper, Errors, JettonMinter, JettonWallet, MASTER_CHAIN_ID, MASTER_CHAIN_SHARD, MultiSigErrors, MultiSigOpCodes, MultiSigParams, Multisig, Op, Order, Txiterator, addressToBigInt, bigintToAddress, buildOnchainMetadata, cellFromArtifact, computedGeneric, differentAddress, executeFrom, executeTill, extractErrors, extractEvents, extractOpcodes, findDeepestCell, findTransaction, formatCoinsPure, generateAllConstructorCodes, generateAllDeconstructorCodes, generateAllTonClassTypes, generateAllViewFunctions, generateCommonTestUtils, generateConstructorCode, generateDeconstructorCode, generateSmlTestUtils, generateTonClassType, generateUlnTestUtils, getMsgPrices, getOpcodeCRC, getRandom, getRandomInt, getSpecificFiles, jettonContentToCell, jettonMinterConfigToCell, jettonWalletConfigToCell, makeSnakeCell, mergeConstructorDicts, multisigConfigToCell, orderConfigToCell, parseDirectory, printTransactionTrace, saveAllTypes, saveBaseEventHandler, saveClasslibWrapper, saveConstantsFile, saveEventsFile, saveLzEventHandler, saveLzGasTracker, saveObjectsAsTS, saveTonContractWrapper, saveTonObjectUnwrapper, saveViewFunctions, storageCollected, to32ByteBuffer };
6198
6304
  //# sourceMappingURL=index.mjs.map
6199
6305
  //# sourceMappingURL=index.mjs.map