@@ -9,11 +9,13 @@ use sncast::helpers::rpc::RpcArgs;
9
9
use sncast:: response:: declare:: {
10
10
AlreadyDeclaredResponse , DeclareResponse , DeclareTransactionResponse ,
11
11
} ;
12
- use sncast:: response:: errors:: StarknetCommandError ;
12
+ use sncast:: response:: errors:: { SNCastProviderError , SNCastStarknetError , StarknetCommandError } ;
13
13
use sncast:: { ErrorData , WaitForTx , apply_optional_fields, handle_wait_for_tx} ;
14
14
use starknet:: accounts:: AccountError :: Provider ;
15
15
use starknet:: accounts:: { ConnectedAccount , DeclarationV3 } ;
16
- use starknet:: core:: types:: { DeclareTransactionResult , StarknetError } ;
16
+ use starknet:: core:: types:: {
17
+ ContractExecutionError , DeclareTransactionResult , StarknetError , TransactionExecutionErrorData ,
18
+ } ;
17
19
use starknet:: providers:: ProviderError ;
18
20
use starknet:: {
19
21
accounts:: { Account , SingleOwnerAccount } ,
@@ -156,6 +158,21 @@ pub(crate) async fn declare_with_artifacts(
156
158
class_hash : class_hash. into_ ( ) ,
157
159
} ) )
158
160
}
161
+ Err ( Provider ( ProviderError :: StarknetError ( StarknetError :: TransactionExecutionError (
162
+ TransactionExecutionErrorData {
163
+ execution_error : ContractExecutionError :: Message ( message) ,
164
+ ..
165
+ } ,
166
+ ) ) ) ) if message. contains ( "is already declared" ) && skip_on_already_declared => {
167
+ Ok ( DeclareResponse :: AlreadyDeclared ( AlreadyDeclaredResponse {
168
+ class_hash : class_hash. into_ ( ) ,
169
+ } ) )
170
+ }
171
+ Err ( Provider ( ProviderError :: StarknetError ( StarknetError :: TransactionExecutionError (
172
+ TransactionExecutionErrorData { .. } ,
173
+ ) ) ) ) => Err ( StarknetCommandError :: ProviderError (
174
+ SNCastProviderError :: StarknetError ( SNCastStarknetError :: ClassAlreadyDeclared ) ,
175
+ ) ) ,
159
176
Err ( Provider ( error) ) => Err ( StarknetCommandError :: ProviderError ( error. into ( ) ) ) ,
160
177
Err ( error) => Err ( anyhow ! ( format!( "Unexpected error occurred: {error}" ) ) . into ( ) ) ,
161
178
}
0 commit comments