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

Handle fedimint tx too large error #1232

Merged
merged 2 commits into from
Jul 1, 2024
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
12 changes: 11 additions & 1 deletion mutiny-core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ pub enum MutinyError {
/// Failed to connect to a federation.
#[error("Failed to connect to a federation.")]
FederationConnectionFailed,
/// Fedimint transaction too large
#[error("Error constructing fedimint transaction, try lowering the amount.")]
FederationTxTooLarge,
#[error(transparent)]
Other(anyhow::Error),
}
Expand Down Expand Up @@ -270,6 +273,7 @@ impl PartialEq for MutinyError {
(Self::TokenAlreadySpent, Self::TokenAlreadySpent) => true,
(Self::FederationRequired, Self::FederationRequired) => true,
(Self::FederationConnectionFailed, Self::FederationConnectionFailed) => true,
(Self::FederationTxTooLarge, Self::FederationTxTooLarge) => true,
(Self::Other(e), Self::Other(e2)) => e.to_string() == e2.to_string(),
_ => false,
}
Expand Down Expand Up @@ -601,7 +605,13 @@ impl From<anyhow::Error> for MutinyError {
match e.to_string().as_str() {
"Insufficient balance" => Self::InsufficientBalance,
"MissingInvoiceAmount" => Self::BadAmountError,
_ => Self::Other(e),
"Federation didn't return peg-out fees" => Self::FederationConnectionFailed,
"The generated transaction would be rejected by the federation for being too large." => Self::FederationTxTooLarge,
str => if str.starts_with("Address isn't compatible with the federation's network") {
Self::IncorrectNetwork
} else {
Self::Other(e)
},
}
}
}
4 changes: 4 additions & 0 deletions mutiny-wasm/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ pub enum MutinyJsError {
/// Failed to connect to a federation.
#[error("Failed to connect to a federation.")]
FederationConnectionFailed,
/// Fedimint transaction too large
#[error("Error constructing fedimint transaction, try lowering the amount.")]
FederationTxTooLarge,
/// Unknown error.
#[error("Unknown Error")]
UnknownError,
Expand Down Expand Up @@ -234,6 +237,7 @@ impl From<MutinyError> for MutinyJsError {
MutinyError::TokenAlreadySpent => MutinyJsError::TokenAlreadySpent,
MutinyError::FederationRequired => MutinyJsError::FederationRequired,
MutinyError::FederationConnectionFailed => MutinyJsError::FederationConnectionFailed,
MutinyError::FederationTxTooLarge => MutinyJsError::FederationTxTooLarge,
MutinyError::Other(_) => MutinyJsError::UnknownError,
MutinyError::SubscriptionClientNotConfigured => {
MutinyJsError::SubscriptionClientNotConfigured
Expand Down
Loading