Skip to main content

EvmError

Enum EvmError 

Source
#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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

§method: &'static str

The JSON-RPC method (or client operation) that failed.

§code: Option<i64>

JSON-RPC error code, when the node returned one.

§message: String

The error message, with the RPC URL redacted.

§transient: bool

True for transport failures, timeouts, rate limits and 5xx responses: retrying later may succeed.

§

ChainIdMismatch

The RPC node serves another chain than the one configured. Nothing was sent.

Fields

§expected: u64

The configured chain id.

§actual: u64

The chain id the node reported.

§

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

§hash: B256

The transaction hash (the newest version, if it was replaced with higher fees).

§nonce: Option<u64>

Its nonce, when known (always for transactions this process sent).

§timeout: Duration

The timeout that elapsed.

§

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

§hash: B256

The signed transaction’s hash.

§nonce: u64

Its nonce.

§message: String

The broadcast error, with the RPC URL redacted.

§

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).

Fields

§hash: B256

The transaction that was to be replaced.

§nonce: u64

Its nonce.

§

InvalidReceipt

The receipt of a mined transaction is malformed (e.g. it has no status).

Fields

§hash: B256

The transaction hash.

§message: String

What is wrong with the receipt.

§

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

§address: Address

The checked address.

§expected: ParalockContract

The contract it was expected to hold.

§empty: bool

True when the address holds no code at all.

§

Timeout

A waiter gave up.

Fields

§what: String

What was awaited.

§timeout: Duration

The timeout that elapsed.

§

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

§expected: Address

The swap’s signer.

§recovered: Address

The address the signature recovers to.

§

PreimageMismatch

sha256(preimage) is not the swap’s hashlock. Nothing was sent.

Fields

§hashlock: B256

The swap’s hashlock.

§

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

§key: B256

Hashlock (htlc) or escrow id (adaptor).

§status: EscrowStatus

Its on-chain status.

§from_block: u64

The configured first block of the scan.

§

SettlementNotIndexed

The entry is settled on-chain but neither its Claimed nor its Refunded event is served yet. Retry later.

Fields

§key: B256

Hashlock (htlc) or escrow id (adaptor).

§

FeeCapExceeded

The fee estimate exceeds EvmConfig::max_fee_per_gas. Nothing was sent.

Fields

§estimated: u128

The estimated maxFeePerGas.

§cap: u128

The configured cap.

§

PublicNetwork

deploy_paralock_contracts refuses known public networks.

Fields

§chain_id: u64

The chain id.

§name: &'static str

The network’s name.

Implementations§

Source§

impl EvmError

Source

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.

Source

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.

Source

pub fn nonce(&self) -> Option<u64>

The nonce of the transaction this error is about, when known (see EvmError::tx_hash).

Source

pub fn revert_name(&self) -> Option<&str>

The custom error name of a revert ("SwapExpired", "SwapSettled", …), if this is a decoded revert.

Source

pub fn revert(&self) -> Option<&RevertReason>

The decoded revert, if this is a revert.

Trait Implementations§

Source§

impl Debug for EvmError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for EvmError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for EvmError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<SignatureError> for EvmError

Source§

fn from(source: SignatureError) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more