diff --git a/Cargo.lock b/Cargo.lock index 6635f8dd..0b8fd767 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11204,7 +11204,6 @@ dependencies = [ "solana-zk-sdk-pod", "spl-token-2022-interface 2.1.0", "spl-token-confidential-transfer-proof-extraction 0.6.0", - "spl-token-confidential-transfer-proof-generation 0.6.0", "spl-token-group-interface", "spl-token-interface", "spl-token-metadata-interface 1.0.0", diff --git a/clients/rust-legacy/src/zk_proofs/confidential_mint_burn.rs b/clients/rust-legacy/src/zk_proofs/confidential_mint_burn.rs index f8556f04..3ba9f71f 100644 --- a/clients/rust-legacy/src/zk_proofs/confidential_mint_burn.rs +++ b/clients/rust-legacy/src/zk_proofs/confidential_mint_burn.rs @@ -1,4 +1,5 @@ use { + crate::zk_proofs::IntoTokenError, solana_zk_elgamal_proof_interface::proof_data::CiphertextCiphertextEqualityProofData, solana_zk_sdk::{ encryption::{ @@ -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. @@ -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. diff --git a/clients/rust-legacy/src/zk_proofs/confidential_transfer.rs b/clients/rust-legacy/src/zk_proofs/confidential_transfer.rs index bdeb476e..7889cd1a 100644 --- a/clients/rust-legacy/src/zk_proofs/confidential_transfer.rs +++ b/clients/rust-legacy/src/zk_proofs/confidential_transfer.rs @@ -1,4 +1,5 @@ use { + crate::zk_proofs::IntoTokenError, solana_zk_elgamal_proof_interface::proof_data::ZeroCiphertextProofData, solana_zk_sdk::{ encryption::{ @@ -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. @@ -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 @@ -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. diff --git a/clients/rust-legacy/src/zk_proofs/mod.rs b/clients/rust-legacy/src/zk_proofs/mod.rs index 61cde2b4..211da9f4 100644 --- a/clients/rust-legacy/src/zk_proofs/mod.rs +++ b/clients/rust-legacy/src/zk_proofs/mod.rs @@ -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, + } + } +} diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 2955cd77..8fa594cd 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -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"] } diff --git a/interface/src/error.rs b/interface/src/error.rs index 9345b94f..3b0a5b78 100644 --- a/interface/src/error.rs +++ b/interface/src/error.rs @@ -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}, @@ -471,19 +469,6 @@ impl ToStr for TokenError { } } -#[cfg(not(target_os = "solana"))] -impl From 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 for TokenError { fn from(e: TokenProofExtractionError) -> Self { match e {