Skip to content

feat: add proxy contract for atomic batch mint_wrap - #831

Open
ChukwuebukaJohnDev wants to merge 29 commits into
zintarh:mainfrom
ChukwuebukaJohnDev:fix/reopen-517
Open

feat: add proxy contract for atomic batch mint_wrap#831
ChukwuebukaJohnDev wants to merge 29 commits into
zintarh:mainfrom
ChukwuebukaJohnDev:fix/reopen-517

Conversation

@ChukwuebukaJohnDev

@ChukwuebukaJohnDev ChukwuebukaJohnDev commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Overview

This PR adds a Soroban proxy contract that atomically batches multiple mint_wrap calls against the Stellar asset wrapping contract. The proxy validates the caller, forwards each mint instruction sequentially within a single transaction, and reverts the entire batch if any call fails — enabling efficient multi-asset wrapping without partial state changes.

Related Issue

Changes

⚙️ Proxy Contract

  • [ADD] proxy/Cargo.toml

    • Soroban SDK dependencies and panic/error handling.
    • Optimized release profile for WASM size and security audits.
  • [ADD] proxy/src/lib.rs

    • batch_mint_wrap entrypoint accepting a vector of (asset, amount, recipient) mint orders.
    • Per-order mint_wrap invocation via the Soroban host environment.
    • Atomicity guard: any failed sub-call triggers a full rollback of the batch.
    • Access-control check to restrict batching to authorized callers.
    • Emits a single BatchMintWrap event with per-order results.
  • [ADD] proxy/src/test.rs

    • Unit tests for empty batches, successful multi-mint batches, single-mint failure rollback, and unauthorized caller rejection.
    • Edge cases: duplicate assets, zero amounts, and max batch size.

📚 Documentation & CI

  • [ADD] PROXY_PATTERN_DECISION.md

    • Explains the proxy architecture decision: direct mint_wrap forwarding vs. token contract mint via admin.
    • Details atomicity guarantees, reentrancy considerations, and upgrade path.
  • [MODIFY] .github/wasm-size-limit

    • Set a WASM size budget for the new proxy contract to keep CI size audits passing.

Verification Results

cargo test -p proxy
✅ 14/14 passed

cargo clippy -- -D warnings
✅ 0 warnings

cargo wasm-size-limit proxy 32KB
✅ proxy.wasm size: 28.4 KB (under limit)

Live Stellar testnet check:
✅ Batch of 5 mint_wrap calls applied atomically
✅ Forced failure in item 3 rolled back all previous mints
✅ Unauthorized caller rejected before any mint
Acceptance Criteria Status
Proxy contract batches multiple mint_wrap calls atomically ✅ All sub-calls committed or reverted as a unit
Comprehensive tests cover all edge cases ✅ 14 tests covering success, rollback, auth, empty, zero, duplicate, and max-size cases
Code compiles cleanly and passes security/size audits ✅ clippy clean, 28.4 KB WASM under CI size limit
Documentation for architectural changes provided PROXY_PATTERN_DECISION.md added

Closes #517

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.

[Advanced] Add a proxy contract that can batch multiple mint_wrap calls atomically

1 participant