Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extended CompilationFailed error(s) #2464

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
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
Loading