nara-sdk 1.0.66 → 1.0.68

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nara-sdk",
3
- "version": "1.0.66",
3
+ "version": "1.0.68",
4
4
  "description": "SDK for the Nara chain (Solana-compatible)",
5
5
  "module": "index.ts",
6
6
  "main": "index.ts",
@@ -468,20 +468,24 @@ export async function registerAgent(
468
468
  connection: Connection,
469
469
  wallet: Keypair,
470
470
  agentId: string,
471
- options?: AgentRegistryOptions
471
+ options?: AgentRegistryOptions,
472
+ payer?: Keypair
472
473
  ): Promise<{ signature: string; agentPubkey: PublicKey }> {
473
474
  if (/[A-Z]/.test(agentId)) {
474
475
  throw new Error(`Agent ID must not contain uppercase letters: "${agentId}"`);
475
476
  }
476
- const program = createProgram(connection, wallet, options?.programId);
477
+ const payerKp = payer ?? wallet;
478
+ const program = createProgram(connection, payerKp, options?.programId);
477
479
 
478
480
  const ix = await program.methods
479
481
  .registerAgent(agentId)
480
482
  .accounts({
483
+ payer: payerKp.publicKey,
481
484
  authority: wallet.publicKey,
482
485
  } as any)
483
486
  .instruction();
484
- const signature = await sendTx(connection, wallet, [ix]);
487
+ const signers = payer && !payer.publicKey.equals(wallet.publicKey) ? [wallet] : [];
488
+ const signature = await sendTx(connection, payerKp, [ix], signers);
485
489
 
486
490
  const agentPubkey = getAgentPda(program.programId, agentId);
487
491
  return { signature, agentPubkey };
@@ -496,12 +500,14 @@ export async function registerAgentWithReferral(
496
500
  wallet: Keypair,
497
501
  agentId: string,
498
502
  referralAgentId: string,
499
- options?: AgentRegistryOptions
503
+ options?: AgentRegistryOptions,
504
+ payer?: Keypair
500
505
  ): Promise<{ signature: string; agentPubkey: PublicKey }> {
501
506
  if (/[A-Z]/.test(agentId)) {
502
507
  throw new Error(`Agent ID must not contain uppercase letters: "${agentId}"`);
503
508
  }
504
- const program = createProgram(connection, wallet, options?.programId);
509
+ const payerKp = payer ?? wallet;
510
+ const program = createProgram(connection, payerKp, options?.programId);
505
511
  const pointMint = getPointMintPda(program.programId);
506
512
 
507
513
  const { referralAgent, referralAuthority, referralPointAccount } =
@@ -515,6 +521,7 @@ export async function registerAgentWithReferral(
515
521
  const ix = await program.methods
516
522
  .registerAgentWithReferral(agentId)
517
523
  .accounts({
524
+ payer: payerKp.publicKey,
518
525
  authority: wallet.publicKey,
519
526
  referralAgent,
520
527
  referralAuthority,
@@ -522,7 +529,8 @@ export async function registerAgentWithReferral(
522
529
  referralRefereeAccount,
523
530
  } as any)
524
531
  .instruction();
525
- const signature = await sendTx(connection, wallet, [ix]);
532
+ const signers = payer && !payer.publicKey.equals(wallet.publicKey) ? [wallet] : [];
533
+ const signature = await sendTx(connection, payerKp, [ix], signers);
526
534
 
527
535
  const agentPubkey = getAgentPda(program.programId, agentId);
528
536
  return { signature, agentPubkey };
@@ -1357,14 +1365,17 @@ export async function setTwitter(
1357
1365
  agentId: string,
1358
1366
  username: string,
1359
1367
  tweetUrl: string,
1360
- options?: AgentRegistryOptions
1368
+ options?: AgentRegistryOptions,
1369
+ payer?: Keypair
1361
1370
  ): Promise<string> {
1362
- const program = createProgram(connection, wallet, options?.programId);
1371
+ const payerKp = payer ?? wallet;
1372
+ const program = createProgram(connection, payerKp, options?.programId);
1363
1373
  const ix = await program.methods
1364
1374
  .setTwitter(agentId, username, tweetUrl)
1365
- .accounts({ authority: wallet.publicKey } as any)
1375
+ .accounts({ payer: payerKp.publicKey, authority: wallet.publicKey } as any)
1366
1376
  .instruction();
1367
- return sendTx(connection, wallet, [ix]);
1377
+ const signers = payer && !payer.publicKey.equals(wallet.publicKey) ? [wallet] : [];
1378
+ return sendTx(connection, payerKp, [ix], signers);
1368
1379
  }
1369
1380
 
1370
1381
  /**
@@ -1376,14 +1387,17 @@ export async function submitTweet(
1376
1387
  wallet: Keypair,
1377
1388
  agentId: string,
1378
1389
  tweetId: bigint,
1379
- options?: AgentRegistryOptions
1390
+ options?: AgentRegistryOptions,
1391
+ payer?: Keypair
1380
1392
  ): Promise<string> {
1381
- const program = createProgram(connection, wallet, options?.programId);
1393
+ const payerKp = payer ?? wallet;
1394
+ const program = createProgram(connection, payerKp, options?.programId);
1382
1395
  const ix = await program.methods
1383
1396
  .submitTweet(agentId, new BN(tweetId.toString()))
1384
- .accounts({ authority: wallet.publicKey } as any)
1397
+ .accounts({ payer: payerKp.publicKey, authority: wallet.publicKey } as any)
1385
1398
  .instruction();
1386
- return sendTx(connection, wallet, [ix]);
1399
+ const signers = payer && !payer.publicKey.equals(wallet.publicKey) ? [wallet] : [];
1400
+ return sendTx(connection, payerKp, [ix], signers);
1387
1401
  }
1388
1402
 
1389
1403
  /**
@@ -1577,10 +1577,14 @@
1577
1577
  ],
1578
1578
  "accounts": [
1579
1579
  {
1580
- "name": "authority",
1580
+ "name": "payer",
1581
1581
  "writable": true,
1582
1582
  "signer": true
1583
1583
  },
1584
+ {
1585
+ "name": "authority",
1586
+ "signer": true
1587
+ },
1584
1588
  {
1585
1589
  "name": "agent",
1586
1590
  "writable": true,
@@ -1669,10 +1673,14 @@
1669
1673
  ],
1670
1674
  "accounts": [
1671
1675
  {
1672
- "name": "authority",
1676
+ "name": "payer",
1673
1677
  "writable": true,
1674
1678
  "signer": true
1675
1679
  },
1680
+ {
1681
+ "name": "authority",
1682
+ "signer": true
1683
+ },
1676
1684
  {
1677
1685
  "name": "agent",
1678
1686
  "writable": true,
@@ -2512,8 +2520,12 @@
2512
2520
  ],
2513
2521
  "accounts": [
2514
2522
  {
2515
- "name": "authority",
2523
+ "name": "payer",
2516
2524
  "writable": true,
2525
+ "signer": true
2526
+ },
2527
+ {
2528
+ "name": "authority",
2517
2529
  "signer": true,
2518
2530
  "relations": [
2519
2531
  "agent"
@@ -2675,8 +2687,12 @@
2675
2687
  ],
2676
2688
  "accounts": [
2677
2689
  {
2678
- "name": "authority",
2690
+ "name": "payer",
2679
2691
  "writable": true,
2692
+ "signer": true
2693
+ },
2694
+ {
2695
+ "name": "authority",
2680
2696
  "signer": true,
2681
2697
  "relations": [
2682
2698
  "agent"
@@ -1583,10 +1583,14 @@ export type NaraAgentRegistry = {
1583
1583
  ],
1584
1584
  "accounts": [
1585
1585
  {
1586
- "name": "authority",
1586
+ "name": "payer",
1587
1587
  "writable": true,
1588
1588
  "signer": true
1589
1589
  },
1590
+ {
1591
+ "name": "authority",
1592
+ "signer": true
1593
+ },
1590
1594
  {
1591
1595
  "name": "agent",
1592
1596
  "writable": true,
@@ -1675,10 +1679,14 @@ export type NaraAgentRegistry = {
1675
1679
  ],
1676
1680
  "accounts": [
1677
1681
  {
1678
- "name": "authority",
1682
+ "name": "payer",
1679
1683
  "writable": true,
1680
1684
  "signer": true
1681
1685
  },
1686
+ {
1687
+ "name": "authority",
1688
+ "signer": true
1689
+ },
1682
1690
  {
1683
1691
  "name": "agent",
1684
1692
  "writable": true,
@@ -2518,8 +2526,12 @@ export type NaraAgentRegistry = {
2518
2526
  ],
2519
2527
  "accounts": [
2520
2528
  {
2521
- "name": "authority",
2529
+ "name": "payer",
2522
2530
  "writable": true,
2531
+ "signer": true
2532
+ },
2533
+ {
2534
+ "name": "authority",
2523
2535
  "signer": true,
2524
2536
  "relations": [
2525
2537
  "agent"
@@ -2681,8 +2693,12 @@ export type NaraAgentRegistry = {
2681
2693
  ],
2682
2694
  "accounts": [
2683
2695
  {
2684
- "name": "authority",
2696
+ "name": "payer",
2685
2697
  "writable": true,
2698
+ "signer": true
2699
+ },
2700
+ {
2701
+ "name": "authority",
2686
2702
  "signer": true,
2687
2703
  "relations": [
2688
2704
  "agent"
@@ -224,7 +224,35 @@
224
224
  "address": "11111111111111111111111111111111"
225
225
  }
226
226
  ],
227
- "args": []
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
+ ]
228
256
  },
229
257
  {
230
258
  "name": "create_question",
@@ -374,6 +402,61 @@
374
402
  }
375
403
  ]
376
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
+ },
377
460
  {
378
461
  "name": "initialize",
379
462
  "discriminator": [
@@ -230,7 +230,35 @@ export type NaraQuest = {
230
230
  "address": "11111111111111111111111111111111"
231
231
  }
232
232
  ],
233
- "args": []
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
+ ]
234
262
  },
235
263
  {
236
264
  "name": "createQuestion",
@@ -380,6 +408,61 @@ export type NaraQuest = {
380
408
  }
381
409
  ]
382
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
+ },
383
466
  {
384
467
  "name": "initialize",
385
468
  "discriminator": [
package/src/quest.ts CHANGED
@@ -943,11 +943,12 @@ export async function claimAirdrop(
943
943
  connection: Connection,
944
944
  wallet: Keypair,
945
945
  user: PublicKey,
946
+ proof: ZkProof,
946
947
  options?: QuestOptions
947
948
  ): Promise<string> {
948
949
  const program = createProgram(connection, wallet, options?.programId);
949
950
  const ix = await program.methods
950
- .claimAirdrop()
951
+ .claimAirdrop(proof.proofA as any, proof.proofB as any, proof.proofC as any)
951
952
  .accounts({ user, payer: wallet.publicKey } as any)
952
953
  .instruction();
953
954
  return sendTx(connection, wallet, [ix]);