Skip to content

Commit

Permalink
fix simulate transaction cycle, return result (#163)
Browse files Browse the repository at this point in the history
* fix simulate transaction cycle, return result

* bump
  • Loading branch information
Yolley authored Apr 9, 2024
1 parent 06f6635 commit bd8cb2d
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"packages": [
"packages/*"
],
"version": "6.2.0",
"version": "6.2.1",
"$schema": "node_modules/lerna/schemas/lerna-schema.json"
}
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@streamflow/common",
"version": "6.2.0",
"version": "6.2.1",
"description": "Common utilities and types used by streamflow packages.",
"homepage": "https://github.com/streamflow-finance/js-sdk/",
"main": "dist/index.js",
Expand Down
8 changes: 5 additions & 3 deletions packages/common/solana/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,9 @@ export async function sendAndConfirmTransaction(
export async function simulateTransaction(
connection: Connection,
tx: Transaction | VersionedTransaction,
): Promise<void> {
): Promise<RpcResponseAndContext<SimulatedTransactionResponse>> {
let res: RpcResponseAndContext<SimulatedTransactionResponse>;
for (let i = 0; i < SIMULATE_TRIES; i++) {
let res: RpcResponseAndContext<SimulatedTransactionResponse>;
if (isTransactionVersioned(tx)) {
res = await connection.simulateTransaction(tx);
} else {
Expand All @@ -273,9 +273,11 @@ export async function simulateTransaction(
if (!errMessage.includes("BlockhashNotFound") || i === SIMULATE_TRIES - 1) {
throw new SendTransactionError("failed to simulate transaction: " + errMessage, res.value.logs || undefined);
}
continue;
}
break;
return res;
}
throw new SendTransactionError("failed to simulate transaction");
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/distributor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@streamflow/distributor",
"version": "6.2.0",
"version": "6.2.1",
"description": "JavaScript SDK to interact with Streamflow Airdrop protocol.",
"homepage": "https://github.com/streamflow-finance/js-sdk/",
"main": "dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/stream/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@streamflow/stream",
"version": "6.2.0",
"version": "6.2.1",
"description": "JavaScript SDK to interact with Streamflow protocol.",
"homepage": "https://github.com/streamflow-finance/js-sdk/",
"main": "dist/index.js",
Expand Down

0 comments on commit bd8cb2d

Please sign in to comment.