Skip to content

0xStation/spec

Repository files navigation

Station Live Objects

Live Objects for Station.

Developing & Testing Locally

To test live objects locally, first make sure the following requirements are met/installed.

Requirements

  • Node.js >= 16
  • Deno >= 1.3 (+recommend the Deno/Denoland VSCode extension)
  • Postgres >= 14
  • Spec CLI

Helpful Links

Setup

  1. Install the Spec CLI:
$ npm install -g @spec.dev/cli
  1. Login to your account:
$ spec login
  1. Make sure one of your Spec projects has been set as the current one (Spec just needs to use one of your project's api keys when subscribing to input events during testing).
$ spec use project station/internal
  1. Make sure your local postgres instance is running on localhost:5432

Great guides

These guides are currently written with the Allo protocol as reference examples, but should still be very helpful:

https://github.com/spec-dev/allo/tree/master/guides

Random Tips

  • Since the "block-related properties" of your live object get automatically set for you before your event handlers run, you should be able to reference them in your handlers when needed as this.blockNumber, this.blockHash, this.blockTimestamp, and this.chainId, respectively.

  • If you ever need to return early from a handler in a "do nothing" case, make sure to return false -- this tells our live object runner not to try and "auto-save" the live object class after the handler function finishes.

Running the Spec Client Locally

  1. Make sure your CLI and local Spec client are up to date:
$ npm i -g @spec.dev/cli @spec.dev/spec
  1. Make sure Postgres is running
$ psql
  1. Link your local folder (this repo) to your Spec project:
$ spec link project station/internal .
  1. Make sure your .spec/connect.toml is pointed to the local DB you want to run the Spec client against. If you don't have this file yet (since it's gitignored, you can use this as a template):
# Local database.
[local]
name = 'station' # whatever your local db name is
port = 5432
host = 'localhost'
user = '<your-db-username>' # whatever shows up as your user when you type "psql"
password = '' # can just leave blank
  1. Make sure you have both Membership and PointsBalance tables inside your local DB. I assume this is a migration from Prisma.

  2. Make sure your <column> = <property> data mappings are exactly how you want them inside of the Live Columns section of .spec/project.toml:

  3. Jump into your handlers folder and npm install:

$ cd .spec/handlers
$ npm install
$ cd ../../
  1. Back in your root folder, start the Spec client :)
$ spec start

This should kick off the Spec client against your local DB and also locally set up your event handlers (so that you can test these too.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •