Skip to content

Feat/missing features and bugfixes#84

Open
efekrbas wants to merge 14 commits into
Stellar-Tools:mainfrom
efekrbas:feat/missing-features-and-bugfixes
Open

Feat/missing features and bugfixes#84
efekrbas wants to merge 14 commits into
Stellar-Tools:mainfrom
efekrbas:feat/missing-features-and-bugfixes

Conversation

@efekrbas

@efekrbas efekrbas commented May 30, 2026

Copy link
Copy Markdown

Description

This PR introduces comprehensive updates to AgentClient by integrating missing namespaces, establishing robust error handling, and achieving 100% test passing coverage. It fulfills the core features required for the Stellar AgentKit while meticulously avoiding the unwanted structural changes from PR #33.

🚀 New Features & Capabilities

  • AgentClient Namespaces: Fully implemented the missing namespaces within agent.ts.
    • sendPayment(): Delegated capability to send XLM or custom assets natively.
    • account: Implemented read-only methods (getInfo, getBalances, getTransactions, getOperations, fundTestnet).
    • asset: Implemented SDEX lookups (getDetails, getOrderbook, getTrades).
    • staking: Connected Soroban staking interactions (initialize, stake, unstake, claimRewards, getStake).
    • claims: Implemented listClaimableBalances and claimBalance utilities.
  • Recovered Library Implementations: Extracted and fixed UTF-8 encoding issues for lib/account.ts and lib/asset.ts to support the new namespaces correctly.
  • Type & Tool Exports: Synchronized index.ts to export all newly mapped types and tools.

🐛 Bug Fixes & Refactoring

  • lib/stakeF.ts: Addressed severe logic flaws where catch blocks were returning string messages instead of throwing errors. Refactored the methods to use robust throw new Error(...) patterns. Cleaned up unreachable code segments in getStake().

🧪 Testing & Documentation

  • Unit Testing: Created a baseline tests/unit/agent.test.ts focusing on constructor validations, mainnet safeguards, and token launch constraints. All 64 Vitest test cases (unit + integration) now pass successfully.
  • API Documentation: Updated docs/api.md with complete usage guides, parameters, and examples for sendPayment, account, asset, staking, and claims.

🛑 What's NOT in this PR

Checklist

  • Code compiles correctly
  • All new and existing tests pass (npm run test)
  • API documentation has been updated
  • No sensitive data (e.g., private keys) is committed

Summary by cubic

Adds the missing AgentClient capabilities (payments, account/asset explorers, Soroban staking, claimable balances) with stricter validation and Horizon helpers. Also fixes Friendbot funding errors, BigInt JSON serialization in liquidity results, hardens env safety and RPC defaults, and refines bridge, claims, and staking flows.

  • New Features

    • sendPayment with strict key/amount validation and optional memo.
    • account: getInfo, getBalances, getTransactions, getOperations, fundTestnet; top-level helpers getBalance, getAccountInfo; new utils/horizon.ts.
    • asset: getDetails, getOrderbook, getTrades.
    • staking: initialize, stake, unstake, claimRewards, getStake (auto Soroban RPC by network).
    • claims: list, claim plus stellar_claim_balance_tool.
    • Exports synced in index.ts (adds StellarAccountTool, StellarAssetTool, balance/account tools, claim APIs; exposes lib-level account/asset/staking/claim functions).
  • Bug Fixes

    • Friendbot funding: clearer errors, idempotent handling for already-funded accounts.
    • Liquidity contract tool: fixed BigInt JSON serialization and getReserves usage; RPC URL defaults by network; cleaned responses.
    • Bridge tool: safer mainnet guard, robust target-chain selection, restore retry, trustline setup.
    • Claims: full pagination with safe next-page handling, fee type fix, and batch limit.
    • lib/stakeF.ts: throw real errors; removed unreachable code.
    • Input validation bounds for asset codes and list limits; narrowed .gitignore to avoid overreach; tests cover agent.ts.

Written for commit 1f7a1c2. Summary will update on new commits.

Review in cubic

efekrbas and others added 10 commits March 24, 2026 21:13
- Add sendPayment, account, asset, staking, and claims namespaces to AgentClient
- Fix bug in lib/stakeF.ts (unreachable code, robust error throwing)
- Add account and asset lib implementations
- Export missing types and tools in index.ts
- Update vitest coverage and add baseline AgentClient tests
- Update API documentation with new namespaces

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

11 issues found across 14 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread .gitignore Outdated
Comment thread lib/claimF.ts
Comment thread lib/claimF.ts Outdated
Comment thread agent.ts
Comment thread tools/contract.ts Outdated
Comment thread lib/asset.ts
Comment thread agent.ts Outdated
Comment thread lib/account.ts Outdated
Comment thread lib/claimF.ts Outdated
Comment thread lib/account.ts Outdated
…, pagination logic, API refactoring, and validation bounds

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

5 issues found across 7 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread .gitignore
Comment thread tools/contract.ts Outdated
Comment thread tools/contract.ts Outdated
Comment thread tools/contract.ts
Comment thread lib/account.ts Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

2 issues found across 3 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread tools/contract.ts Outdated
Comment thread .gitignore Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant