Skip to content

Commit

Permalink
refactor: use tenderly storage for fetching events abi instead of pre…
Browse files Browse the repository at this point in the history
…-calculated hash
  • Loading branch information
blockchainguyy committed Nov 7, 2023
1 parent 736646a commit 67e52c0
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -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');
}
Expand Down

0 comments on commit 67e52c0

Please sign in to comment.