nara-sdk 1.0.43 → 1.0.44
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 +4 -0
- package/package.json +3 -2
- package/src/agent_registry.ts +83 -122
- package/src/constants.ts +7 -0
- package/src/idls/nara_quest.json +368 -36
- package/src/idls/nara_quest.ts +368 -36
- package/src/quest.ts +68 -78
- package/src/skills.ts +59 -98
- package/src/tx.ts +131 -0
- package/src/zkid.ts +22 -16
package/index.ts
CHANGED
|
@@ -14,8 +14,12 @@ export {
|
|
|
14
14
|
DEFAULT_SKILLS_PROGRAM_ID,
|
|
15
15
|
DEFAULT_ZKID_PROGRAM_ID,
|
|
16
16
|
DEFAULT_AGENT_REGISTRY_PROGRAM_ID,
|
|
17
|
+
DEFAULT_ALT_ADDRESS,
|
|
17
18
|
} from "./src/constants";
|
|
18
19
|
|
|
20
|
+
// Export transaction helper
|
|
21
|
+
export { sendTx, setAltAddress, getAltAddress } from "./src/tx";
|
|
22
|
+
|
|
19
23
|
// Export quest functions and types
|
|
20
24
|
export {
|
|
21
25
|
getQuestInfo,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nara-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.44",
|
|
4
4
|
"description": "SDK for the Nara chain (Solana-compatible)",
|
|
5
5
|
"module": "index.ts",
|
|
6
6
|
"main": "index.ts",
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@types/bn.js": "^5.2.0",
|
|
23
23
|
"@types/node": "^22.0.0",
|
|
24
|
-
"
|
|
24
|
+
"esbuild": "^0.27.3",
|
|
25
|
+
"tsx": "^4.21.0",
|
|
25
26
|
"typescript": "^5.9.3"
|
|
26
27
|
},
|
|
27
28
|
"peerDependencies": {
|
package/src/agent_registry.ts
CHANGED
|
@@ -15,6 +15,7 @@ import { Program, AnchorProvider, Wallet } from "@coral-xyz/anchor";
|
|
|
15
15
|
import { getAssociatedTokenAddressSync, TOKEN_2022_PROGRAM_ID } from "@solana/spl-token";
|
|
16
16
|
import type { NaraAgentRegistry } from "./idls/nara_agent_registry";
|
|
17
17
|
import { DEFAULT_AGENT_REGISTRY_PROGRAM_ID } from "./constants";
|
|
18
|
+
import { sendTx } from "./tx";
|
|
18
19
|
|
|
19
20
|
import naraAgentRegistryIdl from "./idls/nara_agent_registry.json";
|
|
20
21
|
|
|
@@ -29,42 +30,6 @@ const BUFFER_HEADER_SIZE = 144;
|
|
|
29
30
|
/** AgentMemory account header: 8 discriminator + 32 agent + 64 _reserved */
|
|
30
31
|
const MEMORY_HEADER_SIZE = 104;
|
|
31
32
|
|
|
32
|
-
// ─── Helpers ─────────────────────────────────────────────────────
|
|
33
|
-
|
|
34
|
-
/** Send a transaction and poll until confirmed, without using WebSocket. */
|
|
35
|
-
async function sendAndConfirmTx(
|
|
36
|
-
connection: Connection,
|
|
37
|
-
tx: anchor.web3.Transaction,
|
|
38
|
-
signers: anchor.web3.Signer[]
|
|
39
|
-
): Promise<string> {
|
|
40
|
-
const { blockhash, lastValidBlockHeight } =
|
|
41
|
-
await connection.getLatestBlockhash("confirmed");
|
|
42
|
-
tx.recentBlockhash = blockhash;
|
|
43
|
-
tx.feePayer = signers[0]!.publicKey;
|
|
44
|
-
tx.sign(...signers);
|
|
45
|
-
|
|
46
|
-
const rawTx = tx.serialize();
|
|
47
|
-
const sig = await connection.sendRawTransaction(rawTx, {
|
|
48
|
-
skipPreflight: false,
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
while (true) {
|
|
52
|
-
const { value } = await connection.getSignatureStatuses([sig]);
|
|
53
|
-
const status = value[0];
|
|
54
|
-
if (status) {
|
|
55
|
-
if (status.err) throw new Error(`Transaction failed: ${JSON.stringify(status.err)}`);
|
|
56
|
-
if (status.confirmationStatus === "confirmed" || status.confirmationStatus === "finalized") {
|
|
57
|
-
return sig;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
const currentHeight = await connection.getBlockHeight("confirmed");
|
|
61
|
-
if (currentHeight > lastValidBlockHeight) {
|
|
62
|
-
throw new Error(`Transaction expired (blockhash no longer valid): ${sig}`);
|
|
63
|
-
}
|
|
64
|
-
await new Promise((r) => setTimeout(r, 1000));
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
33
|
// ─── Types ───────────────────────────────────────────────────────
|
|
69
34
|
|
|
70
35
|
export interface AgentRecord {
|
|
@@ -400,14 +365,14 @@ export async function registerAgent(
|
|
|
400
365
|
const program = createProgram(connection, wallet, options?.programId);
|
|
401
366
|
const config = await getConfig(connection, options);
|
|
402
367
|
|
|
403
|
-
const
|
|
368
|
+
const ix = await program.methods
|
|
404
369
|
.registerAgent(agentId)
|
|
405
370
|
.accounts({
|
|
406
371
|
authority: wallet.publicKey,
|
|
407
372
|
feeRecipient: config.feeRecipient,
|
|
408
373
|
} as any)
|
|
409
|
-
.
|
|
410
|
-
|
|
374
|
+
.instruction();
|
|
375
|
+
const signature = await sendTx(connection, wallet, [ix]);
|
|
411
376
|
|
|
412
377
|
const agentPubkey = getAgentPda(program.programId, agentId);
|
|
413
378
|
return { signature, agentPubkey };
|
|
@@ -439,7 +404,7 @@ export async function registerAgentWithReferral(
|
|
|
439
404
|
refereeMint, referralAuthority, true, TOKEN_2022_PROGRAM_ID
|
|
440
405
|
);
|
|
441
406
|
|
|
442
|
-
const
|
|
407
|
+
const ix = await program.methods
|
|
443
408
|
.registerAgentWithReferral(agentId)
|
|
444
409
|
.accounts({
|
|
445
410
|
authority: wallet.publicKey,
|
|
@@ -449,8 +414,8 @@ export async function registerAgentWithReferral(
|
|
|
449
414
|
referralPointAccount,
|
|
450
415
|
referralRefereeAccount,
|
|
451
416
|
} as any)
|
|
452
|
-
.
|
|
453
|
-
|
|
417
|
+
.instruction();
|
|
418
|
+
const signature = await sendTx(connection, wallet, [ix]);
|
|
454
419
|
|
|
455
420
|
const agentPubkey = getAgentPda(program.programId, agentId);
|
|
456
421
|
return { signature, agentPubkey };
|
|
@@ -467,11 +432,11 @@ export async function transferAgentAuthority(
|
|
|
467
432
|
options?: AgentRegistryOptions
|
|
468
433
|
): Promise<string> {
|
|
469
434
|
const program = createProgram(connection, wallet, options?.programId);
|
|
470
|
-
|
|
435
|
+
const ix = await program.methods
|
|
471
436
|
.transferAuthority(agentId, newAuthority)
|
|
472
437
|
.accounts({ authority: wallet.publicKey } as any)
|
|
473
|
-
.
|
|
474
|
-
|
|
438
|
+
.instruction();
|
|
439
|
+
return sendTx(connection, wallet, [ix]);
|
|
475
440
|
}
|
|
476
441
|
|
|
477
442
|
/**
|
|
@@ -492,14 +457,14 @@ export async function deleteAgent(
|
|
|
492
457
|
? wallet.publicKey
|
|
493
458
|
: record.memory;
|
|
494
459
|
|
|
495
|
-
|
|
460
|
+
const ix = await program.methods
|
|
496
461
|
.deleteAgent(agentId)
|
|
497
462
|
.accounts({
|
|
498
463
|
authority: wallet.publicKey,
|
|
499
464
|
memoryAccount,
|
|
500
465
|
} as any)
|
|
501
|
-
.
|
|
502
|
-
|
|
466
|
+
.instruction();
|
|
467
|
+
return sendTx(connection, wallet, [ix]);
|
|
503
468
|
}
|
|
504
469
|
|
|
505
470
|
// ─── Bio & Metadata ─────────────────────────────────────────────
|
|
@@ -515,11 +480,11 @@ export async function setBio(
|
|
|
515
480
|
options?: AgentRegistryOptions
|
|
516
481
|
): Promise<string> {
|
|
517
482
|
const program = createProgram(connection, wallet, options?.programId);
|
|
518
|
-
|
|
483
|
+
const ix = await program.methods
|
|
519
484
|
.setBio(agentId, bio)
|
|
520
485
|
.accounts({ authority: wallet.publicKey } as any)
|
|
521
|
-
.
|
|
522
|
-
|
|
486
|
+
.instruction();
|
|
487
|
+
return sendTx(connection, wallet, [ix]);
|
|
523
488
|
}
|
|
524
489
|
|
|
525
490
|
/**
|
|
@@ -533,11 +498,11 @@ export async function setMetadata(
|
|
|
533
498
|
options?: AgentRegistryOptions
|
|
534
499
|
): Promise<string> {
|
|
535
500
|
const program = createProgram(connection, wallet, options?.programId);
|
|
536
|
-
|
|
501
|
+
const ix = await program.methods
|
|
537
502
|
.setMetadata(agentId, data)
|
|
538
503
|
.accounts({ authority: wallet.publicKey } as any)
|
|
539
|
-
.
|
|
540
|
-
|
|
504
|
+
.instruction();
|
|
505
|
+
return sendTx(connection, wallet, [ix]);
|
|
541
506
|
}
|
|
542
507
|
|
|
543
508
|
// ─── Memory Upload ──────────────────────────────────────────────
|
|
@@ -583,26 +548,24 @@ export async function uploadMemory(
|
|
|
583
548
|
const bufferSize = BUFFER_HEADER_SIZE + totalLen;
|
|
584
549
|
const bufferRent = await connection.getMinimumBalanceForRentExemption(bufferSize);
|
|
585
550
|
|
|
586
|
-
const
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
);
|
|
595
|
-
await sendAndConfirmTx(connection, createBufferTx, [wallet, bufferKeypair]);
|
|
551
|
+
const createBufferIx = SystemProgram.createAccount({
|
|
552
|
+
fromPubkey: wallet.publicKey,
|
|
553
|
+
newAccountPubkey: bufferKeypair.publicKey,
|
|
554
|
+
lamports: bufferRent,
|
|
555
|
+
space: bufferSize,
|
|
556
|
+
programId: program.programId,
|
|
557
|
+
});
|
|
558
|
+
await sendTx(connection, wallet, [createBufferIx], [bufferKeypair]);
|
|
596
559
|
|
|
597
560
|
// ── Step 2: init_buffer ───────────────────────────────────────
|
|
598
|
-
await program.methods
|
|
561
|
+
const initBufferIx = await program.methods
|
|
599
562
|
.initBuffer(agentId, totalLen)
|
|
600
563
|
.accounts({
|
|
601
564
|
authority: wallet.publicKey,
|
|
602
565
|
buffer: bufferKeypair.publicKey,
|
|
603
566
|
} as any)
|
|
604
|
-
.
|
|
605
|
-
|
|
567
|
+
.instruction();
|
|
568
|
+
await sendTx(connection, wallet, [initBufferIx]);
|
|
606
569
|
|
|
607
570
|
// ── Step 3: write chunks ──────────────────────────────────────
|
|
608
571
|
const totalChunks = Math.ceil(totalLen / chunkSize);
|
|
@@ -610,14 +573,14 @@ export async function uploadMemory(
|
|
|
610
573
|
let chunkIndex = 0;
|
|
611
574
|
while (offset < totalLen) {
|
|
612
575
|
const chunk = Buffer.from(data.slice(offset, offset + chunkSize));
|
|
613
|
-
const
|
|
576
|
+
const writeIx = await program.methods
|
|
614
577
|
.writeToBuffer(agentId, offset, chunk)
|
|
615
578
|
.accounts({
|
|
616
579
|
authority: wallet.publicKey,
|
|
617
580
|
buffer: bufferKeypair.publicKey,
|
|
618
581
|
} as any)
|
|
619
|
-
.
|
|
620
|
-
|
|
582
|
+
.instruction();
|
|
583
|
+
const writeSig = await sendTx(connection, wallet, [writeIx]);
|
|
621
584
|
offset += chunk.length;
|
|
622
585
|
chunkIndex++;
|
|
623
586
|
options?.onProgress?.(chunkIndex, totalChunks, writeSig);
|
|
@@ -626,15 +589,15 @@ export async function uploadMemory(
|
|
|
626
589
|
// ── Step 4: finalize ──────────────────────────────────────────
|
|
627
590
|
if (resolvedMode === "append") {
|
|
628
591
|
// Append: realloc existing memory in-place, no new account needed
|
|
629
|
-
|
|
592
|
+
const appendIx = await program.methods
|
|
630
593
|
.finalizeMemoryAppend(agentId)
|
|
631
594
|
.accounts({
|
|
632
595
|
authority: wallet.publicKey,
|
|
633
596
|
buffer: bufferKeypair.publicKey,
|
|
634
597
|
memory: existingMemory,
|
|
635
598
|
} as any)
|
|
636
|
-
.
|
|
637
|
-
|
|
599
|
+
.instruction();
|
|
600
|
+
return sendTx(connection, wallet, [appendIx]);
|
|
638
601
|
}
|
|
639
602
|
|
|
640
603
|
// new / update: create a new memory account
|
|
@@ -642,19 +605,17 @@ export async function uploadMemory(
|
|
|
642
605
|
const memorySize = MEMORY_HEADER_SIZE + totalLen;
|
|
643
606
|
const memoryRent = await connection.getMinimumBalanceForRentExemption(memorySize);
|
|
644
607
|
|
|
645
|
-
const
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
);
|
|
654
|
-
await sendAndConfirmTx(connection, createMemoryTx, [wallet, memoryKeypair]);
|
|
608
|
+
const createMemoryIx = SystemProgram.createAccount({
|
|
609
|
+
fromPubkey: wallet.publicKey,
|
|
610
|
+
newAccountPubkey: memoryKeypair.publicKey,
|
|
611
|
+
lamports: memoryRent,
|
|
612
|
+
space: memorySize,
|
|
613
|
+
programId: program.programId,
|
|
614
|
+
});
|
|
615
|
+
await sendTx(connection, wallet, [createMemoryIx], [memoryKeypair]);
|
|
655
616
|
|
|
656
617
|
if (resolvedMode === "update") {
|
|
657
|
-
|
|
618
|
+
const updateIx = await program.methods
|
|
658
619
|
.finalizeMemoryUpdate(agentId)
|
|
659
620
|
.accounts({
|
|
660
621
|
authority: wallet.publicKey,
|
|
@@ -662,19 +623,19 @@ export async function uploadMemory(
|
|
|
662
623
|
newMemory: memoryKeypair.publicKey,
|
|
663
624
|
oldMemory: existingMemory,
|
|
664
625
|
} as any)
|
|
665
|
-
.
|
|
666
|
-
|
|
626
|
+
.instruction();
|
|
627
|
+
return sendTx(connection, wallet, [updateIx]);
|
|
667
628
|
} else {
|
|
668
629
|
// "new"
|
|
669
|
-
|
|
630
|
+
const newIx = await program.methods
|
|
670
631
|
.finalizeMemoryNew(agentId)
|
|
671
632
|
.accounts({
|
|
672
633
|
authority: wallet.publicKey,
|
|
673
634
|
buffer: bufferKeypair.publicKey,
|
|
674
635
|
newMemory: memoryKeypair.publicKey,
|
|
675
636
|
} as any)
|
|
676
|
-
.
|
|
677
|
-
|
|
637
|
+
.instruction();
|
|
638
|
+
return sendTx(connection, wallet, [newIx]);
|
|
678
639
|
}
|
|
679
640
|
}
|
|
680
641
|
|
|
@@ -692,11 +653,11 @@ export async function closeBuffer(
|
|
|
692
653
|
if (!record.pendingBuffer) {
|
|
693
654
|
throw new Error(`Agent "${agentId}" has no pending buffer`);
|
|
694
655
|
}
|
|
695
|
-
|
|
656
|
+
const ix = await program.methods
|
|
696
657
|
.closeBuffer(agentId)
|
|
697
658
|
.accounts({ authority: wallet.publicKey, buffer: record.pendingBuffer } as any)
|
|
698
|
-
.
|
|
699
|
-
|
|
659
|
+
.instruction();
|
|
660
|
+
return sendTx(connection, wallet, [ix]);
|
|
700
661
|
}
|
|
701
662
|
|
|
702
663
|
// ─── Activity Logging ───────────────────────────────────────────
|
|
@@ -719,15 +680,15 @@ export async function logActivity(
|
|
|
719
680
|
pointMint, wallet.publicKey, true, TOKEN_2022_PROGRAM_ID
|
|
720
681
|
);
|
|
721
682
|
|
|
722
|
-
|
|
683
|
+
const ix = await program.methods
|
|
723
684
|
.logActivity(agentId, model, activity, log)
|
|
724
685
|
.accounts({
|
|
725
686
|
authority: wallet.publicKey,
|
|
726
687
|
authorityPointAccount,
|
|
727
688
|
instructions: SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
728
689
|
} as any)
|
|
729
|
-
.
|
|
730
|
-
|
|
690
|
+
.instruction();
|
|
691
|
+
return sendTx(connection, wallet, [ix]);
|
|
731
692
|
}
|
|
732
693
|
|
|
733
694
|
/**
|
|
@@ -757,7 +718,7 @@ export async function logActivityWithReferral(
|
|
|
757
718
|
refereeActivityMint, referralAuthority, true, TOKEN_2022_PROGRAM_ID
|
|
758
719
|
);
|
|
759
720
|
|
|
760
|
-
|
|
721
|
+
const ix = await program.methods
|
|
761
722
|
.logActivityWithReferral(agentId, model, activity, log)
|
|
762
723
|
.accounts({
|
|
763
724
|
authority: wallet.publicKey,
|
|
@@ -768,8 +729,8 @@ export async function logActivityWithReferral(
|
|
|
768
729
|
referralRefereeActivityAccount,
|
|
769
730
|
instructions: SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
770
731
|
} as any)
|
|
771
|
-
.
|
|
772
|
-
|
|
732
|
+
.instruction();
|
|
733
|
+
return sendTx(connection, wallet, [ix]);
|
|
773
734
|
}
|
|
774
735
|
|
|
775
736
|
/**
|
|
@@ -870,7 +831,7 @@ export async function setReferral(
|
|
|
870
831
|
refereeMint, referralAuthority, true, TOKEN_2022_PROGRAM_ID
|
|
871
832
|
);
|
|
872
833
|
|
|
873
|
-
|
|
834
|
+
const ix = await program.methods
|
|
874
835
|
.setReferral(agentId)
|
|
875
836
|
.accounts({
|
|
876
837
|
authority: wallet.publicKey,
|
|
@@ -878,8 +839,8 @@ export async function setReferral(
|
|
|
878
839
|
referralAuthority,
|
|
879
840
|
referralRefereeAccount,
|
|
880
841
|
} as any)
|
|
881
|
-
.
|
|
882
|
-
|
|
842
|
+
.instruction();
|
|
843
|
+
return sendTx(connection, wallet, [ix]);
|
|
883
844
|
}
|
|
884
845
|
|
|
885
846
|
// ─── Admin functions ────────────────────────────────────────────
|
|
@@ -894,11 +855,11 @@ export async function initConfig(
|
|
|
894
855
|
options?: AgentRegistryOptions
|
|
895
856
|
): Promise<string> {
|
|
896
857
|
const program = createProgram(connection, wallet, options?.programId);
|
|
897
|
-
|
|
858
|
+
const ix = await program.methods
|
|
898
859
|
.initConfig()
|
|
899
860
|
.accounts({ admin: wallet.publicKey } as any)
|
|
900
|
-
.
|
|
901
|
-
|
|
861
|
+
.instruction();
|
|
862
|
+
return sendTx(connection, wallet, [ix]);
|
|
902
863
|
}
|
|
903
864
|
|
|
904
865
|
/**
|
|
@@ -911,11 +872,11 @@ export async function updateAdmin(
|
|
|
911
872
|
options?: AgentRegistryOptions
|
|
912
873
|
): Promise<string> {
|
|
913
874
|
const program = createProgram(connection, wallet, options?.programId);
|
|
914
|
-
|
|
875
|
+
const ix = await program.methods
|
|
915
876
|
.updateAdmin(newAdmin)
|
|
916
877
|
.accounts({ admin: wallet.publicKey } as any)
|
|
917
|
-
.
|
|
918
|
-
|
|
878
|
+
.instruction();
|
|
879
|
+
return sendTx(connection, wallet, [ix]);
|
|
919
880
|
}
|
|
920
881
|
|
|
921
882
|
/**
|
|
@@ -928,11 +889,11 @@ export async function updateFeeRecipient(
|
|
|
928
889
|
options?: AgentRegistryOptions
|
|
929
890
|
): Promise<string> {
|
|
930
891
|
const program = createProgram(connection, wallet, options?.programId);
|
|
931
|
-
|
|
892
|
+
const ix = await program.methods
|
|
932
893
|
.updateFeeRecipient(newRecipient)
|
|
933
894
|
.accounts({ admin: wallet.publicKey } as any)
|
|
934
|
-
.
|
|
935
|
-
|
|
895
|
+
.instruction();
|
|
896
|
+
return sendTx(connection, wallet, [ix]);
|
|
936
897
|
}
|
|
937
898
|
|
|
938
899
|
/**
|
|
@@ -946,11 +907,11 @@ export async function updateRegisterFee(
|
|
|
946
907
|
): Promise<string> {
|
|
947
908
|
const program = createProgram(connection, wallet, options?.programId);
|
|
948
909
|
const fee = typeof newFee === "number" ? new anchor.BN(newFee) : newFee;
|
|
949
|
-
|
|
910
|
+
const ix = await program.methods
|
|
950
911
|
.updateRegisterFee(fee)
|
|
951
912
|
.accounts({ admin: wallet.publicKey } as any)
|
|
952
|
-
.
|
|
953
|
-
|
|
913
|
+
.instruction();
|
|
914
|
+
return sendTx(connection, wallet, [ix]);
|
|
954
915
|
}
|
|
955
916
|
|
|
956
917
|
/**
|
|
@@ -967,11 +928,11 @@ export async function updatePointsConfig(
|
|
|
967
928
|
const program = createProgram(connection, wallet, options?.programId);
|
|
968
929
|
const ps = typeof pointsSelf === "number" ? new anchor.BN(pointsSelf) : pointsSelf;
|
|
969
930
|
const pr = typeof pointsReferral === "number" ? new anchor.BN(pointsReferral) : pointsReferral;
|
|
970
|
-
|
|
931
|
+
const ix = await program.methods
|
|
971
932
|
.updatePointsConfig(ps, pr)
|
|
972
933
|
.accounts({ admin: wallet.publicKey } as any)
|
|
973
|
-
.
|
|
974
|
-
|
|
934
|
+
.instruction();
|
|
935
|
+
return sendTx(connection, wallet, [ix]);
|
|
975
936
|
}
|
|
976
937
|
|
|
977
938
|
/**
|
|
@@ -992,11 +953,11 @@ export async function updateReferralConfig(
|
|
|
992
953
|
const fee = typeof referralRegisterFee === "number" ? new anchor.BN(referralRegisterFee) : referralRegisterFee;
|
|
993
954
|
const share = typeof referralFeeShare === "number" ? new anchor.BN(referralFeeShare) : referralFeeShare;
|
|
994
955
|
const pts = typeof referralRegisterPoints === "number" ? new anchor.BN(referralRegisterPoints) : referralRegisterPoints;
|
|
995
|
-
|
|
956
|
+
const ix = await program.methods
|
|
996
957
|
.updateReferralConfig(fee, share, pts)
|
|
997
958
|
.accounts({ admin: wallet.publicKey } as any)
|
|
998
|
-
.
|
|
999
|
-
|
|
959
|
+
.instruction();
|
|
960
|
+
return sendTx(connection, wallet, [ix]);
|
|
1000
961
|
}
|
|
1001
962
|
|
|
1002
963
|
/**
|
|
@@ -1014,9 +975,9 @@ export async function updateActivityConfig(
|
|
|
1014
975
|
const program = createProgram(connection, wallet, options?.programId);
|
|
1015
976
|
const ar = typeof activityReward === "number" ? new anchor.BN(activityReward) : activityReward;
|
|
1016
977
|
const rar = typeof referralActivityReward === "number" ? new anchor.BN(referralActivityReward) : referralActivityReward;
|
|
1017
|
-
|
|
978
|
+
const ix = await program.methods
|
|
1018
979
|
.updateActivityConfig(ar, rar)
|
|
1019
980
|
.accounts({ admin: wallet.publicKey } as any)
|
|
1020
|
-
.
|
|
1021
|
-
|
|
981
|
+
.instruction();
|
|
982
|
+
return sendTx(connection, wallet, [ix]);
|
|
1022
983
|
}
|
package/src/constants.ts
CHANGED
|
@@ -37,3 +37,10 @@ export const DEFAULT_ZKID_PROGRAM_ID =
|
|
|
37
37
|
*/
|
|
38
38
|
export const DEFAULT_AGENT_REGISTRY_PROGRAM_ID =
|
|
39
39
|
process.env.AGENT_REGISTRY_PROGRAM_ID || "AgentRegistry111111111111111111111111111111";
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Address Lookup Table address for transaction optimization.
|
|
43
|
+
* When set, all SDK transactions use VersionedTransaction with this ALT.
|
|
44
|
+
* When empty, uses legacy transactions.
|
|
45
|
+
*/
|
|
46
|
+
export const DEFAULT_ALT_ADDRESS = process.env.ALT_ADDRESS || "";
|