Skip to content

feat: Improved interactive contract selection option for FT tokens#574

Merged
frol merged 12 commits into
mainfrom
input-ft-contract
Mar 27, 2026
Merged

feat: Improved interactive contract selection option for FT tokens#574
frol merged 12 commits into
mainfrom
input-ft-contract

Conversation

@FroVolod

@FroVolod FroVolod commented Mar 14, 2026

Copy link
Copy Markdown
Collaborator

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:
Screenshot 2026-03-14 at 12 10 37

@frolvanya frolvanya left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread src/common.rs
new_ft_contract_account.clone()
};

ft_contract_accounts_list.push_front(used_ft_contract_account);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should cap the list length to some constant (around 100 or even less)

Suggested change
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);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done (e11593e)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 frolvanya left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread src/common.rs Outdated
Comment thread src/commands/tokens/send_ft/mod.rs Outdated
Comment thread src/common.rs Outdated
Comment thread src/common.rs
@FroVolod

FroVolod commented Mar 18, 2026

Copy link
Copy Markdown
Collaborator Author

@frolvanya

Also, that's more like a topic for a discussion rather than my request, but is it possible to separate tokens by network?

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.
If my opinion is wrong, please correct me.

@frolvanya

frolvanya commented Mar 18, 2026

Copy link
Copy Markdown
Contributor

@frolvanya

Also, that's more like a topic for a discussion rather than my request, but is it possible to separate tokens by network?

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.

If my opinion is wrong, please correct me.

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

@FroVolod

Copy link
Copy Markdown
Collaborator Author

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.

@FroVolod

Copy link
Copy Markdown
Collaborator Author

@frolvanya

what about view-ft-balance? Should we apply similar logic there as well?

done (92b1986)

@FroVolod FroVolod marked this pull request as ready for review March 18, 2026 14:21
@FroVolod FroVolod requested a review from a team as a code owner March 18, 2026 14:21

@frol frol left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Image

@frolvanya

frolvanya commented Mar 18, 2026

Copy link
Copy Markdown
Contributor

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

@frol

frol commented Mar 18, 2026

Copy link
Copy Markdown
Collaborator

Not sure why would anyone set read-only permissions for this file

I often run untrusted software in a docker with --read-only mode or it could run on systems where there is no HOME directory really.

@FroVolod FroVolod marked this pull request as draft March 19, 2026 05:47
@FroVolod FroVolod marked this pull request as ready for review March 20, 2026 09:32
Comment thread src/commands/tokens/send_ft/mod.rs Outdated
Comment thread src/main.rs
Comment thread src/main.rs
@frolvanya

Copy link
Copy Markdown
Contributor

@race-of-sloths score 8

@race-of-sloths

race-of-sloths commented Mar 20, 2026

Copy link
Copy Markdown

@FroVolod Thank you for your contribution! Your pull request is now a part of the Race of Sloths!
Do you want to apply for monthly streak? Get 8+ score for a single PR this month and receive boost for race-of-sloths!

Shows inviting banner with latest news.

Shows profile picture for the author of the PR

Current status: executed
Reviewer Score
@frolvanya 8

Your contribution is much appreciated with a final score of 8!
You have received 105 (80 base + 10 weekly bonus + 10 monthly bonus + 5% lifetime bonus) Sloth points for this contribution

@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 Sloths

Race 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:

  • Tag @race-of-sloths inside your pull requests
  • Wait for the maintainer to review and score your pull request
  • Check out your position in the Leaderboard
  • Keep weekly and monthly streaks to reach higher positions
  • Boast your contributions with a dynamic picture of your Profile

For maintainers:

  • Score pull requests that participate in the Race of Sloths and receive a reward
  • Engage contributors with fair scoring and fast responses so they keep their streaks
  • Promote the Race to the point where the Race starts promoting you
  • Grow the community of your contributors

Feel free to check our website for additional details!

Bot commands
  • For contributors
    • Include a PR: @race-of-sloths include to enter the Race with your PR
  • For maintainers:
    • Invite contributor @race-of-sloths invite to invite the contributor to participate in a race or include it, if it's already a runner.
    • Assign points: @race-of-sloths score [1/2/3/5/8/13] to award points based on your assessment.
    • Reject this PR: @race-of-sloths exclude to send this PR back to the drawing board.
    • Exclude repo: @race-of-sloths pause to stop bot activity in this repo until @race-of-sloths unpause command is called

@frolvanya frolvanya requested a review from frol March 20, 2026 16:55

@frol frol left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All my feedback was addressed, so looks good to me now

@frol frol merged commit 69b9c12 into main Mar 27, 2026
13 of 14 checks passed
@frol frol deleted the input-ft-contract branch March 27, 2026 15:11
@github-project-automation github-project-automation Bot moved this from NEW❗ to Shipped 🚀 in DevTools Mar 27, 2026
r-near added a commit that referenced this pull request Mar 27, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Shipped 🚀

Development

Successfully merging this pull request may close these issues.

[Task] Simplify interaction with tokens

5 participants