Repository navigation
fix: contract error handling, referral auth ownership, and CI caching improvements - #1686
Merged
Junirezz merged 3 commits intoOct 19, 2026
Conversation
… improvements - Contract (Junirezz#1634): Remove panics reachable from public entry points (pause/unpause role checks, emergency cancellation/dispute window, withdrawal validation, and balance snapshots) and update set_strategy doc to specify Err(VaultError::StrategyNotWhitelisted). - Backend (Junirezz#1603): Add requireAuth support in tenantGuard; enforce ownership and authentication on referral stats and referral code endpoints; convert GET /code/:wallet to read-only returning 404 if not found; add dedicated POST /code/:wallet code creation endpoint with admin bypass. - Config & CLI (Junirezz#1599): Migrate non-secret configurations (BASE_URL, ASSET, AMOUNT, METRICS_PATH, RPC URLs, Passphrase, Contract IDs) to vars.* with fallback; stop passing VERCEL_TOKEN via command-line arguments and pass via environment variables. - CI Caching (Junirezz#1598): Replace slow cargo install invocations with taiki-e/install-action; configure dependency caching with setup-node across CI workflows. Closes Junirezz#1634 Closes Junirezz#1603 Closes Junirezz#1599 Closes Junirezz#1598
|
@ayomideadeniran 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.
Summary of Changes
This pull request resolves four issues across contract error handling, backend referral authorization, workflow secrets & CLI security, and CI caching optimizations.
1. Contract Error Handling & Documentation (#1634)
YieldVault::pause_with_roleandunpause_with_role: replaced panic assertions withpermissions::require_pauser_or_admin_authreturningResult<(), VaultError>, mapping unauthorized callers cleanly toVaultError::RescueUnauthorized.YieldVault::cancel_emergency_action: replacedexpect("Admin not set")andassert!(!proposal.executed)with cleanok_orchecks andVaultError::ProposalAlreadyExecuted.YieldVault::set_emergency_dispute_window: returnsResult<(), VaultError>, validating thatseconds > 0and returningErr(VaultError::InvalidAmount)instead of panicking viaassert!.YieldVault::snapshot_user_balance: returnsResult<(), VaultError>, safely matchingCheckpointNonceinstead of panicking onexpect("no checkpoint").YieldVault::execute_withdrawal: re-validates that the user's current share balance is sufficient (balance >= pending.shares) and positive before executing the transfer.YieldVault::do_withdraw: safely looks upTokenAssetwithok_orrather than unwrap.YieldVault::set_strategy: replacedexpect("Admin not set")andchecked_add().expect("overflow")withok_orand saturating arithmetic.set_strategydocstring under# Errorsto correctly reflect returningErr(VaultError::StrategyNotWhitelisted)when the strategy is not whitelisted.2. Backend Referral Authorization & Endpoints (#1603)
tenantGuardMiddleware Enhancement:requireAuth: booleanoption totenantGuard. When enabled, requests without an authenticated wallet (or admin API key) are rejected with401 Unauthorized({ error: 'Unauthorized', status: 401, message: 'Authentication required' }).403 Forbidden.Permission.ADMIN_READbypass the check as expected.GET /api/v1/referrals/:wallet: protected bytenantGuardwithrequireAuth: trueand admin bypass.GET /api/v1/referrals/code/:wallet: converted to a pure read-only endpoint usingreferralService.getReferralCode(wallet). Returns404 Not Foundif no referral code has been created for the wallet (avoiding side-effect writes on GET requests). Protected withtenantGuard({ requireAuth: true }).POST /api/v1/referrals/code/:wallet: added dedicated code-creation endpoint invokingreferralService.getOrCreateReferralCode(wallet), protected bytenantGuard({ requireAuth: true }).3. Workflow Secret & Command-Line Security (#1599)
.github/workflows/load-tests.yml: migratedBASE_URL,ASSET,AMOUNT, andMETRICS_PATHfromsecrets.*tovars.*with fallback tosecrets.*and sensible defaults..github/workflows/production-deploy.yml: migratedVITE_SOROBAN_RPC_URL,VITE_STELLAR_NETWORK_PASSPHRASE,VITE_VAULT_CONTRACT_ID,VITE_API_BASE_URL, andVITE_SENTRY_DSNfromsecrets.*tovars.*with fallback..github/workflows/production-deploy.yml: removed--token=${{ secrets.VERCEL_TOKEN }}from CLI invocations (vercel pullandvercel deploy), avoiding token leakage into process tables and shell logs. PassedVERCEL_TOKENsecurely via theenv:block where Vercel CLI natively reads it.4. CI Dependency & Tool Caching (#1598)
cargo installcommands withtaiki-e/install-actionacross CI workflows:cargo-auditindependency-security.ymlandrust-security.yml.cargo-denyinrust-security.yml.cargo-fuzzinrust-wasm.yml.soroban-cliinstaging-deploy.yml.actions/setup-node@v4withcache: npmand appropriatecache-dependency-pathacrosstest-coverage.yml,staging-deploy.yml, andrust-wasm.yml.Verification & Testing
cargo check -p vaultandcargo test -p share-price-math(12 tests passing).tenantGuard.ts,referralEndpoints.ts, andreferralService.ts.Closes #1634
Closes #1603
Closes #1599
Closes #1598