Skip to content

Commit

Permalink
Introduce basic eip155 (#22)
Browse files Browse the repository at this point in the history
Co-authored-by: Antony1060 <antoniostignjedec@gmail.com>
  • Loading branch information
lucemans and Antony1060 committed Nov 12, 2023
1 parent 843621f commit b3a0add
Show file tree
Hide file tree
Showing 32 changed files with 737 additions and 53 deletions.
1 change: 1 addition & 0 deletions server/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules/
.wrangler
target/
.env
.idea/
1 change: 1 addition & 0 deletions server/Cargo.lock

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

2 changes: 0 additions & 2 deletions server/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ impl App {
let addr = SocketAddr::from(([0, 0, 0, 0], port));

info!("Listening http on {}", addr);
// println!(" Listening on http://{addr}\n");
// ^^^ Three spaces here to align with enstate.rs header :)

axum::Server::bind(&addr)
.serve(self.router.into_make_service())
Expand Down
1 change: 0 additions & 1 deletion server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ async fn main() {
tracing::subscriber::set_global_default(subscriber).expect("setting default subscriber failed");

info!("📦 enstate.rs v{}", env!("CARGO_PKG_VERSION"));
// println!("📦 enstate.rs v{}", env!("CARGO_PKG_VERSION"));

let state = AppState::new().await;

Expand Down
3 changes: 3 additions & 0 deletions server/src/routes/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,14 @@ pub async fn get(
let cache = Box::new(RedisCache::new(state.redis.clone()));
let rpc = state.provider.get_provider();

let opensea_api_key = state.opensea_api_key.clone();

let profile = Profile::from_address(
address,
query.fresh.unwrap_or(false),
cache,
rpc,
&opensea_api_key,
&state.profile_records,
&state.profile_chains,
)
Expand Down
3 changes: 3 additions & 0 deletions server/src/routes/name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,14 @@ pub async fn get(
let cache = Box::new(RedisCache::new(state.redis.clone()));
let rpc = state.provider.get_provider();

let opensea_api_key = &state.opensea_api_key;

let profile = Profile::from_name(
&name,
query.fresh.unwrap_or(false),
cache,
rpc,
opensea_api_key,
&state.profile_records,
&state.profile_chains,
)
Expand Down
14 changes: 9 additions & 5 deletions server/src/state.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
use enstate_shared::models::{multicoin::cointype::{coins::CoinType, Coins}, records::Records};
use enstate_shared::models::{
multicoin::cointype::{coins::CoinType, Coins},
records::Records,
};
use redis::aio::ConnectionManager;
use std::env;
use tracing::info;

use crate::{
database,
provider::RoundRobinProvider,
};
use crate::{database, provider::RoundRobinProvider};

#[allow(clippy::module_name_repetitions)]
pub struct AppState {
pub redis: ConnectionManager,
pub profile_records: Vec<String>,
pub profile_chains: Vec<CoinType>,
pub rpc_urls: Vec<String>,
pub opensea_api_key: String,
pub provider: RoundRobinProvider,
}

Expand Down Expand Up @@ -47,10 +48,13 @@ impl AppState {

let provider = RoundRobinProvider::new(rpc_urls.clone());

let opensea_api_key = env::var("OPENSEA_API_KEY").expect("OPENSEA_API_KEY not found.");

Self {
redis,
profile_records,
profile_chains: multicoin_chains,
opensea_api_key,
rpc_urls,
provider,
}
Expand Down
1 change: 1 addition & 0 deletions shared/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
target/
.idea/
166 changes: 166 additions & 0 deletions shared/Cargo.lock

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

4 changes: 4 additions & 0 deletions shared/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ rustc-hex = "2.0.1"
serde_json = "1.0.96"
crc32fast = "1.3.2"
hex = "0.4.3"
reqwest = "*"

# ethers-ccip-read = { git = "https://github.com/ensdomains/ethers-ccip-read" }

Expand All @@ -43,6 +44,9 @@ wasm-bindgen-futures = "0.4.36"
wasm-bindgen = { version = "0.2.86", features = ["serde-serialize"] }
web-sys = { version = "0.3.63", features = ["console"] }

[dev-dependencies]
tokio = { version = "1", features = ["full"] }

[profile.release]
lto = true
strip = true
Expand Down
Loading

0 comments on commit b3a0add

Please sign in to comment.