feat: add Claimable Balance support (conditional / time-locked payments)#61
Closed
nishant-uxs wants to merge 2 commits into
Closed
feat: add Claimable Balance support (conditional / time-locked payments)#61nishant-uxs wants to merge 2 commits into
nishant-uxs wants to merge 2 commits into
Conversation
- New lib/claimableBalance.ts module exposing createClaimableBalance, claimClaimableBalance, listClaimableBalances
- Friendly tagged-union ClaimPredicate (unconditional / beforeRelativeTime / beforeAbsoluteTime / not / and / or) with input validation, depth guard, and amount/issuer checks
- 1:1 claimant-to-operation mapping for deterministic balance ID extraction from result XDR
- Wired into AgentClient as agent.claimable.{create,claim,list}
- Public types exported from index.ts and agent.ts
- 16 unit tests (vitest) covering predicate validation, input validation, signing, op shape, and Horizon list filters
- README section with composable predicates table and end-to-end example
Motivates a key Stellar primitive missing from AgentKit, useful for AI-agent
workflows: escrow, vesting, scheduled payouts, and conditional releases.
There was a problem hiding this comment.
1 issue found across 6 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="lib/claimableBalance.ts">
<violation number="1" location="lib/claimableBalance.ts:244">
P2: The function applies a per-balance 10-claimant protocol limit to the total number of one-claimant operations, incorrectly rejecting valid multi-balance requests.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Address Cubic AI review (PR Stellar-Tools#61): the previous MAX_CLAIMANTS=10 check incorrectly applied Stellar's per-balance protocol limit to the total number of one-claimant operations, rejecting valid multi-balance requests. Since createClaimableBalance emits one CreateClaimableBalance op per input claimant (each resulting balance has exactly 1 claimant), the per-balance cap does not apply. The effective limit is the per-transaction operation cap (100). - Replace MAX_CLAIMANTS with MAX_OPERATIONS_PER_TRANSACTION=100 - Export MAX_CLAIMANTS_PER_BALANCE=10 as informational constant for future multi-claimant-per-balance support - Update tests: assert >=11 claimants are accepted, only >100 rejected - Update README to reflect the correct cap
Contributor
|
values in files are constants. |
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.
Motivates a key Stellar primitive missing from AgentKit, useful for AI-agent workflows: escrow, vesting, scheduled payouts, and conditional releases.
Summary by cubic
Adds claimable balance support for conditional and time-locked payments to enable escrow, vesting, and scheduled payouts. Exposes simple create, claim, and list APIs with composable predicates and deterministic balance ID extraction.
New Features
lib/claimableBalancewithcreateClaimableBalance,claimClaimableBalance, andlistClaimableBalances.ClaimPredicate(unconditional,beforeRelativeTime,beforeAbsoluteTime,not,and,or) with validation and depth guard.AgentClientasagent.claimable.{create,claim,list}; public types exported viaagent.tsandindex.ts.Bug Fixes
MAX_CLAIMANTS_PER_BALANCE=10as informational; tests and README updated.Written for commit 87ecec8. Summary will update on new commits.