@ghostspeak/sdk 1.3.2 → 1.3.4
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 +41 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -21582,10 +21582,11 @@ var BaseInstructions = class {
|
|
|
21582
21582
|
*/
|
|
21583
21583
|
getSendAndConfirmTransaction() {
|
|
21584
21584
|
if (!this._sendAndConfirmTransaction) {
|
|
21585
|
-
|
|
21586
|
-
|
|
21587
|
-
rpcSubscriptions
|
|
21588
|
-
}
|
|
21585
|
+
const factoryConfig = { rpc: this.rpc };
|
|
21586
|
+
if (this.rpcSubscriptions) {
|
|
21587
|
+
factoryConfig.rpcSubscriptions = this.rpcSubscriptions;
|
|
21588
|
+
}
|
|
21589
|
+
this._sendAndConfirmTransaction = sendAndConfirmTransactionFactory(factoryConfig);
|
|
21589
21590
|
}
|
|
21590
21591
|
return this._sendAndConfirmTransaction;
|
|
21591
21592
|
}
|
|
@@ -21636,14 +21637,42 @@ var BaseInstructions = class {
|
|
|
21636
21637
|
const signedTransaction = await signTransactionMessageWithSigners(transactionMessage);
|
|
21637
21638
|
console.log("\u2705 Transaction signed");
|
|
21638
21639
|
console.log("\u{1F4E1} Sending transaction to blockchain...");
|
|
21639
|
-
|
|
21640
|
-
|
|
21641
|
-
|
|
21642
|
-
|
|
21643
|
-
|
|
21644
|
-
|
|
21645
|
-
|
|
21646
|
-
|
|
21640
|
+
let result;
|
|
21641
|
+
let signature;
|
|
21642
|
+
if (!this.rpcSubscriptions) {
|
|
21643
|
+
console.log("\u26A0\uFE0F No RPC subscriptions available, using polling for confirmation...");
|
|
21644
|
+
const transactionSignature = await this.rpc.sendTransaction(signedTransaction, {
|
|
21645
|
+
skipPreflight: false,
|
|
21646
|
+
preflightCommitment: this.commitment
|
|
21647
|
+
}).send();
|
|
21648
|
+
console.log(`\u{1F4E4} Transaction sent: ${transactionSignature}`);
|
|
21649
|
+
let confirmed = false;
|
|
21650
|
+
let attempts = 0;
|
|
21651
|
+
const maxAttempts = 30;
|
|
21652
|
+
while (!confirmed && attempts < maxAttempts) {
|
|
21653
|
+
const status = await this.rpc.getSignatureStatuses([transactionSignature]).send();
|
|
21654
|
+
if (status.value[0] && status.value[0].confirmationStatus === this.commitment) {
|
|
21655
|
+
confirmed = true;
|
|
21656
|
+
console.log("\u2705 Transaction confirmed!");
|
|
21657
|
+
} else {
|
|
21658
|
+
attempts++;
|
|
21659
|
+
console.log(`\u23F3 Waiting for confirmation... (${attempts}/${maxAttempts})`);
|
|
21660
|
+
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
21661
|
+
}
|
|
21662
|
+
}
|
|
21663
|
+
if (!confirmed) {
|
|
21664
|
+
throw new Error("Transaction confirmation timeout");
|
|
21665
|
+
}
|
|
21666
|
+
signature = transactionSignature;
|
|
21667
|
+
} else {
|
|
21668
|
+
const sendAndConfirmTransaction = this.getSendAndConfirmTransaction();
|
|
21669
|
+
result = await sendAndConfirmTransaction(signedTransaction, {
|
|
21670
|
+
commitment: this.commitment,
|
|
21671
|
+
skipPreflight: false
|
|
21672
|
+
});
|
|
21673
|
+
signature = result?.signature || Object.values(signedTransaction.signatures || {})[0] || "unknown_signature";
|
|
21674
|
+
}
|
|
21675
|
+
const cluster = this.config.cluster || (this.config.rpcEndpoint ? detectClusterFromEndpoint(this.config.rpcEndpoint) : "devnet");
|
|
21647
21676
|
const transactionResult = createTransactionResult(
|
|
21648
21677
|
signature,
|
|
21649
21678
|
cluster,
|