Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CryptoExchange V7.11.0 #4

Merged
merged 2 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion GateIo.Net.UnitTests/GateIoRestIntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
using System.Text;
using System.Threading.Tasks;

namespace CoinEx.Net.UnitTests
namespace GateIo.Net.UnitTests
{
[NonParallelizable]
internal class GateIoRestIntegrationTests : RestIntergrationTest<GateIoRestClient>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ public async Task<CallResult<GateIoOrder>> EditOrderAsync(string settlementAsset
var timestamp = DateTimeConverter.ConvertToSeconds(DateTime.UtcNow.AddSeconds(-1)).Value;
var signStr = $"api\nfutures.login\n\n{timestamp}";
var id = ExchangeHelpers.NextId();
return new GateIoLoginQuery(id, "futures.login", "api", provider.GetApiKey(), provider.SignSocketRequest(signStr), timestamp);
return new GateIoLoginQuery(id, "futures.login", "api", provider.ApiKey, provider.SignSocketRequest(signStr), timestamp);
}

/// <inheritdoc />
Expand Down
2 changes: 1 addition & 1 deletion GateIo.Net/Clients/SpotApi/GateIoSocketClientSpotApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ public async Task<CallResult<GateIoOrder>> GetOrderAsync(string symbol, long ord
var timestamp = DateTimeConverter.ConvertToSeconds(DateTime.UtcNow.AddSeconds(-1)).Value;
var signStr = $"api\nspot.login\n\n{timestamp}";
var id = ExchangeHelpers.NextId();
return new GateIoLoginQuery(id, "spot.login", "api", provider.GetApiKey(), provider.SignSocketRequest(signStr), timestamp);
return new GateIoLoginQuery(id, "spot.login", "api", provider.ApiKey, provider.SignSocketRequest(signStr), timestamp);
}

/// <inheritdoc />
Expand Down
2 changes: 1 addition & 1 deletion GateIo.Net/GateIo.Net.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="CryptoExchange.Net" Version="7.10.0" />
<PackageReference Include="CryptoExchange.Net" Version="7.11.0" />
</ItemGroup>
</Project>
17 changes: 9 additions & 8 deletions GateIo.Net/GateIoAuthenticationProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ internal class GateIoAuthenticationProvider : AuthenticationProvider
{
private static IMessageSerializer _serializer = new SystemTextJsonMessageSerializer();

public string GetApiKey() => _credentials.Key!.GetString();

public GateIoAuthenticationProvider(ApiCredentials credentials) : base(credentials)
{
}
Expand All @@ -25,9 +23,9 @@ public override void AuthenticateRequest(
RestApiClient apiClient,
Uri uri,
HttpMethod method,
IDictionary<string, object> uriParameters,
IDictionary<string, object> bodyParameters,
Dictionary<string, string> headers,
ref IDictionary<string, object>? uriParameters,
ref IDictionary<string, object>? bodyParameters,
ref Dictionary<string, string>? headers,
bool auth,
ArrayParametersSerialization arraySerialization,
HttpMethodParameterPosition parameterPosition,
Expand All @@ -36,13 +34,16 @@ public override void AuthenticateRequest(
if (!auth)
return;

uri = uri.SetParameters(uriParameters, arraySerialization);
if (uriParameters != null)
uri = uri.SetParameters(uriParameters, arraySerialization);

var timestamp = long.Parse(GetMillisecondTimestamp(apiClient)) / 1000;
var payload = SignSHA512(bodyParameters.Any() ? GetSerializedBody(_serializer, bodyParameters) : "").ToLowerInvariant();
var payload = SignSHA512(bodyParameters?.Any() == true ? GetSerializedBody(_serializer, bodyParameters) : "").ToLowerInvariant();
var signStr = $"{method.ToString().ToUpper()}\n{uri.AbsolutePath}\n{uri.Query.Replace("?", "")}\n{payload}\n{timestamp}";
var signed = SignHMACSHA512(signStr).ToLowerInvariant();

headers["KEY"] = GetApiKey();
headers ??= new Dictionary<string, string>();
headers["KEY"] = ApiKey;
headers["Timestamp"] = timestamp.ToString();
headers["SIGN"] = signed;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public GateIoAuthSubscription(ILogger logger, string channel, IEnumerable<string
var query = new GateIoAuthQuery<GateIoSubscriptionResponse>(_channel, "subscribe", _payload);
var request = (GateIoSocketAuthRequest<IEnumerable<string>>)query.Request;
var sign = provider.SignSocketRequest($"channel={_channel}&event=subscribe&time={request.Timestamp}");
request.Auth = new GateIoSocketAuth { Key = provider.GetApiKey(), Sign = sign, Method = "api_key" };
request.Auth = new GateIoSocketAuth { Key = provider.ApiKey, Sign = sign, Method = "api_key" };
return query;
}

Expand Down
Loading