Exemple #1
0
        public async Task <IReadOnlyList <MerchantWalletBalanceLine> > GetBalancesAsync(string merchantId)
        {
            var balances = new List <MerchantWalletBalanceLine>();

            IReadOnlyList <IMerchantWallet> wallets = await _merchantWalletRespository.GetByMerchantAsync(merchantId);

            foreach (IMerchantWallet merchantWallet in wallets)
            {
                IBlockchainApiClient blockchainClient = _blockchainClientProvider.Get(merchantWallet.Network);

                IReadOnlyList <BlockchainBalanceResult> walletBalance =
                    await blockchainClient.GetBalancesAsync(merchantWallet.WalletAddress);

                balances.AddRange(walletBalance.Select(x => new MerchantWalletBalanceLine
                {
                    Id      = merchantWallet.Id,
                    AssetId = x.AssetId,
                    Balance = x.Balance
                }));
            }

            return(balances);
        }
 public static async Task <decimal> GetBalanceAsync(this IBlockchainApiClient src, string address, string assetId)
 {
     return((await src.GetBalancesAsync(address)).For(assetId)?.Balance ?? 0);
 }