Skip to content

Commit

Permalink
Merge pull request #1232 from MutinyWallet/fedimint-tx-too-large
Browse files Browse the repository at this point in the history
Handle fedimint tx too large error
  • Loading branch information
benthecarman authored Jul 1, 2024
2 parents 2df5362 + 6c81321 commit 6e3b9fa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
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

0 comments on commit 6e3b9fa

Please sign in to comment.