GMX v2 - Trading (#7)
* Move PrivateKeys.cs * Update gitignore * Update gitignore * updt * Extract GmxServiceTests.cs * Refact * update todo * Update code * Fix hashdata * Replace static token hashed datas * Set allowance * Add get orders * Add get orders tests * Add ignore * add close orders * revert * Add get gas limit * Start increasePosition. Todo: Finish GetExecutionFee and estimateGas * little refact * Update gitignore * Fix namespaces and clean repo * Add tests samples * Add execution fee * Add increase position * Handle backtest on the frontend * Add tests * Update increase * Test increase * fix increase * Fix size * Start get position * Update get positions * Fix get position * Update rpc and trade mappers * Finish close position * Fix leverage
This commit is contained in:
24
src/Managing.Core/FileHelpers.cs
Normal file
24
src/Managing.Core/FileHelpers.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System.Reflection;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Managing.Core;
|
||||
|
||||
public static class FileHelpers
|
||||
{
|
||||
public static T ReadJson<T>(string path)
|
||||
{
|
||||
string assemblyLocation = Assembly.GetExecutingAssembly().Location;
|
||||
|
||||
string assemblyDirectory = Path.GetDirectoryName(assemblyLocation);
|
||||
|
||||
if (assemblyDirectory != null)
|
||||
{
|
||||
var pathToReadFrom = Path.Combine(assemblyDirectory, path);
|
||||
// Reads the content of the JSON file.
|
||||
var json = File.ReadAllText(pathToReadFrom);
|
||||
return JsonSerializer.Deserialize<T>(json);
|
||||
}
|
||||
|
||||
return default;
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,18 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Net;
|
||||
using System.Net;
|
||||
using System.Text.Json;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace Managing.Api.WorkersExceptions;
|
||||
namespace Managing.Core.Middleawares;
|
||||
|
||||
public class GlobalErrorHandlingMiddleware
|
||||
{
|
||||
private readonly RequestDelegate _next;
|
||||
|
||||
public GlobalErrorHandlingMiddleware(RequestDelegate next)
|
||||
{
|
||||
_next = next;
|
||||
}
|
||||
|
||||
public async Task Invoke(HttpContext context)
|
||||
{
|
||||
try
|
||||
@@ -22,6 +24,7 @@ public class GlobalErrorHandlingMiddleware
|
||||
await HandleExceptionAsync(context, ex);
|
||||
}
|
||||
}
|
||||
|
||||
private static Task HandleExceptionAsync(HttpContext context, Exception exception)
|
||||
{
|
||||
HttpStatusCode status;
|
||||
@@ -60,4 +63,4 @@ public class GlobalErrorHandlingMiddleware
|
||||
context.Response.StatusCode = (int)status;
|
||||
return context.Response.WriteAsync(exceptionResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user