diff --git a/crates/sncast/src/helpers/scarb_utils.rs b/crates/sncast/src/helpers/scarb_utils.rs index c968e7ddff..c0ccea11bb 100644 --- a/crates/sncast/src/helpers/scarb_utils.rs +++ b/crates/sncast/src/helpers/scarb_utils.rs @@ -8,7 +8,10 @@ use scarb_api::{ use scarb_ui::args::PackagesFilter; use shared::{command::CommandExt, print::print_as_warning}; use starknet::{ - core::types::{contract::SierraClass, BlockId, FlattenedSierraClass}, + core::types::{ + contract::{CompiledClass, SierraClass}, + BlockId, FlattenedSierraClass, + }, providers::{jsonrpc::HttpTransport, JsonRpcClient, Provider, ProviderError}, }; use starknet_crypto::FieldElement; @@ -202,27 +205,36 @@ pub fn read_manifest_and_build_artifacts( pub struct CompiledContract { pub class: FlattenedSierraClass, - pub class_hash: FieldElement, + pub sierra_class_hash: FieldElement, + pub casm_class_hash: FieldElement, } impl TryFrom<&StarknetContractArtifacts> for CompiledContract { type Error = anyhow::Error; fn try_from(artifacts: &StarknetContractArtifacts) -> Result { - let class = serde_json::from_str::(&artifacts.sierra) - .context("Failed to parse sierra artifact")? + let sierra_class = serde_json::from_str::(&artifacts.sierra) + .context("Failed to parse Sierra artifact")? .flatten()?; - let class_hash = class.class_hash(); + let compiled_class = serde_json::from_str::(&artifacts.casm) + .context("Failed to parse CASM artifact")?; - Ok(Self { class, class_hash }) + let sierra_class_hash = sierra_class.class_hash(); + let casm_class_hash = compiled_class.class_hash()?; + + Ok(Self { + class: sierra_class, + sierra_class_hash, + casm_class_hash, + }) } } impl CompiledContract { pub async fn is_declared(&self, provider: &JsonRpcClient) -> Result { let block_id = BlockId::Tag(starknet::core::types::BlockTag::Pending); - let class_hash = self.class_hash; + let class_hash = self.sierra_class_hash; let response = provider.get_class(block_id, class_hash).await; diff --git a/crates/sncast/src/starknet_commands/declare.rs b/crates/sncast/src/starknet_commands/declare.rs index 23405e357d..d0862132cd 100644 --- a/crates/sncast/src/starknet_commands/declare.rs +++ b/crates/sncast/src/starknet_commands/declare.rs @@ -97,7 +97,11 @@ pub async fn declare_compiled( .try_into_fee_settings(account.provider(), account.block_id()) .await?; - let CompiledContract { class, class_hash } = contract; + let CompiledContract { + class, + casm_class_hash: class_hash, + .. + } = contract; let result = match fee_settings { FeeSettings::Eth { max_fee } => {