Skip to content

Commit

Permalink
feat: action to add deployed token manager to tenderly project
Browse files Browse the repository at this point in the history
  • Loading branch information
blockchainguyy committed Oct 20, 2023
1 parent d2a36d1 commit e4ccbb1
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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 };
13 changes: 13 additions & 0 deletions tenderly-suite/add-to-project-action/tenderly.yaml
Original file line number Diff line number Diff line change
@@ -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: ""

0 comments on commit e4ccbb1

Please sign in to comment.