Skip to content

Conversation

@vignesha22
Copy link
Contributor

@vignesha22 vignesha22 commented Apr 16, 2025

Description

  • Added support for multiTokenPaymaster V07

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 multi-token paymasters deployed for EntryPoint version 07.
    • Introduced new configuration options for paymaster gas limits (MTP_PVGL and MTP_PPGL).
    • Extended API responses to include entry point version for multi-token paymasters.
  • Improvements

    • Enhanced paymaster signing and data handling to support both legacy (EPV_06) and new (EPV_07) contract versions.
    • Updated internal models and API key management to track new paymaster attributes including multiTokenPaymastersV2 and epVersion.
    • Expanded repository queries and route logic to handle multiple paymaster versions.
  • Bug Fixes

    • Minor formatting and error message standardization for improved clarity.

@linear
Copy link

linear bot commented Apr 16, 2025

@coderabbitai
Copy link

coderabbitai bot commented Apr 16, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This update introduces support for a new version (V07) of the MultiTokenPaymaster contract throughout the backend. It adds new columns to the relevant database tables and updates the Sequelize models accordingly. The Paymaster class is extended with new properties and methods to handle V07-specific signing and gas limit logic. Configuration files and route handlers are updated to accommodate the new paymaster version and its associated gas limit parameters. The API and repository layers are modified to support querying and returning data for multiple entry point versions, ensuring compatibility with both EPV_06 and EPV_07.

Changes

File(s) Change Summary
backend/migrations/20250416000001-update-apiKey-table.cjs,
backend/migrations/20250416000002-update-MTP-table.cjs
Added migration scripts: one adds MULTI_TOKEN_PAYMASTERS_V2 (text, nullable) to api_keys table; the other adds EP_VERSION (text, default 'EPV_06') to multi_token_paymaster table, both with reversible up/down functions and dynamic schema support.
backend/src/abi/MultiTokenPaymasterAbiV2.ts Introduced the ABI definition for the MultiTokenPaymaster V2 contract, including constructor, errors, events, and a comprehensive set of functions for stake management, token withdrawals, user operation validation, and ownership/fee management.
backend/src/models/api-key.ts Added multiTokenPaymastersV2 (optional string, nullable) property to the APIKey model and mapped it to the MULTI_TOKEN_PAYMASTERS_V2 database column.
backend/src/models/multiTokenPaymaster.ts Added required epVersion (string) property to the MultiTokenPaymaster model and mapped it to the EP_VERSION column.
backend/src/paymaster/index.ts Extended the Paymaster class with new properties (MTP_PVGL, MTP_PPGL), updated constructor, and added methods to support V07 paymaster signing and data generation. Fixed minor error message formatting.
backend/src/plugins/config.ts Added configuration schema and environment variable support for MTP_PVGL and MTP_PPGL (string, defaults: '50000', '70000').
backend/src/repository/multi-token-paymaster.ts Renamed and updated method to findOneByChainIdEPVersionAndTokenAddress, adding an epVersion parameter and filtering by it in queries.
backend/src/routes/admin-routes.ts,
backend/src/routes/deposit-route.ts,
backend/src/routes/whitelist-routes.ts,
backend/src/server.ts
Updated instantiations of the Paymaster class to include the new configuration parameters MTP_PVGL and MTP_PPGL.
backend/src/routes/paymaster-routes.ts Extended logic to support both V2 (EPV_07) and V1 (EPV_06) multi-token and verifying paymasters, including selection, validation, and signing flows. Updated error handling and standardized formatting.
backend/src/routes/pimlico-routes.ts Extended /getAllCommonERC20PaymasterAddress route handler response to include the epVersion property for each record.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant API Server
    participant Paymaster Class
    participant DB
    participant MultiTokenPaymaster Contract (V07)
    participant Wallet

    Client->>API Server: Request paymaster data (EPV_07)
    API Server->>DB: Query MultiTokenPaymaster by chainId, token, epVersion
    DB-->>API Server: Return paymaster record (with epVersion)
    API Server->>Paymaster Class: signMultiTokenPaymasterV07(userOp, ...params)
    Paymaster Class->>MultiTokenPaymaster Contract (V07): getHash(userOp, ...params)
    Paymaster Class->>Wallet: Sign hash
    Paymaster Class->>API Server: Return paymasterData, gas limits
    API Server-->>Client: Respond with paymasterData, gas info
Loading

Possibly related PRs

  • Release v3.1.6 #200: Fixes bugs in paymaster estimation and signer support, modifying paymaster signing and data generation logic in backend/src/paymaster/index.ts and related routes, closely related to extending paymaster handling for new versions.

Suggested reviewers

  • ch4r10t33r
  • nikhilkumar1612

Poem

In the warren where paymasters dwell,
New versions hop in, as stories tell.
With columns and configs, models anew,
Our codebase grows strong—supporting V2!
Gas limits set, the contracts align,
Rabbits rejoice: “It’s release time!”
🐇✨


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

@cloudflare-workers-and-pages
Copy link

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

Deploying arka with  Cloudflare Pages  Cloudflare Pages

Latest commit: c5d185d
Status: ✅  Deploy successful!
Preview URL: https://e361a527.arka-3qg.pages.dev
Branch Preview URL: https://pro-3097-arka-mtp-v07.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: 6

📜 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 9f0ba53.

📒 Files selected for processing (14)
  • backend/migrations/20250416000001-update-apiKey-table.cjs (1 hunks)
  • backend/migrations/20250416000002-update-MTP-table.cjs (1 hunks)
  • backend/src/abi/MultiTokenPaymasterAbiV2.ts (1 hunks)
  • backend/src/models/api-key.ts (2 hunks)
  • backend/src/models/multiTokenPaymaster.ts (2 hunks)
  • backend/src/paymaster/index.ts (6 hunks)
  • backend/src/plugins/config.ts (3 hunks)
  • backend/src/repository/multi-token-paymaster.ts (2 hunks)
  • backend/src/routes/admin-routes.ts (1 hunks)
  • backend/src/routes/deposit-route.ts (1 hunks)
  • backend/src/routes/paymaster-routes.ts (10 hunks)
  • backend/src/routes/pimlico-routes.ts (1 hunks)
  • backend/src/routes/whitelist-routes.ts (1 hunks)
  • backend/src/server.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (4)
backend/src/server.ts (1)
backend/src/paymaster/index.ts (1)
  • Paymaster (51-1340)
backend/src/routes/whitelist-routes.ts (1)
backend/src/paymaster/index.ts (1)
  • Paymaster (51-1340)
backend/src/routes/admin-routes.ts (1)
backend/src/paymaster/index.ts (1)
  • Paymaster (51-1340)
backend/src/routes/deposit-route.ts (1)
backend/src/paymaster/index.ts (1)
  • Paymaster (51-1340)
🪛 Biome (1.9.4)
backend/src/routes/paymaster-routes.ts

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

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

backend/src/paymaster/index.ts

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

Unsafe fix: Use a template literal.

(lint/style/useTemplate)


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

Unsafe fix: Use a template literal.

(lint/style/useTemplate)


[error] 1328-1328: 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 (32)
backend/src/plugins/config.ts (3)

41-42: Gas limit configuration added for MultiTokenPaymaster V07

These new configuration parameters are properly integrated into the config schema with appropriate defaults and support for environment variable overrides. These gas limit settings will be used by the Paymaster class for V07 transaction processing.


85-86: Default gas limit values look appropriate

The default values (50000 for verification gas limit and 70000 for post-op gas limit) are set with appropriate fallbacks from environment variables.


125-126: Config values properly exposed to the application

The configuration values are correctly added to the final config object that gets exposed to the application.

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

4-5: Migration properly adds MULTI_TOKEN_PAYMASTERS_V2 column

The migration adds the required column with appropriate nullability, which aligns with the V07 paymaster support.

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

15-16: Paymaster constructor updated with new gas limit parameters

The Paymaster constructor is correctly updated to include the new MultiTokenPaymaster gas limit parameters (MTP_PVGL and MTP_PPGL) from the configuration, which are required for V07 paymaster support.

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

129-131: Added epVersion to paymaster response

The response now includes the entry point version (epVersion) for each paymaster, which is essential for clients to distinguish between V06 and V07 paymasters.

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

14-15: Updated Paymaster constructor with new gas limit parameters.

The constructor now includes the new MTP_PVGL and MTP_PPGL parameters for MultiTokenPaymaster V07 gas limit configuration. This change is required to properly support the V07 version features.

backend/src/server.ts (1)

64-65: Updated Paymaster constructor with MultiTokenPaymaster V07 gas limit parameters.

The server initialization now correctly passes the new gas limit parameters (MTP_PVGL and MTP_PPGL) to the Paymaster constructor, which is essential for supporting the V07 functionality across the application.

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

21-22: Updated Paymaster constructor with MultiTokenPaymaster V07 parameters.

The constructor now includes the MTP_PVGL and MTP_PPGL parameters needed for V07 support, maintaining consistency with other route files in the application.

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

10-10: Added epVersion field to track entry point version support.

This new required field enables the model to identify which entry point version (EPV_06 or EPV_07) is associated with each MultiTokenPaymaster record, which is essential for the multi-version support being implemented.


54-58: Added Sequelize definition for the epVersion field.

The field is correctly defined as a non-nullable string, which aligns with its intended purpose of tracking the entry point version (EPV_06 or EPV_07) for each record.

backend/src/models/api-key.ts (2)

13-13: Property addition looks good.
No issues with declaring multiTokenPaymastersV2 in the model. It follows the existing pattern for optional string columns.


81-85: Database column definition is consistent.
This aligns with the naming and nullable setup of other columns. No concerns here.

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

8-10: Migration setup is valid.
The down function properly reverts the schema changes, and exporting up/down is correct.

Also applies to: 12-12

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

3-3: New import is appropriate.
Importing EPVersions aligns with the extended filtering logic.


17-21: Method extension is consistent.
Filtering by chainId, tokenAddress, and epVersion is clear and descriptive.

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

19-19: Destructuring is straightforward.
Extracting paymaster from options is a clean approach.


105-105: Variable addition for multiTokenPaymastersV2 is clear.
No issues—this mirrors the approach used for the V1 array.


145-148: Consistent base64 decoding logic.
Reading multiTokenPaymastersV2 from the API key entity matches the existing pattern.


205-205: Mode override logic.
Switching from sponsor to vps when useVp is passed makes sense. Be sure this behavior is desired to avoid surprises.


325-329: Version-based paymaster logic is clear.
Delegating to signMultiTokenPaymaster vs. signMultiTokenPaymasterV07 is well-structured.


390-396: VerifyingPaymasters check is correct.
Returning an error if no entry is found for EPV_06 is consistent with your existing validations.


400-408: VerifyingPaymastersV2 flow is consistent.
Likewise, returning an error if not configured for EPV_07 ensures clarity for users.


412-414: Common ERC20 route extended for epVersion.
Checking EPV_06 vs. EPV_07 before calling the repository is logically consistent.


419-420: Private key presence check.
Promptly returning an error is a good security practice.


441-444: Version-based branching looks good.
No issues in separating EPV_06 vs. EPV_07 logic for the paymaster signing calls.


486-489: Cache data retrieval.
Logging and returning success or failure is straightforward. No issues here.

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

24-24: No issues found with the new ABI import.
The import statement for MultiTokenPaymasterAbiV2 is straightforward and aligns with the updated V07 paymaster logic.


58-59: Validate usage of string vs. BigNumber for gas limit properties.
These new class properties (MTP_PVGL, MTP_PPGL) are typed as strings. In other places, paymaster gas limits (e.g., EP7_PVGL) are stored as BigNumber. Double-check consistency to avoid accidental type mismatches or conversions.

Would you like to confirm whether these properties should remain strings or be converted to BigNumber upon assignment for uniformity?


246-275:

Details

❓ Verification inconclusive

Include a default price source parameter and fix string concatenation.

  1. Price source check: You’re calling getHash with a hardcoded 0 for the priceSource argument. Confirm if ExchangeRateSource=0 is indeed the intended default. Otherwise, consider adding a parameter to make it explicit.
  2. Use a template literal: On line 274, replace the string concatenation with a template literal to comply with the lint hint and improve readability.
- throw new Error('Failed ' + err.message)
+ throw new Error(`Failed ${err.message}`)

Verify that the contract truly expects priceSource=0 in this scenario to avoid incorrect hashing at the contract level.


Action Required: Verify Default Price Source & Update Error String

  • Ensure that using a hardcoded 0 for the priceSource argument in the call to getHash is correct (i.e. that ExchangeRateSource=0 is indeed the intended default as per the contract specification). If not, add a parameter to clearly specify the price source.
  • Replace the string concatenation for the error message with a template literal for improved readability.
- throw new Error('Failed ' + err.message)
+ throw new Error(`Failed ${err.message}`)
🧰 Tools
🪛 Biome (1.9.4)

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

Unsafe fix: Use a template literal.

(lint/style/useTemplate)


779-872:

Details

❓ Verification inconclusive

Enhance error readability and finalize V07 logic checks.

  1. Use a template literal for error messages: On line 870, replace the string concatenation with a template literal to align with lint best practices.
  2. Logic Confirmation: The method updates userOp twice (before and after estimating gas) to incorporate the new paymaster data. This seems intentional but confirm no intermittent side effects (e.g., using partial paymaster data on the first pass).
- throw new Error('Failed to process request to bundler. Please contact support team RawErrorMsg:' + err.message)
+ throw new Error(`Failed to process request to bundler. Please contact support team RawErrorMsg: ${err.message}`)

Double-check whether staggering the assignment of userOp.paymasterAndData across two estimates is the intended design.


Action: Update Error Message Template and Confirm Double Assignment of Paymaster Data

  • Update the error message (line 870) to use a template literal as shown below:
    - throw new Error('Failed to process request to bundler. Please contact support team RawErrorMsg:' + err.message)
    + throw new Error(`Failed to process request to bundler. Please contact support team RawErrorMsg: ${err.message}`)
  • Verify that the intentional double assignment of userOp.paymasterAndData (once before and once after the gas estimation) does not introduce any unintended side effects. Confirm that using intermediate paymaster data in the first pass is the desired design.
🧰 Tools
🪛 Biome (1.9.4)

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

Unsafe fix: Use a template literal.

(lint/style/useTemplate)

backend/src/abi/MultiTokenPaymasterAbiV2.ts (1)

1-878: ABI file addition looks good.
This ABI definition for MultiTokenPaymaster V2 is comprehensive and consistent with the newly integrated paymaster logic in index.ts. No issues found.

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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9f0ba53 and 599c840.

📒 Files selected for processing (2)
  • backend/CHANGELOG.md (1 hunks)
  • backend/package.json (1 hunks)
🧰 Additional context used
🪛 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)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (2)
backend/package.json (1)

3-3: Version bump is appropriate.

The version update to 3.1.7 correctly reflects the addition of a new feature. No issues found.

backend/CHANGELOG.md (1)

2-5: Changelog entry is clear and accurate.

The changelog entry for version 3.1.7 accurately documents the new feature and aligns with the code changes.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

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)

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

♻️ Duplicate comments (1)
backend/migrations/20250416000002-update-MTP-table.cjs (1)

3-5: Consider indexing the new column.

Adding an index on EP_VERSION may help if you expect frequent lookups by version. Otherwise, the migration looks fine.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 599c840 and 7fcd381.

📒 Files selected for processing (2)
  • backend/migrations/20250416000001-update-apiKey-table.cjs (1 hunks)
  • backend/migrations/20250416000002-update-MTP-table.cjs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (1)
backend/migrations/20250416000001-update-apiKey-table.cjs (1)

1-11: Migration looks good.

This migration correctly adds a nullable MULTI_TOKEN_PAYMASTERS_V2 column to the api_keys table with appropriate IF EXISTS clauses in both up and down migrations.

Comment on lines +7 to +9
async function down({ context: queryInterface }) {
await queryInterface.sequelize.query(`ALTER TABLE "${process.env.DATABASE_SCHEMA_NAME}".multi_token_paymaster DROP COLUMN EP_VERSION;`);
}
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Add IF EXISTS clause to the down migration.

The down migration should include an IF EXISTS clause to match the style in the up migration and prevent errors if the table doesn't exist.

- await queryInterface.sequelize.query(`ALTER TABLE "${process.env.DATABASE_SCHEMA_NAME}".multi_token_paymaster DROP COLUMN EP_VERSION;`);
+ await queryInterface.sequelize.query(`ALTER TABLE IF EXISTS "${process.env.DATABASE_SCHEMA_NAME}".multi_token_paymaster DROP COLUMN EP_VERSION;`);
📝 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
async function down({ context: queryInterface }) {
await queryInterface.sequelize.query(`ALTER TABLE "${process.env.DATABASE_SCHEMA_NAME}".multi_token_paymaster DROP COLUMN EP_VERSION;`);
}
async function down({ context: queryInterface }) {
await queryInterface.sequelize.query(`ALTER TABLE IF EXISTS "${process.env.DATABASE_SCHEMA_NAME}".multi_token_paymaster DROP COLUMN EP_VERSION;`);
}

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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: 6

♻️ Duplicate comments (1)
backend/src/paymaster/index.ts (1)

1328-1328: 🧹 Nitpick (assertive)

Prefer template literal over string concatenation.
Replace tokenAddress + ' ' + ErrorMessage.COINGECKO_PRICE_NOT_FETCHED with a template literal.

- throw new Error(tokenAddress + ' ' + ErrorMessage.COINGECKO_PRICE_NOT_FETCHED);
+ throw new Error(`${tokenAddress} ${ErrorMessage.COINGECKO_PRICE_NOT_FETCHED}`);
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7fcd381 and 49e693f.

📒 Files selected for processing (1)
  • backend/src/paymaster/index.ts (7 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
backend/src/paymaster/index.ts

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

Unsafe fix: Use a template literal.

(lint/style/useTemplate)


[error] 870-870: 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)

24-24: Import for MultiTokenPaymasterAbiV2 looks good.
No issues found here.

Comment on lines +76 to +77
this.MTP_PVGL = mtpPvgl;
this.MTP_PPGL = mtpPpgl;
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Keep type consistency for MTP_PVGL and MTP_PPGL.
If you convert MTP_VGL_MARKUP to BigNumber in the constructor, it’s also more consistent to store MTP_PVGL and MTP_PPGL as BigNumber for clarity.

const response = await provider.send('eth_estimateUserOperationGas', [userOp, entryPoint]);
if (BigNumber.from(userOp.verificationGasLimit).lt("45000")) userOp.verificationGasLimit = BigNumber.from("45000").toHexString(); // This is to counter the unaccounted cost(45000)
userOp.verificationGasLimit = BigNumber.from(response.verificationGasLimit).add("30000").toHexString(); // This is added just in case the token is proxy
userOp.verificationGasLimit = BigNumber.from(response.verificationGasLimit).add(this.MTP_VGL_MARKUP).toHexString(); // This is added just in case the token is proxy
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify numeric input for MTP_VGL_MARKUP.
Ensuring MTP_VGL_MARKUP is a valid BigNumber-compatible string is crucial before calling .add(...). Otherwise, it might lead to runtime errors.


🏁 Script executed:

#!/bin/bash
# Description: Verify that MTP_VGL_MARKUP is always a numeric string
rg --multiline --json "MTP_VGL_MARKUP" 

Length of output: 5915


Ensure MTP_VGL_MARKUP is Validated as a Numeric Value

The current implementation in backend/src/paymaster/index.ts (line 758) relies on this.MTP_VGL_MARKUP being a valid BigNumber-compatible numeric string. Although the default configuration (in backend/src/plugins/config.ts and backend/demo.env) sets this value to "30000", the fact that it’s sourced from environment variables means there's a risk of receiving non-numeric input. This could lead to runtime errors when calling BigNumber.from(...).add(...).

  • Actionable Suggestion:
    Add explicit validation or coercion to ensure that MTP_VGL_MARKUP is numeric before it is used in BigNumber arithmetic. This could involve sanitizing the environment variable upon loading the configuration or implementing a helper function to validate/convert the input.

@vignesha22 vignesha22 changed the base branch from master to develop April 16, 2025 11:27
@vignesha22 vignesha22 requested a review from ch4r10t33r April 16, 2025 12:29
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

@vignesha22 vignesha22 merged commit e0693a6 into develop Apr 16, 2025
3 checks passed
@vignesha22 vignesha22 deleted the PRO-3097-Arka_MTP_V07 branch April 16, 2025 12:35
@coderabbitai coderabbitai bot mentioned this pull request Apr 24, 2025
8 tasks
@coderabbitai coderabbitai bot mentioned this pull request Aug 23, 2025
3 tasks
@coderabbitai coderabbitai bot mentioned this pull request Dec 9, 2025
8 tasks
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