public async Task <IReadOnlyDictionary <BlockchainAsset, decimal> > GetBalancesAsync(string address, DateTime at) { var indexResp = await(_baseUrl.AppendPathSegment("slr/address.dws") + $"?{address}.htm") .GetStringAsync(); var id = ChainIdDeserializer.GetChainid(indexResp); var txsResp = await _baseUrl.AppendPathSegment("explorer/address.summary.dws").SetQueryParams ( new { coin = "slr", id } ) .GetStringAsync(); if (txsResp.Contains("busy")) { throw new ArgumentException("Request failed due rate limiter"); } var history = ChainIdDeserializer.DeserializeTransactionsResp(txsResp); var result = 0m; foreach (var entry in history.Where(p => p.date <= at)) { result += entry.amount; } return(new Dictionary <BlockchainAsset, decimal> { { _baseAsset, result } }); }
public async Task CanGetChainIdFromHtml() { var respExample = await File.ReadAllTextAsync("SolarCoinIndex.html"); Assert.Equal(140227, ChainIdDeserializer.GetChainid(respExample)); }