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

fix: filtering in assets endpoint & update guides #1512

Merged
merged 2 commits into from
Oct 14, 2024
Merged

Conversation

Imod7
Copy link
Contributor

@Imod7 Imod7 commented Oct 14, 2024

Issue

The endpoint /accounts/{accountId}/asset-balances no longer returns results for specific assets which means that the array query param format ?assets[]=1&assets[]=2&assets[]=3does not work as expected.
The assets[] array query params are also used in:

  • /accounts/{accountId}/pool-asset-balances
    and other endpoints are using array query params and are probably affected but haven't tested them:
  • /pallets/{palletId}/storage/{storageItemId}
  • /contracts/ink/{address}/query

Suggested Solution

This issue is due to the upgrade from Express v4 to v5. In order to correctly handle [] in query params in v5, we need to set the default parser to extended (related resource).

Testing

Test /accounts/{accountId}/asset-balances in Polkadot Asset Hub

You can test that this change fixes the issue when connected to Polkadot Asset Hub and querying:
accounts/13Fet2MzBBUbJ2oREa7JJrswGeJPY4p7cY3Z2MC9oash8kzN/asset-balances?assets[]=1337

It returns

{
  "at": {
    "hash": "0xfb9b662bcc33e303349a640a85ce35044d38f50428284717db9ecf16a44bfc0a",
    "height": "7334813"
  },
  "assets": [
    {
      "assetId": "1337",
      "balance": "1260526400000",
      "isFrozen": "isFrozen does not exist for this runtime",
      "isSufficient": true
    }
  ]
}

which is the expected output.

Test /accounts/{accountId}/pool-asset-balances in Westend Asset Hub

You can test that this change fixes the issue when connected to Westend Asset Hub and querying:
/accounts/5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty/pool-asset-balances?assets[]=55

It returns

{
  "at": {
    "hash": "0x3853a2bafd9d3eccec5f776bc99caf333fc4f17753f0145b961b23d1fbb89eb9",
    "height": "9357129"
  },
  "poolAssets": [
    {
      "assetId": "55",
      "balance": "0",
      "isFrozen": false,
      "isSufficient": false
    }
  ]
}

which is the expected output.

@Imod7 Imod7 requested a review from a team as a code owner October 14, 2024 10:09
Copy link
Contributor

@IkerAlus IkerAlus left a comment

Choose a reason for hiding this comment

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

LGTM!

@Imod7 Imod7 merged commit b67bdcf into master Oct 14, 2024
19 checks passed
@Imod7 Imod7 deleted the domi-fix-assets branch October 14, 2024 13: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.

4 participants