Skip to content

feat: make MAX_SPONSORS configurable per deployment (#96) - #138

Open
rafaio1 wants to merge 1 commit into
MergeFi:mainfrom
rafaio1:feat/configurable-max-sponsors-96
Open

feat: make MAX_SPONSORS configurable per deployment (#96)#138
rafaio1 wants to merge 1 commit into
MergeFi:mainfrom
rafaio1:feat/configurable-max-sponsors-96

Conversation

@rafaio1

@rafaio1 rafaio1 commented Aug 21, 2026

Copy link
Copy Markdown

Summary

Resolves #96

This PR makes MAX_SPONSORS a per-deployment configuration parameter instead of a hardcoded compile-time constant, enabling different escrow/milestone instances to support varying numbers of sponsors based on their specific use case (e.g., $50 single-issue bounties vs $50k release milestones).

Changes

  • escrow/src/lib.rs: Added optional max_sponsors: Option<u32> parameter to initialize(). Stores value in instance storage under DataKey::MaxSponsors. Defaults to 20 (DEFAULT_MAX_SPONSORS) when None is passed for backward compatibility. Rejects zero with InvalidAmount.
  • milestones/src/lib.rs: Identical changes as escrow contract.
  • escrow/src/types.rs & milestones/src/types.rs: Added MaxSponsors variant to DataKey enum.
  • Tests: Updated all initialize/try_initialize calls in both contracts' test suites to pass &None for the new parameter. Replaced crate::MAX_SPONSORS references with crate::DEFAULT_MAX_SPONSORS.

Testing

  • cargo test --manifest-path contracts/escrow/Cargo.toml — 36 tests passed
  • cargo test --manifest-path contracts/milestones/Cargo.toml — 20 tests passed
  • cargo build succeeds for both contracts

Backward Compatibility

Existing deployments are unaffected. New deployments that omit the max_sponsors parameter will default to 20, matching current behavior. The initialize signature change is breaking for direct callers but this is expected for a pre-mainnet contract.

- Add optional max_sponsors parameter to initialize() in both escrow and milestones contracts
- Store limit in instance storage under DataKey::MaxSponsors
- Default to 20 (DEFAULT_MAX_SPONSORS) when not specified for backward compatibility
- Reject zero value with InvalidAmount error
- Update all tests to pass None for new parameter
- Fixes MergeFi#96
@vercel

vercel Bot commented Aug 21, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the chonilius' projects Team on Vercel.

A member of the Team first needs to authorize it.

@rafaio1

rafaio1 commented Aug 21, 2026

Copy link
Copy Markdown
Author

CI Note

The Vercel deployment check failure is expected and unrelated to this PR's code changes. It requires team authorization for the chonilius' projects Vercel team, which is a repository configuration matter.

This PR modifies only Soroban smart contract Rust code (contracts/escrow and contracts/milestones). There are no frontend or web assets changed. The relevant validation is cargo test and cargo build, both of which pass locally:

  • cargo test --manifest-path contracts/escrow/Cargo.toml — 36/36 passed
  • cargo test --manifest-path contracts/milestones/Cargo.toml — 20/20 passed
  • cargo build succeeds for both contracts

If there's a separate Rust CI workflow configured for this repo, I'm happy to address any feedback from it. Otherwise, the code changes are ready for review.

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.

MAX_SPONSORS (20) is a hardcoded constant with no per-deployment configurability

1 participant