Skip to content

Commit

Permalink
Handle gas too high (#1035)
Browse files Browse the repository at this point in the history
  • Loading branch information
tarrencev authored Nov 15, 2024
1 parent 4531c83 commit 20c5b66
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
11 changes: 7 additions & 4 deletions packages/account-wasm/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,13 @@ impl From<ExecuteFromOutsideError> for JsControllerError {
ErrorCode::PaymasterRateLimitExceeded,
"Rate limit exceeded".to_string(),
),
ExecuteFromOutsideError::ExecuteFromOutsideNotSupported => (
ErrorCode::PaymasterNotSupported,
"Paymaster not supported".to_string(),
),
ExecuteFromOutsideError::ExecuteFromOutsideNotSupported(data) => {
return JsControllerError {
code: ErrorCode::PaymasterNotSupported,
message: "Paymaster not supported".to_string(),
data: Some(data),
}
}
ExecuteFromOutsideError::Serialization(e) => {
(ErrorCode::PaymasterSerialization, e.to_string())
}
Expand Down
6 changes: 4 additions & 2 deletions packages/account_sdk/src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ pub enum ExecuteFromOutsideError {
#[error("Rate limit exceeded")]
RateLimitExceeded,
#[error("Paymaster not supported")]
ExecuteFromOutsideNotSupported,
ExecuteFromOutsideNotSupported(String),
}

impl From<JsonRpcError> for ExecuteFromOutsideError {
Expand All @@ -476,7 +476,9 @@ impl From<JsonRpcError> for ExecuteFromOutsideError {
}
err if err.message.contains("invalid caller") => ExecuteFromOutsideError::InvalidCaller,
err if err.code == -32005 => ExecuteFromOutsideError::RateLimitExceeded,
err if err.code == -32003 => ExecuteFromOutsideError::ExecuteFromOutsideNotSupported,
err if err.code == -32003 || err.code == -32004 => {
ExecuteFromOutsideError::ExecuteFromOutsideNotSupported(err.message)
}
_ => match TryInto::<StarknetError>::try_into(&error) {
Ok(starknet_error) => ExecuteFromOutsideError::ProviderError(
ProviderError::StarknetError(starknet_error),
Expand Down

0 comments on commit 20c5b66

Please sign in to comment.