Add trustline-removal preconditions to the ChangeTrust example - #90
Conversation
…skill Co-authored-by: kaankacar <103106776+kaankacar@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Documents safe trustline removal in the assets skill.
Changes:
- Adds removal preconditions and error handling.
- Updates creation guidance and best practices.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| 3. **Clear offers / buying liabilities.** Open DEX offers that buy the asset | ||
| create buying liabilities; cancel them (`manageSellOffer`/`manageBuyOffer` | ||
| with `amount: "0"`) before removal. |
| if (parseFloat(trustline.buying_liabilities) !== 0) | ||
| throw new Error("Cancel open offers buying this asset first"); |
|
🤖 Automated message from Kaan's Automated Triage Bot. Verified before merging: the Horizon result-codes reference maps |
kaankacar
left a comment
There was a problem hiding this comment.
Result codes and deletion preconditions verified against the Horizon and operations references.
|
🤖 Automated message from Kaan's Automated Triage Bot. Both review points were correct and are addressed in #91: the removal guidance now says |
The assets skill taught trustline removal as a bare
limit: "10000", // 0 to remove trustlinecomment, omitting the preconditions that makeChangeTrust(limit: 0)succeed: a zero balance, no buying liabilities from open offers, and no liquidity pool references (CAP-0038). It also didn't distinguish an actual trustline from wallet-display or claimable-balance state.Changes to
skills/assets/SKILL.mdNew "Remove Trustline" section documenting the four preconditions:
ChangeTrustliquidity_pool_use_count > 0blocks deletion per CAP-0038)Example code that pre-checks trustline state before submitting, then maps failures to specific result codes:
Create-trustline comment now points to the new section instead of the bare "0 to remove" hint
Trustline Management best practices gain a removal-precondition bullet
Result code strings verified against Stellar's Horizon mapping (
ChangeTrustCannotDelete→"op_cannot_delete",ChangeTrustInvalidLimit→"op_invalid_limit").