feat(contracts): recurring allowance / spending-limit authority (#1041) - #1103
Merged
Merged
Conversation
…bux#1041) Add a standalone Soroban contract letting an owner pre-authorize a merchant for capped recurring pulls, decoupled from subscription renewal. - grant/revoke allowance with per-period and absolute (lifetime) caps - consume enforces both caps and auto-resets the period window (boundary aligned) before moving funds owner -> merchant via transfer_from - update_caps (never below already-spent), available() query - admin pause/unpause circuit breaker - 21 unit tests + 4 property/fuzz tests; builds for wasm32v1-none Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Summary
Closes #1041.
Adds a standalone Soroban contract —
allowance— that lets a user (owner) pre-authorize a merchant for capped recurring pulls, fully decoupled from subscription renewal. It enforces two independent limits:Funds move via the token's
transfer_fromwith the contract as spender, so the merchant can pull on its own schedule without the owner signing each time (owner grants a matching tokenapproveonce).API
grant_allowancerevoke_allowanceconsumeupdate_capsavailablepause/unpause/is_pausedDesign notes
period_startadvances by whole periods so caps track fixed cycles rather than drifting per pull.Acceptance criteria
Testing
cargo test -p allowance→ 25 passing (21 unit + 4 property/fuzz), covering the happy path, both cap breaches, period reset & boundary alignment, revoke/pause blocking, cap updates, isolation between allowances, and input validation. Also builds clean for thewasm32v1-nonedeploy target.🤖 Generated with Claude Code