Skip to content

Latest commit

 

History

History
101 lines (71 loc) · 4.13 KB

bot.md

File metadata and controls

101 lines (71 loc) · 4.13 KB

Dev Instructions for Testing ZKMS Bot

Doing this steps in order is more likely to result in success

0. Prerequisites

1. Set up environment

In the environment file apps/passport-server/.env, fill in the TELEGRAM_BOT_TOKEN with the Telegram token you obtained in the prerequisites section. If this file does not exist, follow the instructions in the README.

2. Start the Passport Client and Server

  yarn
  yarn build
  yarn localdb:init && yarn localdb:up
  yarn passport:dev

3. Sync the Dev Tickets

  • cd apps/passport-server && yarn scratch new-dev-event <token>
    • Note: You can call yarn scratch new-dev-event <token> <orgUrl> <eventId> <activeItemIds> to pull from a specific event
  • Copy the output from the scratch script (ex: /link ProgCrypto (Internal Test))
  • You will paste the output in the following step.

4. PCD Join / Auth flow in Telegram

  • Make a new private group chat in the Telegram app (ex: test chat).
  • Go to the chat with your bot (ex: https://t.me/zulearn_bot)
  • Go to Info, then click Add to group or channel. Add the bot to test chat
  • Now, in test chat, type /link. You should get a message confirming that the test event was linked to the TG chat.
  • You can double check by using a GUI like Postico to view the telegram_bot_events table.

5. Putting it All Together

  • In the Telegram app, go to the chat with your bot and type /start

  • Click Generate ZKP

  • Follow the link to Zupass within Telegram (http://localhost:3000) and hit Prove when your ticket appears

  • If this is your first time, you will need to make a new Zupass account:

    • Make a new Zupass account with an email you know has a ticket for the event in question (ivan@0xparc.org should work).
    • Note: This account will only exist locally on your device
  • You should be returned to the Telegram app and presented with the Send ZKP option.

  • Click Send ZKP, then you will be redirected to test_chat

6. (optional) Hot Reloading for TG Development

This is a one-time setup for serving https locally. You need it for Telegram, because Telegram hates http and localhost. At the end, you will be able to access 127.0.0.1 (aka localhost) from a fake domain, dev.local (this is important for https)

  1. Install mkcert - https://github.com/FiloSottile/mkcert

  2. After installing, create a new local Certificate Authority (CA)

    mkcert -install
  3. Now, run the follow commands from the repo root to generate a new certificate

    mkdir apps/certificates && cd apps/certificates && mkcert dev.local
  4. Add the local domain to the hosts file.

    sudo vi /etc/hosts
    # and add a line in /etc/hosts,
    127.0.0.1 dev.local localhost
  5. In passport-client/.env and passport-server/.env

    # passport-client
    IS_LOCAL_HTTPS=true
    PASSPORT_SERVER_URL="https://dev.local:3002"
    # passport-server
    
    # ... a bunch of other stuff
    IS_LOCAL_HTTPS=true
    PASSPORT_SERVER_URL="https://dev.local:3002"
    PASSPORT_CLIENT_URL="https://dev.local:3000"

Troubleshooting

  • When restarting your database, make sure to run localdb:restart not yarn localdb:init && yarn localdb:up.

    • If you do accidentally run init, you will clear all local data. This is ok, but it causes some problems because your local Zupass ticket still exists in localStorage in the Telegram Web View of Zupass, but doesn't exist in the database.
    • To rectify this situation, you should clear localStorage on Telegram Zupass by right-clicking the on the Web view, then selecting Inspect Element. From there, you can go to the Storage tab and clear everything.
    • Then, you just have to login again with an account that has a ticket