From 67e52c0a8d8eaa07a52c366dd8cf0d66e7cf27b9 Mon Sep 17 00:00:00 2001 From: blockchainguyy Date: Tue, 7 Nov 2023 14:43:50 +0530 Subject: [PATCH] refactor: use tenderly storage for fetching events abi instead of pre-calculated hash --- .../add-to-project-action/add-to-project/addToProject.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tenderly-suite/add-to-project-action/add-to-project/addToProject.js b/tenderly-suite/add-to-project-action/add-to-project/addToProject.js index c9a49389..154e2b3b 100644 --- a/tenderly-suite/add-to-project-action/add-to-project/addToProject.js +++ b/tenderly-suite/add-to-project-action/add-to-project/addToProject.js @@ -1,17 +1,19 @@ +const { ethers } = require('ethers'); const axios = require('axios').default; -const TOKEN_MANAGER_DEPLOYED_TOPIC0 = '0x5284c2478b9c1a55e973429331078be39b5fb3eeb9d87d10b34d65a4c89ee4eb'; - const addToProjectFn = async (context, event) => { if (!event || !event.logs || !context || !context.metadata) { throw new Error('INVALID_INPUT_FOR_ACTION'); } + const { tokenManagerDeployed } = await context.storage.getJson('EventsABI'); + const tokenManagerDeployedHash = ethers.utils.keccak256(ethers.utils.toUtf8Bytes(tokenManagerDeployed)); + const logs = event.logs; const contracts = []; for (let index = 0; index < logs.length; ++index) { - if (logs[index].topics[0] === TOKEN_MANAGER_DEPLOYED_TOPIC0) { + if (logs[index].topics[0] === tokenManagerDeployedHash) { if (logs[index].data.length < 66) { throw new Error('INVALID_LOG_DATA_LENGTH'); }