Skip to content

Commit

Permalink
update account proto aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasArrachea committed Jan 10, 2025
1 parent d4b6f92 commit efbd5db
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions crates/proto/src/domain/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub struct AccountSummary {
pub block_num: u32,
}

impl From<&AccountSummary> for proto::AccountSummary {
impl From<&AccountSummary> for proto::account::AccountSummary {
fn from(update: &AccountSummary) -> Self {
Self {
account_id: Some(update.account_id.into()),
Expand All @@ -84,7 +84,7 @@ pub struct AccountInfo {
pub details: Option<Account>,
}

impl From<&AccountInfo> for proto::AccountInfo {
impl From<&AccountInfo> for proto::account::AccountInfo {
fn from(AccountInfo { summary, details }: &AccountInfo) -> Self {
Self {
summary: Some(summary.into()),
Expand Down Expand Up @@ -163,7 +163,7 @@ impl Display for AccountState {
}
}

impl From<AccountState> for AccountTransactionInputRecord {
impl From<AccountState> for proto::responses::AccountTransactionInputRecord {
fn from(from: AccountState) -> Self {
Self {
account_id: Some(from.account_id.into()),
Expand All @@ -172,7 +172,7 @@ impl From<AccountState> for AccountTransactionInputRecord {
}
}

impl From<AccountHeader> for proto::AccountHeader {
impl From<AccountHeader> for proto::account::AccountHeader {
fn from(from: AccountHeader) -> Self {
Self {
vault_root: Some(from.vault_root().into()),
Expand All @@ -183,18 +183,24 @@ impl From<AccountHeader> for proto::AccountHeader {
}
}

impl TryFrom<AccountTransactionInputRecord> for AccountState {
impl TryFrom<proto::responses::AccountTransactionInputRecord> for AccountState {
type Error = ConversionError;

fn try_from(from: AccountTransactionInputRecord) -> Result<Self, Self::Error> {
fn try_from(
from: proto::responses::AccountTransactionInputRecord,
) -> Result<Self, Self::Error> {
let account_id = from
.account_id
.ok_or(AccountTransactionInputRecord::missing_field(stringify!(account_id)))?
.ok_or(proto::responses::AccountTransactionInputRecord::missing_field(stringify!(
account_id
)))?
.try_into()?;

let account_hash = from
.account_hash
.ok_or(AccountTransactionInputRecord::missing_field(stringify!(account_hash)))?
.ok_or(proto::responses::AccountTransactionInputRecord::missing_field(stringify!(
account_hash
)))?
.try_into()?;

// If the hash is equal to `Digest::default()`, it signifies that this is a new account
Expand Down

0 comments on commit efbd5db

Please sign in to comment.