feat: add getBalance and getAccountInfo tools#71
Merged
Conversation
There was a problem hiding this comment.
2 issues found across 3 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="tools/stellar.ts">
<violation number="1" location="tools/stellar.ts:97">
P2: Non-native balance formatting assumes `asset_code`/`asset_issuer` always exist, misreporting `liquidity_pool_shares` balances as `undefined:undefined`.</violation>
</file>
<file name="agent.ts">
<violation number="1" location="agent.ts:166">
P2: Using `publicKey || this.publicKey` silently falls back on empty-string input, which can query the wrong account instead of rejecting invalid caller input.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| }; | ||
| } else { | ||
| return { | ||
| asset: `${balance.asset_code}:${balance.asset_issuer}`, |
There was a problem hiding this comment.
P2: Non-native balance formatting assumes asset_code/asset_issuer always exist, misreporting liquidity_pool_shares balances as undefined:undefined.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At tools/stellar.ts, line 97:
<comment>Non-native balance formatting assumes `asset_code`/`asset_issuer` always exist, misreporting `liquidity_pool_shares` balances as `undefined:undefined`.</comment>
<file context>
@@ -64,4 +64,82 @@ export const stellarSendPaymentTool = new DynamicStructuredTool({
+ };
+ } else {
+ return {
+ asset: `${balance.asset_code}:${balance.asset_issuer}`,
+ balance: balance.balance,
+ };
</file context>
Suggested change
| asset: `${balance.asset_code}:${balance.asset_issuer}`, | |
| asset: | |
| balance.asset_type === "liquidity_pool_shares" | |
| ? `LP:${balance.liquidity_pool_id}` | |
| : `${balance.asset_code}:${balance.asset_issuer}`, | |
| * @param publicKey Optional Stellar public key (defaults to client's publicKey) | ||
| */ | ||
| async getBalance(publicKey?: string) { | ||
| const targetPublicKey = publicKey || this.publicKey; |
There was a problem hiding this comment.
P2: Using publicKey || this.publicKey silently falls back on empty-string input, which can query the wrong account instead of rejecting invalid caller input.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At agent.ts, line 166:
<comment>Using `publicKey || this.publicKey` silently falls back on empty-string input, which can query the wrong account instead of rejecting invalid caller input.</comment>
<file context>
@@ -157,6 +158,51 @@ export class AgentClient {
+ * @param publicKey Optional Stellar public key (defaults to client's publicKey)
+ */
+ async getBalance(publicKey?: string) {
+ const targetPublicKey = publicKey || this.publicKey;
+ if (!targetPublicKey) {
+ throw new Error("Public key is required to fetch balance.");
</file context>
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.
Summary by cubic
Add Stellar account tools to fetch balances and account details, plus
AgentClientmethods to access them easily. Exposes both tools instellarToolsfor use across the app.stellar_get_balanceandstellar_get_account_infotools. Balance returns XLM and asset balances; account info includes sequence, signers, thresholds (excluding_linksandbalances).AgentClient.getBalance(publicKey?)andAgentClient.getAccountInfo(publicKey?), defaulting to the client’spublicKey. Results return JSON when possible, otherwise a readable error message.testnetandmainnet. Exported viastellarToolsinindex.ts.Written for commit 40bf265. Summary will update on new commits. Review in cubic