naracli 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,534 @@
1
+ {
2
+ "address": "EXPLAHaMHLK9p7w5jVqEVY671NkkCKSHTNhhyUrPAboZ",
3
+ "metadata": {
4
+ "name": "nara_quest",
5
+ "version": "0.1.0",
6
+ "spec": "0.1.0",
7
+ "description": "Created with Anchor"
8
+ },
9
+ "instructions": [
10
+ {
11
+ "name": "create_question",
12
+ "discriminator": [
13
+ 222,
14
+ 74,
15
+ 49,
16
+ 30,
17
+ 160,
18
+ 220,
19
+ 179,
20
+ 27
21
+ ],
22
+ "accounts": [
23
+ {
24
+ "name": "game_config",
25
+ "writable": true,
26
+ "pda": {
27
+ "seeds": [
28
+ {
29
+ "kind": "const",
30
+ "value": [
31
+ 103,
32
+ 97,
33
+ 109,
34
+ 101,
35
+ 95,
36
+ 99,
37
+ 111,
38
+ 110,
39
+ 102,
40
+ 105,
41
+ 103
42
+ ]
43
+ }
44
+ ]
45
+ }
46
+ },
47
+ {
48
+ "name": "pool",
49
+ "writable": true,
50
+ "pda": {
51
+ "seeds": [
52
+ {
53
+ "kind": "const",
54
+ "value": [
55
+ 112,
56
+ 111,
57
+ 111,
58
+ 108
59
+ ]
60
+ }
61
+ ]
62
+ }
63
+ },
64
+ {
65
+ "name": "vault",
66
+ "writable": true,
67
+ "pda": {
68
+ "seeds": [
69
+ {
70
+ "kind": "const",
71
+ "value": [
72
+ 118,
73
+ 97,
74
+ 117,
75
+ 108,
76
+ 116
77
+ ]
78
+ }
79
+ ]
80
+ }
81
+ },
82
+ {
83
+ "name": "authority",
84
+ "writable": true,
85
+ "signer": true
86
+ },
87
+ {
88
+ "name": "system_program",
89
+ "address": "11111111111111111111111111111111"
90
+ }
91
+ ],
92
+ "args": [
93
+ {
94
+ "name": "question",
95
+ "type": "string"
96
+ },
97
+ {
98
+ "name": "answer_hash",
99
+ "type": {
100
+ "array": [
101
+ "u8",
102
+ 32
103
+ ]
104
+ }
105
+ },
106
+ {
107
+ "name": "deadline",
108
+ "type": "i64"
109
+ },
110
+ {
111
+ "name": "reward_amount",
112
+ "type": "u64"
113
+ }
114
+ ]
115
+ },
116
+ {
117
+ "name": "initialize",
118
+ "discriminator": [
119
+ 175,
120
+ 175,
121
+ 109,
122
+ 31,
123
+ 13,
124
+ 152,
125
+ 155,
126
+ 237
127
+ ],
128
+ "accounts": [
129
+ {
130
+ "name": "game_config",
131
+ "writable": true,
132
+ "pda": {
133
+ "seeds": [
134
+ {
135
+ "kind": "const",
136
+ "value": [
137
+ 103,
138
+ 97,
139
+ 109,
140
+ 101,
141
+ 95,
142
+ 99,
143
+ 111,
144
+ 110,
145
+ 102,
146
+ 105,
147
+ 103
148
+ ]
149
+ }
150
+ ]
151
+ }
152
+ },
153
+ {
154
+ "name": "pool",
155
+ "writable": true,
156
+ "pda": {
157
+ "seeds": [
158
+ {
159
+ "kind": "const",
160
+ "value": [
161
+ 112,
162
+ 111,
163
+ 111,
164
+ 108
165
+ ]
166
+ }
167
+ ]
168
+ }
169
+ },
170
+ {
171
+ "name": "authority",
172
+ "writable": true,
173
+ "signer": true
174
+ },
175
+ {
176
+ "name": "system_program",
177
+ "address": "11111111111111111111111111111111"
178
+ }
179
+ ],
180
+ "args": []
181
+ },
182
+ {
183
+ "name": "submit_answer",
184
+ "discriminator": [
185
+ 221,
186
+ 73,
187
+ 184,
188
+ 157,
189
+ 1,
190
+ 150,
191
+ 231,
192
+ 48
193
+ ],
194
+ "accounts": [
195
+ {
196
+ "name": "pool",
197
+ "writable": true,
198
+ "pda": {
199
+ "seeds": [
200
+ {
201
+ "kind": "const",
202
+ "value": [
203
+ 112,
204
+ 111,
205
+ 111,
206
+ 108
207
+ ]
208
+ }
209
+ ]
210
+ }
211
+ },
212
+ {
213
+ "name": "winner_record",
214
+ "writable": true,
215
+ "pda": {
216
+ "seeds": [
217
+ {
218
+ "kind": "const",
219
+ "value": [
220
+ 119,
221
+ 105,
222
+ 110,
223
+ 110,
224
+ 101,
225
+ 114
226
+ ]
227
+ },
228
+ {
229
+ "kind": "account",
230
+ "path": "user"
231
+ }
232
+ ]
233
+ }
234
+ },
235
+ {
236
+ "name": "vault",
237
+ "writable": true,
238
+ "pda": {
239
+ "seeds": [
240
+ {
241
+ "kind": "const",
242
+ "value": [
243
+ 118,
244
+ 97,
245
+ 117,
246
+ 108,
247
+ 116
248
+ ]
249
+ }
250
+ ]
251
+ }
252
+ },
253
+ {
254
+ "name": "user",
255
+ "writable": true
256
+ },
257
+ {
258
+ "name": "payer",
259
+ "writable": true,
260
+ "signer": true
261
+ },
262
+ {
263
+ "name": "system_program",
264
+ "address": "11111111111111111111111111111111"
265
+ }
266
+ ],
267
+ "args": [
268
+ {
269
+ "name": "proof_a",
270
+ "type": {
271
+ "array": [
272
+ "u8",
273
+ 64
274
+ ]
275
+ }
276
+ },
277
+ {
278
+ "name": "proof_b",
279
+ "type": {
280
+ "array": [
281
+ "u8",
282
+ 128
283
+ ]
284
+ }
285
+ },
286
+ {
287
+ "name": "proof_c",
288
+ "type": {
289
+ "array": [
290
+ "u8",
291
+ 64
292
+ ]
293
+ }
294
+ }
295
+ ]
296
+ },
297
+ {
298
+ "name": "transfer_authority",
299
+ "discriminator": [
300
+ 48,
301
+ 169,
302
+ 76,
303
+ 72,
304
+ 229,
305
+ 180,
306
+ 55,
307
+ 161
308
+ ],
309
+ "accounts": [
310
+ {
311
+ "name": "game_config",
312
+ "writable": true,
313
+ "pda": {
314
+ "seeds": [
315
+ {
316
+ "kind": "const",
317
+ "value": [
318
+ 103,
319
+ 97,
320
+ 109,
321
+ 101,
322
+ 95,
323
+ 99,
324
+ 111,
325
+ 110,
326
+ 102,
327
+ 105,
328
+ 103
329
+ ]
330
+ }
331
+ ]
332
+ }
333
+ },
334
+ {
335
+ "name": "authority",
336
+ "signer": true
337
+ }
338
+ ],
339
+ "args": [
340
+ {
341
+ "name": "new_authority",
342
+ "type": "pubkey"
343
+ }
344
+ ]
345
+ }
346
+ ],
347
+ "accounts": [
348
+ {
349
+ "name": "GameConfig",
350
+ "discriminator": [
351
+ 45,
352
+ 146,
353
+ 146,
354
+ 33,
355
+ 170,
356
+ 69,
357
+ 96,
358
+ 133
359
+ ]
360
+ },
361
+ {
362
+ "name": "Pool",
363
+ "discriminator": [
364
+ 241,
365
+ 154,
366
+ 109,
367
+ 4,
368
+ 17,
369
+ 177,
370
+ 109,
371
+ 188
372
+ ]
373
+ },
374
+ {
375
+ "name": "WinnerRecord",
376
+ "discriminator": [
377
+ 248,
378
+ 27,
379
+ 49,
380
+ 33,
381
+ 45,
382
+ 88,
383
+ 210,
384
+ 100
385
+ ]
386
+ }
387
+ ],
388
+ "errors": [
389
+ {
390
+ "code": 6000,
391
+ "name": "Unauthorized",
392
+ "msg": "Only the authority can perform this action"
393
+ },
394
+ {
395
+ "code": 6001,
396
+ "name": "PoolNotActive",
397
+ "msg": "Pool has no active question"
398
+ },
399
+ {
400
+ "code": 6002,
401
+ "name": "DeadlineExpired",
402
+ "msg": "The deadline for this question has passed"
403
+ },
404
+ {
405
+ "code": 6003,
406
+ "name": "InvalidProof",
407
+ "msg": "ZK proof verification failed"
408
+ },
409
+ {
410
+ "code": 6004,
411
+ "name": "InvalidDeadline",
412
+ "msg": "Deadline must be in the future"
413
+ },
414
+ {
415
+ "code": 6005,
416
+ "name": "InsufficientReward",
417
+ "msg": "Reward amount must be greater than zero"
418
+ },
419
+ {
420
+ "code": 6006,
421
+ "name": "InsufficientPoolBalance",
422
+ "msg": "Pool balance insufficient for reward transfer"
423
+ },
424
+ {
425
+ "code": 6007,
426
+ "name": "QuestionTooLong",
427
+ "msg": "Question exceeds maximum length"
428
+ },
429
+ {
430
+ "code": 6008,
431
+ "name": "AlreadyAnswered",
432
+ "msg": "Already answered this round"
433
+ }
434
+ ],
435
+ "types": [
436
+ {
437
+ "name": "GameConfig",
438
+ "type": {
439
+ "kind": "struct",
440
+ "fields": [
441
+ {
442
+ "name": "authority",
443
+ "type": "pubkey"
444
+ },
445
+ {
446
+ "name": "next_question_id",
447
+ "type": "u64"
448
+ },
449
+ {
450
+ "name": "bump",
451
+ "type": "u8"
452
+ }
453
+ ]
454
+ }
455
+ },
456
+ {
457
+ "name": "Pool",
458
+ "type": {
459
+ "kind": "struct",
460
+ "fields": [
461
+ {
462
+ "name": "round",
463
+ "type": "u64"
464
+ },
465
+ {
466
+ "name": "question_id",
467
+ "type": "u64"
468
+ },
469
+ {
470
+ "name": "question",
471
+ "type": "string"
472
+ },
473
+ {
474
+ "name": "answer_hash",
475
+ "type": {
476
+ "array": [
477
+ "u8",
478
+ 32
479
+ ]
480
+ }
481
+ },
482
+ {
483
+ "name": "deadline",
484
+ "type": "i64"
485
+ },
486
+ {
487
+ "name": "reward_amount",
488
+ "type": "u64"
489
+ },
490
+ {
491
+ "name": "reward_count",
492
+ "type": "u32"
493
+ },
494
+ {
495
+ "name": "reward_per_winner",
496
+ "type": "u64"
497
+ },
498
+ {
499
+ "name": "winner_count",
500
+ "type": "u32"
501
+ },
502
+ {
503
+ "name": "is_active",
504
+ "type": "bool"
505
+ },
506
+ {
507
+ "name": "bump",
508
+ "type": "u8"
509
+ }
510
+ ]
511
+ }
512
+ },
513
+ {
514
+ "name": "WinnerRecord",
515
+ "type": {
516
+ "kind": "struct",
517
+ "fields": [
518
+ {
519
+ "name": "bump",
520
+ "type": "u8"
521
+ },
522
+ {
523
+ "name": "round",
524
+ "type": "u64"
525
+ },
526
+ {
527
+ "name": "rewarded",
528
+ "type": "bool"
529
+ }
530
+ ]
531
+ }
532
+ }
533
+ ]
534
+ }
Binary file
Binary file
package/index.ts ADDED
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Nara CLI & SDK - CLI and SDK for the Nara chain (Solana-compatible)
3
+ *
4
+ * This SDK provides functions to interact with the Nara chain.
5
+ * All transaction-related functions return unsigned transactions that
6
+ * must be signed and sent by the caller.
7
+ */
8
+
9
+ // Export main client
10
+ export { NaraSDK, type NaraSDKConfig } from "./src/client";
11
+
12
+ // Export constants
13
+ export { DEFAULT_RPC_URL } from "./src/constants";
14
+
15
+ // Export config functions and types
16
+ export {
17
+ createConfig,
18
+ type CreateConfigOptions,
19
+ type CreateConfigResult,
20
+ } from "./src/config";
21
+
22
+ // Export pool functions and types
23
+ export {
24
+ createPool,
25
+ createPoolWithFirstBuy,
26
+ getPoolInfo,
27
+ getPoolProgress,
28
+ type CreatePoolParams,
29
+ type CreatePoolResult,
30
+ type CreatePoolWithFirstBuyParams,
31
+ type CreatePoolWithFirstBuyResult,
32
+ } from "./src/pool";
33
+
34
+ // Export swap functions and types
35
+ export {
36
+ buyToken,
37
+ sellToken,
38
+ getSwapQuote,
39
+ SwapMode,
40
+ type BuyTokenParams,
41
+ type BuyTokenResult,
42
+ type SellTokenParams,
43
+ type SellTokenResult,
44
+ type SwapQuoteResponse,
45
+ } from "./src/swap";
46
+
47
+ // Export migrate functions and types
48
+ export {
49
+ migrateToDAMMV2,
50
+ createLocker,
51
+ canMigrate,
52
+ type MigrateToDAMMV2Params,
53
+ type MigrateToDAMMV2Result,
54
+ type CreateLockerParams,
55
+ type CreateLockerResult,
56
+ } from "./src/migrate";
57
+
58
+ // Export quest functions and types
59
+ export {
60
+ getQuestInfo,
61
+ hasAnswered,
62
+ generateProof,
63
+ submitAnswer,
64
+ submitAnswerViaRelay,
65
+ parseQuestReward,
66
+ type QuestInfo,
67
+ type ZkProof,
68
+ type ZkProofHex,
69
+ type SubmitAnswerResult,
70
+ type SubmitRelayResult,
71
+ type QuestProveOptions,
72
+ } from "./src/quest";
73
+
74
+ // Re-export commonly used types from dependencies
75
+ export { PublicKey, Keypair, Transaction } from "@solana/web3.js";
76
+ export { default as BN } from "bn.js";
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "naracli",
3
+ "version": "0.1.0",
4
+ "description": "CLI for the Nara chain (Solana-compatible)",
5
+ "module": "index.ts",
6
+ "main": "index.ts",
7
+ "type": "module",
8
+ "private": false,
9
+ "bin": {
10
+ "nara-cli": "./dist/nara-cli.mjs"
11
+ },
12
+ "scripts": {
13
+ "cli": "npx tsx bin/nara-cli.ts",
14
+ "build": "npx esbuild bin/nara-cli.ts --bundle --platform=node --format=esm --outfile=dist/nara-cli.mjs --packages=external --banner:js='#!/usr/bin/env node' && mkdir -p dist/zk dist/quest && cp src/cli/zk/answer_proof.wasm src/cli/zk/answer_proof_final.zkey dist/zk/ && cp src/cli/quest/nara_quest.json dist/quest/",
15
+ "prepublishOnly": "npm run build"
16
+ },
17
+ "files": [
18
+ "dist",
19
+ "src",
20
+ "index.ts",
21
+ "bin"
22
+ ],
23
+ "keywords": [
24
+ "nara",
25
+ "solana",
26
+ "blockchain",
27
+ "cli",
28
+ "sdk"
29
+ ],
30
+ "author": "",
31
+ "license": "MIT",
32
+ "devDependencies": {
33
+ "@types/bn.js": "^5.2.0",
34
+ "@types/node": "^22.0.0",
35
+ "esbuild": "^0.24.0",
36
+ "tsx": "^4.19.0"
37
+ },
38
+ "peerDependencies": {
39
+ "typescript": "^5"
40
+ },
41
+ "dependencies": {
42
+ "@coral-xyz/anchor": "^0.32.1",
43
+ "@meteora-ag/cp-amm-sdk": "^1.3.3",
44
+ "@meteora-ag/dynamic-bonding-curve-sdk": "^1.5.2",
45
+ "@solana/spl-token": "^0.4.14",
46
+ "@solana/web3.js": "^1.98.4",
47
+ "bip39": "^3.1.0",
48
+ "bn.js": "^5.2.2",
49
+ "bs58": "^6.0.0",
50
+ "commander": "^12.1.0",
51
+ "ed25519-hd-key": "^1.3.0",
52
+ "snarkjs": "^0.7.6"
53
+ }
54
+ }