Skip to content

Add manual refunds to the Miden example - #19

Open
Man-Jain wants to merge 2 commits into
mainfrom
codex/manual-refund-example
Open

Man-Jain wants to merge 2 commits into
mainfrom
codex/manual-refund-example

Conversation

@Man-Jain

@Man-Jain Man-Jain commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add a manual refund panel to Withdraw to Miden that lists Compacts for the connected sponsor.
  • Request and validate allocator calldata, then submit the refund from the sponsor wallet on the source chain.

Requires the manual refund endpoint from epochprotocol/smallocator#87.

Verification

  • npm test (6 passed)
  • npm run typecheck
  • ESLint on the changed TypeScript files

@vercel

vercel Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
miden-integration-example Error Error Nov 28, 2026 7:45am UTC

@github-actions

github-actions Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

React Doctor found 3 new issues in 1 file · 3 warnings · score 82 / 100 (Needs work) · 0 fixed · vs main

3 warnings

src/components/crosschain/ManualRefund.tsx

  • ⚠️ L28 React function has high control-flow complexity no-high-complexity-react-function
  • ⚠️ L57 Mutation without cache invalidation query-mutation-missing-invalidation
  • ⚠️ L72 fetch Response consumed without status check no-fetch-response-used-without-status-check

Reviewed by React Doctor for commit 845666a. See inline comments for fixes.

compact: { nonce: string; sponsor: string };
};

export function ManualRefund() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

React Doctor · react-doctor/no-high-complexity-react-function (warning)

ManualRefund has cyclomatic complexity 16, cognitive complexity 33, and maximum nesting depth 6, so its React logic is hard to understand and change. Extract independent branches into components or hooks.

Fix → Extract independent render branches and state logic into focused components or hooks until the control flow is easy to follow.

Docs

const selected = intents.data?.find(
(intent) => `${intent.chainId}:${intent.hash}` === selection,
);
const refund = useMutation({

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

React Doctor · react-doctor/query-mutation-missing-invalidation (warning)

useMutation with no cache update here can leave your users looking at stale data after it runs.

Fix → Add onSuccess: () => queryClient.invalidateQueries({ queryKey: ['...'] }) so cached data stays in sync after the mutation

Docs

`Switch your wallet to ${getTestnetChainName(chainId)}.`,
);
}
const response = await fetch(`${allocator}/manual-refund-calldata`, {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

React Doctor · react-doctor/no-fetch-response-used-without-status-check (warning)

fetch() resolves (does not reject) on HTTP 4xx/5xx, so this unchecked body read may treat an HTTP error payload like a successful response. Check response.ok/response.status, or deliberately handle the API's error payload, before reading the body.

Fix → Check response.ok (or response.status) before consuming a fetch Response with .json()/.text()/.blob(). fetch resolves on HTTP 4xx/5xx, so an unchecked response parses the error body as success or crashes on an always-truthy guard.

Docs

This branch had an error being deployed

1 failed deployment
Preview — 845666a1 Deployed Nov 28, 2026 by vercel[bot]
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.

1 participant