nara-sdk 1.0.58 → 1.0.60

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
@@ -45,6 +45,7 @@ export {
45
45
  setQuestInterval,
46
46
  setRewardPerShare,
47
47
  setStakeAuthority,
48
+ makeAdjustFreeStakeIx,
48
49
  adjustFreeStake,
49
50
  getQuestConfig,
50
51
  type QuestInfo,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nara-sdk",
3
- "version": "1.0.58",
3
+ "version": "1.0.60",
4
4
  "description": "SDK for the Nara chain (Solana-compatible)",
5
5
  "module": "index.ts",
6
6
  "main": "index.ts",
@@ -1362,13 +1362,16 @@ export async function unbindTwitter(
1362
1362
  /**
1363
1363
  * Verify an agent's twitter (verifier-only).
1364
1364
  * Awards verification reward and points to the agent owner.
1365
+ * @param freeStakeDelta - If provided, also adjusts free stake credits for the agent owner in the same tx.
1365
1366
  */
1366
1367
  export async function verifyTwitter(
1367
1368
  connection: Connection,
1368
1369
  wallet: Keypair,
1369
1370
  agentId: string,
1370
1371
  username: string,
1371
- options?: AgentRegistryOptions
1372
+ options?: AgentRegistryOptions,
1373
+ freeStakeDelta?: number,
1374
+ tweetUrl?: string
1372
1375
  ): Promise<string> {
1373
1376
  const program = createProgram(connection, wallet, options?.programId);
1374
1377
  const agentPda = getAgentPda(program.programId, agentId);
@@ -1391,7 +1394,17 @@ export async function verifyTwitter(
1391
1394
  authorityPointAccount,
1392
1395
  } as any)
1393
1396
  .instruction();
1394
- return sendTx(connection, wallet, [ix]);
1397
+
1398
+ const ixs = [ix];
1399
+ if (freeStakeDelta !== undefined && freeStakeDelta !== 0) {
1400
+ const { makeAdjustFreeStakeIx } = await import("./quest");
1401
+ const freeStakeIx = await makeAdjustFreeStakeIx(
1402
+ connection, wallet.publicKey, authority, freeStakeDelta, tweetUrl ?? ""
1403
+ );
1404
+ ixs.push(freeStakeIx);
1405
+ }
1406
+
1407
+ return sendTx(connection, wallet, ixs);
1395
1408
  }
1396
1409
 
1397
1410
  /**
@@ -1414,12 +1427,15 @@ export async function rejectTwitter(
1414
1427
  /**
1415
1428
  * Approve a tweet verification (verifier-only).
1416
1429
  * Awards tweet verify reward and points to the agent owner.
1430
+ * @param freeStakeDelta - If provided, also adjusts free stake credits for the agent owner in the same tx.
1417
1431
  */
1418
1432
  export async function approveTweet(
1419
1433
  connection: Connection,
1420
1434
  wallet: Keypair,
1421
1435
  agentId: string,
1422
- options?: AgentRegistryOptions
1436
+ options?: AgentRegistryOptions,
1437
+ freeStakeDelta?: number,
1438
+ tweetUrl?: string
1423
1439
  ): Promise<string> {
1424
1440
  const program = createProgram(connection, wallet, options?.programId);
1425
1441
  const agentPda = getAgentPda(program.programId, agentId);
@@ -1442,7 +1458,17 @@ export async function approveTweet(
1442
1458
  authorityPointAccount,
1443
1459
  } as any)
1444
1460
  .instruction();
1445
- return sendTx(connection, wallet, [ix]);
1461
+
1462
+ const ixs = [ix];
1463
+ if (freeStakeDelta !== undefined && freeStakeDelta !== 0) {
1464
+ const { makeAdjustFreeStakeIx } = await import("./quest");
1465
+ const freeStakeIx = await makeAdjustFreeStakeIx(
1466
+ connection, wallet.publicKey, authority, freeStakeDelta, tweetUrl ?? ""
1467
+ );
1468
+ ixs.push(freeStakeIx);
1469
+ }
1470
+
1471
+ return sendTx(connection, wallet, ixs);
1446
1472
  }
1447
1473
 
1448
1474
  /**
package/src/quest.ts CHANGED
@@ -895,6 +895,24 @@ export async function setStakeAuthority(
895
895
  return sendTx(connection, wallet, [ix]);
896
896
  }
897
897
 
898
+ /**
899
+ * Build an adjustFreeStake instruction without sending it.
900
+ */
901
+ export async function makeAdjustFreeStakeIx(
902
+ connection: Connection,
903
+ caller: PublicKey,
904
+ user: PublicKey,
905
+ delta: number,
906
+ reason: string,
907
+ options?: QuestOptions
908
+ ) {
909
+ const program = createProgram(connection, Keypair.generate(), options?.programId);
910
+ return program.methods
911
+ .adjustFreeStake(delta, reason)
912
+ .accounts({ user, caller } as any)
913
+ .instruction();
914
+ }
915
+
898
916
  /**
899
917
  * Adjust free stake credits for a user (stake_authority or authority only).
900
918
  * @param user - The user whose free credits to adjust
@@ -909,10 +927,6 @@ export async function adjustFreeStake(
909
927
  reason: string,
910
928
  options?: QuestOptions
911
929
  ): Promise<string> {
912
- const program = createProgram(connection, wallet, options?.programId);
913
- const ix = await program.methods
914
- .adjustFreeStake(delta, reason)
915
- .accounts({ user, caller: wallet.publicKey } as any)
916
- .instruction();
930
+ const ix = await makeAdjustFreeStakeIx(connection, wallet.publicKey, user, delta, reason, options);
917
931
  return sendTx(connection, wallet, [ix]);
918
932
  }