refactor(integrity): migrate impl Integrable to #[derive(Integrable)]
This commit is contained in:
@@ -214,15 +214,13 @@ mod tests {
|
|||||||
};
|
};
|
||||||
use arbiter_crypto::safecell::{SafeCell, SafeCellHandle as _};
|
use arbiter_crypto::safecell::{SafeCell, SafeCellHandle as _};
|
||||||
|
|
||||||
use super::{Error, Integrable, sign_entity, verify_entity};
|
use super::{Error, sign_entity, verify_entity};
|
||||||
#[derive(Clone, arbiter_macros::Hashable)]
|
#[derive(Clone, arbiter_macros::Hashable, arbiter_macros::Integrable)]
|
||||||
|
#[integrable(kind = "dummy_entity")]
|
||||||
struct DummyEntity {
|
struct DummyEntity {
|
||||||
payload_version: i32,
|
payload_version: i32,
|
||||||
payload: Vec<u8>,
|
payload: Vec<u8>,
|
||||||
}
|
}
|
||||||
impl Integrable for DummyEntity {
|
|
||||||
const KIND: &'static str = "dummy_entity";
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn bootstrapped_vault(db: &db::DatabasePool) -> ActorRef<Vault> {
|
async fn bootstrapped_vault(db: &db::DatabasePool) -> ActorRef<Vault> {
|
||||||
let actor = Vault::spawn(
|
let actor = Vault::spawn(
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
use super::{DatabaseID, EvalContext, EvalViolation};
|
use super::{DatabaseID, EvalContext, EvalViolation};
|
||||||
use crate::{
|
use crate::{
|
||||||
crypto::integrity::v1::Integrable,
|
|
||||||
db::models::{
|
db::models::{
|
||||||
EvmBasicGrant, EvmEtherTransferGrant, EvmEtherTransferGrantTarget, EvmEtherTransferLimit,
|
EvmBasicGrant, EvmEtherTransferGrant, EvmEtherTransferGrantTarget, EvmEtherTransferLimit,
|
||||||
NewEvmEtherTransferLimit, SqliteTimestamp,
|
NewEvmEtherTransferLimit, SqliteTimestamp,
|
||||||
@@ -52,14 +51,12 @@ impl From<Meaning> for SpecificMeaning {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// A grant for ether transfers, which can be scoped to specific target addresses and volume limits
|
// 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 struct Settings {
|
||||||
pub target: Vec<Address>,
|
pub target: Vec<Address>,
|
||||||
pub limit: VolumeRateLimit,
|
pub limit: VolumeRateLimit,
|
||||||
}
|
}
|
||||||
impl Integrable for Settings {
|
|
||||||
const KIND: &'static str = "EtherTransfer";
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<Settings> for SpecificGrant {
|
impl From<Settings> for SpecificGrant {
|
||||||
fn from(val: Settings) -> Self {
|
fn from(val: Settings) -> Self {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
use super::{DatabaseID, EvalContext, EvalViolation};
|
use super::{DatabaseID, EvalContext, EvalViolation};
|
||||||
use crate::{
|
use crate::{
|
||||||
crypto::integrity::Integrable,
|
|
||||||
db::models::{
|
db::models::{
|
||||||
EvmBasicGrant, EvmTokenTransferGrant, EvmTokenTransferVolumeLimit,
|
EvmBasicGrant, EvmTokenTransferGrant, EvmTokenTransferVolumeLimit,
|
||||||
NewEvmTokenTransferGrant, NewEvmTokenTransferLog, NewEvmTokenTransferVolumeLimit,
|
NewEvmTokenTransferGrant, NewEvmTokenTransferLog, NewEvmTokenTransferVolumeLimit,
|
||||||
@@ -63,15 +62,13 @@ impl From<Meaning> for SpecificMeaning {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// A grant for token transfers, which can be scoped to specific target addresses and volume limits
|
// 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 struct Settings {
|
||||||
pub token_contract: Address,
|
pub token_contract: Address,
|
||||||
pub target: Option<Address>,
|
pub target: Option<Address>,
|
||||||
pub volume_limits: Vec<VolumeRateLimit>,
|
pub volume_limits: Vec<VolumeRateLimit>,
|
||||||
}
|
}
|
||||||
impl Integrable for Settings {
|
|
||||||
const KIND: &'static str = "TokenTransfer";
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<Settings> for SpecificGrant {
|
impl From<Settings> for SpecificGrant {
|
||||||
fn from(val: Settings) -> Self {
|
fn from(val: Settings) -> Self {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use crate::{
|
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_crypto::authn;
|
||||||
use arbiter_macros::Hashable;
|
use arbiter_macros::Hashable;
|
||||||
@@ -14,15 +14,12 @@ pub struct ClientProfile {
|
|||||||
pub metadata: ClientMetadata,
|
pub metadata: ClientMetadata,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Hashable)]
|
#[derive(Hashable, arbiter_macros::Integrable)]
|
||||||
|
#[integrable(kind = "client_credentials")]
|
||||||
pub struct ClientCredentials {
|
pub struct ClientCredentials {
|
||||||
pub pubkey: authn::PublicKey,
|
pub pubkey: authn::PublicKey,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Integrable for ClientCredentials {
|
|
||||||
const KIND: &'static str = "client_credentials";
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct ClientConnection {
|
pub struct ClientConnection {
|
||||||
pub(crate) db: db::DatabasePool,
|
pub(crate) db: db::DatabasePool,
|
||||||
pub(crate) actors: GlobalActors,
|
pub(crate) actors: GlobalActors,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use crate::{
|
|||||||
GlobalActors,
|
GlobalActors,
|
||||||
vault::{GetState, Vault},
|
vault::{GetState, Vault},
|
||||||
},
|
},
|
||||||
crypto::integrity::{self, AttestationStatus, Integrable},
|
crypto::integrity::{self, AttestationStatus},
|
||||||
db::{DatabaseError, DatabasePool},
|
db::{DatabaseError, DatabasePool},
|
||||||
peers::client::ClientProfile,
|
peers::client::ClientProfile,
|
||||||
};
|
};
|
||||||
@@ -23,16 +23,13 @@ pub mod auth;
|
|||||||
pub mod session;
|
pub mod session;
|
||||||
pub mod vault_gate;
|
pub mod vault_gate;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Hashable)]
|
#[derive(Debug, Clone, Hashable, arbiter_macros::Integrable)]
|
||||||
|
#[integrable(kind = "operator_credentials")]
|
||||||
pub struct Credentials {
|
pub struct Credentials {
|
||||||
pub id: i32,
|
pub id: i32,
|
||||||
pub pubkey: authn::PublicKey,
|
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
|
// Messages, sent by operator to connection client without having a request
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum OutOfBand {
|
pub enum OutOfBand {
|
||||||
|
|||||||
Reference in New Issue
Block a user