Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions clients/rust-legacy/src/zk_proofs/confidential_mint_burn.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use {
crate::zk_proofs::IntoTokenError,
solana_zk_elgamal_proof_interface::proof_data::CiphertextCiphertextEqualityProofData,
solana_zk_sdk::{
encryption::{
Expand Down Expand Up @@ -138,7 +139,7 @@ impl SupplyAccountInfo {
destination_elgamal_pubkey,
auditor_elgamal_pubkey,
)
.map_err(|e| -> TokenError { e.into() })
.map_err(|e| -> TokenError { e.into_token_error() })
}

/// Compute the new decryptable supply.
Expand Down Expand Up @@ -206,7 +207,7 @@ impl BurnAccountInfo {
supply_elgamal_pubkey,
auditor_elgamal_pubkey,
)
.map_err(|e| -> TokenError { e.into() })
.map_err(|e| -> TokenError { e.into_token_error() })
}

/// Compute the new decryptable supply.
Expand Down
7 changes: 4 additions & 3 deletions clients/rust-legacy/src/zk_proofs/confidential_transfer.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use {
crate::zk_proofs::IntoTokenError,
solana_zk_elgamal_proof_interface::proof_data::ZeroCiphertextProofData,
solana_zk_sdk::{
encryption::{
Expand Down Expand Up @@ -225,7 +226,7 @@ impl WithdrawAccountInfo {
withdraw_amount,
elgamal_keypair,
)
.map_err(|e| -> TokenError { e.into() })
.map_err(|e| -> TokenError { e.into_token_error() })
}

/// Update the decryptable available balance.
Expand Down Expand Up @@ -301,7 +302,7 @@ impl TransferAccountInfo {
destination_elgamal_pubkey,
auditor_elgamal_pubkey,
)
.map_err(|e| -> TokenError { e.into() })
.map_err(|e| -> TokenError { e.into_token_error() })
}

/// Create a transfer proof data that is split into equality, ciphertext
Expand Down Expand Up @@ -340,7 +341,7 @@ impl TransferAccountInfo {
fee_rate_basis_points,
maximum_fee,
)
.map_err(|e| -> TokenError { e.into() })
.map_err(|e| -> TokenError { e.into_token_error() })
}

/// Update the decryptable available balance.
Expand Down
21 changes: 21 additions & 0 deletions clients/rust-legacy/src/zk_proofs/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
use {
spl_token_2022_interface::error::TokenError,
spl_token_confidential_transfer_proof_generation::errors::TokenProofGenerationError,
};

pub mod confidential_mint_burn;
pub mod confidential_transfer;
pub mod confidential_transfer_fee;

pub trait IntoTokenError {
fn into_token_error(self) -> TokenError;
}

impl IntoTokenError for TokenProofGenerationError {
fn into_token_error(self) -> TokenError {
match self {
TokenProofGenerationError::ProofGeneration(_) => TokenError::ProofGeneration,
TokenProofGenerationError::NotEnoughFunds => TokenError::InsufficientFunds,
TokenProofGenerationError::IllegalAmountBitLength => TokenError::IllegalBitLength,
TokenProofGenerationError::FeeCalculation => TokenError::FeeCalculation,
TokenProofGenerationError::CiphertextExtraction => TokenError::MalformedCiphertext,
}
}
}
3 changes: 0 additions & 3 deletions interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ serde = { version = "1.0.219", optional = true }
serde_with = { version = "3.18.0", optional = true }
base64 = { version = "0.22.1", optional = true }

[target.'cfg(not(target_os = "solana"))'.dependencies]
spl-token-confidential-transfer-proof-generation = { version = "0.6.0", path = "../confidential/proof-generation" }

[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dependencies]
getrandom = { version = "0.2", features = ["js"] }

Expand Down
15 changes: 0 additions & 15 deletions interface/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//! Error types

#[cfg(not(target_os = "solana"))]
use spl_token_confidential_transfer_proof_generation::errors::TokenProofGenerationError;
use {
num_derive::FromPrimitive,
solana_program_error::{ProgramError, ToStr},
Expand Down Expand Up @@ -471,19 +469,6 @@ impl ToStr for TokenError {
}
}

#[cfg(not(target_os = "solana"))]
impl From<TokenProofGenerationError> for TokenError {
fn from(e: TokenProofGenerationError) -> Self {
match e {
TokenProofGenerationError::ProofGeneration(_) => TokenError::ProofGeneration,
TokenProofGenerationError::NotEnoughFunds => TokenError::InsufficientFunds,
TokenProofGenerationError::IllegalAmountBitLength => TokenError::IllegalBitLength,
TokenProofGenerationError::FeeCalculation => TokenError::FeeCalculation,
TokenProofGenerationError::CiphertextExtraction => TokenError::MalformedCiphertext,
}
}
}

impl From<TokenProofExtractionError> for TokenError {
fn from(e: TokenProofExtractionError) -> Self {
match e {
Expand Down
Loading