public async Task <IActionResult> GetWallets() { var wallets = await _clientAccountService.GetWalletsByClientIdAsync(_requestContext.ClientId); if (wallets == null) { return(NotFound()); } var clientKeys = await _hftInternalService.GetKeysAsync(_requestContext.ClientId); return(Ok(wallets.Select(wallet => new WalletModel { Id = wallet.Id, Name = wallet.Name, Type = wallet.Type, Description = wallet.Description, ApiKey = clientKeys.FirstOrDefault(x => x.Wallet == wallet.Id)?.Key }))); }
public async Task <IActionResult> DeleteWallet(string id) { // checking if wallet exists and user owns the specified wallet var wallet = await GetClientWallet(id); if (wallet == null) { return(NotFound()); } // todo: always delete wallet through ClientAccountService; HFT internal service should process deleted messages by itself var apiKey = (await _hftInternalService.GetKeysAsync(_requestContext.ClientId))?.FirstOrDefault(x => x.Wallet == id); if (apiKey != null) { await _hftInternalService.DeleteKeyAsync(apiKey.Key); } await _clientAccountService.DeleteWalletAsync(id); return(Ok()); }
public async Task <IActionResult> RegenerateKey(string walletId) { var clientKeys = await _hftInternalService.GetKeysAsync(_requestContext.ClientId); var existingApiKey = clientKeys.FirstOrDefault(x => x.Wallet == walletId); if (existingApiKey != null) { var apiKey = await _hftInternalService.RegenerateKeyAsync(new RegenerateKeyRequest { ClientId = _requestContext.ClientId, WalletId = existingApiKey.Wallet }); return(Ok(new CreateApiKeyResponse { ApiKey = apiKey.Key, WalletId = apiKey.Wallet })); } return(NotFound()); }