Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@
import org.tron.protos.Protocol.Transaction.Contract.ContractType;
import org.tron.protos.Protocol.TransactionInfo;
import org.tron.protos.contract.AssetIssueContractOuterClass.TransferAssetContract;
import org.tron.protos.contract.BalanceContract.CancelAllUnfreezeV2Contract;
import org.tron.protos.contract.BalanceContract.DelegateResourceContract;
import org.tron.protos.contract.BalanceContract.FreezeBalanceV2Contract;
import org.tron.protos.contract.BalanceContract.TransferContract;
import org.tron.protos.contract.BalanceContract.UnDelegateResourceContract;
import org.tron.protos.contract.BalanceContract.UnfreezeBalanceContract;
import org.tron.protos.contract.BalanceContract.UnfreezeBalanceV2Contract;
import org.tron.protos.contract.BalanceContract.WithdrawExpireUnfreezeContract;
import org.tron.protos.contract.SmartContractOuterClass.CreateSmartContract;
import org.tron.protos.contract.SmartContractOuterClass.TriggerSmartContract;

Expand Down Expand Up @@ -156,6 +163,100 @@ public TransactionLogTriggerCapsule(TransactionCapsule trxCapsule, BlockCapsule
StringUtil.encode58Check(createSmartContract.getOwnerAddress().toByteArray()));
}
break;
case UnfreezeBalanceContract:
UnfreezeBalanceContract unfreezeBalanceContract = contractParameter
.unpack(UnfreezeBalanceContract.class);

if (Objects.nonNull(unfreezeBalanceContract)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

contract cannot be null.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I get it

if (Objects.nonNull(unfreezeBalanceContract.getOwnerAddress())) {
transactionLogTrigger.setFromAddress(StringUtil
.encode58Check(unfreezeBalanceContract.getOwnerAddress().toByteArray()));
}
if (Objects.nonNull(unfreezeBalanceContract.getReceiverAddress())) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The frequency of these if statements is too high, you can encapsulate a function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, Ok, I encapsulate the code

transactionLogTrigger.setToAddress(StringUtil
.encode58Check(unfreezeBalanceContract.getReceiverAddress().toByteArray()));
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be added?

 transactionLogTrigger.setAssetName("trx");
           transactionLogTrigger.setAssetAmount(transactionInfo.getUnfreezeAmount());

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I get it

break;
case FreezeBalanceV2Contract:
FreezeBalanceV2Contract freezeBalanceV2Contract = contractParameter
.unpack(FreezeBalanceV2Contract.class);

if (Objects.nonNull(freezeBalanceV2Contract)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

contract cannot be null.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I get it

if (Objects.nonNull(freezeBalanceV2Contract.getOwnerAddress())) {
transactionLogTrigger.setFromAddress(StringUtil
.encode58Check(freezeBalanceV2Contract.getOwnerAddress().toByteArray()));
}
transactionLogTrigger.setAssetAmount(freezeBalanceV2Contract.getFrozenBalance());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

transactionLogTrigger.setAssetName("trx"); ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK,I get it.

}
break;
case UnfreezeBalanceV2Contract:
UnfreezeBalanceV2Contract unfreezeBalanceV2Contract = contractParameter
.unpack(UnfreezeBalanceV2Contract.class);

if (Objects.nonNull(unfreezeBalanceV2Contract)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

contract cannot be null.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I get it

if (Objects.nonNull(unfreezeBalanceV2Contract.getOwnerAddress())) {
transactionLogTrigger.setFromAddress(StringUtil
.encode58Check(unfreezeBalanceV2Contract.getOwnerAddress().toByteArray()));
}
transactionLogTrigger.setAssetAmount(
unfreezeBalanceV2Contract.getUnfreezeBalance());
}
break;
case WithdrawExpireUnfreezeContract:
WithdrawExpireUnfreezeContract withdrawExpireUnfreezeContract = contractParameter
.unpack(WithdrawExpireUnfreezeContract.class);

if (Objects.nonNull(withdrawExpireUnfreezeContract)
&& Objects.nonNull(withdrawExpireUnfreezeContract.getOwnerAddress())) {
transactionLogTrigger.setFromAddress(StringUtil.encode58Check(
withdrawExpireUnfreezeContract.getOwnerAddress().toByteArray()));
}
break;
case DelegateResourceContract:
DelegateResourceContract delegateResourceContract = contractParameter
.unpack(DelegateResourceContract.class);

if (Objects.nonNull(delegateResourceContract)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

contract cannot be null.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I get it

if (Objects.nonNull(delegateResourceContract.getOwnerAddress())) {
transactionLogTrigger.setFromAddress(StringUtil
.encode58Check(delegateResourceContract.getOwnerAddress().toByteArray()));
}
if (Objects.nonNull(delegateResourceContract.getReceiverAddress())) {
transactionLogTrigger.setToAddress(StringUtil
.encode58Check(delegateResourceContract.getReceiverAddress().toByteArray()));
}
transactionLogTrigger.setAssetAmount(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

transactionLogTrigger.setAssetName("trx");?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK,I get it.

delegateResourceContract.getBalance());
}
break;
case UnDelegateResourceContract:
UnDelegateResourceContract unDelegateResourceContract = contractParameter
.unpack(UnDelegateResourceContract.class);

if (Objects.nonNull(unDelegateResourceContract)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

contract cannot be null.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I get it

if (Objects.nonNull(unDelegateResourceContract.getOwnerAddress())) {
transactionLogTrigger.setFromAddress(StringUtil
.encode58Check(unDelegateResourceContract.getOwnerAddress().toByteArray()));
}
if (Objects.nonNull(unDelegateResourceContract.getReceiverAddress())) {
transactionLogTrigger.setToAddress(StringUtil.encode58Check(
unDelegateResourceContract.getReceiverAddress().toByteArray()));
}
transactionLogTrigger.setAssetAmount(
unDelegateResourceContract.getBalance());
}
break;
case CancelAllUnfreezeV2Contract:
CancelAllUnfreezeV2Contract cancelAllUnfreezeV2Contract = contractParameter
.unpack(CancelAllUnfreezeV2Contract.class);

if (Objects.nonNull(cancelAllUnfreezeV2Contract)
&& Objects.nonNull(cancelAllUnfreezeV2Contract.getOwnerAddress())) {
transactionLogTrigger.setFromAddress(StringUtil
.encode58Check(cancelAllUnfreezeV2Contract.getOwnerAddress().toByteArray()));
}
break;
default:
break;
}
Expand Down