-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
149 additions
and
0 deletions.
There are no files selected for viewing
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,5 @@ | ||
# Dependency directories | ||
node_modules/ | ||
|
||
# Ignore tsc output | ||
out/**/* |
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,47 @@ | ||
const ethers = require('ethers'); | ||
import { Network, Context, AlertEvent } from '@tenderly/actions'; | ||
const axios = require('axios'); | ||
|
||
// Do not change function name. | ||
const actionFn = async (context: Context, alertEvent: AlertEvent) => { | ||
|
||
const provider = new ethers.providers.JsonRpcProvider(context.gateways.getGateway(Network.MAINNET)); | ||
const key = await context.secrets.get('ACCESS-KEY') | ||
const networkId = "1"; | ||
const tagName = "child"; | ||
|
||
const resp = await provider.send("tenderly_traceTransaction", [`${alertEvent.hash}`]); | ||
const poolCreatedLogs = resp.logs.filter((log: { name: string; }) => log.name === 'PoolCreated'); | ||
const poolInput = poolCreatedLogs[0].inputs.find((input: { name: string; }) => input.name === 'pool'); | ||
const poolAddress = poolInput.value; | ||
|
||
async function callYourApi(childContractAddress: any) { | ||
const axiosInstance = axios.create({ | ||
baseURL: 'https://api.tenderly.co/api/v1' | ||
}); | ||
axiosInstance.defaults.headers.common['X-Access-Key'] = key; | ||
|
||
const contractData = { | ||
"network_id": `${networkId}`, | ||
"address": `${childContractAddress}` | ||
}; | ||
|
||
const tagData = { | ||
"tag":`${tagName}`, | ||
"contract_ids":[`eth:${networkId}:${childContractAddress}`] | ||
} | ||
|
||
try { | ||
await axiosInstance.post(`account/me/project/monitoring/address`, contractData); | ||
await axiosInstance.post(`account/me/project/monitoring/tag`, tagData); | ||
console.log(`Pool contract is: ${childContractAddress}, and has been added with tag ${tagName}`); | ||
} catch (error) { | ||
console.error("Error calling Tenderly API:", error); | ||
} | ||
} | ||
|
||
await callYourApi(poolAddress); | ||
}; | ||
|
||
// Do not change this. | ||
module.exports = { actionFn }; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,14 @@ | ||
{ | ||
"name": "actions", | ||
"scripts": { | ||
"build": "tsc" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^20.12.7", | ||
"typescript": "^4.3.5" | ||
}, | ||
"dependencies": { | ||
"@tenderly/actions": "^0.2.0" | ||
}, | ||
"private": true | ||
} |
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,19 @@ | ||
{ | ||
"compileOnSave": true, | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"noImplicitReturns": true, | ||
"noUnusedLocals": true, | ||
"outDir": "out", | ||
"rootDir": "", | ||
"sourceMap": true, | ||
"strict": true, | ||
"target": "es2020" | ||
}, | ||
"exclude": [ | ||
"**/*.spec.ts" | ||
], | ||
"include": [ | ||
"**/*" | ||
] | ||
} |
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,14 @@ | ||
account_id: "dzeka" | ||
actions: | ||
dzeka/monitoring: | ||
runtime: v2 | ||
sources: actions | ||
specs: | ||
uniswapV3: | ||
description: Monitoring UniswapV3 Factory Contract and adding Child/Pool to Contracts page with proper tag | ||
function: example:actionFn | ||
trigger: | ||
type: alert | ||
alert: {2391be3d-15ae-46d6-8d8d-eb629589d1c0} | ||
execution_type: parallel | ||
project_slug: "monitoring" |