@vibeiao/sdk 0.1.0

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.
@@ -0,0 +1,1416 @@
1
+ // src/solana.ts
2
+ import { AnchorProvider, Program } from "@coral-xyz/anchor";
3
+ import {
4
+ LAMPORTS_PER_SOL,
5
+ PublicKey,
6
+ SystemProgram
7
+ } from "@solana/web3.js";
8
+ import BN from "bn.js";
9
+
10
+ // src/idl.ts
11
+ var VIBEIAO_IDL = {
12
+ "address": "5jnUTmty5yjiAFsZJpmmwRL68fNFMDJZQwqkiL2kFSoS",
13
+ "metadata": {
14
+ "name": "vibeiao",
15
+ "version": "0.1.0",
16
+ "spec": "0.1.0"
17
+ },
18
+ "instructions": [
19
+ {
20
+ "name": "create_listing",
21
+ "discriminator": [
22
+ 18,
23
+ 168,
24
+ 45,
25
+ 24,
26
+ 191,
27
+ 31,
28
+ 117,
29
+ 54
30
+ ],
31
+ "accounts": [
32
+ {
33
+ "name": "creator",
34
+ "writable": true,
35
+ "signer": true
36
+ },
37
+ {
38
+ "name": "listing",
39
+ "writable": true,
40
+ "pda": {
41
+ "seeds": [
42
+ {
43
+ "kind": "const",
44
+ "value": [
45
+ 108,
46
+ 105,
47
+ 115,
48
+ 116,
49
+ 105,
50
+ 110,
51
+ 103
52
+ ]
53
+ },
54
+ {
55
+ "kind": "account",
56
+ "path": "creator"
57
+ },
58
+ {
59
+ "kind": "arg",
60
+ "path": "listing_seed"
61
+ }
62
+ ]
63
+ }
64
+ },
65
+ {
66
+ "name": "system_program",
67
+ "address": "11111111111111111111111111111111"
68
+ }
69
+ ],
70
+ "args": [
71
+ {
72
+ "name": "listing_seed",
73
+ "type": {
74
+ "array": [
75
+ "u8",
76
+ 32
77
+ ]
78
+ }
79
+ },
80
+ {
81
+ "name": "revenue_wallet",
82
+ "type": "pubkey"
83
+ },
84
+ {
85
+ "name": "listing_type",
86
+ "type": {
87
+ "defined": {
88
+ "name": "ListingType"
89
+ }
90
+ }
91
+ },
92
+ {
93
+ "name": "name",
94
+ "type": "string"
95
+ },
96
+ {
97
+ "name": "tagline",
98
+ "type": "string"
99
+ },
100
+ {
101
+ "name": "description",
102
+ "type": "string"
103
+ },
104
+ {
105
+ "name": "category",
106
+ "type": "string"
107
+ },
108
+ {
109
+ "name": "image_url",
110
+ "type": "string"
111
+ },
112
+ {
113
+ "name": "product_url",
114
+ "type": "string"
115
+ },
116
+ {
117
+ "name": "endpoint_url",
118
+ "type": "string"
119
+ },
120
+ {
121
+ "name": "manifest_url",
122
+ "type": "string"
123
+ },
124
+ {
125
+ "name": "ticket_price",
126
+ "type": "u64"
127
+ },
128
+ {
129
+ "name": "target_revenue",
130
+ "type": "u64"
131
+ },
132
+ {
133
+ "name": "buyback_bps",
134
+ "type": "u16"
135
+ }
136
+ ]
137
+ },
138
+ {
139
+ "name": "initialize_config",
140
+ "discriminator": [
141
+ 208,
142
+ 127,
143
+ 21,
144
+ 1,
145
+ 194,
146
+ 190,
147
+ 196,
148
+ 70
149
+ ],
150
+ "accounts": [
151
+ {
152
+ "name": "authority",
153
+ "writable": true,
154
+ "signer": true
155
+ },
156
+ {
157
+ "name": "config",
158
+ "writable": true,
159
+ "pda": {
160
+ "seeds": [
161
+ {
162
+ "kind": "const",
163
+ "value": [
164
+ 99,
165
+ 111,
166
+ 110,
167
+ 102,
168
+ 105,
169
+ 103
170
+ ]
171
+ }
172
+ ]
173
+ }
174
+ },
175
+ {
176
+ "name": "system_program",
177
+ "address": "11111111111111111111111111111111"
178
+ }
179
+ ],
180
+ "args": [
181
+ {
182
+ "name": "platform_treasury",
183
+ "type": "pubkey"
184
+ },
185
+ {
186
+ "name": "buyback_treasury",
187
+ "type": "pubkey"
188
+ }
189
+ ]
190
+ },
191
+ {
192
+ "name": "initialize_token",
193
+ "discriminator": [
194
+ 38,
195
+ 209,
196
+ 150,
197
+ 50,
198
+ 190,
199
+ 117,
200
+ 16,
201
+ 54
202
+ ],
203
+ "accounts": [
204
+ {
205
+ "name": "creator",
206
+ "writable": true,
207
+ "signer": true,
208
+ "relations": [
209
+ "listing"
210
+ ]
211
+ },
212
+ {
213
+ "name": "listing",
214
+ "writable": true,
215
+ "pda": {
216
+ "seeds": [
217
+ {
218
+ "kind": "const",
219
+ "value": [
220
+ 108,
221
+ 105,
222
+ 115,
223
+ 116,
224
+ 105,
225
+ 110,
226
+ 103
227
+ ]
228
+ },
229
+ {
230
+ "kind": "account",
231
+ "path": "creator"
232
+ },
233
+ {
234
+ "kind": "arg",
235
+ "path": "listing_seed"
236
+ }
237
+ ]
238
+ }
239
+ },
240
+ {
241
+ "name": "mint",
242
+ "writable": true,
243
+ "signer": true
244
+ },
245
+ {
246
+ "name": "creator_token_account",
247
+ "writable": true,
248
+ "pda": {
249
+ "seeds": [
250
+ {
251
+ "kind": "account",
252
+ "path": "creator"
253
+ },
254
+ {
255
+ "kind": "const",
256
+ "value": [
257
+ 6,
258
+ 221,
259
+ 246,
260
+ 225,
261
+ 215,
262
+ 101,
263
+ 161,
264
+ 147,
265
+ 217,
266
+ 203,
267
+ 225,
268
+ 70,
269
+ 206,
270
+ 235,
271
+ 121,
272
+ 172,
273
+ 28,
274
+ 180,
275
+ 133,
276
+ 237,
277
+ 95,
278
+ 91,
279
+ 55,
280
+ 145,
281
+ 58,
282
+ 140,
283
+ 245,
284
+ 133,
285
+ 126,
286
+ 255,
287
+ 0,
288
+ 169
289
+ ]
290
+ },
291
+ {
292
+ "kind": "account",
293
+ "path": "mint"
294
+ }
295
+ ],
296
+ "program": {
297
+ "kind": "const",
298
+ "value": [
299
+ 140,
300
+ 151,
301
+ 37,
302
+ 143,
303
+ 78,
304
+ 36,
305
+ 137,
306
+ 241,
307
+ 187,
308
+ 61,
309
+ 16,
310
+ 41,
311
+ 20,
312
+ 142,
313
+ 13,
314
+ 131,
315
+ 11,
316
+ 90,
317
+ 19,
318
+ 153,
319
+ 218,
320
+ 255,
321
+ 16,
322
+ 132,
323
+ 4,
324
+ 142,
325
+ 123,
326
+ 216,
327
+ 219,
328
+ 233,
329
+ 248,
330
+ 89
331
+ ]
332
+ }
333
+ }
334
+ },
335
+ {
336
+ "name": "token_program",
337
+ "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
338
+ },
339
+ {
340
+ "name": "associated_token_program",
341
+ "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
342
+ },
343
+ {
344
+ "name": "system_program",
345
+ "address": "11111111111111111111111111111111"
346
+ },
347
+ {
348
+ "name": "rent",
349
+ "address": "SysvarRent111111111111111111111111111111111"
350
+ }
351
+ ],
352
+ "args": [
353
+ {
354
+ "name": "listing_seed",
355
+ "type": {
356
+ "array": [
357
+ "u8",
358
+ 32
359
+ ]
360
+ }
361
+ },
362
+ {
363
+ "name": "token_symbol",
364
+ "type": "string"
365
+ }
366
+ ]
367
+ },
368
+ {
369
+ "name": "purchase_ticket",
370
+ "discriminator": [
371
+ 90,
372
+ 91,
373
+ 173,
374
+ 20,
375
+ 72,
376
+ 109,
377
+ 15,
378
+ 146
379
+ ],
380
+ "accounts": [
381
+ {
382
+ "name": "buyer",
383
+ "writable": true,
384
+ "signer": true
385
+ },
386
+ {
387
+ "name": "listing",
388
+ "writable": true
389
+ },
390
+ {
391
+ "name": "config",
392
+ "pda": {
393
+ "seeds": [
394
+ {
395
+ "kind": "const",
396
+ "value": [
397
+ 99,
398
+ 111,
399
+ 110,
400
+ 102,
401
+ 105,
402
+ 103
403
+ ]
404
+ }
405
+ ]
406
+ }
407
+ },
408
+ {
409
+ "name": "creator",
410
+ "writable": true,
411
+ "relations": [
412
+ "listing"
413
+ ]
414
+ },
415
+ {
416
+ "name": "revenue_wallet",
417
+ "writable": true
418
+ },
419
+ {
420
+ "name": "platform_treasury",
421
+ "writable": true
422
+ },
423
+ {
424
+ "name": "buyback_treasury",
425
+ "writable": true
426
+ },
427
+ {
428
+ "name": "ticket_receipt",
429
+ "writable": true,
430
+ "pda": {
431
+ "seeds": [
432
+ {
433
+ "kind": "const",
434
+ "value": [
435
+ 116,
436
+ 105,
437
+ 99,
438
+ 107,
439
+ 101,
440
+ 116
441
+ ]
442
+ },
443
+ {
444
+ "kind": "account",
445
+ "path": "listing"
446
+ },
447
+ {
448
+ "kind": "account",
449
+ "path": "buyer"
450
+ }
451
+ ]
452
+ }
453
+ },
454
+ {
455
+ "name": "system_program",
456
+ "address": "11111111111111111111111111111111"
457
+ }
458
+ ],
459
+ "args": []
460
+ },
461
+ {
462
+ "name": "redeem_ticket",
463
+ "discriminator": [
464
+ 129,
465
+ 120,
466
+ 104,
467
+ 224,
468
+ 155,
469
+ 25,
470
+ 22,
471
+ 192
472
+ ],
473
+ "accounts": [
474
+ {
475
+ "name": "buyer",
476
+ "writable": true,
477
+ "signer": true
478
+ },
479
+ {
480
+ "name": "listing"
481
+ },
482
+ {
483
+ "name": "ticket_receipt",
484
+ "writable": true,
485
+ "pda": {
486
+ "seeds": [
487
+ {
488
+ "kind": "const",
489
+ "value": [
490
+ 116,
491
+ 105,
492
+ 99,
493
+ 107,
494
+ 101,
495
+ 116
496
+ ]
497
+ },
498
+ {
499
+ "kind": "account",
500
+ "path": "listing"
501
+ },
502
+ {
503
+ "kind": "account",
504
+ "path": "buyer"
505
+ }
506
+ ]
507
+ }
508
+ }
509
+ ],
510
+ "args": []
511
+ },
512
+ {
513
+ "name": "set_buyback_bps",
514
+ "discriminator": [
515
+ 26,
516
+ 112,
517
+ 151,
518
+ 155,
519
+ 69,
520
+ 147,
521
+ 234,
522
+ 24
523
+ ],
524
+ "accounts": [
525
+ {
526
+ "name": "creator",
527
+ "writable": true,
528
+ "signer": true,
529
+ "relations": [
530
+ "listing"
531
+ ]
532
+ },
533
+ {
534
+ "name": "listing",
535
+ "writable": true
536
+ }
537
+ ],
538
+ "args": [
539
+ {
540
+ "name": "buyback_bps",
541
+ "type": "u16"
542
+ }
543
+ ]
544
+ },
545
+ {
546
+ "name": "trigger_ipo",
547
+ "discriminator": [
548
+ 130,
549
+ 168,
550
+ 9,
551
+ 179,
552
+ 203,
553
+ 226,
554
+ 186,
555
+ 114
556
+ ],
557
+ "accounts": [
558
+ {
559
+ "name": "creator",
560
+ "writable": true,
561
+ "signer": true,
562
+ "relations": [
563
+ "listing"
564
+ ]
565
+ },
566
+ {
567
+ "name": "listing",
568
+ "writable": true,
569
+ "pda": {
570
+ "seeds": [
571
+ {
572
+ "kind": "const",
573
+ "value": [
574
+ 108,
575
+ 105,
576
+ 115,
577
+ 116,
578
+ 105,
579
+ 110,
580
+ 103
581
+ ]
582
+ },
583
+ {
584
+ "kind": "account",
585
+ "path": "creator"
586
+ },
587
+ {
588
+ "kind": "arg",
589
+ "path": "listing_seed"
590
+ }
591
+ ]
592
+ }
593
+ },
594
+ {
595
+ "name": "vault",
596
+ "writable": true,
597
+ "pda": {
598
+ "seeds": [
599
+ {
600
+ "kind": "const",
601
+ "value": [
602
+ 118,
603
+ 97,
604
+ 117,
605
+ 108,
606
+ 116
607
+ ]
608
+ },
609
+ {
610
+ "kind": "account",
611
+ "path": "listing"
612
+ }
613
+ ]
614
+ }
615
+ },
616
+ {
617
+ "name": "system_program",
618
+ "address": "11111111111111111111111111111111"
619
+ }
620
+ ],
621
+ "args": [
622
+ {
623
+ "name": "listing_seed",
624
+ "type": {
625
+ "array": [
626
+ "u8",
627
+ 32
628
+ ]
629
+ }
630
+ },
631
+ {
632
+ "name": "buyback_bps",
633
+ "type": "u16"
634
+ }
635
+ ]
636
+ },
637
+ {
638
+ "name": "update_config",
639
+ "discriminator": [
640
+ 29,
641
+ 158,
642
+ 252,
643
+ 191,
644
+ 10,
645
+ 83,
646
+ 219,
647
+ 99
648
+ ],
649
+ "accounts": [
650
+ {
651
+ "name": "authority",
652
+ "writable": true,
653
+ "signer": true
654
+ },
655
+ {
656
+ "name": "config",
657
+ "writable": true,
658
+ "pda": {
659
+ "seeds": [
660
+ {
661
+ "kind": "const",
662
+ "value": [
663
+ 99,
664
+ 111,
665
+ 110,
666
+ 102,
667
+ 105,
668
+ 103
669
+ ]
670
+ }
671
+ ]
672
+ }
673
+ }
674
+ ],
675
+ "args": [
676
+ {
677
+ "name": "platform_treasury",
678
+ "type": "pubkey"
679
+ },
680
+ {
681
+ "name": "buyback_treasury",
682
+ "type": "pubkey"
683
+ }
684
+ ]
685
+ },
686
+ {
687
+ "name": "update_ticket_price",
688
+ "discriminator": [
689
+ 248,
690
+ 105,
691
+ 7,
692
+ 184,
693
+ 173,
694
+ 88,
695
+ 39,
696
+ 242
697
+ ],
698
+ "accounts": [
699
+ {
700
+ "name": "creator",
701
+ "writable": true,
702
+ "signer": true,
703
+ "relations": [
704
+ "listing"
705
+ ]
706
+ },
707
+ {
708
+ "name": "listing",
709
+ "writable": true
710
+ }
711
+ ],
712
+ "args": [
713
+ {
714
+ "name": "ticket_price",
715
+ "type": "u64"
716
+ }
717
+ ]
718
+ }
719
+ ],
720
+ "accounts": [
721
+ {
722
+ "name": "Listing",
723
+ "discriminator": [
724
+ 218,
725
+ 32,
726
+ 50,
727
+ 73,
728
+ 43,
729
+ 134,
730
+ 26,
731
+ 58
732
+ ]
733
+ },
734
+ {
735
+ "name": "ListingVault",
736
+ "discriminator": [
737
+ 23,
738
+ 14,
739
+ 106,
740
+ 31,
741
+ 168,
742
+ 17,
743
+ 92,
744
+ 121
745
+ ]
746
+ },
747
+ {
748
+ "name": "ProtocolConfig",
749
+ "discriminator": [
750
+ 207,
751
+ 91,
752
+ 250,
753
+ 28,
754
+ 152,
755
+ 179,
756
+ 215,
757
+ 209
758
+ ]
759
+ },
760
+ {
761
+ "name": "TicketReceipt",
762
+ "discriminator": [
763
+ 33,
764
+ 39,
765
+ 194,
766
+ 207,
767
+ 210,
768
+ 208,
769
+ 161,
770
+ 103
771
+ ]
772
+ }
773
+ ],
774
+ "events": [
775
+ {
776
+ "name": "TicketPriceUpdated",
777
+ "discriminator": [
778
+ 92,
779
+ 125,
780
+ 96,
781
+ 126,
782
+ 80,
783
+ 77,
784
+ 64,
785
+ 176
786
+ ]
787
+ },
788
+ {
789
+ "name": "TicketPurchased",
790
+ "discriminator": [
791
+ 108,
792
+ 59,
793
+ 246,
794
+ 95,
795
+ 84,
796
+ 145,
797
+ 13,
798
+ 71
799
+ ]
800
+ },
801
+ {
802
+ "name": "TicketRedeemed",
803
+ "discriminator": [
804
+ 251,
805
+ 171,
806
+ 7,
807
+ 57,
808
+ 152,
809
+ 25,
810
+ 168,
811
+ 38
812
+ ]
813
+ }
814
+ ],
815
+ "errors": [
816
+ {
817
+ "code": 6e3,
818
+ "name": "InvalidTicketPrice",
819
+ "msg": "Ticket price must be greater than zero."
820
+ },
821
+ {
822
+ "code": 6001,
823
+ "name": "InvalidListingStatus",
824
+ "msg": "Listing is not in the expected status."
825
+ },
826
+ {
827
+ "code": 6002,
828
+ "name": "IpoNotReady",
829
+ "msg": "IPO revenue threshold not met."
830
+ },
831
+ {
832
+ "code": 6003,
833
+ "name": "InvalidSymbol",
834
+ "msg": "Symbol length exceeds limit."
835
+ },
836
+ {
837
+ "code": 6004,
838
+ "name": "StringTooLong",
839
+ "msg": "String field exceeds max length."
840
+ },
841
+ {
842
+ "code": 6005,
843
+ "name": "MathOverflow",
844
+ "msg": "Math overflow."
845
+ },
846
+ {
847
+ "code": 6006,
848
+ "name": "MissingBump",
849
+ "msg": "Missing bump."
850
+ },
851
+ {
852
+ "code": 6007,
853
+ "name": "NoTicketsAvailable",
854
+ "msg": "No tickets available."
855
+ },
856
+ {
857
+ "code": 6008,
858
+ "name": "InvalidReceipt",
859
+ "msg": "Invalid ticket receipt."
860
+ },
861
+ {
862
+ "code": 6009,
863
+ "name": "Unauthorized",
864
+ "msg": "Unauthorized."
865
+ },
866
+ {
867
+ "code": 6010,
868
+ "name": "InvalidTreasury",
869
+ "msg": "Invalid treasury address."
870
+ },
871
+ {
872
+ "code": 6011,
873
+ "name": "InvalidBuybackBps",
874
+ "msg": "Invalid buyback percentage."
875
+ }
876
+ ],
877
+ "types": [
878
+ {
879
+ "name": "Listing",
880
+ "type": {
881
+ "kind": "struct",
882
+ "fields": [
883
+ {
884
+ "name": "listing_seed",
885
+ "type": {
886
+ "array": [
887
+ "u8",
888
+ 32
889
+ ]
890
+ }
891
+ },
892
+ {
893
+ "name": "creator",
894
+ "type": "pubkey"
895
+ },
896
+ {
897
+ "name": "revenue_wallet",
898
+ "type": "pubkey"
899
+ },
900
+ {
901
+ "name": "listing_type",
902
+ "type": {
903
+ "defined": {
904
+ "name": "ListingType"
905
+ }
906
+ }
907
+ },
908
+ {
909
+ "name": "status",
910
+ "type": {
911
+ "defined": {
912
+ "name": "ListingStatus"
913
+ }
914
+ }
915
+ },
916
+ {
917
+ "name": "name",
918
+ "type": "string"
919
+ },
920
+ {
921
+ "name": "tagline",
922
+ "type": "string"
923
+ },
924
+ {
925
+ "name": "description",
926
+ "type": "string"
927
+ },
928
+ {
929
+ "name": "category",
930
+ "type": "string"
931
+ },
932
+ {
933
+ "name": "image_url",
934
+ "type": "string"
935
+ },
936
+ {
937
+ "name": "product_url",
938
+ "type": "string"
939
+ },
940
+ {
941
+ "name": "endpoint_url",
942
+ "type": "string"
943
+ },
944
+ {
945
+ "name": "manifest_url",
946
+ "type": "string"
947
+ },
948
+ {
949
+ "name": "ticket_price",
950
+ "type": "u64"
951
+ },
952
+ {
953
+ "name": "target_revenue",
954
+ "type": "u64"
955
+ },
956
+ {
957
+ "name": "revenue",
958
+ "type": "u64"
959
+ },
960
+ {
961
+ "name": "tickets_sold",
962
+ "type": "u64"
963
+ },
964
+ {
965
+ "name": "token_mint",
966
+ "type": "pubkey"
967
+ },
968
+ {
969
+ "name": "token_symbol",
970
+ "type": "string"
971
+ },
972
+ {
973
+ "name": "buyback_bps",
974
+ "type": "u16"
975
+ },
976
+ {
977
+ "name": "buyback_total",
978
+ "type": "u64"
979
+ },
980
+ {
981
+ "name": "platform_buyback_total",
982
+ "type": "u64"
983
+ },
984
+ {
985
+ "name": "bump",
986
+ "type": "u8"
987
+ },
988
+ {
989
+ "name": "vault_bump",
990
+ "type": "u8"
991
+ },
992
+ {
993
+ "name": "created_at",
994
+ "type": "i64"
995
+ }
996
+ ]
997
+ }
998
+ },
999
+ {
1000
+ "name": "ListingStatus",
1001
+ "type": {
1002
+ "kind": "enum",
1003
+ "variants": [
1004
+ {
1005
+ "name": "Grind"
1006
+ },
1007
+ {
1008
+ "name": "Ipo"
1009
+ },
1010
+ {
1011
+ "name": "Web2"
1012
+ }
1013
+ ]
1014
+ }
1015
+ },
1016
+ {
1017
+ "name": "ListingType",
1018
+ "type": {
1019
+ "kind": "enum",
1020
+ "variants": [
1021
+ {
1022
+ "name": "Agent"
1023
+ },
1024
+ {
1025
+ "name": "Human"
1026
+ }
1027
+ ]
1028
+ }
1029
+ },
1030
+ {
1031
+ "name": "ListingVault",
1032
+ "type": {
1033
+ "kind": "struct",
1034
+ "fields": []
1035
+ }
1036
+ },
1037
+ {
1038
+ "name": "ProtocolConfig",
1039
+ "type": {
1040
+ "kind": "struct",
1041
+ "fields": [
1042
+ {
1043
+ "name": "authority",
1044
+ "type": "pubkey"
1045
+ },
1046
+ {
1047
+ "name": "platform_treasury",
1048
+ "type": "pubkey"
1049
+ },
1050
+ {
1051
+ "name": "buyback_treasury",
1052
+ "type": "pubkey"
1053
+ },
1054
+ {
1055
+ "name": "bump",
1056
+ "type": "u8"
1057
+ }
1058
+ ]
1059
+ }
1060
+ },
1061
+ {
1062
+ "name": "TicketPriceUpdated",
1063
+ "type": {
1064
+ "kind": "struct",
1065
+ "fields": [
1066
+ {
1067
+ "name": "listing",
1068
+ "type": "pubkey"
1069
+ },
1070
+ {
1071
+ "name": "old_price",
1072
+ "type": "u64"
1073
+ },
1074
+ {
1075
+ "name": "new_price",
1076
+ "type": "u64"
1077
+ },
1078
+ {
1079
+ "name": "timestamp",
1080
+ "type": "i64"
1081
+ }
1082
+ ]
1083
+ }
1084
+ },
1085
+ {
1086
+ "name": "TicketPurchased",
1087
+ "type": {
1088
+ "kind": "struct",
1089
+ "fields": [
1090
+ {
1091
+ "name": "listing",
1092
+ "type": "pubkey"
1093
+ },
1094
+ {
1095
+ "name": "buyer",
1096
+ "type": "pubkey"
1097
+ },
1098
+ {
1099
+ "name": "amount",
1100
+ "type": "u64"
1101
+ },
1102
+ {
1103
+ "name": "creator",
1104
+ "type": "pubkey"
1105
+ },
1106
+ {
1107
+ "name": "platform",
1108
+ "type": "pubkey"
1109
+ },
1110
+ {
1111
+ "name": "creator_amount",
1112
+ "type": "u64"
1113
+ },
1114
+ {
1115
+ "name": "platform_amount",
1116
+ "type": "u64"
1117
+ },
1118
+ {
1119
+ "name": "buyback_amount",
1120
+ "type": "u64"
1121
+ },
1122
+ {
1123
+ "name": "platform_buyback_amount",
1124
+ "type": "u64"
1125
+ },
1126
+ {
1127
+ "name": "status",
1128
+ "type": {
1129
+ "defined": {
1130
+ "name": "ListingStatus"
1131
+ }
1132
+ }
1133
+ },
1134
+ {
1135
+ "name": "remaining",
1136
+ "type": "u64"
1137
+ },
1138
+ {
1139
+ "name": "timestamp",
1140
+ "type": "i64"
1141
+ }
1142
+ ]
1143
+ }
1144
+ },
1145
+ {
1146
+ "name": "TicketReceipt",
1147
+ "type": {
1148
+ "kind": "struct",
1149
+ "fields": [
1150
+ {
1151
+ "name": "listing",
1152
+ "type": "pubkey"
1153
+ },
1154
+ {
1155
+ "name": "buyer",
1156
+ "type": "pubkey"
1157
+ },
1158
+ {
1159
+ "name": "count",
1160
+ "type": "u64"
1161
+ },
1162
+ {
1163
+ "name": "last_purchased_at",
1164
+ "type": "i64"
1165
+ },
1166
+ {
1167
+ "name": "last_redeemed_at",
1168
+ "type": "i64"
1169
+ }
1170
+ ]
1171
+ }
1172
+ },
1173
+ {
1174
+ "name": "TicketRedeemed",
1175
+ "type": {
1176
+ "kind": "struct",
1177
+ "fields": [
1178
+ {
1179
+ "name": "listing",
1180
+ "type": "pubkey"
1181
+ },
1182
+ {
1183
+ "name": "buyer",
1184
+ "type": "pubkey"
1185
+ },
1186
+ {
1187
+ "name": "remaining",
1188
+ "type": "u64"
1189
+ },
1190
+ {
1191
+ "name": "timestamp",
1192
+ "type": "i64"
1193
+ }
1194
+ ]
1195
+ }
1196
+ }
1197
+ ]
1198
+ };
1199
+
1200
+ // src/solana.ts
1201
+ var toPublicKey = (value) => value instanceof PublicKey ? value : new PublicKey(value);
1202
+ var toAnchorWallet = (wallet) => {
1203
+ if ("secretKey" in wallet) {
1204
+ const keypair = wallet;
1205
+ return {
1206
+ publicKey: keypair.publicKey,
1207
+ signTransaction: async (tx) => {
1208
+ if (tx && typeof tx === "object") {
1209
+ const maybeLegacy = tx;
1210
+ const maybeVersioned = tx;
1211
+ if (typeof maybeLegacy.partialSign === "function") {
1212
+ maybeLegacy.partialSign(keypair);
1213
+ } else if (typeof maybeVersioned.sign === "function") {
1214
+ maybeVersioned.sign([keypair]);
1215
+ }
1216
+ }
1217
+ return tx;
1218
+ },
1219
+ signAllTransactions: async (txs) => {
1220
+ txs.forEach((tx) => {
1221
+ if (tx && typeof tx === "object") {
1222
+ const maybeLegacy = tx;
1223
+ const maybeVersioned = tx;
1224
+ if (typeof maybeLegacy.partialSign === "function") {
1225
+ maybeLegacy.partialSign(keypair);
1226
+ } else if (typeof maybeVersioned.sign === "function") {
1227
+ maybeVersioned.sign([keypair]);
1228
+ }
1229
+ }
1230
+ });
1231
+ return txs;
1232
+ }
1233
+ };
1234
+ }
1235
+ const walletLike = wallet;
1236
+ if (typeof walletLike.signAllTransactions !== "function") {
1237
+ return {
1238
+ publicKey: walletLike.publicKey,
1239
+ signTransaction: walletLike.signTransaction,
1240
+ signAllTransactions: async (txs) => {
1241
+ const signed = [];
1242
+ for (const tx of txs) {
1243
+ signed.push(await walletLike.signTransaction(tx));
1244
+ }
1245
+ return signed;
1246
+ }
1247
+ };
1248
+ }
1249
+ return {
1250
+ publicKey: walletLike.publicKey,
1251
+ signTransaction: walletLike.signTransaction,
1252
+ signAllTransactions: walletLike.signAllTransactions
1253
+ };
1254
+ };
1255
+ var toLamports = (sol) => new BN(Math.round(sol * LAMPORTS_PER_SOL));
1256
+ var toSol = (lamports) => Number(lamports) / LAMPORTS_PER_SOL;
1257
+ var deriveListingPda = (creator, seed, programId) => PublicKey.findProgramAddressSync([
1258
+ Buffer.from("listing"),
1259
+ creator.toBuffer(),
1260
+ Buffer.from(seed)
1261
+ ], programId);
1262
+ var deriveTicketReceiptPda = (listing, buyer, programId) => PublicKey.findProgramAddressSync([
1263
+ Buffer.from("ticket"),
1264
+ listing.toBuffer(),
1265
+ buyer.toBuffer()
1266
+ ], programId);
1267
+ var deriveConfigPda = (programId) => PublicKey.findProgramAddressSync([Buffer.from("config")], programId);
1268
+ var fetchSolBalance = async (connection, wallet) => {
1269
+ const pubkey = toPublicKey(wallet);
1270
+ const lamports = await connection.getBalance(pubkey, "confirmed");
1271
+ return toSol(lamports);
1272
+ };
1273
+ var fetchTokenBalance = async (connection, wallet, mint) => {
1274
+ const owner = toPublicKey(wallet);
1275
+ const mintKey = toPublicKey(mint);
1276
+ const response = await connection.getTokenAccountsByOwner(owner, { mint: mintKey });
1277
+ const account = response.value[0];
1278
+ if (!account) return 0;
1279
+ const balance = await connection.getTokenAccountBalance(account.pubkey, "confirmed");
1280
+ return Number(balance.value.uiAmount || 0);
1281
+ };
1282
+ var fetchTokenBalances = async (connection, wallet, mints) => {
1283
+ const owner = toPublicKey(wallet);
1284
+ const results = {};
1285
+ await Promise.all(
1286
+ mints.map(async (mint) => {
1287
+ const mintKey = toPublicKey(mint);
1288
+ const response = await connection.getTokenAccountsByOwner(owner, { mint: mintKey });
1289
+ const account = response.value[0];
1290
+ if (!account) {
1291
+ results[mintKey.toBase58()] = 0;
1292
+ return;
1293
+ }
1294
+ const balance = await connection.getTokenAccountBalance(account.pubkey, "confirmed");
1295
+ results[mintKey.toBase58()] = Number(balance.value.uiAmount || 0);
1296
+ })
1297
+ );
1298
+ return results;
1299
+ };
1300
+ var VibePayments = class {
1301
+ connection;
1302
+ wallet;
1303
+ programId;
1304
+ commitment;
1305
+ constructor(options) {
1306
+ this.connection = options.connection;
1307
+ this.wallet = toAnchorWallet(options.wallet);
1308
+ this.programId = toPublicKey(options.programId);
1309
+ this.commitment = options.commitment || "confirmed";
1310
+ }
1311
+ getProgramId() {
1312
+ return this.programId.toBase58();
1313
+ }
1314
+ getProgram() {
1315
+ const provider = new AnchorProvider(this.connection, this.wallet, {
1316
+ preflightCommitment: this.commitment
1317
+ });
1318
+ return new Program(VIBEIAO_IDL, this.programId, provider);
1319
+ }
1320
+ async fetchProtocolConfig() {
1321
+ const program = this.getProgram();
1322
+ const [config] = deriveConfigPda(this.programId);
1323
+ const data = await program.account.protocolConfig.fetch(config);
1324
+ return {
1325
+ platformTreasury: data.platformTreasury.toBase58(),
1326
+ buybackTreasury: data.buybackTreasury.toBase58()
1327
+ };
1328
+ }
1329
+ getTicketReceiptAddress(listingAccount, buyer) {
1330
+ const listingPubkey = new PublicKey(listingAccount);
1331
+ const buyerKey = buyer ?? this.wallet.publicKey;
1332
+ const [receipt] = deriveTicketReceiptPda(listingPubkey, buyerKey, this.programId);
1333
+ return receipt.toBase58();
1334
+ }
1335
+ async purchaseTicket(input) {
1336
+ const program = this.getProgram();
1337
+ const listingPubkey = new PublicKey(input.listingAccount);
1338
+ const [ticketReceipt] = deriveTicketReceiptPda(listingPubkey, this.wallet.publicKey, this.programId);
1339
+ const [config] = deriveConfigPda(this.programId);
1340
+ let platformTreasury = input.platformTreasury;
1341
+ let buybackTreasury = input.buybackTreasury;
1342
+ if (!platformTreasury || !buybackTreasury) {
1343
+ const protocol = await this.fetchProtocolConfig();
1344
+ platformTreasury = platformTreasury || protocol.platformTreasury;
1345
+ buybackTreasury = buybackTreasury || protocol.buybackTreasury;
1346
+ }
1347
+ if (!platformTreasury || !buybackTreasury) {
1348
+ throw new Error("protocol_config_missing");
1349
+ }
1350
+ return program.methods.purchaseTicket().accounts({
1351
+ buyer: this.wallet.publicKey,
1352
+ listing: listingPubkey,
1353
+ config,
1354
+ creator: new PublicKey(input.creatorWallet),
1355
+ revenueWallet: new PublicKey(input.revenueWallet),
1356
+ platformTreasury: new PublicKey(platformTreasury),
1357
+ buybackTreasury: new PublicKey(buybackTreasury),
1358
+ ticketReceipt,
1359
+ systemProgram: SystemProgram.programId
1360
+ }).rpc();
1361
+ }
1362
+ async purchaseTicketForListing(input) {
1363
+ const listing = input.listing;
1364
+ const listingAccount = listing.chain_listing_account;
1365
+ const creatorWallet = listing.creator_wallet_address;
1366
+ const revenueWallet = listing.revenue_wallet_address || listing.creator_wallet_address;
1367
+ if (!listingAccount) {
1368
+ throw new Error("listing_missing_chain_account");
1369
+ }
1370
+ if (!creatorWallet) {
1371
+ throw new Error("listing_missing_creator_wallet");
1372
+ }
1373
+ if (!revenueWallet) {
1374
+ throw new Error("listing_missing_revenue_wallet");
1375
+ }
1376
+ return this.purchaseTicket({
1377
+ listingAccount,
1378
+ creatorWallet,
1379
+ revenueWallet,
1380
+ platformTreasury: input.platformTreasury,
1381
+ buybackTreasury: input.buybackTreasury
1382
+ });
1383
+ }
1384
+ async redeemTicket(listingAccount) {
1385
+ const program = this.getProgram();
1386
+ const listingPubkey = new PublicKey(listingAccount);
1387
+ const [ticketReceipt] = deriveTicketReceiptPda(listingPubkey, this.wallet.publicKey, this.programId);
1388
+ return program.methods.redeemTicket().accounts({
1389
+ buyer: this.wallet.publicKey,
1390
+ listing: listingPubkey,
1391
+ ticketReceipt
1392
+ }).rpc();
1393
+ }
1394
+ async updateTicketPrice(listingAccount, priceSol) {
1395
+ const program = this.getProgram();
1396
+ const listingPubkey = new PublicKey(listingAccount);
1397
+ const lamports = toLamports(priceSol);
1398
+ return program.methods.updateTicketPrice(lamports).accounts({
1399
+ creator: this.wallet.publicKey,
1400
+ listing: listingPubkey
1401
+ }).rpc();
1402
+ }
1403
+ };
1404
+
1405
+ export {
1406
+ VIBEIAO_IDL,
1407
+ toLamports,
1408
+ toSol,
1409
+ deriveListingPda,
1410
+ deriveTicketReceiptPda,
1411
+ deriveConfigPda,
1412
+ fetchSolBalance,
1413
+ fetchTokenBalance,
1414
+ fetchTokenBalances,
1415
+ VibePayments
1416
+ };