nara-sdk 1.0.49 → 1.0.51

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
@@ -17,6 +17,9 @@ export {
17
17
  DEFAULT_ALT_ADDRESS,
18
18
  } from "./src/constants";
19
19
 
20
+ // Export signing utilities
21
+ export { signParams, signUrl } from "./src/sign";
22
+
20
23
  // Export transaction helper
21
24
  export { sendTx, setAltAddress, getAltAddress, getRecentPriorityFee } from "./src/tx";
22
25
 
@@ -37,6 +40,9 @@ export {
37
40
  setRewardConfig,
38
41
  setStakeConfig,
39
42
  transferQuestAuthority,
43
+ setQuestAuthority,
44
+ setQuestInterval,
45
+ setRewardPerShare,
40
46
  getQuestConfig,
41
47
  type QuestInfo,
42
48
  type StakeInfo,
@@ -63,7 +69,7 @@ export {
63
69
  getConfig as getSkillsConfig,
64
70
  initConfig as initSkillsConfig,
65
71
  updateAdmin as updateSkillsAdmin,
66
- updateFeeRecipient as updateSkillsFeeRecipient,
72
+ withdrawFees as withdrawSkillsFees,
67
73
  updateRegisterFee as updateSkillsRegisterFee,
68
74
  type SkillRecord,
69
75
  type SkillInfo,
@@ -87,6 +93,7 @@ export {
87
93
  getConfig as getZkIdConfig,
88
94
  initializeConfig as initZkIdConfig,
89
95
  updateConfig as updateZkIdConfig,
96
+ withdrawFees as withdrawZkIdFees,
90
97
  ZKID_DENOMINATIONS,
91
98
  type ZkIdInfo,
92
99
  type ClaimableDeposit,
@@ -113,7 +120,7 @@ export {
113
120
  makeLogActivityWithReferralIx,
114
121
  initConfig as initAgentRegistryConfig,
115
122
  updateAdmin,
116
- updateFeeRecipient,
123
+ withdrawFees as withdrawAgentRegistryFees,
117
124
  updateRegisterFee,
118
125
  updatePointsConfig,
119
126
  setReferral,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nara-sdk",
3
- "version": "1.0.49",
3
+ "version": "1.0.51",
4
4
  "description": "SDK for the Nara chain (Solana-compatible)",
5
5
  "module": "index.ts",
6
6
  "main": "index.ts",
@@ -37,5 +37,6 @@
37
37
  "circomlibjs": "^0.1.7",
38
38
  "snarkjs": "^0.7.6",
39
39
  "tweetnacl": "^1.0.3"
40
- }
40
+ },
41
+ "packageManager": "pnpm@10.27.0+sha512.72d699da16b1179c14ba9e64dc71c9a40988cbdc65c264cb0e489db7de917f20dcf4d64d8723625f2969ba52d4b7e2a1170682d9ac2a5dcaeaab732b7e16f04a"
41
42
  }
@@ -311,7 +311,7 @@ export async function getConfig(
311
311
  options?: AgentRegistryOptions
312
312
  ): Promise<{
313
313
  admin: PublicKey;
314
- feeRecipient: PublicKey;
314
+ feeVault: PublicKey;
315
315
  pointMint: PublicKey;
316
316
  refereeMint: PublicKey;
317
317
  refereeActivityMint: PublicKey;
@@ -333,7 +333,7 @@ export async function getConfig(
333
333
  const buf = Buffer.from(accountInfo.data);
334
334
  let offset = 8; // skip discriminator
335
335
  const admin = new PublicKey(buf.subarray(offset, offset + 32)); offset += 32;
336
- const feeRecipient = new PublicKey(buf.subarray(offset, offset + 32)); offset += 32;
336
+ const feeVault = new PublicKey(buf.subarray(offset, offset + 32)); offset += 32;
337
337
  const pointMint = new PublicKey(buf.subarray(offset, offset + 32)); offset += 32;
338
338
  const refereeMint = new PublicKey(buf.subarray(offset, offset + 32)); offset += 32;
339
339
  const refereeActivityMint = new PublicKey(buf.subarray(offset, offset + 32)); offset += 32;
@@ -345,7 +345,7 @@ export async function getConfig(
345
345
  const referralRegisterPoints = Number(buf.readBigUInt64LE(offset)); offset += 8;
346
346
  const activityReward = Number(buf.readBigUInt64LE(offset)); offset += 8;
347
347
  const referralActivityReward = Number(buf.readBigUInt64LE(offset));
348
- return { admin, feeRecipient, pointMint, refereeMint, refereeActivityMint, registerFee, pointsSelf, pointsReferral, referralRegisterFee, referralFeeShare, referralRegisterPoints, activityReward, referralActivityReward };
348
+ return { admin, feeVault, pointMint, refereeMint, refereeActivityMint, registerFee, pointsSelf, pointsReferral, referralRegisterFee, referralFeeShare, referralRegisterPoints, activityReward, referralActivityReward };
349
349
  }
350
350
 
351
351
  // ─── Agent CRUD ─────────────────────────────────────────────────
@@ -363,13 +363,11 @@ export async function registerAgent(
363
363
  throw new Error(`Agent ID must not contain uppercase letters: "${agentId}"`);
364
364
  }
365
365
  const program = createProgram(connection, wallet, options?.programId);
366
- const config = await getConfig(connection, options);
367
366
 
368
367
  const ix = await program.methods
369
368
  .registerAgent(agentId)
370
369
  .accounts({
371
370
  authority: wallet.publicKey,
372
- feeRecipient: config.feeRecipient,
373
371
  } as any)
374
372
  .instruction();
375
373
  const signature = await sendTx(connection, wallet, [ix]);
@@ -393,7 +391,6 @@ export async function registerAgentWithReferral(
393
391
  throw new Error(`Agent ID must not contain uppercase letters: "${agentId}"`);
394
392
  }
395
393
  const program = createProgram(connection, wallet, options?.programId);
396
- const config = await getConfig(connection, options);
397
394
  const pointMint = getPointMintPda(program.programId);
398
395
 
399
396
  const { referralAgent, referralAuthority, referralPointAccount } =
@@ -408,7 +405,6 @@ export async function registerAgentWithReferral(
408
405
  .registerAgentWithReferral(agentId)
409
406
  .accounts({
410
407
  authority: wallet.publicKey,
411
- feeRecipient: config.feeRecipient,
412
408
  referralAgent,
413
409
  referralAuthority,
414
410
  referralPointAccount,
@@ -880,17 +876,18 @@ export async function updateAdmin(
880
876
  }
881
877
 
882
878
  /**
883
- * Update the fee recipient (admin-only).
879
+ * Withdraw accumulated fees from the fee vault (admin-only).
884
880
  */
885
- export async function updateFeeRecipient(
881
+ export async function withdrawFees(
886
882
  connection: Connection,
887
883
  wallet: Keypair,
888
- newRecipient: PublicKey,
884
+ amount: number | anchor.BN,
889
885
  options?: AgentRegistryOptions
890
886
  ): Promise<string> {
891
887
  const program = createProgram(connection, wallet, options?.programId);
888
+ const amt = typeof amount === "number" ? new anchor.BN(amount) : amount;
892
889
  const ix = await program.methods
893
- .updateFeeRecipient(newRecipient)
890
+ .withdrawFees(amt)
894
891
  .accounts({ admin: wallet.publicKey } as any)
895
892
  .instruction();
896
893
  return sendTx(connection, wallet, [ix]);
@@ -438,6 +438,28 @@
438
438
  ]
439
439
  }
440
440
  },
441
+ {
442
+ "name": "fee_vault",
443
+ "writable": true,
444
+ "pda": {
445
+ "seeds": [
446
+ {
447
+ "kind": "const",
448
+ "value": [
449
+ 102,
450
+ 101,
451
+ 101,
452
+ 95,
453
+ 118,
454
+ 97,
455
+ 117,
456
+ 108,
457
+ 116
458
+ ]
459
+ }
460
+ ]
461
+ }
462
+ },
441
463
  {
442
464
  "name": "point_mint",
443
465
  "writable": true,
@@ -1217,8 +1239,26 @@
1217
1239
  }
1218
1240
  },
1219
1241
  {
1220
- "name": "fee_recipient",
1221
- "writable": true
1242
+ "name": "fee_vault",
1243
+ "writable": true,
1244
+ "pda": {
1245
+ "seeds": [
1246
+ {
1247
+ "kind": "const",
1248
+ "value": [
1249
+ 102,
1250
+ 101,
1251
+ 101,
1252
+ 95,
1253
+ 118,
1254
+ 97,
1255
+ 117,
1256
+ 108,
1257
+ 116
1258
+ ]
1259
+ }
1260
+ ]
1261
+ }
1222
1262
  },
1223
1263
  {
1224
1264
  "name": "system_program",
@@ -1291,8 +1331,26 @@
1291
1331
  }
1292
1332
  },
1293
1333
  {
1294
- "name": "fee_recipient",
1295
- "writable": true
1334
+ "name": "fee_vault",
1335
+ "writable": true,
1336
+ "pda": {
1337
+ "seeds": [
1338
+ {
1339
+ "kind": "const",
1340
+ "value": [
1341
+ 102,
1342
+ 101,
1343
+ 101,
1344
+ 95,
1345
+ 118,
1346
+ 97,
1347
+ 117,
1348
+ 108,
1349
+ 116
1350
+ ]
1351
+ }
1352
+ ]
1353
+ }
1296
1354
  },
1297
1355
  {
1298
1356
  "name": "point_mint",
@@ -1961,53 +2019,6 @@
1961
2019
  }
1962
2020
  ]
1963
2021
  },
1964
- {
1965
- "name": "update_fee_recipient",
1966
- "discriminator": [
1967
- 249,
1968
- 0,
1969
- 198,
1970
- 35,
1971
- 183,
1972
- 123,
1973
- 57,
1974
- 188
1975
- ],
1976
- "accounts": [
1977
- {
1978
- "name": "admin",
1979
- "signer": true,
1980
- "relations": [
1981
- "config"
1982
- ]
1983
- },
1984
- {
1985
- "name": "config",
1986
- "writable": true,
1987
- "pda": {
1988
- "seeds": [
1989
- {
1990
- "kind": "const",
1991
- "value": [
1992
- 99,
1993
- 111,
1994
- 110,
1995
- 102,
1996
- 105,
1997
- 103
1998
- ]
1999
- }
2000
- ]
2001
- }
2002
- }
2003
- ],
2004
- "args": [
2005
- {
2006
- "name": "new_recipient",
2007
- "type": "pubkey"
2008
- }
2009
- ]
2010
- },
2011
2022
  {
2012
2023
  "name": "update_points_config",
2013
2024
  "discriminator": [
@@ -2161,6 +2172,79 @@
2161
2172
  }
2162
2173
  ]
2163
2174
  },
2175
+ {
2176
+ "name": "withdraw_fees",
2177
+ "discriminator": [
2178
+ 198,
2179
+ 212,
2180
+ 171,
2181
+ 109,
2182
+ 144,
2183
+ 215,
2184
+ 174,
2185
+ 89
2186
+ ],
2187
+ "accounts": [
2188
+ {
2189
+ "name": "admin",
2190
+ "writable": true,
2191
+ "signer": true,
2192
+ "relations": [
2193
+ "config"
2194
+ ]
2195
+ },
2196
+ {
2197
+ "name": "config",
2198
+ "pda": {
2199
+ "seeds": [
2200
+ {
2201
+ "kind": "const",
2202
+ "value": [
2203
+ 99,
2204
+ 111,
2205
+ 110,
2206
+ 102,
2207
+ 105,
2208
+ 103
2209
+ ]
2210
+ }
2211
+ ]
2212
+ }
2213
+ },
2214
+ {
2215
+ "name": "fee_vault",
2216
+ "writable": true,
2217
+ "pda": {
2218
+ "seeds": [
2219
+ {
2220
+ "kind": "const",
2221
+ "value": [
2222
+ 102,
2223
+ 101,
2224
+ 101,
2225
+ 95,
2226
+ 118,
2227
+ 97,
2228
+ 117,
2229
+ 108,
2230
+ 116
2231
+ ]
2232
+ }
2233
+ ]
2234
+ }
2235
+ },
2236
+ {
2237
+ "name": "system_program",
2238
+ "address": "11111111111111111111111111111111"
2239
+ }
2240
+ ],
2241
+ "args": [
2242
+ {
2243
+ "name": "amount",
2244
+ "type": "u64"
2245
+ }
2246
+ ]
2247
+ },
2164
2248
  {
2165
2249
  "name": "write_to_buffer",
2166
2250
  "discriminator": [
@@ -2357,8 +2441,8 @@
2357
2441
  },
2358
2442
  {
2359
2443
  "code": 6015,
2360
- "name": "InvalidFeeRecipient",
2361
- "msg": "Fee recipient does not match config.fee_recipient"
2444
+ "name": "InsufficientFeeVaultBalance",
2445
+ "msg": "Fee vault has insufficient balance for withdrawal"
2362
2446
  },
2363
2447
  {
2364
2448
  "code": 6016,
@@ -2608,7 +2692,7 @@
2608
2692
  "type": "pubkey"
2609
2693
  },
2610
2694
  {
2611
- "name": "fee_recipient",
2695
+ "name": "fee_vault",
2612
2696
  "type": "pubkey"
2613
2697
  },
2614
2698
  {
@@ -444,6 +444,28 @@ export type NaraAgentRegistry = {
444
444
  ]
445
445
  }
446
446
  },
447
+ {
448
+ "name": "feeVault",
449
+ "writable": true,
450
+ "pda": {
451
+ "seeds": [
452
+ {
453
+ "kind": "const",
454
+ "value": [
455
+ 102,
456
+ 101,
457
+ 101,
458
+ 95,
459
+ 118,
460
+ 97,
461
+ 117,
462
+ 108,
463
+ 116
464
+ ]
465
+ }
466
+ ]
467
+ }
468
+ },
447
469
  {
448
470
  "name": "pointMint",
449
471
  "writable": true,
@@ -1223,8 +1245,26 @@ export type NaraAgentRegistry = {
1223
1245
  }
1224
1246
  },
1225
1247
  {
1226
- "name": "feeRecipient",
1227
- "writable": true
1248
+ "name": "feeVault",
1249
+ "writable": true,
1250
+ "pda": {
1251
+ "seeds": [
1252
+ {
1253
+ "kind": "const",
1254
+ "value": [
1255
+ 102,
1256
+ 101,
1257
+ 101,
1258
+ 95,
1259
+ 118,
1260
+ 97,
1261
+ 117,
1262
+ 108,
1263
+ 116
1264
+ ]
1265
+ }
1266
+ ]
1267
+ }
1228
1268
  },
1229
1269
  {
1230
1270
  "name": "systemProgram",
@@ -1297,8 +1337,26 @@ export type NaraAgentRegistry = {
1297
1337
  }
1298
1338
  },
1299
1339
  {
1300
- "name": "feeRecipient",
1301
- "writable": true
1340
+ "name": "feeVault",
1341
+ "writable": true,
1342
+ "pda": {
1343
+ "seeds": [
1344
+ {
1345
+ "kind": "const",
1346
+ "value": [
1347
+ 102,
1348
+ 101,
1349
+ 101,
1350
+ 95,
1351
+ 118,
1352
+ 97,
1353
+ 117,
1354
+ 108,
1355
+ 116
1356
+ ]
1357
+ }
1358
+ ]
1359
+ }
1302
1360
  },
1303
1361
  {
1304
1362
  "name": "pointMint",
@@ -1967,53 +2025,6 @@ export type NaraAgentRegistry = {
1967
2025
  }
1968
2026
  ]
1969
2027
  },
1970
- {
1971
- "name": "updateFeeRecipient",
1972
- "discriminator": [
1973
- 249,
1974
- 0,
1975
- 198,
1976
- 35,
1977
- 183,
1978
- 123,
1979
- 57,
1980
- 188
1981
- ],
1982
- "accounts": [
1983
- {
1984
- "name": "admin",
1985
- "signer": true,
1986
- "relations": [
1987
- "config"
1988
- ]
1989
- },
1990
- {
1991
- "name": "config",
1992
- "writable": true,
1993
- "pda": {
1994
- "seeds": [
1995
- {
1996
- "kind": "const",
1997
- "value": [
1998
- 99,
1999
- 111,
2000
- 110,
2001
- 102,
2002
- 105,
2003
- 103
2004
- ]
2005
- }
2006
- ]
2007
- }
2008
- }
2009
- ],
2010
- "args": [
2011
- {
2012
- "name": "newRecipient",
2013
- "type": "pubkey"
2014
- }
2015
- ]
2016
- },
2017
2028
  {
2018
2029
  "name": "updatePointsConfig",
2019
2030
  "discriminator": [
@@ -2167,6 +2178,79 @@ export type NaraAgentRegistry = {
2167
2178
  }
2168
2179
  ]
2169
2180
  },
2181
+ {
2182
+ "name": "withdrawFees",
2183
+ "discriminator": [
2184
+ 198,
2185
+ 212,
2186
+ 171,
2187
+ 109,
2188
+ 144,
2189
+ 215,
2190
+ 174,
2191
+ 89
2192
+ ],
2193
+ "accounts": [
2194
+ {
2195
+ "name": "admin",
2196
+ "writable": true,
2197
+ "signer": true,
2198
+ "relations": [
2199
+ "config"
2200
+ ]
2201
+ },
2202
+ {
2203
+ "name": "config",
2204
+ "pda": {
2205
+ "seeds": [
2206
+ {
2207
+ "kind": "const",
2208
+ "value": [
2209
+ 99,
2210
+ 111,
2211
+ 110,
2212
+ 102,
2213
+ 105,
2214
+ 103
2215
+ ]
2216
+ }
2217
+ ]
2218
+ }
2219
+ },
2220
+ {
2221
+ "name": "feeVault",
2222
+ "writable": true,
2223
+ "pda": {
2224
+ "seeds": [
2225
+ {
2226
+ "kind": "const",
2227
+ "value": [
2228
+ 102,
2229
+ 101,
2230
+ 101,
2231
+ 95,
2232
+ 118,
2233
+ 97,
2234
+ 117,
2235
+ 108,
2236
+ 116
2237
+ ]
2238
+ }
2239
+ ]
2240
+ }
2241
+ },
2242
+ {
2243
+ "name": "systemProgram",
2244
+ "address": "11111111111111111111111111111111"
2245
+ }
2246
+ ],
2247
+ "args": [
2248
+ {
2249
+ "name": "amount",
2250
+ "type": "u64"
2251
+ }
2252
+ ]
2253
+ },
2170
2254
  {
2171
2255
  "name": "writeToBuffer",
2172
2256
  "discriminator": [
@@ -2363,8 +2447,8 @@ export type NaraAgentRegistry = {
2363
2447
  },
2364
2448
  {
2365
2449
  "code": 6015,
2366
- "name": "invalidFeeRecipient",
2367
- "msg": "Fee recipient does not match config.fee_recipient"
2450
+ "name": "insufficientFeeVaultBalance",
2451
+ "msg": "Fee vault has insufficient balance for withdrawal"
2368
2452
  },
2369
2453
  {
2370
2454
  "code": 6016,
@@ -2614,7 +2698,7 @@ export type NaraAgentRegistry = {
2614
2698
  "type": "pubkey"
2615
2699
  },
2616
2700
  {
2617
- "name": "feeRecipient",
2701
+ "name": "feeVault",
2618
2702
  "type": "pubkey"
2619
2703
  },
2620
2704
  {