Skip to content

Commit

Permalink
Change account logging on startup (#645)
Browse files Browse the repository at this point in the history
* logging change and remove trait

* add new method
  • Loading branch information
marioiordanov authored Nov 12, 2024
1 parent d9ce83c commit e718fc3
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 15 deletions.
11 changes: 4 additions & 7 deletions crates/starknet-devnet-types/src/rpc/contract_address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use crate::patricia_key::{PatriciaKey, PATRICIA_KEY_ZERO};
use crate::serde_helpers::hex_string::{
deserialize_to_prefixed_contract_address, serialize_contract_address_to_prefixed_hex,
};
use crate::traits::ToHexString;

#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
pub struct ContractAddress(pub(crate) PatriciaKey);
Expand All @@ -22,6 +21,10 @@ impl ContractAddress {
pub fn zero() -> Self {
Self(PATRICIA_KEY_ZERO)
}

pub fn to_fixed_hex_string(&self) -> String {
self.0.0.to_fixed_hex_string()
}
}

impl Serialize for ContractAddress {
Expand Down Expand Up @@ -63,12 +66,6 @@ impl From<ContractAddress> for Felt {
}
}

impl ToHexString for ContractAddress {
fn to_prefixed_hex_str(&self) -> String {
self.0.0.to_hex_string()
}
}

impl LowerHex for ContractAddress {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(self.0.0.to_hex_string().as_str())
Expand Down
3 changes: 1 addition & 2 deletions crates/starknet-devnet-types/src/serde_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ pub mod hex_string {
use crate::contract_address::ContractAddress;
use crate::felt::felt_from_prefixed_hex;
use crate::patricia_key::PatriciaKey;
use crate::traits::ToHexString;

pub fn deserialize_to_prefixed_patricia_key<'de, D>(
deserializer: D,
Expand Down Expand Up @@ -103,7 +102,7 @@ pub mod hex_string {
where
S: Serializer,
{
s.serialize_str(contract_address.to_prefixed_hex_str().as_str())
serialize_patricia_key_to_prefixed_hex(&contract_address.0, s)
}

pub fn deserialize_prefixed_hex_string_to_felt<'de, D>(
Expand Down
4 changes: 0 additions & 4 deletions crates/starknet-devnet-types/src/traits.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
use starknet_types_core::felt::Felt;

pub trait ToHexString {
fn to_prefixed_hex_str(&self) -> String;
}

pub trait HashProducer {
type Error;
fn generate_hash(&self) -> Result<Felt, Self::Error>;
Expand Down
3 changes: 1 addition & 2 deletions crates/starknet-devnet/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ use starknet_rs_providers::{JsonRpcClient, Provider, ProviderError};
use starknet_types::chain_id::ChainId;
use starknet_types::rpc::state::Balance;
use starknet_types::serde_helpers::rpc_sierra_contract_class_to_sierra_contract_class::deserialize_to_sierra_contract_class;
use starknet_types::traits::ToHexString;
use tokio::net::TcpListener;
#[cfg(unix)]
use tokio::signal::unix::{signal, SignalKind};
Expand Down Expand Up @@ -86,7 +85,7 @@ fn log_predeployed_accounts(
| Account address | {}
| Private key | {}
| Public key | {}",
account.account_address.to_prefixed_hex_str(),
account.account_address.to_fixed_hex_string(),
account.private_key.to_fixed_hex_string(),
account.public_key.to_fixed_hex_string()
);
Expand Down

0 comments on commit e718fc3

Please sign in to comment.