nulltrace-sdk 1.0.1 → 1.0.3

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.cjs CHANGED
@@ -390,13 +390,12 @@ var NullTrace = class _NullTrace {
390
390
  toAddress: owner,
391
391
  lamports: amountLamports.sub(feeLamports),
392
392
  outputStateTreeInfo: tree
393
- })
394
- );
395
- ixs.push(
396
- import_web3.SystemProgram.transfer({
397
- fromPubkey: owner,
398
- toPubkey: OPERATOR_PUBLIC_KEY,
399
- lamports: feeLamports
393
+ }),
394
+ await import_stateless.LightSystemProgram.compress({
395
+ payer: owner,
396
+ toAddress: OPERATOR_PUBLIC_KEY,
397
+ lamports: feeLamports,
398
+ outputStateTreeInfo: tree
400
399
  })
401
400
  );
402
401
  } else {
@@ -421,8 +420,8 @@ var NullTrace = class _NullTrace {
421
420
  payer: owner,
422
421
  owner,
423
422
  source: sourceAta,
424
- toAddress: owner,
425
- amount: amountLamports.sub(feeLamports),
423
+ toAddress: [owner, OPERATOR_PUBLIC_KEY],
424
+ amount: [amountLamports.sub(feeLamports), feeLamports],
426
425
  mint: mintPk,
427
426
  outputStateTreeInfo: tree,
428
427
  tokenPoolInfo: {
@@ -435,14 +434,6 @@ var NullTrace = class _NullTrace {
435
434
  }
436
435
  })
437
436
  );
438
- const operatorAta = await (0, import_spl_token.getAssociatedTokenAddress)(mintPk, OPERATOR_PUBLIC_KEY, false, tokenProgram);
439
- const operatorInfo = await this.connection.getAccountInfo(operatorAta);
440
- if (!operatorInfo) {
441
- ixs.push((0, import_spl_token.createAssociatedTokenAccountInstruction)(owner, operatorAta, OPERATOR_PUBLIC_KEY, mintPk, tokenProgram));
442
- }
443
- ixs.push(
444
- (0, import_spl_token.createTransferCheckedInstruction)(sourceAta, mintPk, operatorAta, owner, feeLamports, decimals, [], tokenProgram)
445
- );
446
437
  }
447
438
  const adl = await this._getAlt();
448
439
  const txs = await _packTransactions(this.connection, owner, ixs, adl);
@@ -558,14 +549,15 @@ var NullTrace = class _NullTrace {
558
549
  throw new Error("Insufficient balance");
559
550
  const compressIx = await import_stateless.LightSystemProgram.compress({
560
551
  payer: owner,
561
- toAddress: OPERATOR_PUBLIC_KEY,
552
+ toAddress: recipientPk,
562
553
  lamports: (0, import_stateless.bn)(deficit.toString()).sub(fee),
563
554
  outputStateTreeInfo: tree
564
555
  });
565
- const feeIx = import_web3.SystemProgram.transfer({
566
- fromPubkey: owner,
567
- toPubkey: OPERATOR_PUBLIC_KEY,
568
- lamports: fee
556
+ const feeIx = await import_stateless.LightSystemProgram.compress({
557
+ payer: owner,
558
+ toAddress: OPERATOR_PUBLIC_KEY,
559
+ lamports: fee,
560
+ outputStateTreeInfo: tree
569
561
  });
570
562
  const msg = new import_web3.TransactionMessage({
571
563
  payerKey: owner,
@@ -614,8 +606,8 @@ var NullTrace = class _NullTrace {
614
606
  payer: owner,
615
607
  owner,
616
608
  source: sourceAta,
617
- toAddress: recipientPk,
618
- amount: (0, import_stateless.bn)(deficit.toString()).sub(fee),
609
+ toAddress: [recipientPk, OPERATOR_PUBLIC_KEY],
610
+ amount: [(0, import_stateless.bn)(deficit.toString()).sub(fee), fee],
619
611
  mint: new import_web3.PublicKey(mint),
620
612
  outputStateTreeInfo: tree,
621
613
  tokenPoolInfo: {
@@ -628,21 +620,6 @@ var NullTrace = class _NullTrace {
628
620
  }
629
621
  });
630
622
  instructions.push(compressInstruction);
631
- const operatorTokenAccount = await (0, import_spl_token.getAssociatedTokenAddress)(new import_web3.PublicKey(mint), OPERATOR_PUBLIC_KEY, false, tokenProgram);
632
- const operatorPoolInfo = await this.connection.getAccountInfo(operatorTokenAccount);
633
- if (!operatorPoolInfo) {
634
- instructions.push((0, import_spl_token.createAssociatedTokenAccountInstruction)(owner, operatorTokenAccount, OPERATOR_PUBLIC_KEY, new import_web3.PublicKey(mint), tokenProgram));
635
- }
636
- instructions.push((0, import_spl_token.createTransferCheckedInstruction)(
637
- new import_web3.PublicKey(sourceAta),
638
- new import_web3.PublicKey(mint),
639
- new import_web3.PublicKey(operatorTokenAccount),
640
- owner,
641
- fee,
642
- decimals,
643
- [],
644
- tokenProgram
645
- ));
646
623
  let tx = new import_web3.VersionedTransaction(new import_web3.TransactionMessage({
647
624
  payerKey: owner,
648
625
  recentBlockhash: blockhash,
@@ -763,22 +740,16 @@ var NullTrace = class _NullTrace {
763
740
  const compressIx = await import_stateless.LightSystemProgram.compress({
764
741
  payer: owner,
765
742
  toAddress: OPERATOR_PUBLIC_KEY,
766
- lamports: (0, import_stateless.bn)(deficit.toString()).sub(fee),
743
+ lamports: (0, import_stateless.bn)(deficit.toString()),
767
744
  outputStateTreeInfo: tree
768
745
  });
769
- const feeIx = import_web3.SystemProgram.transfer({
770
- fromPubkey: owner,
771
- toPubkey: OPERATOR_PUBLIC_KEY,
772
- lamports: fee
773
- });
774
746
  const msg = new import_web3.TransactionMessage({
775
747
  payerKey: owner,
776
748
  recentBlockhash: blockhash,
777
749
  instructions: [
778
750
  import_web3.ComputeBudgetProgram.setComputeUnitLimit({ units: COMPUTE_UNITS }),
779
751
  import_web3.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: COMPUTE_PRICE }),
780
- compressIx,
781
- feeIx
752
+ compressIx
782
753
  ]
783
754
  }).compileToV0Message([adl]);
784
755
  preTransactions.push(new import_web3.VersionedTransaction(msg));
@@ -819,7 +790,7 @@ var NullTrace = class _NullTrace {
819
790
  owner,
820
791
  source: sourceAta,
821
792
  toAddress: OPERATOR_PUBLIC_KEY,
822
- amount: (0, import_stateless.bn)(deficit.toString()).sub(fee),
793
+ amount: (0, import_stateless.bn)(deficit.toString()),
823
794
  mint: new import_web3.PublicKey(fromMint),
824
795
  outputStateTreeInfo: tree,
825
796
  tokenPoolInfo: {
@@ -832,21 +803,6 @@ var NullTrace = class _NullTrace {
832
803
  }
833
804
  });
834
805
  instructions.push(compressInstruction);
835
- const operatorTokenAccount = await (0, import_spl_token.getAssociatedTokenAddress)(new import_web3.PublicKey(fromMint), OPERATOR_PUBLIC_KEY, false, tokenProgram);
836
- const operatorPoolInfo = await this.connection.getAccountInfo(operatorTokenAccount);
837
- if (!operatorPoolInfo) {
838
- instructions.push((0, import_spl_token.createAssociatedTokenAccountInstruction)(owner, operatorTokenAccount, OPERATOR_PUBLIC_KEY, new import_web3.PublicKey(fromMint), tokenProgram));
839
- }
840
- instructions.push((0, import_spl_token.createTransferCheckedInstruction)(
841
- new import_web3.PublicKey(sourceAta),
842
- new import_web3.PublicKey(fromMint),
843
- new import_web3.PublicKey(operatorTokenAccount),
844
- owner,
845
- fee,
846
- decimals,
847
- [],
848
- tokenProgram
849
- ));
850
806
  let tx = new import_web3.VersionedTransaction(new import_web3.TransactionMessage({
851
807
  payerKey: owner,
852
808
  recentBlockhash: blockhash,
package/dist/index.mjs CHANGED
@@ -4,8 +4,7 @@ import {
4
4
  PublicKey,
5
5
  TransactionMessage,
6
6
  ComputeBudgetProgram,
7
- Keypair,
8
- SystemProgram
7
+ Keypair
9
8
  } from "@solana/web3.js";
10
9
  import {
11
10
  TOKEN_PROGRAM_ID,
@@ -380,13 +379,12 @@ var NullTrace = class _NullTrace {
380
379
  toAddress: owner,
381
380
  lamports: amountLamports.sub(feeLamports),
382
381
  outputStateTreeInfo: tree
383
- })
384
- );
385
- ixs.push(
386
- SystemProgram.transfer({
387
- fromPubkey: owner,
388
- toPubkey: OPERATOR_PUBLIC_KEY,
389
- lamports: feeLamports
382
+ }),
383
+ await LightSystemProgram.compress({
384
+ payer: owner,
385
+ toAddress: OPERATOR_PUBLIC_KEY,
386
+ lamports: feeLamports,
387
+ outputStateTreeInfo: tree
390
388
  })
391
389
  );
392
390
  } else {
@@ -411,8 +409,8 @@ var NullTrace = class _NullTrace {
411
409
  payer: owner,
412
410
  owner,
413
411
  source: sourceAta,
414
- toAddress: owner,
415
- amount: amountLamports.sub(feeLamports),
412
+ toAddress: [owner, OPERATOR_PUBLIC_KEY],
413
+ amount: [amountLamports.sub(feeLamports), feeLamports],
416
414
  mint: mintPk,
417
415
  outputStateTreeInfo: tree,
418
416
  tokenPoolInfo: {
@@ -425,14 +423,6 @@ var NullTrace = class _NullTrace {
425
423
  }
426
424
  })
427
425
  );
428
- const operatorAta = await getAssociatedTokenAddress(mintPk, OPERATOR_PUBLIC_KEY, false, tokenProgram);
429
- const operatorInfo = await this.connection.getAccountInfo(operatorAta);
430
- if (!operatorInfo) {
431
- ixs.push(createAssociatedTokenAccountInstruction(owner, operatorAta, OPERATOR_PUBLIC_KEY, mintPk, tokenProgram));
432
- }
433
- ixs.push(
434
- createTransferCheckedInstruction(sourceAta, mintPk, operatorAta, owner, feeLamports, decimals, [], tokenProgram)
435
- );
436
426
  }
437
427
  const adl = await this._getAlt();
438
428
  const txs = await _packTransactions(this.connection, owner, ixs, adl);
@@ -548,14 +538,15 @@ var NullTrace = class _NullTrace {
548
538
  throw new Error("Insufficient balance");
549
539
  const compressIx = await LightSystemProgram.compress({
550
540
  payer: owner,
551
- toAddress: OPERATOR_PUBLIC_KEY,
541
+ toAddress: recipientPk,
552
542
  lamports: bn(deficit.toString()).sub(fee),
553
543
  outputStateTreeInfo: tree
554
544
  });
555
- const feeIx = SystemProgram.transfer({
556
- fromPubkey: owner,
557
- toPubkey: OPERATOR_PUBLIC_KEY,
558
- lamports: fee
545
+ const feeIx = await LightSystemProgram.compress({
546
+ payer: owner,
547
+ toAddress: OPERATOR_PUBLIC_KEY,
548
+ lamports: fee,
549
+ outputStateTreeInfo: tree
559
550
  });
560
551
  const msg = new TransactionMessage({
561
552
  payerKey: owner,
@@ -604,8 +595,8 @@ var NullTrace = class _NullTrace {
604
595
  payer: owner,
605
596
  owner,
606
597
  source: sourceAta,
607
- toAddress: recipientPk,
608
- amount: bn(deficit.toString()).sub(fee),
598
+ toAddress: [recipientPk, OPERATOR_PUBLIC_KEY],
599
+ amount: [bn(deficit.toString()).sub(fee), fee],
609
600
  mint: new PublicKey(mint),
610
601
  outputStateTreeInfo: tree,
611
602
  tokenPoolInfo: {
@@ -618,21 +609,6 @@ var NullTrace = class _NullTrace {
618
609
  }
619
610
  });
620
611
  instructions.push(compressInstruction);
621
- const operatorTokenAccount = await getAssociatedTokenAddress(new PublicKey(mint), OPERATOR_PUBLIC_KEY, false, tokenProgram);
622
- const operatorPoolInfo = await this.connection.getAccountInfo(operatorTokenAccount);
623
- if (!operatorPoolInfo) {
624
- instructions.push(createAssociatedTokenAccountInstruction(owner, operatorTokenAccount, OPERATOR_PUBLIC_KEY, new PublicKey(mint), tokenProgram));
625
- }
626
- instructions.push(createTransferCheckedInstruction(
627
- new PublicKey(sourceAta),
628
- new PublicKey(mint),
629
- new PublicKey(operatorTokenAccount),
630
- owner,
631
- fee,
632
- decimals,
633
- [],
634
- tokenProgram
635
- ));
636
612
  let tx = new VersionedTransaction(new TransactionMessage({
637
613
  payerKey: owner,
638
614
  recentBlockhash: blockhash,
@@ -753,22 +729,16 @@ var NullTrace = class _NullTrace {
753
729
  const compressIx = await LightSystemProgram.compress({
754
730
  payer: owner,
755
731
  toAddress: OPERATOR_PUBLIC_KEY,
756
- lamports: bn(deficit.toString()).sub(fee),
732
+ lamports: bn(deficit.toString()),
757
733
  outputStateTreeInfo: tree
758
734
  });
759
- const feeIx = SystemProgram.transfer({
760
- fromPubkey: owner,
761
- toPubkey: OPERATOR_PUBLIC_KEY,
762
- lamports: fee
763
- });
764
735
  const msg = new TransactionMessage({
765
736
  payerKey: owner,
766
737
  recentBlockhash: blockhash,
767
738
  instructions: [
768
739
  ComputeBudgetProgram.setComputeUnitLimit({ units: COMPUTE_UNITS }),
769
740
  ComputeBudgetProgram.setComputeUnitPrice({ microLamports: COMPUTE_PRICE }),
770
- compressIx,
771
- feeIx
741
+ compressIx
772
742
  ]
773
743
  }).compileToV0Message([adl]);
774
744
  preTransactions.push(new VersionedTransaction(msg));
@@ -809,7 +779,7 @@ var NullTrace = class _NullTrace {
809
779
  owner,
810
780
  source: sourceAta,
811
781
  toAddress: OPERATOR_PUBLIC_KEY,
812
- amount: bn(deficit.toString()).sub(fee),
782
+ amount: bn(deficit.toString()),
813
783
  mint: new PublicKey(fromMint),
814
784
  outputStateTreeInfo: tree,
815
785
  tokenPoolInfo: {
@@ -822,21 +792,6 @@ var NullTrace = class _NullTrace {
822
792
  }
823
793
  });
824
794
  instructions.push(compressInstruction);
825
- const operatorTokenAccount = await getAssociatedTokenAddress(new PublicKey(fromMint), OPERATOR_PUBLIC_KEY, false, tokenProgram);
826
- const operatorPoolInfo = await this.connection.getAccountInfo(operatorTokenAccount);
827
- if (!operatorPoolInfo) {
828
- instructions.push(createAssociatedTokenAccountInstruction(owner, operatorTokenAccount, OPERATOR_PUBLIC_KEY, new PublicKey(fromMint), tokenProgram));
829
- }
830
- instructions.push(createTransferCheckedInstruction(
831
- new PublicKey(sourceAta),
832
- new PublicKey(fromMint),
833
- new PublicKey(operatorTokenAccount),
834
- owner,
835
- fee,
836
- decimals,
837
- [],
838
- tokenProgram
839
- ));
840
795
  let tx = new VersionedTransaction(new TransactionMessage({
841
796
  payerKey: owner,
842
797
  recentBlockhash: blockhash,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nulltrace-sdk",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "NullTrace SDK - Privacy-focused Solana transactions powered by ZK compression",
5
5
  "author": "NullTrace",
6
6
  "license": "MIT",
@@ -50,7 +50,7 @@
50
50
  ],
51
51
  "repository": {
52
52
  "type": "git",
53
- "url": "https://github.com/NullTraceBot/null-trace-local/tree/main/sdk",
53
+ "url": "https://github.com/NullTraceBot/null-trace-local",
54
54
  "directory": "sdk"
55
55
  },
56
56
  "homepage": "https://nulltrace.app"