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

Feature: details and chain filter on balance endpoint #633

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

1yam
Copy link
Collaborator

@1yam 1yam commented Oct 22, 2024

With new chain on aleph, as a user i can't get details of my balance.
The goal of the PR is to allow user filter balance base on chain and get the details.

Related Clickup or Jira tickets : ALEPH-232

Self proofreading checklist

  • Is my code clear enough and well documented
  • Are my files well typed
  • New translations have been added or updated if new strings have been introduced in the frontend
  • Are there enough tests
  • Documentation has been included (for new feature)

Changes

The /balances do same things as before but
This PR add 2 things

  • A new field details exemple : "details": {"AVAX": 447.1290583984875, "ETH": 4002.070110401869}
http://localhost:4024/api/v0/addresses/0xd463495a6FEaC9921FD0C3a595B81E7B2C02B57d/balance

{"address": "0xd463495a6FEaC9921FD0C3a595B81E7B2C02B57d", "balance": 4784.379935463618, "details": {"AVAX": 447.1290583984875, "BASE": 335.1807666632614, "ETH": 4002.070110401869}, "locked_amount": 0}
  • A new filter chain takings a Chain like (ETH / AVAX / BASE)
http://localhost:4024/api/v0/addresses/0xd463495a6FEaC9921FD0C3a595B81E7B2C02B57d/balance?chain=ETH

{"address": "0xd463495a6FEaC9921FD0C3a595B81E7B2C02B57d", "balance": 4002.070110401869, "details": {}, "locked_amount": 0}

Fix: /balances when the address didn't has token it's would return ERROR (not found it db cause no balance)
If address not found in db balance is now returning 0

{"address": "0xd463495a6FEaC9921FD0C3a595B81E7B2C02B57", "balance": 0, "details": {}, "locked_amount": 0}

How to test

http://localhost:4024/api/v0/addresses/0xd463495a6FEaC9921FD0C3a595B81E7B2C02B57d/balance?chain=ETH

Notes

The locked_amount is is for the whole address, we would need some refactor on the view for it or new endpoints.

@1yam 1yam requested a review from Psycojoker October 22, 2024 12:14
@1yam 1yam requested a review from Psycojoker October 29, 2024 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants