public override async Task <EmptyResponse> SetBaseAsset(BaseAssetUpdateRequest request, ServerCallContext context) { var result = new EmptyResponse(); try { var token = context.GetBearerToken(); await _walletApiV2Client.SetBaseAssetAsync(new BaseAssetUpdateModel { BaseAssetId = request.BaseAssetId }, token); return(result); } catch (ApiExceptionV2 ex) { if (ex.StatusCode == 404) { result.Error = new ErrorResponseBody { Code = ErrorCode.InvalidField, Message = "Asset not found" }; result.Error.Fields.Add(nameof(request.BaseAssetId), "Asset not found"); return(result); } throw; } }
public override async Task <EmptyResponseV2> SetBaseAsset(BaseAssetUpdateRequest request, ServerCallContext context) { var session = SessionFromContext(context); var assets = await _marketDataService.GetAssetsByTenant(session.TenantId); if (assets.All(a => a.Symbol != request.BaseAssetId || a.IsDisabled)) { return(new EmptyResponseV2() { Error = new ErrorV2() { Error = ErrorModelCode.AssetNotFound.ToString(), Message = ErrorMessages.AssetNotFound } }); } await _accountManager.SetBaseAssetToClientProfile(session.TenantId, session.ClientId, request.BaseAssetId); return(new EmptyResponseV2()); }