feat(wallet): update mint url

feat(cli): add change mint
This commit is contained in:
thesimplekid
2024-06-25 08:31:16 +01:00
parent e358401ec8
commit 54c50c3724
9 changed files with 302 additions and 0 deletions

View File

@@ -108,6 +108,22 @@ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);
Ok(())
}
async fn remove_mint(&self, mint_url: UncheckedUrl) -> Result<(), Self::Err> {
sqlx::query(
r#"
DELETE FROM mint
WHERE mint_url=?
"#,
)
.bind(mint_url.to_string())
.execute(&self.pool)
.await
.map_err(Error::from)?;
Ok(())
}
async fn get_mint(&self, mint_url: UncheckedUrl) -> Result<Option<MintInfo>, Self::Err> {
let rec = sqlx::query(
r#"
@@ -155,6 +171,32 @@ FROM mint
Ok(mints)
}
async fn update_mint_url(
&self,
old_mint_url: UncheckedUrl,
new_mint_url: UncheckedUrl,
) -> Result<(), Self::Err> {
let tables = ["mint_quote", "proof"];
for table in &tables {
let query = format!(
r#"
UPDATE {}
SET mint_url = ?
WHERE mint_url = ?;
"#,
table
);
sqlx::query(&query)
.bind(new_mint_url.to_string())
.bind(old_mint_url.to_string())
.execute(&self.pool)
.await
.map_err(Error::from)?;
}
Ok(())
}
async fn add_mint_keysets(
&self,
mint_url: UncheckedUrl,