Skip to content

feat: add per-owner spending limits and approval-count property test#213

Merged
thegreatfeez merged 1 commit into
Ac0rdP:mainfrom
Omoboi-dev:feat/accord-spending-limits-and-invariant-test
Jun 27, 2026
Merged

feat: add per-owner spending limits and approval-count property test#213
thegreatfeez merged 1 commit into
Ac0rdP:mainfrom
Omoboi-dev:feat/accord-spending-limits-and-invariant-test

Conversation

@Omoboi-dev

Copy link
Copy Markdown
Contributor

Summary

#41 Per-owner spending limits per token

Adds an optional per-owner cap on the amount an owner can propose for a given token.

  • New SetSpendingLimit(owner, token, limit) variant on ProposalKind. A limit of 0 blocks that token entirely; an absent limit means unlimited.
  • Persistent storage keyed by (owner, token) -> i128, with TTL bumping consistent with the rest of the contract.
  • create_spending_limit_proposal creates a governance proposal to set a limit. It runs the same owner, frozen, description and deadline checks as the other create functions. Note: the name was shortened from the suggested create_set_spending_limit_proposal because Soroban caps contract function names at 32 characters.
  • Execute branch writes the limit when the proposal passes.
  • create_proposal now rejects a transfer proposal with the new SpendingLimitExceeded error (code 28) when the proposer has a configured limit and the amount exceeds it.
  • get_spending_limit(owner, token) read function returns the stored limit or None when unlimited.

#55 Property test: approval count never exceeds owner count

  • Adds proptest as a dev dependency.
  • New approval_count_never_exceeds_owner_count test: for a random owner count (1 to 20) and threshold, it builds a fresh env, initializes the multisig, creates a proposal, has every owner approve, and asserts approvals equals the owner count and that a duplicate approval returns AlreadyApproved.
  • The proptest snapshots are non-deterministic (random inputs each run), so they are gitignored. The deterministic snapshots from the Add per-owner spending limits per token #41 unit tests are committed.

Tests

cargo test -p accord passes 70/0, including the two new #41 lifecycle tests and the #55 property test.

Closes #41
Closes #55

@vercel

vercel Bot commented Jun 27, 2026

Copy link
Copy Markdown

@Omoboi-dev is attempting to deploy a commit to the thegreatfeez's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Jun 27, 2026

Copy link
Copy Markdown

@Omoboi-dev Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@thegreatfeez thegreatfeez merged commit 3b7023d into Ac0rdP:main Jun 27, 2026
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add property-based test: approval count never exceeds the number of unique owners Add per-owner spending limits per token

2 participants