#[non_exhaustive]pub enum EvmError {
Show 21 variants
Config(String),
InvalidInput(String),
Rpc {
method: &'static str,
code: Option<i64>,
message: String,
transient: bool,
},
ChainIdMismatch {
expected: u64,
actual: u64,
},
InvalidResponse(String),
TransactionReverted {
hash: Option<B256>,
revert: Option<RevertReason>,
},
ReceiptTimeout {
hash: B256,
nonce: Option<u64>,
timeout: Duration,
},
BroadcastUnknown {
hash: B256,
nonce: u64,
message: String,
},
NonceUsed {
hash: B256,
nonce: u64,
},
InvalidReceipt {
hash: B256,
message: String,
},
CodeMismatch {
address: Address,
expected: ParalockContract,
empty: bool,
},
Timeout {
what: String,
timeout: Duration,
},
ReadOnly,
Signer(String),
Signature(SignatureError),
WrongSigner {
expected: Address,
recovered: Address,
},
PreimageMismatch {
hashlock: B256,
},
LockEventMissing {
key: B256,
status: EscrowStatus,
from_block: u64,
},
SettlementNotIndexed {
key: B256,
},
FeeCapExceeded {
estimated: u128,
cap: u128,
},
PublicNetwork {
chain_id: u64,
name: &'static str,
},
}Expand description
Everything that can go wrong in this crate.
Errors never contain private keys. RPC error messages have the configured RPC URL redacted (it often embeds an API key).
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Config(String)
The configuration is unusable (bad RPC URL, fee token on a non-Tempo chain, …).
InvalidInput(String)
An argument failed validation before anything was sent.
Rpc
The RPC request failed (after the configured retries for transient failures).
Fields
ChainIdMismatch
The RPC node serves another chain than the one configured. Nothing was sent.
InvalidResponse(String)
The node’s response is malformed or inconsistent (it is treated as untrusted input).
TransactionReverted
A transaction reverted: either its simulation (hash is None, nothing was sent) or on-chain after it was mined.
Fields
hash: Option<B256>The mined transaction, or None when the revert was caught by simulation before sending.
revert: Option<RevertReason>The decoded revert, when the node returned revert data.
ReceiptTimeout
A sent transaction was not mined within the receipt timeout. It may still be pending: wait again
(wait_for_receipt / wait_for_sent), check transaction_status, or replace it with higher fees (bump,
same nonce). Retrying the operation from scratch instead would send a second transaction.
Fields
BroadcastUnknown
The broadcast of a signed transaction failed and the node could not be asked whether it received it anyway
(e.g. the response was lost and the follow-up lookup failed too). It may have been sent: look it up
(transaction_status, wait_for_receipt) or replace it (bump) before sending the operation again.
Fields
NonceUsed
A transaction cannot be replaced: its nonce is already used by a mined transaction (this one, an earlier
version of it, or another transaction of the account). Wait for its receipt instead (wait_for_sent).
InvalidReceipt
The receipt of a mined transaction is malformed (e.g. it has no status).
CodeMismatch
The address does not hold the runtime code of the expected Paralock contract (no code, another contract or another build). Refuse to use it as an escrow.
Fields
expected: ParalockContractThe contract it was expected to hold.
Timeout
A waiter gave up.
ReadOnly
The client has no signer.
Signer(String)
The signer failed (a KMS error, a mismatched chain id, …).
Signature(SignatureError)
A claim signature is malformed or not canonical.
WrongSigner
The claim signature does not recover to the swap’s signer. Nothing was sent.
Fields
PreimageMismatch
sha256(preimage) is not the swap’s hashlock. Nothing was sent.
LockEventMissing
The entry exists on-chain but its Locked event was not found from the configured start block (the start
block is after the contract’s deployment, or the node has not indexed the log yet).
Fields
status: EscrowStatusIts on-chain status.
SettlementNotIndexed
The entry is settled on-chain but neither its Claimed nor its Refunded event is served yet. Retry later.
FeeCapExceeded
The fee estimate exceeds EvmConfig::max_fee_per_gas. Nothing was sent.
PublicNetwork
deploy_paralock_contracts refuses known public networks.
Implementations§
Source§impl EvmError
impl EvmError
Sourcepub fn is_transient(&self) -> bool
pub fn is_transient(&self) -> bool
True when retrying the same operation later may succeed: transient RPC failures, receipt or wait timeouts, an uncertain broadcast, and events that are not indexed yet.
When EvmError::tx_hash is Some, a transaction may already be out: retry by waiting for (or bumping)
that transaction, not by sending the operation again.
Sourcepub fn tx_hash(&self) -> Option<B256>
pub fn tx_hash(&self) -> Option<B256>
The hash of the transaction this error is about, if one was signed and (possibly) broadcast: a receipt
timeout, an uncertain broadcast, a mined revert, a nonce already used, or a malformed receipt. None means
the failing step sent nothing (an earlier step of a multi-transaction call, such as the approval in
approve_and_lock, may have).
Keep it when converting this error into another type: it is what lets a caller wait for, look up or replace the transaction instead of sending a second one.
Sourcepub fn nonce(&self) -> Option<u64>
pub fn nonce(&self) -> Option<u64>
The nonce of the transaction this error is about, when known (see EvmError::tx_hash).
Sourcepub fn revert_name(&self) -> Option<&str>
pub fn revert_name(&self) -> Option<&str>
The custom error name of a revert ("SwapExpired", "SwapSettled", …), if this is a decoded revert.
Sourcepub fn revert(&self) -> Option<&RevertReason>
pub fn revert(&self) -> Option<&RevertReason>
The decoded revert, if this is a revert.
Trait Implementations§
Source§impl Error for EvmError
impl Error for EvmError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<SignatureError> for EvmError
impl From<SignatureError> for EvmError
Source§fn from(source: SignatureError) -> Self
fn from(source: SignatureError) -> Self
Auto Trait Implementations§
impl !Freeze for EvmError
impl RefUnwindSafe for EvmError
impl Send for EvmError
impl Sync for EvmError
impl Unpin for EvmError
impl UnsafeUnpin for EvmError
impl UnwindSafe for EvmError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more