Skip to content

Commit

Permalink
Merge pull request #2464 from eqlabs/vbar/return-compilation-error
Browse files Browse the repository at this point in the history
extended CompilationFailed error(s)
  • Loading branch information
vbar authored Jan 10, 2025
2 parents 7cbefab + c061079 commit ca654b8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
9 changes: 6 additions & 3 deletions crates/rpc/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub enum ApplicationError {
#[error("Account validation failed")]
ValidationFailureV06(String),
#[error("Compilation failed")]
CompilationFailed,
CompilationFailed { data: String },
#[error("Contract class size it too large")]
ContractClassSizeIsTooLarge,
#[error("Sender address in not an account contract")]
Expand Down Expand Up @@ -144,7 +144,7 @@ impl ApplicationError {
ApplicationError::InsufficientResourcesForValidate => 53,
ApplicationError::InsufficientAccountBalance => 54,
ApplicationError::ValidationFailure | ApplicationError::ValidationFailureV06(_) => 55,
ApplicationError::CompilationFailed => 56,
ApplicationError::CompilationFailed { .. } => 56,
ApplicationError::ContractClassSizeIsTooLarge => 57,
ApplicationError::NonAccount => 58,
ApplicationError::DuplicateTransaction => 59,
Expand Down Expand Up @@ -202,7 +202,10 @@ impl ApplicationError {
ApplicationError::InsufficientResourcesForValidate => None,
ApplicationError::InsufficientAccountBalance => None,
ApplicationError::ValidationFailure => None,
ApplicationError::CompilationFailed => None,
ApplicationError::CompilationFailed { data } => match version {
RpcVersion::V07 => None,
_ => Some(json!(data)),
},
ApplicationError::ContractClassSizeIsTooLarge => None,
ApplicationError::NonAccount => None,
ApplicationError::DuplicateTransaction => None,
Expand Down
6 changes: 3 additions & 3 deletions crates/rpc/src/method/add_declare_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub enum AddDeclareTransactionError {
InsufficientResourcesForValidate,
InsufficientAccountBalance,
ValidationFailure(String),
CompilationFailed,
CompilationFailed(String),
ContractClassSizeIsTooLarge,
DuplicateTransaction,
CompiledClassHashMismatch,
Expand All @@ -41,7 +41,7 @@ impl From<AddDeclareTransactionError> for crate::error::ApplicationError {
AddDeclareTransactionError::ValidationFailure(message) => {
Self::ValidationFailureV06(message)
}
AddDeclareTransactionError::CompilationFailed => Self::CompilationFailed,
AddDeclareTransactionError::CompilationFailed(data) => Self::CompilationFailed { data },
AddDeclareTransactionError::ContractClassSizeIsTooLarge => {
Self::ContractClassSizeIsTooLarge
}
Expand Down Expand Up @@ -87,7 +87,7 @@ impl From<SequencerError> for AddDeclareTransactionError {
AddDeclareTransactionError::ClassAlreadyDeclared
}
SequencerError::StarknetError(e) if e.code == CompilationFailed.into() => {
AddDeclareTransactionError::CompilationFailed
AddDeclareTransactionError::CompilationFailed(e.message)
}
SequencerError::StarknetError(e)
if e.code == ContractBytecodeSizeTooLarge.into()
Expand Down
6 changes: 5 additions & 1 deletion crates/rpc/src/method/get_compiled_casm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ impl From<anyhow::Error> for Error {
impl From<Error> for crate::jsonrpc::RpcError {
fn from(error: Error) -> Self {
match error {
Error::CompilationFailed => Self::ApplicationError(ApplicationError::CompilationFailed),
Error::CompilationFailed => {
Self::ApplicationError(ApplicationError::CompilationFailed {
data: String::new(),
})
}
Error::ClassHashNotFound(_) => {
Self::ApplicationError(ApplicationError::ClassHashNotFound)
}
Expand Down

0 comments on commit ca654b8

Please sign in to comment.