@streamflow/distributor 8.0.1-alpha.p287.54fe41f → 8.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.
package/dist/esm/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import { PublicKey, TransactionInstruction, Connection, SystemProgram } from '@solana/web3.js';
2
2
  import '@solana/wallet-adapter-base';
3
3
  import { ICluster, ContractError, divCeilN, invariant, getNumberFromBN, getBN } from '@streamflow/common';
4
- import { signAndExecuteTransaction, buildSendThrottler, prepareBaseInstructions, getMintAndProgram, ata, prepareWrappedAccount, createAndEstimateTransaction, prepareTransaction, checkOrCreateAtaBatch, pk, unwrapExecutionParams } from '@streamflow/common/solana';
4
+ import { signAndExecuteTransaction, buildSendThrottler, prepareBaseInstructions, getMintAndProgram, ata, prepareWrappedAccount, prepareTransaction, checkOrCreateAtaBatch, pk } from '@streamflow/common/solana';
5
5
  import { Program } from '@coral-xyz/anchor';
6
- import * as borsh7 from '@coral-xyz/borsh';
6
+ import * as borsh8 from '@coral-xyz/borsh';
7
7
  import { Buffer as Buffer$1 } from 'buffer';
8
- import BN5 from 'bn.js';
8
+ import BN6 from 'bn.js';
9
9
  import { NATIVE_MINT, getTransferFeeConfig, ASSOCIATED_TOKEN_PROGRAM_ID, createTransferCheckedWithFeeInstruction, createTransferCheckedInstruction } from '@solana/spl-token';
10
10
  import bs58 from 'bs58';
11
11
 
@@ -19,6 +19,7 @@ var __export = (target, all) => {
19
19
  var solana_exports = {};
20
20
  __export(solana_exports, {
21
21
  AnchorErrorCode: () => AnchorErrorCode,
22
+ ClaimStatus: () => ClaimStatus,
22
23
  ContractErrorCode: () => ContractErrorCode,
23
24
  MerkleDistributor: () => MerkleDistributor,
24
25
  SolanaAlignedDistributorClient: () => SolanaAlignedDistributorClient,
@@ -126,21 +127,21 @@ var PROGRAM_ID_CLI = new PublicKey("MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N"
126
127
  var PROGRAM_ID = PROGRAM_ID_CLI;
127
128
 
128
129
  // solana/generated/instructions/newDistributor.ts
129
- var layout = borsh7.struct([
130
- borsh7.u64("version"),
131
- borsh7.array(borsh7.u8(), 32, "root"),
132
- borsh7.u64("maxTotalClaim"),
133
- borsh7.u64("maxNumNodes"),
134
- borsh7.u64("unlockPeriod"),
135
- borsh7.u64("startVestingTs"),
136
- borsh7.u64("endVestingTs"),
137
- borsh7.u64("clawbackStartTs"),
138
- borsh7.bool("claimsClosableByAdmin"),
139
- borsh7.option(borsh7.bool(), "canUpdateDuration"),
140
- borsh7.option(borsh7.u64(), "totalAmountUnlocked"),
141
- borsh7.option(borsh7.u64(), "totalAmountLocked"),
142
- borsh7.option(borsh7.bool(), "claimsClosableByClaimant"),
143
- borsh7.option(borsh7.u16(), "claimsLimit")
130
+ var layout = borsh8.struct([
131
+ borsh8.u64("version"),
132
+ borsh8.array(borsh8.u8(), 32, "root"),
133
+ borsh8.u64("maxTotalClaim"),
134
+ borsh8.u64("maxNumNodes"),
135
+ borsh8.u64("unlockPeriod"),
136
+ borsh8.u64("startVestingTs"),
137
+ borsh8.u64("endVestingTs"),
138
+ borsh8.u64("clawbackStartTs"),
139
+ borsh8.bool("claimsClosableByAdmin"),
140
+ borsh8.option(borsh8.bool(), "canUpdateDuration"),
141
+ borsh8.option(borsh8.u64(), "totalAmountUnlocked"),
142
+ borsh8.option(borsh8.u64(), "totalAmountLocked"),
143
+ borsh8.option(borsh8.bool(), "claimsClosableByClaimant"),
144
+ borsh8.option(borsh8.u16(), "claimsLimit")
144
145
  ]);
145
146
  function newDistributor(args, accounts, programId = PROGRAM_ID) {
146
147
  const keys = [
@@ -182,10 +183,10 @@ function newDistributor(args, accounts, programId = PROGRAM_ID) {
182
183
  const ix = new TransactionInstruction({ keys, programId, data });
183
184
  return ix;
184
185
  }
185
- var layout2 = borsh7.struct([
186
- borsh7.u64("amountUnlocked"),
187
- borsh7.u64("amountLocked"),
188
- borsh7.vec(borsh7.array(borsh7.u8(), 32), "proof")
186
+ var layout2 = borsh8.struct([
187
+ borsh8.u64("amountUnlocked"),
188
+ borsh8.u64("amountLocked"),
189
+ borsh8.vec(borsh8.array(borsh8.u8(), 32), "proof")
189
190
  ]);
190
191
  function newClaim(args, accounts, programId = PROGRAM_ID) {
191
192
  const keys = [
@@ -246,10 +247,10 @@ function clawback(accounts, programId = PROGRAM_ID) {
246
247
  const ix = new TransactionInstruction({ keys, programId, data });
247
248
  return ix;
248
249
  }
249
- var layout3 = borsh7.struct([
250
- borsh7.option(borsh7.u64(), "amountUnlocked"),
251
- borsh7.option(borsh7.u64(), "amountLocked"),
252
- borsh7.option(borsh7.vec(borsh7.array(borsh7.u8(), 32)), "proof")
250
+ var layout3 = borsh8.struct([
251
+ borsh8.option(borsh8.u64(), "amountUnlocked"),
252
+ borsh8.option(borsh8.u64(), "amountLocked"),
253
+ borsh8.option(borsh8.vec(borsh8.array(borsh8.u8(), 32)), "proof")
253
254
  ]);
254
255
  function closeClaim(args, accounts, programId = PROGRAM_ID) {
255
256
  const keys = [
@@ -298,1316 +299,6 @@ function setAdmin(accounts, programId = PROGRAM_ID) {
298
299
  return ix;
299
300
  }
300
301
 
301
- // solana/descriptor/idl/merkle_distributor.json
302
- var merkle_distributor_default = {
303
- address: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N",
304
- metadata: {
305
- name: "merkle_distributor",
306
- version: "1.5.0",
307
- spec: "0.1.0",
308
- description: "A Solana program for distributing tokens according to a Merkle root.",
309
- repository: "https://github.com/streamflow-finance/distributor"
310
- },
311
- instructions: [
312
- {
313
- name: "_expose_claim",
314
- discriminator: [103, 233, 83, 69, 115, 199, 128, 249],
315
- accounts: [
316
- {
317
- name: "distributor",
318
- docs: ["The [MerkleDistributor]."]
319
- },
320
- {
321
- name: "claim_status",
322
- docs: ["Claim Status PDA"],
323
- optional: true,
324
- pda: {
325
- seeds: [
326
- {
327
- kind: "const",
328
- value: [67, 108, 97, 105, 109, 83, 116, 97, 116, 117, 115]
329
- },
330
- {
331
- kind: "account",
332
- path: "claimant"
333
- },
334
- {
335
- kind: "account",
336
- path: "distributor"
337
- }
338
- ]
339
- }
340
- },
341
- {
342
- name: "compressed_claim_status",
343
- docs: ["Compress Claim Status PDA"],
344
- optional: true,
345
- pda: {
346
- seeds: [
347
- {
348
- kind: "const",
349
- value: [67, 108, 97, 105, 109, 83, 116, 97, 116, 117, 115]
350
- },
351
- {
352
- kind: "account",
353
- path: "claimant"
354
- },
355
- {
356
- kind: "account",
357
- path: "distributor"
358
- }
359
- ]
360
- }
361
- },
362
- {
363
- name: "claimant",
364
- docs: ["Who is claiming the tokens."],
365
- signer: true
366
- }
367
- ],
368
- args: []
369
- },
370
- {
371
- name: "claim_locked",
372
- discriminator: [34, 206, 181, 23, 11, 207, 147, 90],
373
- accounts: [
374
- {
375
- name: "distributor",
376
- docs: ["The [MerkleDistributor]."],
377
- writable: true
378
- },
379
- {
380
- name: "claim_status",
381
- writable: true,
382
- pda: {
383
- seeds: [
384
- {
385
- kind: "const",
386
- value: [67, 108, 97, 105, 109, 83, 116, 97, 116, 117, 115]
387
- },
388
- {
389
- kind: "account",
390
- path: "claimant"
391
- },
392
- {
393
- kind: "account",
394
- path: "distributor"
395
- }
396
- ]
397
- }
398
- },
399
- {
400
- name: "from",
401
- docs: ["Distributor ATA containing the tokens to distribute."],
402
- writable: true,
403
- pda: {
404
- seeds: [
405
- {
406
- kind: "account",
407
- path: "distributor"
408
- },
409
- {
410
- kind: "account",
411
- path: "token_program"
412
- },
413
- {
414
- kind: "account",
415
- path: "distributor.mint",
416
- account: "MerkleDistributor"
417
- }
418
- ],
419
- program: {
420
- kind: "const",
421
- value: [
422
- 140,
423
- 151,
424
- 37,
425
- 143,
426
- 78,
427
- 36,
428
- 137,
429
- 241,
430
- 187,
431
- 61,
432
- 16,
433
- 41,
434
- 20,
435
- 142,
436
- 13,
437
- 131,
438
- 11,
439
- 90,
440
- 19,
441
- 153,
442
- 218,
443
- 255,
444
- 16,
445
- 132,
446
- 4,
447
- 142,
448
- 123,
449
- 216,
450
- 219,
451
- 233,
452
- 248,
453
- 89
454
- ]
455
- }
456
- }
457
- },
458
- {
459
- name: "to",
460
- docs: [
461
- "Account to send the claimed tokens to.",
462
- "Claimant must sign the transaction and can only claim on behalf of themself"
463
- ],
464
- writable: true
465
- },
466
- {
467
- name: "claimant",
468
- docs: ["Who is claiming the tokens."],
469
- writable: true,
470
- signer: true
471
- },
472
- {
473
- name: "mint",
474
- docs: ["The mint to claim."],
475
- relations: ["distributor"]
476
- },
477
- {
478
- name: "token_program",
479
- docs: ["SPL [Token] program."]
480
- },
481
- {
482
- name: "event_authority",
483
- pda: {
484
- seeds: [
485
- {
486
- kind: "const",
487
- value: [95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121]
488
- }
489
- ]
490
- }
491
- },
492
- {
493
- name: "program"
494
- }
495
- ],
496
- args: []
497
- },
498
- {
499
- name: "clawback",
500
- discriminator: [111, 92, 142, 79, 33, 234, 82, 27],
501
- accounts: [
502
- {
503
- name: "distributor",
504
- docs: ["The [MerkleDistributor]."],
505
- writable: true
506
- },
507
- {
508
- name: "from",
509
- docs: ["Distributor ATA containing the tokens to distribute."],
510
- writable: true
511
- },
512
- {
513
- name: "to",
514
- docs: ["The Clawback token account."],
515
- writable: true
516
- },
517
- {
518
- name: "admin",
519
- docs: ["Only Admin can trigger the clawback of funds"],
520
- writable: true,
521
- signer: true
522
- },
523
- {
524
- name: "mint"
525
- },
526
- {
527
- name: "system_program",
528
- docs: ["The [System] program."],
529
- address: "11111111111111111111111111111111"
530
- },
531
- {
532
- name: "token_program",
533
- docs: ["SPL [Token] program."]
534
- }
535
- ],
536
- args: []
537
- },
538
- {
539
- name: "close_claim",
540
- discriminator: [42, 177, 165, 35, 213, 179, 211, 19],
541
- accounts: [
542
- {
543
- name: "distributor",
544
- docs: ["The [MerkleDistributor]."],
545
- writable: true
546
- },
547
- {
548
- name: "admin_or_claimant",
549
- docs: ["Admin signer"],
550
- writable: true,
551
- signer: true
552
- },
553
- {
554
- name: "claimant",
555
- writable: true
556
- },
557
- {
558
- name: "claim_status",
559
- writable: true,
560
- pda: {
561
- seeds: [
562
- {
563
- kind: "const",
564
- value: [67, 108, 97, 105, 109, 83, 116, 97, 116, 117, 115]
565
- },
566
- {
567
- kind: "account",
568
- path: "claimant"
569
- },
570
- {
571
- kind: "account",
572
- path: "distributor"
573
- }
574
- ]
575
- }
576
- },
577
- {
578
- name: "system_program",
579
- docs: ["The [System] program."],
580
- address: "11111111111111111111111111111111"
581
- },
582
- {
583
- name: "event_authority",
584
- pda: {
585
- seeds: [
586
- {
587
- kind: "const",
588
- value: [95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121]
589
- }
590
- ]
591
- }
592
- },
593
- {
594
- name: "program"
595
- }
596
- ],
597
- args: [
598
- {
599
- name: "amount_unlocked",
600
- type: {
601
- option: "u64"
602
- }
603
- },
604
- {
605
- name: "amount_locked",
606
- type: {
607
- option: "u64"
608
- }
609
- },
610
- {
611
- name: "proof",
612
- type: {
613
- option: {
614
- vec: {
615
- array: ["u8", 32]
616
- }
617
- }
618
- }
619
- }
620
- ]
621
- },
622
- {
623
- name: "compress_claim",
624
- discriminator: [219, 45, 247, 134, 71, 119, 125, 89],
625
- accounts: [
626
- {
627
- name: "distributor",
628
- docs: ["The [MerkleDistributor]."],
629
- writable: true
630
- },
631
- {
632
- name: "claim_status",
633
- writable: true,
634
- pda: {
635
- seeds: [
636
- {
637
- kind: "const",
638
- value: [67, 108, 97, 105, 109, 83, 116, 97, 116, 117, 115]
639
- },
640
- {
641
- kind: "account",
642
- path: "claimant"
643
- },
644
- {
645
- kind: "account",
646
- path: "distributor"
647
- }
648
- ]
649
- }
650
- },
651
- {
652
- name: "signer",
653
- docs: ["Signer account"],
654
- writable: true,
655
- signer: true
656
- },
657
- {
658
- name: "claimant"
659
- },
660
- {
661
- name: "system_program",
662
- docs: ["The [System] program."],
663
- address: "11111111111111111111111111111111"
664
- }
665
- ],
666
- args: []
667
- },
668
- {
669
- name: "new_claim",
670
- discriminator: [78, 177, 98, 123, 210, 21, 187, 83],
671
- accounts: [
672
- {
673
- name: "distributor",
674
- docs: ["The [MerkleDistributor]."],
675
- writable: true
676
- },
677
- {
678
- name: "claim_status",
679
- writable: true,
680
- pda: {
681
- seeds: [
682
- {
683
- kind: "const",
684
- value: [67, 108, 97, 105, 109, 83, 116, 97, 116, 117, 115]
685
- },
686
- {
687
- kind: "account",
688
- path: "claimant"
689
- },
690
- {
691
- kind: "account",
692
- path: "distributor"
693
- }
694
- ]
695
- }
696
- },
697
- {
698
- name: "from",
699
- docs: ["Distributor ATA containing the tokens to distribute."],
700
- writable: true,
701
- pda: {
702
- seeds: [
703
- {
704
- kind: "account",
705
- path: "distributor"
706
- },
707
- {
708
- kind: "account",
709
- path: "token_program"
710
- },
711
- {
712
- kind: "account",
713
- path: "distributor.mint",
714
- account: "MerkleDistributor"
715
- }
716
- ],
717
- program: {
718
- kind: "const",
719
- value: [
720
- 140,
721
- 151,
722
- 37,
723
- 143,
724
- 78,
725
- 36,
726
- 137,
727
- 241,
728
- 187,
729
- 61,
730
- 16,
731
- 41,
732
- 20,
733
- 142,
734
- 13,
735
- 131,
736
- 11,
737
- 90,
738
- 19,
739
- 153,
740
- 218,
741
- 255,
742
- 16,
743
- 132,
744
- 4,
745
- 142,
746
- 123,
747
- 216,
748
- 219,
749
- 233,
750
- 248,
751
- 89
752
- ]
753
- }
754
- }
755
- },
756
- {
757
- name: "to",
758
- docs: ["Account to send the claimed tokens to."],
759
- writable: true
760
- },
761
- {
762
- name: "claimant",
763
- docs: ["Who is claiming the tokens."],
764
- writable: true,
765
- signer: true
766
- },
767
- {
768
- name: "mint",
769
- docs: ["The mint to claim."],
770
- relations: ["distributor"]
771
- },
772
- {
773
- name: "token_program",
774
- docs: ["SPL [Token] program."]
775
- },
776
- {
777
- name: "system_program",
778
- docs: ["The [System] program."],
779
- address: "11111111111111111111111111111111"
780
- },
781
- {
782
- name: "event_authority",
783
- pda: {
784
- seeds: [
785
- {
786
- kind: "const",
787
- value: [95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121]
788
- }
789
- ]
790
- }
791
- },
792
- {
793
- name: "program"
794
- }
795
- ],
796
- args: [
797
- {
798
- name: "amount_unlocked",
799
- type: "u64"
800
- },
801
- {
802
- name: "amount_locked",
803
- type: "u64"
804
- },
805
- {
806
- name: "proof",
807
- type: {
808
- vec: {
809
- array: ["u8", 32]
810
- }
811
- }
812
- }
813
- ]
814
- },
815
- {
816
- name: "new_distributor",
817
- docs: [
818
- "READ THE FOLLOWING:",
819
- "",
820
- "This instruction is susceptible to frontrunning that could result in loss of funds if not handled properly.",
821
- "",
822
- "An attack could look like:",
823
- "- A legitimate user opens a new distributor.",
824
- "- Someone observes the call to this instruction.",
825
- "- They replace the clawback_receiver, admin, or time parameters with their own.",
826
- "",
827
- "One situation that could happen here is the attacker replaces the admin and clawback_receiver with their own",
828
- "and sets the clawback_start_ts with the minimal time allowed. After clawback_start_ts has elapsed,",
829
- "the attacker can steal all funds from the distributor to their own clawback_receiver account.",
830
- "",
831
- "HOW TO AVOID:",
832
- "- When you call into this instruction, ensure your transaction succeeds.",
833
- "- To be extra safe, after your transaction succeeds, read back the state of the created MerkleDistributor account and",
834
- "assert the parameters are what you expect, most importantly the clawback_receiver and admin.",
835
- "- If your transaction fails, double check the value on-chain matches what you expect."
836
- ],
837
- discriminator: [32, 139, 112, 171, 0, 2, 225, 155],
838
- accounts: [
839
- {
840
- name: "distributor",
841
- docs: ["[MerkleDistributor]."],
842
- writable: true,
843
- pda: {
844
- seeds: [
845
- {
846
- kind: "const",
847
- value: [77, 101, 114, 107, 108, 101, 68, 105, 115, 116, 114, 105, 98, 117, 116, 111, 114]
848
- },
849
- {
850
- kind: "account",
851
- path: "mint"
852
- },
853
- {
854
- kind: "arg",
855
- path: "version"
856
- }
857
- ]
858
- }
859
- },
860
- {
861
- name: "clawback_receiver",
862
- docs: ["Clawback receiver token account"],
863
- writable: true
864
- },
865
- {
866
- name: "mint",
867
- docs: ["The mint to distribute."]
868
- },
869
- {
870
- name: "token_vault",
871
- docs: ["Token vault"],
872
- writable: true,
873
- pda: {
874
- seeds: [
875
- {
876
- kind: "account",
877
- path: "distributor"
878
- },
879
- {
880
- kind: "account",
881
- path: "token_program"
882
- },
883
- {
884
- kind: "account",
885
- path: "mint"
886
- }
887
- ],
888
- program: {
889
- kind: "const",
890
- value: [
891
- 140,
892
- 151,
893
- 37,
894
- 143,
895
- 78,
896
- 36,
897
- 137,
898
- 241,
899
- 187,
900
- 61,
901
- 16,
902
- 41,
903
- 20,
904
- 142,
905
- 13,
906
- 131,
907
- 11,
908
- 90,
909
- 19,
910
- 153,
911
- 218,
912
- 255,
913
- 16,
914
- 132,
915
- 4,
916
- 142,
917
- 123,
918
- 216,
919
- 219,
920
- 233,
921
- 248,
922
- 89
923
- ]
924
- }
925
- }
926
- },
927
- {
928
- name: "admin",
929
- docs: [
930
- "Admin wallet, responsible for creating the distributor and paying for the transaction.",
931
- "Also has the authority to set the clawback receiver and change itself."
932
- ],
933
- writable: true,
934
- signer: true
935
- },
936
- {
937
- name: "system_program",
938
- docs: ["The [System] program."],
939
- address: "11111111111111111111111111111111"
940
- },
941
- {
942
- name: "associated_token_program",
943
- docs: ["The [Associated Token] program."],
944
- address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
945
- },
946
- {
947
- name: "token_program",
948
- docs: ["The [Token] program."]
949
- }
950
- ],
951
- args: [
952
- {
953
- name: "version",
954
- type: "u64"
955
- },
956
- {
957
- name: "root",
958
- type: {
959
- array: ["u8", 32]
960
- }
961
- },
962
- {
963
- name: "max_total_claim",
964
- type: "u64"
965
- },
966
- {
967
- name: "max_num_nodes",
968
- type: "u64"
969
- },
970
- {
971
- name: "unlock_period",
972
- type: "u64"
973
- },
974
- {
975
- name: "start_vesting_ts",
976
- type: "u64"
977
- },
978
- {
979
- name: "end_vesting_ts",
980
- type: "u64"
981
- },
982
- {
983
- name: "clawback_start_ts",
984
- type: "u64"
985
- },
986
- {
987
- name: "claims_closable_by_admin",
988
- type: "bool"
989
- },
990
- {
991
- name: "can_update_duration",
992
- type: {
993
- option: "bool"
994
- }
995
- },
996
- {
997
- name: "total_amount_unlocked",
998
- type: {
999
- option: "u64"
1000
- }
1001
- },
1002
- {
1003
- name: "total_amount_locked",
1004
- type: {
1005
- option: "u64"
1006
- }
1007
- },
1008
- {
1009
- name: "claims_closable_by_claimant",
1010
- type: {
1011
- option: "bool"
1012
- }
1013
- },
1014
- {
1015
- name: "claims_limit",
1016
- type: {
1017
- option: "u16"
1018
- }
1019
- }
1020
- ]
1021
- },
1022
- {
1023
- name: "refund_claim",
1024
- discriminator: [157, 23, 164, 146, 176, 53, 147, 143],
1025
- accounts: [
1026
- {
1027
- name: "distributor",
1028
- docs: ["The [MerkleDistributor]."],
1029
- writable: true
1030
- },
1031
- {
1032
- name: "claim_status",
1033
- writable: true,
1034
- pda: {
1035
- seeds: [
1036
- {
1037
- kind: "const",
1038
- value: [67, 108, 97, 105, 109, 83, 116, 97, 116, 117, 115]
1039
- },
1040
- {
1041
- kind: "account",
1042
- path: "claimant"
1043
- },
1044
- {
1045
- kind: "account",
1046
- path: "distributor"
1047
- }
1048
- ]
1049
- }
1050
- },
1051
- {
1052
- name: "signer",
1053
- docs: ["Signer account"],
1054
- writable: true,
1055
- signer: true
1056
- },
1057
- {
1058
- name: "claimant"
1059
- },
1060
- {
1061
- name: "streamflow_treasury",
1062
- writable: true,
1063
- address: "5SEpbdjFK5FxwTvfsGMXVQTD2v4M2c5tyRTxhdsPkgDw"
1064
- },
1065
- {
1066
- name: "system_program",
1067
- docs: ["The [System] program."],
1068
- address: "11111111111111111111111111111111"
1069
- }
1070
- ],
1071
- args: []
1072
- },
1073
- {
1074
- name: "set_admin",
1075
- discriminator: [251, 163, 0, 52, 91, 194, 187, 92],
1076
- accounts: [
1077
- {
1078
- name: "distributor",
1079
- docs: ["The [MerkleDistributor]."],
1080
- writable: true
1081
- },
1082
- {
1083
- name: "admin",
1084
- docs: ["Admin signer"],
1085
- writable: true,
1086
- signer: true
1087
- },
1088
- {
1089
- name: "new_admin",
1090
- docs: ["New admin account"],
1091
- writable: true
1092
- }
1093
- ],
1094
- args: []
1095
- },
1096
- {
1097
- name: "set_clawback_receiver",
1098
- discriminator: [153, 217, 34, 20, 19, 29, 229, 75],
1099
- accounts: [
1100
- {
1101
- name: "distributor",
1102
- docs: ["The [MerkleDistributor]."],
1103
- writable: true
1104
- },
1105
- {
1106
- name: "new_clawback_account",
1107
- docs: ["New clawback account"]
1108
- },
1109
- {
1110
- name: "admin",
1111
- docs: ["Admin signer"],
1112
- writable: true,
1113
- signer: true
1114
- }
1115
- ],
1116
- args: []
1117
- },
1118
- {
1119
- name: "update",
1120
- discriminator: [219, 200, 88, 176, 158, 63, 253, 127],
1121
- accounts: [
1122
- {
1123
- name: "distributor",
1124
- docs: ["The [MerkleDistributor]."],
1125
- writable: true
1126
- },
1127
- {
1128
- name: "admin",
1129
- docs: ["Only Admin can trigger the clawback of funds"],
1130
- writable: true,
1131
- signer: true
1132
- },
1133
- {
1134
- name: "system_program",
1135
- docs: ["The [System] program."],
1136
- address: "11111111111111111111111111111111"
1137
- }
1138
- ],
1139
- args: [
1140
- {
1141
- name: "end_ts",
1142
- type: {
1143
- option: "u64"
1144
- }
1145
- }
1146
- ]
1147
- }
1148
- ],
1149
- accounts: [
1150
- {
1151
- name: "ClaimStatus",
1152
- discriminator: [22, 183, 249, 157, 247, 95, 150, 96]
1153
- },
1154
- {
1155
- name: "CompressedClaimStatus",
1156
- discriminator: [53, 68, 161, 131, 212, 106, 98, 48]
1157
- },
1158
- {
1159
- name: "MerkleDistributor",
1160
- discriminator: [77, 119, 139, 70, 84, 247, 12, 26]
1161
- }
1162
- ],
1163
- events: [
1164
- {
1165
- name: "ClaimClosedEvent",
1166
- discriminator: [139, 166, 215, 195, 184, 233, 26, 217]
1167
- },
1168
- {
1169
- name: "ClaimedEvent",
1170
- discriminator: [144, 172, 209, 86, 144, 87, 84, 115]
1171
- },
1172
- {
1173
- name: "NewClaimEvent",
1174
- discriminator: [244, 3, 231, 151, 60, 101, 55, 55]
1175
- }
1176
- ],
1177
- errors: [
1178
- {
1179
- code: 6e3,
1180
- name: "InsufficientUnlockedTokens",
1181
- msg: "Insufficient unlocked tokens"
1182
- },
1183
- {
1184
- code: 6001,
1185
- name: "InvalidProof",
1186
- msg: "Invalid Merkle proof"
1187
- },
1188
- {
1189
- code: 6002,
1190
- name: "ExceededMaxClaim",
1191
- msg: "Exceeded maximum claim amount"
1192
- },
1193
- {
1194
- code: 6003,
1195
- name: "MaxNodesExceeded",
1196
- msg: "Exceeded maximum node count"
1197
- },
1198
- {
1199
- code: 6004,
1200
- name: "Unauthorized",
1201
- msg: "Account is not authorized to execute this instruction"
1202
- },
1203
- {
1204
- code: 6005,
1205
- name: "OwnerMismatch",
1206
- msg: "Token account owner did not match intended owner"
1207
- },
1208
- {
1209
- code: 6006,
1210
- name: "ClawbackBeforeStart",
1211
- msg: "Attempted clawback before start"
1212
- },
1213
- {
1214
- code: 6007,
1215
- name: "ClawbackAlreadyClaimed",
1216
- msg: "Clawback already claimed"
1217
- },
1218
- {
1219
- code: 6008,
1220
- name: "SameClawbackReceiver",
1221
- msg: "New and old Clawback receivers are identical"
1222
- },
1223
- {
1224
- code: 6009,
1225
- name: "ClawbackReceiverIsTokenVault",
1226
- msg: "Clawback receiver can not be the Token Vault"
1227
- },
1228
- {
1229
- code: 6010,
1230
- name: "SameAdmin",
1231
- msg: "New and old admin are identical"
1232
- },
1233
- {
1234
- code: 6011,
1235
- name: "ClaimExpired",
1236
- msg: "Claim window expired"
1237
- },
1238
- {
1239
- code: 6012,
1240
- name: "ArithmeticError",
1241
- msg: "Arithmetic Error (overflow/underflow)"
1242
- },
1243
- {
1244
- code: 6013,
1245
- name: "StartTimestampAfterEnd",
1246
- msg: "Start Timestamp cannot be after end Timestamp"
1247
- },
1248
- {
1249
- code: 6014,
1250
- name: "TimestampsNotInFuture",
1251
- msg: "Timestamps cannot be in the past"
1252
- },
1253
- {
1254
- code: 6015,
1255
- name: "InvalidMint",
1256
- msg: "Invalid Mint"
1257
- },
1258
- {
1259
- code: 6016,
1260
- name: "ClaimIsClosed",
1261
- msg: "Claim is closed"
1262
- },
1263
- {
1264
- code: 6017,
1265
- name: "ClaimsAreNotClosable",
1266
- msg: "Claims are not closable"
1267
- },
1268
- {
1269
- code: 6018,
1270
- name: "InvalidUnlockPeriod",
1271
- msg: "Invalid unlock period"
1272
- },
1273
- {
1274
- code: 6019,
1275
- name: "DurationUpdateNotAllowed",
1276
- msg: "Duration update is not allowed"
1277
- },
1278
- {
1279
- code: 6020,
1280
- name: "NoVestingAmount",
1281
- msg: "Vesting amounts are not set"
1282
- },
1283
- {
1284
- code: 6021,
1285
- name: "VestingAlreadyFinished",
1286
- msg: "Vesting already finished"
1287
- },
1288
- {
1289
- code: 6022,
1290
- name: "InvalidAmounts",
1291
- msg: "Provided amounts are invalid"
1292
- },
1293
- {
1294
- code: 6023,
1295
- name: "ClaimsLimitReached",
1296
- msg: "Claims limit has been reached"
1297
- }
1298
- ],
1299
- types: [
1300
- {
1301
- name: "ClaimClosedEvent",
1302
- docs: ["Emitted when a new claim is created."],
1303
- type: {
1304
- kind: "struct",
1305
- fields: [
1306
- {
1307
- name: "claimant",
1308
- docs: ["User that claimed."],
1309
- type: "pubkey"
1310
- },
1311
- {
1312
- name: "timestamp",
1313
- docs: ["Timestamp."],
1314
- type: "u64"
1315
- }
1316
- ]
1317
- }
1318
- },
1319
- {
1320
- name: "ClaimStatus",
1321
- docs: ["Holds whether or not a claimant has claimed tokens."],
1322
- type: {
1323
- kind: "struct",
1324
- fields: [
1325
- {
1326
- name: "claimant",
1327
- docs: ["Authority that claimed the tokens."],
1328
- type: "pubkey"
1329
- },
1330
- {
1331
- name: "locked_amount",
1332
- docs: ["Locked amount"],
1333
- type: "u64"
1334
- },
1335
- {
1336
- name: "locked_amount_withdrawn",
1337
- docs: ["Locked amount withdrawn"],
1338
- type: "u64"
1339
- },
1340
- {
1341
- name: "unlocked_amount",
1342
- docs: ["Unlocked amount"],
1343
- type: "u64"
1344
- },
1345
- {
1346
- name: "last_claim_ts",
1347
- docs: ["Last claim time"],
1348
- type: "u64"
1349
- },
1350
- {
1351
- name: "last_amount_per_unlock",
1352
- docs: ["Track amount per unlock, can be useful for non-linear vesting"],
1353
- type: "u64"
1354
- },
1355
- {
1356
- name: "closed",
1357
- docs: ["Whether claim is closed"],
1358
- type: "bool"
1359
- },
1360
- {
1361
- name: "distributor",
1362
- docs: [
1363
- "Distributor account for which ClaimStatus was created, useful to filter by in get_program_accounts"
1364
- ],
1365
- type: "pubkey"
1366
- },
1367
- {
1368
- name: "claims_count",
1369
- docs: ["Number of time amount has been claimed"],
1370
- type: "u16"
1371
- },
1372
- {
1373
- name: "closed_ts",
1374
- docs: ["Time when claim has been closed"],
1375
- type: "u64"
1376
- },
1377
- {
1378
- name: "buffer_2",
1379
- docs: ["Buffer for additional fields"],
1380
- type: {
1381
- array: ["u8", 22]
1382
- }
1383
- }
1384
- ]
1385
- }
1386
- },
1387
- {
1388
- name: "ClaimedEvent",
1389
- docs: ["Emitted when tokens are claimed."],
1390
- type: {
1391
- kind: "struct",
1392
- fields: [
1393
- {
1394
- name: "claimant",
1395
- docs: ["User that claimed."],
1396
- type: "pubkey"
1397
- },
1398
- {
1399
- name: "amount",
1400
- docs: ["Amount of tokens to distribute."],
1401
- type: "u64"
1402
- }
1403
- ]
1404
- }
1405
- },
1406
- {
1407
- name: "CompressedClaimStatus",
1408
- docs: ["Holds whether or not a claimant has claimed tokens."],
1409
- type: {
1410
- kind: "struct",
1411
- fields: [
1412
- {
1413
- name: "state",
1414
- type: {
1415
- defined: {
1416
- name: "State"
1417
- }
1418
- }
1419
- }
1420
- ]
1421
- }
1422
- },
1423
- {
1424
- name: "MerkleDistributor",
1425
- docs: ["State for the account which distributes tokens."],
1426
- type: {
1427
- kind: "struct",
1428
- fields: [
1429
- {
1430
- name: "bump",
1431
- docs: ["Bump seed."],
1432
- type: "u8"
1433
- },
1434
- {
1435
- name: "version",
1436
- docs: ["Version of the airdrop"],
1437
- type: "u64"
1438
- },
1439
- {
1440
- name: "root",
1441
- docs: ["The 256-bit merkle root."],
1442
- type: {
1443
- array: ["u8", 32]
1444
- }
1445
- },
1446
- {
1447
- name: "mint",
1448
- docs: ["[Mint] of the token to be distributed."],
1449
- type: "pubkey"
1450
- },
1451
- {
1452
- name: "token_vault",
1453
- docs: ["Token Address of the vault"],
1454
- type: "pubkey"
1455
- },
1456
- {
1457
- name: "max_total_claim",
1458
- docs: ["Maximum number of tokens that can ever be claimed from this [MerkleDistributor]."],
1459
- type: "u64"
1460
- },
1461
- {
1462
- name: "max_num_nodes",
1463
- docs: ["Maximum number of nodes in [MerkleDistributor]."],
1464
- type: "u64"
1465
- },
1466
- {
1467
- name: "unlock_period",
1468
- docs: ["Time step (period) in seconds per which the unlock occurs"],
1469
- type: "u64"
1470
- },
1471
- {
1472
- name: "total_amount_claimed",
1473
- docs: ["Total amount of tokens that have been claimed."],
1474
- type: "u64"
1475
- },
1476
- {
1477
- name: "num_nodes_claimed",
1478
- docs: ["Number of nodes that have been claimed."],
1479
- type: "u64"
1480
- },
1481
- {
1482
- name: "start_ts",
1483
- docs: ["Lockup time start (Unix Timestamp)"],
1484
- type: "u64"
1485
- },
1486
- {
1487
- name: "end_ts",
1488
- docs: ["Lockup time end (Unix Timestamp)"],
1489
- type: "u64"
1490
- },
1491
- {
1492
- name: "clawback_start_ts",
1493
- docs: ["Clawback start (Unix Timestamp)"],
1494
- type: "u64"
1495
- },
1496
- {
1497
- name: "clawback_receiver",
1498
- docs: ["Clawback receiver"],
1499
- type: "pubkey"
1500
- },
1501
- {
1502
- name: "admin",
1503
- docs: ["Admin wallet"],
1504
- type: "pubkey"
1505
- },
1506
- {
1507
- name: "clawed_back",
1508
- docs: ["Whether or not the distributor has been clawed back"],
1509
- type: "bool"
1510
- },
1511
- {
1512
- name: "claims_closable_by_admin",
1513
- docs: ["Whether claims are closable by the admin or not"],
1514
- type: "bool"
1515
- },
1516
- {
1517
- name: "can_update_duration",
1518
- docs: ["Whether admin can update vesting duration"],
1519
- type: "bool"
1520
- },
1521
- {
1522
- name: "total_amount_unlocked",
1523
- docs: ["Total amount of funds unlocked (cliff/instant)"],
1524
- type: "u64"
1525
- },
1526
- {
1527
- name: "total_amount_locked",
1528
- docs: ["Total amount of funds locked (vested)"],
1529
- type: "u64"
1530
- },
1531
- {
1532
- name: "last_duration_update_ts",
1533
- docs: ["Timestamp when update was last called"],
1534
- type: "u64"
1535
- },
1536
- {
1537
- name: "total_claimable_pre_update",
1538
- docs: [
1539
- "Total amount of locked amount claimable as of last duration update, ever increasing total, accumulates with each update"
1540
- ],
1541
- type: "u64"
1542
- },
1543
- {
1544
- name: "clawed_back_ts",
1545
- docs: ["Timestamp when funds were clawed back"],
1546
- type: "u64"
1547
- },
1548
- {
1549
- name: "claims_closable_by_claimant",
1550
- docs: ["Whether claims are closable by claimant or not"],
1551
- type: "bool"
1552
- },
1553
- {
1554
- name: "claims_limit",
1555
- docs: ["Limit number of claims"],
1556
- type: "u16"
1557
- },
1558
- {
1559
- name: "buffer_2",
1560
- docs: ["Buffer for additional fields"],
1561
- type: {
1562
- array: ["u8", 20]
1563
- }
1564
- },
1565
- {
1566
- name: "buffer_3",
1567
- docs: ["Buffer for additional fields"],
1568
- type: {
1569
- array: ["u8", 32]
1570
- }
1571
- }
1572
- ]
1573
- }
1574
- },
1575
- {
1576
- name: "NewClaimEvent",
1577
- docs: ["Emitted when a new claim is created."],
1578
- type: {
1579
- kind: "struct",
1580
- fields: [
1581
- {
1582
- name: "claimant",
1583
- docs: ["User that claimed."],
1584
- type: "pubkey"
1585
- },
1586
- {
1587
- name: "timestamp",
1588
- docs: ["Timestamp."],
1589
- type: "u64"
1590
- }
1591
- ]
1592
- }
1593
- },
1594
- {
1595
- name: "State",
1596
- type: {
1597
- kind: "enum",
1598
- variants: [
1599
- {
1600
- name: "Claimed"
1601
- },
1602
- {
1603
- name: "Closed"
1604
- }
1605
- ]
1606
- }
1607
- }
1608
- ]
1609
- };
1610
-
1611
302
  // solana/constants.ts
1612
303
  var constants_exports = {};
1613
304
  __export(constants_exports, {
@@ -1648,6 +339,107 @@ var DISTRIBUTOR_PROGRAM_ID = {
1648
339
  [ICluster.Testnet]: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N",
1649
340
  [ICluster.Local]: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N"
1650
341
  };
342
+ var _ClaimStatus = class _ClaimStatus {
343
+ constructor(fields) {
344
+ this.claimant = fields.claimant;
345
+ this.lockedAmount = fields.lockedAmount;
346
+ this.lockedAmountWithdrawn = fields.lockedAmountWithdrawn;
347
+ this.unlockedAmount = fields.unlockedAmount;
348
+ this.lastClaimTs = fields.lastClaimTs;
349
+ this.lastAmountPerUnlock = fields.lastAmountPerUnlock;
350
+ this.closed = fields.closed;
351
+ this.distributor = fields.distributor;
352
+ this.claimsCount = fields.claimsCount;
353
+ this.closedTs = fields.closedTs;
354
+ this.buffer2 = fields.buffer2;
355
+ }
356
+ static async fetch(c, address, programId = PROGRAM_ID) {
357
+ const info = await c.getAccountInfo(address);
358
+ if (info === null) {
359
+ return null;
360
+ }
361
+ if (!info.owner.equals(programId)) {
362
+ throw new Error("account doesn't belong to this program");
363
+ }
364
+ return this.decode(info.data);
365
+ }
366
+ static async fetchMultiple(c, addresses, programId = PROGRAM_ID) {
367
+ const infos = await c.getMultipleAccountsInfo(addresses);
368
+ return infos.map((info) => {
369
+ if (info === null) {
370
+ return null;
371
+ }
372
+ if (!info.owner.equals(programId)) {
373
+ throw new Error("account doesn't belong to this program");
374
+ }
375
+ return this.decode(info.data);
376
+ });
377
+ }
378
+ static decode(data) {
379
+ if (!data.slice(0, 8).equals(_ClaimStatus.discriminator)) {
380
+ throw new Error("invalid account discriminator");
381
+ }
382
+ const dec = _ClaimStatus.layout.decode(data.slice(8));
383
+ return new _ClaimStatus({
384
+ claimant: dec.claimant,
385
+ lockedAmount: dec.lockedAmount,
386
+ lockedAmountWithdrawn: dec.lockedAmountWithdrawn,
387
+ unlockedAmount: dec.unlockedAmount,
388
+ lastClaimTs: dec.lastClaimTs,
389
+ lastAmountPerUnlock: dec.lastAmountPerUnlock,
390
+ closed: dec.closed,
391
+ distributor: dec.distributor,
392
+ claimsCount: dec.claimsCount,
393
+ closedTs: dec.closedTs,
394
+ buffer2: dec.buffer2
395
+ });
396
+ }
397
+ toJSON() {
398
+ return {
399
+ claimant: this.claimant.toString(),
400
+ lockedAmount: this.lockedAmount.toString(),
401
+ lockedAmountWithdrawn: this.lockedAmountWithdrawn.toString(),
402
+ unlockedAmount: this.unlockedAmount.toString(),
403
+ lastClaimTs: this.lastClaimTs.toString(),
404
+ lastAmountPerUnlock: this.lastAmountPerUnlock.toString(),
405
+ closed: this.closed,
406
+ distributor: this.distributor.toString(),
407
+ claimsCount: this.claimsCount,
408
+ closedTs: this.closedTs.toString(),
409
+ buffer2: this.buffer2
410
+ };
411
+ }
412
+ static fromJSON(obj) {
413
+ return new _ClaimStatus({
414
+ claimant: new PublicKey(obj.claimant),
415
+ lockedAmount: new BN6(obj.lockedAmount),
416
+ lockedAmountWithdrawn: new BN6(obj.lockedAmountWithdrawn),
417
+ unlockedAmount: new BN6(obj.unlockedAmount),
418
+ lastClaimTs: new BN6(obj.lastClaimTs),
419
+ lastAmountPerUnlock: new BN6(obj.lastAmountPerUnlock),
420
+ closed: obj.closed,
421
+ distributor: new PublicKey(obj.distributor),
422
+ claimsCount: obj.claimsCount,
423
+ closedTs: new BN6(obj.closedTs),
424
+ buffer2: obj.buffer2
425
+ });
426
+ }
427
+ };
428
+ _ClaimStatus.discriminator = Buffer.from([22, 183, 249, 157, 247, 95, 150, 96]);
429
+ _ClaimStatus.layout = borsh8.struct([
430
+ borsh8.publicKey("claimant"),
431
+ borsh8.u64("lockedAmount"),
432
+ borsh8.u64("lockedAmountWithdrawn"),
433
+ borsh8.u64("unlockedAmount"),
434
+ borsh8.u64("lastClaimTs"),
435
+ borsh8.u64("lastAmountPerUnlock"),
436
+ borsh8.bool("closed"),
437
+ borsh8.publicKey("distributor"),
438
+ borsh8.u16("claimsCount"),
439
+ borsh8.u64("closedTs"),
440
+ borsh8.array(borsh8.u8(), 22, "buffer2")
441
+ ]);
442
+ var ClaimStatus = _ClaimStatus;
1651
443
  var _MerkleDistributor = class _MerkleDistributor {
1652
444
  constructor(fields) {
1653
445
  this.bump = fields.bump;
@@ -1769,28 +561,28 @@ var _MerkleDistributor = class _MerkleDistributor {
1769
561
  static fromJSON(obj) {
1770
562
  return new _MerkleDistributor({
1771
563
  bump: obj.bump,
1772
- version: new BN5(obj.version),
564
+ version: new BN6(obj.version),
1773
565
  root: obj.root,
1774
566
  mint: new PublicKey(obj.mint),
1775
567
  tokenVault: new PublicKey(obj.tokenVault),
1776
- maxTotalClaim: new BN5(obj.maxTotalClaim),
1777
- maxNumNodes: new BN5(obj.maxNumNodes),
1778
- unlockPeriod: new BN5(obj.unlockPeriod),
1779
- totalAmountClaimed: new BN5(obj.totalAmountClaimed),
1780
- numNodesClaimed: new BN5(obj.numNodesClaimed),
1781
- startTs: new BN5(obj.startTs),
1782
- endTs: new BN5(obj.endTs),
1783
- clawbackStartTs: new BN5(obj.clawbackStartTs),
568
+ maxTotalClaim: new BN6(obj.maxTotalClaim),
569
+ maxNumNodes: new BN6(obj.maxNumNodes),
570
+ unlockPeriod: new BN6(obj.unlockPeriod),
571
+ totalAmountClaimed: new BN6(obj.totalAmountClaimed),
572
+ numNodesClaimed: new BN6(obj.numNodesClaimed),
573
+ startTs: new BN6(obj.startTs),
574
+ endTs: new BN6(obj.endTs),
575
+ clawbackStartTs: new BN6(obj.clawbackStartTs),
1784
576
  clawbackReceiver: new PublicKey(obj.clawbackReceiver),
1785
577
  admin: new PublicKey(obj.admin),
1786
578
  clawedBack: obj.clawedBack,
1787
579
  claimsClosableByAdmin: obj.claimsClosableByAdmin,
1788
580
  canUpdateDuration: obj.canUpdateDuration,
1789
- totalAmountUnlocked: new BN5(obj.totalAmountUnlocked),
1790
- totalAmountLocked: new BN5(obj.totalAmountLocked),
1791
- lastDurationUpdateTs: new BN5(obj.lastDurationUpdateTs),
1792
- totalClaimablePreUpdate: new BN5(obj.totalClaimablePreUpdate),
1793
- clawedBackTs: new BN5(obj.clawedBackTs),
581
+ totalAmountUnlocked: new BN6(obj.totalAmountUnlocked),
582
+ totalAmountLocked: new BN6(obj.totalAmountLocked),
583
+ lastDurationUpdateTs: new BN6(obj.lastDurationUpdateTs),
584
+ totalClaimablePreUpdate: new BN6(obj.totalClaimablePreUpdate),
585
+ clawedBackTs: new BN6(obj.clawedBackTs),
1794
586
  claimsClosableByClaimant: obj.claimsClosableByClaimant,
1795
587
  claimsLimit: obj.claimsLimit,
1796
588
  buffer2: obj.buffer2,
@@ -1799,34 +591,34 @@ var _MerkleDistributor = class _MerkleDistributor {
1799
591
  }
1800
592
  };
1801
593
  _MerkleDistributor.discriminator = Buffer.from([77, 119, 139, 70, 84, 247, 12, 26]);
1802
- _MerkleDistributor.layout = borsh7.struct([
1803
- borsh7.u8("bump"),
1804
- borsh7.u64("version"),
1805
- borsh7.array(borsh7.u8(), 32, "root"),
1806
- borsh7.publicKey("mint"),
1807
- borsh7.publicKey("tokenVault"),
1808
- borsh7.u64("maxTotalClaim"),
1809
- borsh7.u64("maxNumNodes"),
1810
- borsh7.u64("unlockPeriod"),
1811
- borsh7.u64("totalAmountClaimed"),
1812
- borsh7.u64("numNodesClaimed"),
1813
- borsh7.u64("startTs"),
1814
- borsh7.u64("endTs"),
1815
- borsh7.u64("clawbackStartTs"),
1816
- borsh7.publicKey("clawbackReceiver"),
1817
- borsh7.publicKey("admin"),
1818
- borsh7.bool("clawedBack"),
1819
- borsh7.bool("claimsClosableByAdmin"),
1820
- borsh7.bool("canUpdateDuration"),
1821
- borsh7.u64("totalAmountUnlocked"),
1822
- borsh7.u64("totalAmountLocked"),
1823
- borsh7.u64("lastDurationUpdateTs"),
1824
- borsh7.u64("totalClaimablePreUpdate"),
1825
- borsh7.u64("clawedBackTs"),
1826
- borsh7.bool("claimsClosableByClaimant"),
1827
- borsh7.u16("claimsLimit"),
1828
- borsh7.array(borsh7.u8(), 20, "buffer2"),
1829
- borsh7.array(borsh7.u8(), 32, "buffer3")
594
+ _MerkleDistributor.layout = borsh8.struct([
595
+ borsh8.u8("bump"),
596
+ borsh8.u64("version"),
597
+ borsh8.array(borsh8.u8(), 32, "root"),
598
+ borsh8.publicKey("mint"),
599
+ borsh8.publicKey("tokenVault"),
600
+ borsh8.u64("maxTotalClaim"),
601
+ borsh8.u64("maxNumNodes"),
602
+ borsh8.u64("unlockPeriod"),
603
+ borsh8.u64("totalAmountClaimed"),
604
+ borsh8.u64("numNodesClaimed"),
605
+ borsh8.u64("startTs"),
606
+ borsh8.u64("endTs"),
607
+ borsh8.u64("clawbackStartTs"),
608
+ borsh8.publicKey("clawbackReceiver"),
609
+ borsh8.publicKey("admin"),
610
+ borsh8.bool("clawedBack"),
611
+ borsh8.bool("claimsClosableByAdmin"),
612
+ borsh8.bool("canUpdateDuration"),
613
+ borsh8.u64("totalAmountUnlocked"),
614
+ borsh8.u64("totalAmountLocked"),
615
+ borsh8.u64("lastDurationUpdateTs"),
616
+ borsh8.u64("totalClaimablePreUpdate"),
617
+ borsh8.u64("clawedBackTs"),
618
+ borsh8.bool("claimsClosableByClaimant"),
619
+ borsh8.u16("claimsLimit"),
620
+ borsh8.array(borsh8.u8(), 20, "buffer2"),
621
+ borsh8.array(borsh8.u8(), 32, "buffer3")
1830
622
  ]);
1831
623
  var MerkleDistributor = _MerkleDistributor;
1832
624
 
@@ -2838,9 +1630,9 @@ function getEventAuthorityPda(programId) {
2838
1630
  const seeds = [Buffer$1.from("__event_authority")];
2839
1631
  return PublicKey.findProgramAddressSync(seeds, programId)[0];
2840
1632
  }
2841
- async function wrappedSignAndExecuteTransaction(...args) {
1633
+ async function wrappedSignAndExecuteTransaction(connection, invoker, tx, confirmationParams, throttleParams) {
2842
1634
  try {
2843
- return await signAndExecuteTransaction(...args);
1635
+ return await signAndExecuteTransaction(connection, invoker, tx, confirmationParams, throttleParams);
2844
1636
  } catch (err) {
2845
1637
  if (err instanceof Error) {
2846
1638
  const parsed = fromTxError(err);
@@ -2881,10 +1673,6 @@ var BaseDistributorClient = class {
2881
1673
  this.connection = new Connection(clusterUrl, this.commitment);
2882
1674
  this.programId = programId !== "" ? new PublicKey(programId) : new PublicKey(DISTRIBUTOR_PROGRAM_ID[cluster]);
2883
1675
  this.sendThrottler = sendThrottler ?? buildSendThrottler(sendRate);
2884
- const merkleDistributorProgram = {
2885
- ...merkle_distributor_default
2886
- };
2887
- this.merkleDistributorProgram = new Program(merkleDistributorProgram, { connection: this.connection });
2888
1676
  }
2889
1677
  getConnection() {
2890
1678
  return this.connection;
@@ -2919,7 +1707,7 @@ var BaseDistributorClient = class {
2919
1707
  };
2920
1708
  if (extParams.isNative) {
2921
1709
  ixs.push(
2922
- ...await prepareWrappedAccount(this.connection, extParams.invoker.publicKey, new BN5(data.maxTotalClaim))
1710
+ ...await prepareWrappedAccount(this.connection, extParams.invoker.publicKey, new BN6(data.maxTotalClaim))
2923
1711
  );
2924
1712
  }
2925
1713
  const newDistributorInstruction = await this.getNewDistributorInstruction(data, accounts);
@@ -2960,14 +1748,7 @@ var BaseDistributorClient = class {
2960
1748
  return { distributorPublicKey, ixs };
2961
1749
  }
2962
1750
  async create(data, extParams) {
2963
- const invoker = extParams.invoker.publicKey;
2964
- invariant(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
2965
- const executionParams = this.unwrapExecutionParams(extParams);
2966
- const { ixs, distributorPublicKey } = await createAndEstimateTransaction(
2967
- (params) => this.prepareCreateInstructions(data, params),
2968
- executionParams,
2969
- (q) => q.ixs
2970
- );
1751
+ const { ixs, distributorPublicKey } = await this.prepareCreateInstructions(data, extParams);
2971
1752
  const { tx, hash, context } = await prepareTransaction(this.connection, ixs, extParams.invoker.publicKey);
2972
1753
  const signature = await wrappedSignAndExecuteTransaction(
2973
1754
  this.connection,
@@ -2978,7 +1759,7 @@ var BaseDistributorClient = class {
2978
1759
  context,
2979
1760
  commitment: this.getCommitment()
2980
1761
  },
2981
- { sendThrottler: this.sendThrottler, skipSimulation: executionParams.skipSimulation }
1762
+ { sendThrottler: this.sendThrottler }
2982
1763
  );
2983
1764
  return {
2984
1765
  ixs,
@@ -2986,29 +1767,23 @@ var BaseDistributorClient = class {
2986
1767
  metadataId: distributorPublicKey.toBase58()
2987
1768
  };
2988
1769
  }
2989
- async claim(data, extParams, _serviceTransfer) {
2990
- const executionParams = this.unwrapExecutionParams(extParams);
2991
- const invoker = executionParams.invoker.publicKey;
2992
- invariant(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
2993
- const ixs = await createAndEstimateTransaction(
2994
- (params) => this.prepareClaimInstructions(data, params, _serviceTransfer),
2995
- executionParams
2996
- );
2997
- const { tx, hash, context } = await prepareTransaction(this.connection, ixs, invoker);
1770
+ async claim(data, extParams) {
1771
+ const ixs = await this.prepareClaimInstructions(data, extParams);
1772
+ const { tx, hash, context } = await prepareTransaction(this.connection, ixs, extParams.invoker.publicKey);
2998
1773
  const signature = await wrappedSignAndExecuteTransaction(
2999
1774
  this.connection,
3000
- executionParams.invoker,
1775
+ extParams.invoker,
3001
1776
  tx,
3002
1777
  {
3003
1778
  hash,
3004
1779
  context,
3005
1780
  commitment: this.getCommitment()
3006
1781
  },
3007
- { sendThrottler: this.sendThrottler, skipSimulation: executionParams.skipSimulation }
1782
+ { sendThrottler: this.sendThrottler }
3008
1783
  );
3009
1784
  return { ixs, txId: signature };
3010
1785
  }
3011
- async prepareClaimInstructions(data, extParams, _serviceTransfer) {
1786
+ async prepareClaimInstructions(data, extParams) {
3012
1787
  if (!extParams.invoker.publicKey) {
3013
1788
  throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
3014
1789
  }
@@ -3035,7 +1810,7 @@ var BaseDistributorClient = class {
3035
1810
  extParams.invoker.publicKey
3036
1811
  );
3037
1812
  const eventAuthorityPublicKey = getEventAuthorityPda(this.programId);
3038
- const claimStatus = await this.getClaim(claimStatusPublicKey);
1813
+ const claimStatus = await ClaimStatus.fetch(this.connection, claimStatusPublicKey);
3039
1814
  const accounts = {
3040
1815
  distributor: distributorPublicKey,
3041
1816
  claimStatus: claimStatusPublicKey,
@@ -3050,43 +1825,32 @@ var BaseDistributorClient = class {
3050
1825
  };
3051
1826
  if (!claimStatus) {
3052
1827
  const args = {
3053
- amountLocked: new BN5(data.amountLocked),
3054
- amountUnlocked: new BN5(data.amountUnlocked),
1828
+ amountLocked: new BN6(data.amountLocked),
1829
+ amountUnlocked: new BN6(data.amountUnlocked),
3055
1830
  proof: data.proof
3056
1831
  };
3057
1832
  ixs.push(newClaim(args, accounts, this.programId));
3058
1833
  }
3059
- const nowTs = new BN5(Math.floor(Date.now() / 1e3));
3060
- if (claimStatus || new BN5(data.amountLocked).gtn(0) && nowTs.sub(distributor.startTs).gte(distributor.unlockPeriod)) {
1834
+ const nowTs = new BN6(Math.floor(Date.now() / 1e3));
1835
+ if (claimStatus || new BN6(data.amountLocked).gtn(0) && nowTs.sub(distributor.startTs).gte(distributor.unlockPeriod)) {
3061
1836
  ixs.push(claimLocked(accounts, this.programId));
3062
1837
  }
3063
- ixs.push(
3064
- this.prepareClaimFeeInstruction(
3065
- extParams.invoker.publicKey,
3066
- typeof _serviceTransfer === "bigint" ? _serviceTransfer : void 0
3067
- )
3068
- );
1838
+ ixs.push(this.prepareClaimFeeInstruction(extParams.invoker.publicKey));
3069
1839
  return ixs;
3070
1840
  }
3071
1841
  async closeClaim(data, extParams) {
3072
- const executionParams = this.unwrapExecutionParams(extParams);
3073
- const invoker = executionParams.invoker.publicKey;
3074
- invariant(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
3075
- const ixs = await createAndEstimateTransaction(
3076
- (params) => this.prepareCloseClaimInstructions(data, params),
3077
- executionParams
3078
- );
3079
- const { tx, hash, context } = await prepareTransaction(this.connection, ixs, invoker);
1842
+ const ixs = await this.prepareCloseClaimInstructions(data, extParams);
1843
+ const { tx, hash, context } = await prepareTransaction(this.connection, ixs, extParams.invoker.publicKey);
3080
1844
  const signature = await wrappedSignAndExecuteTransaction(
3081
1845
  this.connection,
3082
- executionParams.invoker,
1846
+ extParams.invoker,
3083
1847
  tx,
3084
1848
  {
3085
1849
  hash,
3086
1850
  context,
3087
1851
  commitment: this.getCommitment()
3088
1852
  },
3089
- { sendThrottler: this.sendThrottler, skipSimulation: executionParams.skipSimulation }
1853
+ { sendThrottler: this.sendThrottler }
3090
1854
  );
3091
1855
  return { ixs, txId: signature };
3092
1856
  }
@@ -3113,8 +1877,8 @@ var BaseDistributorClient = class {
3113
1877
  program: this.programId
3114
1878
  };
3115
1879
  const closeClaimArgs = {
3116
- amountLocked: data.amountLocked ? new BN5(data.amountLocked) : void 0,
3117
- amountUnlocked: data.amountUnlocked ? new BN5(data.amountUnlocked) : void 0,
1880
+ amountLocked: data.amountLocked ? new BN6(data.amountLocked) : void 0,
1881
+ amountUnlocked: data.amountUnlocked ? new BN6(data.amountUnlocked) : void 0,
3118
1882
  proof: data.proof
3119
1883
  };
3120
1884
  ixs.push(closeClaim(closeClaimArgs, closeClaimAccounts, this.programId));
@@ -3154,37 +1918,26 @@ var BaseDistributorClient = class {
3154
1918
  return ixs;
3155
1919
  }
3156
1920
  async clawback(data, extParams) {
3157
- const executionParams = this.unwrapExecutionParams(extParams);
3158
- const invoker = executionParams.invoker.publicKey;
3159
- invariant(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
3160
- const ixs = await createAndEstimateTransaction(
3161
- (params) => this.prepareClawbackInstructions(data, params),
3162
- executionParams
3163
- );
3164
- const { tx, hash, context } = await prepareTransaction(this.connection, ixs, invoker);
1921
+ const ixs = await this.prepareClawbackInstructions(data, extParams);
1922
+ const { tx, hash, context } = await prepareTransaction(this.connection, ixs, extParams.invoker.publicKey);
3165
1923
  const signature = await wrappedSignAndExecuteTransaction(
3166
1924
  this.connection,
3167
- executionParams.invoker,
1925
+ extParams.invoker,
3168
1926
  tx,
3169
1927
  {
3170
1928
  hash,
3171
1929
  context,
3172
1930
  commitment: this.getCommitment()
3173
1931
  },
3174
- { sendThrottler: this.sendThrottler, skipSimulation: executionParams.skipSimulation }
1932
+ { sendThrottler: this.sendThrottler }
3175
1933
  );
3176
1934
  return { ixs, txId: signature };
3177
1935
  }
3178
- async getClaim(claimStatus) {
3179
- return this.connection.getAccountInfo(pk(claimStatus)).then((account) => this.decodeClaimStatus(account));
3180
- }
3181
1936
  async getClaims(data) {
3182
1937
  const claimStatusPublicKeys = data.map(({ id, recipient }) => {
3183
1938
  return getClaimantStatusPda(this.programId, new PublicKey(id), new PublicKey(recipient));
3184
1939
  });
3185
- return this.connection.getMultipleAccountsInfo(claimStatusPublicKeys).then((accounts) => {
3186
- return accounts.map((account) => this.decodeClaimStatus(account));
3187
- });
1940
+ return ClaimStatus.fetchMultiple(this.connection, claimStatusPublicKeys, this.programId);
3188
1941
  }
3189
1942
  async getDistributors(data) {
3190
1943
  const distributorPublicKeys = data.ids.map((distributorId) => new PublicKey(distributorId));
@@ -3214,28 +1967,28 @@ var BaseDistributorClient = class {
3214
1967
  account: MerkleDistributor.decode(account.data)
3215
1968
  }));
3216
1969
  }
3217
- prepareClaimFeeInstruction(payer, fee = AIRDROP_CLAIM_FEE) {
1970
+ prepareClaimFeeInstruction(payer) {
3218
1971
  return SystemProgram.transfer({
3219
1972
  fromPubkey: payer,
3220
1973
  toPubkey: STREAMFLOW_TREASURY_PUBLIC_KEY,
3221
- lamports: fee
1974
+ lamports: AIRDROP_CLAIM_FEE
3222
1975
  });
3223
1976
  }
3224
1977
  getNewDistributorArgs(data) {
3225
1978
  const args = {
3226
- version: new BN5(data.version),
1979
+ version: new BN6(data.version),
3227
1980
  root: data.root,
3228
- maxTotalClaim: new BN5(data.maxTotalClaim),
3229
- maxNumNodes: new BN5(data.maxNumNodes),
3230
- unlockPeriod: new BN5(data.unlockPeriod),
3231
- startVestingTs: new BN5(data.startVestingTs),
3232
- endVestingTs: new BN5(data.endVestingTs),
3233
- clawbackStartTs: new BN5(data.clawbackStartTs),
1981
+ maxTotalClaim: new BN6(data.maxTotalClaim),
1982
+ maxNumNodes: new BN6(data.maxNumNodes),
1983
+ unlockPeriod: new BN6(data.unlockPeriod),
1984
+ startVestingTs: new BN6(data.startVestingTs),
1985
+ endVestingTs: new BN6(data.endVestingTs),
1986
+ clawbackStartTs: new BN6(data.clawbackStartTs),
3234
1987
  claimsClosableByAdmin: data.claimsClosableByAdmin,
3235
1988
  claimsClosableByClaimant: data.claimsClosableByClaimant,
3236
1989
  claimsLimit: data.claimsLimit
3237
1990
  };
3238
- const nowTs = new BN5(Math.floor(Date.now() / 1e3));
1991
+ const nowTs = new BN6(Math.floor(Date.now() / 1e3));
3239
1992
  const endVestingTs = args.endVestingTs.isZero() ? nowTs : args.endVestingTs;
3240
1993
  const startVestingTs = args.startVestingTs.isZero() ? nowTs : args.startVestingTs;
3241
1994
  if (endVestingTs.gt(startVestingTs) && endVestingTs.sub(startVestingTs).lt(args.unlockPeriod)) {
@@ -3243,34 +1996,7 @@ var BaseDistributorClient = class {
3243
1996
  }
3244
1997
  return args;
3245
1998
  }
3246
- unwrapExecutionParams(extParams) {
3247
- return unwrapExecutionParams(extParams, this.connection);
3248
- }
3249
- decodeClaimStatus(account) {
3250
- if (!account) {
3251
- return account;
3252
- }
3253
- try {
3254
- return decode(this.merkleDistributorProgram, "claimStatus", account.data);
3255
- } catch (baseClaimStatusError) {
3256
- try {
3257
- return decode(this.merkleDistributorProgram, "compressedClaimStatus", account.data);
3258
- } catch (compressedClaimStatusError) {
3259
- throw new Error("Couldn't decode claim status");
3260
- }
3261
- }
3262
- }
3263
1999
  };
3264
- function decode(program, accountName, accInfo, programKey) {
3265
- const programId = program.programId?.toBase58() ?? "N/A";
3266
- invariant(program, `Decoding program with key ${programId} is not available`);
3267
- const accountEntity = program.idl.accounts?.find((acc) => acc.name === accountName);
3268
- invariant(
3269
- !!accountEntity,
3270
- `Decoding program with key ${programId} doesn't specify account with name ${String(accountName)}`
3271
- );
3272
- return program.coder.accounts.decode(accountName, accInfo);
3273
- }
3274
2000
 
3275
2001
  // solana/clients/SolanaDistributorClient.ts
3276
2002
  var SolanaDistributorClient = class extends BaseDistributorClient {
@@ -3288,7 +2014,7 @@ var aligned_distributor_default = {
3288
2014
  address: "aMERKpFAWoChCi5oZwPvgsSCoGpZKBiU7fi76bdZjt2",
3289
2015
  metadata: {
3290
2016
  name: "aligned_distributor",
3291
- version: "1.5.0",
2017
+ version: "1.3.2",
3292
2018
  spec: "0.1.0",
3293
2019
  description: "Proxy for merkle distributor that updates Vesting duration according to token market performance."
3294
2020
  },
@@ -3432,48 +2158,6 @@ var aligned_distributor_default = {
3432
2158
  }
3433
2159
  ]
3434
2160
  },
3435
- {
3436
- name: "migrate_test_oracle",
3437
- discriminator: [203, 254, 19, 3, 172, 185, 85, 190],
3438
- accounts: [
3439
- {
3440
- name: "payer",
3441
- writable: true,
3442
- signer: true
3443
- },
3444
- {
3445
- name: "mint"
3446
- },
3447
- {
3448
- name: "creator"
3449
- },
3450
- {
3451
- name: "test_oracle",
3452
- writable: true,
3453
- pda: {
3454
- seeds: [
3455
- {
3456
- kind: "const",
3457
- value: [116, 101, 115, 116, 45, 111, 114, 97, 99, 108, 101]
3458
- },
3459
- {
3460
- kind: "account",
3461
- path: "mint"
3462
- },
3463
- {
3464
- kind: "account",
3465
- path: "creator"
3466
- }
3467
- ]
3468
- }
3469
- },
3470
- {
3471
- name: "system_program",
3472
- address: "11111111111111111111111111111111"
3473
- }
3474
- ],
3475
- args: []
3476
- },
3477
2161
  {
3478
2162
  name: "new_distributor",
3479
2163
  discriminator: [32, 139, 112, 171, 0, 2, 225, 155],
@@ -3559,48 +2243,6 @@ var aligned_distributor_default = {
3559
2243
  }
3560
2244
  ]
3561
2245
  },
3562
- {
3563
- name: "realloc_test_oracle",
3564
- discriminator: [234, 221, 116, 4, 198, 251, 244, 206],
3565
- accounts: [
3566
- {
3567
- name: "payer",
3568
- writable: true,
3569
- signer: true
3570
- },
3571
- {
3572
- name: "mint"
3573
- },
3574
- {
3575
- name: "creator"
3576
- },
3577
- {
3578
- name: "test_oracle",
3579
- writable: true,
3580
- pda: {
3581
- seeds: [
3582
- {
3583
- kind: "const",
3584
- value: [116, 101, 115, 116, 45, 111, 114, 97, 99, 108, 101]
3585
- },
3586
- {
3587
- kind: "account",
3588
- path: "mint"
3589
- },
3590
- {
3591
- kind: "account",
3592
- path: "creator"
3593
- }
3594
- ]
3595
- }
3596
- },
3597
- {
3598
- name: "system_program",
3599
- address: "11111111111111111111111111111111"
3600
- }
3601
- ],
3602
- args: []
3603
- },
3604
2246
  {
3605
2247
  name: "set_admin",
3606
2248
  discriminator: [251, 163, 0, 52, 91, 194, 187, 92],
@@ -4386,16 +3028,16 @@ var SolanaAlignedDistributorClient = class extends BaseDistributorClient {
4386
3028
  unlockPeriod
4387
3029
  } = data;
4388
3030
  return {
4389
- totalAmountLocked: new BN5(totalAmountLocked),
4390
- totalAmountUnlocked: new BN5(totalAmountUnlocked),
3031
+ totalAmountLocked: new BN6(totalAmountLocked),
3032
+ totalAmountUnlocked: new BN6(totalAmountUnlocked),
4391
3033
  oracleType: !!oracleType ? { [oracleType]: {} } : { none: {} },
4392
3034
  minPrice: getBN(minPrice, ALIGNED_PRECISION_FACTOR_POW),
4393
3035
  maxPrice: getBN(maxPrice, ALIGNED_PRECISION_FACTOR_POW),
4394
3036
  minPercentage: getBN(minPercentage, ALIGNED_PRECISION_FACTOR_POW),
4395
3037
  maxPercentage: getBN(maxPercentage, ALIGNED_PRECISION_FACTOR_POW),
4396
- tickSize: new BN5(tickSize || 1),
3038
+ tickSize: new BN6(tickSize || 1),
4397
3039
  skipInitial: skipInitial ?? false,
4398
- updatePeriod: unlockPeriod < 30 ? new BN5(30) : new BN5(unlockPeriod)
3040
+ updatePeriod: unlockPeriod < 30 ? new BN6(30) : new BN6(unlockPeriod)
4399
3041
  };
4400
3042
  }
4401
3043
  };