{"id":19070808,"url":"https://github.com/mento-protocol/governance-watchdog","last_synced_at":"2026-05-17T14:30:17.482Z","repository":{"id":251907824,"uuid":"829469228","full_name":"mento-protocol/governance-watchdog","owner":"mento-protocol","description":"A system that monitors Mento Governance events on-chain and sends notifications about them to Discord and Telegram","archived":false,"fork":false,"pushed_at":"2024-08-29T12:22:49.000Z","size":331,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-08-29T13:49:51.854Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mento-protocol.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-16T13:43:36.000Z","updated_at":"2024-08-29T12:22:51.000Z","dependencies_parsed_at":"2024-10-25T18:22:15.239Z","dependency_job_id":"7f8ff0e9-ca87-4b23-aead-29a26d2c0da0","html_url":"https://github.com/mento-protocol/governance-watchdog","commit_stats":null,"previous_names":["mento-protocol/governance-watchdog"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mento-protocol%2Fgovernance-watchdog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mento-protocol%2Fgovernance-watchdog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mento-protocol%2Fgovernance-watchdog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mento-protocol%2Fgovernance-watchdog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mento-protocol","download_url":"https://codeload.github.com/mento-protocol/governance-watchdog/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240122574,"owners_count":19751142,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T01:20:41.506Z","updated_at":"2026-05-17T14:30:17.403Z","avatar_url":"https://github.com/mento-protocol.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🐕 Governance Watchdog\n\n\u003c!-- markdown-link-check-disable --\u003e\n\nA system that monitors Mento Governance events on-chain and sends notifications about them to Discord and Telegram. Mento Devs can view the [full project spec in our Notion.](https://www.notion.so/mentolabs/Governance-Watchdog-d168a8110a53430a90e2f5ab65f103f5?pvs=4)\n\n\u003c!-- markdown-link-check-enable --\u003e\n\n- [Local Setup](#local-setup)\n- [Running and testing the Cloud Function locally](#running-and-testing-the-cloud-function-locally)\n- [Testing the Deployed Cloud Function](#testing-the-deployed-cloud-function)\n- [Updating the Cloud Function](#updating-the-cloud-function)\n- [Debugging Problems](#debugging-problems)\n  - [View Logs](#view-logs)\n\n![Architecture Diagram](arch-diagram.png)\n\n## Local Setup\n\n1. Install the `gcloud` CLI\n\n   ```sh\n   # For macOS\n   brew install google-cloud-sdk\n\n   # For other systems, see https://cloud.google.com/sdk/docs/install\n   ```\n\n1. Install `trunk` — one linter to rule them all\n\n   ```sh\n   # For macOS\n   brew install trunk-io\n\n   # For other systems, check https://docs.trunk.io/check/usage\n   ```\n\n   Optionally, you can also install the [Trunk VS Code Extension](https://marketplace.visualstudio.com/items?itemName=Trunk.io)\n\n1. Install `jq` — used in a few shell scripts\n\n   ```sh\n   # For macOS\n   brew install jq\n\n   # For other systems, see https://jqlang.github.io/jq/\n   ```\n\n1. Install `terraform` — to deploy and manage the infra for this project\n\n   ```sh\n   # For macOS\n   brew tap hashicorp/tap\n   brew install hashicorp/tap/terraform\n\n   # For other systems, see https://developer.hashicorp.com/terraform/install\n   ```\n\n1. Run terraform setup script\n\n   ```sh\n   # Checks required permissions, provisions terraform providers and modules, syncs terraform state\n   ./bin/set-up-terraform.sh\n   ```\n\n1. Set your local `gcloud` project and cache project values used in shell scripts:\n\n   ```sh\n   # Will set the correct gcloud project in your terminal and populate a local cache with values frequently used in shell scripts\n   npm run cache:clear\n   ```\n\n1. Create a `./infra/terraform.tfvars` file. This is like `.env` for Terraform:\n\n   ```sh\n   touch ./infra/terraform.tfvars\n   # This file is `.gitignore`d to avoid accidentally leaking sensitive data\n   ```\n\n1. Add the following values to your `terraform.tfvars`. You can either follow the instructions in the comments to look up each value, or you can ask another dev to share his local `terraform.tfvars` with you\n\n   ```hcl\n   # Required for creating new GCP projects\n   # Get it via `gcloud organizations list`\n   org_id               = \"\u003cour-org-id\u003e\"\n\n   # Required for creating new GCP projects\n   # Get it via `gcloud billing accounts list` (pick the GmbH account)\n   billing_account      = \"\u003cour-billing-account-id\u003e\"\n\n   # The Discord Channel where we post notifications to\n   # Get it via `gcloud secrets versions access latest --secret discord-webhook-url`\n   # You need the \"Secret Manager Secret Accessor\" IAM role for this command to succeed\n   discord_webhook_url  = \"\u003cdiscord-webhook-url\u003e\"\n\n   # The Telegram Chat where we post notifications to\n   # Get it via `terraform state show \"google_cloudfunctions2_function.watchdog_notifications\" | grep TELEGRAM_CHAT_ID | awk -F '= ' '{print $2}' | tr -d '\"'`\n   telegram_chat_id     = \"\u003ctelegram-chat-id\u003e\"\n\n   # The Telegram bot used to receive and post notifications\n   # Get it via `gcloud secrets versions access latest --secret telegram-bot-token`\n   telegram_bot_token   = \"\u003ctelegram-bot-token\u003e\"\n\n   # An auth token we use to be able to test deployed functions from our local machines\n   # Get it via `gcloud secrets versions access latest --secret x-auth-token`\n   x_auth_token         = \"\u003cx-auth-token\u003e\"\n\n   # Required for Terraform to be able to create \u0026 destroy QuickAlerts\n   # Get it from the [QuickNode dashboard](https://dashboard.quicknode.com/api-keys)\n   quicknode_api_key    = \"\u003cquicknode-api-key\u003e\"\n\n   # Required to send on-call alerts to VictorOps\n   # Get it from [our VictorOps](https://portal.victorops.com/dash/mento-labs-gmbh#/advanced/stackdriver) and clicking `Integrations` \u003e `Stackdriver` and copying the URL. The routing key can be founder under the [`Settings`](https://portal.victorops.com/dash/mento-labs-gmbh#/routekeys) tab\n   victorops_webhook_url   = \"\u003cvictorops-webhook-url\u003e/\u003cvictorops-routing-key\u003e\"\n   ```\n\n1. Auto-generate a local `.env` file by running `npm run generate:env` — we'll need this to run the cloud function locally\n\n1. Verify that everything works\n\n   ```sh\n   # See if you can fetch logs of the watchdog cloud function\n   npm run logs\n\n   # See if you can manually trigger the deployed watchdog function with some dummy data\n   # Make sure to delete the fake posts from the Telegram \u0026 Discord channels to not spam channel members too much\n   npm run test:prod\n   ```\n\n## Running and testing the Cloud Function locally\n\n- `npm install`\n- `npm run dev` to start a local cloud function with hot-reload via nodemon\n- `npm test` to call the local cloud function with a mocked payload, this will send a real Discord message into the channel belonging to the configured Discord Webhook:\n\n## Testing the Deployed Cloud Function\n\nYou can test the deployed cloud function manually by using the `proposal-created.fixture.json` which contains a similar payload to what a QuickAlert would send to the cloud function:\n\n```sh\nnpm run test:prod\n```\n\n## Updating the Cloud Function\n\nYou have two options, using `terraform` or the `gcloud` cli. Both are perfectly fine to use.\n\n1. Via `terraform` by running `npm run deploy`\n   - How? The npm task will:\n     - Call `terraform apply` which re-deploys the function with the latest code from your local machine (and all other infrastructure that may have changed since the last terraform deploy)\n   - Pros\n     - Keeps the terraform state clean\n     - Same command for all changes, regardless of infra or cloud function code\n   - Cons\n     - Less familiar way of deploying cloud functions (if you're used to `gcloud functions deploy`)\n     - Less log output\n     - Slightly slower because `terraform apply` will always fetch the current state from the cloud storage bucket before deploying\n2. Via `gcloud` by running `npm run deploy:function`\n   - How? The npm task will:\n     - Look up the service account used by the cloud function\n     - Impersonate our shared Terraform Service Account to avoid individual permission issues\n     - Call `gcloud functions deploy` with the correct parameters\n   - Pros\n     - Familiar way of deploying cloud functions\n     - More log output making deployment failures slightly faster to debug\n     - Slightly faster because we're skipping the terraform state lookup\n   - Cons\n     - Will lead to slightly inconsistent terraform state (because terraform is tracking the function source code and its version)\n     - Different commands to remember when updating infra components vs cloud function source code\n     - Will only work for updating a pre-existing cloud function's code, will fail for a first-time deploy\n\n## Debugging Problems\n\n### View Logs\n\nFor most problems, you'll likely want to check the cloud function logs first.\n\n- `npm run logs` will print the latest 50 log entries into your local terminal for quick and easy access\n- `npm run logs:url` will print the URL to the function logs in the Google Cloud Console for full access\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmento-protocol%2Fgovernance-watchdog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmento-protocol%2Fgovernance-watchdog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmento-protocol%2Fgovernance-watchdog/lists"}