feat: Improved interactive contract selection option for FT tokens#574
Conversation
frolvanya
left a comment
There was a problem hiding this comment.
Looks good, I have one more proposal, but it has to be discussed first:
Is prepopulating a file with tokens, if it's empty, with top100 tokens a good idea? For example, top tokens can be retrieved with nearblocks api: https://api.nearblocks.io/api-docs#tag/fts/GET/v1/fts
| new_ft_contract_account.clone() | ||
| }; | ||
|
|
||
| ft_contract_accounts_list.push_front(used_ft_contract_account); |
There was a problem hiding this comment.
I think we should cap the list length to some constant (around 100 or even less)
| ft_contract_accounts_list.push_front(used_ft_contract_account); | |
| ft_contract_accounts_list.push_front(used_ft_contract_account); | |
| ft_contract_accounts_list.truncate(FT_CONTRACT_ACCOUNTS_LIST_SIZE_CAP); |
There was a problem hiding this comment.
I think not entirely, because new tokens still can be added and it will result to >50 tokens stored in file or did I miss something?
Related to: #574 (comment)
There was a problem hiding this comment.
I think we should cap the list length to some constant (around 100 or even less)
I believe user-added ft-contracts would fit into your proposal.
frolvanya
left a comment
There was a problem hiding this comment.
Looks good, thanks!
It works for me during send-ft flow, but what about view-ft-balance? Should we apply similar logic there as well?
Also, that's more like a topic for a discussion rather than my request, but is it possible to separate tokens by network? I know that during ft contract selection user hasn't provided network yet, but maybe we can just take a lucky guess based on user's account id? For example, if user has .near at the end, then show only tokens on mainnet (it would require storing an extra field in json or having two separate files for tokens on each chain, I prefer first option), if user has .testnet, then show only tokens on testnet. This should cover 99% of user account ids, otherwise, we can show tokens for both networks. Again, not sure if this is needed and if it improves UX or only makes it more confusing, so has to be discussed first
I basically did not add ft-contracts from https://api-testnet.nearblocks.io, because I believe that the "testnet" user will be able to find the ft-contract he needs on his own. In addition, this contract will be saved in his file ("ft_contracts.json") for further work. |
I'm not talking about fetching top testnet tokens, because it would be useless indeed. I think people are using like 2-3 tokens like wnear or usdc and some custom tokens at most. I'm talking about not showing mainnet tokens if user wrote that his address is alice.testnet and showing only recent testnet tokens P.S: but again, not sure if we need to over complicate things, maybe it's better to leave it as it's right now |
During the discussion with @frolvanya, it was decided to leave this option for forming a list of ft-contracts. |
done (92b1986) |
frol
left a comment
There was a problem hiding this comment.
I provided my reasoning for having the list of tokens as part of the config: #567 (comment) (yet it is not a blocker for me)
The blocker for me is that failures with this temporary file or with network fetching the list must not prevent CLI usage:
Not sure why would anyone set read-only permissions for this file, but I agree that it should not interrupt normal usage. A warning should be enough |
I often run untrusted software in a docker with |
|
@race-of-sloths score 8 |
|
@FroVolod Thank you for your contribution! Your pull request is now a part of the Race of Sloths! Current status: executed
Your contribution is much appreciated with a final score of 8! @frolvanya received 25 Sloth Points for reviewing and scoring this pull request. Congratulations @FroVolod! Your PR was highly scored and you completed another monthly streak! To keep your monthly streak make another pull request next month and get 8+ score for it What is the Race of SlothsRace of Sloths is a friendly competition where you can participate in challenges and compete with other open-source contributors within your normal workflow For contributors:
For maintainers:
Feel free to check our website for additional details! Bot commands
|
frol
left a comment
There was a problem hiding this comment.
All my feedback was addressed, so looks good to me now
…TTP calls Tests were failing because prepare_tests() used unsafe set_var() to set HOME/XDG_CONFIG_HOME across parallel test threads (undefined behavior). Combined with blocking HTTP calls to nearblocks API added at startup in #574, the subprocess would read wrong config and produce empty output. - Pass env vars explicitly to subprocess Command instead of set_var - Pre-create ft_contracts.json in test setup to skip startup HTTP calls - Simplify is_used_ft_contract_account_list_exist to just check file existence - Write valid empty JSON ("[]") instead of empty file on API failure
Resolves #567
Interactive mode:
Screen.Recording.2026-03-17.at.11.41.53.mov
Command line mode:
Screen.Recording.2026-03-14.at.12.08.15.mov
ft_contracts.json:
