rpcserver: add decimal display to asset stats rpc #1566
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In Terminal, we'd like to display the asset supply value with the decimal point based on the
decimal_display
included in the metadata. We use theQueryAssetStats
REST endpoint to fetch assets from the universe server. Currently, the decimal display isn't included in the response.This PR adds this field to each asset in the response if it was specified in the metadata when minting. I've tested with grouped & non-grouped assets, with and without a
decimal_display
set.Here's what the updated response looks like:
My biggest concern with the approach I took here is the performance implications of looking up the decimal display at the rpcserver level, so this compute isn't cached along with the other queried data. This RPC is already pretty slow, and adding more to it may likely degrade performance further. I couldn't figure out how to obtain the decimal display in the QuerySyncStats function, which would include the results in the cache. Please let me know if there are any better ways of doing this.