From e4ccbb1b6c1954a55640c1a0e828650fed1a40c9 Mon Sep 17 00:00:00 2001 From: blockchainguyy Date: Fri, 20 Oct 2023 18:04:18 +0530 Subject: [PATCH] feat: action to add deployed token manager to tenderly project --- .../add-to-project/addToProject.js | 41 +++++++++++++++++++ .../add-to-project-action/tenderly.yaml | 13 ++++++ 2 files changed, 54 insertions(+) create mode 100644 tenderly-suite/add-to-project-action/add-to-project/addToProject.js create mode 100644 tenderly-suite/add-to-project-action/tenderly.yaml 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 new file mode 100644 index 000000000..ce079c480 --- /dev/null +++ b/tenderly-suite/add-to-project-action/add-to-project/addToProject.js @@ -0,0 +1,41 @@ +const axios = require('axios').default; + +const URL = 'https://api.tenderly.co/api/v2/accounts/axelarEng/projects/ITS/contracts'; +const TOKEN_MANAGER_DEPLOYED_TOPIC0 = '0x614cc9db96194a8f405df6fbdd25ebc1df6bb741c1fd196cb927d546c1406c34'; + +const addToProjectFn = async (context, event) => { + const logs = event.logs; + const contracts = []; + + for (let index = 0; index < logs.length; ++index) { + if (logs[index].topics[0] === TOKEN_MANAGER_DEPLOYED_TOPIC0) { + const deployedAddress = '0x' + logs[index].data.substring(218, 258); // TODO: can change with final event imp with AXL-2064 + const name = `TokenManager-${context.metadata.getNetwork()}-${deployedAddress}`; // TokenManager + network + address + + contracts.push({ + address: deployedAddress, + display_name: name, + network_id: event.network, + }); + } + } + + if (contracts.length === 0) throw Error('NO_DEPLOYED_CONTRACT_FOUND'); + + try { + await axios.post( + URL, + { contracts }, + { + headers: { + 'X-Access-Key': await context.secrets.get('API_TOKEN'), + }, + }, + ); + } catch (error) { + console.error(error.response.data); + throw Error('CONTRACT_ADDITION_FAILED'); + } +}; + +module.exports = { addToProjectFn }; diff --git a/tenderly-suite/add-to-project-action/tenderly.yaml b/tenderly-suite/add-to-project-action/tenderly.yaml new file mode 100644 index 000000000..2b8875481 --- /dev/null +++ b/tenderly-suite/add-to-project-action/tenderly.yaml @@ -0,0 +1,13 @@ +account_id: "" +actions: + axelareng/its: + runtime: v2 + sources: add-to-project + specs: + add-to-project: + description: This action adds newly deployed TokenManagers to a tenderly project. + function: addToProject:addToProjectFn + trigger: + type: transaction + execution_type: sequential +project_slug: "" \ No newline at end of file