Skip to content
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

unclear naming of ClassHash types #169

Open
tdelabro opened this issue Jan 4, 2024 · 0 comments
Open

unclear naming of ClassHash types #169

tdelabro opened this issue Jan 4, 2024 · 0 comments

Comments

@tdelabro
Copy link
Contributor

tdelabro commented Jan 4, 2024

/// The hash of a ContractClass.
#[derive(
    Debug,
    Default,
    Copy,
    Clone,
    Eq,
    PartialEq,
    Hash,
    Deserialize,
    Serialize,
    PartialOrd,
    Ord,
    Display,
)]
#[cfg_attr(
    feature = "parity-scale-codec",
    derive(parity_scale_codec::Encode, parity_scale_codec::Decode)
)]
#[cfg_attr(feature = "scale-info", derive(scale_info::TypeInfo))]
pub struct ClassHash(pub StarkHash);

/// The hash of a compiled ContractClass.
#[derive(
    Debug,
    Default,
    Copy,
    Clone,
    Eq,
    PartialEq,
    Hash,
    Deserialize,
    Serialize,
    PartialOrd,
    Ord,
    Display,
)]
#[cfg_attr(
    feature = "parity-scale-codec",
    derive(parity_scale_codec::Encode, parity_scale_codec::Decode)
)]
#[cfg_attr(feature = "scale-info", derive(scale_info::TypeInfo))]
pub struct CompiledClassHash(pub StarkHash);

So we have two really similar struct here.
We are using two types of class hashes in Starknet, the hash of the contract compiled to sierra and the one of the contract compiled to casm.

So my guess is that ClassHash is SierraClassHash and CompiledClassHash is for CasmClassHash.
But that could be the opposite. It's misleading because both hashes are the hashes of a compiled object, one to Sierra, and the other to Casm.
It could also be that the first one is the hash of something that is not compiled (in opposition to the second), so is the hash of the .cairo files? Or the hash of the in-memory ContractClass struct?

Would it be possible to shed some light on this? And change in naming to make it explicit for lib users. And some doc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant