Skip to content

Commit

Permalink
fix: deserialization issue with roles if imported
Browse files Browse the repository at this point in the history
  • Loading branch information
LHerskind committed Apr 23, 2024
1 parent 78fbdfd commit 66e379e
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use dep::aztec::protocol_types::traits::{FromField, ToField, Serialize};
use dep::aztec::protocol_types::traits::{FromField, ToField, Serialize, Deserialize};

global ADMIN_FLAG: u64 = 1;
global MINTER_FLAG: u64 = 2;
Expand Down Expand Up @@ -52,6 +52,18 @@ impl Serialize<3> for UserFlags {
}
}

// We implement this as it is required for other contracts to be able to "rebuild" the variable
// after having received the serialized value as a return-value
impl Deserialize<3> for UserFlags {
fn deserialize(fields: [Field; 3]) -> Self {
Self {
is_admin: fields[0] as bool,
is_minter: fields[1] as bool,
is_blacklisted: fields[2] as bool,
}
}
}

mod test {
use crate::types::roles::UserFlags;

Expand Down

0 comments on commit 66e379e

Please sign in to comment.