Skip to content

Commit 61e4d3b

Browse files
committed
feat: add base support
1 parent 001eba1 commit 61e4d3b

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

src/services/avatar.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ impl AvatarService {
4545
"mainnet" | "ethereum" => SupportedNetworks::Ethereum,
4646
"sepolia" => SupportedNetworks::Sepolia,
4747
"polygon" => SupportedNetworks::Polygon,
48+
"base" => SupportedNetworks::Base,
4849
_ => { continue; }
4950
};
5051

@@ -79,7 +80,8 @@ impl AvatarService {
7980
let provider = match network {
8081
SupportedNetworks::Ethereum => rpc::ethereum::new(),
8182
SupportedNetworks::Sepolia => rpc::sepolia::new(),
82-
SupportedNetworks::Polygon => rpc::polygon::new()
83+
SupportedNetworks::Polygon => rpc::polygon::new(),
84+
SupportedNetworks::Base => rpc::base::new(),
8385
};
8486

8587
let maybe_avatar_info = provider.get_avatar_info_with_metadata(address, self.cache.clone()).await.ok();
@@ -89,4 +91,8 @@ impl AvatarService {
8991

9092
Ok(response)
9193
}
94+
95+
pub async fn listen_contract_events(&self) {
96+
97+
}
9298
}

src/services/rpc/base.rs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
use std::sync::LazyLock;
2+
3+
use alloy::primitives::Address;
4+
5+
use crate::services::rpc::Client;
6+
use crate::supported_networks::SupportedNetworks;
7+
8+
static BASE_RPC_URL: LazyLock<String> = LazyLock::new(|| {
9+
std::env::var("BASE_RPC_URL").expect("BASE_RPC_URL not set")
10+
});
11+
12+
static BASE_AVATAR_SERVICE: LazyLock<String> = LazyLock::new(|| {
13+
std::env::var("BASE_AVATAR_SERVICE").expect("BASE_AVATAR_SERVICE not set")
14+
});
15+
16+
pub fn new() -> Client {
17+
let contract_address = BASE_AVATAR_SERVICE.parse::<Address>().unwrap();
18+
19+
Client::new(SupportedNetworks::Ethereum, &BASE_RPC_URL, contract_address).unwrap()
20+
}

src/services/rpc/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use crate::supported_networks::SupportedNetworks;
1414
pub mod sepolia;
1515
pub mod polygon;
1616
pub mod ethereum;
17+
pub mod base;
1718

1819
const IPFS_GATEWAYS: [&str; 4] = [
1920
"https://ipfs.io/ipfs/",

src/supported_networks.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ use strum::{Display, EnumIter, IntoEnumIterator};
55
pub enum SupportedNetworks {
66
Ethereum,
77
Sepolia,
8-
Polygon
8+
Polygon,
9+
Base
910
}
1011

1112
impl SupportedNetworks {

0 commit comments

Comments
 (0)