Skip to content

Commit

Permalink
build: impl display for fee and contractaddress structs
Browse files Browse the repository at this point in the history
  • Loading branch information
AvivYossef-starkware committed Jun 17, 2024
1 parent 0845b3a commit 4c23cae
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ pub const BLOCK_HASH_TABLE_ADDRESS: ContractAddress = ContractAddress(PatriciaKe
Default,
Copy,
Clone,
Display,
Eq,
PartialEq,
Hash,
Expand Down Expand Up @@ -305,7 +306,9 @@ pub struct StateDiffCommitment(pub PoseidonHash);
PartialOrd,
Ord,
derive_more:: Deref,
Display,
)]
#[display(fmt = "{}", "_0.to_fixed_hex_string()")]
pub struct PatriciaKey(StarkHash);

// 2**251
Expand Down
13 changes: 13 additions & 0 deletions src/core_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,16 @@ fn nonce_overflow() {
let overflowed_nonce = max_nonce.try_increment();
assert_matches!(overflowed_nonce, Err(StarknetApiError::OutOfRange { string: _err_str }));
}

#[test]
fn test_patricia_key_display() {
assert_eq!(format!("{}", patricia_key!(7_u8)), String::from("0x") + &"0".repeat(63) + "7");
}

#[test]
fn test_contract_address_display() {
assert_eq!(
format!("{}", ContractAddress(patricia_key!(16_u8))),
String::from("0x") + &"0".repeat(62) + "10"
);
}
3 changes: 2 additions & 1 deletion src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::collections::{BTreeMap, HashMap, HashSet};
use std::fmt::Display;
use std::sync::Arc;

use derive_more::From;
use derive_more::{Display, From};
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use starknet_types_core::felt::Felt;
use strum::IntoEnumIterator;
Expand Down Expand Up @@ -646,6 +646,7 @@ pub struct RevertedTransactionExecutionStatus {
Copy,
Clone,
Default,
Display,
Eq,
PartialEq,
Hash,
Expand Down

0 comments on commit 4c23cae

Please sign in to comment.