From 82fb292e98ea89e44515ea9500301e0cdb49b8be Mon Sep 17 00:00:00 2001 From: Ford Date: Wed, 22 Nov 2023 10:09:09 -0800 Subject: [PATCH] indexer-agent: Add fallback if decimals() call to DAI contract fails --- packages/indexer-agent/src/cost.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/indexer-agent/src/cost.ts b/packages/indexer-agent/src/cost.ts index aa564786d..a97677d91 100644 --- a/packages/indexer-agent/src/cost.ts +++ b/packages/indexer-agent/src/cost.ts @@ -87,7 +87,16 @@ const monitorAndInjectDai = async ({ // Identify the decimals used by the DAI or USDC contract const chainId = ethereum.network.chainId const stableCoin = new Contract(daiContractAddress, ERC20_ABI, ethereum) - const decimals = await stableCoin.decimals() + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const decimals = await stableCoin.decimals().catch((error: any) => { + logger.warn( + `Failed to call 'decimals()' on '${daiContractAddress}', defaulting to '18'`, + { + error, + }, + ) + return 18 + }) const DAI = new Token(chainId, daiContractAddress, decimals) const GRT = new Token(chainId, contracts.token.address, 18)