Skip to content
This repository was archived by the owner on Feb 3, 2025. It is now read-only.

Commit 6e3b9fa

Browse files
authored
Merge pull request #1232 from MutinyWallet/fedimint-tx-too-large
Handle fedimint tx too large error
2 parents 2df5362 + 6c81321 commit 6e3b9fa

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

mutiny-core/src/error.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@ pub enum MutinyError {
182182
/// Failed to connect to a federation.
183183
#[error("Failed to connect to a federation.")]
184184
FederationConnectionFailed,
185+
/// Fedimint transaction too large
186+
#[error("Error constructing fedimint transaction, try lowering the amount.")]
187+
FederationTxTooLarge,
185188
#[error(transparent)]
186189
Other(anyhow::Error),
187190
}
@@ -270,6 +273,7 @@ impl PartialEq for MutinyError {
270273
(Self::TokenAlreadySpent, Self::TokenAlreadySpent) => true,
271274
(Self::FederationRequired, Self::FederationRequired) => true,
272275
(Self::FederationConnectionFailed, Self::FederationConnectionFailed) => true,
276+
(Self::FederationTxTooLarge, Self::FederationTxTooLarge) => true,
273277
(Self::Other(e), Self::Other(e2)) => e.to_string() == e2.to_string(),
274278
_ => false,
275279
}
@@ -601,7 +605,13 @@ impl From<anyhow::Error> for MutinyError {
601605
match e.to_string().as_str() {
602606
"Insufficient balance" => Self::InsufficientBalance,
603607
"MissingInvoiceAmount" => Self::BadAmountError,
604-
_ => Self::Other(e),
608+
"Federation didn't return peg-out fees" => Self::FederationConnectionFailed,
609+
"The generated transaction would be rejected by the federation for being too large." => Self::FederationTxTooLarge,
610+
str => if str.starts_with("Address isn't compatible with the federation's network") {
611+
Self::IncorrectNetwork
612+
} else {
613+
Self::Other(e)
614+
},
605615
}
606616
}
607617
}

mutiny-wasm/src/error.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@ pub enum MutinyJsError {
177177
/// Failed to connect to a federation.
178178
#[error("Failed to connect to a federation.")]
179179
FederationConnectionFailed,
180+
/// Fedimint transaction too large
181+
#[error("Error constructing fedimint transaction, try lowering the amount.")]
182+
FederationTxTooLarge,
180183
/// Unknown error.
181184
#[error("Unknown Error")]
182185
UnknownError,
@@ -234,6 +237,7 @@ impl From<MutinyError> for MutinyJsError {
234237
MutinyError::TokenAlreadySpent => MutinyJsError::TokenAlreadySpent,
235238
MutinyError::FederationRequired => MutinyJsError::FederationRequired,
236239
MutinyError::FederationConnectionFailed => MutinyJsError::FederationConnectionFailed,
240+
MutinyError::FederationTxTooLarge => MutinyJsError::FederationTxTooLarge,
237241
MutinyError::Other(_) => MutinyJsError::UnknownError,
238242
MutinyError::SubscriptionClientNotConfigured => {
239243
MutinyJsError::SubscriptionClientNotConfigured

0 commit comments

Comments
 (0)