This repository has been archived by the owner on Feb 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Persona and new() implementation
- Loading branch information
Showing
4 changed files
with
83 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
pub mod persona; | ||
pub mod persona_data; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!(), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod persona_data; |
27 changes: 27 additions & 0 deletions
27
profile/src/v100/entity/persona/persona_data/persona_data.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
} |