Search in sources :

Example 31 with Log

use of org.aion.types.Log in project aion by aionnetwork.

the class LogUtility method decodeLog.

public static Log decodeLog(SharedRLPList sharedRLPList) {
    Objects.requireNonNull(sharedRLPList);
    // Can be null
    byte[] address = sharedRLPList.get(0).getRLPData();
    // Can be null
    byte[] data = sharedRLPList.get(2).getRLPData();
    SharedRLPList encodedTopics = (SharedRLPList) sharedRLPList.get(1);
    List<byte[]> topics = new ArrayList<>();
    for (RLPElement topic1 : encodedTopics) {
        byte[] topic = topic1.getRLPData();
        topics.add(topic);
    }
    Log ret;
    if (address != null && data != null) {
        if (topics.isEmpty()) {
            ret = Log.dataOnly(address, data);
        } else {
            ret = Log.topicsAndData(address, topics, data);
        }
    } else {
        throw new IllegalArgumentException("Unable to decode Log because of null " + (address == null ? "address" : "data"));
    }
    return ret;
}
Also used : Log(org.aion.types.Log) RLPElement(org.aion.rlp.RLPElement) ArrayList(java.util.ArrayList) SharedRLPList(org.aion.rlp.SharedRLPList)

Aggregations

Log (org.aion.types.Log)31 AionAddress (org.aion.types.AionAddress)21 Test (org.junit.Test)18 BigInteger (java.math.BigInteger)14 AionTransaction (org.aion.base.AionTransaction)11 AionTxReceipt (org.aion.base.AionTxReceipt)8 InternalTransaction (org.aion.types.InternalTransaction)8 ArrayList (java.util.ArrayList)6 AionTxExecSummary (org.aion.base.AionTxExecSummary)5 PrecompiledTransactionResult (org.aion.precompiled.PrecompiledTransactionResult)5 PrecompiledTransactionContext (org.aion.precompiled.type.PrecompiledTransactionContext)5 BlockContext (org.aion.zero.impl.types.BlockContext)5 RepositoryCache (org.aion.base.db.RepositoryCache)4 BridgeTransfer (org.aion.precompiled.contracts.ATB.BridgeTransfer)4 AionBlockSummary (org.aion.zero.impl.types.AionBlockSummary)4 AionTxInfo (org.aion.zero.impl.types.AionTxInfo)4 JSONArray (org.json.JSONArray)4 List (java.util.List)3 ECKey (org.aion.crypto.ECKey)3 DataWord (org.aion.util.types.DataWord)3