Skip to content

Commit

Permalink
Merge pull request #2504 from eqlabs/vbar/add-entrypoint-not-found
Browse files Browse the repository at this point in the history
feat: add ApplicationError::EntrypointNotFound
  • Loading branch information
vbar authored Jan 21, 2025
2 parents 3bfd3b6 + b64db96 commit fa95959
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions crates/rpc/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ pub enum ApplicationError {
FailedToReceiveTxn,
#[error("Contract not found")]
ContractNotFound,
#[error("Requested entrypoint does not exist in the contract")]
EntrypointNotFound,
#[error("Block not found")]
BlockNotFound,
#[error("Invalid transaction index in a block")]
Expand Down Expand Up @@ -125,6 +127,7 @@ impl ApplicationError {
ApplicationError::FailedToReceiveTxn => 1,
ApplicationError::NoTraceAvailable(_) => 10,
ApplicationError::ContractNotFound => 20,
ApplicationError::EntrypointNotFound => 21,
ApplicationError::BlockNotFound => 24,
ApplicationError::InvalidTxnHash => 25,
ApplicationError::InvalidBlockHash => 26,
Expand Down Expand Up @@ -187,6 +190,7 @@ impl ApplicationError {
match self {
ApplicationError::FailedToReceiveTxn => None,
ApplicationError::ContractNotFound => None,
ApplicationError::EntrypointNotFound => None,
ApplicationError::BlockNotFound => None,
ApplicationError::InvalidTxnIndex => None,
ApplicationError::InvalidTxnHash => None,
Expand Down
6 changes: 4 additions & 2 deletions crates/rpc/src/method/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub enum CallError {
Custom(anyhow::Error),
BlockNotFound,
ContractNotFound,
EntrypointNotFound,
ContractError {
revert_error: Option<String>,
revert_error_stack: pathfinder_executor::ErrorStack,
Expand All @@ -28,7 +29,7 @@ impl From<pathfinder_executor::CallError> for CallError {
use pathfinder_executor::CallError::*;
match value {
ContractNotFound => Self::ContractNotFound,
InvalidMessageSelector => Self::Custom(anyhow::anyhow!("Invalid message selector")),
InvalidMessageSelector => Self::EntrypointNotFound,
ContractError(error, error_stack) => Self::ContractError {
revert_error: Some(format!("Execution error: {}", error)),
revert_error_stack: error_stack,
Expand All @@ -54,6 +55,7 @@ impl From<CallError> for ApplicationError {
match value {
CallError::BlockNotFound => ApplicationError::BlockNotFound,
CallError::ContractNotFound => ApplicationError::ContractNotFound,
CallError::EntrypointNotFound => ApplicationError::EntrypointNotFound,
CallError::ContractError {
revert_error,
revert_error_stack,
Expand Down Expand Up @@ -613,7 +615,7 @@ mod tests {
block_id: BLOCK_5,
};
let error = call(context, input).await;
assert_matches::assert_matches!(error, Err(CallError::Custom(_)));
assert_matches::assert_matches!(error, Err(CallError::EntrypointNotFound));
}

#[tokio::test]
Expand Down

0 comments on commit fa95959

Please sign in to comment.