Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
24452dc
commit 5e38191
Showing
8 changed files
with
3,587 additions
and
1,321 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/Nethereum.RPC/Eth/Blocks/EthGetBlockReceiptsByNumber.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
using Nethereum.Hex.HexTypes; | ||
using Nethereum.JsonRpc.Client; | ||
using Nethereum.RPC.Eth.DTOs; | ||
|
||
namespace Nethereum.RPC.Eth.Blocks | ||
{ | ||
public class EthGetBlockReceiptsByNumber : RpcRequestResponseHandler<TransactionReceipt[]>, IEthGetBlockReceiptsByNumber | ||
{ | ||
public EthGetBlockReceiptsByNumber(IClient client) | ||
: base(client, ApiMethods.eth_getBlockReceipts.ToString()) | ||
{ | ||
} | ||
|
||
public Task<TransactionReceipt[]> SendRequestAsync(BlockParameter blockParameter, object id = null) | ||
{ | ||
if (blockParameter == null) throw new ArgumentNullException(nameof(blockParameter)); | ||
return base.SendRequestAsync(id, blockParameter, true); | ||
} | ||
|
||
public Task<TransactionReceipt[]> SendRequestAsync(HexBigInteger number, object id = null) | ||
{ | ||
if (number == null) throw new ArgumentNullException(nameof(number)); | ||
return base.SendRequestAsync(id, number, true); | ||
} | ||
|
||
public RpcRequestResponseBatchItem<EthGetBlockReceiptsByNumber, TransactionReceipt[]> CreateBatchItem(HexBigInteger number, object id) | ||
{ | ||
return new RpcRequestResponseBatchItem<EthGetBlockReceiptsByNumber, TransactionReceipt[]>(this, BuildRequest(number, id)); | ||
} | ||
|
||
#if !DOTNET35 | ||
public async Task<List<TransactionReceipt[]>> SendBatchRequestAsync(params HexBigInteger[] numbers) | ||
{ | ||
var batchRequest = new RpcRequestResponseBatch(); | ||
for (int i = 0; i < numbers.Length; i++) | ||
{ | ||
batchRequest.BatchItems.Add(CreateBatchItem(numbers[i], i)); | ||
} | ||
|
||
var response = await Client.SendBatchRequestAsync(batchRequest); | ||
return response.BatchItems.Select(x => ((RpcRequestResponseBatchItem<EthGetBlockReceiptsByNumber, TransactionReceipt[]>)x).Response).ToList(); | ||
|
||
} | ||
#endif | ||
|
||
public RpcRequest BuildRequest(HexBigInteger number, object id = null) | ||
{ | ||
if (number == null) throw new ArgumentNullException(nameof(number)); | ||
return base.BuildRequest(id, number, true); | ||
} | ||
|
||
public RpcRequest BuildRequest(BlockParameter blockParameter, object id = null) | ||
{ | ||
if (blockParameter == null) throw new ArgumentNullException(nameof(blockParameter)); | ||
return base.BuildRequest(id, blockParameter, true); | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/Nethereum.RPC/Eth/Blocks/IEthGetBlockReceiptsByNumber.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using Nethereum.Hex.HexTypes; | ||
using Nethereum.JsonRpc.Client; | ||
using Nethereum.RPC.Eth.DTOs; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
|
||
namespace Nethereum.RPC.Eth.Blocks | ||
{ | ||
public interface IEthGetBlockReceiptsByNumber | ||
{ | ||
RpcRequest BuildRequest(BlockParameter blockParameter, object id = null); | ||
RpcRequest BuildRequest(HexBigInteger number, object id = null); | ||
RpcRequestResponseBatchItem<EthGetBlockReceiptsByNumber, TransactionReceipt[]> CreateBatchItem(HexBigInteger number, object id); | ||
#if !DOTNET35 | ||
Task<List<TransactionReceipt[]>> SendBatchRequestAsync(params HexBigInteger[] numbers); | ||
#endif | ||
Task<TransactionReceipt[]> SendRequestAsync(BlockParameter blockParameter, object id = null); | ||
Task<TransactionReceipt[]> SendRequestAsync(HexBigInteger number, object id = null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.