Skip to content

Commit

Permalink
add serde serialize for policytype and identity (#69)
Browse files Browse the repository at this point in the history
* add serde serialize for policytype and identity

* fmt
  • Loading branch information
Bhargavamacha authored Jul 9, 2024
1 parent 10ad2c5 commit 17daa1d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
1 change: 1 addition & 0 deletions programs/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions programs/policy_engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ idl-build = ["anchor-lang/idl-build", "anchor-spl/idl-build"]
anchor-lang = { version = "0.30.1" }
anchor-spl = { version = "0.30.1" }
rwa_utils = { path = "../rwa_utils" }
serde = "1.0"
num_enum = "0.7.2"
sha256 = "1.5.0"
29 changes: 26 additions & 3 deletions programs/policy_engine/src/state/account.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
use anchor_lang::prelude::*;
use num_enum::IntoPrimitive;
use serde::{Deserialize, Serialize};

use crate::PolicyEngineErrors;

#[derive(AnchorDeserialize, AnchorSerialize, Clone, InitSpace, Copy, Debug)]
#[derive(
AnchorDeserialize, AnchorSerialize, Clone, InitSpace, Copy, Debug, Serialize, Deserialize,
)]
pub struct IdentityFilter {
pub identity_levels: [u8; 10], // 10
pub comparision_type: ComparisionType, // 2
}

#[repr(u8)]
#[derive(IntoPrimitive, AnchorDeserialize, AnchorSerialize, Clone, InitSpace, Copy, Debug)]
#[derive(
IntoPrimitive,
AnchorDeserialize,
AnchorSerialize,
Clone,
InitSpace,
Copy,
Debug,
Serialize,
Deserialize,
)]
pub enum ComparisionType {
Or,
And,
Expand All @@ -36,7 +49,17 @@ pub struct Policy {
pub policy_type: PolicyType,
}

#[derive(AnchorSerialize, AnchorDeserialize, Clone, InitSpace, PartialEq, Copy, Debug)]
#[derive(
AnchorSerialize,
AnchorDeserialize,
Clone,
InitSpace,
PartialEq,
Copy,
Debug,
Serialize,
Deserialize,
)]
pub enum PolicyType {
IdentityApproval,
TransactionAmountLimit { limit: u64 },
Expand Down

0 comments on commit 17daa1d

Please sign in to comment.