public GetWalletsResponse GetWallets(Guid messageId)
 {
     try {
         var data = HostRoot.Current.WalletSet.GetWallets();
         return(new GetWalletsResponse(data));
     }
     catch (Exception e) {
         Global.Logger.ErrorDebugLine(e.Message, e);
         return(GetWalletsResponse.ServerError(messageId, e.Message));
     }
 }
        public async Task <GetWalletsResponse> GetWallets()
        {
            var responce = new GetWalletsResponse();

            var clientId = this.ClientId();

            var balaces = (await _balancesClient.GetClientBalances(clientId)).ToDictionary(e => e.AssetId, e => e);

            responce.Wallets = _settings.BalanceAssets.Select(e => new WalletBalanceModel()
            {
                Asset    = e,
                Balance  = balaces.ContainsKey(e) ? balaces[e].Balance : 0,
                Reserved = balaces.ContainsKey(e) ? balaces[e].Reserved : 0
            }).ToList();

            return(responce);
        }
示例#3
0
        public async Task <IReadOnlyList <Balance> > GetBalancesAsync()
        {
            try
            {
                GetWalletsResponse response = await _client.GetWalletBalancesAsync();

                return(response.Wallets
                       .GroupBy(o => o.Asset)
                       .Select(o =>
                               new Balance(Name, TryGetAssetName(o.Key), o.Sum(e => e.Balance), o.Sum(e => e.Reserved)))
                       .ToList());
            }
            catch (Exception exception)
            {
                throw new Exception("An error occurred while getting balances", exception);
            }
        }
            public GetWalletsResponse GetWallets()
            {
                Guid messageId = Guid.NewGuid();

                try {
                    using (var service = CreateService()) {
                        return(service.GetWallets(messageId));
                    }
                }
                catch (CommunicationException e) {
                    Global.DebugLine(e.Message, ConsoleColor.Red);
                    return(GetWalletsResponse.ClientError(messageId, e.Message));
                }
                catch (Exception e) {
                    Global.Logger.Error(e.Message, e);
                    return(GetWalletsResponse.ClientError(messageId, e.Message));
                }
            }