Skip to content

Commit

Permalink
Merge pull request #26 from hhamud/chore/docs
Browse files Browse the repository at this point in the history
feat: add make install command and clean up readme
  • Loading branch information
avichalp authored Aug 16, 2024
2 parents 38dcf41 + 8a23c98 commit c62c6c9
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 5 deletions.
51 changes: 50 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,47 @@
DATABASE_URL = "sqlite:farcaster.db"
MIGRATIONS_DIR = "./lib/storage/migrations"

define install_package
if ! command -v $(1) >/dev/null 2>&1; then \
echo "installing $(1)..."; \
$(2); \
fi
endef

define install_rust
if ! command -v rustc >/dev/null 2>&1; then \
echo "installing rust..."; \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y; \
fi
endef

define install_protobuf
if ! command -v protoc >/dev/null 2>&1; then \
echo "installing protobufs compiler..."; \
$(1); \
fi
endef

define install_prerequisites
case $$OSTYPE in \
darwin*) \
echo "detected macos"; \
$(call install_package,brew,/bin/bash -c "$$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"); \
$(call install_rust); \
$(call install_protobuf,brew install protobuf); \
;; \
linux*) \
echo "detected linux"; \
$(call install_rust); \
$(call install_protobuf,sudo apt update && sudo apt install -y protobuf-compiler); \
;; \
*) \
echo "unsupported operating system"; \
exit 1; \
;; \
esac
endef

db-create:
DATABASE_URL=$(DATABASE_URL) sqlx db create

Expand All @@ -10,4 +51,12 @@ db-migrate:
db-query-prepare:
DATABASE_URL=$(DATABASE_URL) cargo sqlx prepare --workspace

.PHONY: db-create db-migrate db-query-prepare
install:
@$(call install_prerequisites)
@if ! command -v sqlx >/dev/null 2>&1; then \
echo "installing sqlx cli..."; \
. $$HOME/.cargo/env && cargo install sqlx-cli; \
fi
@echo "all prerequisites installed successfully!"

.PHONY: db-create db-migrate db-query-prepare install
24 changes: 20 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ If you are new to Farcaster Hubs and/or Teleport - here's a quick video that doe

Note that the codebase will outpace the video, and things mentioned `TODO` in the video might have been done now.

<iframe width="560" height="315" src="https://www.youtube.com/embed/YXu2DGMhIao" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
[![Video](https://img.youtube.com/vi/YXu2DGMhIao/0.jpg)](https://www.youtube.com/watch?v=YXu2DGMhIao)

## Rough Features

Expand All @@ -32,6 +32,12 @@ A lot is still left to do:

## Prerequisites

Run the following command to install all the prerequisites for you automatically and if it fails for any reason then simply manually install them.

``` bash
make install
```

- Rust
- Protobufs Compiler (`brew install protobuf` or `apt install -y protobuf-compiler`)
- SQLx CLI (`cargo install sqlx-cli`)
Expand All @@ -42,7 +48,16 @@ Up until recently, there was a Protobuf incompatibility issue with using `prost`

In a recent update the Protobuf schema was updated to add a new field that allows us to get by that issue by serializing the message differently. That hasn't been implemented yet in Teleport but technically we don't need to maintain a patched version of `prost` anymore.

## Database

## Setup the Hub

Copy the example .env file using the following command and then place both your farcaster private key and optimism l2 key.

``` bash
cp env.example .env
```

### Setup the Database

1. create the database

Expand All @@ -56,8 +71,9 @@ make db-create
make db-migrate
```

## Start the Hub

### Start the hub

```bash
FARCASTER_PRIV_KEY=<YOUR_PRIVATE_KEY> OPTIMISM_L2_RPC_URL=<RPC_URL_FOR_OP> cargo run
cargo run
```

0 comments on commit c62c6c9

Please sign in to comment.