Skip to content

Commit 2d7807e

Browse files
committed
switch from .env to .toml config file instead
1 parent 06ace34 commit 2d7807e

File tree

7 files changed

+26
-11
lines changed

7 files changed

+26
-11
lines changed

.env.example

Lines changed: 0 additions & 2 deletions
This file was deleted.

.gitignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,3 @@ __pycache__/
3636
# Rust bindings for smart contracts
3737
timeboost-contract/src/bindings
3838
foundry.lock
39-
40-
# env var files that may contains secrets
41-
.env*
42-
!.env*.example

Cargo.lock

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ tokio = { version = "1", default-features = false, features = ["full"] }
9292
tokio-stream = "0.1.17"
9393
tokio-tungstenite = { version = "0.27.0", features = ["rustls-tls-webpki-roots", "url"] }
9494
tokio-util = "0.7.15"
95+
toml = "0.8"
9596
tonic = "0.14.1"
9697
tonic-prost = "0.14.1"
9798
tonic-prost-build = "0.14.1"

test-configs/keymanager.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[wallet]
2+
mnemonic = "test test test test test test test test test test test junk"
3+
index = 0

timeboost-contract/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ rust-version.workspace = true
88
[dependencies]
99
alloy = { workspace = true }
1010
anyhow = { workspace = true }
11-
dotenvy = "0.15"
1211
rand = { workspace = true }
1312
tracing = { workspace = true }
13+
serde = { workspace = true }
1414
tokio = { workspace = true }
15+
toml = { workspace = true }
1516

1617
[build-dependencies]
1718
alloy = { workspace = true }

timeboost-contract/src/lib.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use alloy::{
88
transports::http::reqwest::Url,
99
};
1010
use anyhow::Result;
11+
use serde::Deserialize;
1112

1213
// Include the generated contract bindings
1314
// The build script auto-detects contracts and generates bindings in src/bindings/
@@ -19,14 +20,28 @@ mod sol_types;
1920
use provider::{HttpProviderWithWallet, TestProviderWithWallet, build_provider};
2021
pub use sol_types::*;
2122

23+
/// Config type for the key manager who has the permission to update the KeyManager contract
24+
/// See `test-configs/keymanager.toml` for an example
25+
#[derive(Deserialize)]
26+
struct KeyManagerConfig {
27+
wallet: LocalWalletConfig,
28+
}
29+
30+
#[derive(Deserialize)]
31+
struct LocalWalletConfig {
32+
mnemonic: String,
33+
index: u32,
34+
}
35+
2236
/// Connect to a real blockchain, deploy the KeyManager contract, set the
2337
/// `TIMEBOOST_KEY_MANAGER_MNEMONIC` as the manager.
2438
/// Returns the (wallet provider, KeyManager address).
2539
pub async fn init_chain(chain: Url) -> Result<(HttpProviderWithWallet, Address)> {
26-
dotenvy::dotenv()?;
40+
let config =
41+
toml::from_str::<KeyManagerConfig>(include_str!("../../test-configs/keymanager.toml"))?;
2742

28-
let mnemonic = dotenvy::var("TIMEBOOST_KEY_MANAGER_MNEMONIC")?;
29-
let account_idx = dotenvy::var("TIMEBOOST_KEY_ACCOUNT_INDEX")?.parse::<u32>()?;
43+
let mnemonic = config.wallet.mnemonic;
44+
let account_idx = config.wallet.index;
3045
let provider = build_provider(mnemonic, account_idx, chain);
3146

3247
let km_addr =

0 commit comments

Comments
 (0)