From 11a2d8c8f3457e8c5009f4d3eab81a5bf5ba5932 Mon Sep 17 00:00:00 2001 From: CleverWild Date: Mon, 29 Jun 2026 16:58:36 +0200 Subject: [PATCH] refactor(integrity): migrate impl Integrable to #[derive(Integrable)] --- server/crates/arbiter-server/src/crypto/integrity/v1.rs | 8 +++----- .../src/evm/policies/ether_transfer/mod.rs | 7 ++----- .../src/evm/policies/token_transfers/mod.rs | 7 ++----- server/crates/arbiter-server/src/peers/client/mod.rs | 9 +++------ server/crates/arbiter-server/src/peers/operator/mod.rs | 9 +++------ 5 files changed, 13 insertions(+), 27 deletions(-) diff --git a/server/crates/arbiter-server/src/crypto/integrity/v1.rs b/server/crates/arbiter-server/src/crypto/integrity/v1.rs index 402a3e6..3e9bf00 100644 --- a/server/crates/arbiter-server/src/crypto/integrity/v1.rs +++ b/server/crates/arbiter-server/src/crypto/integrity/v1.rs @@ -214,15 +214,13 @@ mod tests { }; use arbiter_crypto::safecell::{SafeCell, SafeCellHandle as _}; - use super::{Error, Integrable, sign_entity, verify_entity}; - #[derive(Clone, arbiter_macros::Hashable)] + use super::{Error, sign_entity, verify_entity}; + #[derive(Clone, arbiter_macros::Hashable, arbiter_macros::Integrable)] + #[integrable(kind = "dummy_entity")] struct DummyEntity { payload_version: i32, payload: Vec, } - impl Integrable for DummyEntity { - const KIND: &'static str = "dummy_entity"; - } async fn bootstrapped_vault(db: &db::DatabasePool) -> ActorRef { let actor = Vault::spawn( diff --git a/server/crates/arbiter-server/src/evm/policies/ether_transfer/mod.rs b/server/crates/arbiter-server/src/evm/policies/ether_transfer/mod.rs index bff34a0..38d5155 100644 --- a/server/crates/arbiter-server/src/evm/policies/ether_transfer/mod.rs +++ b/server/crates/arbiter-server/src/evm/policies/ether_transfer/mod.rs @@ -1,6 +1,5 @@ use super::{DatabaseID, EvalContext, EvalViolation}; use crate::{ - crypto::integrity::v1::Integrable, db::models::{ EvmBasicGrant, EvmEtherTransferGrant, EvmEtherTransferGrantTarget, EvmEtherTransferLimit, NewEvmEtherTransferLimit, SqliteTimestamp, @@ -52,14 +51,12 @@ impl From for SpecificMeaning { } // A grant for ether transfers, which can be scoped to specific target addresses and volume limits -#[derive(Debug, Clone, arbiter_macros::Hashable)] +#[derive(Debug, Clone, arbiter_macros::Hashable, arbiter_macros::Integrable)] +#[integrable(kind = "EtherTransfer")] pub struct Settings { pub target: Vec
, pub limit: VolumeRateLimit, } -impl Integrable for Settings { - const KIND: &'static str = "EtherTransfer"; -} impl From for SpecificGrant { fn from(val: Settings) -> Self { diff --git a/server/crates/arbiter-server/src/evm/policies/token_transfers/mod.rs b/server/crates/arbiter-server/src/evm/policies/token_transfers/mod.rs index d91b942..cc4ef51 100644 --- a/server/crates/arbiter-server/src/evm/policies/token_transfers/mod.rs +++ b/server/crates/arbiter-server/src/evm/policies/token_transfers/mod.rs @@ -1,6 +1,5 @@ use super::{DatabaseID, EvalContext, EvalViolation}; use crate::{ - crypto::integrity::Integrable, db::models::{ EvmBasicGrant, EvmTokenTransferGrant, EvmTokenTransferVolumeLimit, NewEvmTokenTransferGrant, NewEvmTokenTransferLog, NewEvmTokenTransferVolumeLimit, @@ -63,15 +62,13 @@ impl From for SpecificMeaning { } // A grant for token transfers, which can be scoped to specific target addresses and volume limits -#[derive(Debug, Clone, arbiter_macros::Hashable)] +#[derive(Debug, Clone, arbiter_macros::Hashable, arbiter_macros::Integrable)] +#[integrable(kind = "TokenTransfer")] pub struct Settings { pub token_contract: Address, pub target: Option
, pub volume_limits: Vec, } -impl Integrable for Settings { - const KIND: &'static str = "TokenTransfer"; -} impl From for SpecificGrant { fn from(val: Settings) -> Self { diff --git a/server/crates/arbiter-server/src/peers/client/mod.rs b/server/crates/arbiter-server/src/peers/client/mod.rs index f142bb8..85c7697 100644 --- a/server/crates/arbiter-server/src/peers/client/mod.rs +++ b/server/crates/arbiter-server/src/peers/client/mod.rs @@ -1,5 +1,5 @@ use crate::{ - actors::GlobalActors, crypto::integrity::Integrable, db, peers::client::session::ClientSession, + actors::GlobalActors, db, peers::client::session::ClientSession, }; use arbiter_crypto::authn; use arbiter_macros::Hashable; @@ -14,15 +14,12 @@ pub struct ClientProfile { pub metadata: ClientMetadata, } -#[derive(Hashable)] +#[derive(Hashable, arbiter_macros::Integrable)] +#[integrable(kind = "client_credentials")] pub struct ClientCredentials { pub pubkey: authn::PublicKey, } -impl Integrable for ClientCredentials { - const KIND: &'static str = "client_credentials"; -} - pub struct ClientConnection { pub(crate) db: db::DatabasePool, pub(crate) actors: GlobalActors, diff --git a/server/crates/arbiter-server/src/peers/operator/mod.rs b/server/crates/arbiter-server/src/peers/operator/mod.rs index 0869d51..5727230 100644 --- a/server/crates/arbiter-server/src/peers/operator/mod.rs +++ b/server/crates/arbiter-server/src/peers/operator/mod.rs @@ -3,7 +3,7 @@ use crate::{ GlobalActors, vault::{GetState, Vault}, }, - crypto::integrity::{self, AttestationStatus, Integrable}, + crypto::integrity::{self, AttestationStatus}, db::{DatabaseError, DatabasePool}, peers::client::ClientProfile, }; @@ -23,16 +23,13 @@ pub mod auth; pub mod session; pub mod vault_gate; -#[derive(Debug, Clone, Hashable)] +#[derive(Debug, Clone, Hashable, arbiter_macros::Integrable)] +#[integrable(kind = "operator_credentials")] pub struct Credentials { pub id: i32, pub pubkey: authn::PublicKey, } -impl Integrable for Credentials { - const KIND: &'static str = "operator_credentials"; -} - // Messages, sent by operator to connection client without having a request #[derive(Debug)] pub enum OutOfBand {