Skip to content

Commit

Permalink
Fix parsing encoded invoice (#45)
Browse files Browse the repository at this point in the history
Encoded invoice value should be without quotation marks to be able to pass to pay_invoice.
In order for that it should be converted to Rust String type using `.as_str()`.
See serde readme for more details.
  • Loading branch information
yellowred authored May 15, 2024
1 parent 08a094f commit b2d5c30
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lightspark/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "lightspark"
description = "Lightspark Rust SDK"
authors = ["Lightspark Group, Inc. <[email protected]>"]
version = "0.8.1"
version = "0.8.2"
edition = "2021"
documentation = "https://docs.lightspark.com/lightspark-sdk/getting-started?language=Rust"
homepage = "https://www.lightspark.com/"
Expand Down
2 changes: 1 addition & 1 deletion lightspark/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Lightspark Rust SDK - v0.8.1
# Lightspark Rust SDK - v0.8.2

The Lightspark Rust SDK provides a convenient way to interact with the Lightspark services from applications written in the Rust language.

Expand Down
6 changes: 4 additions & 2 deletions lightspark/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -805,8 +805,10 @@ impl<K: OperationSigningKey> LightsparkClient<K> {
.execute_graphql(mutation, Some(value))
.await?;

let result = json["create_test_mode_invoice"]["encoded_payment_request"].clone();
Ok(result.to_string())
Ok(json["create_test_mode_invoice"]["encoded_payment_request"]
.as_str()
.ok_or_else(|| Error::GraphqlError("unable to parse the encoded invoice".into()))?
.to_owned())
}

pub async fn create_test_mode_payment(
Expand Down

0 comments on commit b2d5c30

Please sign in to comment.