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