Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- `starknet_getEvents` now returns `block_number` for events from pre-confirmed and pre-latest blocks.
- JSON-RPC input no longer accepts hex strings that are missing the `0x` prefix, in line with the Starknet API spec.

### Fixed

Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/block-commitments/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ mod meta {
const MAINNET_METAINFO: BlockHashMetaInfo = BlockHashMetaInfo {
first_0_7_block: BlockNumber::new_or_panic(833),
fallback_sequencer_address: Some(sequencer_address!(
"021f4b90b0377c82bf330b7b5295820769e72d79d8acd0effa0ebde6e9988bc5"
"0x021f4b90b0377c82bf330b7b5295820769e72d79d8acd0effa0ebde6e9988bc5"
)),
};

Expand Down
2 changes: 1 addition & 1 deletion crates/class-hash/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ pub mod json {
// Known contract which triggered a hash mismatch failure.
hash(CAIRO_0_8_NEW_ATTRIBUTES),
ComputedClassHash::Cairo(class_hash!(
"056b96c1d1bbfa01af44b465763d1b71150fa00c6c9d54c3947f57e979ff68c3"
"0x056b96c1d1bbfa01af44b465763d1b71150fa00c6c9d54c3947f57e979ff68c3"
))
);
}
Expand Down
6 changes: 3 additions & 3 deletions crates/common/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ use crate::macro_prelude::block_hash;
use crate::BlockHash;

pub const MAINNET_GENESIS_HASH: BlockHash =
block_hash!("047C3637B57C2B079B93C61539950C17E868A28F46CDEF28F88521067F21E943");
block_hash!("0x047C3637B57C2B079B93C61539950C17E868A28F46CDEF28F88521067F21E943");

pub const SEPOLIA_TESTNET_GENESIS_HASH: BlockHash =
block_hash!("5c627d4aeb51280058bed93c7889bce78114d63baad1be0f0aeb32496d5f19c");
block_hash!("0x5c627d4aeb51280058bed93c7889bce78114d63baad1be0f0aeb32496d5f19c");

pub const SEPOLIA_INTEGRATION_GENESIS_HASH: BlockHash =
block_hash!("19f675d3fb226821493a6ab9a1955e384bba80f130de625621a418e9a7c0ca3");
block_hash!("0x19f675d3fb226821493a6ab9a1955e384bba80f130de625621a418e9a7c0ca3");
32 changes: 4 additions & 28 deletions crates/common/src/event.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use std::str::FromStr;

use fake::Dummy;
use num_bigint::BigUint;
use pathfinder_crypto::Felt;
use pathfinder_tagged::Tagged;
use pathfinder_tagged_debug_derive::TaggedDebug;
Expand All @@ -26,34 +23,13 @@ pub struct EventIndex(pub u64);
serde_conv!(
EventDataAsDecimalStr,
EventData,
|serialize_me: &EventData| starkhash_to_dec_str(&serialize_me.0),
|s: &str| starkhash_from_dec_str(s).map(EventData)
|serialize_me: &EventData| serialize_me.0.to_dec_str(),
|s: &str| Felt::from_dec_str(s).map(EventData)
);

serde_conv!(
EventKeyAsDecimalStr,
EventKey,
|serialize_me: &EventKey| starkhash_to_dec_str(&serialize_me.0),
|s: &str| starkhash_from_dec_str(s).map(EventKey)
|serialize_me: &EventKey| serialize_me.0.to_dec_str(),
|s: &str| Felt::from_dec_str(s).map(EventKey)
);

/// A helper conversion function. Only use with __sequencer API related types__.
fn starkhash_to_dec_str(h: &Felt) -> String {
let b = h.to_be_bytes();
let b = BigUint::from_bytes_be(&b);
b.to_str_radix(10)
}

/// A helper conversion function. Only use with __sequencer API related types__.
fn starkhash_from_dec_str(s: &str) -> Result<Felt, anyhow::Error> {
match BigUint::from_str(s) {
Ok(b) => {
let h = Felt::from_be_slice(&b.to_bytes_be())?;
Ok(h)
}
Err(_) => {
let h = Felt::from_hex_str(s)?;
Ok(h)
}
}
}
3 changes: 3 additions & 0 deletions crates/common/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,9 @@ macro_rules! felt {
Err(pathfinder_crypto::HexParseError::InvalidLength { .. }) => {
panic!("Too many hex digits")
}
Err(pathfinder_crypto::HexParseError::MissingPrefix) => {
panic!("Missing '0x' prefix")
}
Err(pathfinder_crypto::HexParseError::Overflow) => panic!("Felt overflow"),
};
CONST_FELT
Expand Down
2 changes: 1 addition & 1 deletion crates/crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ path = "src/lib.rs"
[dependencies]
bitvec = { workspace = true }
fake = { workspace = true }
num-bigint = { workspace = true }
rand = { workspace = true }
serde = { workspace = true }

Expand All @@ -33,7 +34,6 @@ ark-ff = { workspace = true, features = ["std", "asm"] }
assert_matches = { workspace = true }
criterion = { workspace = true }
ff = { workspace = true, features = ["derive"] }
num-bigint = { workspace = true }
pretty_assertions_sorted = { workspace = true }
serde_json = { workspace = true }

Expand Down
Loading
Loading