• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

bmresearch / Solnet / 8950601615

04 May 2024 12:47PM UTC coverage: 77.239% (-3.7%) from 80.902%
8950601615

push

github

web-flow
Update dotnet.yml

1123 of 1710 branches covered (65.67%)

Branch coverage included in aggregate %.

5199 of 6475 relevant lines covered (80.29%)

1304486.85 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.69
/src/Solnet.Rpc/SolanaRpcClient.cs
1
using Microsoft.Extensions.Logging;
2
using Solnet.Rpc.Core;
3
using Solnet.Rpc.Core.Http;
4
using Solnet.Rpc.Messages;
5
using Solnet.Rpc.Models;
6
using Solnet.Rpc.Types;
7
using Solnet.Rpc.Utilities;
8
using System;
9
using System.Collections.Generic;
10
using System.Diagnostics;
11
using System.Linq;
12
using System.Net.Http;
13
using System.Threading.Tasks;
14

15
namespace Solnet.Rpc
16
{
17
    /// <summary>
18
    /// Implements functionality to interact with the Solana JSON RPC API.
19
    /// </summary>
20
    [DebuggerDisplay("Cluster = {" + nameof(NodeAddress) + "}")]
21
    internal class SolanaRpcClient : JsonRpcClient, IRpcClient
22
    {
23
        /// <summary>
24
        /// Message Id generator.
25
        /// </summary>
26
        private readonly IdGenerator _idGenerator = new IdGenerator();
149✔
27

28
        /// <summary>
29
        /// Initialize the Rpc Client with the passed url.
30
        /// </summary>
31
        /// <param name="url">The url of the node exposing the JSON RPC API.</param>
32
        /// <param name="logger">The logger to use.</param>
33
        /// <param name="httpClient">An http client.</param>
34

35
        /// <param name="rateLimiter">A rate limiting strategy or null.</param>
36
        internal SolanaRpcClient(string url, ILogger logger, HttpClient httpClient = default, IRateLimiter rateLimiter = null) 
37
            : base(url, logger, httpClient, rateLimiter)
149✔
38
        {
39
        }
149✔
40

41
        #region RequestBuilder
42

43
        /// <summary>
44
        /// Build the request for the passed RPC method and parameters.
45
        /// </summary>
46
        /// <param name="method">The request's RPC method.</param>
47
        /// <param name="parameters">A list of parameters to include in the request.</param>
48
        /// <typeparam name="T">The type of the request result.</typeparam>
49
        /// <returns>A task which may return a request result.</returns>
50
        private JsonRpcRequest BuildRequest<T>(string method, IList<object> parameters)
51
            => new JsonRpcRequest(_idGenerator.GetNextId(), method, parameters);
129✔
52

53
        /// <summary>
54
        /// 
55
        /// </summary>
56
        /// <param name="method">The request's RPC method.</param>
57
        /// <typeparam name="T">The type of the request result.</typeparam>
58
        /// <returns>A task which may return a request result.</returns>
59
        private async Task<RequestResult<T>> SendRequestAsync<T>(string method)
60
        {
61
            JsonRpcRequest req = BuildRequest<T>(method, null);
15✔
62

63
            return await SendRequest<T>(req);
15✔
64
        }
15✔
65

66
        /// <summary>
67
        /// Send a request asynchronously.
68
        /// </summary>
69
        /// <param name="method">The request's RPC method.</param>
70
        /// <param name="parameters">A list of parameters to include in the request.</param>
71
        /// <typeparam name="T">The type of the request result.</typeparam>
72
        /// <returns>A task which may return a request result.</returns>
73
        private async Task<RequestResult<T>> SendRequestAsync<T>(string method, IList<object> parameters)
74
        {
75
            JsonRpcRequest req = BuildRequest<T>(method, parameters);
114✔
76
            return await SendRequest<T>(req);
114✔
77
        }
114✔
78

79
        private KeyValue HandleCommitment(Commitment parameter, Commitment defaultValue = Commitment.Finalized)
80
            => parameter != defaultValue ? KeyValue.Create("commitment", parameter) : null;
103✔
81

82
        private KeyValue HandleTransactionDetails(TransactionDetailsFilterType parameter,
83
            TransactionDetailsFilterType defaultValue = TransactionDetailsFilterType.Full)
84
            => parameter != defaultValue ? KeyValue.Create("transactionDetails", parameter) : null;
4!
85

86
        #endregion
87

88

89
        #region Accounts
90

91
        /// <inheritdoc cref="IRpcClient.GetTokenMintInfoAsync(string,Commitment)"/>
92
        public async Task<RequestResult<ResponseValue<TokenMintInfo>>> GetTokenMintInfoAsync(string pubKey,
93
            Commitment commitment = Commitment.Finalized)
94
        {
95
            return await SendRequestAsync<ResponseValue<TokenMintInfo>>("getAccountInfo",
1✔
96
                Parameters.Create(
1✔
97
                    pubKey,
1✔
98
                    ConfigObject.Create(
1✔
99
                        KeyValue.Create("encoding", "jsonParsed"),
1✔
100
                        HandleCommitment(commitment))));
1✔
101
        }
1✔
102

103
        /// <inheritdoc cref="IRpcClient.GetTokenMintInfo(string,Commitment)"/>
104
        public RequestResult<ResponseValue<TokenMintInfo>> GetTokenMintInfo(string pubKey,
105
            Commitment commitment = Commitment.Finalized)
106
            => GetTokenMintInfoAsync(pubKey, commitment).Result;
1✔
107

108

109
        /// <inheritdoc cref="IRpcClient.GetTokenAccountInfoAsync(string,Commitment)"/>
110
        public async Task<RequestResult<ResponseValue<TokenAccountInfo>>> GetTokenAccountInfoAsync(string pubKey,
111
            Commitment commitment = Commitment.Finalized)
112
        {
113
            return await SendRequestAsync<ResponseValue<TokenAccountInfo>>("getAccountInfo",
1✔
114
                Parameters.Create(
1✔
115
                    pubKey,
1✔
116
                    ConfigObject.Create(
1✔
117
                        KeyValue.Create("encoding", "jsonParsed"),
1✔
118
                        HandleCommitment(commitment))));
1✔
119
        }
1✔
120

121
        /// <inheritdoc cref="IRpcClient.GetTokenAccountInfo(string,Commitment)"/>
122
        public RequestResult<ResponseValue<TokenAccountInfo>> GetTokenAccountInfo(string pubKey,
123
            Commitment commitment = Commitment.Finalized)
124
            => GetTokenAccountInfoAsync(pubKey, commitment).Result;
1✔
125

126

127

128
        /// <inheritdoc cref="IRpcClient.GetAccountInfoAsync(string,Commitment,BinaryEncoding)"/>
129
        public async Task<RequestResult<ResponseValue<AccountInfo>>> GetAccountInfoAsync(string pubKey,
130
            Commitment commitment = Commitment.Finalized, BinaryEncoding encoding = BinaryEncoding.Base64)
131
        {
132
            return await SendRequestAsync<ResponseValue<AccountInfo>>("getAccountInfo",
3✔
133
                Parameters.Create(
3✔
134
                    pubKey,
3✔
135
                    ConfigObject.Create(
3✔
136
                        KeyValue.Create("encoding", encoding),
3✔
137
                        HandleCommitment(commitment))));
3✔
138
        }
3✔
139

140
        /// <inheritdoc cref="IRpcClient.GetAccountInfo(string,Commitment,BinaryEncoding)"/>
141
        public RequestResult<ResponseValue<AccountInfo>> GetAccountInfo(string pubKey,
142
            Commitment commitment = Commitment.Finalized, BinaryEncoding encoding = BinaryEncoding.Base64)
143
            => GetAccountInfoAsync(pubKey, commitment, encoding).Result;
3✔
144

145

146
        /// <inheritdoc cref="IRpcClient.GetProgramAccountsAsync"/>
147
        public async Task<RequestResult<List<AccountKeyPair>>> GetProgramAccountsAsync(string pubKey,
148
            Commitment commitment = Commitment.Finalized, int? dataSize = null, IList<MemCmp> memCmpList = null)
149
        {
150
            List<object> filters = Parameters.Create(ConfigObject.Create(KeyValue.Create("dataSize", dataSize)));
5✔
151
            if (memCmpList != null)
5✔
152
            {
153
                filters ??= new List<object>();
2!
154
                filters.AddRange(memCmpList.Select(filter => ConfigObject.Create(KeyValue.Create("memcmp",
4✔
155
                    ConfigObject.Create(KeyValue.Create("offset", filter.Offset),
4✔
156
                        KeyValue.Create("bytes", filter.Bytes))))));
4✔
157
            }
158

159
            return await SendRequestAsync<List<AccountKeyPair>>("getProgramAccounts",
5✔
160
                Parameters.Create(
5✔
161
                    pubKey,
5✔
162
                    ConfigObject.Create(
5✔
163
                        KeyValue.Create("encoding", "base64"),
5✔
164
                        KeyValue.Create("filters", filters),
5✔
165
                        HandleCommitment(commitment))));
5✔
166
        }
5✔
167

168
        /// <inheritdoc cref="IRpcClient.GetProgramAccounts"/>
169
        public RequestResult<List<AccountKeyPair>> GetProgramAccounts(string pubKey,
170
            Commitment commitment = Commitment.Finalized,
171
            int? dataSize = null, IList<MemCmp> memCmpList = null)
172
            => GetProgramAccountsAsync(pubKey, commitment, dataSize, memCmpList).Result;
5✔
173

174

175
        /// <inheritdoc cref="IRpcClient.GetMultipleAccountsAsync"/>
176
        public async Task<RequestResult<ResponseValue<List<AccountInfo>>>> GetMultipleAccountsAsync(
177
            IList<string> accounts,
178
            Commitment commitment = Commitment.Finalized)
179
        {
180
            return await SendRequestAsync<ResponseValue<List<AccountInfo>>>("getMultipleAccounts",
2✔
181
                Parameters.Create(
2✔
182
                    accounts,
2✔
183
                    ConfigObject.Create(
2✔
184
                        KeyValue.Create("encoding", "base64"),
2✔
185
                        HandleCommitment(commitment))));
2✔
186
        }
2✔
187

188
        /// <inheritdoc cref="IRpcClient.GetMultipleAccounts"/>
189
        public RequestResult<ResponseValue<List<AccountInfo>>> GetMultipleAccounts(IList<string> accounts,
190
            Commitment commitment = Commitment.Finalized)
191
            => GetMultipleAccountsAsync(accounts, commitment).Result;
2✔
192

193
        #endregion
194

195
        /// <inheritdoc cref="IRpcClient.GetBalanceAsync"/>
196
        public async Task<RequestResult<ResponseValue<ulong>>> GetBalanceAsync(string pubKey,
197
            Commitment commitment = Commitment.Finalized)
198
        {
199
            return await SendRequestAsync<ResponseValue<ulong>>("getBalance",
7✔
200
                Parameters.Create(pubKey, ConfigObject.Create(HandleCommitment(commitment))));
7✔
201
        }
7✔
202

203
        /// <inheritdoc cref="IRpcClient.GetBalance"/>
204
        public RequestResult<ResponseValue<ulong>> GetBalance(string pubKey,
205
            Commitment commitment = Commitment.Finalized)
206
            => GetBalanceAsync(pubKey, commitment).Result;
7✔
207

208
        #region Blocks
209

210
        /// <inheritdoc cref="IRpcClient.GetBlockAsync"/>
211
        public async Task<RequestResult<BlockInfo>> GetBlockAsync(ulong slot,
212
            Commitment commitment = Commitment.Finalized,
213
            TransactionDetailsFilterType transactionDetails = TransactionDetailsFilterType.Full,
214
            bool blockRewards = false, int maxSupportedTransactionVersion = 0)
215
        {
216
            if (commitment == Commitment.Processed)
4✔
217
            {
218
                throw new ArgumentException("Commitment.Processed is not supported for this method.");
2✔
219
            }
220

221
            return await SendRequestAsync<BlockInfo>("getBlock",
2!
222
                Parameters.Create(slot, ConfigObject.Create(
2✔
223
                    KeyValue.Create("encoding", "json"),
2✔
224
                    KeyValue.Create("maxSupportedTransactionVersion", maxSupportedTransactionVersion),
2✔
225
                    HandleTransactionDetails(transactionDetails),
2✔
226
                    KeyValue.Create("rewards", blockRewards ? blockRewards : null),
2✔
227
                    HandleCommitment(commitment))));
2✔
228
        }
2✔
229

230
        /// <inheritdoc cref="IRpcClient.GetBlock"/>
231
        public RequestResult<BlockInfo> GetBlock(ulong slot, Commitment commitment = Commitment.Finalized,
232
            TransactionDetailsFilterType transactionDetails = TransactionDetailsFilterType.Full,
233
            bool blockRewards = false, int maxSupportedTransactionVersion = 0)
234
            => GetBlockAsync(slot, commitment, transactionDetails, blockRewards, maxSupportedTransactionVersion).Result;
4✔
235

236

237
        /// <inheritdoc cref="IRpcClient.GetBlocksAsync"/>
238
        public async Task<RequestResult<List<ulong>>> GetBlocksAsync(ulong startSlot, ulong endSlot = 0,
239
            Commitment commitment = Commitment.Finalized)
240
        {
241
            if (commitment == Commitment.Processed)
3✔
242
            {
243
                throw new ArgumentException("Commitment.Processed is not supported for this method.");
1✔
244
            }
245

246
            return await SendRequestAsync<List<ulong>>("getBlocks",
2!
247
                Parameters.Create(startSlot, endSlot > 0 ? endSlot : null,
2✔
248
                    ConfigObject.Create(HandleCommitment(commitment))));
2✔
249
        }
2✔
250

251
        /// <inheritdoc cref="IRpcClient.GetConfirmedBlockAsync"/>
252
        public async Task<RequestResult<BlockInfo>> GetConfirmedBlockAsync(ulong slot,
253
            Commitment commitment = Commitment.Finalized,
254
            TransactionDetailsFilterType transactionDetails = TransactionDetailsFilterType.Full,
255
            bool blockRewards = false, int maxSupportedTransactionVersion = 0)
256
        {
257
            if (commitment == Commitment.Processed)
2!
258
            {
259
                throw new ArgumentException("Commitment.Processed is not supported for this method.");
×
260
            }
261

262
            return await SendRequestAsync<BlockInfo>("getConfirmedBlock",
2!
263
                Parameters.Create(slot, ConfigObject.Create(
2✔
264
                    KeyValue.Create("encoding", "json"),
2✔
265
                    KeyValue.Create("maxSupportedTransactionVersion", maxSupportedTransactionVersion),
2✔
266
                    HandleTransactionDetails(transactionDetails),
2✔
267
                    KeyValue.Create("rewards", blockRewards ? blockRewards : null),
2✔
268
                    HandleCommitment(commitment))));
2✔
269
        }
2✔
270

271
        /// <inheritdoc cref="IRpcClient.GetConfirmedBlock"/>
272
        public RequestResult<BlockInfo> GetConfirmedBlock(ulong slot, Commitment commitment = Commitment.Finalized,
273
            TransactionDetailsFilterType transactionDetails = TransactionDetailsFilterType.Full,
274
            bool blockRewards = false, int maxSupportedTransactionVersion = 0)
275
            => GetConfirmedBlockAsync(slot, commitment, transactionDetails, blockRewards).Result;
2✔
276

277

278
        /// <inheritdoc cref="IRpcClient.GetBlocks"/>
279
        public RequestResult<List<ulong>> GetBlocks(ulong startSlot, ulong endSlot = 0,
280
            Commitment commitment = Commitment.Finalized)
281
            => GetBlocksAsync(startSlot, endSlot, commitment).Result;
3✔
282

283
        /// <inheritdoc cref="IRpcClient.GetConfirmedBlocksAsync"/>
284
        public async Task<RequestResult<List<ulong>>> GetConfirmedBlocksAsync(ulong startSlot, ulong endSlot = 0,
285
            Commitment commitment = Commitment.Finalized)
286
        {
287
            if (commitment == Commitment.Processed)
3✔
288
            {
289
                throw new ArgumentException("Commitment.Processed is not supported for this method.");
1✔
290
            }
291

292
            return await SendRequestAsync<List<ulong>>("getConfirmedBlocks",
2!
293
                Parameters.Create(startSlot, endSlot > 0 ? endSlot : null,
2✔
294
                    ConfigObject.Create(HandleCommitment(commitment))));
2✔
295
        }
2✔
296

297
        /// <inheritdoc cref="IRpcClient.GetConfirmedBlocks"/>
298
        public RequestResult<List<ulong>> GetConfirmedBlocks(ulong startSlot, ulong endSlot = 0,
299
            Commitment commitment = Commitment.Finalized)
300
            => GetConfirmedBlocksAsync(startSlot, endSlot, commitment).Result;
3✔
301

302
        /// <inheritdoc cref="IRpcClient.GetConfirmedBlocksWithLimitAsync"/>
303
        public async Task<RequestResult<List<ulong>>> GetConfirmedBlocksWithLimitAsync(ulong startSlot, ulong limit,
304
            Commitment commitment = Commitment.Finalized)
305
        {
306
            if (commitment == Commitment.Processed)
3✔
307
            {
308
                throw new ArgumentException("Commitment.Processed is not supported for this method.");
1✔
309
            }
310

311
            return await SendRequestAsync<List<ulong>>("getConfirmedBlocksWithLimit",
2✔
312
                Parameters.Create(startSlot, limit, ConfigObject.Create(HandleCommitment(commitment))));
2✔
313
        }
2✔
314

315
        /// <inheritdoc cref="IRpcClient.GetBlocksWithLimit"/>
316
        public RequestResult<List<ulong>> GetBlocksWithLimit(ulong startSlot, ulong limit,
317
            Commitment commitment = Commitment.Finalized)
318
            => GetBlocksWithLimitAsync(startSlot, limit, commitment).Result;
3✔
319

320
        /// <inheritdoc cref="IRpcClient.GetConfirmedBlocksWithLimit"/>
321
        public RequestResult<List<ulong>> GetConfirmedBlocksWithLimit(ulong startSlot, ulong limit,
322
            Commitment commitment = Commitment.Finalized)
323
            => GetConfirmedBlocksWithLimitAsync(startSlot, limit, commitment).Result;
3✔
324

325
        /// <inheritdoc cref="IRpcClient.GetBlocksWithLimitAsync"/>
326
        public async Task<RequestResult<List<ulong>>> GetBlocksWithLimitAsync(ulong startSlot, ulong limit,
327
            Commitment commitment = Commitment.Finalized)
328
        {
329
            if (commitment == Commitment.Processed)
3✔
330
            {
331
                throw new ArgumentException("Commitment.Processed is not supported for this method.");
1✔
332
            }
333

334
            return await SendRequestAsync<List<ulong>>("getBlocksWithLimit",
2✔
335
                Parameters.Create(startSlot, limit, ConfigObject.Create(HandleCommitment(commitment))));
2✔
336
        }
2✔
337

338

339
        /// <inheritdoc cref="IRpcClient.GetFirstAvailableBlock"/>
340
        public RequestResult<ulong> GetFirstAvailableBlock()
341
            => GetFirstAvailableBlockAsync().Result;
1✔
342

343
        /// <inheritdoc cref="IRpcClient.GetFirstAvailableBlock"/>
344
        public async Task<RequestResult<ulong>> GetFirstAvailableBlockAsync()
345
        {
346
            return await SendRequestAsync<ulong>("getFirstAvailableBlock");
1✔
347
        }
1✔
348

349
        #endregion
350

351
        #region Block Production
352

353
        /// <inheritdoc cref="IRpcClient.GetBlockProductionAsync(string, ulong?, ulong?, Commitment)"/>
354
        public async Task<RequestResult<ResponseValue<BlockProductionInfo>>> GetBlockProductionAsync(
355
            string identity = null, ulong? firstSlot = null, ulong? lastSlot = null,
356
            Commitment commitment = Commitment.Finalized)
357
        {
358
            Dictionary<string, object> parameters = new Dictionary<string, object>();
5✔
359

360
            if (commitment != Commitment.Finalized)
5✔
361
            {
362
                parameters.Add("commitment", commitment);
1✔
363
            }
364

365
            if (!string.IsNullOrEmpty(identity))
5✔
366
            {
367
                parameters.Add("identity", identity);
2✔
368
            }
369

370
            if (firstSlot.HasValue)
5✔
371
            {
372
                Dictionary<string, object> range = new Dictionary<string, object> { { "firstSlot", firstSlot.Value } };
2✔
373

374
                if (lastSlot.HasValue)
2✔
375
                {
376
                    range.Add("lastSlot", lastSlot.Value);
1✔
377
                }
378

379
                parameters.Add("range", range);
2✔
380
            }
381
            else if (lastSlot.HasValue)
3✔
382
            {
383
                throw new ArgumentException(
1✔
384
                    "Range parameters are optional, but the lastSlot argument must be paired with a firstSlot.");
1✔
385
            }
386

387
            List<object> args = parameters.Count > 0 ? new List<object> { parameters } : null;
4✔
388

389
            return await SendRequestAsync<ResponseValue<BlockProductionInfo>>("getBlockProduction", args);
4✔
390
        }
4✔
391

392
        /// <inheritdoc cref="IRpcClient.GetBlockProduction(string, ulong?, ulong?, Commitment)"/>
393
        public RequestResult<ResponseValue<BlockProductionInfo>> GetBlockProduction(string identity = null,
394
            ulong? firstSlot = null, ulong? lastSlot = null, Commitment commitment = Commitment.Finalized)
395
            => GetBlockProductionAsync(identity, firstSlot, lastSlot, commitment).Result;
5✔
396

397
        #endregion
398

399
        /// <inheritdoc cref="IRpcClient.GetHealth()"/>
400
        public RequestResult<string> GetHealth()
401
            => GetHealthAsync().Result;
2✔
402

403
        /// <inheritdoc cref="IRpcClient.GetHealthAsync()"/>
404
        public async Task<RequestResult<string>> GetHealthAsync()
405
        {
406
            return await SendRequestAsync<string>("getHealth");
2✔
407
        }
2✔
408

409

410
        /// <inheritdoc cref="IRpcClient.GetLeaderSchedule"/>
411
        public RequestResult<Dictionary<string, List<ulong>>> GetLeaderSchedule(ulong slot = 0,
412
            string identity = null, Commitment commitment = Commitment.Finalized)
413
            => GetLeaderScheduleAsync(slot, identity, commitment).Result;
6✔
414

415
        /// <inheritdoc cref="IRpcClient.GetLeaderScheduleAsync"/>
416
        public async Task<RequestResult<Dictionary<string, List<ulong>>>> GetLeaderScheduleAsync(ulong slot = 0,
417
            string identity = null, Commitment commitment = Commitment.Finalized)
418
        {
419
            return await SendRequestAsync<Dictionary<string, List<ulong>>>("getLeaderSchedule",
6✔
420
                Parameters.Create(
6✔
421
                    slot > 0 ? slot : null,
6✔
422
                    ConfigObject.Create(
6✔
423
                        HandleCommitment(commitment),
6✔
424
                        KeyValue.Create("identity", identity))));
6✔
425
        }
6✔
426

427

428
        /// <inheritdoc cref="IRpcClient.GetTransactionAsync"/>
429
        public async Task<RequestResult<TransactionMetaSlotInfo>> GetTransactionAsync(string signature,
430
            Commitment commitment = Commitment.Finalized, int maxSupportedTransactionVersion = 0)
431
        {
432
            return await SendRequestAsync<TransactionMetaSlotInfo>("getTransaction",
3✔
433
                Parameters.Create(signature,
3✔
434
                    ConfigObject.Create(KeyValue.Create("encoding", "json"), HandleCommitment(commitment), KeyValue.Create("maxSupportedTransactionVersion", maxSupportedTransactionVersion))));
3✔
435
        }
3✔
436

437
        /// <inheritdoc cref="IRpcClient.GetConfirmedTransactionAsync(string, Commitment, int)"/>
438
        public async Task<RequestResult<TransactionMetaSlotInfo>> GetConfirmedTransactionAsync(string signature,
439
            Commitment commitment = Commitment.Finalized, int maxSupportedTransactionVersion = 0)
440
        {
441
            return await SendRequestAsync<TransactionMetaSlotInfo>("getConfirmedTransaction",
2✔
442
                Parameters.Create(signature,
2✔
443
                    ConfigObject.Create(KeyValue.Create("encoding", "json"), HandleCommitment(commitment), KeyValue.Create("maxSupportedTransactionVersion", maxSupportedTransactionVersion))));
2✔
444
        }
2✔
445

446
        /// <inheritdoc cref="IRpcClient.GetTransaction"/>
447
        public RequestResult<TransactionMetaSlotInfo> GetTransaction(string signature,
448
            Commitment commitment = Commitment.Finalized, int maxSupportedTransactionVersion = 0)
449
            => GetTransactionAsync(signature, commitment, maxSupportedTransactionVersion).Result;
3✔
450

451
        /// <inheritdoc cref="IRpcClient.GetConfirmedTransaction(string, Commitment, int)"/>
452
        public RequestResult<TransactionMetaSlotInfo> GetConfirmedTransaction(string signature,
453
            Commitment commitment = Commitment.Finalized, int maxSupportedTransactionVersion = 0) =>
454
            GetConfirmedTransactionAsync(signature, commitment, maxSupportedTransactionVersion).Result;
2✔
455

456
        /// <inheritdoc cref="IRpcClient.GetBlockHeightAsync"/>
457
        public async Task<RequestResult<ulong>> GetBlockHeightAsync(Commitment commitment = Commitment.Finalized)
458
        {
459
            return await SendRequestAsync<ulong>("getBlockHeight",
2✔
460
                Parameters.Create(ConfigObject.Create(HandleCommitment(commitment))));
2✔
461
        }
2✔
462

463
        /// <inheritdoc cref="IRpcClient.GetBlockHeight"/>
464
        public RequestResult<ulong> GetBlockHeight(Commitment commitment = Commitment.Finalized)
465
            => GetBlockHeightAsync(commitment).Result;
2✔
466

467
        /// <inheritdoc cref="IRpcClient.GetBlockCommitmentAsync"/>
468
        public async Task<RequestResult<BlockCommitment>> GetBlockCommitmentAsync(ulong slot)
469
        {
470
            return await SendRequestAsync<BlockCommitment>("getBlockCommitment", Parameters.Create(slot));
1✔
471
        }
1✔
472

473
        /// <inheritdoc cref="IRpcClient.GetBlockCommitment"/>
474
        public RequestResult<BlockCommitment> GetBlockCommitment(ulong slot)
475
            => GetBlockCommitmentAsync(slot).Result;
1✔
476

477
        /// <inheritdoc cref="IRpcClient.GetBlockTimeAsync"/>
478
        public async Task<RequestResult<ulong>> GetBlockTimeAsync(ulong slot)
479
        {
480
            return await SendRequestAsync<ulong>("getBlockTime", Parameters.Create(slot));
1✔
481
        }
1✔
482

483
        /// <inheritdoc cref="IRpcClient.GetBlockTime"/>
484
        public RequestResult<ulong> GetBlockTime(ulong slot)
485
            => GetBlockTimeAsync(slot).Result;
1✔
486

487
        /// <inheritdoc cref="IRpcClient.GetClusterNodesAsync"/>
488
        public async Task<RequestResult<List<ClusterNode>>> GetClusterNodesAsync()
489
        {
490
            return await SendRequestAsync<List<ClusterNode>>("getClusterNodes");
1✔
491
        }
1✔
492

493
        /// <inheritdoc cref="IRpcClient.GetClusterNodes"/>
494
        public RequestResult<List<ClusterNode>> GetClusterNodes()
495
            => GetClusterNodesAsync().Result;
1✔
496

497
        /// <inheritdoc cref="IRpcClient.GetEpochInfoAsync"/>
498
        public async Task<RequestResult<EpochInfo>> GetEpochInfoAsync(Commitment commitment = Commitment.Finalized)
499
        {
500
            return await SendRequestAsync<EpochInfo>("getEpochInfo",
2✔
501
                Parameters.Create(ConfigObject.Create(HandleCommitment(commitment))));
2✔
502
        }
2✔
503

504
        /// <inheritdoc cref="IRpcClient.GetEpochInfo"/>
505
        public RequestResult<EpochInfo> GetEpochInfo(Commitment commitment = Commitment.Finalized) =>
506
            GetEpochInfoAsync(commitment).Result;
2✔
507

508
        /// <inheritdoc cref="IRpcClient.GetEpochScheduleAsync"/>
509
        public async Task<RequestResult<EpochScheduleInfo>> GetEpochScheduleAsync()
510
        {
511
            return await SendRequestAsync<EpochScheduleInfo>("getEpochSchedule");
1✔
512
        }
1✔
513

514
        /// <inheritdoc cref="IRpcClient.GetEpochSchedule"/>
515
        public RequestResult<EpochScheduleInfo> GetEpochSchedule() => GetEpochScheduleAsync().Result;
1✔
516

517

518
        /// <inheritdoc cref="IRpcClient.GetFeeCalculatorForBlockhashAsync"/>
519
        public async Task<RequestResult<ResponseValue<FeeCalculatorInfo>>> GetFeeCalculatorForBlockhashAsync(
520
            string blockhash, Commitment commitment = Commitment.Finalized)
521
        {
522
            List<object> parameters = Parameters.Create(blockhash, ConfigObject.Create(HandleCommitment(commitment)));
2✔
523

524
            return await SendRequestAsync<ResponseValue<FeeCalculatorInfo>>("getFeeCalculatorForBlockhash", parameters);
2✔
525
        }
2✔
526

527
        /// <inheritdoc cref="IRpcClient.GetFeeCalculatorForBlockhash"/>
528
        public RequestResult<ResponseValue<FeeCalculatorInfo>> GetFeeCalculatorForBlockhash(string blockhash,
529
            Commitment commitment = Commitment.Finalized) =>
530
            GetFeeCalculatorForBlockhashAsync(blockhash, commitment).Result;
2✔
531

532
        /// <inheritdoc cref="IRpcClient.GetFeeRateGovernorAsync"/>
533
        public async Task<RequestResult<ResponseValue<FeeRateGovernorInfo>>> GetFeeRateGovernorAsync()
534
        {
535
            return await SendRequestAsync<ResponseValue<FeeRateGovernorInfo>>("getFeeRateGovernor");
1✔
536
        }
1✔
537

538
        /// <inheritdoc cref="IRpcClient.GetFeeRateGovernor"/>
539
        public RequestResult<ResponseValue<FeeRateGovernorInfo>> GetFeeRateGovernor()
540
            => GetFeeRateGovernorAsync().Result;
1✔
541

542
        /// <inheritdoc cref="IRpcClient.GetFeesAsync"/>
543
        public async Task<RequestResult<ResponseValue<FeesInfo>>> GetFeesAsync(
544
            Commitment commitment = Commitment.Finalized)
545
        {
546
            return await SendRequestAsync<ResponseValue<FeesInfo>>("getFees",
2✔
547
                Parameters.Create(ConfigObject.Create(HandleCommitment(commitment))));
2✔
548
        }
2✔
549

550
        /// <inheritdoc cref="IRpcClient.GetFees"/>
551
        public RequestResult<ResponseValue<FeesInfo>> GetFees(Commitment commitment = Commitment.Finalized)
552
            => GetFeesAsync(commitment).Result;
2✔
553
        
554
        /// <inheritdoc cref="IRpcClient.GetFeeForMessageAsync(string, Commitment)"/>
555
        public async Task<RequestResult<ResponseValue<ulong>>> GetFeeForMessageAsync(
556
            string message, Commitment commitment = Commitment.Finalized)
557
        {
558
            List<object> parameters = Parameters.Create(message, ConfigObject.Create(HandleCommitment(commitment)));
1✔
559
            return await SendRequestAsync<ResponseValue<ulong>>("getFeeForMessage", parameters);
1✔
560
        }
1✔
561

562
        /// <inheritdoc cref="IRpcClient.GetFeeForMessage(string, Commitment)"/>
563
        public RequestResult<ResponseValue<ulong>> GetFeeForMessage(string message,
564
            Commitment commitment = Commitment.Finalized)
565
            => GetFeeForMessageAsync(message, commitment).Result;
1✔
566

567
        /// <inheritdoc cref="IRpcClient.GetRecentBlockHashAsync"/>
568
        public async Task<RequestResult<ResponseValue<BlockHash>>> GetRecentBlockHashAsync(
569
            Commitment commitment = Commitment.Finalized)
570
        {
571
            return await SendRequestAsync<ResponseValue<BlockHash>>("getRecentBlockhash",
2✔
572
                Parameters.Create(ConfigObject.Create(HandleCommitment(commitment))));
2✔
573
        }
2✔
574

575
        /// <inheritdoc cref="IRpcClient.GetLatestBlockHash"/>
576
        public RequestResult<ResponseValue<LatestBlockHash>> GetLatestBlockHash(Commitment commitment = Commitment.Finalized)
577
            => GetLatestBlockHashAsync(commitment).Result;
1✔
578

579
        /// <inheritdoc cref="IRpcClient.GetLatestBlockHashAsync"/>
580
        public async Task<RequestResult<ResponseValue<LatestBlockHash>>> GetLatestBlockHashAsync(
581
            Commitment commitment = Commitment.Finalized)
582
        {
583
            return await SendRequestAsync<ResponseValue<LatestBlockHash>>("getLatestBlockhash",
1✔
584
                Parameters.Create(ConfigObject.Create(HandleCommitment(commitment))));
1✔
585
        }
1✔
586

587
        /// <inheritdoc cref="IRpcClient.IsBlockHashValidAsync"/>
588
        public async Task<RequestResult<ResponseValue<bool>>> IsBlockHashValidAsync(string blockHash, Commitment commitment = Commitment.Finalized)
589
        {
590
            return await SendRequestAsync<ResponseValue<bool>>("isBlockhashValid",
1✔
591
                Parameters.Create(blockHash, ConfigObject.Create(HandleCommitment(commitment))));
1✔
592
        }
1✔
593

594
        /// <inheritdoc cref="IRpcClient.IsBlockHashValid"/>
595
        public RequestResult<ResponseValue<bool>> IsBlockHashValid(string blockHash, Commitment commitment = Commitment.Finalized)
596
            => IsBlockHashValidAsync(blockHash, commitment).Result;
1✔
597

598
        /// <inheritdoc cref="IRpcClient.GetRecentBlockHash"/>
599
        public RequestResult<ResponseValue<BlockHash>> GetRecentBlockHash(Commitment commitment = Commitment.Finalized)
600
            => GetRecentBlockHashAsync(commitment).Result;
2✔
601

602
        /// <inheritdoc cref="IRpcClient.GetMaxRetransmitSlotAsync"/>
603
        public async Task<RequestResult<ulong>> GetMaxRetransmitSlotAsync()
604
        {
605
            return await SendRequestAsync<ulong>("getMaxRetransmitSlot");
1✔
606
        }
1✔
607

608
        /// <inheritdoc cref="IRpcClient.GetMaxRetransmitSlot"/>
609
        public RequestResult<ulong> GetMaxRetransmitSlot()
610
            => GetMaxRetransmitSlotAsync().Result;
1✔
611

612
        /// <inheritdoc cref="IRpcClient.GetMaxShredInsertSlotAsync"/>
613
        public async Task<RequestResult<ulong>> GetMaxShredInsertSlotAsync()
614
        {
615
            return await SendRequestAsync<ulong>("getMaxShredInsertSlot");
1✔
616
        }
1✔
617

618
        /// <inheritdoc cref="IRpcClient.GetMaxShredInsertSlot"/>
619
        public RequestResult<ulong> GetMaxShredInsertSlot()
620
            => GetMaxShredInsertSlotAsync().Result;
1✔
621

622
        /// <inheritdoc cref="IRpcClient.GetMinimumBalanceForRentExemptionAsync"/>
623
        public async Task<RequestResult<ulong>> GetMinimumBalanceForRentExemptionAsync(long accountDataSize,
624
            Commitment commitment = Commitment.Finalized)
625
        {
626
            return await SendRequestAsync<ulong>("getMinimumBalanceForRentExemption",
2✔
627
                Parameters.Create(accountDataSize, ConfigObject.Create(HandleCommitment(commitment))));
2✔
628
        }
2✔
629

630
        /// <inheritdoc cref="IRpcClient.GetMinimumBalanceForRentExemption"/>
631
        public RequestResult<ulong> GetMinimumBalanceForRentExemption(long accountDataSize,
632
            Commitment commitment = Commitment.Finalized)
633
            => GetMinimumBalanceForRentExemptionAsync(accountDataSize, commitment).Result;
2✔
634

635
        /// <inheritdoc cref="IRpcClient.GetGenesisHashAsync"/>
636
        public async Task<RequestResult<string>> GetGenesisHashAsync()
637
        {
638
            return await SendRequestAsync<string>("getGenesisHash");
1✔
639
        }
1✔
640

641
        /// <inheritdoc cref="IRpcClient.GetGenesisHash"/>
642
        public RequestResult<string> GetGenesisHash()
643
            => GetGenesisHashAsync().Result;
1✔
644

645
        /// <inheritdoc cref="IRpcClient.GetIdentityAsync"/>
646
        public async Task<RequestResult<NodeIdentity>> GetIdentityAsync()
647
        {
648
            return await SendRequestAsync<NodeIdentity>("getIdentity");
1✔
649
        }
1✔
650

651
        /// <inheritdoc cref="IRpcClient.GetIdentity"/>
652
        public RequestResult<NodeIdentity> GetIdentity()
653
            => GetIdentityAsync().Result;
1✔
654

655
        /// <inheritdoc cref="IRpcClient.GetInflationGovernorAsync"/>
656
        public async Task<RequestResult<InflationGovernor>> GetInflationGovernorAsync(
657
            Commitment commitment = Commitment.Finalized)
658
        {
659
            return await SendRequestAsync<InflationGovernor>("getInflationGovernor",
2✔
660
                Parameters.Create(ConfigObject.Create(HandleCommitment(commitment))));
2✔
661
        }
2✔
662

663
        /// <inheritdoc cref="IRpcClient.GetInflationGovernor"/>
664
        public RequestResult<InflationGovernor> GetInflationGovernor(Commitment commitment = Commitment.Finalized)
665
            => GetInflationGovernorAsync(commitment).Result;
2✔
666

667
        /// <inheritdoc cref="IRpcClient.GetInflationRateAsync"/>
668
        public async Task<RequestResult<InflationRate>> GetInflationRateAsync()
669
        {
670
            return await SendRequestAsync<InflationRate>("getInflationRate");
1✔
671
        }
1✔
672

673
        /// <inheritdoc cref="IRpcClient.GetInflationRate"/>
674
        public RequestResult<InflationRate> GetInflationRate()
675
            => GetInflationRateAsync().Result;
1✔
676

677
        /// <inheritdoc cref="IRpcClient.GetInflationRewardAsync"/>
678
        public async Task<RequestResult<List<InflationReward>>> GetInflationRewardAsync(IList<string> addresses,
679
            ulong epoch = 0, Commitment commitment = Commitment.Finalized)
680
        {
681
            return await SendRequestAsync<List<InflationReward>>("getInflationReward",
3✔
682
                Parameters.Create(
3✔
683
                    addresses,
3✔
684
                    ConfigObject.Create(
3✔
685
                        HandleCommitment(commitment),
3✔
686
                        KeyValue.Create("epoch", epoch > 0 ? epoch : null))));
3✔
687
        }
3✔
688

689
        /// <inheritdoc cref="IRpcClient.GetInflationReward"/>
690
        public RequestResult<List<InflationReward>> GetInflationReward(IList<string> addresses, ulong epoch = 0,
691
            Commitment commitment = Commitment.Finalized)
692
            => GetInflationRewardAsync(addresses, epoch, commitment).Result;
3✔
693

694
        /// <inheritdoc cref="IRpcClient.GetLargestAccountsAsync"/>
695
        public async Task<RequestResult<ResponseValue<List<LargeAccount>>>> GetLargestAccountsAsync(
696
            AccountFilterType? filter = null,
697
            Commitment commitment = Commitment.Finalized)
698
        {
699
            return await SendRequestAsync<ResponseValue<List<LargeAccount>>>("getLargestAccounts",
2✔
700
                Parameters.Create(
2✔
701
                    ConfigObject.Create(
2✔
702
                        HandleCommitment(commitment),
2✔
703
                        KeyValue.Create("filter", filter))));
2✔
704
        }
2✔
705

706
        /// <inheritdoc cref="IRpcClient.GetLargestAccounts"/>
707
        public RequestResult<ResponseValue<List<LargeAccount>>> GetLargestAccounts(AccountFilterType? filter = null,
708
            Commitment commitment = Commitment.Finalized)
709
            => GetLargestAccountsAsync(filter, commitment).Result;
2✔
710

711
        /// <inheritdoc cref="IRpcClient.GetSnapshotSlotAsync"/>
712
        public async Task<RequestResult<ulong>> GetSnapshotSlotAsync()
713
        {
714
            return await SendRequestAsync<ulong>("getSnapshotSlot");
1✔
715
        }
1✔
716

717
        /// <inheritdoc cref="IRpcClient.GetSnapshotSlot"/>
718
        public RequestResult<ulong> GetSnapshotSlot() => GetSnapshotSlotAsync().Result;
1✔
719
        
720
        /// <inheritdoc cref="IRpcClient.GetHighestSnapshotSlotAsync"/>
721
        public async Task<RequestResult<SnapshotSlotInfo>> GetHighestSnapshotSlotAsync()
722
        {
723
            return await SendRequestAsync<SnapshotSlotInfo>("getHighestSnapshotSlot");
1✔
724
        }
1✔
725

726
        /// <inheritdoc cref="IRpcClient.GetHighestSnapshotSlot"/>
727
        public RequestResult<SnapshotSlotInfo> GetHighestSnapshotSlot() => GetHighestSnapshotSlotAsync().Result;
1✔
728

729
        /// <inheritdoc cref="IRpcClient.GetRecentPerformanceSamplesAsync"/>
730
        public async Task<RequestResult<List<PerformanceSample>>> GetRecentPerformanceSamplesAsync(ulong limit = 720)
731
        {
732
            return await SendRequestAsync<List<PerformanceSample>>("getRecentPerformanceSamples",
1✔
733
                new List<object> { limit });
1✔
734
        }
1✔
735

736
        /// <inheritdoc cref="IRpcClient.GetRecentPerformanceSamples"/>
737
        public RequestResult<List<PerformanceSample>> GetRecentPerformanceSamples(ulong limit = 720)
738
            => GetRecentPerformanceSamplesAsync(limit).Result;
1✔
739

740
        /// <inheritdoc cref="IRpcClient.GetSignaturesForAddressAsync"/>
741
        public async Task<RequestResult<List<SignatureStatusInfo>>> GetSignaturesForAddressAsync(string accountPubKey,
742
            ulong limit = 1000, string before = null, string until = null, Commitment commitment = Commitment.Finalized)
743
        {
744
            if (commitment == Commitment.Processed)
5✔
745
                throw new ArgumentException("Commitment.Processed is not supported for this method.");
1✔
746

747
            return await SendRequestAsync<List<SignatureStatusInfo>>("getSignaturesForAddress",
4!
748
                Parameters.Create(
4✔
749
                    accountPubKey,
4✔
750
                    ConfigObject.Create(
4✔
751
                        KeyValue.Create("limit", limit != 1000 ? limit : null),
4✔
752
                        KeyValue.Create("before", before),
4✔
753
                        KeyValue.Create("until", until),
4✔
754
                        HandleCommitment(commitment))));
4✔
755
        }
4✔
756

757
        /// <inheritdoc cref="IRpcClient.GetConfirmedSignaturesForAddress2Async"/>
758
        public async Task<RequestResult<List<SignatureStatusInfo>>> GetConfirmedSignaturesForAddress2Async(
759
            string accountPubKey, ulong limit = 1000, string before = null, string until = null,
760
            Commitment commitment = Commitment.Finalized)
761
        {
762
            if (commitment == Commitment.Processed)
5✔
763
                throw new ArgumentException("Commitment.Processed is not supported for this method.");
1✔
764

765
            return await SendRequestAsync<List<SignatureStatusInfo>>("getConfirmedSignaturesForAddress2",
4!
766
                Parameters.Create(
4✔
767
                    accountPubKey,
4✔
768
                    ConfigObject.Create(
4✔
769
                        KeyValue.Create("limit", limit != 1000 ? limit : null),
4✔
770
                        KeyValue.Create("before", before),
4✔
771
                        KeyValue.Create("until", until),
4✔
772
                        HandleCommitment(commitment))));
4✔
773
        }
4✔
774

775
        /// <inheritdoc cref="IRpcClient.GetSignaturesForAddress"/>
776
        public RequestResult<List<SignatureStatusInfo>> GetSignaturesForAddress(string accountPubKey,
777
            ulong limit = 1000,
778
            string before = null, string until = null, Commitment commitment = Commitment.Finalized)
779
            => GetSignaturesForAddressAsync(accountPubKey, limit, before, until, commitment).Result;
5✔
780

781
        /// <inheritdoc cref="IRpcClient.GetConfirmedSignaturesForAddress2"/>
782
        public RequestResult<List<SignatureStatusInfo>> GetConfirmedSignaturesForAddress2(string accountPubKey,
783
            ulong limit = 1000, string before = null,
784
            string until = null, Commitment commitment = Commitment.Finalized)
785
            => GetConfirmedSignaturesForAddress2Async(accountPubKey, limit, before, until, commitment).Result;
5✔
786

787
        /// <inheritdoc cref="IRpcClient.GetSignatureStatusesAsync"/>
788
        public async Task<RequestResult<ResponseValue<List<SignatureStatusInfo>>>> GetSignatureStatusesAsync(
789
            List<string> transactionHashes,
790
            bool searchTransactionHistory = false)
791
        {
792
            return await SendRequestAsync<ResponseValue<List<SignatureStatusInfo>>>("getSignatureStatuses",
2✔
793
                Parameters.Create(
2✔
794
                    transactionHashes,
2✔
795
                    ConfigObject.Create(
2✔
796
                        KeyValue.Create("searchTransactionHistory",
2✔
797
                            searchTransactionHistory ? searchTransactionHistory : null))));
2✔
798
        }
2✔
799

800
        /// <inheritdoc cref="IRpcClient.GetSignatureStatuses"/>
801
        public RequestResult<ResponseValue<List<SignatureStatusInfo>>> GetSignatureStatuses(
802
            List<string> transactionHashes,
803
            bool searchTransactionHistory = false)
804
            => GetSignatureStatusesAsync(transactionHashes, searchTransactionHistory).Result;
2✔
805

806
        /// <inheritdoc cref="IRpcClient.GetSlotAsync"/>
807
        public async Task<RequestResult<ulong>> GetSlotAsync(Commitment commitment = Commitment.Finalized)
808
        {
809
            return await SendRequestAsync<ulong>("getSlot",
2✔
810
                Parameters.Create(ConfigObject.Create(HandleCommitment(commitment))));
2✔
811
        }
2✔
812

813
        /// <inheritdoc cref="IRpcClient.GetSlot"/>
814
        public RequestResult<ulong> GetSlot(Commitment commitment = Commitment.Finalized) =>
815
            GetSlotAsync(commitment).Result;
2✔
816

817
        /// <inheritdoc cref="IRpcClient.GetSlotLeaderAsync"/>
818
        public async Task<RequestResult<string>> GetSlotLeaderAsync(Commitment commitment = Commitment.Finalized)
819
        {
820
            return await SendRequestAsync<string>("getSlotLeader",
2✔
821
                Parameters.Create(ConfigObject.Create(HandleCommitment(commitment))));
2✔
822
        }
2✔
823

824
        /// <inheritdoc cref="IRpcClient.GetSlotLeader"/>
825
        public RequestResult<string> GetSlotLeader(Commitment commitment = Commitment.Finalized) =>
826
            GetSlotLeaderAsync(commitment).Result;
2✔
827

828
        /// <inheritdoc cref="IRpcClient.GetSlotLeadersAsync"/>
829
        public async Task<RequestResult<List<string>>> GetSlotLeadersAsync(ulong start, ulong limit,
830
            Commitment commitment = Commitment.Finalized)
831
        {
832
            return await SendRequestAsync<List<string>>("getSlotLeaders",
2✔
833
                Parameters.Create(start, limit, ConfigObject.Create(HandleCommitment(commitment))));
2✔
834
        }
2✔
835

836
        /// <inheritdoc cref="IRpcClient.GetSlotLeaders"/>
837
        public RequestResult<List<string>> GetSlotLeaders(ulong start, ulong limit,
838
            Commitment commitment = Commitment.Finalized)
839
            => GetSlotLeadersAsync(start, limit, commitment).Result;
2✔
840

841
        #region Token Supply and Balances
842

843
        /// <inheritdoc cref="IRpcClient.GetStakeActivationAsync"/>
844
        public async Task<RequestResult<StakeActivationInfo>> GetStakeActivationAsync(string publicKey, ulong epoch = 0,
845
            Commitment commitment = Commitment.Finalized)
846
        {
847
            return await SendRequestAsync<StakeActivationInfo>("getStakeActivation",
3✔
848
                Parameters.Create(
3✔
849
                    publicKey,
3✔
850
                    ConfigObject.Create(
3✔
851
                        HandleCommitment(commitment),
3✔
852
                        KeyValue.Create("epoch", epoch > 0 ? epoch : null))));
3✔
853
        }
3✔
854

855
        /// <inheritdoc cref="IRpcClient.GetStakeActivation"/>
856
        public RequestResult<StakeActivationInfo> GetStakeActivation(string publicKey, ulong epoch = 0,
857
            Commitment commitment = Commitment.Finalized) =>
858
            GetStakeActivationAsync(publicKey, epoch, commitment).Result;
3✔
859

860
        /// <inheritdoc cref="IRpcClient.GetSupplyAsync"/>
861
        public async Task<RequestResult<ResponseValue<Supply>>> GetSupplyAsync(
862
            Commitment commitment = Commitment.Finalized)
863
        {
864
            return await SendRequestAsync<ResponseValue<Supply>>("getSupply",
2✔
865
                Parameters.Create(ConfigObject.Create(HandleCommitment(commitment))));
2✔
866
        }
2✔
867

868
        /// <inheritdoc cref="IRpcClient.GetSupply"/>
869
        public RequestResult<ResponseValue<Supply>> GetSupply(Commitment commitment = Commitment.Finalized)
870
            => GetSupplyAsync(commitment).Result;
2✔
871

872
        /// <inheritdoc cref="IRpcClient.GetTokenAccountBalanceAsync"/>
873
        public async Task<RequestResult<ResponseValue<TokenBalance>>> GetTokenAccountBalanceAsync(
874
            string splTokenAccountPublicKey, Commitment commitment = Commitment.Finalized)
875
        {
876
            return await SendRequestAsync<ResponseValue<TokenBalance>>("getTokenAccountBalance",
2✔
877
                Parameters.Create(splTokenAccountPublicKey, ConfigObject.Create(HandleCommitment(commitment))));
2✔
878
        }
2✔
879

880
        /// <inheritdoc cref="IRpcClient.GetTokenAccountBalance"/>
881
        public RequestResult<ResponseValue<TokenBalance>> GetTokenAccountBalance(string splTokenAccountPublicKey,
882
            Commitment commitment = Commitment.Finalized)
883
            => GetTokenAccountBalanceAsync(splTokenAccountPublicKey, commitment).Result;
2✔
884

885
        /// <inheritdoc cref="IRpcClient.GetTokenAccountsByDelegateAsync"/>
886
        public async Task<RequestResult<ResponseValue<List<TokenAccount>>>> GetTokenAccountsByDelegateAsync(
887
            string ownerPubKey, string tokenMintPubKey = null, string tokenProgramId = null,
888
            Commitment commitment = Commitment.Finalized)
889
        {
890
            if (string.IsNullOrWhiteSpace(tokenMintPubKey) && string.IsNullOrWhiteSpace(tokenProgramId))
3✔
891
                throw new ArgumentException("either tokenProgramId or tokenMintPubKey must be set");
1✔
892

893
            return await SendRequestAsync<ResponseValue<List<TokenAccount>>>("getTokenAccountsByDelegate",
2✔
894
                Parameters.Create(
2✔
895
                    ownerPubKey,
2✔
896
                    ConfigObject.Create(
2✔
897
                        KeyValue.Create("mint", tokenMintPubKey),
2✔
898
                        KeyValue.Create("programId", tokenProgramId)),
2✔
899
                    ConfigObject.Create(
2✔
900
                        HandleCommitment(commitment),
2✔
901
                        KeyValue.Create("encoding", "jsonParsed"))));
2✔
902
        }
2✔
903

904
        /// <inheritdoc cref="IRpcClient.GetTokenAccountsByDelegate"/>
905
        public RequestResult<ResponseValue<List<TokenAccount>>> GetTokenAccountsByDelegate(string ownerPubKey,
906
            string tokenMintPubKey = null, string tokenProgramId = null, Commitment commitment = Commitment.Finalized)
907
            => GetTokenAccountsByDelegateAsync(ownerPubKey, tokenMintPubKey, tokenProgramId, commitment).Result;
3✔
908

909
        /// <inheritdoc cref="IRpcClient.GetTokenAccountsByOwnerAsync"/>
910
        public async Task<RequestResult<ResponseValue<List<TokenAccount>>>> GetTokenAccountsByOwnerAsync(
911
            string ownerPubKey, string tokenMintPubKey = null, string tokenProgramId = null,
912
            Commitment commitment = Commitment.Finalized)
913
        {
914
            if (string.IsNullOrWhiteSpace(tokenMintPubKey) && string.IsNullOrWhiteSpace(tokenProgramId))
3✔
915
                throw new ArgumentException("either tokenProgramId or tokenMintPubKey must be set");
1✔
916

917
            return await SendRequestAsync<ResponseValue<List<TokenAccount>>>("getTokenAccountsByOwner",
2✔
918
                Parameters.Create(
2✔
919
                    ownerPubKey,
2✔
920
                    ConfigObject.Create(
2✔
921
                        KeyValue.Create("mint", tokenMintPubKey),
2✔
922
                        KeyValue.Create("programId", tokenProgramId)),
2✔
923
                    ConfigObject.Create(
2✔
924
                        HandleCommitment(commitment),
2✔
925
                        KeyValue.Create("encoding", "jsonParsed"))));
2✔
926
        }
2✔
927

928
        /// <inheritdoc cref="IRpcClient.GetTokenAccountsByOwner"/>
929
        public RequestResult<ResponseValue<List<TokenAccount>>> GetTokenAccountsByOwner(
930
            string ownerPubKey, string tokenMintPubKey = null, string tokenProgramId = null,
931
            Commitment commitment = Commitment.Finalized)
932
            => GetTokenAccountsByOwnerAsync(ownerPubKey, tokenMintPubKey, tokenProgramId, commitment).Result;
3✔
933

934
        /// <inheritdoc cref="IRpcClient.GetTokenLargestAccountsAsync"/>
935
        public async Task<RequestResult<ResponseValue<List<LargeTokenAccount>>>> GetTokenLargestAccountsAsync(
936
            string tokenMintPubKey, Commitment commitment = Commitment.Finalized)
937
        {
938
            return await SendRequestAsync<ResponseValue<List<LargeTokenAccount>>>("getTokenLargestAccounts",
2✔
939
                Parameters.Create(tokenMintPubKey, ConfigObject.Create(HandleCommitment(commitment))));
2✔
940
        }
2✔
941

942
        /// <inheritdoc cref="IRpcClient.GetTokenLargestAccounts"/>
943
        public RequestResult<ResponseValue<List<LargeTokenAccount>>> GetTokenLargestAccounts(string tokenMintPubKey,
944
            Commitment commitment = Commitment.Finalized)
945
            => GetTokenLargestAccountsAsync(tokenMintPubKey, commitment).Result;
2✔
946

947
        /// <inheritdoc cref="IRpcClient.GetTokenSupplyAsync"/>
948
        public async Task<RequestResult<ResponseValue<TokenBalance>>> GetTokenSupplyAsync(string tokenMintPubKey,
949
            Commitment commitment = Commitment.Finalized)
950
        {
951
            return await SendRequestAsync<ResponseValue<TokenBalance>>("getTokenSupply",
2✔
952
                Parameters.Create(tokenMintPubKey, ConfigObject.Create(HandleCommitment(commitment))));
2✔
953
        }
2✔
954

955
        /// <inheritdoc cref="IRpcClient.GetTokenSupply"/>
956
        public RequestResult<ResponseValue<TokenBalance>> GetTokenSupply(string tokenMintPubKey,
957
            Commitment commitment = Commitment.Finalized)
958
            => GetTokenSupplyAsync(tokenMintPubKey, commitment).Result;
2✔
959

960
        #endregion
961

962
        /// <inheritdoc cref="IRpcClient.GetTransactionCountAsync"/>
963
        public async Task<RequestResult<ulong>> GetTransactionCountAsync(Commitment commitment = Commitment.Finalized)
964
        {
965
            return await SendRequestAsync<ulong>("getTransactionCount",
2✔
966
                Parameters.Create(ConfigObject.Create(HandleCommitment(commitment))));
2✔
967
        }
2✔
968

969
        /// <inheritdoc cref="IRpcClient.GetTransactionCount"/>
970
        public RequestResult<ulong> GetTransactionCount(Commitment commitment = Commitment.Finalized)
971
            => GetTransactionCountAsync(commitment).Result;
2✔
972

973
        /// <inheritdoc cref="IRpcClient.GetVersionAsync"/>
974
        public async Task<RequestResult<NodeVersion>> GetVersionAsync()
975
        {
976
            return await SendRequestAsync<NodeVersion>("getVersion");
1✔
977
        }
1✔
978

979
        /// <inheritdoc cref="IRpcClient.GetVersion"/>
980
        public RequestResult<NodeVersion> GetVersion()
981
            => GetVersionAsync().Result;
1✔
982

983
        /// <inheritdoc cref="IRpcClient.GetVoteAccountsAsync"/>
984
        public async Task<RequestResult<VoteAccounts>> GetVoteAccountsAsync(string votePubKey = null,
985
            Commitment commitment = Commitment.Finalized)
986
        {
987
            return await SendRequestAsync<VoteAccounts>("getVoteAccounts",
2✔
988
                Parameters.Create(ConfigObject.Create(HandleCommitment(commitment),
2✔
989
                    KeyValue.Create("votePubkey", votePubKey))));
2✔
990
        }
2✔
991

992
        /// <inheritdoc cref="IRpcClient.GetVoteAccounts"/>
993
        public RequestResult<VoteAccounts> GetVoteAccounts(string votePubKey = null,
994
            Commitment commitment = Commitment.Finalized)
995
            => GetVoteAccountsAsync(votePubKey, commitment).Result;
2✔
996

997
        /// <inheritdoc cref="IRpcClient.GetMinimumLedgerSlotAsync"/>
998
        public async Task<RequestResult<ulong>> GetMinimumLedgerSlotAsync()
999
        {
1000
            return await SendRequestAsync<ulong>("minimumLedgerSlot");
1✔
1001
        }
1✔
1002

1003
        /// <inheritdoc cref="IRpcClient.GetMinimumLedgerSlot"/>
1004
        public RequestResult<ulong> GetMinimumLedgerSlot()
1005
            => GetMinimumLedgerSlotAsync().Result;
1✔
1006

1007
        /// <inheritdoc cref="IRpcClient.RequestAirdropAsync"/>
1008
        public async Task<RequestResult<string>> RequestAirdropAsync(string pubKey, ulong lamports,
1009
            Commitment commitment = Commitment.Finalized)
1010
        {
1011
            return await SendRequestAsync<string>("requestAirdrop",
1✔
1012
                Parameters.Create(pubKey, lamports, ConfigObject.Create(HandleCommitment(commitment))));
1✔
1013
        }
1✔
1014

1015
        /// <inheritdoc cref="IRpcClient.RequestAirdrop"/>
1016
        public RequestResult<string> RequestAirdrop(string pubKey, ulong lamports,
1017
            Commitment commitment = Commitment.Finalized)
1018
            => RequestAirdropAsync(pubKey, lamports, commitment).Result;
1✔
1019

1020
        #region Transactions
1021

1022
        /// <inheritdoc cref="IRpcClient.SendTransactionAsync(byte[], bool, Commitment)"/>
1023
        public async Task<RequestResult<string>> SendTransactionAsync(byte[] transaction, bool skipPreflight = false,
1024
            Commitment preflightCommitment = Commitment.Finalized)
1025
        {
1026
            return await SendTransactionAsync(Convert.ToBase64String(transaction), skipPreflight, preflightCommitment)
1✔
1027
                .ConfigureAwait(false);
1✔
1028
        }
1✔
1029

1030

1031
        /// <inheritdoc cref="IRpcClient.SendTransactionAsync(string, bool, Commitment)"/>
1032
        public async Task<RequestResult<string>> SendTransactionAsync(string transaction, bool skipPreflight = false,
1033
            Commitment preflightCommitment = Commitment.Finalized)
1034
        {
1035
            return await SendRequestAsync<string>("sendTransaction",
2✔
1036
                Parameters.Create(
2✔
1037
                    transaction,
2✔
1038
                    ConfigObject.Create(
2✔
1039
                        KeyValue.Create("skipPreflight", skipPreflight ? skipPreflight : null),
2✔
1040
                        KeyValue.Create("preflightCommitment",
2✔
1041
                            preflightCommitment == Commitment.Finalized ? null : preflightCommitment),
2✔
1042
                        KeyValue.Create("encoding", BinaryEncoding.Base64))));
2✔
1043
        }
2✔
1044

1045
        /// <inheritdoc cref="IRpcClient.SendTransaction(string, bool, Commitment)"/>
1046
        public RequestResult<string> SendTransaction(string transaction, bool skipPreFlight = false,
1047
            Commitment preFlightCommitment = Commitment.Finalized)
1048
            => SendTransactionAsync(transaction, skipPreFlight, preFlightCommitment).Result;
1✔
1049

1050
        /// <inheritdoc cref="IRpcClient.SendTransactionAsync(byte[], bool, Commitment)"/>
1051
        public RequestResult<string> SendTransaction(byte[] transaction, bool skipPreFlight = false,
1052
            Commitment preFlightCommitment = Commitment.Finalized)
1053
            => SendTransactionAsync(transaction, skipPreFlight, preFlightCommitment).Result;
1✔
1054

1055
        /// <inheritdoc cref="IRpcClient.SimulateTransactionAsync(string, bool, Commitment, bool, IList{string})"/>
1056
        public async Task<RequestResult<ResponseValue<SimulationLogs>>> SimulateTransactionAsync(string transaction,
1057
            bool sigVerify = false,
1058
            Commitment commitment = Commitment.Finalized, bool replaceRecentBlockhash = false,
1059
            IList<string> accountsToReturn = null)
1060
        {
1061
            if (sigVerify && replaceRecentBlockhash)
6✔
1062
            {
1063
                throw new ArgumentException(
1✔
1064
                    $"Parameters {nameof(sigVerify)} and {nameof(replaceRecentBlockhash)} are incompatible, only one can be set to true.");
1✔
1065
            }
1066

1067
            return await SendRequestAsync<ResponseValue<SimulationLogs>>("simulateTransaction",
5!
1068
                Parameters.Create(
5✔
1069
                    transaction,
5✔
1070
                    ConfigObject.Create(
5✔
1071
                        KeyValue.Create("sigVerify", sigVerify ? sigVerify : null),
5✔
1072
                        HandleCommitment(commitment),
5✔
1073
                        KeyValue.Create("encoding", BinaryEncoding.Base64),
5✔
1074
                        KeyValue.Create("replaceRecentBlockhash",
5✔
1075
                            replaceRecentBlockhash ? replaceRecentBlockhash : null),
5✔
1076
                        KeyValue.Create("accounts", accountsToReturn != null
5✔
1077
                            ? ConfigObject.Create(
5✔
1078
                                KeyValue.Create("encoding", BinaryEncoding.Base64),
5✔
1079
                                KeyValue.Create("addresses", accountsToReturn))
5✔
1080
                            : null))));
5✔
1081
        }
5✔
1082

1083
        /// <inheritdoc cref="IRpcClient.SimulateTransactionAsync(byte[], bool, Commitment, bool, IList{string})"/>
1084
        public async Task<RequestResult<ResponseValue<SimulationLogs>>> SimulateTransactionAsync(byte[] transaction,
1085
            bool sigVerify = false,
1086
            Commitment commitment = Commitment.Finalized, bool replaceRecentBlockhash = false,
1087
            IList<string> accountsToReturn = null)
1088
        {
1089
            return await SimulateTransactionAsync(Convert.ToBase64String(transaction), sigVerify, commitment,
1✔
1090
                    replaceRecentBlockhash, accountsToReturn)
1✔
1091
                .ConfigureAwait(false);
1✔
1092
        }
1✔
1093

1094
        /// <inheritdoc cref="IRpcClient.SimulateTransaction(string, bool, Commitment, bool, IList{string})"/>
1095
        public RequestResult<ResponseValue<SimulationLogs>> SimulateTransaction(string transaction,
1096
            bool sigVerify = false,
1097
            Commitment commitment = Commitment.Finalized, bool replaceRecentBlockhash = false,
1098
            IList<string> accountsToReturn = null)
1099
            => SimulateTransactionAsync(transaction, sigVerify, commitment, replaceRecentBlockhash, accountsToReturn)
5✔
1100
                .Result;
5✔
1101

1102
        /// <inheritdoc cref="IRpcClient.SimulateTransaction(byte[], bool, Commitment, bool, IList{string})"/>
1103
        public RequestResult<ResponseValue<SimulationLogs>> SimulateTransaction(byte[] transaction,
1104
            bool sigVerify = false,
1105
            Commitment commitment = Commitment.Finalized, bool replaceRecentBlockhash = false,
1106
            IList<string> accountsToReturn = null)
1107
            => SimulateTransactionAsync(transaction, sigVerify, commitment, replaceRecentBlockhash, accountsToReturn)
1✔
1108
                .Result;
1✔
1109

1110
        #endregion
1111

1112
        /// <summary>
1113
        /// Gets the id for the next request.
1114
        /// </summary>
1115
        /// <returns>The id.</returns>
1116
        int IRpcClient.GetNextIdForReq() => _idGenerator.GetNextId();
24✔
1117

1118
    }
1119
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc