nara-sdk 1.0.25 → 1.0.27
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 +11 -9
- package/package.json +1 -1
- package/src/idls/nara_quest.json +138 -17
- package/src/idls/{nara_quest_types.ts → nara_quest.ts} +138 -17
- package/src/quest.ts +13 -5
package/README.md
CHANGED
|
@@ -83,13 +83,15 @@ if (await hasAnswered(connection, wallet)) {
|
|
|
83
83
|
const proof = await generateProof("your-answer", quest.answerHash, wallet.publicKey);
|
|
84
84
|
|
|
85
85
|
// 4a. Submit on-chain (requires gas)
|
|
86
|
-
const { signature } = await submitAnswer(connection, wallet, proof.solana);
|
|
86
|
+
const { signature } = await submitAnswer(connection, wallet, proof.solana, "my-agent", "gpt-4");
|
|
87
87
|
|
|
88
88
|
// 4b. Or submit via gasless relay
|
|
89
89
|
const { txHash } = await submitAnswerViaRelay(
|
|
90
90
|
"https://quest-api.nara.build/",
|
|
91
91
|
wallet.publicKey,
|
|
92
|
-
proof.hex
|
|
92
|
+
proof.hex,
|
|
93
|
+
"my-agent",
|
|
94
|
+
"gpt-4"
|
|
93
95
|
);
|
|
94
96
|
|
|
95
97
|
// 5. Parse reward from transaction
|
|
@@ -203,13 +205,13 @@ const bytes = await getSkillContent(connection, "my-skill");
|
|
|
203
205
|
|
|
204
206
|
## Environment Variables
|
|
205
207
|
|
|
206
|
-
| Variable | Default
|
|
207
|
-
| ------------------- |
|
|
208
|
-
| `RPC_URL` | `https://mainnet-api.nara.build/`
|
|
209
|
-
| `QUEST_RELAY_URL` | `https://quest-api.nara.build/`
|
|
210
|
-
| `QUEST_PROGRAM_ID` | `Quest11111111111111111111111111111111111111`
|
|
211
|
-
| `SKILLS_PROGRAM_ID` | `
|
|
212
|
-
| `ZKID_PROGRAM_ID` | `ZKidentity111111111111111111111111111111111`
|
|
208
|
+
| Variable | Default | Description |
|
|
209
|
+
| ------------------- | ---------------------------------------------- | ----------------------------------- |
|
|
210
|
+
| `RPC_URL` | `https://mainnet-api.nara.build/` | Solana RPC endpoint |
|
|
211
|
+
| `QUEST_RELAY_URL` | `https://quest-api.nara.build/` | Gasless relay for quest submissions |
|
|
212
|
+
| `QUEST_PROGRAM_ID` | `Quest11111111111111111111111111111111111111` | Quest program address |
|
|
213
|
+
| `SKILLS_PROGRAM_ID` | `SkiLLHub11111111111111111111111111111111111` | Skills Hub program address |
|
|
214
|
+
| `ZKID_PROGRAM_ID` | `ZKidentity111111111111111111111111111111111` | ZK ID program address |
|
|
213
215
|
|
|
214
216
|
## Examples
|
|
215
217
|
|
package/package.json
CHANGED
package/src/idls/nara_quest.json
CHANGED
|
@@ -28,10 +28,11 @@
|
|
|
28
28
|
{
|
|
29
29
|
"kind": "const",
|
|
30
30
|
"value": [
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
109,
|
|
31
|
+
113,
|
|
32
|
+
117,
|
|
34
33
|
101,
|
|
34
|
+
115,
|
|
35
|
+
116,
|
|
35
36
|
95,
|
|
36
37
|
99,
|
|
37
38
|
111,
|
|
@@ -52,6 +53,12 @@
|
|
|
52
53
|
{
|
|
53
54
|
"kind": "const",
|
|
54
55
|
"value": [
|
|
56
|
+
113,
|
|
57
|
+
117,
|
|
58
|
+
101,
|
|
59
|
+
115,
|
|
60
|
+
116,
|
|
61
|
+
95,
|
|
55
62
|
112,
|
|
56
63
|
111,
|
|
57
64
|
111,
|
|
@@ -69,6 +76,12 @@
|
|
|
69
76
|
{
|
|
70
77
|
"kind": "const",
|
|
71
78
|
"value": [
|
|
79
|
+
113,
|
|
80
|
+
117,
|
|
81
|
+
101,
|
|
82
|
+
115,
|
|
83
|
+
116,
|
|
84
|
+
95,
|
|
72
85
|
118,
|
|
73
86
|
97,
|
|
74
87
|
117,
|
|
@@ -110,6 +123,10 @@
|
|
|
110
123
|
{
|
|
111
124
|
"name": "reward_amount",
|
|
112
125
|
"type": "u64"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"name": "difficulty",
|
|
129
|
+
"type": "u32"
|
|
113
130
|
}
|
|
114
131
|
]
|
|
115
132
|
},
|
|
@@ -134,10 +151,11 @@
|
|
|
134
151
|
{
|
|
135
152
|
"kind": "const",
|
|
136
153
|
"value": [
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
109,
|
|
154
|
+
113,
|
|
155
|
+
117,
|
|
140
156
|
101,
|
|
157
|
+
115,
|
|
158
|
+
116,
|
|
141
159
|
95,
|
|
142
160
|
99,
|
|
143
161
|
111,
|
|
@@ -158,6 +176,12 @@
|
|
|
158
176
|
{
|
|
159
177
|
"kind": "const",
|
|
160
178
|
"value": [
|
|
179
|
+
113,
|
|
180
|
+
117,
|
|
181
|
+
101,
|
|
182
|
+
115,
|
|
183
|
+
116,
|
|
184
|
+
95,
|
|
161
185
|
112,
|
|
162
186
|
111,
|
|
163
187
|
111,
|
|
@@ -200,6 +224,12 @@
|
|
|
200
224
|
{
|
|
201
225
|
"kind": "const",
|
|
202
226
|
"value": [
|
|
227
|
+
113,
|
|
228
|
+
117,
|
|
229
|
+
101,
|
|
230
|
+
115,
|
|
231
|
+
116,
|
|
232
|
+
95,
|
|
203
233
|
112,
|
|
204
234
|
111,
|
|
205
235
|
111,
|
|
@@ -217,6 +247,12 @@
|
|
|
217
247
|
{
|
|
218
248
|
"kind": "const",
|
|
219
249
|
"value": [
|
|
250
|
+
113,
|
|
251
|
+
117,
|
|
252
|
+
101,
|
|
253
|
+
115,
|
|
254
|
+
116,
|
|
255
|
+
95,
|
|
220
256
|
119,
|
|
221
257
|
105,
|
|
222
258
|
110,
|
|
@@ -240,6 +276,12 @@
|
|
|
240
276
|
{
|
|
241
277
|
"kind": "const",
|
|
242
278
|
"value": [
|
|
279
|
+
113,
|
|
280
|
+
117,
|
|
281
|
+
101,
|
|
282
|
+
115,
|
|
283
|
+
116,
|
|
284
|
+
95,
|
|
243
285
|
118,
|
|
244
286
|
97,
|
|
245
287
|
117,
|
|
@@ -291,6 +333,14 @@
|
|
|
291
333
|
64
|
|
292
334
|
]
|
|
293
335
|
}
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
"name": "agent",
|
|
339
|
+
"type": "string"
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
"name": "model",
|
|
343
|
+
"type": "string"
|
|
294
344
|
}
|
|
295
345
|
]
|
|
296
346
|
},
|
|
@@ -315,10 +365,11 @@
|
|
|
315
365
|
{
|
|
316
366
|
"kind": "const",
|
|
317
367
|
"value": [
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
109,
|
|
368
|
+
113,
|
|
369
|
+
117,
|
|
321
370
|
101,
|
|
371
|
+
115,
|
|
372
|
+
116,
|
|
322
373
|
95,
|
|
323
374
|
99,
|
|
324
375
|
111,
|
|
@@ -385,6 +436,21 @@
|
|
|
385
436
|
]
|
|
386
437
|
}
|
|
387
438
|
],
|
|
439
|
+
"events": [
|
|
440
|
+
{
|
|
441
|
+
"name": "AnswerSubmitted",
|
|
442
|
+
"discriminator": [
|
|
443
|
+
197,
|
|
444
|
+
84,
|
|
445
|
+
24,
|
|
446
|
+
211,
|
|
447
|
+
90,
|
|
448
|
+
196,
|
|
449
|
+
234,
|
|
450
|
+
120
|
|
451
|
+
]
|
|
452
|
+
}
|
|
453
|
+
],
|
|
388
454
|
"errors": [
|
|
389
455
|
{
|
|
390
456
|
"code": 6000,
|
|
@@ -433,6 +499,42 @@
|
|
|
433
499
|
}
|
|
434
500
|
],
|
|
435
501
|
"types": [
|
|
502
|
+
{
|
|
503
|
+
"name": "AnswerSubmitted",
|
|
504
|
+
"type": {
|
|
505
|
+
"kind": "struct",
|
|
506
|
+
"fields": [
|
|
507
|
+
{
|
|
508
|
+
"name": "round",
|
|
509
|
+
"type": "u64"
|
|
510
|
+
},
|
|
511
|
+
{
|
|
512
|
+
"name": "question_id",
|
|
513
|
+
"type": "u64"
|
|
514
|
+
},
|
|
515
|
+
{
|
|
516
|
+
"name": "user",
|
|
517
|
+
"type": "pubkey"
|
|
518
|
+
},
|
|
519
|
+
{
|
|
520
|
+
"name": "rewarded",
|
|
521
|
+
"type": "bool"
|
|
522
|
+
},
|
|
523
|
+
{
|
|
524
|
+
"name": "reward_lamports",
|
|
525
|
+
"type": "u64"
|
|
526
|
+
},
|
|
527
|
+
{
|
|
528
|
+
"name": "agent",
|
|
529
|
+
"type": "string"
|
|
530
|
+
},
|
|
531
|
+
{
|
|
532
|
+
"name": "model",
|
|
533
|
+
"type": "string"
|
|
534
|
+
}
|
|
535
|
+
]
|
|
536
|
+
}
|
|
537
|
+
},
|
|
436
538
|
{
|
|
437
539
|
"name": "GameConfig",
|
|
438
540
|
"type": {
|
|
@@ -447,8 +549,13 @@
|
|
|
447
549
|
"type": "u64"
|
|
448
550
|
},
|
|
449
551
|
{
|
|
450
|
-
"name": "
|
|
451
|
-
"type":
|
|
552
|
+
"name": "_padding",
|
|
553
|
+
"type": {
|
|
554
|
+
"array": [
|
|
555
|
+
"u8",
|
|
556
|
+
64
|
|
557
|
+
]
|
|
558
|
+
}
|
|
452
559
|
}
|
|
453
560
|
]
|
|
454
561
|
}
|
|
@@ -504,8 +611,17 @@
|
|
|
504
611
|
"type": "bool"
|
|
505
612
|
},
|
|
506
613
|
{
|
|
507
|
-
"name": "
|
|
508
|
-
"type": "
|
|
614
|
+
"name": "difficulty",
|
|
615
|
+
"type": "u32"
|
|
616
|
+
},
|
|
617
|
+
{
|
|
618
|
+
"name": "_padding",
|
|
619
|
+
"type": {
|
|
620
|
+
"array": [
|
|
621
|
+
"u8",
|
|
622
|
+
64
|
|
623
|
+
]
|
|
624
|
+
}
|
|
509
625
|
}
|
|
510
626
|
]
|
|
511
627
|
}
|
|
@@ -515,10 +631,6 @@
|
|
|
515
631
|
"type": {
|
|
516
632
|
"kind": "struct",
|
|
517
633
|
"fields": [
|
|
518
|
-
{
|
|
519
|
-
"name": "bump",
|
|
520
|
-
"type": "u8"
|
|
521
|
-
},
|
|
522
634
|
{
|
|
523
635
|
"name": "round",
|
|
524
636
|
"type": "u64"
|
|
@@ -526,6 +638,15 @@
|
|
|
526
638
|
{
|
|
527
639
|
"name": "rewarded",
|
|
528
640
|
"type": "bool"
|
|
641
|
+
},
|
|
642
|
+
{
|
|
643
|
+
"name": "_padding",
|
|
644
|
+
"type": {
|
|
645
|
+
"array": [
|
|
646
|
+
"u8",
|
|
647
|
+
64
|
|
648
|
+
]
|
|
649
|
+
}
|
|
529
650
|
}
|
|
530
651
|
]
|
|
531
652
|
}
|
|
@@ -34,10 +34,11 @@ export type NaraQuest = {
|
|
|
34
34
|
{
|
|
35
35
|
"kind": "const",
|
|
36
36
|
"value": [
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
109,
|
|
37
|
+
113,
|
|
38
|
+
117,
|
|
40
39
|
101,
|
|
40
|
+
115,
|
|
41
|
+
116,
|
|
41
42
|
95,
|
|
42
43
|
99,
|
|
43
44
|
111,
|
|
@@ -58,6 +59,12 @@ export type NaraQuest = {
|
|
|
58
59
|
{
|
|
59
60
|
"kind": "const",
|
|
60
61
|
"value": [
|
|
62
|
+
113,
|
|
63
|
+
117,
|
|
64
|
+
101,
|
|
65
|
+
115,
|
|
66
|
+
116,
|
|
67
|
+
95,
|
|
61
68
|
112,
|
|
62
69
|
111,
|
|
63
70
|
111,
|
|
@@ -75,6 +82,12 @@ export type NaraQuest = {
|
|
|
75
82
|
{
|
|
76
83
|
"kind": "const",
|
|
77
84
|
"value": [
|
|
85
|
+
113,
|
|
86
|
+
117,
|
|
87
|
+
101,
|
|
88
|
+
115,
|
|
89
|
+
116,
|
|
90
|
+
95,
|
|
78
91
|
118,
|
|
79
92
|
97,
|
|
80
93
|
117,
|
|
@@ -116,6 +129,10 @@ export type NaraQuest = {
|
|
|
116
129
|
{
|
|
117
130
|
"name": "rewardAmount",
|
|
118
131
|
"type": "u64"
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"name": "difficulty",
|
|
135
|
+
"type": "u32"
|
|
119
136
|
}
|
|
120
137
|
]
|
|
121
138
|
},
|
|
@@ -140,10 +157,11 @@ export type NaraQuest = {
|
|
|
140
157
|
{
|
|
141
158
|
"kind": "const",
|
|
142
159
|
"value": [
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
109,
|
|
160
|
+
113,
|
|
161
|
+
117,
|
|
146
162
|
101,
|
|
163
|
+
115,
|
|
164
|
+
116,
|
|
147
165
|
95,
|
|
148
166
|
99,
|
|
149
167
|
111,
|
|
@@ -164,6 +182,12 @@ export type NaraQuest = {
|
|
|
164
182
|
{
|
|
165
183
|
"kind": "const",
|
|
166
184
|
"value": [
|
|
185
|
+
113,
|
|
186
|
+
117,
|
|
187
|
+
101,
|
|
188
|
+
115,
|
|
189
|
+
116,
|
|
190
|
+
95,
|
|
167
191
|
112,
|
|
168
192
|
111,
|
|
169
193
|
111,
|
|
@@ -206,6 +230,12 @@ export type NaraQuest = {
|
|
|
206
230
|
{
|
|
207
231
|
"kind": "const",
|
|
208
232
|
"value": [
|
|
233
|
+
113,
|
|
234
|
+
117,
|
|
235
|
+
101,
|
|
236
|
+
115,
|
|
237
|
+
116,
|
|
238
|
+
95,
|
|
209
239
|
112,
|
|
210
240
|
111,
|
|
211
241
|
111,
|
|
@@ -223,6 +253,12 @@ export type NaraQuest = {
|
|
|
223
253
|
{
|
|
224
254
|
"kind": "const",
|
|
225
255
|
"value": [
|
|
256
|
+
113,
|
|
257
|
+
117,
|
|
258
|
+
101,
|
|
259
|
+
115,
|
|
260
|
+
116,
|
|
261
|
+
95,
|
|
226
262
|
119,
|
|
227
263
|
105,
|
|
228
264
|
110,
|
|
@@ -246,6 +282,12 @@ export type NaraQuest = {
|
|
|
246
282
|
{
|
|
247
283
|
"kind": "const",
|
|
248
284
|
"value": [
|
|
285
|
+
113,
|
|
286
|
+
117,
|
|
287
|
+
101,
|
|
288
|
+
115,
|
|
289
|
+
116,
|
|
290
|
+
95,
|
|
249
291
|
118,
|
|
250
292
|
97,
|
|
251
293
|
117,
|
|
@@ -297,6 +339,14 @@ export type NaraQuest = {
|
|
|
297
339
|
64
|
|
298
340
|
]
|
|
299
341
|
}
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
"name": "agent",
|
|
345
|
+
"type": "string"
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
"name": "model",
|
|
349
|
+
"type": "string"
|
|
300
350
|
}
|
|
301
351
|
]
|
|
302
352
|
},
|
|
@@ -321,10 +371,11 @@ export type NaraQuest = {
|
|
|
321
371
|
{
|
|
322
372
|
"kind": "const",
|
|
323
373
|
"value": [
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
109,
|
|
374
|
+
113,
|
|
375
|
+
117,
|
|
327
376
|
101,
|
|
377
|
+
115,
|
|
378
|
+
116,
|
|
328
379
|
95,
|
|
329
380
|
99,
|
|
330
381
|
111,
|
|
@@ -391,6 +442,21 @@ export type NaraQuest = {
|
|
|
391
442
|
]
|
|
392
443
|
}
|
|
393
444
|
],
|
|
445
|
+
"events": [
|
|
446
|
+
{
|
|
447
|
+
"name": "answerSubmitted",
|
|
448
|
+
"discriminator": [
|
|
449
|
+
197,
|
|
450
|
+
84,
|
|
451
|
+
24,
|
|
452
|
+
211,
|
|
453
|
+
90,
|
|
454
|
+
196,
|
|
455
|
+
234,
|
|
456
|
+
120
|
|
457
|
+
]
|
|
458
|
+
}
|
|
459
|
+
],
|
|
394
460
|
"errors": [
|
|
395
461
|
{
|
|
396
462
|
"code": 6000,
|
|
@@ -439,6 +505,42 @@ export type NaraQuest = {
|
|
|
439
505
|
}
|
|
440
506
|
],
|
|
441
507
|
"types": [
|
|
508
|
+
{
|
|
509
|
+
"name": "answerSubmitted",
|
|
510
|
+
"type": {
|
|
511
|
+
"kind": "struct",
|
|
512
|
+
"fields": [
|
|
513
|
+
{
|
|
514
|
+
"name": "round",
|
|
515
|
+
"type": "u64"
|
|
516
|
+
},
|
|
517
|
+
{
|
|
518
|
+
"name": "questionId",
|
|
519
|
+
"type": "u64"
|
|
520
|
+
},
|
|
521
|
+
{
|
|
522
|
+
"name": "user",
|
|
523
|
+
"type": "pubkey"
|
|
524
|
+
},
|
|
525
|
+
{
|
|
526
|
+
"name": "rewarded",
|
|
527
|
+
"type": "bool"
|
|
528
|
+
},
|
|
529
|
+
{
|
|
530
|
+
"name": "rewardLamports",
|
|
531
|
+
"type": "u64"
|
|
532
|
+
},
|
|
533
|
+
{
|
|
534
|
+
"name": "agent",
|
|
535
|
+
"type": "string"
|
|
536
|
+
},
|
|
537
|
+
{
|
|
538
|
+
"name": "model",
|
|
539
|
+
"type": "string"
|
|
540
|
+
}
|
|
541
|
+
]
|
|
542
|
+
}
|
|
543
|
+
},
|
|
442
544
|
{
|
|
443
545
|
"name": "gameConfig",
|
|
444
546
|
"type": {
|
|
@@ -453,8 +555,13 @@ export type NaraQuest = {
|
|
|
453
555
|
"type": "u64"
|
|
454
556
|
},
|
|
455
557
|
{
|
|
456
|
-
"name": "
|
|
457
|
-
"type":
|
|
558
|
+
"name": "padding",
|
|
559
|
+
"type": {
|
|
560
|
+
"array": [
|
|
561
|
+
"u8",
|
|
562
|
+
64
|
|
563
|
+
]
|
|
564
|
+
}
|
|
458
565
|
}
|
|
459
566
|
]
|
|
460
567
|
}
|
|
@@ -510,8 +617,17 @@ export type NaraQuest = {
|
|
|
510
617
|
"type": "bool"
|
|
511
618
|
},
|
|
512
619
|
{
|
|
513
|
-
"name": "
|
|
514
|
-
"type": "
|
|
620
|
+
"name": "difficulty",
|
|
621
|
+
"type": "u32"
|
|
622
|
+
},
|
|
623
|
+
{
|
|
624
|
+
"name": "padding",
|
|
625
|
+
"type": {
|
|
626
|
+
"array": [
|
|
627
|
+
"u8",
|
|
628
|
+
64
|
|
629
|
+
]
|
|
630
|
+
}
|
|
515
631
|
}
|
|
516
632
|
]
|
|
517
633
|
}
|
|
@@ -521,10 +637,6 @@ export type NaraQuest = {
|
|
|
521
637
|
"type": {
|
|
522
638
|
"kind": "struct",
|
|
523
639
|
"fields": [
|
|
524
|
-
{
|
|
525
|
-
"name": "bump",
|
|
526
|
-
"type": "u8"
|
|
527
|
-
},
|
|
528
640
|
{
|
|
529
641
|
"name": "round",
|
|
530
642
|
"type": "u64"
|
|
@@ -532,6 +644,15 @@ export type NaraQuest = {
|
|
|
532
644
|
{
|
|
533
645
|
"name": "rewarded",
|
|
534
646
|
"type": "bool"
|
|
647
|
+
},
|
|
648
|
+
{
|
|
649
|
+
"name": "padding",
|
|
650
|
+
"type": {
|
|
651
|
+
"array": [
|
|
652
|
+
"u8",
|
|
653
|
+
64
|
|
654
|
+
]
|
|
655
|
+
}
|
|
535
656
|
}
|
|
536
657
|
]
|
|
537
658
|
}
|
package/src/quest.ts
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from "@solana/web3.js";
|
|
11
11
|
import * as anchor from "@coral-xyz/anchor";
|
|
12
12
|
import { Program, AnchorProvider, Wallet } from "@coral-xyz/anchor";
|
|
13
|
-
import type { NaraQuest } from "./idls/
|
|
13
|
+
import type { NaraQuest } from "./idls/nara_quest";
|
|
14
14
|
import { DEFAULT_QUEST_PROGRAM_ID } from "./constants";
|
|
15
15
|
|
|
16
16
|
import naraQuestIdl from "./idls/nara_quest.json";
|
|
@@ -48,6 +48,7 @@ export interface QuestInfo {
|
|
|
48
48
|
rewardCount: number;
|
|
49
49
|
winnerCount: number;
|
|
50
50
|
remainingSlots: number;
|
|
51
|
+
difficulty: number;
|
|
51
52
|
deadline: number;
|
|
52
53
|
timeRemaining: number;
|
|
53
54
|
expired: boolean;
|
|
@@ -177,7 +178,7 @@ function createProgram(
|
|
|
177
178
|
|
|
178
179
|
function getPoolPda(programId: PublicKey): PublicKey {
|
|
179
180
|
const [pda] = PublicKey.findProgramAddressSync(
|
|
180
|
-
[Buffer.from("
|
|
181
|
+
[Buffer.from("quest_pool")],
|
|
181
182
|
programId
|
|
182
183
|
);
|
|
183
184
|
return pda;
|
|
@@ -188,7 +189,7 @@ function getWinnerRecordPda(
|
|
|
188
189
|
user: PublicKey
|
|
189
190
|
): PublicKey {
|
|
190
191
|
const [pda] = PublicKey.findProgramAddressSync(
|
|
191
|
-
[Buffer.from("
|
|
192
|
+
[Buffer.from("quest_winner"), user.toBuffer()],
|
|
192
193
|
programId
|
|
193
194
|
);
|
|
194
195
|
return pda;
|
|
@@ -224,6 +225,7 @@ export async function getQuestInfo(
|
|
|
224
225
|
rewardCount: pool.rewardCount,
|
|
225
226
|
winnerCount: pool.winnerCount,
|
|
226
227
|
remainingSlots: Math.max(0, pool.rewardCount - pool.winnerCount),
|
|
228
|
+
difficulty: pool.difficulty,
|
|
227
229
|
deadline,
|
|
228
230
|
timeRemaining: secsLeft,
|
|
229
231
|
expired: secsLeft <= 0,
|
|
@@ -291,11 +293,13 @@ export async function submitAnswer(
|
|
|
291
293
|
connection: Connection,
|
|
292
294
|
wallet: Keypair,
|
|
293
295
|
proof: ZkProof,
|
|
296
|
+
agent: string = "",
|
|
297
|
+
model: string = "",
|
|
294
298
|
options?: QuestOptions
|
|
295
299
|
): Promise<SubmitAnswerResult> {
|
|
296
300
|
const program = createProgram(connection, wallet, options?.programId);
|
|
297
301
|
const signature = await program.methods
|
|
298
|
-
.submitAnswer(proof.proofA as any, proof.proofB as any, proof.proofC as any)
|
|
302
|
+
.submitAnswer(proof.proofA as any, proof.proofB as any, proof.proofC as any, agent, model)
|
|
299
303
|
.accounts({ user: wallet.publicKey, payer: wallet.publicKey })
|
|
300
304
|
.signers([wallet])
|
|
301
305
|
.rpc({ skipPreflight: true });
|
|
@@ -309,7 +313,9 @@ export async function submitAnswer(
|
|
|
309
313
|
export async function submitAnswerViaRelay(
|
|
310
314
|
relayUrl: string,
|
|
311
315
|
userPubkey: PublicKey,
|
|
312
|
-
proof: ZkProofHex
|
|
316
|
+
proof: ZkProofHex,
|
|
317
|
+
agent: string = "",
|
|
318
|
+
model: string = ""
|
|
313
319
|
): Promise<SubmitRelayResult> {
|
|
314
320
|
const base = relayUrl.replace(/\/+$/, "");
|
|
315
321
|
const res = await fetch(`${base}/submit-answer`, {
|
|
@@ -320,6 +326,8 @@ export async function submitAnswerViaRelay(
|
|
|
320
326
|
proofA: proof.proofA,
|
|
321
327
|
proofB: proof.proofB,
|
|
322
328
|
proofC: proof.proofC,
|
|
329
|
+
agent,
|
|
330
|
+
model,
|
|
323
331
|
}),
|
|
324
332
|
});
|
|
325
333
|
|