diff --git a/crates/client/rpc/src/lib.rs b/crates/client/rpc/src/lib.rs index d41f9161fe..a2ab28fb48 100644 --- a/crates/client/rpc/src/lib.rs +++ b/crates/client/rpc/src/lib.rs @@ -253,7 +253,7 @@ where .contract_class_by_class_hash(current_block_hash, txn.class_hash()); if let Some(contract_class) = contract_class { - log::error!("Contract class already exists: {:?}", contract_class); + log::debug!("Contract class already exists: {:?}", contract_class); return Err(StarknetRpcApiError::ClassAlreadyDeclared); } @@ -343,8 +343,8 @@ where StarknetRpcApiError::InternalServerError })?; - let (txn_hash, class_hash) = self.declare_tx_common(declare_transaction).await.unwrap(); - + let (txn_hash, class_hash) = self.declare_tx_common(declare_transaction).await?; + Ok(DeclareV0Result { txn_hash, class_hash }) } } diff --git a/starknet-rpc-test/Cargo.toml b/starknet-rpc-test/Cargo.toml index 1cc03f672f..d077f132cc 100644 --- a/starknet-rpc-test/Cargo.toml +++ b/starknet-rpc-test/Cargo.toml @@ -15,7 +15,6 @@ env_logger = "0.9" flate2 = { workspace = true } indexmap = { workspace = true } parity-scale-codec = { workspace = true } -reqwest = "0.11.18" rstest = "0.18.1" serde = "1.0.192" serde_json = "1.0.108" @@ -30,6 +29,7 @@ starknet_api = { workspace = true } thiserror = { workspace = true } tokio = { version = "1.36.0", features = ["rt", "macros", "parking_lot"] } url = "2.4.1" +reqwest = { version = "0.11.22", features = ["json"] } # [[test]] # name = "starknet_spec_version" diff --git a/starknet-rpc-test/declareV0.rs b/starknet-rpc-test/declareV0.rs index bd05e7d0c6..817de6904c 100644 --- a/starknet-rpc-test/declareV0.rs +++ b/starknet-rpc-test/declareV0.rs @@ -9,7 +9,7 @@ use serde_json::json; use starknet_api::core::{ClassHash, ContractAddress, Nonce, PatriciaKey}; use starknet_api::deprecated_contract_class::{EntryPoint, EntryPointType}; use starknet_api::hash::{StarkFelt, StarkHash}; -use starknet_api::transaction::{DeclareTransactionV0V1, Fee, TransactionSignature}; +use starknet_api::transaction::{DeclareTransactionV0V1, Fee, TransactionHash, TransactionSignature}; use starknet_core::types::contract::legacy::LegacyContractClass; use starknet_core::types::{BlockId, StarknetError}; use starknet_ff::FieldElement; @@ -25,6 +25,12 @@ pub struct CustomDeclareV0Transaction { pub abi_length: usize, } +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +pub struct DeclareV0Result { + pub txn_hash: TransactionHash, + pub class_hash: ClassHash, +} + #[rstest] #[tokio::test] async fn fail_non_existing_contract(madara: &ThreadSafeMadaraClient) -> Result<(), anyhow::Error> { @@ -88,7 +94,7 @@ async fn declare_v0_contract(madara: &ThreadSafeMadaraClient) -> Result<(), anyh match raw_txn_rpc { Ok(val) => { - let res = val.json().await.unwrap(); + let res = val.json::().await; println!("Txn Sent Successfully : {:?}", res); println!("Declare Success : {:?}", contract_abi_artifact.class_hash().unwrap()); }