Ejemplo n.º 1
0
    /// <summary>
    /// Creates a TransactionInfo object from a token transaction json object.
    /// </summary>
    /// <param name="tokenTransaction"> The token json to convert. </param>
    /// <param name="userWalletManager"> The active UserWalletManager. </param>
    /// <returns> The TransactionInfo created from the json. </returns>
    public static TransactionInfo CreateTokenTransaction(TokenTransactionJson tokenTransaction, UserWalletManager userWalletManager)
    {
        var topics        = tokenTransaction.topics;
        var tokenSender   = topics[1].Remove(2, 24);
        var tokenReceiver = topics[2].Remove(2, 24);

        if (tokenSender == tokenReceiver)
        {
            return(null);
        }

        return(new TransactionInfo(GetTransactionType(tokenSender.EqualsIgnoreCase(userWalletManager.GetWalletAddress())),
                                   tokenSender,
                                   tokenReceiver,
                                   tokenTransaction.address,
                                   tokenTransaction.transactionHash,
                                   tokenTransaction.data.ConvertFromHex(),
                                   tokenTransaction.gasPrice.ConvertFromHex(),
                                   (int)tokenTransaction.gasUsed.ConvertFromHex(),
                                   (long)tokenTransaction.timeStamp.ConvertFromHex()));
    }
Ejemplo n.º 2
0
 /// <summary>
 /// Checks the details of each purpose transaction sent to the hodl contract.
 /// </summary>
 /// <param name="tokenTransactionJson"> The json of the token transaction. </param>
 private void GetTransactionInputData(TokenTransactionJson tokenTransactionJson)
 {
     TransactionUtils.GetTransactionDetails(tokenTransactionJson.transactionHash)
     .OnSuccess(tx => GetItemFromHodlerContract(SolidityUtils.ExtractFunctionParameters(tx.Input), tokenTransactionJson.timeStamp.ConvertFromHex()));
 }