-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: action to add deployed token manager to tenderly project
- Loading branch information
1 parent
d2a36d1
commit e4ccbb1
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
tenderly-suite/add-to-project-action/add-to-project/addToProject.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: "" |