Add initAddress api
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using Managing.Application.Abstractions;
|
||||
using Managing.Application.Abstractions.Repositories;
|
||||
using Managing.Application.Abstractions.Repositories;
|
||||
using Managing.Application.Abstractions.Services;
|
||||
using Managing.Domain.Accounts;
|
||||
using Managing.Domain.Scenarios;
|
||||
@@ -7,6 +6,7 @@ using Managing.Domain.Shared.Helpers;
|
||||
using Managing.Domain.Statistics;
|
||||
using Managing.Domain.Strategies;
|
||||
using Managing.Domain.Trades;
|
||||
using Managing.Infrastructure.Evm.Models.Privy;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using static Managing.Common.Enums;
|
||||
|
||||
@@ -20,6 +20,7 @@ public class TradingService : ITradingService
|
||||
private readonly ICacheService _cacheService;
|
||||
private readonly IMessengerService _messengerService;
|
||||
private readonly IStatisticRepository _statisticRepository;
|
||||
private readonly IEvmManager _evmManager;
|
||||
private readonly ILogger<TradingService> _logger;
|
||||
|
||||
public TradingService(
|
||||
@@ -29,7 +30,8 @@ public class TradingService : ITradingService
|
||||
IAccountService accountService,
|
||||
ICacheService cacheService,
|
||||
IMessengerService messengerService,
|
||||
IStatisticRepository statisticRepository)
|
||||
IStatisticRepository statisticRepository,
|
||||
IEvmManager evmManager)
|
||||
{
|
||||
_tradingRepository = tradingRepository;
|
||||
_exchangeService = exchangeService;
|
||||
@@ -38,6 +40,7 @@ public class TradingService : ITradingService
|
||||
_cacheService = cacheService;
|
||||
_messengerService = messengerService;
|
||||
_statisticRepository = statisticRepository;
|
||||
_evmManager = evmManager;
|
||||
}
|
||||
|
||||
public void DeleteScenario(string name)
|
||||
@@ -374,4 +377,23 @@ public class TradingService : ITradingService
|
||||
public List<Trade> Trades { get; set; }
|
||||
public List<string> PositionIdentifiers { get; set; }
|
||||
}
|
||||
|
||||
public async Task<PrivyInitAddressResponse> InitPrivyWallet(string publicAddress)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(publicAddress))
|
||||
{
|
||||
_logger.LogWarning("Attempted to initialize Privy wallet with null or empty public address");
|
||||
return new PrivyInitAddressResponse { Success = false, Error = "Public address cannot be null or empty" };
|
||||
}
|
||||
|
||||
return await _evmManager.InitAddress(publicAddress);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error initializing Privy wallet for address {PublicAddress}", publicAddress);
|
||||
return new PrivyInitAddressResponse { Success = false, Error = ex.Message };
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user