nulltrace-sdk 1.0.1 → 1.0.2
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 +19 -55
- package/dist/index.mjs +20 -57
- package/package.json +1 -1
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
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
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: {
|
|
@@ -558,14 +557,15 @@ var NullTrace = class _NullTrace {
|
|
|
558
557
|
throw new Error("Insufficient balance");
|
|
559
558
|
const compressIx = await import_stateless.LightSystemProgram.compress({
|
|
560
559
|
payer: owner,
|
|
561
|
-
toAddress:
|
|
560
|
+
toAddress: recipientPk,
|
|
562
561
|
lamports: (0, import_stateless.bn)(deficit.toString()).sub(fee),
|
|
563
562
|
outputStateTreeInfo: tree
|
|
564
563
|
});
|
|
565
|
-
const feeIx =
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
lamports: fee
|
|
564
|
+
const feeIx = await import_stateless.LightSystemProgram.compress({
|
|
565
|
+
payer: owner,
|
|
566
|
+
toAddress: OPERATOR_PUBLIC_KEY,
|
|
567
|
+
lamports: fee,
|
|
568
|
+
outputStateTreeInfo: tree
|
|
569
569
|
});
|
|
570
570
|
const msg = new import_web3.TransactionMessage({
|
|
571
571
|
payerKey: owner,
|
|
@@ -614,8 +614,8 @@ var NullTrace = class _NullTrace {
|
|
|
614
614
|
payer: owner,
|
|
615
615
|
owner,
|
|
616
616
|
source: sourceAta,
|
|
617
|
-
toAddress: recipientPk,
|
|
618
|
-
amount: (0, import_stateless.bn)(deficit.toString()).sub(fee),
|
|
617
|
+
toAddress: [recipientPk, OPERATOR_PUBLIC_KEY],
|
|
618
|
+
amount: [(0, import_stateless.bn)(deficit.toString()).sub(fee), fee],
|
|
619
619
|
mint: new import_web3.PublicKey(mint),
|
|
620
620
|
outputStateTreeInfo: tree,
|
|
621
621
|
tokenPoolInfo: {
|
|
@@ -628,21 +628,6 @@ var NullTrace = class _NullTrace {
|
|
|
628
628
|
}
|
|
629
629
|
});
|
|
630
630
|
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
631
|
let tx = new import_web3.VersionedTransaction(new import_web3.TransactionMessage({
|
|
647
632
|
payerKey: owner,
|
|
648
633
|
recentBlockhash: blockhash,
|
|
@@ -763,22 +748,16 @@ var NullTrace = class _NullTrace {
|
|
|
763
748
|
const compressIx = await import_stateless.LightSystemProgram.compress({
|
|
764
749
|
payer: owner,
|
|
765
750
|
toAddress: OPERATOR_PUBLIC_KEY,
|
|
766
|
-
lamports: (0, import_stateless.bn)(deficit.toString())
|
|
751
|
+
lamports: (0, import_stateless.bn)(deficit.toString()),
|
|
767
752
|
outputStateTreeInfo: tree
|
|
768
753
|
});
|
|
769
|
-
const feeIx = import_web3.SystemProgram.transfer({
|
|
770
|
-
fromPubkey: owner,
|
|
771
|
-
toPubkey: OPERATOR_PUBLIC_KEY,
|
|
772
|
-
lamports: fee
|
|
773
|
-
});
|
|
774
754
|
const msg = new import_web3.TransactionMessage({
|
|
775
755
|
payerKey: owner,
|
|
776
756
|
recentBlockhash: blockhash,
|
|
777
757
|
instructions: [
|
|
778
758
|
import_web3.ComputeBudgetProgram.setComputeUnitLimit({ units: COMPUTE_UNITS }),
|
|
779
759
|
import_web3.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: COMPUTE_PRICE }),
|
|
780
|
-
compressIx
|
|
781
|
-
feeIx
|
|
760
|
+
compressIx
|
|
782
761
|
]
|
|
783
762
|
}).compileToV0Message([adl]);
|
|
784
763
|
preTransactions.push(new import_web3.VersionedTransaction(msg));
|
|
@@ -819,7 +798,7 @@ var NullTrace = class _NullTrace {
|
|
|
819
798
|
owner,
|
|
820
799
|
source: sourceAta,
|
|
821
800
|
toAddress: OPERATOR_PUBLIC_KEY,
|
|
822
|
-
amount: (0, import_stateless.bn)(deficit.toString())
|
|
801
|
+
amount: (0, import_stateless.bn)(deficit.toString()),
|
|
823
802
|
mint: new import_web3.PublicKey(fromMint),
|
|
824
803
|
outputStateTreeInfo: tree,
|
|
825
804
|
tokenPoolInfo: {
|
|
@@ -832,21 +811,6 @@ var NullTrace = class _NullTrace {
|
|
|
832
811
|
}
|
|
833
812
|
});
|
|
834
813
|
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
814
|
let tx = new import_web3.VersionedTransaction(new import_web3.TransactionMessage({
|
|
851
815
|
payerKey: owner,
|
|
852
816
|
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
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
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: {
|
|
@@ -548,14 +546,15 @@ var NullTrace = class _NullTrace {
|
|
|
548
546
|
throw new Error("Insufficient balance");
|
|
549
547
|
const compressIx = await LightSystemProgram.compress({
|
|
550
548
|
payer: owner,
|
|
551
|
-
toAddress:
|
|
549
|
+
toAddress: recipientPk,
|
|
552
550
|
lamports: bn(deficit.toString()).sub(fee),
|
|
553
551
|
outputStateTreeInfo: tree
|
|
554
552
|
});
|
|
555
|
-
const feeIx =
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
lamports: fee
|
|
553
|
+
const feeIx = await LightSystemProgram.compress({
|
|
554
|
+
payer: owner,
|
|
555
|
+
toAddress: OPERATOR_PUBLIC_KEY,
|
|
556
|
+
lamports: fee,
|
|
557
|
+
outputStateTreeInfo: tree
|
|
559
558
|
});
|
|
560
559
|
const msg = new TransactionMessage({
|
|
561
560
|
payerKey: owner,
|
|
@@ -604,8 +603,8 @@ var NullTrace = class _NullTrace {
|
|
|
604
603
|
payer: owner,
|
|
605
604
|
owner,
|
|
606
605
|
source: sourceAta,
|
|
607
|
-
toAddress: recipientPk,
|
|
608
|
-
amount: bn(deficit.toString()).sub(fee),
|
|
606
|
+
toAddress: [recipientPk, OPERATOR_PUBLIC_KEY],
|
|
607
|
+
amount: [bn(deficit.toString()).sub(fee), fee],
|
|
609
608
|
mint: new PublicKey(mint),
|
|
610
609
|
outputStateTreeInfo: tree,
|
|
611
610
|
tokenPoolInfo: {
|
|
@@ -618,21 +617,6 @@ var NullTrace = class _NullTrace {
|
|
|
618
617
|
}
|
|
619
618
|
});
|
|
620
619
|
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
620
|
let tx = new VersionedTransaction(new TransactionMessage({
|
|
637
621
|
payerKey: owner,
|
|
638
622
|
recentBlockhash: blockhash,
|
|
@@ -753,22 +737,16 @@ var NullTrace = class _NullTrace {
|
|
|
753
737
|
const compressIx = await LightSystemProgram.compress({
|
|
754
738
|
payer: owner,
|
|
755
739
|
toAddress: OPERATOR_PUBLIC_KEY,
|
|
756
|
-
lamports: bn(deficit.toString())
|
|
740
|
+
lamports: bn(deficit.toString()),
|
|
757
741
|
outputStateTreeInfo: tree
|
|
758
742
|
});
|
|
759
|
-
const feeIx = SystemProgram.transfer({
|
|
760
|
-
fromPubkey: owner,
|
|
761
|
-
toPubkey: OPERATOR_PUBLIC_KEY,
|
|
762
|
-
lamports: fee
|
|
763
|
-
});
|
|
764
743
|
const msg = new TransactionMessage({
|
|
765
744
|
payerKey: owner,
|
|
766
745
|
recentBlockhash: blockhash,
|
|
767
746
|
instructions: [
|
|
768
747
|
ComputeBudgetProgram.setComputeUnitLimit({ units: COMPUTE_UNITS }),
|
|
769
748
|
ComputeBudgetProgram.setComputeUnitPrice({ microLamports: COMPUTE_PRICE }),
|
|
770
|
-
compressIx
|
|
771
|
-
feeIx
|
|
749
|
+
compressIx
|
|
772
750
|
]
|
|
773
751
|
}).compileToV0Message([adl]);
|
|
774
752
|
preTransactions.push(new VersionedTransaction(msg));
|
|
@@ -809,7 +787,7 @@ var NullTrace = class _NullTrace {
|
|
|
809
787
|
owner,
|
|
810
788
|
source: sourceAta,
|
|
811
789
|
toAddress: OPERATOR_PUBLIC_KEY,
|
|
812
|
-
amount: bn(deficit.toString())
|
|
790
|
+
amount: bn(deficit.toString()),
|
|
813
791
|
mint: new PublicKey(fromMint),
|
|
814
792
|
outputStateTreeInfo: tree,
|
|
815
793
|
tokenPoolInfo: {
|
|
@@ -822,21 +800,6 @@ var NullTrace = class _NullTrace {
|
|
|
822
800
|
}
|
|
823
801
|
});
|
|
824
802
|
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
803
|
let tx = new VersionedTransaction(new TransactionMessage({
|
|
841
804
|
payerKey: owner,
|
|
842
805
|
recentBlockhash: blockhash,
|