nara-sdk 1.0.65 → 1.0.67

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/index.ts CHANGED
@@ -47,6 +47,8 @@ export {
47
47
  setStakeAuthority,
48
48
  makeAdjustFreeStakeIx,
49
49
  adjustFreeStake,
50
+ claimAirdrop,
51
+ setAirdropConfig,
50
52
  getQuestConfig,
51
53
  type QuestInfo,
52
54
  type StakeInfo,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nara-sdk",
3
- "version": "1.0.65",
3
+ "version": "1.0.67",
4
4
  "description": "SDK for the Nara chain (Solana-compatible)",
5
5
  "module": "index.ts",
6
6
  "main": "index.ts",
@@ -96,6 +96,164 @@
96
96
  }
97
97
  ]
98
98
  },
99
+ {
100
+ "name": "claim_airdrop",
101
+ "discriminator": [
102
+ 137,
103
+ 50,
104
+ 122,
105
+ 111,
106
+ 89,
107
+ 254,
108
+ 8,
109
+ 20
110
+ ],
111
+ "accounts": [
112
+ {
113
+ "name": "game_config",
114
+ "pda": {
115
+ "seeds": [
116
+ {
117
+ "kind": "const",
118
+ "value": [
119
+ 113,
120
+ 117,
121
+ 101,
122
+ 115,
123
+ 116,
124
+ 95,
125
+ 99,
126
+ 111,
127
+ 110,
128
+ 102,
129
+ 105,
130
+ 103
131
+ ]
132
+ }
133
+ ]
134
+ }
135
+ },
136
+ {
137
+ "name": "pool",
138
+ "pda": {
139
+ "seeds": [
140
+ {
141
+ "kind": "const",
142
+ "value": [
143
+ 113,
144
+ 117,
145
+ 101,
146
+ 115,
147
+ 116,
148
+ 95,
149
+ 112,
150
+ 111,
151
+ 111,
152
+ 108
153
+ ]
154
+ }
155
+ ]
156
+ }
157
+ },
158
+ {
159
+ "name": "winner_record",
160
+ "writable": true,
161
+ "pda": {
162
+ "seeds": [
163
+ {
164
+ "kind": "const",
165
+ "value": [
166
+ 113,
167
+ 117,
168
+ 101,
169
+ 115,
170
+ 116,
171
+ 95,
172
+ 119,
173
+ 105,
174
+ 110,
175
+ 110,
176
+ 101,
177
+ 114
178
+ ]
179
+ },
180
+ {
181
+ "kind": "account",
182
+ "path": "user"
183
+ }
184
+ ]
185
+ }
186
+ },
187
+ {
188
+ "name": "airdrop_fund",
189
+ "writable": true,
190
+ "pda": {
191
+ "seeds": [
192
+ {
193
+ "kind": "const",
194
+ "value": [
195
+ 113,
196
+ 117,
197
+ 101,
198
+ 115,
199
+ 116,
200
+ 95,
201
+ 97,
202
+ 105,
203
+ 114,
204
+ 100,
205
+ 114,
206
+ 111,
207
+ 112
208
+ ]
209
+ }
210
+ ]
211
+ }
212
+ },
213
+ {
214
+ "name": "user",
215
+ "writable": true
216
+ },
217
+ {
218
+ "name": "payer",
219
+ "writable": true,
220
+ "signer": true
221
+ },
222
+ {
223
+ "name": "system_program",
224
+ "address": "11111111111111111111111111111111"
225
+ }
226
+ ],
227
+ "args": [
228
+ {
229
+ "name": "proof_a",
230
+ "type": {
231
+ "array": [
232
+ "u8",
233
+ 64
234
+ ]
235
+ }
236
+ },
237
+ {
238
+ "name": "proof_b",
239
+ "type": {
240
+ "array": [
241
+ "u8",
242
+ 128
243
+ ]
244
+ }
245
+ },
246
+ {
247
+ "name": "proof_c",
248
+ "type": {
249
+ "array": [
250
+ "u8",
251
+ 64
252
+ ]
253
+ }
254
+ }
255
+ ]
256
+ },
99
257
  {
100
258
  "name": "create_question",
101
259
  "discriminator": [
@@ -244,6 +402,61 @@
244
402
  }
245
403
  ]
246
404
  },
405
+ {
406
+ "name": "expand_config",
407
+ "discriminator": [
408
+ 120,
409
+ 201,
410
+ 195,
411
+ 128,
412
+ 35,
413
+ 202,
414
+ 73,
415
+ 161
416
+ ],
417
+ "accounts": [
418
+ {
419
+ "name": "game_config",
420
+ "writable": true,
421
+ "pda": {
422
+ "seeds": [
423
+ {
424
+ "kind": "const",
425
+ "value": [
426
+ 113,
427
+ 117,
428
+ 101,
429
+ 115,
430
+ 116,
431
+ 95,
432
+ 99,
433
+ 111,
434
+ 110,
435
+ 102,
436
+ 105,
437
+ 103
438
+ ]
439
+ }
440
+ ]
441
+ }
442
+ },
443
+ {
444
+ "name": "authority",
445
+ "writable": true,
446
+ "signer": true
447
+ },
448
+ {
449
+ "name": "system_program",
450
+ "address": "11111111111111111111111111111111"
451
+ }
452
+ ],
453
+ "args": [
454
+ {
455
+ "name": "additional_size",
456
+ "type": "u32"
457
+ }
458
+ ]
459
+ },
247
460
  {
248
461
  "name": "initialize",
249
462
  "discriminator": [
@@ -343,6 +556,60 @@
343
556
  ],
344
557
  "args": []
345
558
  },
559
+ {
560
+ "name": "set_airdrop_config",
561
+ "discriminator": [
562
+ 255,
563
+ 181,
564
+ 252,
565
+ 34,
566
+ 155,
567
+ 230,
568
+ 65,
569
+ 227
570
+ ],
571
+ "accounts": [
572
+ {
573
+ "name": "game_config",
574
+ "writable": true,
575
+ "pda": {
576
+ "seeds": [
577
+ {
578
+ "kind": "const",
579
+ "value": [
580
+ 113,
581
+ 117,
582
+ 101,
583
+ 115,
584
+ 116,
585
+ 95,
586
+ 99,
587
+ 111,
588
+ 110,
589
+ 102,
590
+ 105,
591
+ 103
592
+ ]
593
+ }
594
+ ]
595
+ }
596
+ },
597
+ {
598
+ "name": "authority",
599
+ "signer": true
600
+ }
601
+ ],
602
+ "args": [
603
+ {
604
+ "name": "airdrop_amount",
605
+ "type": "u64"
606
+ },
607
+ {
608
+ "name": "max_airdrop_count",
609
+ "type": "u32"
610
+ }
611
+ ]
612
+ },
346
613
  {
347
614
  "name": "set_quest_authority",
348
615
  "discriminator": [
@@ -1618,6 +1885,31 @@
1618
1885
  "code": 6017,
1619
1886
  "name": "FreeCreditsOverflow",
1620
1887
  "msg": "Free credits overflow"
1888
+ },
1889
+ {
1890
+ "code": 6018,
1891
+ "name": "AirdropNotEligible",
1892
+ "msg": "Not eligible: must answer current round first"
1893
+ },
1894
+ {
1895
+ "code": 6019,
1896
+ "name": "AirdropMaxReached",
1897
+ "msg": "Max airdrop count reached for this address"
1898
+ },
1899
+ {
1900
+ "code": 6020,
1901
+ "name": "AirdropCooldown",
1902
+ "msg": "Must wait 24 hours between airdrop claims"
1903
+ },
1904
+ {
1905
+ "code": 6021,
1906
+ "name": "AirdropDisabled",
1907
+ "msg": "Airdrop is disabled (amount = 0)"
1908
+ },
1909
+ {
1910
+ "code": 6022,
1911
+ "name": "InsufficientAirdrop",
1912
+ "msg": "Airdrop fund has insufficient balance"
1621
1913
  }
1622
1914
  ],
1623
1915
  "types": [
@@ -1706,12 +1998,20 @@
1706
1998
  "name": "stake_authority",
1707
1999
  "type": "pubkey"
1708
2000
  },
2001
+ {
2002
+ "name": "airdrop_amount",
2003
+ "type": "u64"
2004
+ },
2005
+ {
2006
+ "name": "max_airdrop_count",
2007
+ "type": "u32"
2008
+ },
1709
2009
  {
1710
2010
  "name": "_padding",
1711
2011
  "type": {
1712
2012
  "array": [
1713
2013
  "u8",
1714
- 32
2014
+ 20
1715
2015
  ]
1716
2016
  }
1717
2017
  }
@@ -1826,12 +2126,20 @@
1826
2126
  "name": "round",
1827
2127
  "type": "u64"
1828
2128
  },
2129
+ {
2130
+ "name": "airdrop_count",
2131
+ "type": "u32"
2132
+ },
2133
+ {
2134
+ "name": "last_airdrop_ts",
2135
+ "type": "i64"
2136
+ },
1829
2137
  {
1830
2138
  "name": "_padding",
1831
2139
  "type": {
1832
2140
  "array": [
1833
2141
  "u8",
1834
- 64
2142
+ 52
1835
2143
  ]
1836
2144
  }
1837
2145
  }
@@ -102,6 +102,164 @@ export type NaraQuest = {
102
102
  }
103
103
  ]
104
104
  },
105
+ {
106
+ "name": "claimAirdrop",
107
+ "discriminator": [
108
+ 137,
109
+ 50,
110
+ 122,
111
+ 111,
112
+ 89,
113
+ 254,
114
+ 8,
115
+ 20
116
+ ],
117
+ "accounts": [
118
+ {
119
+ "name": "gameConfig",
120
+ "pda": {
121
+ "seeds": [
122
+ {
123
+ "kind": "const",
124
+ "value": [
125
+ 113,
126
+ 117,
127
+ 101,
128
+ 115,
129
+ 116,
130
+ 95,
131
+ 99,
132
+ 111,
133
+ 110,
134
+ 102,
135
+ 105,
136
+ 103
137
+ ]
138
+ }
139
+ ]
140
+ }
141
+ },
142
+ {
143
+ "name": "pool",
144
+ "pda": {
145
+ "seeds": [
146
+ {
147
+ "kind": "const",
148
+ "value": [
149
+ 113,
150
+ 117,
151
+ 101,
152
+ 115,
153
+ 116,
154
+ 95,
155
+ 112,
156
+ 111,
157
+ 111,
158
+ 108
159
+ ]
160
+ }
161
+ ]
162
+ }
163
+ },
164
+ {
165
+ "name": "winnerRecord",
166
+ "writable": true,
167
+ "pda": {
168
+ "seeds": [
169
+ {
170
+ "kind": "const",
171
+ "value": [
172
+ 113,
173
+ 117,
174
+ 101,
175
+ 115,
176
+ 116,
177
+ 95,
178
+ 119,
179
+ 105,
180
+ 110,
181
+ 110,
182
+ 101,
183
+ 114
184
+ ]
185
+ },
186
+ {
187
+ "kind": "account",
188
+ "path": "user"
189
+ }
190
+ ]
191
+ }
192
+ },
193
+ {
194
+ "name": "airdropFund",
195
+ "writable": true,
196
+ "pda": {
197
+ "seeds": [
198
+ {
199
+ "kind": "const",
200
+ "value": [
201
+ 113,
202
+ 117,
203
+ 101,
204
+ 115,
205
+ 116,
206
+ 95,
207
+ 97,
208
+ 105,
209
+ 114,
210
+ 100,
211
+ 114,
212
+ 111,
213
+ 112
214
+ ]
215
+ }
216
+ ]
217
+ }
218
+ },
219
+ {
220
+ "name": "user",
221
+ "writable": true
222
+ },
223
+ {
224
+ "name": "payer",
225
+ "writable": true,
226
+ "signer": true
227
+ },
228
+ {
229
+ "name": "systemProgram",
230
+ "address": "11111111111111111111111111111111"
231
+ }
232
+ ],
233
+ "args": [
234
+ {
235
+ "name": "proofA",
236
+ "type": {
237
+ "array": [
238
+ "u8",
239
+ 64
240
+ ]
241
+ }
242
+ },
243
+ {
244
+ "name": "proofB",
245
+ "type": {
246
+ "array": [
247
+ "u8",
248
+ 128
249
+ ]
250
+ }
251
+ },
252
+ {
253
+ "name": "proofC",
254
+ "type": {
255
+ "array": [
256
+ "u8",
257
+ 64
258
+ ]
259
+ }
260
+ }
261
+ ]
262
+ },
105
263
  {
106
264
  "name": "createQuestion",
107
265
  "discriminator": [
@@ -250,6 +408,61 @@ export type NaraQuest = {
250
408
  }
251
409
  ]
252
410
  },
411
+ {
412
+ "name": "expandConfig",
413
+ "discriminator": [
414
+ 120,
415
+ 201,
416
+ 195,
417
+ 128,
418
+ 35,
419
+ 202,
420
+ 73,
421
+ 161
422
+ ],
423
+ "accounts": [
424
+ {
425
+ "name": "gameConfig",
426
+ "writable": true,
427
+ "pda": {
428
+ "seeds": [
429
+ {
430
+ "kind": "const",
431
+ "value": [
432
+ 113,
433
+ 117,
434
+ 101,
435
+ 115,
436
+ 116,
437
+ 95,
438
+ 99,
439
+ 111,
440
+ 110,
441
+ 102,
442
+ 105,
443
+ 103
444
+ ]
445
+ }
446
+ ]
447
+ }
448
+ },
449
+ {
450
+ "name": "authority",
451
+ "writable": true,
452
+ "signer": true
453
+ },
454
+ {
455
+ "name": "systemProgram",
456
+ "address": "11111111111111111111111111111111"
457
+ }
458
+ ],
459
+ "args": [
460
+ {
461
+ "name": "additionalSize",
462
+ "type": "u32"
463
+ }
464
+ ]
465
+ },
253
466
  {
254
467
  "name": "initialize",
255
468
  "discriminator": [
@@ -349,6 +562,60 @@ export type NaraQuest = {
349
562
  ],
350
563
  "args": []
351
564
  },
565
+ {
566
+ "name": "setAirdropConfig",
567
+ "discriminator": [
568
+ 255,
569
+ 181,
570
+ 252,
571
+ 34,
572
+ 155,
573
+ 230,
574
+ 65,
575
+ 227
576
+ ],
577
+ "accounts": [
578
+ {
579
+ "name": "gameConfig",
580
+ "writable": true,
581
+ "pda": {
582
+ "seeds": [
583
+ {
584
+ "kind": "const",
585
+ "value": [
586
+ 113,
587
+ 117,
588
+ 101,
589
+ 115,
590
+ 116,
591
+ 95,
592
+ 99,
593
+ 111,
594
+ 110,
595
+ 102,
596
+ 105,
597
+ 103
598
+ ]
599
+ }
600
+ ]
601
+ }
602
+ },
603
+ {
604
+ "name": "authority",
605
+ "signer": true
606
+ }
607
+ ],
608
+ "args": [
609
+ {
610
+ "name": "airdropAmount",
611
+ "type": "u64"
612
+ },
613
+ {
614
+ "name": "maxAirdropCount",
615
+ "type": "u32"
616
+ }
617
+ ]
618
+ },
352
619
  {
353
620
  "name": "setQuestAuthority",
354
621
  "discriminator": [
@@ -1624,6 +1891,31 @@ export type NaraQuest = {
1624
1891
  "code": 6017,
1625
1892
  "name": "freeCreditsOverflow",
1626
1893
  "msg": "Free credits overflow"
1894
+ },
1895
+ {
1896
+ "code": 6018,
1897
+ "name": "airdropNotEligible",
1898
+ "msg": "Not eligible: must answer current round first"
1899
+ },
1900
+ {
1901
+ "code": 6019,
1902
+ "name": "airdropMaxReached",
1903
+ "msg": "Max airdrop count reached for this address"
1904
+ },
1905
+ {
1906
+ "code": 6020,
1907
+ "name": "airdropCooldown",
1908
+ "msg": "Must wait 24 hours between airdrop claims"
1909
+ },
1910
+ {
1911
+ "code": 6021,
1912
+ "name": "airdropDisabled",
1913
+ "msg": "Airdrop is disabled (amount = 0)"
1914
+ },
1915
+ {
1916
+ "code": 6022,
1917
+ "name": "insufficientAirdrop",
1918
+ "msg": "Airdrop fund has insufficient balance"
1627
1919
  }
1628
1920
  ],
1629
1921
  "types": [
@@ -1712,12 +2004,20 @@ export type NaraQuest = {
1712
2004
  "name": "stakeAuthority",
1713
2005
  "type": "pubkey"
1714
2006
  },
2007
+ {
2008
+ "name": "airdropAmount",
2009
+ "type": "u64"
2010
+ },
2011
+ {
2012
+ "name": "maxAirdropCount",
2013
+ "type": "u32"
2014
+ },
1715
2015
  {
1716
2016
  "name": "padding",
1717
2017
  "type": {
1718
2018
  "array": [
1719
2019
  "u8",
1720
- 32
2020
+ 20
1721
2021
  ]
1722
2022
  }
1723
2023
  }
@@ -1832,12 +2132,20 @@ export type NaraQuest = {
1832
2132
  "name": "round",
1833
2133
  "type": "u64"
1834
2134
  },
2135
+ {
2136
+ "name": "airdropCount",
2137
+ "type": "u32"
2138
+ },
2139
+ {
2140
+ "name": "lastAirdropTs",
2141
+ "type": "i64"
2142
+ },
1835
2143
  {
1836
2144
  "name": "padding",
1837
2145
  "type": {
1838
2146
  "array": [
1839
2147
  "u8",
1840
- 64
2148
+ 52
1841
2149
  ]
1842
2150
  }
1843
2151
  }
package/src/quest.ts CHANGED
@@ -853,6 +853,8 @@ export async function getQuestConfig(
853
853
  rewardPerShare: number;
854
854
  extraReward: number;
855
855
  stakeAuthority: PublicKey;
856
+ airdropAmount: number;
857
+ maxAirdropCount: number;
856
858
  }> {
857
859
  const kp = Keypair.generate();
858
860
  const program = createProgram(connection, kp, options?.programId);
@@ -875,6 +877,8 @@ export async function getQuestConfig(
875
877
  rewardPerShare: Number(config.rewardPerShare.toString()),
876
878
  extraReward: Number(config.extraReward.toString()),
877
879
  stakeAuthority: config.stakeAuthority,
880
+ airdropAmount: Number(config.airdropAmount.toString()),
881
+ maxAirdropCount: config.maxAirdropCount,
878
882
  };
879
883
  }
880
884
 
@@ -930,3 +934,43 @@ export async function adjustFreeStake(
930
934
  const ix = await makeAdjustFreeStakeIx(connection, wallet.publicKey, user, delta, reason, options);
931
935
  return sendTx(connection, wallet, [ix]);
932
936
  }
937
+
938
+ /**
939
+ * Claim airdrop for a user. The payer pays for the transaction.
940
+ * @param user - The user to claim airdrop for
941
+ */
942
+ export async function claimAirdrop(
943
+ connection: Connection,
944
+ wallet: Keypair,
945
+ user: PublicKey,
946
+ proof: ZkProof,
947
+ options?: QuestOptions
948
+ ): Promise<string> {
949
+ const program = createProgram(connection, wallet, options?.programId);
950
+ const ix = await program.methods
951
+ .claimAirdrop(proof.proofA as any, proof.proofB as any, proof.proofC as any)
952
+ .accounts({ user, payer: wallet.publicKey } as any)
953
+ .instruction();
954
+ return sendTx(connection, wallet, [ix]);
955
+ }
956
+
957
+ /**
958
+ * Set airdrop configuration (authority only).
959
+ * @param airdropAmount - Amount per airdrop in lamports
960
+ * @param maxAirdropCount - Maximum number of airdrops per user
961
+ */
962
+ export async function setAirdropConfig(
963
+ connection: Connection,
964
+ wallet: Keypair,
965
+ airdropAmount: number | BN,
966
+ maxAirdropCount: number,
967
+ options?: QuestOptions
968
+ ): Promise<string> {
969
+ const program = createProgram(connection, wallet, options?.programId);
970
+ const amt = typeof airdropAmount === "number" ? new BN(airdropAmount) : airdropAmount;
971
+ const ix = await program.methods
972
+ .setAirdropConfig(amt, maxAirdropCount)
973
+ .accounts({ authority: wallet.publicKey } as any)
974
+ .instruction();
975
+ return sendTx(connection, wallet, [ix]);
976
+ }