naracli 1.0.17 → 1.0.22
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/README.md +101 -114
- package/bin/nara-cli.ts +0 -20
- package/dist/nara-cli.mjs +49930 -2222
- package/index.ts +10 -58
- package/package.json +7 -6
- package/src/cli/commands/quest.ts +8 -7
- package/src/cli/commands/skills.ts +491 -0
- package/src/cli/commands/skillsInstall.ts +793 -0
- package/src/cli/commands/wallet.ts +13 -114
- package/src/cli/commands/zkid.ts +410 -0
- package/src/cli/index.ts +215 -9
- package/src/cli/prompts/searchMultiselect.ts +297 -0
- package/src/cli/types.ts +0 -138
- package/src/cli/utils/transaction.ts +1 -1
- package/src/cli/utils/validation.ts +0 -40
- package/src/cli/utils/wallet.ts +3 -1
- package/src/tests/helpers.ts +78 -0
- package/src/tests/skills.e2e.test.ts +126 -0
- package/src/tests/skills.test.ts +192 -0
- package/src/tests/test_skill.md +18 -0
- package/src/tests/zkid.e2e.test.ts +128 -0
- package/src/tests/zkid.test.ts +153 -0
- package/src/types/snarkjs.d.ts +4 -1
- package/dist/quest/nara_quest.json +0 -534
- package/dist/zk/answer_proof.wasm +0 -0
- package/dist/zk/answer_proof_final.zkey +0 -0
- package/src/cli/commands/config.ts +0 -125
- package/src/cli/commands/migrate.ts +0 -270
- package/src/cli/commands/pool.ts +0 -364
- package/src/cli/commands/swap.ts +0 -349
- package/src/cli/quest/nara_quest.json +0 -534
- package/src/cli/quest/nara_quest_types.ts +0 -540
- package/src/cli/zk/answer_proof.wasm +0 -0
- package/src/cli/zk/answer_proof_final.zkey +0 -0
- package/src/client.ts +0 -96
- package/src/config.ts +0 -132
- package/src/constants.ts +0 -35
- package/src/migrate.ts +0 -222
- package/src/pool.ts +0 -259
- package/src/quest.ts +0 -387
- package/src/swap.ts +0 -608
|
@@ -1,540 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Program IDL in camelCase format in order to be used in JS/TS.
|
|
3
|
-
*
|
|
4
|
-
* Note that this is only a type helper and is not the actual IDL. The original
|
|
5
|
-
* IDL can be found at `target/idl/nara_quest.json`.
|
|
6
|
-
*/
|
|
7
|
-
export type NaraQuest = {
|
|
8
|
-
"address": "EXPLAHaMHLK9p7w5jVqEVY671NkkCKSHTNhhyUrPAboZ",
|
|
9
|
-
"metadata": {
|
|
10
|
-
"name": "naraQuest",
|
|
11
|
-
"version": "0.1.0",
|
|
12
|
-
"spec": "0.1.0",
|
|
13
|
-
"description": "Created with Anchor"
|
|
14
|
-
},
|
|
15
|
-
"instructions": [
|
|
16
|
-
{
|
|
17
|
-
"name": "createQuestion",
|
|
18
|
-
"discriminator": [
|
|
19
|
-
222,
|
|
20
|
-
74,
|
|
21
|
-
49,
|
|
22
|
-
30,
|
|
23
|
-
160,
|
|
24
|
-
220,
|
|
25
|
-
179,
|
|
26
|
-
27
|
|
27
|
-
],
|
|
28
|
-
"accounts": [
|
|
29
|
-
{
|
|
30
|
-
"name": "gameConfig",
|
|
31
|
-
"writable": true,
|
|
32
|
-
"pda": {
|
|
33
|
-
"seeds": [
|
|
34
|
-
{
|
|
35
|
-
"kind": "const",
|
|
36
|
-
"value": [
|
|
37
|
-
103,
|
|
38
|
-
97,
|
|
39
|
-
109,
|
|
40
|
-
101,
|
|
41
|
-
95,
|
|
42
|
-
99,
|
|
43
|
-
111,
|
|
44
|
-
110,
|
|
45
|
-
102,
|
|
46
|
-
105,
|
|
47
|
-
103
|
|
48
|
-
]
|
|
49
|
-
}
|
|
50
|
-
]
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
"name": "pool",
|
|
55
|
-
"writable": true,
|
|
56
|
-
"pda": {
|
|
57
|
-
"seeds": [
|
|
58
|
-
{
|
|
59
|
-
"kind": "const",
|
|
60
|
-
"value": [
|
|
61
|
-
112,
|
|
62
|
-
111,
|
|
63
|
-
111,
|
|
64
|
-
108
|
|
65
|
-
]
|
|
66
|
-
}
|
|
67
|
-
]
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
"name": "vault",
|
|
72
|
-
"writable": true,
|
|
73
|
-
"pda": {
|
|
74
|
-
"seeds": [
|
|
75
|
-
{
|
|
76
|
-
"kind": "const",
|
|
77
|
-
"value": [
|
|
78
|
-
118,
|
|
79
|
-
97,
|
|
80
|
-
117,
|
|
81
|
-
108,
|
|
82
|
-
116
|
|
83
|
-
]
|
|
84
|
-
}
|
|
85
|
-
]
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
"name": "authority",
|
|
90
|
-
"writable": true,
|
|
91
|
-
"signer": true
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
"name": "systemProgram",
|
|
95
|
-
"address": "11111111111111111111111111111111"
|
|
96
|
-
}
|
|
97
|
-
],
|
|
98
|
-
"args": [
|
|
99
|
-
{
|
|
100
|
-
"name": "question",
|
|
101
|
-
"type": "string"
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
"name": "answerHash",
|
|
105
|
-
"type": {
|
|
106
|
-
"array": [
|
|
107
|
-
"u8",
|
|
108
|
-
32
|
|
109
|
-
]
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
"name": "deadline",
|
|
114
|
-
"type": "i64"
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
"name": "rewardAmount",
|
|
118
|
-
"type": "u64"
|
|
119
|
-
}
|
|
120
|
-
]
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
"name": "initialize",
|
|
124
|
-
"discriminator": [
|
|
125
|
-
175,
|
|
126
|
-
175,
|
|
127
|
-
109,
|
|
128
|
-
31,
|
|
129
|
-
13,
|
|
130
|
-
152,
|
|
131
|
-
155,
|
|
132
|
-
237
|
|
133
|
-
],
|
|
134
|
-
"accounts": [
|
|
135
|
-
{
|
|
136
|
-
"name": "gameConfig",
|
|
137
|
-
"writable": true,
|
|
138
|
-
"pda": {
|
|
139
|
-
"seeds": [
|
|
140
|
-
{
|
|
141
|
-
"kind": "const",
|
|
142
|
-
"value": [
|
|
143
|
-
103,
|
|
144
|
-
97,
|
|
145
|
-
109,
|
|
146
|
-
101,
|
|
147
|
-
95,
|
|
148
|
-
99,
|
|
149
|
-
111,
|
|
150
|
-
110,
|
|
151
|
-
102,
|
|
152
|
-
105,
|
|
153
|
-
103
|
|
154
|
-
]
|
|
155
|
-
}
|
|
156
|
-
]
|
|
157
|
-
}
|
|
158
|
-
},
|
|
159
|
-
{
|
|
160
|
-
"name": "pool",
|
|
161
|
-
"writable": true,
|
|
162
|
-
"pda": {
|
|
163
|
-
"seeds": [
|
|
164
|
-
{
|
|
165
|
-
"kind": "const",
|
|
166
|
-
"value": [
|
|
167
|
-
112,
|
|
168
|
-
111,
|
|
169
|
-
111,
|
|
170
|
-
108
|
|
171
|
-
]
|
|
172
|
-
}
|
|
173
|
-
]
|
|
174
|
-
}
|
|
175
|
-
},
|
|
176
|
-
{
|
|
177
|
-
"name": "authority",
|
|
178
|
-
"writable": true,
|
|
179
|
-
"signer": true
|
|
180
|
-
},
|
|
181
|
-
{
|
|
182
|
-
"name": "systemProgram",
|
|
183
|
-
"address": "11111111111111111111111111111111"
|
|
184
|
-
}
|
|
185
|
-
],
|
|
186
|
-
"args": []
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
"name": "submitAnswer",
|
|
190
|
-
"discriminator": [
|
|
191
|
-
221,
|
|
192
|
-
73,
|
|
193
|
-
184,
|
|
194
|
-
157,
|
|
195
|
-
1,
|
|
196
|
-
150,
|
|
197
|
-
231,
|
|
198
|
-
48
|
|
199
|
-
],
|
|
200
|
-
"accounts": [
|
|
201
|
-
{
|
|
202
|
-
"name": "pool",
|
|
203
|
-
"writable": true,
|
|
204
|
-
"pda": {
|
|
205
|
-
"seeds": [
|
|
206
|
-
{
|
|
207
|
-
"kind": "const",
|
|
208
|
-
"value": [
|
|
209
|
-
112,
|
|
210
|
-
111,
|
|
211
|
-
111,
|
|
212
|
-
108
|
|
213
|
-
]
|
|
214
|
-
}
|
|
215
|
-
]
|
|
216
|
-
}
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
"name": "winnerRecord",
|
|
220
|
-
"writable": true,
|
|
221
|
-
"pda": {
|
|
222
|
-
"seeds": [
|
|
223
|
-
{
|
|
224
|
-
"kind": "const",
|
|
225
|
-
"value": [
|
|
226
|
-
119,
|
|
227
|
-
105,
|
|
228
|
-
110,
|
|
229
|
-
110,
|
|
230
|
-
101,
|
|
231
|
-
114
|
|
232
|
-
]
|
|
233
|
-
},
|
|
234
|
-
{
|
|
235
|
-
"kind": "account",
|
|
236
|
-
"path": "user"
|
|
237
|
-
}
|
|
238
|
-
]
|
|
239
|
-
}
|
|
240
|
-
},
|
|
241
|
-
{
|
|
242
|
-
"name": "vault",
|
|
243
|
-
"writable": true,
|
|
244
|
-
"pda": {
|
|
245
|
-
"seeds": [
|
|
246
|
-
{
|
|
247
|
-
"kind": "const",
|
|
248
|
-
"value": [
|
|
249
|
-
118,
|
|
250
|
-
97,
|
|
251
|
-
117,
|
|
252
|
-
108,
|
|
253
|
-
116
|
|
254
|
-
]
|
|
255
|
-
}
|
|
256
|
-
]
|
|
257
|
-
}
|
|
258
|
-
},
|
|
259
|
-
{
|
|
260
|
-
"name": "user",
|
|
261
|
-
"writable": true
|
|
262
|
-
},
|
|
263
|
-
{
|
|
264
|
-
"name": "payer",
|
|
265
|
-
"writable": true,
|
|
266
|
-
"signer": true
|
|
267
|
-
},
|
|
268
|
-
{
|
|
269
|
-
"name": "systemProgram",
|
|
270
|
-
"address": "11111111111111111111111111111111"
|
|
271
|
-
}
|
|
272
|
-
],
|
|
273
|
-
"args": [
|
|
274
|
-
{
|
|
275
|
-
"name": "proofA",
|
|
276
|
-
"type": {
|
|
277
|
-
"array": [
|
|
278
|
-
"u8",
|
|
279
|
-
64
|
|
280
|
-
]
|
|
281
|
-
}
|
|
282
|
-
},
|
|
283
|
-
{
|
|
284
|
-
"name": "proofB",
|
|
285
|
-
"type": {
|
|
286
|
-
"array": [
|
|
287
|
-
"u8",
|
|
288
|
-
128
|
|
289
|
-
]
|
|
290
|
-
}
|
|
291
|
-
},
|
|
292
|
-
{
|
|
293
|
-
"name": "proofC",
|
|
294
|
-
"type": {
|
|
295
|
-
"array": [
|
|
296
|
-
"u8",
|
|
297
|
-
64
|
|
298
|
-
]
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
]
|
|
302
|
-
},
|
|
303
|
-
{
|
|
304
|
-
"name": "transferAuthority",
|
|
305
|
-
"discriminator": [
|
|
306
|
-
48,
|
|
307
|
-
169,
|
|
308
|
-
76,
|
|
309
|
-
72,
|
|
310
|
-
229,
|
|
311
|
-
180,
|
|
312
|
-
55,
|
|
313
|
-
161
|
|
314
|
-
],
|
|
315
|
-
"accounts": [
|
|
316
|
-
{
|
|
317
|
-
"name": "gameConfig",
|
|
318
|
-
"writable": true,
|
|
319
|
-
"pda": {
|
|
320
|
-
"seeds": [
|
|
321
|
-
{
|
|
322
|
-
"kind": "const",
|
|
323
|
-
"value": [
|
|
324
|
-
103,
|
|
325
|
-
97,
|
|
326
|
-
109,
|
|
327
|
-
101,
|
|
328
|
-
95,
|
|
329
|
-
99,
|
|
330
|
-
111,
|
|
331
|
-
110,
|
|
332
|
-
102,
|
|
333
|
-
105,
|
|
334
|
-
103
|
|
335
|
-
]
|
|
336
|
-
}
|
|
337
|
-
]
|
|
338
|
-
}
|
|
339
|
-
},
|
|
340
|
-
{
|
|
341
|
-
"name": "authority",
|
|
342
|
-
"signer": true
|
|
343
|
-
}
|
|
344
|
-
],
|
|
345
|
-
"args": [
|
|
346
|
-
{
|
|
347
|
-
"name": "newAuthority",
|
|
348
|
-
"type": "pubkey"
|
|
349
|
-
}
|
|
350
|
-
]
|
|
351
|
-
}
|
|
352
|
-
],
|
|
353
|
-
"accounts": [
|
|
354
|
-
{
|
|
355
|
-
"name": "gameConfig",
|
|
356
|
-
"discriminator": [
|
|
357
|
-
45,
|
|
358
|
-
146,
|
|
359
|
-
146,
|
|
360
|
-
33,
|
|
361
|
-
170,
|
|
362
|
-
69,
|
|
363
|
-
96,
|
|
364
|
-
133
|
|
365
|
-
]
|
|
366
|
-
},
|
|
367
|
-
{
|
|
368
|
-
"name": "pool",
|
|
369
|
-
"discriminator": [
|
|
370
|
-
241,
|
|
371
|
-
154,
|
|
372
|
-
109,
|
|
373
|
-
4,
|
|
374
|
-
17,
|
|
375
|
-
177,
|
|
376
|
-
109,
|
|
377
|
-
188
|
|
378
|
-
]
|
|
379
|
-
},
|
|
380
|
-
{
|
|
381
|
-
"name": "winnerRecord",
|
|
382
|
-
"discriminator": [
|
|
383
|
-
248,
|
|
384
|
-
27,
|
|
385
|
-
49,
|
|
386
|
-
33,
|
|
387
|
-
45,
|
|
388
|
-
88,
|
|
389
|
-
210,
|
|
390
|
-
100
|
|
391
|
-
]
|
|
392
|
-
}
|
|
393
|
-
],
|
|
394
|
-
"errors": [
|
|
395
|
-
{
|
|
396
|
-
"code": 6000,
|
|
397
|
-
"name": "unauthorized",
|
|
398
|
-
"msg": "Only the authority can perform this action"
|
|
399
|
-
},
|
|
400
|
-
{
|
|
401
|
-
"code": 6001,
|
|
402
|
-
"name": "poolNotActive",
|
|
403
|
-
"msg": "Pool has no active question"
|
|
404
|
-
},
|
|
405
|
-
{
|
|
406
|
-
"code": 6002,
|
|
407
|
-
"name": "deadlineExpired",
|
|
408
|
-
"msg": "The deadline for this question has passed"
|
|
409
|
-
},
|
|
410
|
-
{
|
|
411
|
-
"code": 6003,
|
|
412
|
-
"name": "invalidProof",
|
|
413
|
-
"msg": "ZK proof verification failed"
|
|
414
|
-
},
|
|
415
|
-
{
|
|
416
|
-
"code": 6004,
|
|
417
|
-
"name": "invalidDeadline",
|
|
418
|
-
"msg": "Deadline must be in the future"
|
|
419
|
-
},
|
|
420
|
-
{
|
|
421
|
-
"code": 6005,
|
|
422
|
-
"name": "insufficientReward",
|
|
423
|
-
"msg": "Reward amount must be greater than zero"
|
|
424
|
-
},
|
|
425
|
-
{
|
|
426
|
-
"code": 6006,
|
|
427
|
-
"name": "insufficientPoolBalance",
|
|
428
|
-
"msg": "Pool balance insufficient for reward transfer"
|
|
429
|
-
},
|
|
430
|
-
{
|
|
431
|
-
"code": 6007,
|
|
432
|
-
"name": "questionTooLong",
|
|
433
|
-
"msg": "Question exceeds maximum length"
|
|
434
|
-
},
|
|
435
|
-
{
|
|
436
|
-
"code": 6008,
|
|
437
|
-
"name": "alreadyAnswered",
|
|
438
|
-
"msg": "Already answered this round"
|
|
439
|
-
}
|
|
440
|
-
],
|
|
441
|
-
"types": [
|
|
442
|
-
{
|
|
443
|
-
"name": "gameConfig",
|
|
444
|
-
"type": {
|
|
445
|
-
"kind": "struct",
|
|
446
|
-
"fields": [
|
|
447
|
-
{
|
|
448
|
-
"name": "authority",
|
|
449
|
-
"type": "pubkey"
|
|
450
|
-
},
|
|
451
|
-
{
|
|
452
|
-
"name": "nextQuestionId",
|
|
453
|
-
"type": "u64"
|
|
454
|
-
},
|
|
455
|
-
{
|
|
456
|
-
"name": "bump",
|
|
457
|
-
"type": "u8"
|
|
458
|
-
}
|
|
459
|
-
]
|
|
460
|
-
}
|
|
461
|
-
},
|
|
462
|
-
{
|
|
463
|
-
"name": "pool",
|
|
464
|
-
"type": {
|
|
465
|
-
"kind": "struct",
|
|
466
|
-
"fields": [
|
|
467
|
-
{
|
|
468
|
-
"name": "round",
|
|
469
|
-
"type": "u64"
|
|
470
|
-
},
|
|
471
|
-
{
|
|
472
|
-
"name": "questionId",
|
|
473
|
-
"type": "u64"
|
|
474
|
-
},
|
|
475
|
-
{
|
|
476
|
-
"name": "question",
|
|
477
|
-
"type": "string"
|
|
478
|
-
},
|
|
479
|
-
{
|
|
480
|
-
"name": "answerHash",
|
|
481
|
-
"type": {
|
|
482
|
-
"array": [
|
|
483
|
-
"u8",
|
|
484
|
-
32
|
|
485
|
-
]
|
|
486
|
-
}
|
|
487
|
-
},
|
|
488
|
-
{
|
|
489
|
-
"name": "deadline",
|
|
490
|
-
"type": "i64"
|
|
491
|
-
},
|
|
492
|
-
{
|
|
493
|
-
"name": "rewardAmount",
|
|
494
|
-
"type": "u64"
|
|
495
|
-
},
|
|
496
|
-
{
|
|
497
|
-
"name": "rewardCount",
|
|
498
|
-
"type": "u32"
|
|
499
|
-
},
|
|
500
|
-
{
|
|
501
|
-
"name": "rewardPerWinner",
|
|
502
|
-
"type": "u64"
|
|
503
|
-
},
|
|
504
|
-
{
|
|
505
|
-
"name": "winnerCount",
|
|
506
|
-
"type": "u32"
|
|
507
|
-
},
|
|
508
|
-
{
|
|
509
|
-
"name": "isActive",
|
|
510
|
-
"type": "bool"
|
|
511
|
-
},
|
|
512
|
-
{
|
|
513
|
-
"name": "bump",
|
|
514
|
-
"type": "u8"
|
|
515
|
-
}
|
|
516
|
-
]
|
|
517
|
-
}
|
|
518
|
-
},
|
|
519
|
-
{
|
|
520
|
-
"name": "winnerRecord",
|
|
521
|
-
"type": {
|
|
522
|
-
"kind": "struct",
|
|
523
|
-
"fields": [
|
|
524
|
-
{
|
|
525
|
-
"name": "bump",
|
|
526
|
-
"type": "u8"
|
|
527
|
-
},
|
|
528
|
-
{
|
|
529
|
-
"name": "round",
|
|
530
|
-
"type": "u64"
|
|
531
|
-
},
|
|
532
|
-
{
|
|
533
|
-
"name": "rewarded",
|
|
534
|
-
"type": "bool"
|
|
535
|
-
}
|
|
536
|
-
]
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
]
|
|
540
|
-
};
|
|
Binary file
|
|
Binary file
|
package/src/client.ts
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Connection,
|
|
3
|
-
PublicKey,
|
|
4
|
-
Transaction,
|
|
5
|
-
AddressLookupTableAccount,
|
|
6
|
-
MessageV0,
|
|
7
|
-
VersionedTransaction,
|
|
8
|
-
} from "@solana/web3.js";
|
|
9
|
-
import { DynamicBondingCurveClient } from "@meteora-ag/dynamic-bonding-curve-sdk";
|
|
10
|
-
|
|
11
|
-
export interface NaraSDKConfig {
|
|
12
|
-
rpcUrl: string;
|
|
13
|
-
commitment?: "processed" | "confirmed" | "finalized";
|
|
14
|
-
/** Address Lookup Table addresses array for compressing transaction size */
|
|
15
|
-
addressLookupTableAddresses?: string[];
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export class NaraSDK {
|
|
19
|
-
private connection: Connection;
|
|
20
|
-
private client: DynamicBondingCurveClient;
|
|
21
|
-
private addressLookupTableAddresses: PublicKey[];
|
|
22
|
-
|
|
23
|
-
constructor(config: NaraSDKConfig) {
|
|
24
|
-
this.connection = new Connection(
|
|
25
|
-
config.rpcUrl,
|
|
26
|
-
config.commitment || "confirmed"
|
|
27
|
-
);
|
|
28
|
-
this.client = new DynamicBondingCurveClient(
|
|
29
|
-
this.connection,
|
|
30
|
-
config.commitment || "confirmed"
|
|
31
|
-
);
|
|
32
|
-
this.addressLookupTableAddresses = (
|
|
33
|
-
config.addressLookupTableAddresses || []
|
|
34
|
-
).map((addr) => new PublicKey(addr));
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
getConnection(): Connection {
|
|
38
|
-
return this.connection;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
getClient(): DynamicBondingCurveClient {
|
|
42
|
-
return this.client;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
getAddressLookupTableAddresses(): PublicKey[] {
|
|
46
|
-
return this.addressLookupTableAddresses;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Compile transaction with Address Lookup Tables
|
|
51
|
-
* Converts Transaction to VersionedTransaction if ALT is configured
|
|
52
|
-
* @param transaction Original transaction
|
|
53
|
-
* @param feePayer Fee payer public key
|
|
54
|
-
* @returns VersionedTransaction or original Transaction
|
|
55
|
-
*/
|
|
56
|
-
async compileTransactionWithALT(
|
|
57
|
-
transaction: Transaction,
|
|
58
|
-
feePayer: PublicKey
|
|
59
|
-
): Promise<Transaction | VersionedTransaction> {
|
|
60
|
-
if (this.addressLookupTableAddresses.length === 0) {
|
|
61
|
-
// No ALT configured, return original transaction
|
|
62
|
-
return transaction;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// Fetch Address Lookup Table accounts
|
|
66
|
-
const lookupTableAccounts: AddressLookupTableAccount[] = [];
|
|
67
|
-
for (const address of this.addressLookupTableAddresses) {
|
|
68
|
-
const accountInfo =
|
|
69
|
-
await this.connection.getAddressLookupTable(address);
|
|
70
|
-
if (accountInfo.value) {
|
|
71
|
-
lookupTableAccounts.push(accountInfo.value);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (lookupTableAccounts.length === 0) {
|
|
76
|
-
// No valid ALT accounts, return original transaction
|
|
77
|
-
return transaction;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Get latest blockhash
|
|
81
|
-
const { blockhash } = await this.connection.getLatestBlockhash(
|
|
82
|
-
this.connection.commitment
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
// Create MessageV0
|
|
86
|
-
const messageV0 = MessageV0.compile({
|
|
87
|
-
payerKey: feePayer,
|
|
88
|
-
instructions: transaction.instructions,
|
|
89
|
-
recentBlockhash: blockhash,
|
|
90
|
-
addressLookupTableAccounts: lookupTableAccounts,
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
// Create VersionedTransaction
|
|
94
|
-
return new VersionedTransaction(messageV0);
|
|
95
|
-
}
|
|
96
|
-
}
|