@paul.lumberwork/bonding-curve-sdk 1.7.2 → 1.8.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/index.js CHANGED
@@ -3,13 +3,1289 @@
3
3
  var anchor = require('@coral-xyz/anchor');
4
4
  var web3_js = require('@solana/web3.js');
5
5
  var splToken = require('@solana/spl-token');
6
- var nacl = require('tweetnacl');
7
6
 
8
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
+ function _interopNamespace(e) {
8
+ if (e && e.__esModule) return e;
9
+ var n = Object.create(null);
10
+ if (e) {
11
+ Object.keys(e).forEach(function (k) {
12
+ if (k !== 'default') {
13
+ var d = Object.getOwnPropertyDescriptor(e, k);
14
+ Object.defineProperty(n, k, d.get ? d : {
15
+ enumerable: true,
16
+ get: function () { return e[k]; }
17
+ });
18
+ }
19
+ });
20
+ }
21
+ n.default = e;
22
+ return Object.freeze(n);
23
+ }
9
24
 
10
- var nacl__default = /*#__PURE__*/_interopDefault(nacl);
25
+ var anchor__namespace = /*#__PURE__*/_interopNamespace(anchor);
11
26
 
12
- // src/sdk/index.ts
27
+ var __getOwnPropNames = Object.getOwnPropertyNames;
28
+ var __commonJS = (cb, mod) => function __require() {
29
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
30
+ };
31
+
32
+ // idl/streamer_program.json
33
+ var require_streamer_program = __commonJS({
34
+ "idl/streamer_program.json"(exports$1, module) {
35
+ module.exports = {
36
+ address: "BZHZ5pSZLi4zRBrCmG1VD65fqKnrPYC2bBb2HQ4VKiJ1",
37
+ metadata: {
38
+ name: "streamer_program",
39
+ version: "0.1.0",
40
+ spec: "0.1.0",
41
+ description: "Streamer Management Program with Ed25519 Signature Verification"
42
+ },
43
+ instructions: [
44
+ {
45
+ name: "add_whitelist",
46
+ docs: [
47
+ "Add a wallet to the whitelist (admin only)"
48
+ ],
49
+ discriminator: [
50
+ 215,
51
+ 46,
52
+ 143,
53
+ 176,
54
+ 108,
55
+ 113,
56
+ 24,
57
+ 1
58
+ ],
59
+ accounts: [
60
+ {
61
+ name: "admin",
62
+ writable: true,
63
+ signer: true
64
+ },
65
+ {
66
+ name: "platform_config",
67
+ pda: {
68
+ seeds: [
69
+ {
70
+ kind: "const",
71
+ value: [
72
+ 112,
73
+ 108,
74
+ 97,
75
+ 116,
76
+ 102,
77
+ 111,
78
+ 114,
79
+ 109,
80
+ 95,
81
+ 99,
82
+ 111,
83
+ 110,
84
+ 102,
85
+ 105,
86
+ 103
87
+ ]
88
+ }
89
+ ]
90
+ }
91
+ },
92
+ {
93
+ name: "whitelist_entry",
94
+ writable: true,
95
+ pda: {
96
+ seeds: [
97
+ {
98
+ kind: "const",
99
+ value: [
100
+ 119,
101
+ 104,
102
+ 105,
103
+ 116,
104
+ 101,
105
+ 108,
106
+ 105,
107
+ 115,
108
+ 116
109
+ ]
110
+ },
111
+ {
112
+ kind: "arg",
113
+ path: "wallet"
114
+ }
115
+ ]
116
+ }
117
+ },
118
+ {
119
+ name: "system_program",
120
+ address: "11111111111111111111111111111111"
121
+ }
122
+ ],
123
+ args: [
124
+ {
125
+ name: "wallet",
126
+ type: "pubkey"
127
+ }
128
+ ]
129
+ },
130
+ {
131
+ name: "claim_funds",
132
+ docs: [
133
+ "Claim SOL/tokens from vault to a registered streamer",
134
+ "Caller must be whitelisted, streamer signs Ed25519 to authorize amounts"
135
+ ],
136
+ discriminator: [
137
+ 145,
138
+ 36,
139
+ 143,
140
+ 242,
141
+ 168,
142
+ 66,
143
+ 200,
144
+ 155
145
+ ],
146
+ accounts: [
147
+ {
148
+ name: "caller",
149
+ docs: [
150
+ "Whitelisted wallet \u2014 tx signer, pays gas (relayer)"
151
+ ],
152
+ writable: true,
153
+ signer: true
154
+ },
155
+ {
156
+ name: "whitelist_entry",
157
+ docs: [
158
+ "Whitelist entry \u2014 caller must be whitelisted"
159
+ ],
160
+ pda: {
161
+ seeds: [
162
+ {
163
+ kind: "const",
164
+ value: [
165
+ 119,
166
+ 104,
167
+ 105,
168
+ 116,
169
+ 101,
170
+ 108,
171
+ 105,
172
+ 115,
173
+ 116
174
+ ]
175
+ },
176
+ {
177
+ kind: "account",
178
+ path: "caller"
179
+ }
180
+ ]
181
+ }
182
+ },
183
+ {
184
+ name: "streamer_registration",
185
+ docs: [
186
+ "Streamer registration \u2014 validates streamer_id + wallet; updated on claim"
187
+ ],
188
+ writable: true,
189
+ pda: {
190
+ seeds: [
191
+ {
192
+ kind: "const",
193
+ value: [
194
+ 115,
195
+ 116,
196
+ 114,
197
+ 101,
198
+ 97,
199
+ 109,
200
+ 101,
201
+ 114
202
+ ]
203
+ },
204
+ {
205
+ kind: "arg",
206
+ path: "streamer_id"
207
+ }
208
+ ]
209
+ }
210
+ },
211
+ {
212
+ name: "streamer_wallet",
213
+ docs: [
214
+ "Streamer wallet \u2014 receives SOL+tokens"
215
+ ],
216
+ writable: true
217
+ },
218
+ {
219
+ name: "vault",
220
+ docs: [
221
+ "Vault PDA holding SOL"
222
+ ],
223
+ writable: true,
224
+ pda: {
225
+ seeds: [
226
+ {
227
+ kind: "const",
228
+ value: [
229
+ 118,
230
+ 97,
231
+ 117,
232
+ 108,
233
+ 116
234
+ ]
235
+ }
236
+ ]
237
+ }
238
+ },
239
+ {
240
+ name: "mint",
241
+ docs: [
242
+ "Token mint"
243
+ ]
244
+ },
245
+ {
246
+ name: "program_token_account",
247
+ docs: [
248
+ "Vault's token account holding tokens (authority = vault PDA)"
249
+ ],
250
+ writable: true,
251
+ pda: {
252
+ seeds: [
253
+ {
254
+ kind: "account",
255
+ path: "vault"
256
+ },
257
+ {
258
+ kind: "const",
259
+ value: [
260
+ 6,
261
+ 221,
262
+ 246,
263
+ 225,
264
+ 215,
265
+ 101,
266
+ 161,
267
+ 147,
268
+ 217,
269
+ 203,
270
+ 225,
271
+ 70,
272
+ 206,
273
+ 235,
274
+ 121,
275
+ 172,
276
+ 28,
277
+ 180,
278
+ 133,
279
+ 237,
280
+ 95,
281
+ 91,
282
+ 55,
283
+ 145,
284
+ 58,
285
+ 140,
286
+ 245,
287
+ 133,
288
+ 126,
289
+ 255,
290
+ 0,
291
+ 169
292
+ ]
293
+ },
294
+ {
295
+ kind: "account",
296
+ path: "mint"
297
+ }
298
+ ],
299
+ program: {
300
+ kind: "const",
301
+ value: [
302
+ 140,
303
+ 151,
304
+ 37,
305
+ 143,
306
+ 78,
307
+ 36,
308
+ 137,
309
+ 241,
310
+ 187,
311
+ 61,
312
+ 16,
313
+ 41,
314
+ 20,
315
+ 142,
316
+ 13,
317
+ 131,
318
+ 11,
319
+ 90,
320
+ 19,
321
+ 153,
322
+ 218,
323
+ 255,
324
+ 16,
325
+ 132,
326
+ 4,
327
+ 142,
328
+ 123,
329
+ 216,
330
+ 219,
331
+ 233,
332
+ 248,
333
+ 89
334
+ ]
335
+ }
336
+ }
337
+ },
338
+ {
339
+ name: "streamer_token_account",
340
+ docs: [
341
+ "Streamer's token account to receive tokens"
342
+ ],
343
+ writable: true,
344
+ pda: {
345
+ seeds: [
346
+ {
347
+ kind: "account",
348
+ path: "streamer_wallet"
349
+ },
350
+ {
351
+ kind: "const",
352
+ value: [
353
+ 6,
354
+ 221,
355
+ 246,
356
+ 225,
357
+ 215,
358
+ 101,
359
+ 161,
360
+ 147,
361
+ 217,
362
+ 203,
363
+ 225,
364
+ 70,
365
+ 206,
366
+ 235,
367
+ 121,
368
+ 172,
369
+ 28,
370
+ 180,
371
+ 133,
372
+ 237,
373
+ 95,
374
+ 91,
375
+ 55,
376
+ 145,
377
+ 58,
378
+ 140,
379
+ 245,
380
+ 133,
381
+ 126,
382
+ 255,
383
+ 0,
384
+ 169
385
+ ]
386
+ },
387
+ {
388
+ kind: "account",
389
+ path: "mint"
390
+ }
391
+ ],
392
+ program: {
393
+ kind: "const",
394
+ value: [
395
+ 140,
396
+ 151,
397
+ 37,
398
+ 143,
399
+ 78,
400
+ 36,
401
+ 137,
402
+ 241,
403
+ 187,
404
+ 61,
405
+ 16,
406
+ 41,
407
+ 20,
408
+ 142,
409
+ 13,
410
+ 131,
411
+ 11,
412
+ 90,
413
+ 19,
414
+ 153,
415
+ 218,
416
+ 255,
417
+ 16,
418
+ 132,
419
+ 4,
420
+ 142,
421
+ 123,
422
+ 216,
423
+ 219,
424
+ 233,
425
+ 248,
426
+ 89
427
+ ]
428
+ }
429
+ }
430
+ },
431
+ {
432
+ name: "instructions_sysvar",
433
+ address: "Sysvar1nstructions1111111111111111111111111"
434
+ },
435
+ {
436
+ name: "system_program",
437
+ address: "11111111111111111111111111111111"
438
+ },
439
+ {
440
+ name: "token_program",
441
+ address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
442
+ },
443
+ {
444
+ name: "associated_token_program",
445
+ address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
446
+ }
447
+ ],
448
+ args: [
449
+ {
450
+ name: "streamer_id",
451
+ type: "string"
452
+ },
453
+ {
454
+ name: "sol_amount",
455
+ type: "u64"
456
+ },
457
+ {
458
+ name: "token_amount",
459
+ type: "u64"
460
+ },
461
+ {
462
+ name: "nonce",
463
+ type: "u64"
464
+ },
465
+ {
466
+ name: "timestamp",
467
+ type: "i64"
468
+ }
469
+ ]
470
+ },
471
+ {
472
+ name: "delete_streamer",
473
+ docs: [
474
+ "Delete a registered streamer (whitelist only)"
475
+ ],
476
+ discriminator: [
477
+ 77,
478
+ 81,
479
+ 2,
480
+ 93,
481
+ 223,
482
+ 43,
483
+ 13,
484
+ 120
485
+ ],
486
+ accounts: [
487
+ {
488
+ name: "caller",
489
+ writable: true,
490
+ signer: true
491
+ },
492
+ {
493
+ name: "platform_config",
494
+ pda: {
495
+ seeds: [
496
+ {
497
+ kind: "const",
498
+ value: [
499
+ 112,
500
+ 108,
501
+ 97,
502
+ 116,
503
+ 102,
504
+ 111,
505
+ 114,
506
+ 109,
507
+ 95,
508
+ 99,
509
+ 111,
510
+ 110,
511
+ 102,
512
+ 105,
513
+ 103
514
+ ]
515
+ }
516
+ ]
517
+ }
518
+ },
519
+ {
520
+ name: "whitelist_entry",
521
+ docs: [
522
+ "Whitelist entry for the caller - must exist and be active"
523
+ ],
524
+ pda: {
525
+ seeds: [
526
+ {
527
+ kind: "const",
528
+ value: [
529
+ 119,
530
+ 104,
531
+ 105,
532
+ 116,
533
+ 101,
534
+ 108,
535
+ 105,
536
+ 115,
537
+ 116
538
+ ]
539
+ },
540
+ {
541
+ kind: "account",
542
+ path: "caller"
543
+ }
544
+ ]
545
+ }
546
+ },
547
+ {
548
+ name: "streamer_registration",
549
+ writable: true,
550
+ pda: {
551
+ seeds: [
552
+ {
553
+ kind: "const",
554
+ value: [
555
+ 115,
556
+ 116,
557
+ 114,
558
+ 101,
559
+ 97,
560
+ 109,
561
+ 101,
562
+ 114
563
+ ]
564
+ },
565
+ {
566
+ kind: "arg",
567
+ path: "streamer_id"
568
+ }
569
+ ]
570
+ }
571
+ },
572
+ {
573
+ name: "system_program",
574
+ address: "11111111111111111111111111111111"
575
+ }
576
+ ],
577
+ args: [
578
+ {
579
+ name: "streamer_id",
580
+ type: "string"
581
+ }
582
+ ]
583
+ },
584
+ {
585
+ name: "initialize_platform",
586
+ docs: [
587
+ "Initialize the platform (one-time setup by admin)"
588
+ ],
589
+ discriminator: [
590
+ 119,
591
+ 201,
592
+ 101,
593
+ 45,
594
+ 75,
595
+ 122,
596
+ 89,
597
+ 3
598
+ ],
599
+ accounts: [
600
+ {
601
+ name: "admin",
602
+ writable: true,
603
+ signer: true
604
+ },
605
+ {
606
+ name: "platform_config",
607
+ writable: true,
608
+ pda: {
609
+ seeds: [
610
+ {
611
+ kind: "const",
612
+ value: [
613
+ 112,
614
+ 108,
615
+ 97,
616
+ 116,
617
+ 102,
618
+ 111,
619
+ 114,
620
+ 109,
621
+ 95,
622
+ 99,
623
+ 111,
624
+ 110,
625
+ 102,
626
+ 105,
627
+ 103
628
+ ]
629
+ }
630
+ ]
631
+ }
632
+ },
633
+ {
634
+ name: "system_program",
635
+ address: "11111111111111111111111111111111"
636
+ }
637
+ ],
638
+ args: []
639
+ },
640
+ {
641
+ name: "register_streamer",
642
+ docs: [
643
+ "Register a streamer with Ed25519 signature verification (whitelist only)"
644
+ ],
645
+ discriminator: [
646
+ 228,
647
+ 216,
648
+ 173,
649
+ 237,
650
+ 216,
651
+ 202,
652
+ 48,
653
+ 59
654
+ ],
655
+ accounts: [
656
+ {
657
+ name: "caller",
658
+ writable: true,
659
+ signer: true
660
+ },
661
+ {
662
+ name: "platform_config",
663
+ pda: {
664
+ seeds: [
665
+ {
666
+ kind: "const",
667
+ value: [
668
+ 112,
669
+ 108,
670
+ 97,
671
+ 116,
672
+ 102,
673
+ 111,
674
+ 114,
675
+ 109,
676
+ 95,
677
+ 99,
678
+ 111,
679
+ 110,
680
+ 102,
681
+ 105,
682
+ 103
683
+ ]
684
+ }
685
+ ]
686
+ }
687
+ },
688
+ {
689
+ name: "whitelist_entry",
690
+ docs: [
691
+ "Whitelist entry for the caller - must exist and be active"
692
+ ],
693
+ pda: {
694
+ seeds: [
695
+ {
696
+ kind: "const",
697
+ value: [
698
+ 119,
699
+ 104,
700
+ 105,
701
+ 116,
702
+ 101,
703
+ 108,
704
+ 105,
705
+ 115,
706
+ 116
707
+ ]
708
+ },
709
+ {
710
+ kind: "account",
711
+ path: "caller"
712
+ }
713
+ ]
714
+ }
715
+ },
716
+ {
717
+ name: "streamer_registration",
718
+ writable: true,
719
+ pda: {
720
+ seeds: [
721
+ {
722
+ kind: "const",
723
+ value: [
724
+ 115,
725
+ 116,
726
+ 114,
727
+ 101,
728
+ 97,
729
+ 109,
730
+ 101,
731
+ 114
732
+ ]
733
+ },
734
+ {
735
+ kind: "arg",
736
+ path: "streamer_id"
737
+ }
738
+ ]
739
+ }
740
+ },
741
+ {
742
+ name: "instructions_sysvar",
743
+ address: "Sysvar1nstructions1111111111111111111111111"
744
+ },
745
+ {
746
+ name: "system_program",
747
+ address: "11111111111111111111111111111111"
748
+ }
749
+ ],
750
+ args: [
751
+ {
752
+ name: "streamer_id",
753
+ type: "string"
754
+ },
755
+ {
756
+ name: "streamer_wallet",
757
+ type: "pubkey"
758
+ },
759
+ {
760
+ name: "timestamp",
761
+ type: "i64"
762
+ }
763
+ ]
764
+ },
765
+ {
766
+ name: "remove_whitelist",
767
+ docs: [
768
+ "Remove a wallet from the whitelist (admin only)"
769
+ ],
770
+ discriminator: [
771
+ 148,
772
+ 244,
773
+ 73,
774
+ 234,
775
+ 131,
776
+ 55,
777
+ 247,
778
+ 90
779
+ ],
780
+ accounts: [
781
+ {
782
+ name: "admin",
783
+ writable: true,
784
+ signer: true
785
+ },
786
+ {
787
+ name: "platform_config",
788
+ pda: {
789
+ seeds: [
790
+ {
791
+ kind: "const",
792
+ value: [
793
+ 112,
794
+ 108,
795
+ 97,
796
+ 116,
797
+ 102,
798
+ 111,
799
+ 114,
800
+ 109,
801
+ 95,
802
+ 99,
803
+ 111,
804
+ 110,
805
+ 102,
806
+ 105,
807
+ 103
808
+ ]
809
+ }
810
+ ]
811
+ }
812
+ },
813
+ {
814
+ name: "whitelist_entry",
815
+ writable: true,
816
+ pda: {
817
+ seeds: [
818
+ {
819
+ kind: "const",
820
+ value: [
821
+ 119,
822
+ 104,
823
+ 105,
824
+ 116,
825
+ 101,
826
+ 108,
827
+ 105,
828
+ 115,
829
+ 116
830
+ ]
831
+ },
832
+ {
833
+ kind: "account",
834
+ path: "whitelist_entry.wallet",
835
+ account: "WhitelistEntry"
836
+ }
837
+ ]
838
+ }
839
+ },
840
+ {
841
+ name: "system_program",
842
+ address: "11111111111111111111111111111111"
843
+ }
844
+ ],
845
+ args: []
846
+ }
847
+ ],
848
+ accounts: [
849
+ {
850
+ name: "PlatformConfig",
851
+ discriminator: [
852
+ 160,
853
+ 78,
854
+ 128,
855
+ 0,
856
+ 248,
857
+ 83,
858
+ 230,
859
+ 160
860
+ ]
861
+ },
862
+ {
863
+ name: "StreamerRegistration",
864
+ discriminator: [
865
+ 215,
866
+ 11,
867
+ 122,
868
+ 169,
869
+ 47,
870
+ 13,
871
+ 145,
872
+ 179
873
+ ]
874
+ },
875
+ {
876
+ name: "WhitelistEntry",
877
+ discriminator: [
878
+ 51,
879
+ 70,
880
+ 173,
881
+ 81,
882
+ 219,
883
+ 192,
884
+ 234,
885
+ 62
886
+ ]
887
+ }
888
+ ],
889
+ events: [
890
+ {
891
+ name: "StreamerClaim",
892
+ discriminator: [
893
+ 111,
894
+ 131,
895
+ 155,
896
+ 100,
897
+ 154,
898
+ 243,
899
+ 78,
900
+ 224
901
+ ]
902
+ },
903
+ {
904
+ name: "StreamerDeleted",
905
+ discriminator: [
906
+ 93,
907
+ 21,
908
+ 157,
909
+ 7,
910
+ 69,
911
+ 5,
912
+ 248,
913
+ 209
914
+ ]
915
+ },
916
+ {
917
+ name: "StreamerRegistered",
918
+ discriminator: [
919
+ 250,
920
+ 238,
921
+ 67,
922
+ 213,
923
+ 160,
924
+ 156,
925
+ 240,
926
+ 105
927
+ ]
928
+ },
929
+ {
930
+ name: "WhitelistAdded",
931
+ discriminator: [
932
+ 97,
933
+ 233,
934
+ 173,
935
+ 159,
936
+ 42,
937
+ 22,
938
+ 108,
939
+ 250
940
+ ]
941
+ },
942
+ {
943
+ name: "WhitelistRemoved",
944
+ discriminator: [
945
+ 57,
946
+ 55,
947
+ 186,
948
+ 142,
949
+ 33,
950
+ 197,
951
+ 220,
952
+ 71
953
+ ]
954
+ }
955
+ ],
956
+ errors: [
957
+ {
958
+ code: 6e3,
959
+ name: "Unauthorized",
960
+ msg: "Unauthorized: caller is not admin"
961
+ },
962
+ {
963
+ code: 6001,
964
+ name: "AlreadyRegistered",
965
+ msg: "Streamer is already registered"
966
+ },
967
+ {
968
+ code: 6002,
969
+ name: "StreamerNotFound",
970
+ msg: "Streamer not found"
971
+ },
972
+ {
973
+ code: 6003,
974
+ name: "InvalidSignature",
975
+ msg: "Invalid Ed25519 signature"
976
+ },
977
+ {
978
+ code: 6004,
979
+ name: "SignatureExpired",
980
+ msg: "Signature has expired (timestamp > 1 hour old)"
981
+ },
982
+ {
983
+ code: 6005,
984
+ name: "InvalidMessage",
985
+ msg: "Signature message does not match expected format"
986
+ },
987
+ {
988
+ code: 6006,
989
+ name: "WalletMismatch",
990
+ msg: "Wallet in signature does not match expected wallet"
991
+ },
992
+ {
993
+ code: 6007,
994
+ name: "InsufficientFunds",
995
+ msg: "Insufficient funds in vault"
996
+ },
997
+ {
998
+ code: 6008,
999
+ name: "WhitelistAlreadyExists",
1000
+ msg: "Wallet is already whitelisted"
1001
+ },
1002
+ {
1003
+ code: 6009,
1004
+ name: "WhitelistNotFound",
1005
+ msg: "Wallet is not in whitelist"
1006
+ },
1007
+ {
1008
+ code: 6010,
1009
+ name: "InvalidTimestamp",
1010
+ msg: "Invalid timestamp"
1011
+ },
1012
+ {
1013
+ code: 6011,
1014
+ name: "Ed25519InstructionMissing",
1015
+ msg: "Ed25519 instruction not found in transaction"
1016
+ },
1017
+ {
1018
+ code: 6012,
1019
+ name: "InvalidEd25519Data",
1020
+ msg: "Invalid Ed25519 instruction data"
1021
+ },
1022
+ {
1023
+ code: 6013,
1024
+ name: "InvalidStreamerId",
1025
+ msg: "Streamer ID cannot be empty"
1026
+ },
1027
+ {
1028
+ code: 6014,
1029
+ name: "ClaimCooldownNotElapsed",
1030
+ msg: "Claim cooldown not elapsed (minimum 60 seconds between claims)"
1031
+ },
1032
+ {
1033
+ code: 6015,
1034
+ name: "InvalidNonce",
1035
+ msg: "Invalid claim nonce \u2014 possible replay attack"
1036
+ }
1037
+ ],
1038
+ types: [
1039
+ {
1040
+ name: "PlatformConfig",
1041
+ type: {
1042
+ kind: "struct",
1043
+ fields: [
1044
+ {
1045
+ name: "admin",
1046
+ docs: [
1047
+ "Admin wallet that can manage whitelist and withdraw funds"
1048
+ ],
1049
+ type: "pubkey"
1050
+ },
1051
+ {
1052
+ name: "bump",
1053
+ docs: [
1054
+ "PDA bump seed"
1055
+ ],
1056
+ type: "u8"
1057
+ }
1058
+ ]
1059
+ }
1060
+ },
1061
+ {
1062
+ name: "StreamerClaim",
1063
+ type: {
1064
+ kind: "struct",
1065
+ fields: [
1066
+ {
1067
+ name: "streamer_id",
1068
+ type: "string"
1069
+ },
1070
+ {
1071
+ name: "wallet",
1072
+ type: "pubkey"
1073
+ },
1074
+ {
1075
+ name: "mint",
1076
+ type: "pubkey"
1077
+ },
1078
+ {
1079
+ name: "sol_amount",
1080
+ type: "u64"
1081
+ },
1082
+ {
1083
+ name: "token_amount",
1084
+ type: "u64"
1085
+ },
1086
+ {
1087
+ name: "claimed_by",
1088
+ type: "pubkey"
1089
+ },
1090
+ {
1091
+ name: "timestamp",
1092
+ type: "i64"
1093
+ }
1094
+ ]
1095
+ }
1096
+ },
1097
+ {
1098
+ name: "StreamerDeleted",
1099
+ type: {
1100
+ kind: "struct",
1101
+ fields: [
1102
+ {
1103
+ name: "streamer_id",
1104
+ type: "string"
1105
+ },
1106
+ {
1107
+ name: "wallet",
1108
+ type: "pubkey"
1109
+ },
1110
+ {
1111
+ name: "deleted_by",
1112
+ type: "pubkey"
1113
+ },
1114
+ {
1115
+ name: "timestamp",
1116
+ type: "i64"
1117
+ }
1118
+ ]
1119
+ }
1120
+ },
1121
+ {
1122
+ name: "StreamerRegistered",
1123
+ type: {
1124
+ kind: "struct",
1125
+ fields: [
1126
+ {
1127
+ name: "streamer_id",
1128
+ type: "string"
1129
+ },
1130
+ {
1131
+ name: "wallet",
1132
+ type: "pubkey"
1133
+ },
1134
+ {
1135
+ name: "registered_by",
1136
+ type: "pubkey"
1137
+ },
1138
+ {
1139
+ name: "timestamp",
1140
+ type: "i64"
1141
+ }
1142
+ ]
1143
+ }
1144
+ },
1145
+ {
1146
+ name: "StreamerRegistration",
1147
+ type: {
1148
+ kind: "struct",
1149
+ fields: [
1150
+ {
1151
+ name: "streamer_id",
1152
+ docs: [
1153
+ "Unique streamer identifier"
1154
+ ],
1155
+ type: "string"
1156
+ },
1157
+ {
1158
+ name: "wallet",
1159
+ docs: [
1160
+ "Streamer's wallet public key"
1161
+ ],
1162
+ type: "pubkey"
1163
+ },
1164
+ {
1165
+ name: "verified_at",
1166
+ docs: [
1167
+ "On-chain clock timestamp when signature was verified"
1168
+ ],
1169
+ type: "i64"
1170
+ },
1171
+ {
1172
+ name: "registered_by",
1173
+ docs: [
1174
+ "Whitelisted wallet that performed the registration"
1175
+ ],
1176
+ type: "pubkey"
1177
+ },
1178
+ {
1179
+ name: "created_at",
1180
+ docs: [
1181
+ "Account creation timestamp"
1182
+ ],
1183
+ type: "i64"
1184
+ },
1185
+ {
1186
+ name: "claim_nonce",
1187
+ docs: [
1188
+ "Monotonically increasing counter \u2014 included in claim message to prevent replay"
1189
+ ],
1190
+ type: "u64"
1191
+ },
1192
+ {
1193
+ name: "last_claim_at",
1194
+ docs: [
1195
+ "Unix timestamp of last successful claim (0 if never claimed)"
1196
+ ],
1197
+ type: "i64"
1198
+ },
1199
+ {
1200
+ name: "bump",
1201
+ docs: [
1202
+ "PDA bump seed"
1203
+ ],
1204
+ type: "u8"
1205
+ }
1206
+ ]
1207
+ }
1208
+ },
1209
+ {
1210
+ name: "WhitelistAdded",
1211
+ type: {
1212
+ kind: "struct",
1213
+ fields: [
1214
+ {
1215
+ name: "wallet",
1216
+ type: "pubkey"
1217
+ },
1218
+ {
1219
+ name: "added_by",
1220
+ type: "pubkey"
1221
+ },
1222
+ {
1223
+ name: "timestamp",
1224
+ type: "i64"
1225
+ }
1226
+ ]
1227
+ }
1228
+ },
1229
+ {
1230
+ name: "WhitelistEntry",
1231
+ type: {
1232
+ kind: "struct",
1233
+ fields: [
1234
+ {
1235
+ name: "wallet",
1236
+ docs: [
1237
+ "The whitelisted wallet address"
1238
+ ],
1239
+ type: "pubkey"
1240
+ },
1241
+ {
1242
+ name: "active",
1243
+ docs: [
1244
+ "Whether this entry is active"
1245
+ ],
1246
+ type: "bool"
1247
+ },
1248
+ {
1249
+ name: "added_at",
1250
+ docs: [
1251
+ "Timestamp when added to whitelist"
1252
+ ],
1253
+ type: "i64"
1254
+ },
1255
+ {
1256
+ name: "bump",
1257
+ docs: [
1258
+ "PDA bump seed"
1259
+ ],
1260
+ type: "u8"
1261
+ }
1262
+ ]
1263
+ }
1264
+ },
1265
+ {
1266
+ name: "WhitelistRemoved",
1267
+ type: {
1268
+ kind: "struct",
1269
+ fields: [
1270
+ {
1271
+ name: "wallet",
1272
+ type: "pubkey"
1273
+ },
1274
+ {
1275
+ name: "removed_by",
1276
+ type: "pubkey"
1277
+ },
1278
+ {
1279
+ name: "timestamp",
1280
+ type: "i64"
1281
+ }
1282
+ ]
1283
+ }
1284
+ }
1285
+ ]
1286
+ };
1287
+ }
1288
+ });
13
1289
  var PROGRAM_ID = new web3_js.PublicKey("6o7oTqg2CfvcMCJTLNEJsef7c875zGpTvcnFctNAjudL");
14
1290
  var ADMIN_WALLET = new web3_js.PublicKey("7eGpbyRpcM7WpNKQtd6XkteNQWHbWXP7icZjKzNK2aTk");
15
1291
  var METADATA_PROGRAM_ID = new web3_js.PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s");
@@ -639,7 +1915,7 @@ var KickFunSDK = class {
639
1915
  return numerator / denominator;
640
1916
  }
641
1917
  };
642
- var StreamerSDK = class _StreamerSDK {
1918
+ var StreamerSDK = class {
643
1919
  constructor(program, wallet) {
644
1920
  this.program = program;
645
1921
  this.connection = program.provider.connection;
@@ -702,10 +1978,10 @@ var StreamerSDK = class _StreamerSDK {
702
1978
  * Build the message that the streamer must sign for claim_funds.
703
1979
  * The streamer signs this with their wallet (e.g. Phantom signMessage).
704
1980
  *
705
- * Format: "claim_funds:{streamer_id}:{wallet}:{mint}:{token_amount}:{sol_amount}:{timestamp}"
1981
+ * Format: "claim_funds:{streamer_id}:{wallet}:{mint}:{token_amount}:{sol_amount}:{nonce}:{timestamp}"
706
1982
  */
707
- buildClaimMessage(streamerId, streamerWallet, mint, tokenAmount, solAmount, timestamp) {
708
- const msg = `claim_funds:${streamerId}:${streamerWallet.toBase58()}:${mint.toBase58()}:${tokenAmount.toString()}:${solAmount.toString()}:${timestamp}`;
1983
+ buildClaimMessage(streamerId, streamerWallet, mint, tokenAmount, solAmount, nonce, timestamp) {
1984
+ const msg = `claim_funds:${streamerId}:${streamerWallet.toBase58()}:${mint.toBase58()}:${tokenAmount.toString()}:${solAmount.toString()}:${nonce.toString()}:${timestamp}`;
709
1985
  return Buffer.from(msg, "utf-8");
710
1986
  }
711
1987
  /**
@@ -724,81 +2000,10 @@ var StreamerSDK = class _StreamerSDK {
724
2000
  signature
725
2001
  });
726
2002
  }
727
- /**
728
- * Sign a message using a Keypair directly (server-side / test usage).
729
- * Returns the Ed25519 signature bytes.
730
- */
731
- static signMessage(message, keypair) {
732
- return nacl__default.default.sign.detached(message, keypair.secretKey);
733
- }
734
2003
  // ═══════════════════════════════════════════════════════════════════════════
735
2004
  // Register Streamer
736
2005
  // ═══════════════════════════════════════════════════════════════════════════
737
2006
  async registerStreamer(params) {
738
- const { streamerId, streamerKeypair } = params;
739
- const timestamp = await this.getSolanaTimestamp();
740
- const msgBytes = this.buildRegisterMessage(streamerId, streamerKeypair.publicKey, timestamp);
741
- const sig = _StreamerSDK.signMessage(msgBytes, streamerKeypair);
742
- const ed25519Ix = this.createEd25519Instruction(streamerKeypair.publicKey, msgBytes, sig);
743
- const whitelistPda = this.deriveWhitelistEntry(this.wallet.publicKey);
744
- const streamerRegPda = this.deriveStreamerRegistration(streamerId);
745
- const registerIx = await this.program.methods.registerStreamer(
746
- streamerId,
747
- streamerKeypair.publicKey,
748
- new anchor.BN(timestamp)
749
- ).accounts({
750
- caller: this.wallet.publicKey,
751
- whitelistEntry: whitelistPda,
752
- streamerRegistration: streamerRegPda,
753
- instructionsSysvar: web3_js.SYSVAR_INSTRUCTIONS_PUBKEY
754
- }).instruction();
755
- const tx = new web3_js.Transaction().add(ed25519Ix).add(registerIx);
756
- const provider = this.program.provider;
757
- const txSignature = await provider.sendAndConfirm(tx);
758
- return { txSignature, streamerRegistrationPda: streamerRegPda };
759
- }
760
- // ═══════════════════════════════════════════════════════════════════════════
761
- // Claim Funds
762
- // ═══════════════════════════════════════════════════════════════════════════
763
- async claimFunds(params) {
764
- const { streamerId, streamerKeypair, mint, solAmount, tokenAmount } = params;
765
- const timestamp = await this.getSolanaTimestamp();
766
- const msgBytes = this.buildClaimMessage(streamerId, streamerKeypair.publicKey, mint, tokenAmount, solAmount, timestamp);
767
- const sig = _StreamerSDK.signMessage(msgBytes, streamerKeypair);
768
- const ed25519Ix = this.createEd25519Instruction(streamerKeypair.publicKey, msgBytes, sig);
769
- const whitelistPda = this.deriveWhitelistEntry(this.wallet.publicKey);
770
- const streamerRegPda = this.deriveStreamerRegistration(streamerId);
771
- const vaultPda = this.deriveVault();
772
- const programTokenAccount = splToken.getAssociatedTokenAddressSync(
773
- mint,
774
- vaultPda,
775
- true
776
- );
777
- const streamerTokenAccount = splToken.getAssociatedTokenAddressSync(
778
- mint,
779
- streamerKeypair.publicKey,
780
- false
781
- );
782
- const claimIx = await this.program.methods.claimFunds(streamerId, solAmount, tokenAmount, new anchor.BN(timestamp)).accounts({
783
- caller: this.wallet.publicKey,
784
- whitelistEntry: whitelistPda,
785
- streamerRegistration: streamerRegPda,
786
- streamerWallet: streamerKeypair.publicKey,
787
- vault: vaultPda,
788
- mint,
789
- programTokenAccount,
790
- streamerTokenAccount,
791
- instructionsSysvar: web3_js.SYSVAR_INSTRUCTIONS_PUBKEY
792
- }).instruction();
793
- const tx = new web3_js.Transaction().add(ed25519Ix).add(claimIx);
794
- const provider = this.program.provider;
795
- const txSignature = await provider.sendAndConfirm(tx);
796
- return { txSignature };
797
- }
798
- // ═══════════════════════════════════════════════════════════════════════════
799
- // Register Streamer (browser wallet — signature from Phantom/Solflare)
800
- // ═══════════════════════════════════════════════════════════════════════════
801
- async registerStreamerWithSignature(params) {
802
2007
  const { streamerId, streamerPublicKey, signature, timestamp } = params;
803
2008
  const msgBytes = this.buildRegisterMessage(streamerId, streamerPublicKey, timestamp);
804
2009
  const ed25519Ix = this.createEd25519Instruction(streamerPublicKey, msgBytes, signature);
@@ -816,18 +2021,18 @@ var StreamerSDK = class _StreamerSDK {
816
2021
  return { txSignature, streamerRegistrationPda: streamerRegPda };
817
2022
  }
818
2023
  // ═══════════════════════════════════════════════════════════════════════════
819
- // Claim Funds (browser wallet — signature from Phantom/Solflare)
2024
+ // Claim Funds
820
2025
  // ═══════════════════════════════════════════════════════════════════════════
821
- async claimFundsWithSignature(params) {
822
- const { streamerId, streamerPublicKey, mint, solAmount, tokenAmount, signature, timestamp } = params;
823
- const msgBytes = this.buildClaimMessage(streamerId, streamerPublicKey, mint, tokenAmount, solAmount, timestamp);
2026
+ async claimFunds(params) {
2027
+ const { streamerId, streamerPublicKey, mint, solAmount, tokenAmount, nonce, signature, timestamp } = params;
2028
+ const msgBytes = this.buildClaimMessage(streamerId, streamerPublicKey, mint, tokenAmount, solAmount, nonce, timestamp);
824
2029
  const ed25519Ix = this.createEd25519Instruction(streamerPublicKey, msgBytes, signature);
825
2030
  const whitelistPda = this.deriveWhitelistEntry(this.wallet.publicKey);
826
2031
  const streamerRegPda = this.deriveStreamerRegistration(streamerId);
827
2032
  const vaultPda = this.deriveVault();
828
2033
  const programTokenAccount = splToken.getAssociatedTokenAddressSync(mint, vaultPda, true);
829
2034
  const streamerTokenAccount = splToken.getAssociatedTokenAddressSync(mint, streamerPublicKey, false);
830
- const claimIx = await this.program.methods.claimFunds(streamerId, solAmount, tokenAmount, new anchor.BN(timestamp)).accounts({
2035
+ const claimIx = await this.program.methods.claimFunds(streamerId, solAmount, tokenAmount, nonce, new anchor.BN(timestamp)).accounts({
831
2036
  caller: this.wallet.publicKey,
832
2037
  whitelistEntry: whitelistPda,
833
2038
  streamerRegistration: streamerRegPda,
@@ -855,7 +2060,9 @@ var StreamerSDK = class _StreamerSDK {
855
2060
  wallet: account.wallet,
856
2061
  verifiedAt: account.verifiedAt.toNumber(),
857
2062
  registeredBy: account.registeredBy,
858
- createdAt: account.createdAt.toNumber()
2063
+ createdAt: account.createdAt.toNumber(),
2064
+ claimNonce: account.claimNonce.toNumber(),
2065
+ lastClaimAt: account.lastClaimAt.toNumber()
859
2066
  };
860
2067
  } catch {
861
2068
  return null;
@@ -899,6 +2106,12 @@ function parseSol(sol) {
899
2106
  function parseTokens(tokens) {
900
2107
  return BigInt(Math.floor(tokens * 10 ** TOKEN_DECIMALS));
901
2108
  }
2109
+ var STREAMER_IDL = require_streamer_program();
2110
+ function createStreamerSDK(connection, wallet) {
2111
+ const provider = new anchor__namespace.AnchorProvider(connection, wallet, { commitment: "confirmed" });
2112
+ const program = new anchor__namespace.Program(STREAMER_IDL, provider);
2113
+ return new StreamerSDK(program, wallet);
2114
+ }
902
2115
 
903
2116
  exports.ADMIN_WALLET = ADMIN_WALLET;
904
2117
  exports.CURVE_PERCENT = CURVE_PERCENT;
@@ -913,6 +2126,7 @@ exports.STREAMER_PROGRAM_ID = STREAMER_PROGRAM_ID;
913
2126
  exports.StreamerSDK = StreamerSDK;
914
2127
  exports.TOKEN_DECIMALS = TOKEN_DECIMALS;
915
2128
  exports.TREASURY_PERCENT = TREASURY_PERCENT;
2129
+ exports.createStreamerSDK = createStreamerSDK;
916
2130
  exports.formatSol = formatSol;
917
2131
  exports.formatTokens = formatTokens;
918
2132
  exports.parseSol = parseSol;