Skip to content

Commit

Permalink
fix(comments)
Browse files Browse the repository at this point in the history
  • Loading branch information
Trantorian1 committed Oct 21, 2024
1 parent 05d703c commit 4af813e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

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

1 change: 0 additions & 1 deletion crates/primitives/transactions/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ starknet_api = { workspace = true }

# Other
anyhow = { workspace = true }
lazy_static = { workspace = true }
log = { workspace = true }
num-bigint = { workspace = true }
serde = { workspace = true, features = ["derive"] }
Expand Down
15 changes: 9 additions & 6 deletions crates/primitives/transactions/src/compute_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ const L1_HANDLER_PREFIX: Felt = Felt::from_hex_unchecked("0x6c315f68616e646c6572

const L1_GAS: &[u8] = b"L1_GAS";
const L2_GAS: &[u8] = b"L2_GAS";

lazy_static::lazy_static! {
static ref PEDERSEN_EMPTY: Felt = Pedersen::hash_array(&[]);
}
const PEDERSEN_EMPTY: Felt =
Felt::from_hex_unchecked("0x49ee3eba8c1600700ee1b87eb599f16716b0b1022947733551fde4050ca6804");

impl Transaction {
pub fn compute_hash(&self, chain_id: Felt, version: StarknetVersion, offset_version: bool) -> Felt {
Expand Down Expand Up @@ -77,7 +75,7 @@ impl Transaction {
Transaction::Declare(_)
| Transaction::DeployAccount(_)
| Transaction::Deploy(_)
| Transaction::L1Handler(_) => *PEDERSEN_EMPTY,
| Transaction::L1Handler(_) => PEDERSEN_EMPTY,
};

Pedersen::hash(&tx_hash, &signature_hash)
Expand All @@ -88,7 +86,7 @@ impl Transaction {
Transaction::Invoke(tx) => tx.compute_hash_signature::<Pedersen>(),
Transaction::Declare(tx) => tx.compute_hash_signature::<Pedersen>(),
Transaction::DeployAccount(tx) => tx.compute_hash_signature::<Pedersen>(),
Transaction::Deploy(_) | Transaction::L1Handler(_) => *PEDERSEN_EMPTY,
Transaction::Deploy(_) | Transaction::L1Handler(_) => PEDERSEN_EMPTY,
};

Pedersen::hash(&tx_hash, &signature_hash)
Expand Down Expand Up @@ -704,4 +702,9 @@ mod tests {
Felt::from_hex_unchecked("0x734743d11641ecb3d92bafae091346fec3b2c75f7808e39f8b23d9287636e45");
assert_eq!(contract_address, expected_contract_address,);
}

#[test]
fn test_pedersen_empty() {
assert_eq!(PEDERSEN_EMPTY, Pedersen::hash_array(&[]))
}
}

0 comments on commit 4af813e

Please sign in to comment.