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

refactor: Move total asset quantity to asset definition #5029

Conversation

DCNick3
Copy link
Contributor

@DCNick3 DCNick3 commented Sep 3, 2024

Context

total_asset_quantity map that we store is somewhat redundant and can be stored in the asset definition. This refactor allows us to remove FindTotalAssetQuantityByAssetDefinitionId query, as the total asset quantity can be found by querying the asset definition itself.

Closes #4934.

Solution

  • remove asset_total_quantities map from WSV
  • add total_quantity field to the AssetDefinition
  • remove FindTotalAssetQuantityByAssetDefinitionId query
  • replace test usages by the filtered FindAssetsDefinitions

Migration Guide

FindTotalAssetQuantityByAssetDefinitionId:

query(FindAssetsDefinitions::new())
  .filter_with(|asset_definition| asset_definition.id.eq(needle_definition_id))
  .execute_single()?
  .total_quantity

Checklist

@github-actions github-actions bot added the api-changes Changes in the API for client libraries label Sep 3, 2024
@DCNick3 DCNick3 added the queries label Sep 3, 2024
@DCNick3 DCNick3 merged commit 6613210 into hyperledger-iroha:main Sep 3, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-changes Changes in the API for client libraries queries
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move asset_total_amount inside the asset definition
3 participants