drk: Update wallet metadata when tokens are being frozen.

This commit is contained in:
parazyd
2023-02-24 15:06:42 +01:00
parent e67f133be8
commit 23b6b110c5
3 changed files with 22 additions and 12 deletions

View File

@@ -29,7 +29,8 @@ use darkfi_money_contract::{
MONEY_COINS_COL_USER_DATA, MONEY_COINS_COL_VALUE, MONEY_COINS_COL_VALUE_BLIND,
MONEY_COINS_TABLE, MONEY_INFO_COL_LAST_SCANNED_SLOT, MONEY_INFO_TABLE,
MONEY_KEYS_COL_IS_DEFAULT, MONEY_KEYS_COL_KEY_ID, MONEY_KEYS_COL_PUBLIC,
MONEY_KEYS_COL_SECRET, MONEY_KEYS_TABLE, MONEY_TREE_COL_TREE, MONEY_TREE_TABLE,
MONEY_KEYS_COL_SECRET, MONEY_KEYS_TABLE, MONEY_TOKENS_COL_IS_FROZEN,
MONEY_TOKENS_COL_TOKEN_ID, MONEY_TOKENS_TABLE, MONEY_TREE_COL_TREE, MONEY_TREE_TABLE,
},
model::{MoneyFreezeParamsV1, MoneyMintParamsV1, MoneyTransferParamsV1, Output},
MoneyFunction,
@@ -637,7 +638,15 @@ impl Drk {
}
for token_id in freezes {
// TODO: Update info in wallet if token id is found
let query = format!(
"UPDATE {} SET {} = 1 WHERE {} = ?1;",
MONEY_TOKENS_TABLE, MONEY_TOKENS_COL_IS_FROZEN, MONEY_TOKENS_COL_TOKEN_ID,
);
let params = json!([query, QueryType::Blob as u8, serialize(&token_id)]);
let req = JsonRequest::new("wallet.exec_sql", params);
let _ = self.rpc_client.request(req).await?;
}
if !owncoins.is_empty() {

View File

@@ -19,7 +19,8 @@
use anyhow::{anyhow, Result};
use darkfi::{rpc::jsonrpc::JsonRequest, wallet::walletdb::QueryType};
use darkfi_money_contract::client::{
MONEY_TOKENS_IS_FROZEN, MONEY_TOKENS_MINT_AUTHORITY, MONEY_TOKENS_TABLE, MONEY_TOKENS_TOKEN_ID,
MONEY_TOKENS_COL_IS_FROZEN, MONEY_TOKENS_COL_MINT_AUTHORITY, MONEY_TOKENS_COL_TOKEN_ID,
MONEY_TOKENS_TABLE,
};
use darkfi_sdk::crypto::{SecretKey, TokenId};
use darkfi_serial::{deserialize, serialize};
@@ -36,9 +37,9 @@ impl Drk {
let query = format!(
"INSERT INTO {} ({}, {}, {}) VALUES (?1, ?2, ?3);",
MONEY_TOKENS_TABLE,
MONEY_TOKENS_MINT_AUTHORITY,
MONEY_TOKENS_TOKEN_ID,
MONEY_TOKENS_IS_FROZEN,
MONEY_TOKENS_COL_MINT_AUTHORITY,
MONEY_TOKENS_COL_TOKEN_ID,
MONEY_TOKENS_COL_IS_FROZEN,
);
let params = json!([
@@ -65,11 +66,11 @@ impl Drk {
let params = json!([
query,
QueryType::Blob as u8,
MONEY_TOKENS_MINT_AUTHORITY,
MONEY_TOKENS_COL_MINT_AUTHORITY,
QueryType::Blob as u8,
MONEY_TOKENS_TOKEN_ID,
MONEY_TOKENS_COL_TOKEN_ID,
QueryType::Integer as u8,
MONEY_TOKENS_IS_FROZEN,
MONEY_TOKENS_COL_IS_FROZEN,
]);
let req = JsonRequest::new("wallet.query_row_multi", params);

View File

@@ -76,9 +76,9 @@ pub const MONEY_COINS_COL_LEAF_POSITION: &str = "leaf_position";
pub const MONEY_COINS_COL_MEMO: &str = "memo";
pub const MONEY_TOKENS_TABLE: &str = "money_tokens";
pub const MONEY_TOKENS_MINT_AUTHORITY: &str = "mint_authority";
pub const MONEY_TOKENS_TOKEN_ID: &str = "token_id";
pub const MONEY_TOKENS_IS_FROZEN: &str = "is_frozen";
pub const MONEY_TOKENS_COL_MINT_AUTHORITY: &str = "mint_authority";
pub const MONEY_TOKENS_COL_TOKEN_ID: &str = "token_id";
pub const MONEY_TOKENS_COL_IS_FROZEN: &str = "is_frozen";
pub const MONEY_ALIASES_TABLE: &str = "money_aliases";
pub const MONEY_ALIASES_COL_ALIAS: &str = "alias";