Skip to content

chore: Replace axios with native Node.js fetch#3134

Closed
nicholaspai wants to merge 8 commits intomasterfrom
remove-axios
Closed

chore: Replace axios with native Node.js fetch#3134
nicholaspai wants to merge 8 commits intomasterfrom
remove-axios

Conversation

@nicholaspai
Copy link
Copy Markdown
Member

Summary

  • Removed all axios imports and usage across 10 files in the codebase
  • Replaced with native Node.js fetch API throughout:
    • axios.get()fetch() with response status checks
    • axios.post()fetch() with method: "POST" and JSON.stringify()
    • axios.isAxiosError() → HTTP status code checks on the response
    • Axios timeout config → AbortSignal.timeout()
    • Axios params config → URLSearchParams appended to URL
    • RawAxiosRequestHeaders / AxiosError types → Record<string, string> / Error
  • Removed axios from package.json dependencies and updated yarn.lock

Files changed

  • src/utils/BridgeUtils.ts — GET/POST with retry logic
  • src/utils/CCTPUtils.ts — Circle CCTP attestation fetches
  • src/utils/OFTUtils.ts — LayerZero transaction details
  • src/clients/AcrossApiBaseClient.ts — Base API client with timeout/params/auth
  • src/clients/AcrossAPIClient.ts — Liquid reserves fetching
  • src/finalizer/utils/scroll.ts — Scroll unclaimed withdrawals API
  • src/finalizer/utils/helios.ts — ZK proof API (GET/POST with 404 handling)
  • src/refiller/Refiller.ts — Native markets API (addresses, transfer routes)
  • scripts/simulateFill.ts — Tenderly simulation API
  • scripts/fetchInventoryConfig.ts — Configurama config fetching

Test plan

  • Verify tsc --noEmit passes (confirmed locally)
  • Run unit tests to verify no regressions
  • Deploy to staging and verify API calls work end-to-end (CCTP, Scroll finalizer, Helios finalizer, refiller, etc.)

🤖 Generated with Claude Code

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7a6ecaa152

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

nicholaspai and others added 2 commits March 31, 2026 09:51
Avoid parsing body and caching all-zero reserves when the liquid-reserves
API returns a non-2xx status (e.g. 429/5xx transient failures).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Paul <108695806+pxrl@users.noreply.github.com>
}

// No axios error, process `proofState`
proofState = (await getResponse.json()) as ProofStateResponse;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We probably want to follow up and check how to validate types on this. I'm not really sure why it wasn't required for; perhaps the return was typed as any 🤔

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The ProofStateResponse type from src/interfaces/ZkApi.ts is already well-defined with typed status, update_calldata, and error_message fields. The as ProofStateResponse cast on the response.json() result gives us the same type safety as the prior axios.get<ProofStateResponse> generic — both are essentially trust-the-server assertions since neither validates at runtime. If we want true runtime validation we'd need a schema library (zod, etc), but that's a bigger lift.

Copy link
Copy Markdown
Collaborator

@pxrl pxrl left a comment

Choose a reason for hiding this comment

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

@nicholaspai I wonder if we should be wrapping fetch to accept generic typing hints supplied by the caller. It might make our use of fetch a bit more consistent. Not sure if it's the right approach though.

@nicholaspai
Copy link
Copy Markdown
Member Author

@codex

@nicholaspai nicholaspai requested a review from pxrl March 31, 2026 08:20
- Use isDefined() instead of manual null/undefined check in AcrossApiBaseClient
- Remove unused stringifyThrownValue import in helios.ts
- Add proper types for Native Markets API responses in Refiller (remove `any`)
- Add proper type for Tenderly simulation response in simulateFill
- Skip caching all-zero reserves in AcrossAPIClient to avoid persisting
  bad data from transient API failures

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b9e39a45e5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

nicholaspai and others added 2 commits March 31, 2026 10:37
Resolve yarn.lock conflict by regenerating lockfile.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Comment on lines 27 to 36
try {
const response = await axios.get(url, { headers, responseType: "text", timeout: 30000 });
return response.data as string;
const response = await fetch(url, {
headers,
signal: AbortSignal.timeout(30000),
});
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
}
return await response.text();
} catch (error) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

wdyt about getting rid of this try/catch construction? fetch won't throw by default so it's basically artificial that we're setting up the try/catch loop and then are the sole reason for it to throw. i.e. it should be possible to just evaluate response.status directly, rather than doing string comparisons on error.message.

@nicholaspai
Copy link
Copy Markdown
Member Author

#3142

@nicholaspai nicholaspai closed this Apr 2, 2026
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.

2 participants