feat: Add --of-principal to icp token/cycles balance#536
Merged
adamspofford-dfinity merged 4 commits intomainfrom May 1, 2026
Merged
feat: Add --of-principal to icp token/cycles balance#536adamspofford-dfinity merged 4 commits intomainfrom
--of-principal to icp token/cycles balance#536adamspofford-dfinity merged 4 commits intomainfrom
Conversation
raymondk
reviewed
Apr 28, 2026
| /// | ||
| /// # Returns | ||
| /// | ||
| pub async fn get_balance( |
Collaborator
There was a problem hiding this comment.
isn't it simpler if get_balance takes:
- principal
- Option
- token
And you get the balance for that principal.
Seems like a clearer api than maybe maybe of_principal otherwise the principal of the agent.
Contributor
Author
There was a problem hiding this comment.
No, the agent should typically be an input to functions like this. The reason is that we do not want to create more than one HTTP client for keep-alive reasons.
Collaborator
There was a problem hiding this comment.
Yes - I didn't mean to drop the agent.
I meant
Suggested change
| pub async fn get_balance( | |
| agent: &Agent, | |
| of_principal: Principal, | |
| subaccount: Option<[u8; 32]>, | |
| token: &str, | |
| ) -> Result<TokenAmount, GetBalanceError> { |
This way you're always getting the balance of_principal not falling back on the principal in the agent and it's clearer what the function is doing.
Otherwise - at the very least add a comment to explain the arguments
raymondk
approved these changes
May 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.