Fix db and fix endpoints

This commit is contained in:
2025-08-05 22:30:18 +07:00
parent 2dcbcc3ef2
commit 36529ae403
36 changed files with 5073 additions and 245 deletions

View File

@@ -35,52 +35,52 @@ public class AccountService : IAccountService
_userRepository = userRepository;
}
public async Task<Account> CreateAccount(User user, Account request)
public async Task<Account> CreateAccount(User user, Account account)
{
var account = await _accountRepository.GetAccountByNameAsync(request.Name);
var a = await _accountRepository.GetAccountByNameAsync(account.Name);
if (account != null)
if (a != null)
{
throw new Exception($"Account {request.Name} alreary exist");
throw new Exception($"Account {account.Name} alreary exist");
}
else
{
request.User = user;
account.User = user;
if (request.Exchange == TradingExchanges.Evm
&& request.Type == AccountType.Trader)
if (account.Exchange == TradingExchanges.Evm
&& account.Type == AccountType.Trader)
{
var keys = _evmManager.GenerateAddress();
request.Key = keys.Key;
request.Secret = keys.Secret;
account.Key = keys.Key;
account.Secret = keys.Secret;
}
else if (request.Exchange == TradingExchanges.Evm
&& request.Type == AccountType.Privy)
else if (account.Exchange == TradingExchanges.Evm
&& account.Type == AccountType.Privy)
{
if (string.IsNullOrEmpty(request.Key))
if (string.IsNullOrEmpty(account.Key))
{
// No key provided, create new privy embedded wallet.
// TODO : Fix it to create privy wallet
var privyClient = await _evmManager.CreatePrivyWallet();
request.Key = privyClient.Address;
request.Secret = privyClient.Id;
account.Key = privyClient.Address;
account.Secret = privyClient.Id;
}
else
{
request.Key = request.Key; // Address
request.Secret = request.Secret; // Privy wallet id
account.Key = account.Key; // Address
account.Secret = account.Secret; // Privy wallet id
}
}
else
{
request.Key = request.Key;
request.Secret = request.Secret;
account.Key = account.Key;
account.Secret = account.Secret;
}
await _accountRepository.InsertAccountAsync(request);
await _accountRepository.InsertAccountAsync(account);
}
return request;
return account;
}
public bool DeleteAccount(User user, string name)