From 96290cf1e2ff0d71fb3355d3c484958fd30ca1e2 Mon Sep 17 00:00:00 2001 From: Juan Blanco Date: Thu, 27 Jul 2023 20:38:34 +0200 Subject: [PATCH] Adding optimism and binance --- .../EtherscanChain.cs | 5 +++- .../EtherscanRequestService.cs | 6 ++++ .../EtherscanApiServiceTests.cs | 28 +++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/Nethereum.DataServices.Etherscan/EtherscanChain.cs b/src/Nethereum.DataServices.Etherscan/EtherscanChain.cs index 4a377b15f..57b4107db 100644 --- a/src/Nethereum.DataServices.Etherscan/EtherscanChain.cs +++ b/src/Nethereum.DataServices.Etherscan/EtherscanChain.cs @@ -5,9 +5,12 @@ namespace Nethereum.DataServices.Etherscan public enum EtherscanChain { Mainnet, - + Binance, + Optimism } + + public enum EtherscanResultSort { Ascending, diff --git a/src/Nethereum.DataServices.Etherscan/EtherscanRequestService.cs b/src/Nethereum.DataServices.Etherscan/EtherscanRequestService.cs index fd0d1fd44..da887519d 100644 --- a/src/Nethereum.DataServices.Etherscan/EtherscanRequestService.cs +++ b/src/Nethereum.DataServices.Etherscan/EtherscanRequestService.cs @@ -17,6 +17,12 @@ public static string GetBaseUrl(EtherscanChain chain) { case EtherscanChain.Mainnet: return "https://api.etherscan.io/"; + + case EtherscanChain.Binance: + return "https://api.bscscan.com/"; + + case EtherscanChain.Optimism: + return "https://api-optimistic.etherscan.io/"; } throw new NotImplementedException(); } diff --git a/tests/Nethereum.DataServices.Etherscan.IntegrationTests/EtherscanApiServiceTests.cs b/tests/Nethereum.DataServices.Etherscan.IntegrationTests/EtherscanApiServiceTests.cs index bbebae5e1..442a36812 100644 --- a/tests/Nethereum.DataServices.Etherscan.IntegrationTests/EtherscanApiServiceTests.cs +++ b/tests/Nethereum.DataServices.Etherscan.IntegrationTests/EtherscanApiServiceTests.cs @@ -97,6 +97,34 @@ public async void ShouldGetAccountTransactions() }); } + [Fact] + public async void ShouldGetAccountTransactionsBinance() + { + await ThrottleEtherscanCallAsync(async () => + { + var etherscanService = new EtherscanApiService(EtherscanChain.Binance); + var result = await etherscanService.Accounts.GetAccountTransactionsAsync("0x0E09FaBB73Bd3Ade0a17ECC321fD13a19e81cE82"); + Assert.Equal("1", result.Status); + Assert.Equal(10, result.Result.Count); + + }); + } + + [Fact] + public async void ShouldGetAccountTransactionsOptimism() + { + await ThrottleEtherscanCallAsync(async () => + { + var etherscanService = new EtherscanApiService(EtherscanChain.Optimism); + var result = await etherscanService.Accounts.GetAccountTransactionsAsync("0x6fd9d7AD17242c41f7131d257212c54A0e816691"); + Assert.Equal("1", result.Status); + Assert.Equal(10, result.Result.Count); + + }); + } + + // + [Fact] public async void ShouldGetAccountInternalTransactions() {