Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

Commit

Permalink
Add Persona and new() implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinnstah committed Dec 6, 2023
1 parent e0da263 commit 615f214
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 1 deletion.
1 change: 1 addition & 0 deletions profile/src/v100/entity/persona/mod.rs
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pub mod persona;
pub mod persona_data;
55 changes: 54 additions & 1 deletion profile/src/v100/entity/persona/persona.rs
Original file line number Diff line number Diff line change
@@ -1 +1,54 @@
pub struct Persona {}
use crate::v100::address::identity_address::IdentityAddress;
use crate::v100::entity::display_name::DisplayName;
use crate::v100::entity::entity_flags::EntityFlags;
use crate::v100::entity::persona::persona_data::persona_data::PersonaData;
use crate::v100::entity_security_state::entity_security_state::EntitySecurityState;
use radix_engine_common::prelude::RefCell;
use serde::{Deserialize, Serialize};
use wallet_kit_common::network_id::NetworkID;

/// A network unique account with a unique public address and a set of cryptographic
/// factors used to control it. The account is either `virtual` or not. By "virtual"
/// we mean that the Radix Public Ledger does not yet know of the public address
/// of this account.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct Persona {
/// The ID of the network this persona exists on.
#[serde(rename = "networkID")]
pub network_id: NetworkID,

/// The globally unique and identifiable Radix component address of this persona. Can be used as
/// a stable ID. Cryptographically derived from a seeding public key which typically was created by
/// the `DeviceFactorSource`
pub address: IdentityAddress,

/// Security of this persona
#[serde(rename = "securityState")]
security_state: EntitySecurityState,

/// A required non empty display name, used by presentation layer and sent to Dapps when requested.
#[serde(rename = "displayName")]
display_name: RefCell<DisplayName>,

/// An order set of `EntityFlag`s used to describe certain Off-ledger
/// user state about Accounts or Personas, such as if an entity is
/// marked as hidden or not.
pub flags: RefCell<EntityFlags>,

#[serde(rename = "personaData")]
persona_data: PersonaData,
}

impl Persona {
pub fn new(address: IdentityAddress, display_name: DisplayName) -> Self {
Self {
network_id: address.network_id,
address,
security_state: EntitySecurityState::placeholder(),
display_name: RefCell::new(display_name),
flags: RefCell::new(EntityFlags::default()),
persona_data: todo!(),
}
}
}
1 change: 1 addition & 0 deletions profile/src/v100/entity/persona/persona_data/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod persona_data;
27 changes: 27 additions & 0 deletions profile/src/v100/entity/persona/persona_data/persona_data.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
use serde::{Deserialize, Serialize};

//Need to implement https://github.com/radixdlt/babylon-wallet-ios/blob/main/RadixWallet/Profile/Entity/PersonaData/PersonaData.swift
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, Default)]
pub struct PersonaData {
name: String,

#[serde(rename = "dateOfBirth")]
date_of_birth: String,

#[serde(rename = "companyName")]
company_name: String,

#[serde(rename = "emailAddresses")]
email_addresses: String,

#[serde(rename = "phoneNumbers")]
phone_numbers: String,

urls: String,

#[serde(rename = "postalAddresses")]
postal_addresses: String,

#[serde(rename = "creditCards")]
credit_cards: String,
}

0 comments on commit 615f214

Please sign in to comment.