feat(mirror): add account mirror endpoints#122
Conversation
Signed-off-by: Alejandro <26930485+alejandroGM0@users.noreply.github.com>
9302948 to
aa5a74e
Compare
manishdait
left a comment
There was a problem hiding this comment.
@alejandroGM0, Thanks for the PR added some requested changes. Also add the e2e test for the new methods in the AccountRepositoryTest in spring and microprofile module
|
|
||
| @Inject | ||
| public HieroEndpoint(final AccountClient client, final BlockRepository blockRepository) { | ||
| public HieroEndpoint( |
There was a problem hiding this comment.
we can ignore sample for now
| private final List<String> requestedPaths = new CopyOnWriteArrayList<>(); | ||
|
|
||
| @BeforeEach | ||
| void startServer() throws IOException { |
There was a problem hiding this comment.
can be replace to use mockito mock
| private final AccountRepository accountRepository; | ||
|
|
||
| public HieroEndpoint(final AccountClient client, final BlockRepository blockRepository) { | ||
| public HieroEndpoint( |
There was a problem hiding this comment.
same with this can ignore sample for now
| private final List<String> requestedPaths = new CopyOnWriteArrayList<>(); | ||
|
|
||
| @BeforeEach | ||
| void startServer() throws IOException { |
There was a problem hiding this comment.
replace with mockito mocks
- Revert sample HieroEndpoint and pom changes per maintainer (ignore samples for now) - Replace HttpServer-based MirrorNodeClientImplAccountEndpointsTest with Mockito mocks (Spring uses MockRestServiceServer; MicroProfile mocks ClientBuilder.newClient) - Add e2e tests for findCryptoAllowances/findTokenAllowances/findNftAllowances/ findStakingRewards/findOutstandingAirdrops/findPendingAirdrops in spring and microprofile AccountRepositoryTest
- Revert sample HieroEndpoint and pom changes per maintainer (ignore samples for now) - Replace HttpServer-based MirrorNodeClientImplAccountEndpointsTest with Mockito mocks (Spring uses MockRestServiceServer; MicroProfile mocks ClientBuilder.newClient) - Add e2e tests for findCryptoAllowances/findTokenAllowances/findNftAllowances/ findStakingRewards/findOutstandingAirdrops/findPendingAirdrops in spring and microprofile AccountRepositoryTest Signed-off-by: Alejandro <26930485+alejandroGM0@users.noreply.github.com>
57b7f02 to
95627fd
Compare
aceppaluni
left a comment
There was a problem hiding this comment.
@alejandroGM0 The work here looks very good, thank you for this.
Left a thought and would like your input.
| outstandingAirdropsPath, | ||
| pendingAirdropsPath), | ||
| pathCaptor.getAllValues()); | ||
| assertEquals(1, cryptoAllowances.getSize()); |
There was a problem hiding this comment.
@alejandroGM0 These assertions are great. I am wondering if we should add a few more to validate a few representative mapped fields per endpoint so converter regressions are caught more explicitly.
For example
assertEquals(AccountId.fromString("0.0.1000"),
stakingRewards.getData().get(0).accountId());
assertEquals(10,
stakingRewards.getData().get(0).amount());
assertFalse(nftAllowances.getData().get(0).approvedForAll());What do you think?
There was a problem hiding this comment.
Yes, that makes sense — happy to add representative field assertions
here. Since the fixtures are deterministic and there isn't a separate
MirrorNodeJsonConverterImplTest for these new account models, this
client test is currently the only unit-level coverage of the new
converter mappings, so field-level assertions add real value.
Will mirror the same assertions in the Spring test.
| final Page<TokenAirdrop> outstandingAirdrops = client.queryOutstandingAirdrops(accountId); | ||
| final Page<TokenAirdrop> pendingAirdrops = client.queryPendingAirdrops(accountId); | ||
|
|
||
| assertEquals(1, cryptoAllowances.getSize()); |
Split the combined account endpoint client tests into six per-endpoint cases with representative field assertions so converter regressions are caught explicitly in Spring and MicroProfile. Signed-off-by: Alejandro <26930485+alejandroGM0@users.noreply.github.com>
📝 WalkthroughWalkthroughThis PR extends the Hiero enterprise library to expose six new Mirror Node account endpoints for allowances, staking rewards, and token airdrops. It introduces typed data models, updates repository and client interfaces with new query methods, implements the queries in both MicroProfile and Spring frameworks, and provides comprehensive test coverage across both implementations. ChangesAccount Allowances, Rewards, and Airdrops
🎯 3 (Moderate) | ⏱️ ~20 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
hiero-enterprise-microprofile/src/test/java/org/hiero/microprofile/test/AccountRepositoryTest.java (1)
146-150: ⚡ Quick winReplace fixed sleep with bounded polling wait.
Using a fixed 10s pause makes these integration tests flaky and slower than necessary. Please poll
accountRepository.findById(accountId)(or the target endpoint) with timeout + short interval, then proceed once data is visible.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@hiero-enterprise-microprofile/src/test/java/org/hiero/microprofile/test/AccountRepositoryTest.java` around lines 146 - 150, The fixed Thread.sleep in newAccountVisibleOnMirrorNode makes tests slow and flaky; replace it with a bounded polling loop that calls accountRepository.findById(account.accountId()) (or the target visibility check) every short interval (e.g., 200-500ms) until a deadline (e.g., 5-10s) is reached, returning the AccountId as soon as the repository returns a non-empty result; if the deadline expires throw an exception or fail the test with a clear message. Ensure you use the existing accountClient.createAccount() result (variable account) and poll using account.accountId(), and avoid indefinite waits.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In
`@hiero-enterprise-microprofile/src/test/java/org/hiero/microprofile/test/AccountRepositoryTest.java`:
- Around line 146-150: The fixed Thread.sleep in newAccountVisibleOnMirrorNode
makes tests slow and flaky; replace it with a bounded polling loop that calls
accountRepository.findById(account.accountId()) (or the target visibility check)
every short interval (e.g., 200-500ms) until a deadline (e.g., 5-10s) is
reached, returning the AccountId as soon as the repository returns a non-empty
result; if the deadline expires throw an exception or fail the test with a clear
message. Ensure you use the existing accountClient.createAccount() result
(variable account) and poll using account.accountId(), and avoid indefinite
waits.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 7db76a61-e909-4575-bcd4-c7b4167efcae
📒 Files selected for processing (19)
hiero-enterprise-base/src/main/java/org/hiero/base/data/CryptoAllowance.javahiero-enterprise-base/src/main/java/org/hiero/base/data/NftAllowance.javahiero-enterprise-base/src/main/java/org/hiero/base/data/StakingReward.javahiero-enterprise-base/src/main/java/org/hiero/base/data/TimestampRange.javahiero-enterprise-base/src/main/java/org/hiero/base/data/TokenAirdrop.javahiero-enterprise-base/src/main/java/org/hiero/base/data/TokenAllowance.javahiero-enterprise-base/src/main/java/org/hiero/base/implementation/AccountRepositoryImpl.javahiero-enterprise-base/src/main/java/org/hiero/base/implementation/MirrorNodeJsonConverter.javahiero-enterprise-base/src/main/java/org/hiero/base/mirrornode/AccountRepository.javahiero-enterprise-base/src/main/java/org/hiero/base/mirrornode/MirrorNodeClient.javahiero-enterprise-microprofile/pom.xmlhiero-enterprise-microprofile/src/main/java/org/hiero/microprofile/implementation/MirrorNodeClientImpl.javahiero-enterprise-microprofile/src/main/java/org/hiero/microprofile/implementation/MirrorNodeJsonConverterImpl.javahiero-enterprise-microprofile/src/test/java/org/hiero/microprofile/test/AccountRepositoryTest.javahiero-enterprise-microprofile/src/test/java/org/hiero/microprofile/test/MirrorNodeClientImplAccountEndpointsTest.javahiero-enterprise-spring/src/main/java/org/hiero/spring/implementation/MirrorNodeClientImpl.javahiero-enterprise-spring/src/main/java/org/hiero/spring/implementation/MirrorNodeJsonConverterImpl.javahiero-enterprise-spring/src/test/java/org/hiero/spring/test/AccountRepositoryTest.javahiero-enterprise-spring/src/test/java/org/hiero/spring/test/MirrorNodeClientImplAccountEndpointsTest.java
Summary
Adds account-related mirror-node endpoints to
hiero-enterprise-java, allowing applications to retrieve account information through the enterprise API instead of calling the mirror node directly.Closes #100
What Changed
Why
This expands the mirror-node integration surface in the enterprise Java SDK/API and provides a standardized way for consumers to access account data. It also keeps account lookup workflows consistent with the existing mirror endpoint patterns already available in the project.
Testing
Working
Summary by CodeRabbit