From 3bd0a1a4cf0891f5c882de13a2453c13201cb028 Mon Sep 17 00:00:00 2001 From: Heemank Verma Date: Fri, 19 Jul 2024 16:06:45 +0530 Subject: [PATCH] update: add env support for Celestia DA client --- .env.example | 6 ++++++ Cargo.lock | 1 + crates/da-clients/celestia/Cargo.toml | 1 + crates/da-clients/celestia/src/config.rs | 5 +++-- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index 57635205..8561f780 100644 --- a/.env.example +++ b/.env.example @@ -11,6 +11,12 @@ ETHEREUM_RPC_URL= MEMORY_PAGES_CONTRACT_ADDRESS= STARKNET_SOLIDITY_CORE_CONTRACT_ADDRESS= +# Celestia DA Client +CELESTIA_DA_RPC_URL=http://localhost:8000 +# CELESTIA_DA_AUTH_TOKEN +CELESTIA_DA_NID=Karnot + + # Starknet STARKNET_PUBLIC_KEY= diff --git a/Cargo.lock b/Cargo.lock index 56a93b60..ab6d436a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3197,6 +3197,7 @@ dependencies = [ "celestia-types", "color-eyre", "da-client-interface", + "dotenv", "jsonrpsee", "mockall", "protobuf", diff --git a/crates/da-clients/celestia/Cargo.toml b/crates/da-clients/celestia/Cargo.toml index d566d447..4db79658 100644 --- a/crates/da-clients/celestia/Cargo.toml +++ b/crates/da-clients/celestia/Cargo.toml @@ -11,6 +11,7 @@ celestia-rpc = "0.2.0" celestia-types = "0.2.0" color-eyre = { workspace = true } da-client-interface = { workspace = true } +dotenv = "0.15.0" jsonrpsee = { version = "0.20.0", features = ["http-client"] } mockall = "0.12.1" protobuf = "3.5.0" diff --git a/crates/da-clients/celestia/src/config.rs b/crates/da-clients/celestia/src/config.rs index 826f6f78..2afc5369 100644 --- a/crates/da-clients/celestia/src/config.rs +++ b/crates/da-clients/celestia/src/config.rs @@ -3,7 +3,7 @@ use std::fs::File; use std::path::PathBuf; use utils::env_utils::get_env_var_or_panic; use serde::Deserialize; - +use dotenv::dotenv; #[derive(Clone, PartialEq, Deserialize, Debug)] pub struct CelestiaDaConfig { pub http_provider: String, @@ -22,10 +22,11 @@ impl TryFrom<&PathBuf> for CelestiaDaConfig { impl DaConfig for CelestiaDaConfig { fn new_from_env() -> Self { + dotenv().ok(); Self { http_provider: get_env_var_or_panic("CELESTIA_DA_RPC_URL"), auth_token: Some(get_env_var_or_panic("CELESTIA_DA_AUTH_TOKEN")), nid: get_env_var_or_panic("CELESTIA_DA_NID"), } } -} +} \ No newline at end of file