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

Expand error message on invalid swap state #112

Merged
merged 1 commit into from
Apr 29, 2024
Merged
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
9 changes: 4 additions & 5 deletions lib/ls-sdk-core/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ impl Wallet {
.swap_status(SwapStatusRequest { id: id.clone() })
.map_err(|e| anyhow!("Failed to fetch swap status for ID {id}: {e:?}"))?;

let swap_state = status_response
.status
let status = status_response.status;
let swap_state = status
.parse::<SubSwapStates>()
.map_err(|_| anyhow!("Invalid swap state received for swap {id}"))?;
.map_err(|_| anyhow!("Invalid swap state received for swap {id}: {status}",))?;

match swap_state {
SubSwapStates::SwapExpired => {
Expand All @@ -140,8 +140,7 @@ impl Wallet {
SubSwapStates::TransactionMempool | SubSwapStates::TransactionConfirmed => {}
_ => {
return Err(anyhow!(
"Cannot claim swap {id}: invoice not paid yet. Swap state: {}",
swap_state.to_string()
"Cannot claim swap {id}: invoice not paid yet. Swap state: {status}",
));
}
}
Expand Down