Skip to content

Claimable Balance Predicate Builder #517

Description

@Kingsman-99

Description

Creating claimable balances with complex claim predicates (time-based, unconditional, or compound AND/OR predicates) requires directly manipulating the @stellar/stellar-sdk Claimant and xdr.ClaimPredicate types, which have an unintuitive API. The SDK must expose a fluent predicate builder that makes composing time-windowed and compound predicates readable and type-safe.

Technical Context

Add src/predicateBuilder.ts. Wraps @stellar/stellar-sdk Claimant.predicateUnconditional(), predicateBeforeAbsoluteTime(), predicateBeforeRelativeTime(), predicateAnd(), and predicateOr(). Produces typed ClaimPredicate objects passed to Operation.createClaimableBalance(). Extends src/claimableBalanceFallback.ts. Adds PredicateConfig to src/types.ts.

Acceptance Criteria

  • PredicateBuilder.unconditional() returns an always-claimable predicate
  • PredicateBuilder.absoluteWindow(start, end) returns a predicate claimable only within the given Unix timestamp window
  • PredicateBuilder.relativeWindow(secondsFromNow) returns a predicate claimable for the next N seconds
  • PredicateBuilder.and(a, b) and PredicateBuilder.or(a, b) compose two predicates with logical operators
  • Built predicates are passed correctly to Operation.createClaimableBalance() in src/claimableBalanceFallback.ts; integration test claims the balance within and outside the window
  • All CI checks (npm test, npm run build, ESLint/TypeScript) pass and the branch has no merge conflicts

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions