Exemplo n.º 1
0
 /// <summary>
 /// Gets a list of valid transactions.
 /// </summary>
 /// <typeparam name="T"> The type of the transaction json object. Either EtherTransactionJson or TokenTransactionJson. </typeparam>
 /// <param name="transactionsJson"> The json object which holds all the transaction data. </param>
 /// <param name="isValidTransaction"> Func to call to determine if the current transaction is valid or not. </param>
 /// <param name="getTransaction"> Action called to get the TransactionInfo object from the json. </param>
 /// <returns> The array of transactions which are valid based on the Func criteria. </returns>
 private TransactionInfo[] GetValidTransactions <T>(EtherscanAPIJson <T> transactionsJson, Func <T, bool> isValidTransaction, Func <T, TransactionInfo> getTransaction)
 {
     return(transactionsJson.result
            .Where(isValidTransaction)
            .Select(getTransaction)
            .Where(tx => tx != null)
            .ToArray());
 }
Exemplo n.º 2
0
    /// <summary>
    /// Reads the json data from the transaction list received.
    /// </summary>
    /// <typeparam name="T"> The type of the transaction json object. Either EtherTransactionJson or TokenTransactionJson. </typeparam>
    /// <param name="transactionList"> The transaction data to process. </param>
    /// <param name="assetAddress"> The address of this asset. </param>
    /// <param name="isValidTransaction"> Func to call to determine if the current transaction is valid or not. </param>
    /// <param name="getTransaction"> Action called to get the TransactionInfo object from the json. </param>
    private void ReadJsonData <T>(string transactionList, string assetAddress, Func <T, bool> isValidTransaction, Func <T, TransactionInfo> getTransaction)
    {
        EtherscanAPIJson <T> transactionsJson = JsonUtils.Deserialize <EtherscanAPIJson <T> >(transactionList);

        if (transactionsJson == null)
        {
            return;
        }

        AddTransactions(assetAddress, GetValidTransactions(transactionsJson, isValidTransaction, getTransaction));
    }