feat(server::actors::evm): implement operator_delete_grant
Sets revoked_at on the evm_basic_grant row; returns NotFound if the grant does not exist. Wires the handler in OperatorSession replacing the todo!().
This commit is contained in:
@@ -160,29 +160,23 @@ impl EvmActor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[message]
|
#[message]
|
||||||
#[expect(clippy::unused_async, reason = "reserved for impl")]
|
pub async fn operator_delete_grant(&mut self, grant_id: i32) -> Result<(), Error> {
|
||||||
pub async fn operator_delete_grant(&mut self, _grant_id: i32) -> Result<(), Error> {
|
let mut conn = self.db.get().await.map_err(DatabaseError::from)?;
|
||||||
// let mut conn = self.db.get().await.map_err(DatabaseError::from)?;
|
|
||||||
// let vault = self.vault.clone();
|
|
||||||
|
|
||||||
// diesel_async::AsyncConnection::transaction(&mut conn, |conn| {
|
let affected = diesel::update(schema::evm_basic_grant::table)
|
||||||
// Box::pin(async move {
|
.filter(schema::evm_basic_grant::id.eq(grant_id))
|
||||||
// diesel::update(schema::evm_basic_grant::table)
|
.set(schema::evm_basic_grant::revoked_at.eq(models::SqliteTimestamp::now()))
|
||||||
// .filter(schema::evm_basic_grant::id.eq(grant_id))
|
.execute(&mut conn)
|
||||||
// .set(schema::evm_basic_grant::revoked_at.eq(SqliteTimestamp::now()))
|
.await
|
||||||
// .execute(conn)
|
.map_err(DatabaseError::from)?;
|
||||||
// .await?;
|
|
||||||
|
|
||||||
// let signed = integrity::evm::load_signed_grant_by_basic_id(conn, grant_id).await?;
|
if affected == 0 {
|
||||||
|
return Err(Error::Database(DatabaseError::from(
|
||||||
|
diesel::result::Error::NotFound,
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
// diesel::result::QueryResult::Ok(())
|
Ok(())
|
||||||
// })
|
|
||||||
// })
|
|
||||||
// .await
|
|
||||||
// .map_err(DatabaseError::from)?;
|
|
||||||
|
|
||||||
// Ok(())
|
|
||||||
todo!()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[message]
|
#[message]
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ use super::{Error, OperatorSession};
|
|||||||
use crate::{
|
use crate::{
|
||||||
actors::{
|
actors::{
|
||||||
evm::{
|
evm::{
|
||||||
ClientSignTransaction, Generate, ListWallets, OperatorCreateGrant, OperatorListGrants,
|
ClientSignTransaction, Generate, ListWallets, OperatorCreateGrant, OperatorDeleteGrant,
|
||||||
SignTransactionError as EvmSignError,
|
OperatorListGrants, SignTransactionError as EvmSignError,
|
||||||
},
|
},
|
||||||
flow_coordinator::client_connect_approval::ClientApprovalAnswer,
|
flow_coordinator::client_connect_approval::ClientApprovalAnswer,
|
||||||
vault::VaultState,
|
vault::VaultState,
|
||||||
@@ -122,22 +122,23 @@ impl OperatorSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[message]
|
#[message]
|
||||||
pub(crate) fn handle_grant_delete(&mut self, grant_id: i32) -> Result<(), GrantMutationError> {
|
pub(crate) async fn handle_grant_delete(
|
||||||
// match self
|
&mut self,
|
||||||
// .props
|
grant_id: i32,
|
||||||
// .actors
|
) -> Result<(), GrantMutationError> {
|
||||||
// .evm
|
match self
|
||||||
// .ask(OperatorDeleteGrant { grant_id })
|
.props
|
||||||
// .await
|
.actors
|
||||||
// {
|
.evm
|
||||||
// Ok(()) => Ok(()),
|
.ask(OperatorDeleteGrant { grant_id })
|
||||||
// Err(err) => {
|
.await
|
||||||
// error!(?err, "EVM grant delete failed");
|
{
|
||||||
// Err(GrantMutationError::Internal)
|
Ok(()) => Ok(()),
|
||||||
// }
|
Err(err) => {
|
||||||
// }
|
error!(?err, "EVM grant delete failed");
|
||||||
let _ = grant_id;
|
Err(GrantMutationError::Internal)
|
||||||
todo!()
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[message]
|
#[message]
|
||||||
@@ -217,8 +218,8 @@ impl OperatorSession {
|
|||||||
pub(crate) async fn handle_list_wallet_access(
|
pub(crate) async fn handle_list_wallet_access(
|
||||||
&mut self,
|
&mut self,
|
||||||
) -> Result<Vec<EvmWalletAccess>, Error> {
|
) -> Result<Vec<EvmWalletAccess>, Error> {
|
||||||
let mut conn = self.props.db.get().await?;
|
|
||||||
use crate::db::schema::evm_wallet_access;
|
use crate::db::schema::evm_wallet_access;
|
||||||
|
let mut conn = self.props.db.get().await?;
|
||||||
let access_entries = evm_wallet_access::table
|
let access_entries = evm_wallet_access::table
|
||||||
.select(EvmWalletAccess::as_select())
|
.select(EvmWalletAccess::as_select())
|
||||||
.load::<_>(&mut conn)
|
.load::<_>(&mut conn)
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ impl OperatorSession {
|
|||||||
Self {
|
Self {
|
||||||
props,
|
props,
|
||||||
sender,
|
sender,
|
||||||
pending_client_approvals: Default::default(),
|
pending_client_approvals: HashMap::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user