Skip to content

Commit 2ee2885

Browse files
committed
add contract info to transaction trigger
1 parent 45e02ea commit 2ee2885

2 files changed

Lines changed: 34 additions & 33 deletions

File tree

‎src/main/java/org/tron/common/logsfilter/capsule/TransactionLogTriggerCapsule.java‎

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
import com.google.protobuf.ByteString;
66
import lombok.Getter;
77
import lombok.Setter;
8+
import org.spongycastle.util.encoders.Hex;
89
import org.tron.common.logsfilter.EventPluginLoader;
910
import org.tron.common.logsfilter.trigger.TransactionLogTrigger;
1011
import org.tron.common.runtime.vm.program.ProgramResult;
1112
import org.tron.common.utils.TypeConversion;
1213
import org.tron.core.capsule.BlockCapsule;
1314
import org.tron.core.capsule.TransactionCapsule;
1415
import org.tron.core.db.TransactionTrace;
16+
import org.tron.protos.Protocol;
1517

1618
public class TransactionLogTriggerCapsule extends TriggerCapsule {
1719

@@ -30,6 +32,31 @@ public TransactionLogTriggerCapsule(TransactionCapsule trxCasule, BlockCapsule b
3032

3133
TransactionTrace trxTrace = trxCasule.getTrxTrace();
3234

35+
// contract result
36+
if (Objects.nonNull(trxCasule.getContractRet())){
37+
transactionLogTrigger.setContractResult(trxCasule.getContractRet().toString());
38+
}
39+
40+
if (Objects.nonNull(trxCasule.getInstance().getRawData())){
41+
// feelimit
42+
transactionLogTrigger.setFeeLimit(trxCasule.getInstance().getRawData().getFeeLimit());
43+
44+
Protocol.Transaction.Contract contract = trxCasule.getInstance().getRawData().getContract(0);
45+
// contract type
46+
if (Objects.nonNull(contract)){
47+
Protocol.Transaction.Contract.ContractType contractType = contract.getType();
48+
if (Objects.nonNull(contractType)){
49+
transactionLogTrigger.setContractType(contractType.toString());
50+
}
51+
52+
if (Objects.nonNull(contract.getContractName())){
53+
transactionLogTrigger.setContractName(Hex.toHexString(contract.getContractName().toByteArray()));
54+
}
55+
56+
transactionLogTrigger.setCallValue(TransactionCapsule.getCallValue(contract));
57+
}
58+
}
59+
3360
// receipt
3461
if (Objects.nonNull(trxTrace) && Objects.nonNull(trxTrace.getReceipt())) {
3562
transactionLogTrigger.setEnergyFee(trxTrace.getReceipt().getEnergyFee());
@@ -54,17 +81,6 @@ public TransactionLogTriggerCapsule(TransactionCapsule trxCasule, BlockCapsule b
5481
transactionLogTrigger.setContractAddress(TypeConversion.bytesToHexString(contractAddress.toByteArray()));
5582
}
5683

57-
if (Objects.nonNull(programResult.getRet())){
58-
transactionLogTrigger.setContractFee(programResult.getRet().getFee());
59-
transactionLogTrigger.setUnfreezeAmount(programResult.getRet().getUnfreezeAmount());
60-
transactionLogTrigger.setAssetIssueID(programResult.getRet().getAssetIssueID());
61-
transactionLogTrigger.setExchangeId(programResult.getRet().getExchangeId());
62-
transactionLogTrigger.setWithdrawAmount(programResult.getRet().getWithdrawAmount());
63-
transactionLogTrigger.setExchangeReceivedAmount(programResult.getRet().getExchangeReceivedAmount());
64-
transactionLogTrigger.setExchangeInjectAnotherAmount(programResult.getRet().getExchangeInjectAnotherAmount());
65-
transactionLogTrigger.setExchangeWithdrawAnotherAmount(programResult.getRet().getExchangeWithdrawAnotherAmount());
66-
}
67-
6884
// internal transaction
6985
transactionLogTrigger.setInternalTransactionPojoList(programResult.getInternalTransactions());
7086
}

‎src/main/java/org/tron/common/logsfilter/trigger/TransactionLogTrigger.java‎

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -49,46 +49,31 @@ public void setTimeStamp(long ts) {
4949
@Setter
5050
private long netFee;
5151

52-
// program result
53-
@Getter
54-
@Setter
55-
private String contractResult;
56-
57-
@Getter
58-
@Setter
59-
private String contractAddress;
52+
// contract
6053

6154
@Getter
6255
@Setter
63-
private long contractFee;
56+
private String contractName;
6457

6558
@Getter
6659
@Setter
67-
private long unfreezeAmount;
68-
69-
@Getter
70-
@Setter
71-
private String assetIssueID;
72-
73-
@Getter
74-
@Setter
75-
private long exchangeId;
60+
private String contractResult;
7661

7762
@Getter
7863
@Setter
79-
private long withdrawAmount;
64+
private String contractAddress;
8065

8166
@Getter
8267
@Setter
83-
private long exchangeReceivedAmount;
68+
private String contractType;
8469

8570
@Getter
8671
@Setter
87-
private long exchangeInjectAnotherAmount;
72+
private long feeLimit;
8873

8974
@Getter
9075
@Setter
91-
private long exchangeWithdrawAnotherAmount;
76+
private long callValue;
9277

9378
// internal transaction
9479
@Getter

0 commit comments

Comments
 (0)