Skip to content

Commit 9a68b8e

Browse files
authored
support v0 txs for receipt fetching (#718)
1 parent 6b21f01 commit 9a68b8e

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ dist/
119119
# Stores VSCode versions used for testing VSCode extensions
120120
.vscode-test
121121

122+
# Idea editors
123+
.idea
124+
122125
# Temporary folders
123126
tmp/
124127
temp/

packages/solana-contrib/src/transaction/PendingTransaction.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ export interface TransactionWaitOptions
2626
* Whether or not to use websockets for awaiting confirmation. Defaults to `false`.
2727
*/
2828
readonly useWebsocket?: boolean;
29+
/**
30+
* Max supported transaction version. Pass `undefined` to only support `legacy` transactions.
31+
*/
32+
readonly maxSupportedTransactionVersion?: number;
2933
}
3034

3135
/**
@@ -54,6 +58,7 @@ export class PendingTransaction {
5458
*/
5559
async wait({
5660
commitment = "confirmed",
61+
maxSupportedTransactionVersion = 0,
5762
useWebsocket = true,
5863
...retryOpts
5964
}: TransactionWaitOptions = {}): Promise<TransactionReceipt> {
@@ -62,9 +67,16 @@ export class PendingTransaction {
6267
}
6368
if (useWebsocket) {
6469
await this.confirm({ commitment, ...retryOpts });
65-
return await this.pollForReceipt({ commitment });
70+
return await this.pollForReceipt({
71+
commitment,
72+
maxSupportedTransactionVersion,
73+
});
6674
}
67-
return await this.pollForReceipt({ commitment, ...retryOpts });
75+
return await this.pollForReceipt({
76+
commitment,
77+
maxSupportedTransactionVersion,
78+
...retryOpts,
79+
});
6880
}
6981

7082
/**
@@ -73,6 +85,7 @@ export class PendingTransaction {
7385
*/
7486
async pollForReceipt({
7587
commitment = "confirmed",
88+
maxSupportedTransactionVersion = 0,
7689
...retryOpts
7790
}: Omit<
7891
TransactionWaitOptions,
@@ -82,6 +95,7 @@ export class PendingTransaction {
8295
async (retry) => {
8396
const result = await this.connection.getTransaction(this.signature, {
8497
commitment,
98+
maxSupportedTransactionVersion,
8599
});
86100
if (!result) {
87101
retry(new Error("Error fetching transaction"));

packages/solana-contrib/src/transaction/TransactionReceipt.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type {
22
Cluster,
33
TransactionResponse,
44
TransactionSignature,
5+
VersionedTransactionResponse,
56
} from "@solana/web3.js";
67
import { default as invariant } from "tiny-invariant";
78

@@ -57,7 +58,7 @@ export class TransactionReceipt {
5758
/**
5859
* Raw response from web3.js
5960
*/
60-
readonly response: TransactionResponse
61+
readonly response: TransactionResponse | VersionedTransactionResponse
6162
) {}
6263

6364
/**

0 commit comments

Comments
 (0)