Add common crate to access env variables

In the future, we should use a proper secret store (not just env variables).
This lets us update one block of code and not n in the future.
This commit is contained in:
Luke Parker
2023-07-17 00:50:46 -04:00
parent 845c2842b5
commit 0a367bfbda
11 changed files with 54 additions and 4 deletions

View File

@@ -35,6 +35,8 @@ tokio = { version = "1", features = ["full"] }
serai-db = { path = "../common/db", features = ["rocksdb"] }
rocksdb = "0.21"
serai-env = { path = "../common/env" }
serai-primitives = { path = "../substrate/primitives" }
jsonrpsee = { version = "0.16", features = ["server"] }

View File

@@ -100,10 +100,10 @@ fn ack_message(service: Service, id: u64, _signature: SchnorrSignature<Ristretto
async fn main() {
// Open the DB
let db =
Arc::new(rocksdb::TransactionDB::open_default(std::env::var("DB_PATH").unwrap()).unwrap());
Arc::new(rocksdb::TransactionDB::open_default(serai_env::var("DB_PATH").unwrap()).unwrap());
let read_key = |str| {
let Ok(key) = std::env::var(str) else { None? };
let Ok(key) = serai_env::var(str) else { None? };
let mut repr = <<Ristretto as Ciphersuite>::G as GroupEncoding>::Repr::default();
repr.as_mut().copy_from_slice(&hex::decode(key).unwrap());