@ghostspeak/sdk 1.4.0 → 1.4.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 +4 -41
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -21602,10 +21602,6 @@ var BaseInstructions = class {
|
|
|
21602
21602
|
*/
|
|
21603
21603
|
async sendTransactionWithDetails(instructions, signers) {
|
|
21604
21604
|
try {
|
|
21605
|
-
console.log(`\u{1F4E4} Sending REAL transaction with ${instructions.length} instructions`);
|
|
21606
|
-
console.log(`\u{1F510} Using ${signers.length} signers`);
|
|
21607
|
-
console.log(`\u{1F4CD} Program ID: ${this.programId}`);
|
|
21608
|
-
console.log(`\u{1F310} Commitment: ${this.commitment}`);
|
|
21609
21605
|
for (let i = 0; i < instructions.length; i++) {
|
|
21610
21606
|
const instruction = instructions[i];
|
|
21611
21607
|
if (!instruction) {
|
|
@@ -21620,32 +21616,22 @@ var BaseInstructions = class {
|
|
|
21620
21616
|
if (!Array.isArray(instruction.accounts)) {
|
|
21621
21617
|
throw new Error(`Instruction at index ${i} accounts is not an array`);
|
|
21622
21618
|
}
|
|
21623
|
-
console.log(`\u2705 Instruction ${i}: ${instruction.accounts.length} accounts, program: ${instruction.programAddress}`);
|
|
21624
21619
|
}
|
|
21625
|
-
console.log("\u{1F517} Fetching latest blockhash...");
|
|
21626
21620
|
const { value: latestBlockhash } = await this.rpc.getLatestBlockhash().send();
|
|
21627
|
-
console.log(`\u2705 Got blockhash: ${latestBlockhash.blockhash}`);
|
|
21628
|
-
console.log("\u{1F3D7}\uFE0F Building transaction message...");
|
|
21629
21621
|
const transactionMessage = await pipe(
|
|
21630
21622
|
createTransactionMessage({ version: 0 }),
|
|
21631
21623
|
(tx) => setTransactionMessageFeePayerSigner(signers[0], tx),
|
|
21632
21624
|
(tx) => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, tx),
|
|
21633
21625
|
(tx) => appendTransactionMessageInstructions(instructions, tx)
|
|
21634
21626
|
);
|
|
21635
|
-
console.log("\u2705 Transaction message built");
|
|
21636
|
-
console.log("\u270D\uFE0F Signing transaction...");
|
|
21637
21627
|
const signedTransaction = await signTransactionMessageWithSigners(transactionMessage);
|
|
21638
|
-
console.log("\u2705 Transaction signed");
|
|
21639
|
-
console.log("\u{1F4E1} Sending transaction to blockchain...");
|
|
21640
21628
|
let result;
|
|
21641
21629
|
let signature;
|
|
21642
21630
|
if (!this.rpcSubscriptions) {
|
|
21643
|
-
console.log("\u26A0\uFE0F No RPC subscriptions available, using polling for confirmation...");
|
|
21644
21631
|
const transactionSignature = await this.rpc.sendTransaction(signedTransaction, {
|
|
21645
21632
|
skipPreflight: false,
|
|
21646
21633
|
preflightCommitment: this.commitment
|
|
21647
21634
|
}).send();
|
|
21648
|
-
console.log(`\u{1F4E4} Transaction sent: ${transactionSignature}`);
|
|
21649
21635
|
let confirmed = false;
|
|
21650
21636
|
let attempts = 0;
|
|
21651
21637
|
const maxAttempts = 30;
|
|
@@ -21801,14 +21787,6 @@ var AgentInstructions = class extends BaseInstructions {
|
|
|
21801
21787
|
*/
|
|
21802
21788
|
async register(signer, agentAddress, userRegistryAddress, params) {
|
|
21803
21789
|
const agentType = typeof params.agentType === "number" && !isNaN(params.agentType) ? params.agentType : 1;
|
|
21804
|
-
console.log("\u{1F50D} Registering agent with params:", {
|
|
21805
|
-
agentType,
|
|
21806
|
-
metadataUri: params.metadataUri,
|
|
21807
|
-
agentId: params.agentId,
|
|
21808
|
-
agentAddress: agentAddress.toString(),
|
|
21809
|
-
userRegistry: userRegistryAddress.toString(),
|
|
21810
|
-
signer: signer.address ? signer.address.toString() : "NO_ADDRESS"
|
|
21811
|
-
});
|
|
21812
21790
|
try {
|
|
21813
21791
|
const instruction = getRegisterAgentInstruction({
|
|
21814
21792
|
agentAccount: agentAddress,
|
|
@@ -21818,16 +21796,11 @@ var AgentInstructions = class extends BaseInstructions {
|
|
|
21818
21796
|
metadataUri: params.metadataUri,
|
|
21819
21797
|
agentId: params.agentId
|
|
21820
21798
|
});
|
|
21821
|
-
console.log("\u{1F4E6} Instruction created:", {
|
|
21822
|
-
programAddress: instruction.programAddress,
|
|
21823
|
-
accountsLength: instruction.accounts?.length,
|
|
21824
|
-
dataLength: instruction.data?.length,
|
|
21825
|
-
accounts: instruction.accounts
|
|
21826
|
-
});
|
|
21827
21799
|
this.logInstructionDetails(instruction);
|
|
21828
|
-
|
|
21800
|
+
const signature = await this.sendTransaction([instruction], [signer]);
|
|
21801
|
+
return signature;
|
|
21829
21802
|
} catch (error) {
|
|
21830
|
-
console.error("\u274C Failed to
|
|
21803
|
+
console.error("\u274C Failed to register agent:", error);
|
|
21831
21804
|
throw error;
|
|
21832
21805
|
}
|
|
21833
21806
|
}
|
|
@@ -21989,17 +21962,7 @@ var AgentInstructions = class extends BaseInstructions {
|
|
|
21989
21962
|
// Could use memcmp filter here for efficiency
|
|
21990
21963
|
this.commitment
|
|
21991
21964
|
);
|
|
21992
|
-
|
|
21993
|
-
const ownerAgents = accounts.map(({ data, address: address2 }) => {
|
|
21994
|
-
console.log("\u{1F50D} Debug: Agent account:", {
|
|
21995
|
-
address: address2.toString(),
|
|
21996
|
-
owner: data.owner?.toString(),
|
|
21997
|
-
name: data.name,
|
|
21998
|
-
isActive: data.isActive
|
|
21999
|
-
});
|
|
22000
|
-
return { ...data, address: address2 };
|
|
22001
|
-
}).filter((agent) => agent.owner?.toString() === options.owner.toString());
|
|
22002
|
-
console.log("\u{1F50D} Debug: Filtered agents for owner:", ownerAgents.length);
|
|
21965
|
+
const ownerAgents = accounts.map(({ data, address: address2 }) => ({ ...data, address: address2 })).filter((agent) => agent.owner?.toString() === options.owner.toString());
|
|
22003
21966
|
return ownerAgents;
|
|
22004
21967
|
} catch (error) {
|
|
22005
21968
|
console.warn("Failed to fetch agents by owner:", error);
|