@ghostspeak/sdk 1.4.2 → 1.5.0

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.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _solana_addresses from '@solana/addresses';
2
2
  import { Address as Address$1 } from '@solana/addresses';
3
- import { ReadonlyUint8Array, Address, Encoder, Decoder, Codec, EncodedAccount, Account, MaybeEncodedAccount, MaybeAccount, fetchEncodedAccount, FetchAccountConfig, fetchEncodedAccounts, FetchAccountsConfig, Option, OptionOrNullable, GetDiscriminatedUnionVariant, GetDiscriminatedUnionVariantContent, SolanaError, SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM, IAccountMeta, IInstruction, IInstructionWithData, IInstructionWithAccounts, WritableAccount, WritableSignerAccount, IAccountSignerMeta, ReadonlyAccount, TransactionSigner, ReadonlySignerAccount, Rpc, GetLatestBlockhashApi, SendTransactionApi, GetAccountInfoApi, SimulateTransactionApi, GetFeeForMessageApi, GetProgramAccountsApi, RpcSubscriptions, Signature, GetEpochInfoApi, GetSignatureStatusesApi, SignatureNotificationsApi, SlotNotificationsApi, TransactionMessage } from '@solana/kit';
3
+ import { ReadonlyUint8Array, Address, Encoder, Decoder, Codec, EncodedAccount, Account, MaybeEncodedAccount, MaybeAccount, fetchEncodedAccount, FetchAccountConfig, fetchEncodedAccounts, FetchAccountsConfig, Option, OptionOrNullable, GetDiscriminatedUnionVariant, GetDiscriminatedUnionVariantContent, SolanaError, SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM, IAccountMeta, IInstruction, IInstructionWithData, IInstructionWithAccounts, WritableAccount, WritableSignerAccount, IAccountSignerMeta, ReadonlyAccount, TransactionSigner, ReadonlySignerAccount, Rpc, GetLatestBlockhashApi, SendTransactionApi, GetAccountInfoApi, SimulateTransactionApi, GetFeeForMessageApi, GetProgramAccountsApi, GetEpochInfoApi, GetSignatureStatusesApi, RpcSubscriptions, SignatureNotificationsApi, SlotNotificationsApi, Signature, TransactionMessage } from '@solana/kit';
4
4
  import { TransactionSigner as TransactionSigner$1 } from '@solana/signers';
5
5
  import { IInstruction as IInstruction$1 } from '@solana/instructions';
6
6
 
@@ -12255,12 +12255,14 @@ type ParsedVerifyAgentInstruction<TProgram extends string = typeof GHOSTSPEAK_MA
12255
12255
  declare function parseVerifyAgentInstruction<TProgram extends string, TAccountMetas extends readonly IAccountMeta[]>(instruction: IInstruction<TProgram> & IInstructionWithAccounts<TAccountMetas> & IInstructionWithData<Uint8Array>): ParsedVerifyAgentInstruction<TProgram, TAccountMetas>;
12256
12256
 
12257
12257
  type RpcApi = Rpc<GetLatestBlockhashApi & SendTransactionApi & GetAccountInfoApi & SimulateTransactionApi & GetFeeForMessageApi & GetProgramAccountsApi>;
12258
+ type ExtendedRpcApi = RpcApi & Rpc<GetEpochInfoApi & GetSignatureStatusesApi>;
12259
+ type RpcSubscriptionApi = RpcSubscriptions<SignatureNotificationsApi & SlotNotificationsApi>;
12258
12260
  type Commitment = 'processed' | 'confirmed' | 'finalized';
12259
12261
 
12260
12262
  interface GhostSpeakConfig$1 {
12261
12263
  programId?: Address$1;
12262
- rpc: RpcApi;
12263
- rpcSubscriptions?: RpcSubscriptions<any>;
12264
+ rpc: ExtendedRpcApi;
12265
+ rpcSubscriptions?: RpcSubscriptionApi;
12264
12266
  commitment?: Commitment;
12265
12267
  transactionTimeout?: number;
12266
12268
  defaultFeePayer?: Address$1;
@@ -12306,11 +12308,11 @@ declare abstract class BaseInstructions {
12306
12308
  /**
12307
12309
  * Get the RPC client
12308
12310
  */
12309
- protected get rpc(): Rpc<GetLatestBlockhashApi & SendTransactionApi & GetAccountInfoApi & SimulateTransactionApi & GetFeeForMessageApi & GetProgramAccountsApi & GetEpochInfoApi & GetSignatureStatusesApi>;
12311
+ protected get rpc(): ExtendedRpcApi;
12310
12312
  /**
12311
12313
  * Get the RPC subscriptions client
12312
12314
  */
12313
- protected get rpcSubscriptions(): RpcSubscriptions<SignatureNotificationsApi & SlotNotificationsApi> | undefined;
12315
+ protected get rpcSubscriptions(): RpcSubscriptionApi | undefined;
12314
12316
  /**
12315
12317
  * Get the program ID
12316
12318
  */
@@ -13888,7 +13890,7 @@ declare class GhostSpeakClient$1 {
13888
13890
  /**
13889
13891
  * Create a new GhostSpeak client instance
13890
13892
  */
13891
- static create(rpc: RpcApi, programId?: Address$1): GhostSpeakClient$1;
13893
+ static create(rpc: ExtendedRpcApi, programId?: Address$1): GhostSpeakClient$1;
13892
13894
  /**
13893
13895
  * Register a new AI agent
13894
13896
  */
package/dist/index.js CHANGED
@@ -21635,19 +21635,38 @@ var BaseInstructions = class {
21635
21635
  let confirmed = false;
21636
21636
  let attempts = 0;
21637
21637
  const maxAttempts = 30;
21638
+ const baseDelay = 1e3;
21639
+ let currentDelay = baseDelay;
21638
21640
  while (!confirmed && attempts < maxAttempts) {
21639
- const status = await this.rpc.getSignatureStatuses([transactionSignature]).send();
21640
- if (status.value[0] && status.value[0].confirmationStatus === this.commitment) {
21641
- confirmed = true;
21642
- console.log("\u2705 Transaction confirmed!");
21643
- } else {
21641
+ try {
21642
+ const status = await this.rpc.getSignatureStatuses([transactionSignature]).send();
21643
+ if (status.value[0]) {
21644
+ const confirmationStatus = status.value[0].confirmationStatus;
21645
+ const err = status.value[0].err;
21646
+ if (err) {
21647
+ throw new Error(`Transaction failed: ${JSON.stringify(err)}`);
21648
+ }
21649
+ if (confirmationStatus === this.commitment || this.commitment === "confirmed" && confirmationStatus === "finalized") {
21650
+ confirmed = true;
21651
+ console.log("\u2705 Transaction confirmed!");
21652
+ break;
21653
+ }
21654
+ }
21644
21655
  attempts++;
21645
21656
  console.log(`\u23F3 Waiting for confirmation... (${attempts}/${maxAttempts})`);
21646
- await new Promise((resolve) => setTimeout(resolve, 1e3));
21657
+ await new Promise((resolve) => setTimeout(resolve, currentDelay));
21658
+ currentDelay = Math.min(currentDelay * 1.5, 5e3);
21659
+ } catch (statusError) {
21660
+ if (statusError.message?.includes("Transaction failed")) {
21661
+ throw statusError;
21662
+ }
21663
+ attempts++;
21664
+ console.warn(`\u26A0\uFE0F Status check failed (${attempts}/${maxAttempts}): ${statusError.message}`);
21665
+ await new Promise((resolve) => setTimeout(resolve, currentDelay * 2));
21647
21666
  }
21648
21667
  }
21649
21668
  if (!confirmed) {
21650
- throw new Error("Transaction confirmation timeout");
21669
+ throw new Error(`Transaction confirmation timeout after ${maxAttempts} attempts. Signature: ${transactionSignature}`);
21651
21670
  }
21652
21671
  signature = transactionSignature;
21653
21672
  } else {
@@ -21656,7 +21675,18 @@ var BaseInstructions = class {
21656
21675
  commitment: this.commitment,
21657
21676
  skipPreflight: false
21658
21677
  });
21659
- signature = result?.signature || Object.values(signedTransaction.signatures || {})[0] || "unknown_signature";
21678
+ if (result && typeof result === "object" && "signature" in result) {
21679
+ signature = result.signature;
21680
+ } else if (signedTransaction.signatures && typeof signedTransaction.signatures === "object") {
21681
+ const signatures = Object.values(signedTransaction.signatures);
21682
+ if (signatures.length > 0 && typeof signatures[0] === "string") {
21683
+ signature = signatures[0];
21684
+ } else {
21685
+ throw new Error("Unable to extract transaction signature");
21686
+ }
21687
+ } else {
21688
+ throw new Error("Transaction result missing signature");
21689
+ }
21660
21690
  }
21661
21691
  const cluster = this.config.cluster || (this.config.rpcEndpoint ? detectClusterFromEndpoint(this.config.rpcEndpoint) : "devnet");
21662
21692
  const transactionResult = createTransactionResult(