From 51d5426f375db59d7128a61f321b73bc30237b84 Mon Sep 17 00:00:00 2001 From: benthecarman Date: Mon, 1 Jul 2024 11:28:15 -0500 Subject: [PATCH 1/2] Handle fedimint tx too large error --- mutiny-core/src/error.rs | 5 +++++ mutiny-wasm/src/error.rs | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/mutiny-core/src/error.rs b/mutiny-core/src/error.rs index 89f7640d5..20591337e 100644 --- a/mutiny-core/src/error.rs +++ b/mutiny-core/src/error.rs @@ -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), } @@ -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, } @@ -601,6 +605,7 @@ impl From for MutinyError { match e.to_string().as_str() { "Insufficient balance" => Self::InsufficientBalance, "MissingInvoiceAmount" => Self::BadAmountError, + "The generated transaction would be rejected by the federation for being too large." => Self::FederationTxTooLarge, _ => Self::Other(e), } } diff --git a/mutiny-wasm/src/error.rs b/mutiny-wasm/src/error.rs index 4297049f4..0e06d4c9d 100644 --- a/mutiny-wasm/src/error.rs +++ b/mutiny-wasm/src/error.rs @@ -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, @@ -234,6 +237,7 @@ impl From 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 From 6c81321dba78ca3a74ee3daaca239128f73bc56d Mon Sep 17 00:00:00 2001 From: benthecarman Date: Mon, 1 Jul 2024 11:47:47 -0500 Subject: [PATCH 2/2] Handle other fedimint errors --- mutiny-core/src/error.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mutiny-core/src/error.rs b/mutiny-core/src/error.rs index 20591337e..5fbce3cd6 100644 --- a/mutiny-core/src/error.rs +++ b/mutiny-core/src/error.rs @@ -605,8 +605,13 @@ impl From for MutinyError { match e.to_string().as_str() { "Insufficient balance" => Self::InsufficientBalance, "MissingInvoiceAmount" => Self::BadAmountError, + "Federation didn't return peg-out fees" => Self::FederationConnectionFailed, "The generated transaction would be rejected by the federation for being too large." => Self::FederationTxTooLarge, - _ => Self::Other(e), + str => if str.starts_with("Address isn't compatible with the federation's network") { + Self::IncorrectNetwork + } else { + Self::Other(e) + }, } } }