@layerzerolabs/ton-sdk-tools 3.0.95 → 3.0.96

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @layerzerolabs/ton-sdk-tools
2
2
 
3
+ ## 3.0.96
4
+
5
+ ### Patch Changes
6
+
7
+ - 91d573e: ton sdk cleanup
8
+
3
9
  ## 3.0.95
4
10
 
5
11
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -470,10 +470,9 @@ function saveBaseEventHandler(directory, opcodesImportPath = "../constants", all
470
470
  /* eslint-disable @typescript-eslint/no-unsafe-assignment */
471
471
  /* eslint-disable @typescript-eslint/no-unnecessary-condition */
472
472
 
473
- import { Cell, Transaction, TransactionComputeVm, TransactionDescriptionGeneric, beginCell } from '@ton/core'
473
+ import { Cell, Transaction, beginCell } from '@ton/core'
474
474
  import { BlockchainTransaction, EventMessageSent, SendMessageResult } from '@ton/sandbox'
475
- import { flattenTransaction } from '@ton/test-utils'
476
- import { ExtendedContract, getLzDict } from '${baseWrapperImportPath}'
475
+ import { ExtendedContract } from '${baseWrapperImportPath}'
477
476
 
478
477
  import { OPCODES } from '${opcodesImportPath}'
479
478
 
@@ -531,11 +530,11 @@ export class BaseEventHandler {
531
530
  eventObjects: [] as LzEvent[],
532
531
  }
533
532
 
534
- async postProcessSuccess(event: LzEvent, tx: BlockchainTransaction & Transaction): Promise<void> {
533
+ async postProcessSuccess(_event: LzEvent, _tx: BlockchainTransaction & Transaction): Promise<void> {
535
534
  // base case: do nothing
536
535
  }
537
536
 
538
- async postProcessFailure(event: EventMessageSent, tx: BlockchainTransaction & Transaction): Promise<void> {
537
+ async postProcessFailure(_event: EventMessageSent, _tx: BlockchainTransaction & Transaction): Promise<void> {
539
538
  // base case: do nothing
540
539
  }
541
540
 
@@ -580,8 +579,8 @@ function saveLzEventHandler(directory, allTypesImportPath = "./allTypes", baseEv
580
579
  /* eslint-disable @typescript-eslint/no-unsafe-assignment */
581
580
  /* eslint-disable @typescript-eslint/no-unnecessary-condition */
582
581
 
583
- import { Cell, Transaction } from '@ton/core'
584
- import { BlockchainTransaction, EventMessageSent, SendMessageResult } from '@ton/sandbox'
582
+ import { Transaction } from '@ton/core'
583
+ import { BlockchainTransaction } from '@ton/sandbox'
585
584
 
586
585
  import { Md, MdPacketSent } from '${allTypesImportPath}'
587
586
  import { BaseEventHandler, LzEvent } from '${baseEventHandlerImportPath}'
@@ -593,7 +592,7 @@ export class LzEventHandler extends BaseEventHandler {
593
592
  packetsSent: [] as MdPacketSent[],
594
593
  }
595
594
 
596
- async postProcessSuccess(event: LzEvent, tx: BlockchainTransaction & Transaction): Promise<void> {
595
+ async postProcessSuccess(event: LzEvent, _tx: BlockchainTransaction & Transaction): Promise<void> {
597
596
  if (event.topic === 'Channel::event::PACKET_SENT' && this.isMdPacketSent(event.body)) {
598
597
  this.allVictories.packetsSent.push(event.body)
599
598
  }
@@ -619,16 +618,9 @@ function saveTonContractWrapper(tonObjects, directory, classlibWrapperImportPath
619
618
  const savedCode = `${file_signature_header}
620
619
 
621
620
  import {
622
- Address,
623
621
  Cell,
624
622
  ContractProvider,
625
- ContractState,
626
- Sender,
627
- SenderArguments,
628
- TupleItem,
629
- TupleReader,
630
623
  contractAddress,
631
- beginCell,
632
624
  } from '@ton/core'
633
625
 
634
626
  import { ClasslibWrapper } from '${classlibWrapperImportPath}'
@@ -644,8 +636,23 @@ export class TonContractWrapper extends ClasslibWrapper {
644
636
  `;
645
637
  fs__namespace.writeFileSync(path__namespace.join(directory, "TonContractWrapper.ts"), savedCode);
646
638
  }
639
+ function generateTypeStringFromTonObjects(tonObjects) {
640
+ return Object.entries(tonObjects).map(([key, tonObject]) => {
641
+ if (tonObject.attributes.length > 0) {
642
+ return "export " + (tonObject.tsTypeCode ?? "");
643
+ }
644
+ const fixedKey = key.replace(/::New.*$/, "");
645
+ const altObject = Object.entries(tonObjects).find(
646
+ ([otherKey, otherObj]) => otherKey !== key && otherKey.startsWith(fixedKey) && otherObj.attributes.length > 0
647
+ )?.[1];
648
+ if (!altObject) {
649
+ return "";
650
+ }
651
+ return "export " + (altObject.tsTypeCode?.replace(altObject.tsTypeName ?? "", tonObject.tsTypeName ?? "") ?? "");
652
+ }).filter((typeCode) => typeCode !== "").join("");
653
+ }
647
654
  function saveAllTypes(tonObjects, directory, tonContractWrapperImportPath = "./TonContractWrapper", baseWrapperImportPath = "@layerzerolabs/ton-sdk-tools") {
648
- const generatedTypes = Object.entries(tonObjects).filter(([_, tonObject]) => tonObject.attributes.length > 0).map(([_, tonObject]) => "export " + (tonObject.tsTypeCode ?? "")).join("");
655
+ const generatedTypes = generateTypeStringFromTonObjects(tonObjects);
649
656
  const mapping = {};
650
657
  const keyMapping = {};
651
658
  Object.entries(tonObjects).forEach(([key, item]) => {
@@ -670,11 +677,9 @@ function saveAllTypes(tonObjects, directory, tonContractWrapperImportPath = "./T
670
677
  const savedCode = `${file_signature_header}
671
678
  /* eslint-disable @typescript-eslint/no-empty-interface */
672
679
 
673
- import { Cell, OpenedContract, beginCell } from '@ton/core'
674
- import { SandboxContract } from '@ton/sandbox'
680
+ import { Cell } from '@ton/core'
675
681
 
676
- import { TonContractWrapper } from '${tonContractWrapperImportPath}'
677
- import { ExtendedContract, LzDict, getLzDict } from '${baseWrapperImportPath}'
682
+ import { LzDict } from '${baseWrapperImportPath}'
678
683
 
679
684
  export interface Md {}
680
685
 
@@ -816,23 +821,18 @@ export class LzGasTracker {
816
821
  }
817
822
  function saveTonObjectUnwrapper(tonObjects, directory, allTypesImportPath = "./allTypes", tonContractWrapperImportPath = "./TonContractWrapper", classlibWrapperImportPath = "@layerzerolabs/ton-sdk-tools", baseWrapperImportPath = "@layerzerolabs/ton-sdk-tools") {
818
823
  const allTypes = [
819
- ...Object.values(tonObjects).map((obj) => obj.tsTypeName).filter((name) => name !== void 0),
820
- "Md",
821
- "nameMap"
824
+ ...Object.values(tonObjects).filter((obj) => obj.attributes.length !== 0).map((obj) => obj.tsTypeName).filter((name) => name !== void 0)
822
825
  ].sort();
823
826
  const savedCode = `${file_signature_header}
824
827
  /* eslint-disable @typescript-eslint/no-unsafe-assignment */
825
828
  /* eslint-disable @typescript-eslint/no-unnecessary-condition */
826
829
 
827
- import { Cell, Transaction, TransactionComputeVm, TransactionDescriptionGeneric, beginCell } from '@ton/core'
828
- import { BlockchainTransaction, EventMessageSent, SendMessageResult } from '@ton/sandbox'
829
- import { flattenTransaction } from '@ton/test-utils'
830
+ import { Cell } from '@ton/core'
830
831
 
831
832
  import {
832
833
  ${allTypes.map((type) => " " + type + ",\n").join("")}} from '${allTypesImportPath}'
833
834
  import { TonContractWrapper } from '${tonContractWrapperImportPath}'
834
- import { ClasslibWrapper } from '${classlibWrapperImportPath}'
835
- import { ExtendedContract, LzDict, getLzDict } from '${baseWrapperImportPath}'
835
+ import { ExtendedContract, getLzDict } from '${baseWrapperImportPath}'
836
836
 
837
837
  export class TonObjectUnwrapper {
838
838
  ${Array.from(
@@ -1402,8 +1402,6 @@ import {
1402
1402
  Address,
1403
1403
  Builder,
1404
1404
  Cell,
1405
- Dictionary,
1406
- SendMode,
1407
1405
  TupleItem,
1408
1406
  TupleItemCell,
1409
1407
  TupleItemInt,
@@ -1412,16 +1410,12 @@ import {
1412
1410
  } from '@ton/core'
1413
1411
  import {
1414
1412
  Blockchain,
1415
- BlockchainTransaction,
1416
1413
  SandboxContract,
1417
1414
  SendMessageResult,
1418
- Treasury,
1419
1415
  TreasuryContract,
1420
1416
  } from '@ton/sandbox'
1421
1417
  import { FlatTransactionComparable } from '@ton/test-utils'
1422
- import { ethers } from 'ethers'
1423
1418
 
1424
- import AllStoragesArtifact from '@layerzerolabs/layerzero-v2-ton/build/AllStorages.compiled.json'
1425
1419
  import ChannelArtifact from '@layerzerolabs/layerzero-v2-ton/build/Channel.compiled.json'
1426
1420
  import ControllerArtifact from '@layerzerolabs/layerzero-v2-ton/build/Controller.compiled.json'
1427
1421
  import EndpointArtifact from '@layerzerolabs/layerzero-v2-ton/build/Endpoint.compiled.json'
@@ -1432,16 +1426,12 @@ import MultiSigOrderArtifact from '@layerzerolabs/layerzero-v2-ton/src/multisig/
1432
1426
  import {
1433
1427
  JettonMinter,
1434
1428
  JettonWallet,
1435
- MultiSigOpCodes,
1436
1429
  Multisig,
1437
- Order,
1438
1430
  Profile,
1439
- TransferRequest,
1440
1431
  addressToBigInt,
1441
1432
  buildOnchainMetadata,
1442
1433
  cellFromArtifact,
1443
1434
  getRandomInt,
1444
- printTransactionTrace,
1445
1435
  ExtendedContract,
1446
1436
  sendMessageViaMultisigAndExpect,
1447
1437
  sendInternalMessageAndExpect,
@@ -2703,8 +2693,14 @@ export async function txDecoder(
2703
2693
  }
2704
2694
  }
2705
2695
 
2706
- export async function runtimeDecoder(contract: SandboxContract<TonContractWrapper>, obj: Cell): Promise<void> {
2707
- const { tonObjects } = require('${options.relativeSrcPath}/offchain-helpers/allObjects') as { [key: string]: { [key: string]: any } }
2696
+ export async function runtimeDecoder(
2697
+ contract: SandboxContract<TonContractWrapper>,
2698
+ obj: Cell,
2699
+ tonObjectsImportPath = '../../src/offchain-helpers/allObjects'
2700
+ ): Promise<void> {
2701
+ const { tonObjects } = (await import(tonObjectsImportPath)) as {
2702
+ [key: string]: { [key: string]: any }
2703
+ }
2708
2704
 
2709
2705
  const typeName = await contract.getTypeOf(obj)
2710
2706
 
@@ -3147,18 +3143,16 @@ import ProxyArtifact from '@layerzerolabs/layerzero-v2-ton/build/Proxy.compiled.
3147
3143
  import UlnArtifact from '@layerzerolabs/layerzero-v2-ton/build/Uln.compiled.json'
3148
3144
  import UlnConnectionArtifact from '@layerzerolabs/layerzero-v2-ton/build/UlnConnection.compiled.json'
3149
3145
  import UlnManagerArtifact from '@layerzerolabs/layerzero-v2-ton/build/UlnManager.compiled.json'
3150
- import { BlueprintArtfiact, ExtendedContract, Profile, addressToBigInt, cellFromArtifact, sendInternalMessageAndExpect, sendMessageViaMultisigAndExpect, LzDict, createSignatures, createVerifierDictSetFromEtherWallets, generateRandomVerifierSet } from '@layerzerolabs/ton-sdk-tools'
3146
+ import { BlueprintArtfiact, ExtendedContract, Profile, addressToBigInt, cellFromArtifact, sendInternalMessageAndExpect, sendMessageViaMultisigAndExpect, createSignatures, createVerifierDictSetFromEtherWallets, generateRandomVerifierSet } from '@layerzerolabs/ton-sdk-tools'
3151
3147
 
3152
3148
  import {
3153
3149
  OAppFixture,
3154
3150
  OAppFlowGas,
3155
3151
  ProtocolFixture,
3156
- SIGNATURE_BYTE_LENGTH,
3157
3152
  addMsgLibToController,
3158
3153
  createLzPacketFromPacketEncoded,
3159
3154
  emptyObject,
3160
3155
  protocolSetupGas,
3161
- publicKeyToHash,
3162
3156
  requireDefined,
3163
3157
  serializeAddressList,
3164
3158
  setDefaultEndpointConfig,