This repository has been archived by the owner on Aug 2, 2022. It is now read-only.
cleos improvements: disambiguate symbol_code in to_asset cache using contract name; efficiency improvements related to --pay-ram-to-open option #5702
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.
This PR makes two changes to cleos.
First, it fixes a potential bug in the
to_asset
function. Theto_asset
function uses a static map to cache the results of queries to nodeos to find the actual precision of a token symbol given only its name. The problem is that the cache uses only thesymbol_code
(i.e. the symbol name inuint64_t
form) as the key for the map even though theto_asset
function allows the caller to specify an alternative token contract account.This means if cleos was ever updated such that one of its sub-commands needed to deal with two different tokens from two different token contracts, then if the symbol names happened to be the same it could be possible that the precision returned for at least one of those tokens would be wrong. This PR fixes the potential bug by using a pair of the contract account name and symbol code as the key in the cache map.
Second, it modifies the signature of the new
create_open
function recently introduced in PR #5581 to take asymbol
rather than anasset
which includes additional information (specifically the quantity) which is not necessary for theeosio.token::open
action. Furthermore, the cleos transfer sub-command code is modified to avoid redundant calls toto_asset
if the new--pay-ram-to-open
option is provided.