diff --git a/README.md b/README.md index 9919d7f..1723bfa 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,6 @@ is running with pnpm version 9.11.0. pnpm i ``` - #### Notable Envio CLI commands This command will generate the `generated` folder for the repo based on the latest `config.yaml` and `schema.graphql` files. diff --git a/package.json b/package.json index 6ec67e4..cd42eaa 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "dev": "envio dev", "codegen": "envio codegen", "start": "ts-node generated/src/Index.bs.js", - "test": "mocha --recursive --require ts-node/register \"test/**/*.ts\" --timeout 20000", + "test": "mocha --recursive --require ts-node/register \"test/**/*.ts\" --timeout 30000", "enable-hydra": "./hack/hydra-mode/hydra-mode.sh" }, "devDependencies": { diff --git a/schema.graphql b/schema.graphql index 2d6b68b..8e16b25 100644 --- a/schema.graphql +++ b/schema.graphql @@ -117,6 +117,7 @@ type VotingReward_NotifyReward { from: String! reward: String! epoch: BigInt! @config(precision: 76) + pool: String! amount: BigInt! @config(precision: 76) sourceAddress: String! timestamp: Timestamp! diff --git a/src/EventHandlers/CLFactory.ts b/src/EventHandlers/CLFactory.ts index b99426e..acf10e4 100644 --- a/src/EventHandlers/CLFactory.ts +++ b/src/EventHandlers/CLFactory.ts @@ -43,11 +43,16 @@ CLFactory.PoolCreated.handlerWithLoader({ for (let poolTokenAddressMapping of poolTokenAddressMappings) { if (poolTokenAddressMapping.tokenInstance == undefined) { - const { symbol: tokenSymbol } = await getErc20TokenDetails( - poolTokenAddressMapping.address, - event.chainId - ); - poolTokenSymbols.push(tokenSymbol); + try { + const { symbol: tokenSymbol } = await getErc20TokenDetails( + poolTokenAddressMapping.address, + event.chainId + ); + poolTokenSymbols.push(tokenSymbol); + } catch (error) { + context.log.error(`Error in cl factory fetching token details` + + ` for ${poolTokenAddressMapping.address} on chain ${event.chainId}: ${error}`); + } } else { poolTokenSymbols.push(poolTokenAddressMapping.tokenInstance.symbol); } diff --git a/src/EventHandlers/PoolFactory.ts b/src/EventHandlers/PoolFactory.ts index 5fd6655..b1415a2 100644 --- a/src/EventHandlers/PoolFactory.ts +++ b/src/EventHandlers/PoolFactory.ts @@ -35,11 +35,16 @@ PoolFactory.PoolCreated.handlerWithLoader({ for (let poolTokenAddressMapping of poolTokenAddressMappings) { if (poolTokenAddressMapping.tokenInstance == undefined) { - const { symbol: tokenSymbol } = await getErc20TokenDetails( - poolTokenAddressMapping.address, - event.chainId - ); - poolTokenSymbols.push(tokenSymbol); + try { + const { symbol: tokenSymbol } = await getErc20TokenDetails( + poolTokenAddressMapping.address, + event.chainId + ); + poolTokenSymbols.push(tokenSymbol); + } catch (error) { + context.log.error(`Error in pool factory fetching token details` + + ` for ${poolTokenAddressMapping.address} on chain ${event.chainId}: ${error}`); + } } else { poolTokenSymbols.push(poolTokenAddressMapping.tokenInstance.symbol); } diff --git a/src/EventHandlers/Voter/SuperchainLeafVoter.ts b/src/EventHandlers/Voter/SuperchainLeafVoter.ts index f7ced21..056606e 100644 --- a/src/EventHandlers/Voter/SuperchainLeafVoter.ts +++ b/src/EventHandlers/Voter/SuperchainLeafVoter.ts @@ -235,22 +235,27 @@ SuperchainLeafVoter.WhitelistToken.handlerWithLoader({ context.Token.set(updatedToken as Token); return; } else { - const tokenDetails = await getErc20TokenDetails( - event.params.token, - event.chainId - ); - const updatedToken: Token = { - id: TokenIdByChain(event.params.token, event.chainId), - name: tokenDetails.name, - symbol: tokenDetails.symbol, - pricePerUSDNew: 0n, - address: event.params.token, - chainId: event.chainId, - decimals: BigInt(tokenDetails.decimals), - isWhitelisted: event.params._bool, - lastUpdatedTimestamp: new Date(event.block.timestamp * 1000), - }; - context.Token.set(updatedToken); + try { + const tokenDetails = await getErc20TokenDetails( + event.params.token, + event.chainId + ); + const updatedToken: Token = { + id: TokenIdByChain(event.params.token, event.chainId), + name: tokenDetails.name, + symbol: tokenDetails.symbol, + pricePerUSDNew: 0n, + address: event.params.token, + chainId: event.chainId, + decimals: BigInt(tokenDetails.decimals), + isWhitelisted: event.params._bool, + lastUpdatedTimestamp: new Date(event.block.timestamp * 1000), + }; + context.Token.set(updatedToken); + } catch (error) { + context.log.error(`Error in superchain leaf voter whitelist token event fetching token details` + + ` for ${event.params.token} on chain ${event.chainId}: ${error}`); + } } }, }); diff --git a/src/EventHandlers/Voter/Voter.ts b/src/EventHandlers/Voter/Voter.ts index 7e2c899..f6dfd37 100644 --- a/src/EventHandlers/Voter/Voter.ts +++ b/src/EventHandlers/Voter/Voter.ts @@ -232,22 +232,26 @@ Voter.WhitelistToken.handlerWithLoader({ context.Token.set(updatedToken as Token); return; } else { - const tokenDetails = await getErc20TokenDetails( - event.params.token, - event.chainId - ); - const updatedToken: Token = { - id: TokenIdByChain(event.params.token, event.chainId), - name: tokenDetails.name, - symbol: tokenDetails.symbol, - pricePerUSDNew: 0n, - address: event.params.token, - chainId: event.chainId, - decimals: BigInt(tokenDetails.decimals), - isWhitelisted: event.params._bool, - lastUpdatedTimestamp: new Date(event.block.timestamp * 1000), - }; - context.Token.set(updatedToken); + try { + const tokenDetails = await getErc20TokenDetails( + event.params.token, + event.chainId + ); + const updatedToken: Token = { + id: TokenIdByChain(event.params.token, event.chainId), + name: tokenDetails.name, + symbol: tokenDetails.symbol, + pricePerUSDNew: 0n, + address: event.params.token, + chainId: event.chainId, + decimals: BigInt(tokenDetails.decimals), + isWhitelisted: event.params._bool, + lastUpdatedTimestamp: new Date(event.block.timestamp * 1000), + }; + context.Token.set(updatedToken); + } catch (error) { + context.log.error(`Error in whitelist token event fetching token details for ${event.params.token} on chain ${event.chainId}: ${error}`); + } } }, }); diff --git a/src/EventHandlers/VotingReward.ts b/src/EventHandlers/VotingReward.ts index ad1cb49..e796476 100644 --- a/src/EventHandlers/VotingReward.ts +++ b/src/EventHandlers/VotingReward.ts @@ -41,8 +41,13 @@ VotingReward.NotifyReward.handlerWithLoader({ ]); if (!storedToken) { - const rewardTokenDetails = await getTokenPriceData(event.params.reward, event.block.number, event.chainId); - rewardToken = rewardTokenDetails; + try { + const rewardTokenDetails = await getTokenPriceData(event.params.reward, event.block.number, event.chainId); + rewardToken = rewardTokenDetails; + } catch (error) { + context.log.error(`Error in voting reward notify reward event fetching token details` + + ` for ${event.params.reward} on chain ${event.chainId}: ${error}`); + } } else { rewardToken = { pricePerUSDNew: storedToken.pricePerUSDNew, @@ -58,6 +63,7 @@ VotingReward.NotifyReward.handlerWithLoader({ from: event.params.from, reward: event.params.reward, epoch: event.params.epoch, + pool: loaderReturn?.currentLiquidityPool?.id ?? "", amount: event.params.amount, timestamp: new Date(event.block.timestamp * 1000), sourceAddress: event.srcAddress,