Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: action to add deployed token manager to tenderly project [AXE-2356] #86

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
const { ethers } = require('ethers');
const axios = require('axios').default;

const addToProjectFn = async (context, event) => {
blockchainguyy marked this conversation as resolved.
Show resolved Hide resolved
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] === tokenManagerDeployedHash) {
if (logs[index].data.length < 66) {
throw new Error('INVALID_LOG_DATA_LENGTH');
}

// log data contains address in first 32 bytes i.e. first 64 chars, here data string is also prefixed with 0x.
// data = '0x' + 24 chars (appended 0) + 40 chars (address)
const [deployedAddress] = ethers.utils.defaultAbiCoder.decode(['address'], logs[index].data.substring(0, 66));
const name = `TokenManager-${context.metadata.getNetwork()}-${deployedAddress}`;

console.log(`New TokenManager deployed for chain ${context.metadata.getNetwork()} at address ${deployedAddress}`);

contracts.push({
address: deployedAddress,
display_name: name,
network_id: event.network,
});
}
}

if (contracts.length === 0) throw Error('NO_NEW_TOKEN_MANAGER_DEPLOYED');

try {
await axios.post(
await context.storage.getStr('TenderlyAddContractsURL'),
{ contracts },
{
headers: {
'X-Access-Key': await context.secrets.get('API_TOKEN'),
},
},
);
} catch (error) {
console.log(error.response.status);
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: "axelarEng"
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: "ITS"
Loading