From b5167d226ceaeb8213310aa888be6d186ced342d Mon Sep 17 00:00:00 2001 From: Jkorf Date: Mon, 23 Dec 2024 14:56:27 +0100 Subject: [PATCH] Update CryptoExchange.Net version to 8.5.0, added SetOptions on clients, added setting of DefaultProxyCredentials to CredentialCache.DefaultCredentials on the DI http client, updated dotnet versions to 9.0 --- .github/workflows/dotnet.yml | 2 +- .github/workflows/tests.yml | 2 +- .../Bitfinex.Net.UnitTests.csproj | 2 +- .../TestImplementations/TestSocket.cs | 4 +++- Bitfinex.Net/Bitfinex.Net.csproj | 2 +- Bitfinex.Net/Bitfinex.Net.xml | 18 ++++++++++++++++++ Bitfinex.Net/Clients/BitfinexRestClient.cs | 7 +++++++ Bitfinex.Net/Clients/BitfinexSocketClient.cs | 6 ++++++ .../ServiceCollectionExtensions.cs | 1 + .../Interfaces/Clients/IBitfinexRestClient.cs | 7 +++++++ .../Clients/IBitfinexSocketClient.cs | 7 +++++++ 11 files changed, 53 insertions(+), 5 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index cafaa72a..e156742f 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -16,7 +16,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v1 with: - dotnet-version: 8.0.x + dotnet-version: 9.0.x - name: Set GitHub package source run: dotnet nuget add source --username JKorf --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/JKorf/index.json" - name: Restore dependencies diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0e18e3e8..67110fdf 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,7 +14,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v1 with: - dotnet-version: 8.0.x + dotnet-version: 9.0.x - name: Set GitHub package source run: dotnet nuget add source --username JKorf --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/JKorf/index.json" - name: Restore dependencies diff --git a/Bitfinex.Net.UnitTests/Bitfinex.Net.UnitTests.csproj b/Bitfinex.Net.UnitTests/Bitfinex.Net.UnitTests.csproj index 5f854d24..fb090657 100644 --- a/Bitfinex.Net.UnitTests/Bitfinex.Net.UnitTests.csproj +++ b/Bitfinex.Net.UnitTests/Bitfinex.Net.UnitTests.csproj @@ -1,7 +1,7 @@  - net8.0 + net9.0 false diff --git a/Bitfinex.Net.UnitTests/TestImplementations/TestSocket.cs b/Bitfinex.Net.UnitTests/TestImplementations/TestSocket.cs index 398f28fb..ad132402 100644 --- a/Bitfinex.Net.UnitTests/TestImplementations/TestSocket.cs +++ b/Bitfinex.Net.UnitTests/TestImplementations/TestSocket.cs @@ -10,7 +10,7 @@ namespace Binance.Net.UnitTests.TestImplementations { - public class TestSocket: IWebsocket + public class TestSocket : IWebsocket { public bool CanConnect { get; set; } = true; public bool Connected { get; set; } @@ -130,5 +130,7 @@ public async Task ReconnectAsync() await Task.Delay(10); await OnReconnected(); } + + public void UpdateProxy(ApiProxy proxy) => throw new NotImplementedException(); } } diff --git a/Bitfinex.Net/Bitfinex.Net.csproj b/Bitfinex.Net/Bitfinex.Net.csproj index cf9148e2..8d2772c4 100644 --- a/Bitfinex.Net/Bitfinex.Net.csproj +++ b/Bitfinex.Net/Bitfinex.Net.csproj @@ -51,7 +51,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Bitfinex.Net/Bitfinex.Net.xml b/Bitfinex.Net/Bitfinex.Net.xml index 6c998a5b..1b2360c5 100644 --- a/Bitfinex.Net/Bitfinex.Net.xml +++ b/Bitfinex.Net/Bitfinex.Net.xml @@ -126,6 +126,9 @@ The logger factory Http client for this client + + + Set the default options to be used when creating new clients @@ -154,6 +157,9 @@ The logger factory Option configuration + + + Set the default options to be used when creating new clients @@ -1630,6 +1636,12 @@ Spot endpoints + + + Update specific options + + Options to update. Only specific options are changable after the client has been created + Set the API credentials for this client. All Api clients in this client will use the new credentials, regardless of earlier set options. @@ -1646,6 +1658,12 @@ Spot streams + + + Update specific options + + Options to update. Only specific options are changable after the client has been created + Set the API credentials for this client. All Api clients in this client will use the new credentials, regardless of earlier set options. diff --git a/Bitfinex.Net/Clients/BitfinexRestClient.cs b/Bitfinex.Net/Clients/BitfinexRestClient.cs index 575a8b71..35a11c77 100644 --- a/Bitfinex.Net/Clients/BitfinexRestClient.cs +++ b/Bitfinex.Net/Clients/BitfinexRestClient.cs @@ -11,6 +11,7 @@ using Microsoft.Extensions.DependencyInjection; using CryptoExchange.Net.Clients; using Microsoft.Extensions.Options; +using CryptoExchange.Net.Objects.Options; namespace Bitfinex.Net.Clients { @@ -52,6 +53,12 @@ public BitfinexRestClient(HttpClient? httpClient, ILoggerFactory? loggerFactory, #endregion #region methods + /// + public void SetOptions(UpdateOptions options) + { + GeneralApi.SetOptions(options); + SpotApi.SetOptions(options); + } /// /// Set the default options to be used when creating new clients diff --git a/Bitfinex.Net/Clients/BitfinexSocketClient.cs b/Bitfinex.Net/Clients/BitfinexSocketClient.cs index ce29aaa8..dbe853c8 100644 --- a/Bitfinex.Net/Clients/BitfinexSocketClient.cs +++ b/Bitfinex.Net/Clients/BitfinexSocketClient.cs @@ -7,6 +7,7 @@ using Bitfinex.Net.Objects.Options; using CryptoExchange.Net.Clients; using Microsoft.Extensions.Options; +using CryptoExchange.Net.Objects.Options; namespace Bitfinex.Net.Clients { @@ -44,6 +45,11 @@ public BitfinexSocketClient(IOptions options, ILoggerFact } #endregion + /// + public void SetOptions(UpdateOptions options) + { + SpotApi.SetOptions(options); + } /// /// Set the default options to be used when creating new clients diff --git a/Bitfinex.Net/ExtensionMethods/ServiceCollectionExtensions.cs b/Bitfinex.Net/ExtensionMethods/ServiceCollectionExtensions.cs index 19f7e319..c2282be3 100644 --- a/Bitfinex.Net/ExtensionMethods/ServiceCollectionExtensions.cs +++ b/Bitfinex.Net/ExtensionMethods/ServiceCollectionExtensions.cs @@ -110,6 +110,7 @@ private static IServiceCollection AddBitfinexCore( try { handler.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate; + handler.DefaultProxyCredentials = CredentialCache.DefaultCredentials; } catch (PlatformNotSupportedException) { } diff --git a/Bitfinex.Net/Interfaces/Clients/IBitfinexRestClient.cs b/Bitfinex.Net/Interfaces/Clients/IBitfinexRestClient.cs index 0f031449..c794d58b 100644 --- a/Bitfinex.Net/Interfaces/Clients/IBitfinexRestClient.cs +++ b/Bitfinex.Net/Interfaces/Clients/IBitfinexRestClient.cs @@ -2,6 +2,7 @@ using Bitfinex.Net.Interfaces.Clients.SpotApi; using CryptoExchange.Net.Authentication; using CryptoExchange.Net.Interfaces; +using CryptoExchange.Net.Objects.Options; namespace Bitfinex.Net.Interfaces.Clients { @@ -20,6 +21,12 @@ public interface IBitfinexRestClient : IRestClient /// IBitfinexRestClientSpotApi SpotApi { get; } + /// + /// Update specific options + /// + /// Options to update. Only specific options are changable after the client has been created + void SetOptions(UpdateOptions options); + /// /// Set the API credentials for this client. All Api clients in this client will use the new credentials, regardless of earlier set options. /// diff --git a/Bitfinex.Net/Interfaces/Clients/IBitfinexSocketClient.cs b/Bitfinex.Net/Interfaces/Clients/IBitfinexSocketClient.cs index a2a90731..2df66f8b 100644 --- a/Bitfinex.Net/Interfaces/Clients/IBitfinexSocketClient.cs +++ b/Bitfinex.Net/Interfaces/Clients/IBitfinexSocketClient.cs @@ -1,6 +1,7 @@ using Bitfinex.Net.Interfaces.Clients.SpotApi; using CryptoExchange.Net.Authentication; using CryptoExchange.Net.Interfaces; +using CryptoExchange.Net.Objects.Options; namespace Bitfinex.Net.Interfaces.Clients { @@ -14,6 +15,12 @@ public interface IBitfinexSocketClient : ISocketClient /// IBitfinexSocketClientSpotApi SpotApi { get; } + /// + /// Update specific options + /// + /// Options to update. Only specific options are changable after the client has been created + void SetOptions(UpdateOptions options); + /// /// Set the API credentials for this client. All Api clients in this client will use the new credentials, regardless of earlier set options. ///