Upgrades Alert System
1. Scan for new Upgrade proposals once every 30 minutes
<?php
$jsonFilePath = '/var/www/html/proposals.json';
$jsonContents = file_get_contents($jsonFilePath);
$existingProposals = json_decode($jsonContents, true);
$final = $existingProposals;
$chains = [
"cosmoshub",
"archway",
"axelar",
"canto",
"evmos",
"kava",
"kujira",
"mars",
"meme",
"migaloo",
"oraichain",
"planq",
"provenance",
"stride",
"tenet",
"terra2"
];
foreach ($chains as $chain) {
$api = "https://rest.cosmos.directory/". $chain . "/cosmos/gov/v1beta1/proposals";
$rpc = "https://rpc.cosmos.directory/". $chain;
$ch = curl_init($api . '?proposal_status=2');
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$resp = curl_exec($ch);
curl_close($ch);
$result = json_decode($resp, true);
foreach ($result['proposals'] as $proposal) {
$pid = $proposal['proposal_id'];
$type = $proposal['content']['@type'];
if (strpos($type, 'SoftwareUpgradeProposal') !== false) {
$newProposal = [
"chain" => ucfirst($chain),
"pid" => $pid,
"rpc" => $rpc,
"api" => $api . '/' . $pid,
];
$exists = false;
foreach ($existingProposals as $existingProposal) {
if ($existingProposal['chain'] === $newProposal['chain'] && $existingProposal['pid'] === $newProposal['pid']) {
$exists = true;
break;
}
}
if (!$exists) {
$final[] = $newProposal;
}
}
}
}
echo json_encode($final, JSON_UNESCAPED_SLASHES);
?>2. Update Status & Current Block number once every 5 Minutes
3. NodeJs file to run every 5 Minutes for PagerDuty alerts
Last updated