Conversation
| case '421613': | ||
| baseURL = 'https://api-goerli.arbiscan.io/api' | ||
| break | ||
| case '42161': | ||
| baseURL = 'https://api.arbiscan.io/api' | ||
| break | ||
| default: | ||
| throw new Error(`Unsupported chain ${chainId}`) |
There was a problem hiding this comment.
The current approach of hardcoding the URLs for different chains is not maintainable. If the URLs change in the future, or if new chains are added, the code will need to be updated and redeployed. A more maintainable approach would be to store these URLs in a configuration file or environment variables. This way, changes can be made without modifying the code.
| const etherscanApi = createEtherscanApi(chainId) | ||
| const blockscoutApi = createBlockscoutApi(chainId) | ||
| apis.push(etherscanApi, blockscoutApi) | ||
| break; | ||
| break | ||
| case '421613': | ||
| case '42161': | ||
| const arbiscanApi = createArbiscanApi(chainId) | ||
| apis.push(arbiscanApi) | ||
| break |
There was a problem hiding this comment.
The current implementation creates multiple API instances regardless of the chainId. This could lead to unnecessary memory usage and potential performance issues if the number of APIs grows. It would be more efficient to create only the API instance that corresponds to the provided chainId.
To improve this, consider refactoring the code to create and push the API instance into the apis array only when the chainId matches the specific case. This way, you only instantiate the necessary API, which can help optimize memory usage and improve performance.
No description provided.