Skip to content

Fix/issues 355 357 361 362#453

Merged
Junman140 merged 2 commits into
Pi-Defi-world:devfrom
Chinaza007:fix/issues-355-357-361-362
Jun 28, 2026
Merged

Fix/issues 355 357 361 362#453
Junman140 merged 2 commits into
Pi-Defi-world:devfrom
Chinaza007:fix/issues-355-357-361-362

Conversation

@Chinaza007

@Chinaza007 Chinaza007 commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

close #355
close #357
close #361
close #362

Summary by CodeRabbit

  • New Features
    • Added a shared, standardized contract error set with clear numeric codes for initialization, authorization, validation, and transfer failures.
  • Chores
    • Added automation scripts to help prepare, branch, commit, and push contract fixes more consistently.
    • Added pre-checks to reduce accidental runs with an unclean working tree or from the wrong location.

@coderabbitai

coderabbitai Bot commented Jun 27, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds shared/src/errors.rs defining a SharedError Soroban contracterror enum with seven explicit u32 error codes. Also adds two automation scripts (submit_fixes.sh and submit_fixes.bat) that copy pre-prepared Rust fix files into the repo, create a feature branch, commit, and push with PR creation instructions.

Changes

Shared Soroban Error Taxonomy

Layer / File(s) Summary
SharedError contracterror enum
shared/src/errors.rs
Defines SharedError as a #[contracterror] #[repr(u32)] enum with variants: AlreadyInitialized=1, NotInitialized=2, Unauthorized=3, InvalidAmount=4, InvalidAddress=5, TokenXferFailed=6, TransferFailed=7.

Fix-submission automation scripts

Layer / File(s) Summary
Bash automation script
submit_fixes.sh
Strict-mode Bash script with configurable BRANCH/REMOTE/BASE_BRANCH, ANSI logging helpers, pre-flight checks (git, curl, Cargo.toml, clean tree), fetch/branch creation, file copy with directory creation, conditional commit, push, and gh pr create guidance.
Windows batch automation script
submit_fixes.bat
Batch equivalent: defines variables, validates git/Cargo.toml/clean tree, fetches and creates or checks out the branch, copies fix files with existence checks, stages files, conditionally commits for issues #355/#357/#361/#362, pushes, and prints GitHub compare URL.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • Pi-Defi-world/acbu-smart-contract#190: Also introduces shared typed error enums with numeric codes aligned to per-contract error taxonomy, directly related to the SharedError addition in this PR.

Poem

🐇 Hop, hop — errors now have names and numbers too,
TokenXferFailed distinct from TransferFailed blue,
A batch and a shell script both ready to run,
Copying fixes and pushing — the branch has begun!
No more mystery failures, each code tells the tale. 🌟

🚥 Pre-merge checks | ✅ 1 | ❌ 4

❌ Failed checks (3 warnings, 1 inconclusive)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR adds a shared error enum and automation scripts, but the contract fixes for #355/#357/#361/#362 are not shown. Include the actual contract updates: preserve token transfer errors, add initialization guards, annotate event types, and dedupe require_auth calls.
Out of Scope Changes check ⚠️ Warning The batch/Bash branch-sync scripts are automation unrelated to the four issue fixes, so they are outside the PR's stated scope. Remove the submit_fixes scripts unless they are explicitly intended as part of the issue solution.
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title references the right issues, but it is generic and doesn't describe the actual change. Use a concise descriptive title, e.g. "Add shared error taxonomy and contract fix scripts for issues 355, 357, 361, 362".
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@drips-wave

drips-wave Bot commented Jun 27, 2026

Copy link
Copy Markdown

@Chinaza007 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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@submit_fixes.bat`:
- Around line 68-98: The copy/stage flow in submit_fixes.bat assumes every
target file exists, so update each copy block to verify the copy command
succeeded before printing success and before staging that file. Use the existing
acbu_escrow, acbu_minting, and shared errors blocks to track which files were
actually copied, then gate the git add step so it only stages files that were
successfully copied instead of always adding all three paths. If a source is
missing or copy fails, fail that file’s step explicitly rather than proceeding
with stale or nonexistent targets.
- Around line 54-63: The branch-handling logic in submit_fixes.bat reuses an
existing local branch instead of recreating it from the freshly fetched base,
which can leave stale history on %BRANCH%. Update the branch setup flow around
the git show-ref / git checkout block so that an existing local %BRANCH% is
replaced or reset to %REMOTE%/%BASE_BRANCH% before continuing, ensuring the
script always starts from the latest remote base rather than an old local fix
branch.
- Around line 1-131: Normalize submit_fixes.bat to CRLF so cmd.exe can parse
labels and control flow correctly, and update .gitattributes to enforce *.bat
text eol=crlf for all batch files. Make the change in the batch script itself
and in the repo’s attributes config so the formatting stays consistent going
forward.

In `@submit_fixes.sh`:
- Around line 48-57: The staging step contradicts the missing-file skip behavior
in copy_if_exists, since it still adds all expected paths even when a source was
skipped. Update the git add logic in submit_fixes.sh so it only stages files
that were actually copied or already exist, and avoid failing when a destination
is absent after copy_if_exists warned and continued. Use the copy_if_exists
helper and the later staging block together to gate git add on file presence.
- Around line 37-43: The branch handling in the script currently reuses an
existing local branch via git checkout, which can leave stale commits behind.
Update the logic around the branch creation flow so that when "$BRANCH" already
exists locally it either aborts with a clear message or explicitly resets it to
"$REMOTE/$BASE_BRANCH" before proceeding, rather than silently checking it out.
Use the existing info/warn checkout block and the "$BRANCH", "$REMOTE", and
"$BASE_BRANCH" symbols to locate the fix.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d83ea695-c9a0-47c4-bebb-f456098db0f7

📥 Commits

Reviewing files that changed from the base of the PR and between a05db92 and 04dca5b.

📒 Files selected for processing (3)
  • shared/src/errors.rs
  • submit_fixes.bat
  • submit_fixes.sh

Comment thread submit_fixes.bat
Comment on lines +1 to +131
@echo off
:: =============================================================================
:: submit_fixes.bat — ACBU smart contract fixes (#355, #357, #361, #362)
:: Usage: Double-click or run from a command prompt.
:: Run this from the ROOT of your local acbu-smart-contract clone.
:: =============================================================================

setlocal enabledelayedexpansion

:: ── Config ────────────────────────────────────────────────────────────────────
set BRANCH=fix/issues-355-357-361-362
set REMOTE=origin
set BASE_BRANCH=dev
:: Change BASE_BRANCH to "main" above if your repo uses main

:: ── Helpers ───────────────────────────────────────────────────────────────────
:: FIXES_DIR is relative to this script; adjust if you placed acbu-fixes elsewhere
set FIXES_DIR=%~dp0acbu-fixes

:: ── Pre-flight ────────────────────────────────────────────────────────────────
echo [INFO] Checking prerequisites...

where git >nul 2>&1
if errorlevel 1 (
echo [ERROR] git not found. Install Git for Windows: https://git-scm.com/
pause & exit /b 1
)

if not exist "Cargo.toml" (
echo [ERROR] Cargo.toml not found.
echo Run this script from the root of the acbu-smart-contract repo.
pause & exit /b 1
)

:: Check for uncommitted changes
git diff --quiet
if errorlevel 1 (
echo [ERROR] Working tree has uncommitted changes.
echo Stash or commit them before running this script.
pause & exit /b 1
)
git diff --cached --quiet
if errorlevel 1 (
echo [ERROR] Staged changes detected.
echo Commit or reset them before running this script.
pause & exit /b 1
)

:: ── Fetch & branch ────────────────────────────────────────────────────────────
echo [INFO] Fetching latest '%BASE_BRANCH%' from %REMOTE%...
git fetch %REMOTE% %BASE_BRANCH%
if errorlevel 1 ( echo [ERROR] git fetch failed & pause & exit /b 1 )

:: Check if branch already exists locally
git show-ref --quiet "refs/heads/%BRANCH%"
if errorlevel 1 (
echo [INFO] Creating branch '%BRANCH%' from %REMOTE%/%BASE_BRANCH%...
git checkout -b %BRANCH% %REMOTE%/%BASE_BRANCH%
) else (
echo [WARN] Branch '%BRANCH%' already exists — checking it out
git checkout %BRANCH%
)
if errorlevel 1 ( echo [ERROR] git checkout failed & pause & exit /b 1 )

:: ── Copy fixed files ──────────────────────────────────────────────────────────
echo [INFO] Copying fixed source files...

:: acbu_escrow
if exist "%FIXES_DIR%\acbu_escrow\src\lib.rs" (
if not exist "acbu_escrow\src" mkdir "acbu_escrow\src"
copy /Y "%FIXES_DIR%\acbu_escrow\src\lib.rs" "acbu_escrow\src\lib.rs" >nul
echo [INFO] Copied: acbu_escrow\src\lib.rs
) else (
echo [WARN] Not found, skipping: %FIXES_DIR%\acbu_escrow\src\lib.rs
)

:: acbu_minting
if exist "%FIXES_DIR%\acbu_minting\src\lib.rs" (
if not exist "acbu_minting\src" mkdir "acbu_minting\src"
copy /Y "%FIXES_DIR%\acbu_minting\src\lib.rs" "acbu_minting\src\lib.rs" >nul
echo [INFO] Copied: acbu_minting\src\lib.rs
) else (
echo [WARN] Not found, skipping: %FIXES_DIR%\acbu_minting\src\lib.rs
)

:: shared errors
if exist "%FIXES_DIR%\shared\src\errors.rs" (
if not exist "shared\src" mkdir "shared\src"
copy /Y "%FIXES_DIR%\shared\src\errors.rs" "shared\src\errors.rs" >nul
echo [INFO] Copied: shared\src\errors.rs
) else (
echo [WARN] Not found, skipping: %FIXES_DIR%\shared\src\errors.rs
)

:: ── Stage ─────────────────────────────────────────────────────────────────────
echo [INFO] Staging changes...
git add acbu_escrow\src\lib.rs acbu_minting\src\lib.rs shared\src\errors.rs
if errorlevel 1 ( echo [ERROR] git add failed & pause & exit /b 1 )

:: Check if there is anything to commit
git diff --cached --quiet
if not errorlevel 1 (
echo [WARN] Nothing new to commit — files may already be up to date
goto :push
)

:: ── Commit ────────────────────────────────────────────────────────────────────
echo [INFO] Committing...
git commit -m "fix: address issues #355 #357 #361 #362" -m "#357 — add AlreadyInitialized guard to initialize() in escrow & minting. Prevents re-initialisation from silently overwriting admin, fee rate, and token addresses." -m "#361 — add #[allow(dead_code)] to emit-only event structs. Suppresses spurious lint warnings so real dead-code issues are not masked." -m "#355 — differentiate token_client transfer errors. Switch from transfer() (panics) to try_transfer() (Result). TokenXferFailed for token-side rejections, TransferFailed for internal disbursements." -m "#362 — deduplicate require_auth when user == admin. New require_auth_dedup() helper skips the second auth charge when both addresses are identical."
if errorlevel 1 ( echo [ERROR] git commit failed & pause & exit /b 1 )

:push
:: ── Push ──────────────────────────────────────────────────────────────────────
echo [INFO] Pushing branch to %REMOTE%...
git push -u %REMOTE% %BRANCH%
if errorlevel 1 ( echo [ERROR] git push failed & pause & exit /b 1 )

:: ── Done ──────────────────────────────────────────────────────────────────────
echo.
echo [OK] Branch pushed successfully.
echo.
echo Next steps:
echo 1. Open a PR on GitHub:
echo https://github.com/Pi-Defi-world/acbu-smart-contract/compare/%BASE_BRANCH%...%BRANCH%
echo.
echo 2. Or, if you have the GitHub CLI installed:
echo gh pr create --base %BASE_BRANCH% --head %BRANCH% ^
echo --title "fix: address issues #355 #357 #361 #362" ^
echo --body-file acbu-fixes\FIX_SUMMARY.md
echo.
pause

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
python - <<'PY'
from pathlib import Path
data = Path("submit_fixes.bat").read_bytes()
print("CRLF count:", data.count(b"\r\n"))
print("LF count:", data.count(b"\n"))
print("LF-only newlines present:", b"\n" in data.replace(b"\r\n", b""))
PY

Repository: Pi-Defi-world/acbu-smart-contract

Length of output: 230


🌐 Web query:

cmd.exe batch file LF-only line endings CRLF required behavior

💡 Result:

Windows Batch files (.bat and.cmd) officially require CRLF (Carriage Return + Line Feed, \r\n) line endings to function reliably [1][2][3]. While scripts using only LF (Line Feed, \n) may appear to work in simple scenarios, they are prone to erratic behavior and critical failures [1][2]. The primary technical risks of using LF-only line endings include: 1. Label Lookup Failures: cmd.exe parses batch files in 512-byte chunks [2][4]. When a file uses LF-only, the parser can miscalculate the position of labels (e.g., :myLabel), leading to the error: "The system cannot find the batch label specified" [5][2][4]. This often occurs when a label crosses or aligns near a 512-byte boundary [5][4]. 2. Unpredictable Execution: Because the command interpreter expects CRLF to properly identify line boundaries, LF-only files may cause the interpreter to consume multiple lines as a single command, leading to syntax errors or unexpected execution logic [1][2]. 3. Parsing Anomalies: Complex batch scripts, particularly those involving loops, complex conditional logic, or multi-byte characters (like UTF-8), are highly susceptible to breakage when LF endings are used [2][3]. For cross-platform development (e.g., using Git), it is strongly recommended to enforce CRLF line endings for batch files to prevent these issues [6][7]. This can be accomplished by creating or updating a.gitattributes file in the repository root: *.bat text eol=crlf *.cmd text eol=crlf Adopting this practice ensures that files are converted to the required CRLF format automatically upon checkout on Windows, maintaining compatibility with cmd.exe [6][4].

Citations:


Normalize this batch file to CRLF, and enforce *.bat text eol=crlf in .gitattributes. submit_fixes.bat is LF-only, which can make cmd.exe misparse labels and control flow on Windows.

🧰 Tools
🪛 Blinter (1.0.112)

[error] 1-1: Unix line endings detected. Explanation: Batch file uses Unix line endings (LF-only) which can cause GOTO/CALL label parsing failures and script malfunction due to Windows batch parser 512-byte boundary bugs. Recommendation: Convert file to Windows line endings (CRLF). Use tools like dos2unix, notepad++, or configure git with 'git config core.autocrlf true'. Context: File uses Unix line endings (LF-only) - 131 LF sequences found

(E018)


[error] 11-11: Unsafe SET command usage. Explanation: SET commands without proper validation or quoting can cause security issues. Recommendation: Always quote SET values and validate input: SET "var=safe value". Context: SET command value should be quoted for safety

(SEC002)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@submit_fixes.bat` around lines 1 - 131, Normalize submit_fixes.bat to CRLF so
cmd.exe can parse labels and control flow correctly, and update .gitattributes
to enforce *.bat text eol=crlf for all batch files. Make the change in the batch
script itself and in the repo’s attributes config so the formatting stays
consistent going forward.

Source: Linters/SAST tools

Comment thread submit_fixes.bat
Comment on lines +54 to +63
:: Check if branch already exists locally
git show-ref --quiet "refs/heads/%BRANCH%"
if errorlevel 1 (
echo [INFO] Creating branch '%BRANCH%' from %REMOTE%/%BASE_BRANCH%...
git checkout -b %BRANCH% %REMOTE%/%BASE_BRANCH%
) else (
echo [WARN] Branch '%BRANCH%' already exists — checking it out
git checkout %BRANCH%
)
if errorlevel 1 ( echo [ERROR] git checkout failed & pause & exit /b 1 )

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Don't keep working on an old local fix branch.

If %BRANCH% already exists locally, this path reuses whatever history is on it instead of recreating it from the freshly fetched %REMOTE%/%BASE_BRANCH%. That can push unrelated or stale commits into the PR.

Suggested fix
 :: Check if branch already exists locally
 git show-ref --quiet "refs/heads/%BRANCH%"
-if errorlevel 1 (
-    echo [INFO] Creating branch '%BRANCH%' from %REMOTE%/%BASE_BRANCH%...
-    git checkout -b %BRANCH% %REMOTE%/%BASE_BRANCH%
-) else (
-    echo [WARN] Branch '%BRANCH%' already exists — checking it out
-    git checkout %BRANCH%
+if not errorlevel 1 (
+    echo [ERROR] Local branch '%BRANCH%' already exists. Delete it or reset it to %REMOTE%/%BASE_BRANCH% before rerunning.
+    pause & exit /b 1
 )
+echo [INFO] Creating branch '%BRANCH%' from %REMOTE%/%BASE_BRANCH%...
+git checkout -b %BRANCH% %REMOTE%/%BASE_BRANCH%
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
:: Check if branch already exists locally
git show-ref --quiet "refs/heads/%BRANCH%"
if errorlevel 1 (
echo [INFO] Creating branch '%BRANCH%' from %REMOTE%/%BASE_BRANCH%...
git checkout -b %BRANCH% %REMOTE%/%BASE_BRANCH%
) else (
echo [WARN] Branch '%BRANCH%' already exists — checking it out
git checkout %BRANCH%
)
if errorlevel 1 ( echo [ERROR] git checkout failed & pause & exit /b 1 )
:: Check if branch already exists locally
git show-ref --quiet "refs/heads/%BRANCH%"
if not errorlevel 1 (
echo [ERROR] Local branch '%BRANCH%' already exists. Delete it or reset it to %REMOTE%/%BASE_BRANCH% before rerunning.
pause & exit /b 1
)
echo [INFO] Creating branch '%BRANCH%' from %REMOTE%/%BASE_BRANCH%...
git checkout -b %BRANCH% %REMOTE%/%BASE_BRANCH%
if errorlevel 1 ( echo [ERROR] git checkout failed & pause & exit /b 1 )
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@submit_fixes.bat` around lines 54 - 63, The branch-handling logic in
submit_fixes.bat reuses an existing local branch instead of recreating it from
the freshly fetched base, which can leave stale history on %BRANCH%. Update the
branch setup flow around the git show-ref / git checkout block so that an
existing local %BRANCH% is replaced or reset to %REMOTE%/%BASE_BRANCH% before
continuing, ensuring the script always starts from the latest remote base rather
than an old local fix branch.

Comment thread submit_fixes.bat
Comment on lines +68 to +98
:: acbu_escrow
if exist "%FIXES_DIR%\acbu_escrow\src\lib.rs" (
if not exist "acbu_escrow\src" mkdir "acbu_escrow\src"
copy /Y "%FIXES_DIR%\acbu_escrow\src\lib.rs" "acbu_escrow\src\lib.rs" >nul
echo [INFO] Copied: acbu_escrow\src\lib.rs
) else (
echo [WARN] Not found, skipping: %FIXES_DIR%\acbu_escrow\src\lib.rs
)

:: acbu_minting
if exist "%FIXES_DIR%\acbu_minting\src\lib.rs" (
if not exist "acbu_minting\src" mkdir "acbu_minting\src"
copy /Y "%FIXES_DIR%\acbu_minting\src\lib.rs" "acbu_minting\src\lib.rs" >nul
echo [INFO] Copied: acbu_minting\src\lib.rs
) else (
echo [WARN] Not found, skipping: %FIXES_DIR%\acbu_minting\src\lib.rs
)

:: shared errors
if exist "%FIXES_DIR%\shared\src\errors.rs" (
if not exist "shared\src" mkdir "shared\src"
copy /Y "%FIXES_DIR%\shared\src\errors.rs" "shared\src\errors.rs" >nul
echo [INFO] Copied: shared\src\errors.rs
) else (
echo [WARN] Not found, skipping: %FIXES_DIR%\shared\src\errors.rs
)

:: ── Stage ─────────────────────────────────────────────────────────────────────
echo [INFO] Staging changes...
git add acbu_escrow\src\lib.rs acbu_minting\src\lib.rs shared\src\errors.rs
if errorlevel 1 ( echo [ERROR] git add failed & pause & exit /b 1 )

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Fail the copy/stage step per file instead of assuming every target exists.

Each copy block prints success without checking copy's exit code, and Lines 97-98 then stage all three paths even when an earlier block printed “skipping”. That either stages stale files or aborts on a missing path.

Suggested fix
+set COPIED_ANY=
+
 :: acbu_escrow
 if exist "%FIXES_DIR%\acbu_escrow\src\lib.rs" (
     if not exist "acbu_escrow\src" mkdir "acbu_escrow\src"
     copy /Y "%FIXES_DIR%\acbu_escrow\src\lib.rs" "acbu_escrow\src\lib.rs" >nul
+    if errorlevel 1 ( echo [ERROR] copy failed for acbu_escrow\src\lib.rs & pause & exit /b 1 )
+    git add "acbu_escrow\src\lib.rs"
+    if errorlevel 1 ( echo [ERROR] git add failed for acbu_escrow\src\lib.rs & pause & exit /b 1 )
+    set COPIED_ANY=1
     echo [INFO] Copied: acbu_escrow\src\lib.rs
 ) else (
     echo [WARN] Not found, skipping: %FIXES_DIR%\acbu_escrow\src\lib.rs
 )
@@
-echo [INFO] Staging changes...
-git add acbu_escrow\src\lib.rs acbu_minting\src\lib.rs shared\src\errors.rs
-if errorlevel 1 ( echo [ERROR] git add failed & pause & exit /b 1 )
+if not defined COPIED_ANY (
+    echo [WARN] No fix files were copied
+    goto :push
+)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@submit_fixes.bat` around lines 68 - 98, The copy/stage flow in
submit_fixes.bat assumes every target file exists, so update each copy block to
verify the copy command succeeded before printing success and before staging
that file. Use the existing acbu_escrow, acbu_minting, and shared errors blocks
to track which files were actually copied, then gate the git add step so it only
stages files that were successfully copied instead of always adding all three
paths. If a source is missing or copy fails, fail that file’s step explicitly
rather than proceeding with stale or nonexistent targets.

Comment thread submit_fixes.sh
Comment on lines +37 to +43
info "Creating branch '$BRANCH' from $REMOTE/$BASE_BRANCH..."
if git show-ref --quiet "refs/heads/$BRANCH"; then
warn "Branch '$BRANCH' already exists locally — checking it out"
git checkout "$BRANCH"
else
git checkout -b "$BRANCH" "$REMOTE/$BASE_BRANCH"
fi

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Don't silently reuse an existing local fix branch.

If this branch already has local commits or is behind origin/dev, rerunning the script produces a PR from stale ancestry instead of a fresh branch from the fetched base. Abort here or explicitly reset the branch to $REMOTE/$BASE_BRANCH.

Suggested fix
 info "Creating branch '$BRANCH' from $REMOTE/$BASE_BRANCH..."
 if git show-ref --quiet "refs/heads/$BRANCH"; then
-  warn "Branch '$BRANCH' already exists locally — checking it out"
-  git checkout "$BRANCH"
-else
-  git checkout -b "$BRANCH" "$REMOTE/$BASE_BRANCH"
+  die "Local branch '$BRANCH' already exists. Delete it or reset it to $REMOTE/$BASE_BRANCH before rerunning."
 fi
+git checkout -b "$BRANCH" "$REMOTE/$BASE_BRANCH"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
info "Creating branch '$BRANCH' from $REMOTE/$BASE_BRANCH..."
if git show-ref --quiet "refs/heads/$BRANCH"; then
warn "Branch '$BRANCH' already exists locally — checking it out"
git checkout "$BRANCH"
else
git checkout -b "$BRANCH" "$REMOTE/$BASE_BRANCH"
fi
info "Creating branch '$BRANCH' from $REMOTE/$BASE_BRANCH..."
if git show-ref --quiet "refs/heads/$BRANCH"; then
die "Local branch '$BRANCH' already exists. Delete it or reset it to $REMOTE/$BASE_BRANCH before rerunning."
fi
git checkout -b "$BRANCH" "$REMOTE/$BASE_BRANCH"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@submit_fixes.sh` around lines 37 - 43, The branch handling in the script
currently reuses an existing local branch via git checkout, which can leave
stale commits behind. Update the logic around the branch creation flow so that
when "$BRANCH" already exists locally it either aborts with a clear message or
explicitly resets it to "$REMOTE/$BASE_BRANCH" before proceeding, rather than
silently checking it out. Use the existing info/warn checkout block and the
"$BRANCH", "$REMOTE", and "$BASE_BRANCH" symbols to locate the fix.

Comment thread submit_fixes.sh
Comment on lines +48 to +57
copy_if_exists() {
local src="$1" dst="$2"
if [ -f "$src" ]; then
mkdir -p "$(dirname "$dst")"
cp "$src" "$dst"
info "Copied: $dst"
else
warn "Source not found, skipping: $src"
fi
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

git add contradicts the “skip missing fix” path.

copy_if_exists warns and continues when a source file is absent, but Lines 66-69 still stage all three paths unconditionally. If a skipped destination does not already exist, git add fails and the script exits anyway.

Suggested fix
+copied_files=()
+
 copy_if_exists() {
   local src="$1" dst="$2"
   if [ -f "$src" ]; then
     mkdir -p "$(dirname "$dst")"
     cp "$src" "$dst"
+    copied_files+=("$dst")
     info "Copied: $dst"
   else
     warn "Source not found, skipping: $src"
   fi
 }
@@
 info "Staging changes..."
-git add \
-  acbu_escrow/src/lib.rs \
-  acbu_minting/src/lib.rs \
-  shared/src/errors.rs
+if ((${`#copied_files`[@]})); then
+  git add -- "${copied_files[@]}"
+else
+  warn "No fix files were copied"
+fi

Also applies to: 64-73

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@submit_fixes.sh` around lines 48 - 57, The staging step contradicts the
missing-file skip behavior in copy_if_exists, since it still adds all expected
paths even when a source was skipped. Update the git add logic in
submit_fixes.sh so it only stages files that were actually copied or already
exist, and avoid failing when a destination is absent after copy_if_exists
warned and continued. Use the copy_if_exists helper and the later staging block
together to gate git add on file presence.

@Junman140 Junman140 merged commit ab416ca into Pi-Defi-world:dev Jun 28, 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

2 participants