tests(evm::engine): basic policies tests
This commit is contained in:
@@ -17,6 +17,7 @@ use crate::{
|
||||
pub mod ether_transfer;
|
||||
pub mod token_transfers;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct EvalContext {
|
||||
// Which wallet is this transaction for
|
||||
pub client_id: i32,
|
||||
@@ -72,6 +73,7 @@ pub struct Grant<PolicySettings> {
|
||||
pub settings: PolicySettings,
|
||||
}
|
||||
|
||||
|
||||
pub trait Policy: Sized {
|
||||
type Settings: Send + Sync + 'static + Into<SpecificGrant>;
|
||||
type Meaning: Display + std::fmt::Debug + Send + Sync + 'static + Into<SpecificMeaning>;
|
||||
@@ -201,19 +203,6 @@ pub enum SpecificGrant {
|
||||
TokenTransfer(token_transfers::Settings),
|
||||
}
|
||||
|
||||
/// Blanket conversion from a typed `Grant<S>` into `Grant<SpecificGrant>`.
|
||||
/// Lets the engine collect across all policies into one `Vec<Grant<SpecificGrant>>`.
|
||||
impl<S: Into<SpecificGrant>> From<Grant<S>> for Grant<SpecificGrant> {
|
||||
fn from(g: Grant<S>) -> Self {
|
||||
Grant {
|
||||
id: g.id,
|
||||
shared_grant_id: g.shared_grant_id,
|
||||
shared: g.shared,
|
||||
settings: g.settings.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct FullGrant<PolicyGrant> {
|
||||
pub basic: SharedGrantSettings,
|
||||
pub specific: PolicyGrant,
|
||||
|
||||
Reference in New Issue
Block a user