Add user to position + fix few things
This commit is contained in:
@@ -35,17 +35,17 @@ namespace Managing.Infrastructure.Evm.Services
|
||||
endpoint = $"/{endpoint}";
|
||||
}
|
||||
|
||||
var url = $"{_settings.BaseUrl}privy{endpoint}";
|
||||
|
||||
var url = $"{_settings.BaseUrl}/api/privy{endpoint}";
|
||||
|
||||
try
|
||||
{
|
||||
var response = await _httpClient.PostAsJsonAsync(url, payload, _jsonOptions);
|
||||
|
||||
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
await HandleErrorResponse(response);
|
||||
}
|
||||
|
||||
|
||||
return await response.Content.ReadFromJsonAsync<T>(_jsonOptions);
|
||||
}
|
||||
catch (Exception ex) when (!(ex is Web3ProxyException))
|
||||
@@ -62,7 +62,7 @@ namespace Managing.Infrastructure.Evm.Services
|
||||
endpoint = $"/{endpoint}";
|
||||
}
|
||||
|
||||
var url = $"{_settings.BaseUrl}privy{endpoint}";
|
||||
var url = $"{_settings.BaseUrl}/api/privy{endpoint}";
|
||||
|
||||
if (payload != null)
|
||||
{
|
||||
@@ -72,12 +72,12 @@ namespace Managing.Infrastructure.Evm.Services
|
||||
try
|
||||
{
|
||||
var response = await _httpClient.GetAsync(url);
|
||||
|
||||
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
await HandleErrorResponse(response);
|
||||
}
|
||||
|
||||
|
||||
return await response.Content.ReadFromJsonAsync<T>(_jsonOptions);
|
||||
}
|
||||
catch (Exception ex) when (!(ex is Web3ProxyException))
|
||||
@@ -95,16 +95,16 @@ namespace Managing.Infrastructure.Evm.Services
|
||||
}
|
||||
|
||||
var url = $"{_settings.BaseUrl}/api/gmx{endpoint}";
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
var response = await _httpClient.PostAsJsonAsync(url, payload, _jsonOptions);
|
||||
|
||||
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
await HandleErrorResponse(response);
|
||||
}
|
||||
|
||||
|
||||
return await response.Content.ReadFromJsonAsync<T>(_jsonOptions);
|
||||
}
|
||||
catch (Exception ex) when (!(ex is Web3ProxyException))
|
||||
@@ -131,12 +131,12 @@ namespace Managing.Infrastructure.Evm.Services
|
||||
try
|
||||
{
|
||||
var response = await _httpClient.GetAsync(url);
|
||||
|
||||
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
await HandleErrorResponse(response);
|
||||
}
|
||||
|
||||
|
||||
return await response.Content.ReadFromJsonAsync<T>(_jsonOptions);
|
||||
}
|
||||
catch (Exception ex) when (!(ex is Web3ProxyException))
|
||||
@@ -149,25 +149,26 @@ namespace Managing.Infrastructure.Evm.Services
|
||||
private async Task HandleErrorResponse(HttpResponseMessage response)
|
||||
{
|
||||
var statusCode = (int)response.StatusCode;
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
// Try to parse as the Web3Proxy error format (success: false, error: string)
|
||||
var content = await response.Content.ReadAsStringAsync();
|
||||
var errorResponse = await response.Content.ReadFromJsonAsync<Web3ProxyResponse>(_jsonOptions);
|
||||
|
||||
|
||||
if (errorResponse != null && !errorResponse.Success && !string.IsNullOrEmpty(errorResponse.Error))
|
||||
{
|
||||
// Handle the standard Web3Proxy error format
|
||||
throw new Web3ProxyException(errorResponse.Error);
|
||||
}
|
||||
|
||||
|
||||
// Fallback for other error formats
|
||||
try
|
||||
try
|
||||
{
|
||||
// Try to parse as structured error if it doesn't match the simple format
|
||||
var structuredErrorResponse = await response.Content.ReadFromJsonAsync<Web3ProxyErrorResponse>(_jsonOptions);
|
||||
|
||||
var structuredErrorResponse =
|
||||
await response.Content.ReadFromJsonAsync<Web3ProxyErrorResponse>(_jsonOptions);
|
||||
|
||||
if (structuredErrorResponse?.ErrorDetails != null)
|
||||
{
|
||||
structuredErrorResponse.ErrorDetails.StatusCode = statusCode;
|
||||
|
||||
Reference in New Issue
Block a user