Skip to content
Open
Show file tree
Hide file tree
Changes from 7 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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -1335,3 +1335,9 @@ snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry", tag = "v
#### Added

- Initial release

### Cast

#### Changed

- Error in case of redeclaration was improved.
3 changes: 3 additions & 0 deletions crates/sncast/src/response/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::{ErrorData, WaitForTransactionError, handle_rpc_error};
use anyhow::anyhow;
use console::style;
use conversions::serde::serialize::CairoSerialize;
use starknet_types_core::felt::Felt;

use conversions::byte_array::ByteArray;

Expand Down Expand Up @@ -51,6 +52,8 @@ pub enum StarknetCommandError {
WaitForTransactionError(#[from] WaitForTransactionError),
#[error(transparent)]
ProviderError(#[from] SNCastProviderError),
#[error("Contract with class hash {0} is already declared on Starknet.")]
ClassAlreadyDeclared(Felt),
}

#[must_use]
Expand Down
4 changes: 3 additions & 1 deletion crates/sncast/src/starknet_commands/declare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ pub async fn declare(
class_hash: class_hash.into_(),
}))
}
Err(Provider(error)) => Err(StarknetCommandError::ProviderError(error.into())),
Err(Provider(ProviderError::StarknetError(StarknetError::ClassAlreadyDeclared))) => Err(
StarknetCommandError::ClassAlreadyDeclared(class_hash.into_()),
),
Err(error) => Err(anyhow!(format!("Unexpected error occurred: {error}")).into()),
}
}
2 changes: 1 addition & 1 deletion crates/sncast/tests/e2e/declare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ async fn test_contract_already_declared() {
output,
indoc! {r"
Command: declare
Error: Contract with the same class hash is already declared
Error: Contract with class hash 3108664225240562387851974058679424955795215347221665253736957753632123141297 is already declared on Starknet.
"},
);
}
Expand Down
Loading