Skip to content

Commit eac7430

Browse files
committed
Added GetTransaction & GetBlock support for versioned transactions
The client will be able to retrieve versioned transactions now
1 parent b468954 commit eac7430

File tree

2 files changed

+32
-23
lines changed

2 files changed

+32
-23
lines changed

src/Solnet.Rpc/IRpcClient.cs

+15-8
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ RequestResult<ResponseValue<AccountInfo>> GetAccountInfo(string pubKey, Commitme
133133
/// <param name="blockRewards">Whether to populate the <c>rewards</c> array, the default includes rewards.</param>
134134
/// <returns>Returns a task that holds the asynchronous operation result and state.</returns>
135135
Task<RequestResult<BlockInfo>> GetBlockAsync(ulong slot, Commitment commitment = Commitment.Finalized,
136-
TransactionDetailsFilterType transactionDetails = TransactionDetailsFilterType.Full, bool blockRewards = false);
136+
TransactionDetailsFilterType transactionDetails = TransactionDetailsFilterType.Full, bool blockRewards = false, int maxSupportedTransactionVersion = 0);
137137

138138
/// <summary>
139139
/// Returns identity and transaction information about a confirmed block in the ledger.
@@ -154,10 +154,11 @@ Task<RequestResult<BlockInfo>> GetBlockAsync(ulong slot, Commitment commitment =
154154
/// <param name="commitment">The state commitment to consider when querying the ledger state.</param>
155155
/// <param name="transactionDetails">The level of transaction detail to return, see <see cref="TransactionDetailsFilterType"/>.</param>
156156
/// <param name="blockRewards">Whether to populate the <c>rewards</c> array, the default includes rewards.</param>
157+
/// <param name="maxSupportedTransactionVersion">Max supported transaction version either LEGACY or 1</param>
157158
/// <returns>Returns a task that holds the asynchronous operation result and state.</returns>
158159
[Obsolete("Please use GetBlockAsync whenever possible instead. This method is expected to be removed in solana-core v1.8.")]
159160
Task<RequestResult<BlockInfo>> GetConfirmedBlockAsync(ulong slot, Commitment commitment = Commitment.Finalized,
160-
TransactionDetailsFilterType transactionDetails = TransactionDetailsFilterType.Full, bool blockRewards = false);
161+
TransactionDetailsFilterType transactionDetails = TransactionDetailsFilterType.Full, bool blockRewards = false, int maxSupportedTransactionVersion = 0);
161162

162163
/// <summary>
163164
/// Returns identity and transaction information about a block in the ledger.
@@ -178,9 +179,10 @@ Task<RequestResult<BlockInfo>> GetConfirmedBlockAsync(ulong slot, Commitment com
178179
/// <param name="commitment">The state commitment to consider when querying the ledger state.</param>
179180
/// <param name="transactionDetails">The level of transaction detail to return, see <see cref="TransactionDetailsFilterType"/>.</param>
180181
/// <param name="blockRewards">Whether to populate the <c>rewards</c> array, the default includes rewards.</param>
182+
/// <param name="maxSupportedTransactionVersion">Max supported transaction version either LEGACY or 1</param>
181183
/// <returns>Returns an object that wraps the result along with possible errors with the request.</returns>
182184
RequestResult<BlockInfo> GetBlock(ulong slot, Commitment commitment = Commitment.Finalized,
183-
TransactionDetailsFilterType transactionDetails = TransactionDetailsFilterType.Full, bool blockRewards = false);
185+
TransactionDetailsFilterType transactionDetails = TransactionDetailsFilterType.Full, bool blockRewards = false, int maxSupportedTransactionVersion = 0);
184186

185187
/// <summary>
186188
/// Returns identity and transaction information about a confirmed block in the ledger.
@@ -201,10 +203,11 @@ RequestResult<BlockInfo> GetBlock(ulong slot, Commitment commitment = Commitment
201203
/// <param name="commitment">The state commitment to consider when querying the ledger state.</param>
202204
/// <param name="transactionDetails">The level of transaction detail to return, see <see cref="TransactionDetailsFilterType"/>.</param>
203205
/// <param name="blockRewards">Whether to populate the <c>rewards</c> array, the default includes rewards.</param>
206+
/// <param name="maxSupportedTransactionVersion">Max supported transaction version either LEGACY or 1</param>
204207
/// <returns>Returns an object that wraps the result along with possible errors with the request.</returns>
205208
[Obsolete("Please use GetBlock whenever possible instead. This method is expected to be removed in solana-core v1.8.")]
206209
RequestResult<BlockInfo> GetConfirmedBlock(ulong slot, Commitment commitment = Commitment.Finalized,
207-
TransactionDetailsFilterType transactionDetails = TransactionDetailsFilterType.Full, bool blockRewards = false);
210+
TransactionDetailsFilterType transactionDetails = TransactionDetailsFilterType.Full, bool blockRewards = false, int maxSupportedTransactionVersion = 0);
208211

209212
/// <summary>
210213
/// Gets the block commitment of a certain block, identified by slot.
@@ -1075,9 +1078,10 @@ Task<RequestResult<ResponseValue<TokenBalance>>> GetTokenSupplyAsync(string toke
10751078
/// </summary>
10761079
/// <param name="signature">Transaction signature as base-58 encoded string.</param>
10771080
/// <param name="commitment">The state commitment to consider when querying the ledger state.</param>
1081+
/// <param name="maxSupportedTransactionVersion">Max supported transaction version either LEGACY or 1</param>
10781082
/// <returns>Returns a task that holds the asynchronous operation result and state.</returns>
10791083
Task<RequestResult<TransactionMetaSlotInfo>> GetTransactionAsync(string signature,
1080-
Commitment commitment = Commitment.Finalized);
1084+
Commitment commitment = Commitment.Finalized, int maxSupportedTransactionVersion = 0);
10811085

10821086
/// <summary>
10831087
/// Returns transaction details for a confirmed transaction.
@@ -1090,9 +1094,10 @@ Task<RequestResult<TransactionMetaSlotInfo>> GetTransactionAsync(string signatur
10901094
/// </summary>
10911095
/// <param name="signature">Transaction signature as base-58 encoded string.</param>
10921096
/// <param name="commitment">The state commitment to consider when querying the ledger state.</param>
1097+
/// <param name="maxSupportedTransactionVersion">Max supported transaction version either LEGACY or 1</param>
10931098
/// <returns>Returns an object that wraps the result along with possible errors with the request.</returns>
10941099
[Obsolete("Please use GetTransactionAsync whenever possible instead. This method is expected to be removed in solana-core v1.8.")]
1095-
Task<RequestResult<TransactionMetaSlotInfo>> GetConfirmedTransactionAsync(string signature, Commitment commitment = Commitment.Finalized);
1100+
Task<RequestResult<TransactionMetaSlotInfo>> GetConfirmedTransactionAsync(string signature, Commitment commitment = Commitment.Finalized, int maxSupportedTransactionVersion = 0);
10961101

10971102
/// <summary>
10981103
/// Returns transaction details for a confirmed transaction.
@@ -1105,8 +1110,9 @@ Task<RequestResult<TransactionMetaSlotInfo>> GetTransactionAsync(string signatur
11051110
/// </summary>
11061111
/// <param name="signature">Transaction signature as base-58 encoded string.</param>
11071112
/// <param name="commitment">The state commitment to consider when querying the ledger state.</param>
1113+
/// <param name="maxSupportedTransactionVersion">Max supported transaction version either LEGACY or 1</param>
11081114
/// <returns>Returns an object that wraps the result along with possible errors with the request.</returns>
1109-
RequestResult<TransactionMetaSlotInfo> GetTransaction(string signature, Commitment commitment = Commitment.Finalized);
1115+
RequestResult<TransactionMetaSlotInfo> GetTransaction(string signature, Commitment commitment = Commitment.Finalized, int maxSupportedTransactionVersion = 0);
11101116

11111117
/// <summary>
11121118
/// Returns transaction details for a confirmed transaction.
@@ -1119,9 +1125,10 @@ Task<RequestResult<TransactionMetaSlotInfo>> GetTransactionAsync(string signatur
11191125
/// </summary>
11201126
/// <param name="signature">Transaction signature as base-58 encoded string.</param>
11211127
/// <param name="commitment">The state commitment to consider when querying the ledger state.</param>
1128+
/// <param name="maxSupportedTransactionVersion">Max supported transaction version either LEGACY or 1</param>
11221129
/// <returns>Returns an object that wraps the result along with possible errors with the request.</returns>
11231130
[Obsolete("Please use GetTransaction whenever possible instead. This method is expected to be removed in solana-core v1.8.")]
1124-
RequestResult<TransactionMetaSlotInfo> GetConfirmedTransaction(string signature, Commitment commitment = Commitment.Finalized);
1131+
RequestResult<TransactionMetaSlotInfo> GetConfirmedTransaction(string signature, Commitment commitment = Commitment.Finalized, int maxSupportedTransactionVersion = 0);
11251132

11261133
/// <summary>
11271134
/// Gets the total transaction count of the ledger.

src/Solnet.Rpc/SolanaRpcClient.cs

+17-15
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ public RequestResult<ResponseValue<ulong>> GetBalance(string pubKey,
211211
public async Task<RequestResult<BlockInfo>> GetBlockAsync(ulong slot,
212212
Commitment commitment = Commitment.Finalized,
213213
TransactionDetailsFilterType transactionDetails = TransactionDetailsFilterType.Full,
214-
bool blockRewards = false)
214+
bool blockRewards = false, int maxSupportedTransactionVersion = 0)
215215
{
216216
if (commitment == Commitment.Processed)
217217
{
@@ -221,6 +221,7 @@ public async Task<RequestResult<BlockInfo>> GetBlockAsync(ulong slot,
221221
return await SendRequestAsync<BlockInfo>("getBlock",
222222
Parameters.Create(slot, ConfigObject.Create(
223223
KeyValue.Create("encoding", "json"),
224+
KeyValue.Create("maxSupportedTransactionVersion", maxSupportedTransactionVersion),
224225
HandleTransactionDetails(transactionDetails),
225226
KeyValue.Create("rewards", blockRewards ? blockRewards : null),
226227
HandleCommitment(commitment))));
@@ -229,8 +230,8 @@ public async Task<RequestResult<BlockInfo>> GetBlockAsync(ulong slot,
229230
/// <inheritdoc cref="IRpcClient.GetBlock"/>
230231
public RequestResult<BlockInfo> GetBlock(ulong slot, Commitment commitment = Commitment.Finalized,
231232
TransactionDetailsFilterType transactionDetails = TransactionDetailsFilterType.Full,
232-
bool blockRewards = false)
233-
=> GetBlockAsync(slot, commitment, transactionDetails, blockRewards).Result;
233+
bool blockRewards = false, int maxSupportedTransactionVersion = 0)
234+
=> GetBlockAsync(slot, commitment, transactionDetails, blockRewards, maxSupportedTransactionVersion).Result;
234235

235236

236237
/// <inheritdoc cref="IRpcClient.GetBlocksAsync"/>
@@ -251,7 +252,7 @@ public async Task<RequestResult<List<ulong>>> GetBlocksAsync(ulong startSlot, ul
251252
public async Task<RequestResult<BlockInfo>> GetConfirmedBlockAsync(ulong slot,
252253
Commitment commitment = Commitment.Finalized,
253254
TransactionDetailsFilterType transactionDetails = TransactionDetailsFilterType.Full,
254-
bool blockRewards = false)
255+
bool blockRewards = false, int maxSupportedTransactionVersion = 0)
255256
{
256257
if (commitment == Commitment.Processed)
257258
{
@@ -261,6 +262,7 @@ public async Task<RequestResult<BlockInfo>> GetConfirmedBlockAsync(ulong slot,
261262
return await SendRequestAsync<BlockInfo>("getConfirmedBlock",
262263
Parameters.Create(slot, ConfigObject.Create(
263264
KeyValue.Create("encoding", "json"),
265+
KeyValue.Create("maxSupportedTransactionVersion", maxSupportedTransactionVersion),
264266
HandleTransactionDetails(transactionDetails),
265267
KeyValue.Create("rewards", blockRewards ? blockRewards : null),
266268
HandleCommitment(commitment))));
@@ -269,7 +271,7 @@ public async Task<RequestResult<BlockInfo>> GetConfirmedBlockAsync(ulong slot,
269271
/// <inheritdoc cref="IRpcClient.GetConfirmedBlock"/>
270272
public RequestResult<BlockInfo> GetConfirmedBlock(ulong slot, Commitment commitment = Commitment.Finalized,
271273
TransactionDetailsFilterType transactionDetails = TransactionDetailsFilterType.Full,
272-
bool blockRewards = false)
274+
bool blockRewards = false, int maxSupportedTransactionVersion = 0)
273275
=> GetConfirmedBlockAsync(slot, commitment, transactionDetails, blockRewards).Result;
274276

275277

@@ -425,31 +427,31 @@ public async Task<RequestResult<Dictionary<string, List<ulong>>>> GetLeaderSched
425427

426428
/// <inheritdoc cref="IRpcClient.GetTransactionAsync"/>
427429
public async Task<RequestResult<TransactionMetaSlotInfo>> GetTransactionAsync(string signature,
428-
Commitment commitment = Commitment.Finalized)
430+
Commitment commitment = Commitment.Finalized, int maxSupportedTransactionVersion = 0)
429431
{
430432
return await SendRequestAsync<TransactionMetaSlotInfo>("getTransaction",
431433
Parameters.Create(signature,
432-
ConfigObject.Create(KeyValue.Create("encoding", "json"), HandleCommitment(commitment))));
434+
ConfigObject.Create(KeyValue.Create("encoding", "json"), HandleCommitment(commitment), KeyValue.Create("maxSupportedTransactionVersion", maxSupportedTransactionVersion))));
433435
}
434436

435-
/// <inheritdoc cref="IRpcClient.GetConfirmedTransactionAsync(string, Commitment)"/>
437+
/// <inheritdoc cref="IRpcClient.GetConfirmedTransactionAsync(string, Commitment, int)"/>
436438
public async Task<RequestResult<TransactionMetaSlotInfo>> GetConfirmedTransactionAsync(string signature,
437-
Commitment commitment = Commitment.Finalized)
439+
Commitment commitment = Commitment.Finalized, int maxSupportedTransactionVersion = 0)
438440
{
439441
return await SendRequestAsync<TransactionMetaSlotInfo>("getConfirmedTransaction",
440442
Parameters.Create(signature,
441-
ConfigObject.Create(KeyValue.Create("encoding", "json"), HandleCommitment(commitment))));
443+
ConfigObject.Create(KeyValue.Create("encoding", "json"), HandleCommitment(commitment), KeyValue.Create("maxSupportedTransactionVersion", maxSupportedTransactionVersion))));
442444
}
443445

444446
/// <inheritdoc cref="IRpcClient.GetTransaction"/>
445447
public RequestResult<TransactionMetaSlotInfo> GetTransaction(string signature,
446-
Commitment commitment = Commitment.Finalized)
447-
=> GetTransactionAsync(signature, commitment).Result;
448+
Commitment commitment = Commitment.Finalized, int maxSupportedTransactionVersion = 0)
449+
=> GetTransactionAsync(signature, commitment, maxSupportedTransactionVersion).Result;
448450

449-
/// <inheritdoc cref="IRpcClient.GetConfirmedTransaction(string, Commitment)"/>
451+
/// <inheritdoc cref="IRpcClient.GetConfirmedTransaction(string, Commitment, int)"/>
450452
public RequestResult<TransactionMetaSlotInfo> GetConfirmedTransaction(string signature,
451-
Commitment commitment = Commitment.Finalized) =>
452-
GetConfirmedTransactionAsync(signature, commitment).Result;
453+
Commitment commitment = Commitment.Finalized, int maxSupportedTransactionVersion = 0) =>
454+
GetConfirmedTransactionAsync(signature, commitment, maxSupportedTransactionVersion).Result;
453455

454456
/// <inheritdoc cref="IRpcClient.GetBlockHeightAsync"/>
455457
public async Task<RequestResult<ulong>> GetBlockHeightAsync(Commitment commitment = Commitment.Finalized)

0 commit comments

Comments
 (0)