Skip to content
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

Merged
merged 1 commit into from
Sep 17, 2018

Conversation

arhag
Copy link
Contributor

@arhag arhag commented Sep 17, 2018

This PR makes two changes to cleos.

First, it fixes a potential bug in the to_asset function. The to_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 the symbol_code (i.e. the symbol name in uint64_t form) as the key for the map even though the to_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 a symbol rather than an asset which includes additional information (specifically the quantity) which is not necessary for the eosio.token::open action. Furthermore, the cleos transfer sub-command code is modified to avoid redundant calls to to_asset if the new --pay-ram-to-open option is provided.

@arhag arhag merged commit 2e94abd into develop Sep 17, 2018
@arhag arhag deleted the cleos-to_asset-bug-fix branch September 17, 2018 22:25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants