diff --git a/actions/.example.env b/actions/.example.env deleted file mode 100644 index 333dd75..0000000 --- a/actions/.example.env +++ /dev/null @@ -1,4 +0,0 @@ -# Example values -DISCORD_WEBHOOK="https://discord.com/api/webhooks/..." -TELEGRAM_TOKEN="1259850921:31098ageeg3ngRLQKNERr90rwn0rnoiaenf" -TELEGRAM_CHAT_ID="-0982149857132" \ No newline at end of file diff --git a/actions/package.json b/actions/package.json index c58e629..58f3a4a 100755 --- a/actions/package.json +++ b/actions/package.json @@ -10,8 +10,7 @@ "typescript": "^4.3.5" }, "dependencies": { - "@tenderly/actions": "^0.1.0", - "dotenv": "^16.0.3" + "@tenderly/actions": "^0.1.0" }, "private": true } diff --git a/actions/readBalance.ts b/actions/readBalance.ts index 2892f0a..b62781e 100755 --- a/actions/readBalance.ts +++ b/actions/readBalance.ts @@ -1,11 +1,8 @@ -import dotenv from 'dotenv' import { ActionFn, Context, Event, BlockEvent } from "@tenderly/actions"; import { BigNumber, Contract, ethers } from "ethers"; import { abi as jbV3EthTerminalAbi } from "./artifacts/JBETHPaymentTerminal.json"; -dotenv.config() - const provider = new ethers.providers.JsonRpcProvider( "https://rpc.ankr.com/eth" ); @@ -131,16 +128,23 @@ export const readBalance: ActionFn = async (context: Context, event: Event) => { const message = `cumSum: ${cumSum}` console.log('Message: ', message); + const DISCORD_WEBHOOK = context.secrets.get("DISCORD_WEBHOOK") + const DISCORD_ROLE_ID = context.secrets.get("DISCORD_ROLE_ID") + const TELEGRAM_TOKEN = context.secrets.get("TELEGRAM_TOKEN") + const TELEGRAM_CHAT_ID = context.secrets.get("TELEGRAM_CHAT_ID") + + await Promise.all([DISCORD_WEBHOOK, DISCORD_ROLE_ID, TELEGRAM_TOKEN, TELEGRAM_CHAT_ID]) + // Discord hook - fetch(process.env.DISCORD_WEBHOOK as unknown as URL, { - body: JSON.stringify({ content: message }), + fetch(DISCORD_WEBHOOK as unknown as URL, { + body: JSON.stringify({ content: `<@&${DISCORD_ROLE_ID}>: ${message}` }), method: 'POST', headers: { 'Content-Type': 'application/json' }, }).then(res => res.json()) .then(json => console.log('Discord Response: ', json)) // Telegram hook - fetch(`https://api.telegram.org/bot${process.env.TELEGRAM_TOKEN}/sendMessage?chat_id=${process.env.TELEGRAM_CHAT_ID}&text=${message}`) + fetch(`https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendMessage?chat_id=${TELEGRAM_CHAT_ID}&text=${message}`) .then(res => res.json()) .then(json => console.log('Telegram Response: ', json)) }