Skip to content

Commit

Permalink
add transaction data
Browse files Browse the repository at this point in the history
  • Loading branch information
wubinTron committed Jun 3, 2020
1 parent 61c07a2 commit bdfcd19
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ public class TransactionLogTrigger extends Trigger {
@Getter
@Setter
private List<InternalTransactionPojo> internalTrananctionList;
@Getter
@Setter
private String data;

public TransactionLogTrigger() {
setTriggerName(Trigger.TRANSACTION_TRIGGER_NAME);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package org.tron.common.logsfilter.capsule;

import static org.tron.protos.Protocol.Transaction.Contract.ContractType.CreateSmartContract;
import static org.tron.protos.Protocol.Transaction.Contract.ContractType.TransferAssetContract;
import static org.tron.protos.Protocol.Transaction.Contract.ContractType.TransferContract;
import static org.tron.protos.Protocol.Transaction.Contract.ContractType.TriggerSmartContract;

import com.google.protobuf.Any;
import com.google.protobuf.ByteString;
Expand All @@ -18,13 +20,16 @@
import org.tron.common.runtime.InternalTransaction;
import org.tron.common.runtime.ProgramResult;
import org.tron.common.utils.StringUtil;
import org.tron.core.Wallet;
import org.tron.common.utils.ByteArray;
import org.tron.core.capsule.BlockCapsule;
import org.tron.core.capsule.TransactionCapsule;
import org.tron.core.db.TransactionTrace;
import org.tron.protos.Protocol;
import org.tron.protos.contract.AssetIssueContractOuterClass.TransferAssetContract;
import org.tron.protos.contract.BalanceContract.TransferContract;
import org.tron.protos.contract.SmartContractOuterClass;
import org.tron.protos.contract.SmartContractOuterClass.CreateSmartContract;
import org.tron.protos.contract.SmartContractOuterClass.TriggerSmartContract;

@Slf4j
public class TransactionLogTriggerCapsule extends TriggerCapsule {
Expand Down Expand Up @@ -108,6 +113,17 @@ public TransactionLogTriggerCapsule(TransactionCapsule trxCasule, BlockCapsule b
}
transactionLogTrigger.setAssetAmount(contractTransfer.getAmount());
}
} else if (contract.getType() == CreateSmartContract) {
CreateSmartContract contractTransfer = contractParameter
.unpack(CreateSmartContract.class);
transactionLogTrigger.setData(
ByteArray.toHexString(contractTransfer
.getNewContract().getBytecode().toByteArray()));
} else if (contract.getType() == TriggerSmartContract) {
SmartContractOuterClass.TriggerSmartContract triggerSmart = contractParameter
.unpack(TriggerSmartContract.class);
transactionLogTrigger.setData(ByteArray.toHexString(triggerSmart
.getData().toByteArray()));
}
} catch (Exception e) {
logger.error("failed to load transferAssetContract, error'{}'", e);
Expand Down

0 comments on commit bdfcd19

Please sign in to comment.