Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring #28

Merged
merged 23 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 86 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 4 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
[workspace]
members = [
"lib/cli",
"lib/common",
"lib/rpc",
"lib/hub",
"lib/eth",
"lib/storage",
"crates/*"
]

resolver = "2"

[workspace.package]
authors = ["openfarcaster"]
authors = ["openfarcaster", "Hamza Hamud <[email protected]>"]
name = "teleport"
license = "MIT"
version = "0.1.0"
Expand Down Expand Up @@ -66,3 +62,4 @@ dotenv = { version = "0.15.0" }
codegen-units = 1
lto = true
strip = true

4 changes: 2 additions & 2 deletions Config.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
db_path = "sqlite:./farcaster.db"
db_migrations_path = "./lib/storage/migrations"
db_migrations_path = "./crates/storage/migrations"
farcaster_priv_key = ""
optimism_l2_rpc_url = "https://mainnet.optimism.io"
chain_id = 10
id_registry_address = "0x00000000Fc6c5F01Fc30151999387Bb99A9f489b"
key_registry_address = "0x00000000Fc1237824fb747aBDE0FF18990E59b7e"
storage_registry_address = "0x00000000fcce7f938e7ae6d3c335bd6a1a7c593d"
abi_dir = "./lib/eth/abis"
abi_dir = "./crates/eth/abis"
indexer_interval = 60 # This value is in seconds
bootstrap_addrs = ["/ip4/107.21.22.118/tcp/2282"]
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2024 Openfarcaster

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 changes: 25 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,28 @@ install:
fi
@echo "all prerequisites installed successfully!"

.PHONY: db-create db-migrate db-query-prepare install
check:
@echo "Check: Running cargo check"
cargo check

test:
@echo "Test: Running cargo test"
cargo test

fmt:
@echo "Fmt: Running cargo fmt"
cargo +nightly fmt --all -- --check

clippy:
@echo "Clippy: Running cargo clippy"
cargo clippy -- -D warnings

verify:
@echo "Running all checks"
@make check
@make test
@make fmt
@make clippy


.PHONY: db-create db-migrate db-query-prepare install clippy fmt test check verify
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,16 @@ make db-migrate
```bash
cargo run
```



## Contributing

Make sure to run the following command before pushing commits as this will run all the checks needed to pass the CI workflow.

``` bash
make verify
```



6 changes: 3 additions & 3 deletions lib/cli/Cargo.toml → crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[package]
authors = { workspace = true }
description = "CLI for teleport"
edition = { workspace = true }
name = "teleport_cli"
authors = { workspace = true }
edition = { workspace = true }
homepage = { workspace = true }
license = { workspace = true }
readme = { workspace = true }
repository = { workspace = true }
version = { workspace = true }

[dependencies]
clap = { workspace = true }
clap = { workspace = true }
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 16 additions & 0 deletions crates/config/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
authors.workspace = true
name = "teleport_config"
description = "Config build for teleport"
license.workspace = true
version.workspace = true
edition.workspace = true
readme.workspace = true
homepage.workspace = true
repository.workspace = true

[dependencies]
dotenv = {workspace = true}
figment = {workspace = true}
serde = {workspace = true}
serde_json = { workspace = true }
34 changes: 34 additions & 0 deletions crates/config/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
use figment::{
providers::{Env, Format, Toml},
Figment,
};

use dotenv::dotenv;
use serde::Deserialize;

#[derive(Debug, PartialEq, Deserialize, Clone, Default)]
pub struct Config {
pub db_path: String,
pub db_migrations_path: String,
pub farcaster_priv_key: String,
pub optimism_l2_rpc_url: String,
pub chain_id: u32,
pub id_registry_address: String,
pub key_registry_address: String,
pub storage_registry_address: String,
pub abi_dir: String,
pub indexer_interval: u64,
pub bootstrap_addrs: Vec<String>,
}

impl Config {
pub fn new() -> Self {
dotenv().ok();
// Load configuration from a TOML file and override with environment variables
Figment::new()
.merge(Toml::file("Config.toml"))
.merge(Env::raw())
.extract()
.expect("configuration error")
}
}
Loading
Loading