nara-sdk 1.0.65 → 1.0.66
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 +2 -0
- package/package.json +1 -1
- package/src/idls/nara_quest.json +227 -2
- package/src/idls/nara_quest.ts +227 -2
- package/src/quest.ts +43 -0
package/index.ts
CHANGED
package/package.json
CHANGED
package/src/idls/nara_quest.json
CHANGED
|
@@ -96,6 +96,136 @@
|
|
|
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
|
+
},
|
|
99
229
|
{
|
|
100
230
|
"name": "create_question",
|
|
101
231
|
"discriminator": [
|
|
@@ -343,6 +473,60 @@
|
|
|
343
473
|
],
|
|
344
474
|
"args": []
|
|
345
475
|
},
|
|
476
|
+
{
|
|
477
|
+
"name": "set_airdrop_config",
|
|
478
|
+
"discriminator": [
|
|
479
|
+
255,
|
|
480
|
+
181,
|
|
481
|
+
252,
|
|
482
|
+
34,
|
|
483
|
+
155,
|
|
484
|
+
230,
|
|
485
|
+
65,
|
|
486
|
+
227
|
|
487
|
+
],
|
|
488
|
+
"accounts": [
|
|
489
|
+
{
|
|
490
|
+
"name": "game_config",
|
|
491
|
+
"writable": true,
|
|
492
|
+
"pda": {
|
|
493
|
+
"seeds": [
|
|
494
|
+
{
|
|
495
|
+
"kind": "const",
|
|
496
|
+
"value": [
|
|
497
|
+
113,
|
|
498
|
+
117,
|
|
499
|
+
101,
|
|
500
|
+
115,
|
|
501
|
+
116,
|
|
502
|
+
95,
|
|
503
|
+
99,
|
|
504
|
+
111,
|
|
505
|
+
110,
|
|
506
|
+
102,
|
|
507
|
+
105,
|
|
508
|
+
103
|
|
509
|
+
]
|
|
510
|
+
}
|
|
511
|
+
]
|
|
512
|
+
}
|
|
513
|
+
},
|
|
514
|
+
{
|
|
515
|
+
"name": "authority",
|
|
516
|
+
"signer": true
|
|
517
|
+
}
|
|
518
|
+
],
|
|
519
|
+
"args": [
|
|
520
|
+
{
|
|
521
|
+
"name": "airdrop_amount",
|
|
522
|
+
"type": "u64"
|
|
523
|
+
},
|
|
524
|
+
{
|
|
525
|
+
"name": "max_airdrop_count",
|
|
526
|
+
"type": "u32"
|
|
527
|
+
}
|
|
528
|
+
]
|
|
529
|
+
},
|
|
346
530
|
{
|
|
347
531
|
"name": "set_quest_authority",
|
|
348
532
|
"discriminator": [
|
|
@@ -1618,6 +1802,31 @@
|
|
|
1618
1802
|
"code": 6017,
|
|
1619
1803
|
"name": "FreeCreditsOverflow",
|
|
1620
1804
|
"msg": "Free credits overflow"
|
|
1805
|
+
},
|
|
1806
|
+
{
|
|
1807
|
+
"code": 6018,
|
|
1808
|
+
"name": "AirdropNotEligible",
|
|
1809
|
+
"msg": "Not eligible: must answer current round first"
|
|
1810
|
+
},
|
|
1811
|
+
{
|
|
1812
|
+
"code": 6019,
|
|
1813
|
+
"name": "AirdropMaxReached",
|
|
1814
|
+
"msg": "Max airdrop count reached for this address"
|
|
1815
|
+
},
|
|
1816
|
+
{
|
|
1817
|
+
"code": 6020,
|
|
1818
|
+
"name": "AirdropCooldown",
|
|
1819
|
+
"msg": "Must wait 24 hours between airdrop claims"
|
|
1820
|
+
},
|
|
1821
|
+
{
|
|
1822
|
+
"code": 6021,
|
|
1823
|
+
"name": "AirdropDisabled",
|
|
1824
|
+
"msg": "Airdrop is disabled (amount = 0)"
|
|
1825
|
+
},
|
|
1826
|
+
{
|
|
1827
|
+
"code": 6022,
|
|
1828
|
+
"name": "InsufficientAirdrop",
|
|
1829
|
+
"msg": "Airdrop fund has insufficient balance"
|
|
1621
1830
|
}
|
|
1622
1831
|
],
|
|
1623
1832
|
"types": [
|
|
@@ -1706,12 +1915,20 @@
|
|
|
1706
1915
|
"name": "stake_authority",
|
|
1707
1916
|
"type": "pubkey"
|
|
1708
1917
|
},
|
|
1918
|
+
{
|
|
1919
|
+
"name": "airdrop_amount",
|
|
1920
|
+
"type": "u64"
|
|
1921
|
+
},
|
|
1922
|
+
{
|
|
1923
|
+
"name": "max_airdrop_count",
|
|
1924
|
+
"type": "u32"
|
|
1925
|
+
},
|
|
1709
1926
|
{
|
|
1710
1927
|
"name": "_padding",
|
|
1711
1928
|
"type": {
|
|
1712
1929
|
"array": [
|
|
1713
1930
|
"u8",
|
|
1714
|
-
|
|
1931
|
+
20
|
|
1715
1932
|
]
|
|
1716
1933
|
}
|
|
1717
1934
|
}
|
|
@@ -1826,12 +2043,20 @@
|
|
|
1826
2043
|
"name": "round",
|
|
1827
2044
|
"type": "u64"
|
|
1828
2045
|
},
|
|
2046
|
+
{
|
|
2047
|
+
"name": "airdrop_count",
|
|
2048
|
+
"type": "u32"
|
|
2049
|
+
},
|
|
2050
|
+
{
|
|
2051
|
+
"name": "last_airdrop_ts",
|
|
2052
|
+
"type": "i64"
|
|
2053
|
+
},
|
|
1829
2054
|
{
|
|
1830
2055
|
"name": "_padding",
|
|
1831
2056
|
"type": {
|
|
1832
2057
|
"array": [
|
|
1833
2058
|
"u8",
|
|
1834
|
-
|
|
2059
|
+
52
|
|
1835
2060
|
]
|
|
1836
2061
|
}
|
|
1837
2062
|
}
|
package/src/idls/nara_quest.ts
CHANGED
|
@@ -102,6 +102,136 @@ 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
|
+
},
|
|
105
235
|
{
|
|
106
236
|
"name": "createQuestion",
|
|
107
237
|
"discriminator": [
|
|
@@ -349,6 +479,60 @@ export type NaraQuest = {
|
|
|
349
479
|
],
|
|
350
480
|
"args": []
|
|
351
481
|
},
|
|
482
|
+
{
|
|
483
|
+
"name": "setAirdropConfig",
|
|
484
|
+
"discriminator": [
|
|
485
|
+
255,
|
|
486
|
+
181,
|
|
487
|
+
252,
|
|
488
|
+
34,
|
|
489
|
+
155,
|
|
490
|
+
230,
|
|
491
|
+
65,
|
|
492
|
+
227
|
|
493
|
+
],
|
|
494
|
+
"accounts": [
|
|
495
|
+
{
|
|
496
|
+
"name": "gameConfig",
|
|
497
|
+
"writable": true,
|
|
498
|
+
"pda": {
|
|
499
|
+
"seeds": [
|
|
500
|
+
{
|
|
501
|
+
"kind": "const",
|
|
502
|
+
"value": [
|
|
503
|
+
113,
|
|
504
|
+
117,
|
|
505
|
+
101,
|
|
506
|
+
115,
|
|
507
|
+
116,
|
|
508
|
+
95,
|
|
509
|
+
99,
|
|
510
|
+
111,
|
|
511
|
+
110,
|
|
512
|
+
102,
|
|
513
|
+
105,
|
|
514
|
+
103
|
|
515
|
+
]
|
|
516
|
+
}
|
|
517
|
+
]
|
|
518
|
+
}
|
|
519
|
+
},
|
|
520
|
+
{
|
|
521
|
+
"name": "authority",
|
|
522
|
+
"signer": true
|
|
523
|
+
}
|
|
524
|
+
],
|
|
525
|
+
"args": [
|
|
526
|
+
{
|
|
527
|
+
"name": "airdropAmount",
|
|
528
|
+
"type": "u64"
|
|
529
|
+
},
|
|
530
|
+
{
|
|
531
|
+
"name": "maxAirdropCount",
|
|
532
|
+
"type": "u32"
|
|
533
|
+
}
|
|
534
|
+
]
|
|
535
|
+
},
|
|
352
536
|
{
|
|
353
537
|
"name": "setQuestAuthority",
|
|
354
538
|
"discriminator": [
|
|
@@ -1624,6 +1808,31 @@ export type NaraQuest = {
|
|
|
1624
1808
|
"code": 6017,
|
|
1625
1809
|
"name": "freeCreditsOverflow",
|
|
1626
1810
|
"msg": "Free credits overflow"
|
|
1811
|
+
},
|
|
1812
|
+
{
|
|
1813
|
+
"code": 6018,
|
|
1814
|
+
"name": "airdropNotEligible",
|
|
1815
|
+
"msg": "Not eligible: must answer current round first"
|
|
1816
|
+
},
|
|
1817
|
+
{
|
|
1818
|
+
"code": 6019,
|
|
1819
|
+
"name": "airdropMaxReached",
|
|
1820
|
+
"msg": "Max airdrop count reached for this address"
|
|
1821
|
+
},
|
|
1822
|
+
{
|
|
1823
|
+
"code": 6020,
|
|
1824
|
+
"name": "airdropCooldown",
|
|
1825
|
+
"msg": "Must wait 24 hours between airdrop claims"
|
|
1826
|
+
},
|
|
1827
|
+
{
|
|
1828
|
+
"code": 6021,
|
|
1829
|
+
"name": "airdropDisabled",
|
|
1830
|
+
"msg": "Airdrop is disabled (amount = 0)"
|
|
1831
|
+
},
|
|
1832
|
+
{
|
|
1833
|
+
"code": 6022,
|
|
1834
|
+
"name": "insufficientAirdrop",
|
|
1835
|
+
"msg": "Airdrop fund has insufficient balance"
|
|
1627
1836
|
}
|
|
1628
1837
|
],
|
|
1629
1838
|
"types": [
|
|
@@ -1712,12 +1921,20 @@ export type NaraQuest = {
|
|
|
1712
1921
|
"name": "stakeAuthority",
|
|
1713
1922
|
"type": "pubkey"
|
|
1714
1923
|
},
|
|
1924
|
+
{
|
|
1925
|
+
"name": "airdropAmount",
|
|
1926
|
+
"type": "u64"
|
|
1927
|
+
},
|
|
1928
|
+
{
|
|
1929
|
+
"name": "maxAirdropCount",
|
|
1930
|
+
"type": "u32"
|
|
1931
|
+
},
|
|
1715
1932
|
{
|
|
1716
1933
|
"name": "padding",
|
|
1717
1934
|
"type": {
|
|
1718
1935
|
"array": [
|
|
1719
1936
|
"u8",
|
|
1720
|
-
|
|
1937
|
+
20
|
|
1721
1938
|
]
|
|
1722
1939
|
}
|
|
1723
1940
|
}
|
|
@@ -1832,12 +2049,20 @@ export type NaraQuest = {
|
|
|
1832
2049
|
"name": "round",
|
|
1833
2050
|
"type": "u64"
|
|
1834
2051
|
},
|
|
2052
|
+
{
|
|
2053
|
+
"name": "airdropCount",
|
|
2054
|
+
"type": "u32"
|
|
2055
|
+
},
|
|
2056
|
+
{
|
|
2057
|
+
"name": "lastAirdropTs",
|
|
2058
|
+
"type": "i64"
|
|
2059
|
+
},
|
|
1835
2060
|
{
|
|
1836
2061
|
"name": "padding",
|
|
1837
2062
|
"type": {
|
|
1838
2063
|
"array": [
|
|
1839
2064
|
"u8",
|
|
1840
|
-
|
|
2065
|
+
52
|
|
1841
2066
|
]
|
|
1842
2067
|
}
|
|
1843
2068
|
}
|
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,42 @@ 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
|
+
options?: QuestOptions
|
|
947
|
+
): Promise<string> {
|
|
948
|
+
const program = createProgram(connection, wallet, options?.programId);
|
|
949
|
+
const ix = await program.methods
|
|
950
|
+
.claimAirdrop()
|
|
951
|
+
.accounts({ user, payer: wallet.publicKey } as any)
|
|
952
|
+
.instruction();
|
|
953
|
+
return sendTx(connection, wallet, [ix]);
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
/**
|
|
957
|
+
* Set airdrop configuration (authority only).
|
|
958
|
+
* @param airdropAmount - Amount per airdrop in lamports
|
|
959
|
+
* @param maxAirdropCount - Maximum number of airdrops per user
|
|
960
|
+
*/
|
|
961
|
+
export async function setAirdropConfig(
|
|
962
|
+
connection: Connection,
|
|
963
|
+
wallet: Keypair,
|
|
964
|
+
airdropAmount: number | BN,
|
|
965
|
+
maxAirdropCount: number,
|
|
966
|
+
options?: QuestOptions
|
|
967
|
+
): Promise<string> {
|
|
968
|
+
const program = createProgram(connection, wallet, options?.programId);
|
|
969
|
+
const amt = typeof airdropAmount === "number" ? new BN(airdropAmount) : airdropAmount;
|
|
970
|
+
const ix = await program.methods
|
|
971
|
+
.setAirdropConfig(amt, maxAirdropCount)
|
|
972
|
+
.accounts({ authority: wallet.publicKey } as any)
|
|
973
|
+
.instruction();
|
|
974
|
+
return sendTx(connection, wallet, [ix]);
|
|
975
|
+
}
|