feat: harden asset management with critical trustline fix and mainnet…#24
feat: harden asset management with critical trustline fix and mainnet…#24murat48 wants to merge 1 commit intoStellar-Tools:mainfrom
Conversation
|
| GitGuardian id | GitGuardian status | Secret | Commit | Filename | |
|---|---|---|---|---|---|
| - | - | Generic High Entropy Secret | e5afaf6 | .env | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secret safely. Learn here the best practices.
- Revoke and rotate this secret.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.
There was a problem hiding this comment.
1 issue found across 23 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/assetManagement.ts">
<violation number="1" location="tools/assetManagement.ts:17">
P2: Module-level Stellar key validation throws on import, so importing the toolkit will crash if STELLAR_PUBLIC_KEY/PRIVATE_KEY aren’t set even when asset management isn’t used. Defer validation until the tool is invoked or lazily initialize to avoid breaking initialization.</violation>
</file>
Since this is your first cubic review, here's how it works:
- cubic automatically reviews your code and comments on bugs and improvements
- Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
- Add one-off context when rerunning by tagging
@cubic-dev-aiwith guidance or docs links (includingllms.txt) - Ask questions if you need clarification on any suggestion
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Summary
This PR adds
assetManagementToolto the Stellar AgentKit, enabling developers to manage Stellar assets programmatically — including balance queries, trustline management, and custom asset issuance. The implementation includes production-grade security from the start, with mainnet safeguards and strict input validation consistent with the project's "safe by default" philosophy.What's Added
tools/assetManagement.tsA new
DynamicStructuredToolwith three actions:get_balances— Fetch all asset balances (XLM + custom tokens) for the configured accountmanage_trustline— Add or remove trustlines for custom Stellar assetscreate_asset— Issue a new custom asset to a recipient accountSecurity Features
ALLOW_MAINNET_ASSET_MANAGEMENT=truein.env, consistent withbridgeTokenToolSTELLAR_PUBLIC_KEYis verified againstSTELLAR_PRIVATE_KEYat module load — fails fast with a clear error if mismatchedcreate_assetvalidates that the recipient already has a trustline before issuing, rather than attempting to sign the recipient'schangeTrustwith the issuer's keypair (which would violate Stellar's auth model and fail withtx_bad_auth)assetCode: 1–12 alphanumeric characters (regex)assetIssuer/recipientAddress: valid Ed25519 public keys viaStrKeyamount/limit: positive numbers, max 7 decimal places (Stellar precision limit)Documentation
💰 Asset Managementsection toREADME.mdwith usage examples, mainnet instructions, and error scenariosALLOW_MAINNET_ASSET_MANAGEMENTto.envand.env.exampleIntegration
index.tsas part ofstellarToolsarray — immediately available to all AgentKit consumersTesting
pnpm build
✅ No TypeScript errors
node [test-asset-tool-with-create-asset.mjs]
✅ get_balances — PASS
✅ manage_trustline — PASS
✅ create_asset — PASS
Backward Compatibility
Summary by cubic
Adds a secure
asset_managementtool with balances, trustline management, and custom asset issuance, plus a critical trustline authorization fix. Also introduces mainnet safeguards, unified transaction building, and docs/tests to make asset operations safe and predictable.New Features
asset_managementactions:get_balances,manage_trustline,create_asset.stellarTools; addsAgentClientand network-aware bridge helper.buildTransactionandbuildTransactionFromXDRused by LP, stake, and bridge flows.createwallet/create_wallet.mjs).Bug Fixes / Hardening
ALLOW_MAINNET_ASSET_MANAGEMENT=trueandALLOW_MAINNET_BRIDGE=trueto run on mainnet.StrKey, amounts with up to 7 decimals, keypair consistency check at load.Written for commit e5afaf6. Summary will update on new commits.