Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom fees REST api #2247

Merged
merged 14 commits into from
Jul 9, 2021
Merged

Custom fees REST api #2247

merged 14 commits into from
Jul 9, 2021

Conversation

xin-hedera
Copy link
Collaborator

@xin-hedera xin-hedera commented Jul 8, 2021

Description:

This PR adds HTS custom fees support to the mirror node REST API.

  • Add assessed custom fees to /api/v1/transactions/:transactionId endpoint
  • Add custom fees schedule to/api/v1/tokens/:tokenId endpoint
  • Add model/viewmodel for assessed custom fees and custom fees schedule
  • Add integration domain support for assessed custom fees and custom fees schedule
  • Update openapi spec
  • Fix EntityId throwing exception with nullable undefined value
  • Move queryQuietly to pool class prototype
  • Add/Update integration tests

Related issue(s):

Fixes #2199

Notes for reviewer:

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

Signed-off-by: Xin Li <xin.li@hedera.com>
Signed-off-by: Xin Li <xin.li@hedera.com>
Signed-off-by: Xin Li <xin.li@hedera.com>
Signed-off-by: Xin Li <xin.li@hedera.com>
Signed-off-by: Xin Li <xin.li@hedera.com>
Signed-off-by: Xin Li <xin.li@hedera.com>
Signed-off-by: Xin Li <xin.li@hedera.com>
@xin-hedera xin-hedera added enhancement Type: New feature P1 rest Area: REST API labels Jul 8, 2021
@xin-hedera xin-hedera added this to the Mirror 0.37.0 milestone Jul 8, 2021
@xin-hedera xin-hedera requested a review from a team July 8, 2021 13:56
@xin-hedera xin-hedera self-assigned this Jul 8, 2021
@codecov
Copy link

codecov bot commented Jul 8, 2021

Codecov Report

Merging #2247 (ad2822b) into main (50c046b) will increase coverage by 0.13%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##               main    #2247      +/-   ##
============================================
+ Coverage     83.13%   83.27%   +0.13%     
  Complexity     2234     2234              
============================================
  Files           433      437       +4     
  Lines         11682    11783     +101     
  Branches        985     1002      +17     
============================================
+ Hits           9712     9812     +100     
- Misses         1642     1643       +1     
  Partials        328      328              
Impacted Files Coverage Δ
server.js 82.22% <0.00%> (-0.58%) ⬇️
utils.js 95.69% <0.00%> (-0.12%) ⬇️
schedules.js 95.00% <0.00%> (-0.07%) ⬇️
tokens.js 96.20% <0.00%> (-0.06%) ⬇️
topicmessage.js 98.05% <0.00%> (-0.06%) ⬇️
stateproof.js 96.63% <0.00%> (-0.03%) ⬇️
model/token.js 100.00% <0.00%> (ø)
service/nftService.js 100.00% <0.00%> (ø)
service/tokenService.js 100.00% <0.00%> (ø)
model/assessedCustomFee.js 100.00% <0.00%> (ø)
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 50c046b...ad2822b. Read the comment docs.

Signed-off-by: Xin Li <xin.li@hedera.com>
Signed-off-by: Xin Li <xin.li@hedera.com>
Signed-off-by: Xin Li <xin.li@hedera.com>
Comment on lines +184 to +185
logger.error(err);
process.exit(1);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

rethrow will cause unhandled rejection warning and the nodejs process hanging there.

Signed-off-by: Xin Li <xin.li@hedera.com>
hedera-mirror-rest/api/v1/openapi.yml Show resolved Hide resolved
hedera-mirror-rest/api/v1/openapi.yml Show resolved Hide resolved
hedera-mirror-rest/tokens.js Outdated Show resolved Hide resolved
hedera-mirror-rest/transactions.js Outdated Show resolved Hide resolved
hedera-mirror-rest/transactions.js Outdated Show resolved Hide resolved
hedera-mirror-rest/utils.js Show resolved Hide resolved
Signed-off-by: Xin Li <xin.li@hedera.com>
'maximum_amount', ${CustomFee.MAXIMUM_AMOUNT}::text,
'minimum_amount', ${CustomFee.MINIMUM_AMOUNT}::text,
'token_id', ${CustomFee.TOKEN_ID}::text
) order by ${CustomFee.AMOUNT}, ${CustomFee.COLLECTOR_ACCOUNT_ID}, ${CustomFee.DENOMINATING_TOKEN_ID})
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

order the custom fees so integration tests can pass. it's interesting that the same data inserted in the same order, vanilla pg and timescaledb return them in opposite orders.

Copy link
Contributor

Choose a reason for hiding this comment

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

Probably cause of the extra index in the timescale case

Signed-off-by: Xin Li <xin.li@hedera.com>
Copy link
Member

@steven-sheehy steven-sheehy left a comment

Choose a reason for hiding this comment

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

LGTM

@sonarcloud
Copy link

sonarcloud bot commented Jul 8, 2021

@xin-hedera xin-hedera requested a review from Nana-EC July 9, 2021 14:32
Copy link
Contributor

@Nana-EC Nana-EC left a comment

Choose a reason for hiding this comment

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

LGTM

@xin-hedera xin-hedera merged commit b82d07f into main Jul 9, 2021
@xin-hedera xin-hedera deleted the custom_fees_rest_api branch July 9, 2021 15:49
ijungmann pushed a commit that referenced this pull request Jul 16, 2021
- Add assessed custom fees to /api/v1/transactions/:transactionId endpoint
- Add custom fees schedule to/api/v1/tokens/:tokenId endpoint
- Add model/viewmodel for assessed custom fees and custom fees schedule
- Add integration domain support for assessed custom fees and custom fees schedule
- Update openapi spec
- Fix EntityId throwing exception with nullable undefined value
- Move queryQuietly to pool class prototype
- Add/Update integration tests

Signed-off-by: Xin Li <xin.li@hedera.com>
Signed-off-by: Ian Jungmann <ian.jungmann@hedera.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Type: New feature P1 rest Area: REST API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add custom fees to existing REST APIs
4 participants