mirror of
https://github.com/aljazceru/cdk.git
synced 2025-12-19 13:44:55 +01:00
Fix get_mint_quote_by_request_lookup_id
Fixes #916 The two functions (read and transaction) got out of sync
This commit is contained in:
@@ -414,7 +414,7 @@ impl<'a> MintQuotesTransaction<'a> for SqliteTransaction<'a> {
|
|||||||
// Get current amount_paid from quote
|
// Get current amount_paid from quote
|
||||||
let current_amount = query(
|
let current_amount = query(
|
||||||
r#"
|
r#"
|
||||||
SELECT amount_paid
|
SELECT amount_paid
|
||||||
FROM mint_quote
|
FROM mint_quote
|
||||||
WHERE id = :quote_id
|
WHERE id = :quote_id
|
||||||
"#,
|
"#,
|
||||||
@@ -442,8 +442,8 @@ impl<'a> MintQuotesTransaction<'a> for SqliteTransaction<'a> {
|
|||||||
// Update the amount_paid
|
// Update the amount_paid
|
||||||
query(
|
query(
|
||||||
r#"
|
r#"
|
||||||
UPDATE mint_quote
|
UPDATE mint_quote
|
||||||
SET amount_paid = :amount_paid
|
SET amount_paid = :amount_paid
|
||||||
WHERE id = :quote_id
|
WHERE id = :quote_id
|
||||||
"#,
|
"#,
|
||||||
)
|
)
|
||||||
@@ -487,7 +487,7 @@ impl<'a> MintQuotesTransaction<'a> for SqliteTransaction<'a> {
|
|||||||
// Get current amount_issued from quote
|
// Get current amount_issued from quote
|
||||||
let current_amount = query(
|
let current_amount = query(
|
||||||
r#"
|
r#"
|
||||||
SELECT amount_issued
|
SELECT amount_issued
|
||||||
FROM mint_quote
|
FROM mint_quote
|
||||||
WHERE id = :quote_id
|
WHERE id = :quote_id
|
||||||
"#,
|
"#,
|
||||||
@@ -515,8 +515,8 @@ impl<'a> MintQuotesTransaction<'a> for SqliteTransaction<'a> {
|
|||||||
// Update the amount_issued
|
// Update the amount_issued
|
||||||
query(
|
query(
|
||||||
r#"
|
r#"
|
||||||
UPDATE mint_quote
|
UPDATE mint_quote
|
||||||
SET amount_issued = :amount_issued
|
SET amount_issued = :amount_issued
|
||||||
WHERE id = :quote_id
|
WHERE id = :quote_id
|
||||||
"#,
|
"#,
|
||||||
)
|
)
|
||||||
@@ -593,8 +593,8 @@ VALUES (:quote_id, :amount, :timestamp);
|
|||||||
let current_time = unix_time();
|
let current_time = unix_time();
|
||||||
let row_affected = query(
|
let row_affected = query(
|
||||||
r#"
|
r#"
|
||||||
DELETE FROM melt_quote
|
DELETE FROM melt_quote
|
||||||
WHERE request_lookup_id = :request_lookup_id
|
WHERE request_lookup_id = :request_lookup_id
|
||||||
AND state = :state
|
AND state = :state
|
||||||
AND expiry < :current_time
|
AND expiry < :current_time
|
||||||
"#,
|
"#,
|
||||||
@@ -781,7 +781,7 @@ VALUES (:quote_id, :amount, :timestamp);
|
|||||||
) -> Result<Option<mint::MeltQuote>, Self::Err> {
|
) -> Result<Option<mint::MeltQuote>, Self::Err> {
|
||||||
Ok(query(
|
Ok(query(
|
||||||
r#"
|
r#"
|
||||||
SELECT
|
SELECT
|
||||||
id,
|
id,
|
||||||
unit,
|
unit,
|
||||||
amount,
|
amount,
|
||||||
@@ -985,12 +985,12 @@ impl MintQuotesDatabase for MintSqliteDatabase {
|
|||||||
request_lookup_id_kind
|
request_lookup_id_kind
|
||||||
FROM
|
FROM
|
||||||
mint_quote
|
mint_quote
|
||||||
WHERE request_lookup_id = :request_lookup_id"#,
|
WHERE request_lookup_id = :request_lookup_id
|
||||||
)
|
AND request_lookup_id_kind = :request_lookup_id_kind
|
||||||
.bind(
|
"#,
|
||||||
":request_lookup_id",
|
|
||||||
serde_json::to_string(request_lookup_id)?,
|
|
||||||
)
|
)
|
||||||
|
.bind(":request_lookup_id", request_lookup_id.to_string())
|
||||||
|
.bind(":request_lookup_id_kind", request_lookup_id.kind())
|
||||||
.fetch_one(&self.pool)
|
.fetch_one(&self.pool)
|
||||||
.await?
|
.await?
|
||||||
.map(|row| sqlite_row_to_mint_quote(row, vec![], vec![]))
|
.map(|row| sqlite_row_to_mint_quote(row, vec![], vec![]))
|
||||||
@@ -1077,7 +1077,7 @@ impl MintQuotesDatabase for MintSqliteDatabase {
|
|||||||
async fn get_melt_quotes(&self) -> Result<Vec<mint::MeltQuote>, Self::Err> {
|
async fn get_melt_quotes(&self) -> Result<Vec<mint::MeltQuote>, Self::Err> {
|
||||||
Ok(query(
|
Ok(query(
|
||||||
r#"
|
r#"
|
||||||
SELECT
|
SELECT
|
||||||
id,
|
id,
|
||||||
unit,
|
unit,
|
||||||
amount,
|
amount,
|
||||||
|
|||||||
Reference in New Issue
Block a user