Skip to content

Conversation

@vignesha22
Copy link
Contributor

@vignesha22 vignesha22 commented Apr 24, 2025

Description

  • Added entryPoint v8 support
  • Added MTP deployed on entryPoint v7

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

  • New Features

    • Added support for a new entry point version (EPV_08) across paymaster, whitelist, deposit, metadata, and admin routes.
    • Introduced new API endpoints and configuration options for EPV_08, including /deposit/v3, /metadata/v3, and /whitelist/v3.
    • Enhanced whitelist management to support version-specific and global records with policy ID validation.
    • Added new ABIs for VerifyingPaymaster V3 and MultiTokenPaymaster V2.
    • Extended paymaster signing methods to support EPV_08 and updated multi-token paymaster versions.
  • Improvements

    • Expanded configuration and environment variable support for new entry point and token parameters.
    • Updated error messages and improved error handling and logging across routes and paymaster logic.
    • Refined paymaster and token management logic for better flexibility and versioning.
    • Replaced PimlicoPaymaster references with TokenPaymaster for clearer naming and updated related contracts and tests.
  • Bug Fixes

    • Fixed validation and handling of policy IDs in whitelist routes.
    • Corrected token mapping and added missing syntax in constants.
  • Documentation

    • Updated changelog and example environment/configuration files to reflect new features and versions.
  • Refactor

    • Renamed classes, methods, and routes for clarity (e.g., PimlicoPaymaster to TokenPaymaster).
    • Consolidated and streamlined route logic for deposits, metadata, and whitelist management.
    • Modularized deposit route handlers to share common logic for different entry point versions.

* added changes to support MTP for EPV07
* Changes on epv08

* cron job fix

* added default config and deposit api

* added check whitelist fn for sponsor and useVp

* added checks for policyId to be number
* added seed data

* removed entryPoint params

* updated version
@coderabbitai
Copy link

coderabbitai bot commented Apr 24, 2025

Walkthrough

This update introduces comprehensive support for a new entry point version, EPV_08, across the backend service. The changes span configuration, environment variables, ABIs, paymaster logic, models, migrations, and all major API routes. New ABIs and bytecode for VerifyingPaymaster V3 and MultiTokenPaymaster V2 are added. Database schema migrations introduce new columns for EP versioning and paymaster addresses. The codebase is refactored to generalize paymaster logic, add new signing and deployment methods for EPV_08, and extend whitelist, deposit, metadata, and paymaster routes to handle the new version. Configuration handling and error messages are updated accordingly.

Changes

File(s) / Group Change Summary
.env.example, config.json.default, CHANGELOG.md, package.json Added EPV_08 env/config entries, updated changelog for EPV08/multiTokenPaymaster V07, bumped version to 4.0.1
src/abi/MultiTokenPaymasterAbiV2.ts, src/abi/VerifyingPaymasterAbiV3.ts Added new ABI and bytecode files for MultiTokenPaymaster V2 and VerifyingPaymaster V3
src/constants/ErrorMessage.ts, src/constants/MultitokenPaymaster.ts Added error message for EPV08 support, added ETH token entry for Arbitrum
src/types/sponsorship-policy-dto.ts, src/types/whitelist-dto.ts Added EPV_08 to EPVersions enum and utility functions, added epVersion to WhitelistDto
src/models/api-key.ts, src/models/multiTokenPaymaster.ts, src/models/whitelist.ts Extended models to support new columns for EPV_08 and multi-token paymaster versions
migrations/2025032800001-update-apiKey-table.cjs, migrations/2025032800002-update-arka-whitelist-table.cjs, migrations/20250416000001-update-apiKey-table.cjs, migrations/20250416000002-update-MTP-table.cjs, migrations/2025042200001-seed-data.cjs Added/seeded new columns for EP versioning and multi-token paymaster support in DB tables
src/plugins/config.ts Refactored config schema to add EPV_08 and related parameters, moved defaults, added new config fields
src/paymaster/index.ts, src/paymaster/token.ts, src/paymaster/token.test.ts, src/paymaster/index.test.ts Refactored paymaster logic: replaced PimlicoPaymaster with TokenPaymaster, added methods for EPV_08 and multi-token V2, updated tests and imports
src/repository/api-key-repository.ts, src/repository/multi-token-paymaster.ts, src/repository/whitelist-repository.ts Updated repositories to handle EPV_08 and new multi-token paymaster logic, added/renamed methods for versioned lookups
src/routes/admin-routes.ts, src/routes/deposit-route.ts, src/routes/metadata-routes.ts, src/routes/paymaster-routes.ts, src/routes/token-routes.ts, src/routes/whitelist-routes.ts Extended all relevant routes to support EPV_08, added v3 endpoints, refactored logic for versioned paymaster/whitelist handling, updated response payloads
src/server.ts Updated imports, Paymaster instantiation, route registration, and deposit monitoring for new ABI/config/versioning

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant API
    participant DB
    participant Paymaster
    participant Blockchain

    Client->>API: Request (e.g., /paymaster, /whitelist/v3, /deposit/v3) with epVersion=EPV_08
    API->>DB: Lookup API key, whitelist, paymaster addresses for EPV_08
    DB-->>API: Return config, whitelist, paymaster info
    API->>Paymaster: Instantiate with EPV_08 config & ABI
    API->>Blockchain: Interact with EPV_08 paymaster contract (sign, deploy, deposit, etc.)
    Blockchain-->>API: Return contract results (signatures, receipts, balances)
    API-->>Client: Respond with result (paymasterAndData, status, etc.)
Loading

Possibly related PRs

  • PRO - 3097 - ARKA EPV08 Support #198: Implements support for EPV08, updating configuration, database, models, and routes—directly related as both PRs introduce and extend EPV_08 support.
  • PRO-3097-MTP_V07 #201: Adds support for multiTokenPaymaster V07 and related database/code changes; related via shared focus on paymaster versioning and multi-token support.
  • Release v3.1.6 #200: Fixes a bug in multiTokenPaymaster's getERC20Quotes API by improving paymasterAndData generation before estimation; related at the paymaster signing and quoting logic level.

Suggested reviewers

  • kanthgithub
  • nikhilkumar1612
  • ch4r10t33r
  • cryptonoyaiba

Poem

A hop, a leap, to version eight,
New paymasters join the gate!
Whitelists grow, configs bloom,
ABI bunnies fill the room.
With tokens many, chains anew,
This backend hops—robust and true!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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: 30

🔭 Outside diff range comments (7)
backend/src/paymaster/token.test.ts (1)

44-61: 💡 Verification agent

🧩 Analysis chain

Tests should be enabled to verify functionality

All tests are currently skipped with test.skip. Given the significant refactoring from PimlicoPaymaster to TokenPaymaster, these tests should be enabled to verify the functionality works correctly with the new implementation.

Run this script to see if there are any active TokenPaymaster tests elsewhere in the codebase:

Also applies to: 63-81, 83-102, 104-124, 126-159, 161-194, 196-230, 232-266, 268-303, 305-339, 341-376, 378-413, 415-450, 452-487


🏁 Script executed:

#!/bin/bash
# Check if there are any non-skipped TokenPaymaster tests
rg "describe\(\"TokenPaymaster" --type js --type ts | grep -v "skip"

# Check for other related test files that might cover this functionality
fd "token.test" --type file --exec grep -l "TokenPaymaster" {} \;

Length of output: 253


Enable the SMOKE calculateTokenAmount test

The file backend/src/paymaster/token.test.ts already contains an active suite under
describe("TokenPaymaster on Mumbai", …). Only the SMOKE test for calculateTokenAmount is currently skipped.

• File: backend/src/paymaster/token.test.ts
Lines: 44–61

- test.skip("SMOKE: validate the calculateTokenAmount function with valid details", async () => {
+ test("SMOKE: validate the calculateTokenAmount function with valid details", async () => {

Please remove the .skip once the new TokenPaymaster implementation is ready, so that we verify calculateTokenAmount works as expected.

backend/src/repository/whitelist-repository.ts (1)

68-84: ⚠️ Potential issue

Missing epVersion field in updateOneById method

The updateOneById method doesn't include the epVersion field in the list of fields to update. This could lead to the field being reset to null when updating a record.

Apply this fix to include the epVersion field in updates:

async updateOneById(record: ArkaWhitelist): Promise<ArkaWhitelist | null> {
  const result = await this.sequelize.models.ArkaWhitelist.update({
    apiKey: record.apiKey,
    addresses: record.addresses,
-   policyId: record.policyId
+   policyId: record.policyId,
+   epVersion: record.epVersion
  }, {
    where: { id: record.id }
  })
backend/src/plugins/config.ts (2)

18-45: ⚠️ Potential issue

Optional properties are marked as required – validation will now fail

Using the pattern Type.String() || undefined always returns the left operand (a truthy object), so the field stays required.
Example:

EP7_TOKEN_VGL: Type.String() || undefined // still “required string”

With the new EPV_08 additions this will reject any .env that omits those keys, contradicting the fallback defaults you add later.

Suggested fix for every optional value:

-EP7_TOKEN_VGL: Type.String() || undefined,
+EP7_TOKEN_VGL: Type.Optional(Type.String()),

Do this for EP7_TOKEN_PGL, EPV_06, EPV_07, EPV_08, MTP_VGL_MARKUP, USE_SKANDHA_FOR_GAS_DATA, MTP_PVGL, MTP_PPGL, etc.

Without the change validate(envVar) will throw on fresh deployments.


74-91: 🛠️ Refactor suggestion

Undefined → undefined arrays break schema check

process.env.EPV_08?.split(',') yields undefined when the env var is absent, but (after the previous issue is fixed) the schema still expects an array (even when optional).
A simple fallback prevents runtime TypeError: Cannot read properties of undefined (reading 'split'):

EPV_06: (process.env.EPV_06 ?? '').split(',').filter(Boolean),
EPV_07: (process.env.EPV_07 ?? '').split(',').filter(Boolean),
-EPV_08: process.env.EPV_08?.split(','),
+EPV_08: (process.env.EPV_08 ?? '').split(',').filter(Boolean),

Or rely on defaults directly when empty.

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

69-82: 🧹 Nitpick (assertive)

Constructor signature is getting unwieldy – switch to a config object

Nine positional parameters (and growing) are hard to reason about and easy to mis-order.
Prefer passing a single options object (or loading from an injected config service) so that:

  • Call-sites become self-documenting (new Paymaster({ feeMarkUp, multiTokenMarkUp, … }))
  • Future parameters are additive and backwards-compatible.

978-979: 🛠️ Refactor suggestion

Permit exact-balance payments

gte blocks the case where the sender holds exactly the required amount.
Use > (or gt) so equality is allowed.

- if (tokenAmountRequired.gte(tokenBalance))
+ if (tokenAmountRequired.gt(tokenBalance))

1404-1410: ⚠️ Potential issue

Missing return causes silent undefined

Inside the catch block of getPriceFromCoingecko, when tokenData does exist you silently fall through without returning, so the caller receives undefined and will likely crash later.

- if (!tokenData) {
-   log?.error('Price fetch error on tokenAddress: ' + tokenAddress, 'CoingeckoError')
-   throw new Error(`${tokenAddress} ${ErrorMessage.COINGECKO_PRICE_NOT_FETCHED}`);
- }
+ if (!tokenData) {
+   log?.error(`Price fetch error on tokenAddress: ${tokenAddress}`, 'CoingeckoError')
+   throw new Error(`${tokenAddress} ${ErrorMessage.COINGECKO_PRICE_NOT_FETCHED}`);
+ }
+ return {
+   ethPrice: ethers.utils.parseUnits(
+     (Number(nativePrice) / tokenData.price).toFixed(tokenData.decimals),
+     tokenData.decimals
+   ),
+   ...tokenData
+ };

Without this, every happy-path through the catch results in undefined.

🧰 Tools
🪛 Biome (1.9.4)

[error] 1405-1405: Template literals are preferred over string concatenation.

Unsafe fix: Use a template literal.

(lint/style/useTemplate)


[error] 1408-1408: Template literals are preferred over string concatenation.

Unsafe fix: Use a template literal.

(lint/style/useTemplate)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 75e69ad and 5084c39.

📒 Files selected for processing (33)
  • backend/.env.example (1 hunks)
  • backend/CHANGELOG.md (1 hunks)
  • backend/config.json.default (1 hunks)
  • backend/migrations/2025032800001-update-apiKey-table.cjs (1 hunks)
  • backend/migrations/2025032800002-update-arka-whitelist-table.cjs (1 hunks)
  • backend/migrations/20250416000001-update-apiKey-table.cjs (1 hunks)
  • backend/migrations/20250416000002-update-MTP-table.cjs (1 hunks)
  • backend/migrations/2025042200001-seed-data.cjs (1 hunks)
  • backend/package.json (1 hunks)
  • backend/src/abi/MultiTokenPaymasterAbiV2.ts (1 hunks)
  • backend/src/abi/VerifyingPaymasterAbiV3.ts (1 hunks)
  • backend/src/constants/ErrorMessage.ts (1 hunks)
  • backend/src/constants/MultitokenPaymaster.ts (1 hunks)
  • backend/src/models/api-key.ts (3 hunks)
  • backend/src/models/multiTokenPaymaster.ts (2 hunks)
  • backend/src/models/whitelist.ts (2 hunks)
  • backend/src/paymaster/index.test.ts (1 hunks)
  • backend/src/paymaster/index.ts (13 hunks)
  • backend/src/paymaster/token.test.ts (3 hunks)
  • backend/src/paymaster/token.ts (5 hunks)
  • backend/src/plugins/config.ts (5 hunks)
  • backend/src/repository/api-key-repository.ts (2 hunks)
  • backend/src/repository/multi-token-paymaster.ts (2 hunks)
  • backend/src/repository/whitelist-repository.ts (3 hunks)
  • backend/src/routes/admin-routes.ts (7 hunks)
  • backend/src/routes/deposit-route.ts (3 hunks)
  • backend/src/routes/metadata-routes.ts (4 hunks)
  • backend/src/routes/paymaster-routes.ts (15 hunks)
  • backend/src/routes/token-routes.ts (4 hunks)
  • backend/src/routes/whitelist-routes.ts (13 hunks)
  • backend/src/server.ts (7 hunks)
  • backend/src/types/sponsorship-policy-dto.ts (3 hunks)
  • backend/src/types/whitelist-dto.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
backend/src/paymaster/token.test.ts (1)
backend/src/paymaster/token.ts (1)
  • TokenPaymaster (17-90)
backend/src/server.ts (2)
backend/src/paymaster/index.ts (1)
  • Paymaster (53-1421)
backend/src/utils/monitorTokenPaymaster.ts (1)
  • checkDeposit (6-22)
backend/src/repository/whitelist-repository.ts (1)
backend/src/models/whitelist.ts (1)
  • ArkaWhitelist (3-11)
🪛 markdownlint-cli2 (0.17.2)
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)


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

(MD022, blanks-around-headings)


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

(MD022, blanks-around-headings)


4-4: Lists should be surrounded by blank lines
null

(MD032, blanks-around-lists)


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

(MD022, blanks-around-headings)


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

(MD022, blanks-around-headings)


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

(MD022, blanks-around-headings)


8-8: Lists should be surrounded by blank lines
null

(MD032, blanks-around-lists)


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

(MD022, blanks-around-headings)


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

(MD022, blanks-around-headings)


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

(MD022, blanks-around-headings)


12-12: Lists should be surrounded by blank lines
null

(MD032, blanks-around-lists)

🪛 Biome (1.9.4)
backend/src/routes/admin-routes.ts

[error] 504-504: Declare variables separately

Unsafe fix: Break out into multiple declarations

(lint/style/useSingleVarDeclarator)

backend/src/routes/metadata-routes.ts

[error] 247-247: Declare variables separately

Unsafe fix: Break out into multiple declarations

(lint/style/useSingleVarDeclarator)

backend/src/routes/paymaster-routes.ts

[error] 305-305: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

backend/src/paymaster/index.ts

[error] 352-352: Template literals are preferred over string concatenation.

Unsafe fix: Use a template literal.

(lint/style/useTemplate)


[error] 949-949: Template literals are preferred over string concatenation.

Unsafe fix: Use a template literal.

(lint/style/useTemplate)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (41)
backend/src/paymaster/index.test.ts (1)

4-4: Update import path for PAYMASTER_ADDRESS
The test now imports PAYMASTER_ADDRESS from ../constants/Token.js, matching the updated constants module.

backend/src/constants/ErrorMessage.ts (1)

59-60: Add missing comma and new error message
A comma was correctly added after COINGECKO_PRICE_NOT_FETCHED, and the new MTP_EP_SUPPORT message clearly indicates unsupported entry point versions for multi-token paymaster. Ensure this constant is used in the relevant routes so that users receive this error when hitting an unsupported EP version.

backend/src/models/whitelist.ts (2)

8-8: Well-structured model property addition

Adding the epVersion property with appropriate typing and default value correctly extends the model to support multiple entry point versions.


38-42: Properly defined database column for EP versioning

The database column definition for epVersion follows good practices with proper typing, nullability, and field naming conventions that match the rest of the model.

backend/src/constants/MultitokenPaymaster.ts (1)

192-193: Good addition of ETH support for Arbitrum

Adding native ETH support with the standard placeholder address (0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE) is appropriate and follows conventions for representing native tokens in token lists.

backend/config.json.default (1)

472-481: Proper configuration for EPV_08 on Sepolia

The addition of a new configuration entry for Sepolia (chainId 11155111) with a v3 bundler and the EPV_08 entryPoint address is correctly structured and follows the pattern of other configurations in the file.

backend/migrations/2025032800001-update-apiKey-table.cjs (1)

1-13: LGTM! Migration properly adds the VERIFYING_PAYMASTERS_V3 column.

The migration correctly adds the new column to store verifying paymaster addresses for EPV_08 in the api_keys table.

backend/migrations/2025032800002-update-arka-whitelist-table.cjs (1)

1-13: LGTM! Migration properly adds the EP_VERSION column.

The migration correctly adds the new column to track entry point versions for whitelist entries, supporting the new EPV_08 functionality.

backend/src/repository/multi-token-paymaster.ts (1)

3-3: LGTM! Properly imported EPVersions enum.

The import is correctly added to support strongly-typed version parameters.

backend/src/models/multiTokenPaymaster.ts (1)

10-10: LGTM! Added epVersion property to model class.

Properly added the new property to track entry point versions.

backend/migrations/20250416000002-update-MTP-table.cjs (1)

4-4: Good addition of EntryPoint versioning!

Adding the EP_VERSION column with a default of 'EPV_06' is a good approach for supporting multiple EntryPoint versions. This ensures backward compatibility with existing data.

backend/migrations/20250416000001-update-apiKey-table.cjs (1)

1-11: Good migration implementation with proper safety checks

The migration correctly adds a nullable column for multi-token paymasters V2 support with appropriate IF EXISTS checks in both up and down migrations.

backend/src/paymaster/token.test.ts (1)

3-3: Consistent replacement of PimlicoPaymaster with TokenPaymaster

The imports, class instantiation, and test description are properly updated to reflect the refactoring from Pimlico to Token paymaster.

Also applies to: 8-8, 10-10, 42-42

backend/src/server.ts (6)

12-12: Good replacement of Pimlico with Token-based components

The import changes correctly reflect the architectural shift from Pimlico-specific to more generic Token-based paymaster handling.

Also applies to: 22-22


64-65: Constructor updated with additional EntryPoint version parameters

The Paymaster constructor now receives additional parameters for multi-token paymaster gas limits and EntryPoint v8 verification gas limits, which aligns with the PR objective of adding support for EntryPoint version 8.


266-268: Improved null checking for etherspotPaymasterAddress

This change adds a safety check to verify etherspotPaymasterAddress exists before calling checkDeposit, preventing potential null reference errors.


311-313: Consistent null checking for etherspotPaymasterAddress

Similar to the earlier check, this ensures the etherspotPaymasterAddress exists before calling checkDeposit when processing networks from the default config.


165-165: Updated contract ABI reference

The contract instantiation now correctly uses ERC20PaymasterAbi instead of PimlicoAbi, which aligns with the architectural changes.


105-105: Updated route registration

The server now registers tokenRoutes instead of pimlicoRoutes, completing the refactoring of the Pimlico-specific components.

backend/src/types/sponsorship-policy-dto.ts (3)

38-38: Support for EPV_08 version added to the enum

The enum is properly extended with the new entry point version EPV_08, maintaining consistency with the existing pattern.


51-52: Handler for EPV_08 string conversion added

The getEPVersion function is correctly updated to handle the new EPV_08 version string, maintaining the pattern established for previous versions.


65-66: Handler for EPV_08 enum conversion added

The getEPVersionString function is properly updated to convert the EPV_08 enum value to its string representation, following the established pattern.

backend/src/routes/token-routes.ts (5)

6-6: Import path updated from Pimlico to Token

The import path for PAYMASTER_ADDRESS has been correctly updated to use the Token constants module instead of Pimlico, aligning with the broader refactoring to standardize on Token paymaster terminology.


14-14: Route handler renamed to reflect token-based implementation

The Fastify plugin has been renamed from pimlicoRoutes to tokenRoutes, making the naming more consistent with the actual implementation and other changes in the codebase.


127-128: Added epVersion field to response object

The response now includes the EP version for each multi-token paymaster record, which is essential for supporting multiple entry point versions. This is a good enhancement that aligns with the database schema changes.


146-146: Updated default export name

The default export has been correctly updated to match the renamed tokenRoutes function.


116-116:

Details

❓ Verification inconclusive

API parameter index changed - potential breaking change

The extraction of api_key now uses body.params[0] instead of the previous body.params[1]. This change could break existing client code if clients were relying on the previous parameter order.


🏁 Script executed:

#!/bin/bash
# Verify if there are any client implementations that might be affected by the parameter order change
# Look for code that calls this endpoint and expects parameters in a specific order

# First check if there are any direct calls to this endpoint in the codebase
rg -A 3 -B 3 "getAllCommonERC20PaymasterAddress" --type ts

Length of output: 1567


Confirm backward‐compatibility of apiKey extraction

I didn’t find any internal client calls to /getAllCommonERC20PaymasterAddress in the repo, but external consumers relying on body.params[1] for the apiKey will break now that it’s read from body.params[0]. To safeguard against regressions:

  • Support both parameter orders (e.g. fall back to body.params[1] if body.params[0] is missing) or switch to named JSON properties.
  • Update API documentation and example payloads to reflect the new position.
  • Bump the API (major) version and notify clients of this breaking change.
backend/src/repository/whitelist-repository.ts (3)

4-4: Added import for EPVersions enum

The EPVersions enum is properly imported to support type checking for the new methods that use EP version.


18-19: Added epVersion to repository create method

The create method now correctly stores the epVersion from the input DTO, defaulting to null if not provided, aligning with the model changes.


55-66: Added method to query whitelist by API key, EP version, and policy ID

The new method follows the existing pattern for the similar API key and policy ID method, but adds EP version support. The early null return when epVersion is missing prevents unnecessary database queries.

backend/src/paymaster/token.ts (5)

4-5: Updated imports from Pimlico to Token-related modules

The imports have been correctly updated to use the generic token-related modules instead of Pimlico-specific ones, consistent with the class renaming below.


17-17: Renamed class from PimlicoPaymaster to TokenPaymaster

The class has been renamed to better reflect its generic token handling capabilities rather than being tied to a specific provider.


192-192: Updated return type to TokenPaymaster

The return type of getERC20Paymaster function has been correctly updated to match the renamed class.


201-201: Removed trailing whitespace in owner address string

Minor cleanup of the default owner address string by removing trailing whitespace.


210-210: Updated instantiation to use TokenPaymaster

The function now correctly returns an instance of TokenPaymaster instead of PimlicoPaymaster.

backend/src/repository/api-key-repository.ts (1)

64-71: Surface silent failures by checking the update count

sequelize.update() resolves to [affectedCount] and silently returns [0] when no rows match.
Consider mirroring the behaviour of delete() and throw when affectedCount === 0 so callers don’t mistake “nothing updated” for success.

const [affected] = await this.sequelize.models.APIKey.update(
  { [column]: vpAddresses },
  { where: { apiKey } },
);
if (affected === 0) {
  throw new Error(`APIKey ${apiKey} not found – no rows updated`);
}
return affected;
backend/src/models/api-key.ts (1)

71-75: Verify migrations & indices for the two new columns

VERIFYING_PAYMASTERS_V3 and MULTI_TOKEN_PAYMASTERS_V2 are now part of the model.
Please ensure that:

  1. The matching migrations have been applied in every environment before the new code is deployed.
  2. Any queries / indices that previously referenced only the V and V2 columns are extended accordingly.

This avoids Unknown column runtime errors and keeps look-ups performant.

Also applies to: 87-91

backend/src/routes/admin-routes.ts (1)

20-23: Confirm Paymaster constructor signature

A tenth argument server.config.EP8_PVGL is now passed.
Double-check that the Paymaster class has been updated to accept (and use) this parameter; otherwise the service will crash on startup.

backend/migrations/2025042200001-seed-data.cjs (1)

4-195: Potential duplicate primary-key rows

TOKEN_ADDRESS '0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb' appears twice (lines ~19 & ~101).
If a uniqueness constraint exists on TOKEN_ADDRESS+CHAIN_ID, the migration will fail on the second insert.

Please de-duplicate before shipping.

backend/src/routes/deposit-route.ts (1)

47-66: Boolean query params arrive as strings

const useVp = query['useVp'] ?? false;
When the caller sends /deposit?useVp=true, useVp is the string "true", which is truthy, so the logic works.
However !useVp later becomes false as intended only if the param is present and non-empty – "false" will still be truthy.

Safer coercion:

-const useVp = query['useVp'] ?? false;
+const useVp = String(query['useVp']).toLowerCase() === 'true';
backend/src/abi/MultiTokenPaymasterAbiV2.ts (1)

1-878: ABI JSON looks good – just be mindful of bundle size

Nothing jumps out as incorrect: the array is exported as const, is type-safe (as const), and contains a complete ABI.
A minor point to watch is import cost – this file is ~900 lines and will be loaded into memory any time it is imported. If you only need small fragments at run-time, consider code-splitting or lazy-loading to avoid inflating cold-start time.

Copy link
Contributor

@nikhilkumar1612 nikhilkumar1612 left a comment

Choose a reason for hiding this comment

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

I think we should consider, splitting paymaster class into smaller classes based on entry points

@ch4r10t33r @vignesha22

* changed Bignumber to hex string as per current change in skandha
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Apr 24, 2025

Deploying arka with  Cloudflare Pages  Cloudflare Pages

Latest commit: fb1d25e
Status: ✅  Deploy successful!
Preview URL: https://13104659.arka-3qg.pages.dev
Branch Preview URL: https://develop.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: 3

♻️ Duplicate comments (3)
backend/src/types/whitelist-dto.ts (1)

1-7: Properly implemented type-safe EPVersion support!

The changes appropriately implement the optional epVersion field with the EPVersions enum type, providing strong type safety as recommended in the previous review. This enhancement aligns well with the PR objective of adding support for entryPoint version 8.

backend/src/routes/paymaster-routes.ts (1)

206-208: ⚠️ Potential issue

useVp is still parsed as a raw query-string – logic silently bypassed
useVp arrives as "true" | "false" (string). The conditional if (useVp && …) always evaluates to true (non-empty string) causing unintended mode switches.
The exact problem was raised in an earlier review and is still unresolved.

-const useVp = query['useVp'] ?? false;
+const useVp =
+  String(query['useVp']).toLowerCase() === 'true';
backend/src/paymaster/index.ts (1)

191-263: 🛠️ Refactor suggestion

signV08 duplicates 90 % of signV07 – extract shared helper
The two methods differ only in ABI reference and the EP*_PVGL constant. Duplication invites divergence and bugs.

Suggested approach (sketch):

-async signV07(...) { return this.signGeneric('v07', ...); }
-async signV08(...) { return this.signGeneric('v08', ...); }

+private async signGeneric(
+  version: 'v07' | 'v08',
+  userOp, validUntil, validAfter,
+  entryPoint, paymasterAddress,
+  bundlerRpc, signer, estimate, log
+) {
+  const cfg = version === 'v07'
+    ? { abi: EtherspotAbiV07, pvgl: this.EP7_PVGL }
+    : { abi: verifyingPaymasterV3Abi, pvgl: this.EP8_PVGL };
+  ...
+}

Refactor once now; you will thank yourself when EPV-09 arrives.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5084c39 and fb1d25e.

📒 Files selected for processing (3)
  • backend/src/paymaster/index.ts (14 hunks)
  • backend/src/routes/paymaster-routes.ts (15 hunks)
  • backend/src/types/whitelist-dto.ts (1 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
backend/src/routes/paymaster-routes.ts

[error] 308-308: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

backend/src/paymaster/index.ts

[error] 352-352: Template literals are preferred over string concatenation.

Unsafe fix: Use a template literal.

(lint/style/useTemplate)


[error] 949-949: Template literals are preferred over string concatenation.

Unsafe fix: Use a template literal.

(lint/style/useTemplate)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (1)
backend/src/paymaster/index.ts (1)

836-838: this.MTP_VGL_MARKUP is a string – implicit coercion hides unit errors
Adding a plain string to a BigNumber works only when the string is a base-10 integer, but future edits may prepend 0x or leave it empty leading to runtime failures.

-userOp.verificationGasLimit = BigNumber.from(response.verificationGasLimit).add(this.MTP_VGL_MARKUP).toHexString();
+userOp.verificationGasLimit = BigNumber
+  .from(response.verificationGasLimit)
+  .add(BigNumber.from(this.MTP_VGL_MARKUP))
+  .toHexString();

Consider normalising constructor arguments to BigNumber once and store them as such.

@vignesha22 vignesha22 merged commit d51879f into master Apr 24, 2025
6 checks passed
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