Looking into The Watcher

Written by Rob Haining, Engineer

Posted in: engineering,

Jan 20, 2022

Blog image

As you might have noticed, we recently dropped a new app: The Watcher

This macOS app lives in your status bar and monitors gas prices, ETH prices, as well as the ability to monitor wallets for incoming transfers of ERC20 & ERC721 tokens.

How does The Watcher work?

The Watcher lives in your status bar as a menu-based app. While running, the app updates the gas & ETH/USD sections every 5 minutes, and it updates the watched wallets section every hour. The app uses Daniel Gindi’s Charts library to render the gas & ETH/USD trends – we liked this library for its simplicity & how customizable it could be. Outside of a few third party libraries, the app is written in Swift and utilizes SwiftUI for building the user interface.

Occasionally, you might notice a little gap in the gas chart in particular. We will take whatever data we can get from GasPrice.io, but then we will add in the current gas price at the current time, which can cause a little data gap.

Where does The Watcher source data? 

Initially, this experiment started off solely with “web2” style APIs. We polled GasPrice.io for current gas & historical gas trends, CoinGecko.com for ETH to USD prices, and a combination of APIs from Etherscan & OpenSea to monitor wallets and for ENS resolution.

We made a move to try to use web3 directly as much as possible, and with that in mind, we transitioned to use the blockchain directly to resolve ENS names, monitor wallets, and see what current gas prices are (using Infura.io as a gateway & the web3.swift library from Argent Labs). We maintained the use of web2 style APIs from GasPrice.io for historical gas, as well as CoinGecko.com for ETH to USD prices.

What data does The Watcher store? You aren’t spying on me, are you? 

No, we’re not spying on you while you’re creeping on others! 😹 We don’t send any of the specific information about what wallets you’re watching anywhere. You don’t have to create an account or connect your wallet to use The Watcher.

We do store a bit of data locally via macOS “defaults” in order to personalize the app for you. This ranges from the list of ETH addresses you follow to your notification preferences. If you are comfortable with the Terminal app, you can check what we’re storing at any point via the command `defaults read io.galactic.web3console`. But this data is not saved to Galactic’s servers.

We also use a 3rd party analytics service to help us gauge success of the app, but we don’t share any sensitive data with them. For example, the addresses of your watched wallets are not shared, but we do share the number of wallets being monitored by that instance of The Watcher.

Making The Watcher available via Homebrew

One of the ways to deliver apps to users is Homebrew. Homebrew allows users to install apps via command line. Surely this way of installing apps has a certain crowd, like the programmer or hacker or someone that is allergic to a mouse. We want to make The Watcher available to all kinds of users. 

The first thing we did is to create a separate deployment path for the app in Xcode. 

Once we built the app, we submitted to Apple to be validated (notarized). Follow this guide on how to do it. 

After this process is done, your app is ready for distribution. Export the app from Xcode and compress the file (zip or tar). You’ll need to get the checksum of this zip file to use in the cask file later. Create another file that contains information about the version number. This file can be a .json, .html or  a simple .txt file. We choose the latter. Put the zip file and the version file somewhere on your server where they are accessible from the world.

Creating the cask file is trivial. We followed the guide from https://docs.brew.sh/Cask-Cookbook. Also ensure that you are set up to fork the Homebrew/homebrew-cask repo to create a pull request for your new cask. Here’s The Watcher’s cask file (the-watcher.rb): 

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  cask "the-watcher" do
    version "1.0"
    sha256 "3a38bb76f147a377f4ea25983bcf5bf6a883d08cc3a75d3317c2aba65fbe6bf6"

    url "https://watcher.app/downloads/TheWatcher_v#{version}.zip"
    name "The Watcher"
    desc "Monitor ETH wallets, USD-ETH prices and gas prices"
    homepage "https://watcher.app/"

    livecheck do
      url "https://watcher.app/downloads/latest-version.txt"
      regex(/(\d+(?:\.\d+)+)/)
    end

    depends_on macos: ">= :monterey"

    app "The Watcher.app"

    zap trash: [
      "~/Library/Application Scripts/io.galactic.web3console",
      "~/Library/Containers/io.galactic.web3console",
      "~/Library/Group Containers/2VV9TDDQG6.group.io.galactic.web3console",
    ]
end

Don’t forget to run the audit and style tests that are required for your pull request. You can run them by using brew audit --strict --new-formula --online <cask> and brew style <cask> commands respectively.

1
2
3
4
5
6
% brew  audit --strict --new-formula --online the-watcher
==> Downloading https://watcher.app/downloads/TheWatcher_v1.1.zip
audit for the-watcher: passed

% brew  style the-watcher
1 file inspected, no offenses detected

If everything looks good, submit your pull request. Make sure to do the checklist for the pull request.

Wait for it to be merged by the Homebrew crew. And that’s it. Your app is available on Homebrew.

Last thing, tell all your friends to install your new app, or The Watcher app by typing brew install the-watcher on their terminal. Watch it! It works for real.

Download The Watcher
engineering
General Galactic Corporation
Subscribe

Get the tips and tricks, product updates and memes to your inbox every month.

General Galactic Corporation. © 2022 All rights reserved.