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
Description
Creating claimable balances with complex claim predicates (time-based, unconditional, or compound AND/OR predicates) requires directly manipulating the
@stellar/stellar-sdkClaimantandxdr.ClaimPredicatetypes, 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-sdkClaimant.predicateUnconditional(),predicateBeforeAbsoluteTime(),predicateBeforeRelativeTime(),predicateAnd(), andpredicateOr(). Produces typedClaimPredicateobjects passed toOperation.createClaimableBalance(). Extendssrc/claimableBalanceFallback.ts. AddsPredicateConfigtosrc/types.ts.Acceptance Criteria
PredicateBuilder.unconditional()returns an always-claimable predicatePredicateBuilder.absoluteWindow(start, end)returns a predicate claimable only within the given Unix timestamp windowPredicateBuilder.relativeWindow(secondsFromNow)returns a predicate claimable for the next N secondsPredicateBuilder.and(a, b)andPredicateBuilder.or(a, b)compose two predicates with logical operatorsOperation.createClaimableBalance()insrc/claimableBalanceFallback.ts; integration test claims the balance within and outside the window