Skip to content

Conversation

@vignesha22
Copy link
Contributor

@vignesha22 vignesha22 commented Dec 9, 2025

Description

  • Skips the getDeposit fn for all testnets
  • While creating an apiKey or modifying an apiKey adding default supportedNetworks as null to make it use only config.json available in order to make the system flexible with addition or removal of networks

Types of changes

What types of changes does your code introduce?

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Other (please describe):

Further comments (optional)

Summary by CodeRabbit

  • Release 4.2.2

    • Minor backend release with configuration and pricing updates.
  • Bug Fixes

    • Fixed type handling for network pricing data.
    • Improved testnet detection in deposit monitoring to skip testnet checks.
    • Ensured numeric chainId handling in sponsorship policy queries.
  • Improvements

    • API keys now default to configured networks (existing DB supportedNetworks set to null).
    • Added explicit network configuration support and strengthened utility type annotations.
    • Initialized a token-pricing repository to improve price retrieval.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 9, 2025

Walkthrough

Type and interface refinements in Paymaster price handling, Fastify plugin decoration with a Coingecko repository, admin API now persists supportedNetworks as null, a testnet early-return in deposit monitoring, chainId numeric conversion, several return-type/constant renames, a DB migration to set supported networks to null, and a package/version bump.

Changes

Cohort / File(s) Summary
Paymaster types & logic
backend/src/paymaster/index.ts
TokenPriceAndMetadata.ethPrice changed from anystring; NativeCurrencyPricyCache renamed → NativeCurrencyPriceCache; Paymaster.nativeCurrencyPrice Map type updated and ethPrice assignments coerced/stored as strings; minor import reordering.
Fastify plugin — Coingecko repo
backend/src/plugins/sequelizePlugin.ts
Module augmentation adds coingeckoRepo: CoingeckoTokensRepository to FastifyInstance; plugin initializes and decorates the server with a CoingeckoTokensRepository instance.
Admin API defaults
backend/src/routes/admin-routes.ts, backend/migrations/...-update-supported-network-to-null.cjs
Creation/update paths now persist supportedNetworks as null (so config.json defaults apply); new Sequelize migration sets SUPPORTED_NETWORKS = NULL for all api_keys rows.
Sponsorship route type fix
backend/src/routes/sponsorship-policy-routes.ts
Convert route chainId to number before repository call to ensure numeric type.
Server constant rename
backend/src/server.ts
Renamed defaultThrustholdValuedefaultThresholdValue and updated all usages.
Utility return types & NetworkConfig
backend/src/utils/common.ts, backend/src/utils/interface.ts
Added explicit return types to multiple utility functions and introduced exported NetworkConfig interface; getNetworkConfig may return null when not found.
Monitor — testnet shortcut
backend/src/utils/monitorTokenPaymaster.ts
Added early return in checkDeposit when bundlerUrl contains 'testnet', skipping external deposit call.
Changelog & version bump
backend/CHANGELOG.md, backend/package.json
Added changelog entry for 4.2.2 and bumped backend package version to 4.2.2.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–30 minutes

  • Paymaster type/name changes (type coercions and Map key/value rename) — verify runtime serialization and consumers.
  • Sequelize plugin augmentation — check lifecycle, DI, and places using server.coingeckoRepo.
  • Admin route + migration — confirm migration intent and downstream expectations for supportedNetworks === null.
  • Utility return-type tightening and new NetworkConfig — ensure callers handle null and updated signatures.
  • Monitor testnet early-return — validate cron/monitoring assumptions for testnet deployments.

Files to pay special attention to:

  • backend/src/paymaster/index.ts
  • backend/src/plugins/sequelizePlugin.ts
  • backend/src/routes/admin-routes.ts
  • backend/migrations/20251209000001-update-supported-network-to-null.cjs
  • backend/src/utils/common.ts and backend/src/utils/interface.ts

Possibly related PRs

Suggested reviewers

  • nikhilkumar1612
  • ch4r10t33r
  • cryptonoyaiba

Poem

🐰 I hopped through types and fixed a name,
Prices turned to strings — tidy and tame.
A Coingecko friend now sits on the server's chair,
Testnet skips the trip — light paws in the air.
Thump-thump — version bumped, and I nibble a carrot near.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix/Skip getDeposit' is partially related to the changeset, referring to skipping getDeposit for testnets, but misses the more significant change of setting supportedNetworks to null and other refactoring work.
Description check ✅ Passed The description covers the main objectives and includes the required 'Types of changes' section with appropriate selections, meeting template requirements.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch Bug_Fixes

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 and usage tips.

Copy link
Member

@ch4r10t33r ch4r10t33r left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6150e29 and b7b98b6.

📒 Files selected for processing (7)
  • backend/src/paymaster/index.ts (6 hunks)
  • backend/src/plugins/sequelizePlugin.ts (1 hunks)
  • backend/src/routes/admin-routes.ts (3 hunks)
  • backend/src/routes/sponsorship-policy-routes.ts (1 hunks)
  • backend/src/server.ts (6 hunks)
  • backend/src/utils/common.ts (3 hunks)
  • backend/src/utils/monitorTokenPaymaster.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
backend/src/plugins/sequelizePlugin.ts (1)
backend/src/repository/coingecko-token-repository.ts (1)
  • CoingeckoTokensRepository (4-40)
backend/src/server.ts (1)
backend/src/utils/monitorTokenPaymaster.ts (1)
  • checkDeposit (6-25)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (5)
backend/src/server.ts (1)

43-43: LGTM! Typo correction applied consistently.

The constant name has been corrected from defaultThrustholdValue to defaultThresholdValue, and all references throughout the file (lines 317, 338, 352, 362, 371) have been updated accordingly.

backend/src/plugins/sequelizePlugin.ts (1)

81-82: LGTM! CoingeckoTokensRepository properly integrated.

The new coingeckoRepo repository has been correctly:

  • Instantiated with the Sequelize connection
  • Decorated on the Fastify instance
  • Added to the FastifyInstance interface for type safety

The implementation follows the established pattern used for other repositories in this file.

Also applies to: 103-103

backend/src/paymaster/index.ts (2)

55-55: LGTM! Type safety improvements and typo correction.

The changes improve code quality:

  1. Line 55: ethPrice type changed from any to string for better type safety
  2. Line 64: Interface name corrected from NativeCurrencyPricyCache to NativeCurrencyPriceCache
  3. Line 99: Map declaration updated to use the corrected interface name

These changes eliminate the use of any and fix a spelling error, both of which improve code maintainability.

Also applies to: 64-64, 99-99


682-682: Explicit type casts align with ethPrice type refinement.

The explicit casts to string on lines 682 and 922 are consistent with the ethPrice type change from any to string in the TokenPriceAndMetadata interface. This ensures type safety throughout the codebase.

Also applies to: 922-922

backend/src/routes/sponsorship-policy-routes.ts (1)

152-152: LGTM! Numeric type conversion ensures consistency.

The explicit conversion to Number(chainId) before passing to the repository is correct and consistent with similar patterns used elsewhere in this file (lines 103, 191). This ensures the repository receives the expected numeric type rather than a string from the request parameters.

@ch4r10t33r
Copy link
Member

fix the CI @vignesha22

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Dec 9, 2025

Deploying arka with  Cloudflare Pages  Cloudflare Pages

Latest commit: da33185
Status: ✅  Deploy successful!
Preview URL: https://731f2359.arka-3qg.pages.dev
Branch Preview URL: https://bug-fixes.arka-3qg.pages.dev

View logs

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (1)
backend/src/utils/monitorTokenPaymaster.ts (1)

8-11: Testnet detection remains fragile despite added logging.

While the logging addition addresses observability concerns from the previous review, the string-matching approach bundlerUrl.includes('testnet') still has reliability issues:

  • False positives remain possible with URLs containing "testnet" in unexpected contexts
  • Maintenance burden when bundler URL patterns change

The previous review suggested more robust alternatives that haven't been implemented:

  • Maintaining a list of testnet chainIds
  • Using a configuration flag per network
  • Matching against known testnet bundler domains

Consider implementing chainId-based detection using the NetworkConfig interface now available in the codebase:

// Example: Define testnet chainIds
const TESTNET_CHAIN_IDS = new Set([
  80001, // Polygon Mumbai
  11155111, // Sepolia
  421614, // Arbitrum Sepolia
  // ... add other testnets
]);

export async function checkDeposit(paymasterAddress: string, bundlerUrl: string, webhookUrl: string, thresholdValue: string, chainId: number, log: FastifyBaseLogger) {
  try {
    if (TESTNET_CHAIN_IDS.has(chainId)) {
      log.info(`Skipping deposit check for testnet chainId ${chainId}, address: ${paymasterAddress}`);
      return;
    }
    // ... rest of function

This approach is deterministic and eliminates false positives from URL parsing.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b7b98b6 and 48b17f4.

📒 Files selected for processing (5)
  • backend/CHANGELOG.md (1 hunks)
  • backend/package.json (1 hunks)
  • backend/src/utils/common.ts (3 hunks)
  • backend/src/utils/interface.ts (1 hunks)
  • backend/src/utils/monitorTokenPaymaster.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
backend/src/utils/monitorTokenPaymaster.ts (1)
frontend/src/components/Dashboard.jsx (1)
  • chainId (92-92)
backend/src/utils/common.ts (1)
backend/src/utils/interface.ts (1)
  • NetworkConfig (22-31)
🪛 markdownlint-cli2 (0.18.1)
backend/CHANGELOG.md

2-2: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Above

(MD022, blanks-around-headings)


2-2: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (5)
backend/package.json (1)

3-3: LGTM! Version bump aligns with the changelog.

The version increment from 4.2.1 to 4.2.2 is appropriate for this bugfix release.

backend/CHANGELOG.md (1)

2-5: Changelog content accurately reflects the changes.

The changelog entry correctly documents both key changes in this release:

  • Setting supportedNetworks to null by default for new/updated API keys
  • Skipping getDeposit calls for testnet networks
backend/src/utils/interface.ts (1)

22-31: LGTM! Well-structured interface for network configuration.

The new NetworkConfig interface provides clear typing for network configuration data. The structure is logical with:

  • Proper numeric type for chainId
  • String types for URLs and addresses
  • Nested contracts object for paymaster address

This interface is correctly exported and used throughout the codebase (e.g., in common.ts) to improve type safety.

backend/src/utils/common.ts (2)

5-5: LGTM! Proper import of the new NetworkConfig interface.

The import correctly brings in the NetworkConfig interface that's used for return type annotations throughout this file.


8-8: Excellent type safety improvements with explicit return types.

The addition of explicit return types across these functions significantly improves type safety and code clarity:

  • printRequest: void (side-effect function)
  • getNetworkConfig: NetworkConfig | null (properly typed with the new interface)
  • getChainIdsFromDefaultSupportedNetworks: number[]
  • decodeSupportedNetworks: NetworkConfig[]
  • getChainIdsFromSupportedNetworks: number[]

The explicit || null returns on lines 43 and 49 ensure null safety is clear and aligns with the function's type signature. These changes address the suggestions from the previous review and leverage the new NetworkConfig interface effectively.

Based on past review comments suggesting explicit return types.

Also applies to: 36-36, 43-43, 49-49, 65-65, 69-69, 74-74

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 48b17f4 and b430af8.

📒 Files selected for processing (1)
  • backend/migrations/20251209000001-update-supported-network-to-null.cjs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Cloudflare Pages

@vignesha22 vignesha22 merged commit fe41927 into master Dec 10, 2025
4 checks passed
@vignesha22 vignesha22 deleted the Bug_Fixes branch December 10, 2025 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants