Skip to content

Conversation

@CarlChaoCarl
Copy link
Contributor

@CarlChaoCarl CarlChaoCarl commented Aug 14, 2023

What does this PR do?
optimize address parsing of stake interfaces, close #5411

Why are these changes required?

This PR has been tested by:

  • Unit Tests
  • Manual Testing

Follow up

Extra details

@CarlChaoCarl CarlChaoCarl changed the title feat(mechanism): optimize new transaction address parsing feat(mechanism): optimize address parsing of stake-related interfaces Aug 15, 2023
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

@CarlChaoCarl CarlChaoCarl changed the title feat(mechanism): optimize address parsing of stake-related interfaces feat(mechanism): optimize address parsing of stake interfaces Aug 15, 2023
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.

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.

if (Objects.nonNull(withdrawExpireUnfreezeContract)) {
transactionLogTrigger.setFromAddress(StringUtil.encode58Check(
withdrawExpireUnfreezeContract.getOwnerAddress().toByteArray()));
transactionLogTrigger.setAssetAmount(transactionInfo.getWithdrawExpireAmount());
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

WithdrawExpireUnfreezeContract withdrawExpireUnfreezeContract = contractParameter
.unpack(WithdrawExpireUnfreezeContract.class);

if (Objects.nonNull(withdrawExpireUnfreezeContract)) {
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

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

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

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

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

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

CancelAllUnfreezeV2Contract cancelAllUnfreezeV2Contract = contractParameter
.unpack(CancelAllUnfreezeV2Contract.class);

if (Objects.nonNull(cancelAllUnfreezeV2Contract)) {
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 (!ByteString.EMPTY.equals(unfreezeBalanceContract.getReceiverAddress())) {
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

@codecov-commenter
Copy link

codecov-commenter commented Aug 29, 2023

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 85.48387% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.41%. Comparing base (ad728fa) to head (eaaa323).
⚠️ Report is 527 commits behind head on develop.

Files with missing lines Patch % Lines
...gsfilter/capsule/TransactionLogTriggerCapsule.java 88.33% 6 Missing and 1 partial ⚠️
...mmon/logsfilter/trigger/TransactionLogTrigger.java 0.00% 2 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #5419      +/-   ##
=============================================
+ Coverage      61.35%   61.41%   +0.05%     
- Complexity      9348     9351       +3     
=============================================
  Files            846      846              
  Lines          50211    50273      +62     
  Branches        5583     5584       +1     
=============================================
+ Hits           30805    30873      +68     
+ Misses         17002    16981      -21     
- Partials        2404     2419      +15     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@halibobo1205 halibobo1205 added this to the GreatVoyage-v4.7.3 milestone Aug 30, 2023
@halibobo1205 halibobo1205 merged commit d6ff733 into tronprotocol:develop Sep 4, 2023
@halibobo1205 halibobo1205 added topic:event subscribe transaction trigger, block trigger, contract event, contract log status:delivery test labels Oct 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic:event subscribe transaction trigger, block trigger, contract event, contract log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Optimize address parsing of stake-related interfaces

6 participants