-
Notifications
You must be signed in to change notification settings - Fork 11
Merge pull request #220 from etherspot/CronJobFixes #221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThis change introduces a migration script to seed the Changes
Sequence Diagram(s)sequenceDiagram
participant CronJob as Cron Job (updateTokenOracleData)
participant Constants as Constants (MULTI_TOKEN_PAYMASTERS/ORACLES)
participant Utils as getNetworkConfig
participant Provider as Blockchain Provider
participant Paymaster as Paymaster Contract
CronJob->>Constants: Access paymaster/oracle mappings
loop For each chainId in constants
CronJob->>Utils: getNetworkConfig(chainId)
alt Network config found
CronJob->>Provider: Create provider for network
alt Provider created
CronJob->>Paymaster: Fetch/update token prices via oracle
Paymaster-->>CronJob: Return updated price data
else Provider creation fails
CronJob->>CronJob: Log error, continue
end
else Network config missing
CronJob->>CronJob: Log error, continue
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🔇 Additional comments (5)
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 8
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (5)
backend/migrations/2025073000001-seed-data.cjs(1 hunks)backend/src/constants/MultiTokenPaymasterCronJob.ts(1 hunks)backend/src/constants/MultitokenPaymaster.ts(1 hunks)backend/src/server.ts(7 hunks)backend/src/utils/common.ts(1 hunks)
🔇 Additional comments (1)
backend/src/server.ts (1)
364-387: Good improvements to error handling and performance.The changes to reduce cron frequency from 2 to 30 minutes and add comprehensive error handling with explicit logging are excellent improvements for system stability and debugging.
| await queryInterface.sequelize.query(`INSERT INTO "${process.env.DATABASE_SCHEMA_NAME}".multi_token_paymaster ("TOKEN_ADDRESS", "PAYMASTER_ADDRESS", "ORACLE_ADDRESS", "CHAIN_ID", "DECIMALS", "CREATED_AT", "UPDATED_AT", "EP_VERSION") VALUES ('${ethers.utils.getAddress('0xdAC17F958D2ee523a2206206994597C13D831ec7')}', '0x5E6ce32Bb6Fa47001cf87f2f9E07d5Fd3dE57990', '0x3E7d1eAB13ad0104d2750B8863b489D65364e32D', 1, 6, NOW(), NOW(), 'EPV_07')`); | ||
| await queryInterface.sequelize.query(`INSERT INTO "${process.env.DATABASE_SCHEMA_NAME}".multi_token_paymaster ("TOKEN_ADDRESS", "PAYMASTER_ADDRESS", "ORACLE_ADDRESS", "CHAIN_ID", "DECIMALS", "CREATED_AT", "UPDATED_AT", "EP_VERSION") VALUES ('${ethers.utils.getAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48')}', '0x5E6ce32Bb6Fa47001cf87f2f9E07d5Fd3dE57990', '0x8fFfFfd4AfB6115b954Bd326cbe7B4BA576818f6', 1, 6, NOW(), NOW(), 'EPV_07')`); | ||
| await queryInterface.sequelize.query(`INSERT INTO "${process.env.DATABASE_SCHEMA_NAME}".multi_token_paymaster ("TOKEN_ADDRESS", "PAYMASTER_ADDRESS", "ORACLE_ADDRESS", "CHAIN_ID", "DECIMALS", "CREATED_AT", "UPDATED_AT", "EP_VERSION") VALUES ('${ethers.utils.getAddress('0x514910771AF9Ca656af840dff83E8264EcF986CA')}', '0x5E6ce32Bb6Fa47001cf87f2f9E07d5Fd3dE57990', '0x2c1d072e956AFFC0D435Cb7AC38EF18d24d9127c', 1, 18, NOW(), NOW(), 'EPV_07')`); | ||
| await queryInterface.sequelize.query(`INSERT INTO "${process.env.DATABASE_SCHEMA_NAME}".multi_token_paymaster ("TOKEN_ADDRESS", "PAYMASTER_ADDRESS", "ORACLE_ADDRESS", "CHAIN_ID", "DECIMALS", "CREATED_AT", "UPDATED_AT", "EP_VERSION") VALUES ('${ethers.utils.getAddress('0xB8c77482e45F1F44dE1745F52C74426C631bDD52')}', '0x5E6ce32Bb6Fa47001cf87f2f9E07d5Fd3dE57990', '0x14e613AC84a31f709eadbdF89C6CC390fDc9540A', 1, 18, NOW(), NOW(), 'EPV_07')`); | ||
| await queryInterface.sequelize.query(`INSERT INTO "${process.env.DATABASE_SCHEMA_NAME}".multi_token_paymaster ("TOKEN_ADDRESS", "PAYMASTER_ADDRESS", "ORACLE_ADDRESS", "CHAIN_ID", "DECIMALS", "CREATED_AT", "UPDATED_AT", "EP_VERSION") VALUES ('${ethers.utils.getAddress('0xB50721BCf8d664c30412Cfbc6cf7a15145234ad1')}', '0x5E6ce32Bb6Fa47001cf87f2f9E07d5Fd3dE57990', '0x31697852a68433DbCc2Ff612c516d69E3D9bd08F', 1, 18, NOW(), NOW(), 'EPV_07')`); | ||
| await queryInterface.sequelize.query(`INSERT INTO "${process.env.DATABASE_SCHEMA_NAME}".multi_token_paymaster ("TOKEN_ADDRESS", "PAYMASTER_ADDRESS", "ORACLE_ADDRESS", "CHAIN_ID", "DECIMALS", "CREATED_AT", "UPDATED_AT", "EP_VERSION") VALUES ('${ethers.utils.getAddress('0xF57e7e7C23978C3cAEC3C3548E3D615c346e79fF')}', '0x5E6ce32Bb6Fa47001cf87f2f9E07d5Fd3dE57990', '0xBAEbEFc1D023c0feCcc047Bff42E75F15Ff213E6', 1, 18, NOW(), NOW(), 'EPV_07')`); | ||
| await queryInterface.sequelize.query(`INSERT INTO "${process.env.DATABASE_SCHEMA_NAME}".multi_token_paymaster ("TOKEN_ADDRESS", "PAYMASTER_ADDRESS", "ORACLE_ADDRESS", "CHAIN_ID", "DECIMALS", "CREATED_AT", "UPDATED_AT", "EP_VERSION") VALUES ('${ethers.utils.getAddress('0x7D1AfA7B718fb893dB30A3aBc0Cfc608AaCfeBB0')}', '0x5E6ce32Bb6Fa47001cf87f2f9E07d5Fd3dE57990', '0x7bAC85A8a13A4BcD8abb3eB7d6b4d632c5a57676', 1, 18, NOW(), NOW(), 'EPV_07')`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Paymaster address mismatch with constants file.
The paymaster address 0x5E6ce32Bb6Fa47001cf87f2f9E07d5Fd3dE57990 used in this migration differs from the one defined in MultiTokenPaymasterCronJob.ts for chain 1 (0xb5739957aFD931FeDfb25Fb18e2eabe3C69801c5). This inconsistency could lead to issues.
Please verify which address is correct and ensure consistency across all files.
🤖 Prompt for AI Agents
In backend/migrations/2025073000001-seed-data.cjs around lines 5 to 11, the
paymaster address used in the INSERT statements does not match the paymaster
address defined in MultiTokenPaymasterCronJob.ts for chain 1. Verify the correct
paymaster address and update all occurrences in this migration file to use the
consistent, correct address matching the constants file to avoid discrepancies.
| async function down({ context: queryInterface }) { | ||
| await queryInterface.sequelize.query(`DELETE IF EXISTS FROM "${process.env.DATABASE_SCHEMA_NAME}".multi_token_paymaster;`); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix SQL syntax error in DELETE statement.
The SQL syntax is incorrect. DELETE IF EXISTS is not valid SQL syntax.
- await queryInterface.sequelize.query(`DELETE IF EXISTS FROM "${process.env.DATABASE_SCHEMA_NAME}".multi_token_paymaster;`);
+ await queryInterface.sequelize.query(`DELETE FROM "${process.env.DATABASE_SCHEMA_NAME}".multi_token_paymaster;`);📝 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.
| async function down({ context: queryInterface }) { | |
| await queryInterface.sequelize.query(`DELETE IF EXISTS FROM "${process.env.DATABASE_SCHEMA_NAME}".multi_token_paymaster;`); | |
| } | |
| async function down({ context: queryInterface }) { | |
| await queryInterface.sequelize.query(`DELETE FROM "${process.env.DATABASE_SCHEMA_NAME}".multi_token_paymaster;`); | |
| } |
🤖 Prompt for AI Agents
In backend/migrations/2025073000001-seed-data.cjs around lines 14 to 16, the SQL
statement uses invalid syntax "DELETE IF EXISTS". Replace this with a valid SQL
DELETE statement, such as "DELETE FROM" without "IF EXISTS". If conditional
deletion is needed, consider using a WHERE clause or check existence in
application logic before deletion.
| 88888888: { | ||
| '0x97423A68BAe94b5De52d767a17aBCc54c157c0E5': { decimals: 6, symbol: 'USDC' } | ||
| } |
There was a problem hiding this comment.
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 the custom chain ID 88888888.
The chain ID 88888888 appears to be a custom or test network. Please ensure this is intentional and properly documented, as it could cause confusion with standard chain IDs.
🌐 Web query:
What is chain ID 88888888 in blockchain networks? Is it a known testnet or custom network?
💡 Result:
Chain ID 88888888 is associated with the T.E.A.M Blockchain, a custom blockchain network. This network utilizes the TEAM token (symbol: $TEAM) and offers an RPC endpoint at https://88888888.rpc.thirdweb.com. Its block explorer is available at teamscan. (thirdweb.com)
It's important to note that chain IDs are unique identifiers for blockchain networks. The same chain ID can be used by different networks, which may lead to conflicts or confusion. For instance, the chain ID 88888888 has also been used by other networks, such as the Ancient8 Mainnet. (developer.vialabs.io) This overlap can cause issues, like scam warnings when adding networks to wallets like MetaMask. (github.com)
Therefore, while chain ID 88888888 is currently assigned to the T.E.A.M Blockchain, it's advisable to verify the network's details and ensure you're connecting to the correct blockchain to avoid potential issues.
Citations:
- 1: https://thirdweb.com/t.e.a.m-blockchain?utm_source=openai
- 2: https://developer.vialabs.io/general/supported-networks/?utm_source=openai
- 3: Our chain ID is being used by another chain, so when users add the network it is displaying a scam warning MetaMask/metamask-extension#23839
Add documentation and confirmation for chain ID 88888888 (T.E.A.M Blockchain)
Chain ID 88888888 is indeed assigned to the T.E.A.M Blockchain (TEAM token) with RPC https://88888888.rpc.thirdweb.com and explorer “teamscan,” but it’s also been reused by other networks (e.g., Ancient8 Mainnet), which can trigger scam warnings in wallets like MetaMask. To avoid confusion and potential conflicts, please:
- Confirm that you intend to support the T.E.A.M Blockchain and not another network using the same ID.
- Document this chain in backend/src/constants/MultitokenPaymaster.ts (around lines 204–206) with a brief comment linking to the network details (RPC endpoint, explorer, token symbol).
- Update your project’s README or network-configuration docs to include:
- Chain name (“T.E.A.M Blockchain”)
- Chain ID (88888888)
- RPC endpoint and block explorer URL
- Native token symbol ($TEAM)
- (Optional) Consider centralizing supported chains into an enum or config object to prevent future ID collisions.
🤖 Prompt for AI Agents
In backend/src/constants/MultitokenPaymaster.ts around lines 204 to 206, add a
clear comment above the chain ID 88888888 entry confirming it represents the
T.E.A.M Blockchain, including its RPC endpoint, block explorer URL, and native
token symbol ($TEAM). Verify that this is the intended network to support and
not another using the same ID. Additionally, update the project README or
network configuration documentation to list the chain name, ID, RPC, explorer,
and token symbol. Optionally, refactor supported chains into a centralized enum
or config object to avoid future ID conflicts.
| export const MULTI_TOKEN_PAYMASTERS: Record<string, Record<string, string>> = { | ||
| "137": { | ||
| "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0xc2132D05D31c914a87C6611C10748AEb04B58e8F": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0xD6DF932A45C0f255f85145f286eA0b292B21C90B": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x8f3cf7ad23cd3cadbd9735aff958023239c6a063": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x53e0bca35ec356bd5dddfebbd1fc0fd03fabad39": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0xa1c57f48f0deb89f569dfbe6e2b7f46d33606fd4": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0xb5c064f955d8e7f38fe0460c556a72987494ee17": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0xbbba073c31bf03b8acf7c28ef0738decf3695683": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x0b3f868e0be5597d5db7feb59e1cadbb0fdda50a": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x2e1ad108ff1d8c782fcbbb89aad783ac49586756": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0xb33eaad8d922b1083446dc23f610c2567fb5180f": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x1bfd67037b42cf73acf2047067bd4f2c47d9bfd6": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x9a71012b13ca4d3d0cdc72a177df3ef03b0e76a3": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x172370d5cd63279efa6d502dab29171933a610af": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x385eeac5cb85a38a9a07a70c73e0a3271cfb54a7": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0xfa68fb4628dff1028cfec22b4162fccd0d45efb6": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3" | ||
| }, | ||
| "8453": { | ||
| "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x2Ae3F1Ec7F1F5012CFEab0185bfc7aa3cf0DEc22": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x9EaF8C1E34F05a589EDa6BAfdF391Cf6Ad3CB239": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3" | ||
| }, | ||
| "42161": { | ||
| "0xaf88d065e77c8cC2239327C5EDb3A432268e5831": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x912CE59144191C1204E64559FE8253a0e49E6548": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0xfc5A1A6EB076a2C7aD06eD22C90d7E710E35ad0a": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0xFa7F8980b0f1E64A2062791cc3b0871572f1F7f0": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x371c7ec6D8039ff7933a2AA28EB827Ffe1F52f07": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x040d1EdC9569d4Bab2D15287Dc5A4F10F56a56B8": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0xf97f4df75117a78c1A5a0DBb814Af92458539FB4": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0xd4d42F0b6DEF4CE0383636770eF773390d85c61A": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x3E6648C5a70A150A88bCE65F4aD4d506Fe15d2AF": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x17FC002b466eEc40DaE837Fc4bE5c67993ddBd6F": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x6694340fc020c5E6B96567843da2df01b2CE1eb6": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x13Ad51ed4F1B7e9Dc168d8a00cB3f4dDD85EfA60": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0xEC70Dcb4A1EFa46b8F2D97C310C9c4790ba5ffA8": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x3082CC23568eA640225c2467653dB90e9250AaA0": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3" | ||
| }, | ||
| "10": { | ||
| "0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x94b008aA00579c1307B0EF2c499aD98a8ce58e58": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x68f180fcCe6836688e9084f035309E29Bf0A2095": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x8700dAec35aF8Ff88c16BdF0418774CB3D7599B4": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x350a791Bfc2C21F9Ed5d10980Dad2e2638ffa7f6": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x9e1028F5F1D5eDE59748FFceE5532509976840E0": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x4200000000000000000000000000000000000042": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x3c8B650257cFb5f272f799F5e2b4e65093a11a05": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x9Bcef72be871e61ED4fBbc7630889beE758eb81D": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x7F5c764cBc14f9669B88837ca1490cCa17c31607": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3" | ||
| }, | ||
| "56": { | ||
| "0x55d398326f99059fF775485246999027B3197955": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x0E09FaBB73Bd3Ade0a17ECC321fD13a19e81cE82": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x2170Ed0880ac9A755fd29B2688956BD959F933F8": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x1AF3F329e8BE154074D8769D1FFa4eE058B1DBc3": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x1D2F0da169ceB9fC7B3144628dB156f3F6c60dBE": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x14016E85a25aeb13065688cAFB43044C2ef86784": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0xCC42724C6683B7E57334c4E856f4c9965ED682bD": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0xBf5140A22578168FD562DCcF235E5D43A02ce9B1": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0xF8A0BF9cF54Bb92F17374d9e9A321E6a111a51bD": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0xf7DE7E8A6bd59ED41a4b5fe50278b3B7f31384dF": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x7Ddc52c4De30e94Be3A6A0A2b259b2850f421989": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0xAD29AbB318791D579433D831ed122aFeAf29dcfe": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0xaEC945e04baF28b135Fa7c640f624f8D90F1C3a6": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x715D400F88C167884bbCc41C5FeA407ed4D2f8A0": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x90C97F71E18723b0Cf0dfa30ee176Ab653E89F40": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x965F527D9159dCe6288a2219DB51fc6Eef120dD1": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0xfe56d5892BDffC7BF58f2E84BE1b2C32D21C308b": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x4691937a7508860F876c9c0a2a617E7d9E945D4B": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x16939ef78684453bfDFb47825F8a5F714f12623a": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x8F0528cE5eF7B51152A59745bEfDD91D97091d2F": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x762539b45A1dCcE3D36d080F74d1AED37844b878": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x67ee3Cb086F8a16f34beE3ca72FAD36F7Db929e2": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0xFd7B3A77848f1C2D67E05E54d78d174a0C850335": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x1Fa4a73a3F0133f0025378af00236f3aBDEE5D63": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x0Eb3a705fc54725037CC9e008bDede697f62F335": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x0D8Ce2A99Bb6e3B7Db580eD848240e4a0F9aE153": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x8fF795a6F4D97E7887C79beA79aba5cc76444aDf": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x4338665CBB7B2485A8855A139b75D5e34AB0DB94": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x56b6fB708fC5732DEC1Afc8D8556423A2EDcCbD6": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0xa2B726B1145A4773F68593CF171187d8EBe4d495": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x52CE071Bd9b1C4B00A0b92D298c512478CaD67e8": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x47BEAd2563dCBf3bF2c9407fEa4dC236fAbA485A": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x88f1A5ae2A3BF98AEAF342D26B30a79438c9142e": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0xcF6BB5389c92Bdda8a3747Ddb454cB7a64626C63": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x3EE2200Efb3400fAbB9AacF31297cBdD1d435D47": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0xAD6cAEb32CD2c308980a548bD0Bc5AA4306c6c18": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x7083609fCE4d1d8Dc0C979AAb8c869Ea2C873402": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x570A5D26f7765Ecb712C0924E4De545B89fD43dF": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0xbA2aE424d960c26247Dd6c32edC70B295c744C43": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x2eD9a5C8C13b93955103B9a7C167B67Ef4d568a3": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3", | ||
| "0x111111111117dC0aa78b770fA6A738034120C302": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3" | ||
| }, | ||
| "1": { | ||
| "0xdAC17F958D2ee523a2206206994597C13D831ec7": "0xb5739957aFD931FeDfb25Fb18e2eabe3C69801c5", | ||
| "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48": "0xb5739957aFD931FeDfb25Fb18e2eabe3C69801c5", | ||
| "0x514910771AF9Ca656af840dff83E8264EcF986CA": "0xb5739957aFD931FeDfb25Fb18e2eabe3C69801c5", | ||
| "0xB8c77482e45F1F44dE1745F52C74426C631bDD52": "0xb5739957aFD931FeDfb25Fb18e2eabe3C69801c5", | ||
| "0xB50721BCf8d664c30412Cfbc6cf7a15145234ad1": "0xb5739957aFD931FeDfb25Fb18e2eabe3C69801c5", | ||
| "0xF57e7e7C23978C3cAEC3C3548E3D615c346e79fF": "0xb5739957aFD931FeDfb25Fb18e2eabe3C69801c5", | ||
| "0x7D1AfA7B718fb893dB30A3aBc0Cfc608AaCfeBB0": "0xb5739957aFD931FeDfb25Fb18e2eabe3C69801c5" | ||
| }, | ||
| "204": { | ||
| "0x7c6b91D9Be155A6Db01f749217d76fF02A7227F2": "0xb5739957aFD931FeDfb25Fb18e2eabe3C69801c5", | ||
| "0xE7798f023fC62146e8Aa1b36Da45fb70855a77Ea": "0xb5739957aFD931FeDfb25Fb18e2eabe3C69801c5", | ||
| "0x9e5aac1ba1a2e6aed6b32689dfcf62a509ca96f3": "0xb5739957aFD931FeDfb25Fb18e2eabe3C69801c5", | ||
| "0x50c5725949a6f0c72e6c4a641f24049a917db0cb": "0xb5739957aFD931FeDfb25Fb18e2eabe3C69801c5" | ||
| }, | ||
| "888888888": { | ||
| "0x97423A68BAe94b5De52d767a17aBCc54c157c0E5": "0xa056CC60088CEfba94d9e16d5408459039FA8D64" | ||
| }, | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Standardize token address formatting to checksummed addresses.
Token addresses are inconsistently formatted with mixed cases. All Ethereum addresses should be checksummed for consistency and to prevent potential issues.
- "0x8f3cf7ad23cd3cadbd9735aff958023239c6a063": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3",
+ "0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063": "0x386eD13Ba07E1C409693b299BbB9839d05aF20c3",Apply similar checksumming to all lowercase addresses in the file. You can use ethers.utils.getAddress() to get the checksummed version.
🤖 Prompt for AI Agents
In backend/src/constants/MultiTokenPaymasterCronJob.ts from lines 5 to 127, the
token addresses are inconsistently formatted with mixed or lowercase letters. To
fix this, convert all token addresses to their checksummed versions using
ethers.utils.getAddress() to ensure consistent and correct Ethereum address
formatting throughout the file.
| "888888888": { | ||
| "0x97423A68BAe94b5De52d767a17aBCc54c157c0E5": "0xa056CC60088CEfba94d9e16d5408459039FA8D64" | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Document the purpose of chain ID 888888888.
This custom chain ID appears in multiple files. Please add a comment explaining what network this represents (e.g., testnet, local development, etc.).
+ // Custom testnet/development network
"888888888": {
"0x97423A68BAe94b5De52d767a17aBCc54c157c0E5": "0xa056CC60088CEfba94d9e16d5408459039FA8D64"
},📝 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.
| "888888888": { | |
| "0x97423A68BAe94b5De52d767a17aBCc54c157c0E5": "0xa056CC60088CEfba94d9e16d5408459039FA8D64" | |
| }, | |
| // Custom testnet/development network | |
| "888888888": { | |
| "0x97423A68BAe94b5De52d767a17aBCc54c157c0E5": "0xa056CC60088CEfba94d9e16d5408459039FA8D64" | |
| }, |
🤖 Prompt for AI Agents
In backend/src/constants/MultiTokenPaymasterCronJob.ts around lines 124 to 126,
add a comment above the entry for chain ID 888888888 explaining the purpose of
this custom chain ID, specifying which network it represents such as a testnet,
local development, or any other environment. This will clarify its usage for
future maintainers.
| export function getNetworkConfig(key: any, supportedNetworks: any, entryPoint?: string[]) { | ||
| if (supportedNetworks !== '') { | ||
| const buffer = Buffer.from(supportedNetworks, 'base64'); | ||
| const SUPPORTED_NETWORKS = JSON.parse(buffer.toString()) | ||
| const SUPPORTED_NETWORKS = JSON.parse(buffer.toString()); | ||
| if (entryPoint === undefined || entryPoint === null || entryPoint.length === 0) { | ||
| const result = SUPPORTED_NETWORKS.find((chain: any) => chain["chainId"] == key); | ||
| if (!result) { | ||
| return SupportedNetworks.find((chain) => chain.chainId == key); | ||
| } | ||
| return result; | ||
| } | ||
| const result = SUPPORTED_NETWORKS.find((chain: any) => { return chain["chainId"] == key && entryPoint.includes(chain["entryPoint"]) }); | ||
| if (!result) { | ||
| return SupportedNetworks.find((chain) => chain.chainId == key && entryPoint.includes(chain.entryPoint)); | ||
| } | ||
| return result | ||
| } else | ||
| return SupportedNetworks.find((chain) => chain.chainId == key && entryPoint.includes(chain.entryPoint)); | ||
| } else { | ||
| if (entryPoint === undefined || entryPoint === null || entryPoint.length === 0) { | ||
| const result = SupportedNetworks.find((chain) => chain.chainId == key); | ||
| if (!result) { | ||
| return null; | ||
| } | ||
| return result; | ||
| } | ||
| const result = SupportedNetworks.find((chain) => { return chain.chainId == key && entryPoint.includes(chain.entryPoint) }); | ||
| return result ? result : null; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Refactor to reduce code duplication and improve type safety.
The function has duplicate logic for handling cases with and without entryPoint. Also, using any type reduces type safety.
-export function getNetworkConfig(key: any, supportedNetworks: any, entryPoint?: string[]) {
+export function getNetworkConfig(key: string | number, supportedNetworks: string, entryPoint?: string[]) {
+ const isEntryPointProvided = entryPoint !== undefined && entryPoint !== null && entryPoint.length > 0;
+
+ let networks = SupportedNetworks;
if (supportedNetworks !== '') {
const buffer = Buffer.from(supportedNetworks, 'base64');
- const SUPPORTED_NETWORKS = JSON.parse(buffer.toString());
- if (entryPoint === undefined || entryPoint === null || entryPoint.length === 0) {
- const result = SUPPORTED_NETWORKS.find((chain: any) => chain["chainId"] == key);
- if (!result) {
- return SupportedNetworks.find((chain) => chain.chainId == key);
- }
- return result;
- }
- const result = SUPPORTED_NETWORKS.find((chain: any) => { return chain["chainId"] == key && entryPoint.includes(chain["entryPoint"]) });
- if (!result) {
- return SupportedNetworks.find((chain) => chain.chainId == key && entryPoint.includes(chain.entryPoint));
- }
- return result
- } else {
- if (entryPoint === undefined || entryPoint === null || entryPoint.length === 0) {
- const result = SupportedNetworks.find((chain) => chain.chainId == key);
- if (!result) {
- return null;
- }
- return result;
- }
- const result = SupportedNetworks.find((chain) => { return chain.chainId == key && entryPoint.includes(chain.entryPoint) });
- return result ? result : null;
+ networks = JSON.parse(buffer.toString());
}
+
+ const result = networks.find((chain: any) => {
+ const chainIdMatch = chain.chainId == key;
+ if (!isEntryPointProvided) {
+ return chainIdMatch;
+ }
+ return chainIdMatch && entryPoint.includes(chain.entryPoint);
+ });
+
+ if (!result && supportedNetworks !== '') {
+ return SupportedNetworks.find((chain) => {
+ const chainIdMatch = chain.chainId == key;
+ if (!isEntryPointProvided) {
+ return chainIdMatch;
+ }
+ return chainIdMatch && entryPoint.includes(chain.entryPoint);
+ });
+ }
+
+ return result || null;
}📝 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.
| export function getNetworkConfig(key: any, supportedNetworks: any, entryPoint?: string[]) { | |
| if (supportedNetworks !== '') { | |
| const buffer = Buffer.from(supportedNetworks, 'base64'); | |
| const SUPPORTED_NETWORKS = JSON.parse(buffer.toString()) | |
| const SUPPORTED_NETWORKS = JSON.parse(buffer.toString()); | |
| if (entryPoint === undefined || entryPoint === null || entryPoint.length === 0) { | |
| const result = SUPPORTED_NETWORKS.find((chain: any) => chain["chainId"] == key); | |
| if (!result) { | |
| return SupportedNetworks.find((chain) => chain.chainId == key); | |
| } | |
| return result; | |
| } | |
| const result = SUPPORTED_NETWORKS.find((chain: any) => { return chain["chainId"] == key && entryPoint.includes(chain["entryPoint"]) }); | |
| if (!result) { | |
| return SupportedNetworks.find((chain) => chain.chainId == key && entryPoint.includes(chain.entryPoint)); | |
| } | |
| return result | |
| } else | |
| return SupportedNetworks.find((chain) => chain.chainId == key && entryPoint.includes(chain.entryPoint)); | |
| } else { | |
| if (entryPoint === undefined || entryPoint === null || entryPoint.length === 0) { | |
| const result = SupportedNetworks.find((chain) => chain.chainId == key); | |
| if (!result) { | |
| return null; | |
| } | |
| return result; | |
| } | |
| const result = SupportedNetworks.find((chain) => { return chain.chainId == key && entryPoint.includes(chain.entryPoint) }); | |
| return result ? result : null; | |
| } | |
| } | |
| export function getNetworkConfig(key: string | number, supportedNetworks: string, entryPoint?: string[]) { | |
| const isEntryPointProvided = entryPoint !== undefined && entryPoint !== null && entryPoint.length > 0; | |
| let networks = SupportedNetworks; | |
| if (supportedNetworks !== '') { | |
| const buffer = Buffer.from(supportedNetworks, 'base64'); | |
| networks = JSON.parse(buffer.toString()); | |
| } | |
| const result = networks.find((chain: any) => { | |
| const chainIdMatch = chain.chainId == key; | |
| if (!isEntryPointProvided) { | |
| return chainIdMatch; | |
| } | |
| return chainIdMatch && entryPoint.includes(chain.entryPoint); | |
| }); | |
| if (!result && supportedNetworks !== '') { | |
| return SupportedNetworks.find((chain) => { | |
| const chainIdMatch = chain.chainId == key; | |
| if (!isEntryPointProvided) { | |
| return chainIdMatch; | |
| } | |
| return chainIdMatch && entryPoint.includes(chain.entryPoint); | |
| }); | |
| } | |
| return result || null; | |
| } |
🤖 Prompt for AI Agents
In backend/src/utils/common.ts around lines 12 to 39, the getNetworkConfig
function duplicates logic for handling cases with and without entryPoint and
uses the any type, reducing type safety. Refactor by extracting the common find
logic into a single reusable function or variable to avoid repetition, and
replace any types with more specific types or interfaces that describe the
expected structure of supportedNetworks and entryPoint. This will improve
readability, maintainability, and type safety.
Deploying arka with
|
| Latest commit: |
b2430de
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://a6973ea2.arka-3qg.pages.dev |
| Branch Preview URL: | https://develop.arka-3qg.pages.dev |
Description
Types of changes
What types of changes does your code introduce?
Further comments (optional)
Summary by CodeRabbit
New Features
Chores
Refactor
Bug Fixes