-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor/env utils #447
Refactor/env utils #447
Conversation
crates/utils/src/env_utils.rs
Outdated
} | ||
} | ||
|
||
pub fn get_env_car_optional_or_panic(key: &str) -> Option<String> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub fn get_env_car_optional_or_panic(key: &str) -> Option<String> { | |
pub fn get_env_var_optional_or_panic(key: &str) -> Option<String> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function removed.
crates/utils/src/env_utils.rs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we keep all if they aren't being used right now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Valid, we'll add them when we need them.
Removed for now.
crates/utils/src/lib.rs
Outdated
@@ -0,0 +1 @@ | |||
pub mod env_utils; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need a full crate for this? cc @notlesh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, these are some pretty short utility functions, an entire utils
crate seems like overkill to me as it would come with a lot of extra overhead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@heemankv I would suggest so. Or just inline the code and skip the functions part.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright added, can you re-review @whichqua
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some needed changes. Let me know if you have any thoughts or questions.
@@ -11,6 +12,12 @@ use starknet_api::{contract_address, felt, patricia_key}; | |||
|
|||
use crate::utils::{felt_to_u128, FeltConversionError}; | |||
|
|||
/// Fetches environment variable based on provided key. | |||
/// If key is not found in env, it returns default value provided | |||
pub fn get_env_var_or_default(key: &str, default: &str) -> String { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub fn get_env_var_or_default(key: &str, default: &str) -> String { | |
#[inline] | |
fn get_env_var_or_default(key: &str, default: &str) -> String { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
crates/rpc-replay/Cargo.toml
Outdated
@@ -16,6 +16,7 @@ starknet_api = { workspace = true } | |||
starknet-os-types = { workspace = true } | |||
thiserror = { workspace = true } | |||
tokio = { workspace = true } | |||
serial_test = "3.2.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a dev dependency. +1 if we can avoid adding it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have now updated it to be a dev-dependency, I hope that solves the issue,
This is required to ensure
test_build_block_context_with_default_env_works
test_build_block_context_with_default_env_fails
works together properly.
WDYT ?
); | ||
let eth_fee_token_address = get_env_var_or_default( | ||
"SNOS_ETH_FEE_TOKEN_ADDRESS", | ||
"0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider creating constants for these, something like:
const DEFAULT_ETH_FEE_TOKEN_ADDRESS = ....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Valid, added.
Cargo.toml
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these changes needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are lint changes, will revert to keep as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
3c95181
into
keep-starknet-strange:tmp/snos_devnet_zero_txs
Issue Number: N/A
Type
Description
strk
andeth
token addresses found inrpc-replay
crate.Breaking changes?