diff --git a/account-decoder/src/parse_token_extension.rs b/account-decoder/src/parse_token_extension.rs index c9e60fb2024986..998250368b0f90 100644 --- a/account-decoder/src/parse_token_extension.rs +++ b/account-decoder/src/parse_token_extension.rs @@ -14,8 +14,8 @@ pub enum UiExtension { TransferFeeConfig(UiTransferFeeConfig), TransferFeeAmount(UiTransferFeeAmount), MintCloseAuthority(UiMintCloseAuthority), - ConfidentialTransferMint, // Implementation of extension state to come - ConfidentialTransferAccount, // Implementation of extension state to come + ConfidentialTransferMint(UiConfidentialTransferMint), + ConfidentialTransferAccount(UiConfidentialTransferAccount), DefaultAccountState(UiDefaultAccountState), ImmutableOwner, MemoTransfer(UiMemoTransfer), @@ -42,8 +42,14 @@ pub fn parse_extension( .get_extension::() .map(|&extension| UiExtension::MintCloseAuthority(extension.into())) .unwrap_or(UiExtension::UnparseableExtension), - ExtensionType::ConfidentialTransferMint => UiExtension::ConfidentialTransferMint, - ExtensionType::ConfidentialTransferAccount => UiExtension::ConfidentialTransferAccount, + ExtensionType::ConfidentialTransferMint => account + .get_extension::() + .map(|&extension| UiExtension::ConfidentialTransferMint(extension.into())) + .unwrap_or(UiExtension::UnparseableExtension), + ExtensionType::ConfidentialTransferAccount => account + .get_extension::() + .map(|&extension| UiExtension::ConfidentialTransferAccount(extension.into())) + .unwrap_or(UiExtension::UnparseableExtension), ExtensionType::DefaultAccountState => account .get_extension::() .map(|&extension| UiExtension::DefaultAccountState(extension.into())) @@ -197,3 +203,86 @@ impl From for UiInteres } } } + +#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)] +#[serde(rename_all = "camelCase")] +pub struct UiConfidentialTransferMint { + pub authority: String, + pub auto_approve_new_accounts: bool, + pub auditor_encryption_pubkey: String, + pub withdraw_withheld_authority_encryption_pubkey: String, + pub withheld_amount: String, +} + +impl From + for UiConfidentialTransferMint +{ + fn from( + confidential_transfer_mint: extension::confidential_transfer::ConfidentialTransferMint, + ) -> Self { + Self { + authority: confidential_transfer_mint.authority.to_string(), + auto_approve_new_accounts: confidential_transfer_mint.auto_approve_new_accounts.into(), + auditor_encryption_pubkey: format!( + "{}", + confidential_transfer_mint.auditor_encryption_pubkey + ), + withdraw_withheld_authority_encryption_pubkey: format!( + "{}", + confidential_transfer_mint.withdraw_withheld_authority_encryption_pubkey + ), + withheld_amount: format!("{}", confidential_transfer_mint.withheld_amount), + } + } +} + +#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)] +#[serde(rename_all = "camelCase")] +pub struct UiConfidentialTransferAccount { + pub approved: bool, + pub encryption_pubkey: String, + pub pending_balance_lo: String, + pub pending_balance_hi: String, + pub available_balance: String, + pub decryptable_available_balance: String, + pub allow_balance_credits: bool, + pub pending_balance_credit_counter: u64, + pub maximum_pending_balance_credit_counter: u64, + pub expected_pending_balance_credit_counter: u64, + pub actual_pending_balance_credit_counter: u64, + pub withheld_amount: String, +} + +impl From + for UiConfidentialTransferAccount +{ + fn from( + confidential_transfer_account: extension::confidential_transfer::ConfidentialTransferAccount, + ) -> Self { + Self { + approved: confidential_transfer_account.approved.into(), + encryption_pubkey: format!("{}", confidential_transfer_account.encryption_pubkey), + pending_balance_lo: format!("{}", confidential_transfer_account.pending_balance_lo), + pending_balance_hi: format!("{}", confidential_transfer_account.pending_balance_hi), + available_balance: format!("{}", confidential_transfer_account.available_balance), + decryptable_available_balance: format!( + "{}", + confidential_transfer_account.decryptable_available_balance + ), + allow_balance_credits: confidential_transfer_account.allow_balance_credits.into(), + pending_balance_credit_counter: confidential_transfer_account + .pending_balance_credit_counter + .into(), + maximum_pending_balance_credit_counter: confidential_transfer_account + .maximum_pending_balance_credit_counter + .into(), + expected_pending_balance_credit_counter: confidential_transfer_account + .expected_pending_balance_credit_counter + .into(), + actual_pending_balance_credit_counter: confidential_transfer_account + .actual_pending_balance_credit_counter + .into(), + withheld_amount: format!("{}", confidential_transfer_account.withheld_amount), + } + } +}