Skip to content
Open
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
4 changes: 0 additions & 4 deletions actions/.example.env

This file was deleted.

3 changes: 1 addition & 2 deletions actions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
16 changes: 10 additions & 6 deletions actions/readBalance.ts
Original file line number Diff line number Diff line change
@@ -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"
);
Expand Down Expand Up @@ -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))
}
Expand Down