Feature/129 refund vault refactor - #254
Open
tecmalik wants to merge 4 commits into
Open
Conversation
…censa#129) Introduce the multi-contract refund architecture: - contracts/refund-window-policy: a stateless policy contract whose check_refund() evaluates the refund-window rule. Other policy kinds are new contracts implementing the same fixed signature, so the vault wasm never changes when a policy rule changes. - RefundVault: now constructor-only (__constructor(merchant, token, window, policy)), mirroring ReceiptShard. Removed initialize. refund() routes its window check to the bound policy contract via the RefundPolicyClient trait (same pattern as ReceiptAnchor's ShardInterface), translating deliberate policy errors (WindowExpired) while mapping host-level failures to the new Error::PolicyCallFailed. Adds get_refund_policy() and set_refund_policy(). - contracts/refund-vault-factory: deploys RefundVault instances via deploy_v2 + __constructor, stores the vault wasm hash, keeps an on-chain registry of deployed vaults, and supports deploy() (default policy) and deploy_with_policy() (explicit policy bind). - Add Error::PolicyCallFailed (302) to accensa_common. Unit/integration/multisig test helpers now register vaults with constructor args; "uninitialized calls fail" vault tests were removed (a deployed vault is always initialised) and replaced where valuable by policy-call and constructor-init coverage. WIP: tests not fully green; superuser deployment/dynamic factory deploy is an open work item.
…#129) Resolve the test failures that followed the factory + stateless-policy refactor: - Fix all vault unit tests registering the constructor with plain integer literals (100 / 17_280), which the `env.register` constructor-deserialization inferred as `i32` and rejected with ConversionError. Type them `u32` to match the `__constructor(merchant, token, refund_window_ledgers, policy)` signature. - Rework the three directly-initialised vault tests that no longer apply: - self-transfer tests now assert no token movement instead of a fragile event count that is unmeasurable after a failed `try_*` sub-call - `test_transfer_admin_requires_auth` uses `#[should_panic]` like its siblings (the constructor-based setup surfaces the auth abort correctly) - removed `test_set_yield_strategy_uninitialized_fails` (a constructor-only vault is always initialised; coverage now lives in the factory tests) - Fix factory tests: `get_refund_policy` returns `Option<Address>`, so wrap the expected policy in `Some(...)`. Verification: full workspace `cargo test` is green (19 ok, 0 failed); clippy is clean (-D warnings) on the vault, factory and policy crates; `cargo fmt` applied. Update .wasm-budget.json, ci.yml (cross-contract wasm build + size budget for the three refund contracts), CHANGELOG.md and deploy.sh (policy + factory deploy, then factory.deploy for the merchant vault). Note: `cargo clippy --all-targets -- -D warnings` still fails on two pre-existing lints outside this change (receipt-anchor u32 cast, and the same nonminimal_bool in fuzz_test that this branch already pinned) — both fail on the clean baseline under the local rust 1.96.0 toolchain.
|
@tecmalik 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! 🚀 |
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.
Closes #129
Title
feat(refund-vault): split into factory + stateless policy modules (#129)
Summary
Refactors RefundVault into a multi-contract architecture so refund-policy rules can evolve without redeploying (or re-auditing) the vault itself.
What changed
Tests & verification
Deployment / tooling
Provide a brief summary of the changes in this pull request and the problem being solved.
Contract Change Safety Checklist
Please verify that your changes adhere to contract stability requirements:
docs/EVENTS.md)CHANGELOG.md?DEPLOYMENTS.mdbeen documented?cargo test) and/or exercised on Soroban testnet?Related Issues
Closes #