@ghostspeak/sdk 1.3.0 → 1.3.2
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/dist/index.js +57 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -16302,7 +16302,12 @@ function getRegisterAgentInstructionDataEncoder() {
|
|
|
16302
16302
|
["metadataUri", addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())],
|
|
16303
16303
|
["agentId", addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())]
|
|
16304
16304
|
]),
|
|
16305
|
-
(value) =>
|
|
16305
|
+
(value) => {
|
|
16306
|
+
if (typeof value.agentType !== "number" || isNaN(value.agentType)) {
|
|
16307
|
+
throw new Error(`Invalid agentType: ${value.agentType}. Must be a valid number.`);
|
|
16308
|
+
}
|
|
16309
|
+
return { ...value, discriminator: REGISTER_AGENT_DISCRIMINATOR };
|
|
16310
|
+
}
|
|
16306
16311
|
);
|
|
16307
16312
|
}
|
|
16308
16313
|
function getRegisterAgentInstructionDataDecoder() {
|
|
@@ -21600,6 +21605,22 @@ var BaseInstructions = class {
|
|
|
21600
21605
|
console.log(`\u{1F510} Using ${signers.length} signers`);
|
|
21601
21606
|
console.log(`\u{1F4CD} Program ID: ${this.programId}`);
|
|
21602
21607
|
console.log(`\u{1F310} Commitment: ${this.commitment}`);
|
|
21608
|
+
for (let i = 0; i < instructions.length; i++) {
|
|
21609
|
+
const instruction = instructions[i];
|
|
21610
|
+
if (!instruction) {
|
|
21611
|
+
throw new Error(`Instruction at index ${i} is undefined`);
|
|
21612
|
+
}
|
|
21613
|
+
if (!instruction.programAddress) {
|
|
21614
|
+
throw new Error(`Instruction at index ${i} has no programAddress`);
|
|
21615
|
+
}
|
|
21616
|
+
if (!instruction.accounts) {
|
|
21617
|
+
throw new Error(`Instruction at index ${i} has no accounts array`);
|
|
21618
|
+
}
|
|
21619
|
+
if (!Array.isArray(instruction.accounts)) {
|
|
21620
|
+
throw new Error(`Instruction at index ${i} accounts is not an array`);
|
|
21621
|
+
}
|
|
21622
|
+
console.log(`\u2705 Instruction ${i}: ${instruction.accounts.length} accounts, program: ${instruction.programAddress}`);
|
|
21623
|
+
}
|
|
21603
21624
|
console.log("\u{1F517} Fetching latest blockhash...");
|
|
21604
21625
|
const { value: latestBlockhash } = await this.rpc.getLatestBlockhash().send();
|
|
21605
21626
|
console.log(`\u2705 Got blockhash: ${latestBlockhash.blockhash}`);
|
|
@@ -21733,6 +21754,11 @@ var BaseInstructions = class {
|
|
|
21733
21754
|
console.log(` Program: ${instruction.programAddress}`);
|
|
21734
21755
|
console.log(` Accounts: ${instruction.accounts?.length || 0}`);
|
|
21735
21756
|
console.log(` Data size: ${instruction.data?.length || 0} bytes`);
|
|
21757
|
+
if (instruction.accounts) {
|
|
21758
|
+
instruction.accounts.forEach((account, index) => {
|
|
21759
|
+
console.log(` Account ${index}: ${JSON.stringify(account)}`);
|
|
21760
|
+
});
|
|
21761
|
+
}
|
|
21736
21762
|
}
|
|
21737
21763
|
};
|
|
21738
21764
|
|
|
@@ -21745,24 +21771,46 @@ var AgentInstructions = class extends BaseInstructions {
|
|
|
21745
21771
|
* Register a new AI agent
|
|
21746
21772
|
*/
|
|
21747
21773
|
async register(signer, agentAddress, userRegistryAddress, params) {
|
|
21748
|
-
const
|
|
21749
|
-
|
|
21750
|
-
|
|
21751
|
-
signer,
|
|
21752
|
-
agentType: params.agentType,
|
|
21774
|
+
const agentType = typeof params.agentType === "number" && !isNaN(params.agentType) ? params.agentType : 1;
|
|
21775
|
+
console.log("\u{1F50D} Registering agent with params:", {
|
|
21776
|
+
agentType,
|
|
21753
21777
|
metadataUri: params.metadataUri,
|
|
21754
|
-
agentId: params.agentId
|
|
21778
|
+
agentId: params.agentId,
|
|
21779
|
+
agentAddress: agentAddress.toString(),
|
|
21780
|
+
userRegistry: userRegistryAddress.toString(),
|
|
21781
|
+
signer: signer.address ? signer.address.toString() : "NO_ADDRESS"
|
|
21755
21782
|
});
|
|
21756
|
-
|
|
21783
|
+
try {
|
|
21784
|
+
const instruction = getRegisterAgentInstruction({
|
|
21785
|
+
agentAccount: agentAddress,
|
|
21786
|
+
userRegistry: userRegistryAddress,
|
|
21787
|
+
signer,
|
|
21788
|
+
agentType,
|
|
21789
|
+
metadataUri: params.metadataUri,
|
|
21790
|
+
agentId: params.agentId
|
|
21791
|
+
});
|
|
21792
|
+
console.log("\u{1F4E6} Instruction created:", {
|
|
21793
|
+
programAddress: instruction.programAddress,
|
|
21794
|
+
accountsLength: instruction.accounts?.length,
|
|
21795
|
+
dataLength: instruction.data?.length,
|
|
21796
|
+
accounts: instruction.accounts
|
|
21797
|
+
});
|
|
21798
|
+
this.logInstructionDetails(instruction);
|
|
21799
|
+
return this.sendTransaction([instruction], [signer]);
|
|
21800
|
+
} catch (error) {
|
|
21801
|
+
console.error("\u274C Failed to create register instruction:", error);
|
|
21802
|
+
throw error;
|
|
21803
|
+
}
|
|
21757
21804
|
}
|
|
21758
21805
|
/**
|
|
21759
21806
|
* Update an existing agent
|
|
21760
21807
|
*/
|
|
21761
21808
|
async update(signer, agentAddress, agentType, metadataUri, agentId) {
|
|
21809
|
+
const validAgentType = typeof agentType === "number" && !isNaN(agentType) ? agentType : 1;
|
|
21762
21810
|
const instruction = getUpdateAgentInstruction({
|
|
21763
21811
|
agentAccount: agentAddress,
|
|
21764
21812
|
signer,
|
|
21765
|
-
agentType,
|
|
21813
|
+
agentType: validAgentType,
|
|
21766
21814
|
metadataUri,
|
|
21767
21815
|
agentId
|
|
21768
21816
|
});
|