(address: string, chainId: number | string)
| 36 | * @returns The ABI as a JSON object or undefined if the fetch fails. |
| 37 | */ |
| 38 | export async function tryFetchAbiFromExplorer(address: string, chainId: number | string): Promise<unknown> { |
| 39 | try { |
| 40 | const result = await runRequest<string>(chainId, { |
| 41 | module: 'contract', |
| 42 | action: 'getabi', |
| 43 | address, |
| 44 | }); |
| 45 | |
| 46 | if (!result) { |
| 47 | return undefined; |
| 48 | } |
| 49 | |
| 50 | return JSON.parse(result); |
| 51 | } catch (e) { |
| 52 | if (e instanceof Error && e.message.includes('Contract source code not verified')) { |
| 53 | return undefined; |
| 54 | } |
| 55 | throw e; |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Fetches the deployment height of a contract from Etherscan. |
no outgoing calls
no test coverage detected