From 7da620f0b4e1552eedd87bf00b1e52005df9b87f Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Wed, 29 Sep 2021 20:31:46 -0700 Subject: [PATCH] Merge sdk/ back into crypto/ --- zk-token-sdk/Cargo.toml | 16 ---- zk-token-sdk/src/lib.rs | 2 - .../src/zk_token_proof_instruction.rs | 92 ------------------- zk-token-sdk/src/zk_token_proof_program.rs | 2 - 4 files changed, 112 deletions(-) delete mode 100644 zk-token-sdk/Cargo.toml delete mode 100644 zk-token-sdk/src/lib.rs delete mode 100644 zk-token-sdk/src/zk_token_proof_instruction.rs delete mode 100644 zk-token-sdk/src/zk_token_proof_program.rs diff --git a/zk-token-sdk/Cargo.toml b/zk-token-sdk/Cargo.toml deleted file mode 100644 index 7ae72578f..000000000 --- a/zk-token-sdk/Cargo.toml +++ /dev/null @@ -1,16 +0,0 @@ -[package] -name = "spl-zk-token-sdk" -description = "Solana Program Library ZkToken Program SDK" -authors = ["Solana Maintainers "] -repository = "https://github.com/solana-labs/solana-program-library" -version = "0.1.0" -license = "Apache-2.0" -edition = "2018" -publish = false - -[dependencies] -bytemuck = { version = "1.7.2", features = ["derive"] } -num-derive = "0.3" -num-traits = "0.2" -solana-program = "=1.7.11" -spl-zk-token-crypto = { path = "../crypto" } diff --git a/zk-token-sdk/src/lib.rs b/zk-token-sdk/src/lib.rs deleted file mode 100644 index 373a9c8d1..000000000 --- a/zk-token-sdk/src/lib.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod zk_token_proof_instruction; -pub mod zk_token_proof_program; diff --git a/zk-token-sdk/src/zk_token_proof_instruction.rs b/zk-token-sdk/src/zk_token_proof_instruction.rs deleted file mode 100644 index 1cbf1854f..000000000 --- a/zk-token-sdk/src/zk_token_proof_instruction.rs +++ /dev/null @@ -1,92 +0,0 @@ -///! Instructions provided by the ZkToken Proof program -pub use spl_zk_token_crypto::instruction::*; - -use { - bytemuck::Pod, - num_derive::{FromPrimitive, ToPrimitive}, - num_traits::{FromPrimitive, ToPrimitive}, - solana_program::{instruction::Instruction, pubkey::Pubkey}, - spl_zk_token_crypto::pod::*, -}; - -#[derive(Clone, Copy, Debug, FromPrimitive, ToPrimitive, PartialEq)] -#[repr(u8)] -pub enum ProofInstruction { - /// Verify a `UpdateAccountPkData` struct - /// - /// Accounts expected by this instruction: - /// None - /// - /// Data expected by this instruction: - /// `UpdateAccountPkData` - /// - VerifyUpdateAccountPk, - - /// Verify a `CloseAccountData` struct - /// - /// Accounts expected by this instruction: - /// None - /// - /// Data expected by this instruction: - /// `CloseAccountData` - /// - VerifyCloseAccount, - - /// Verify a `WithdrawData` struct - /// - /// Accounts expected by this instruction: - /// None - /// - /// Data expected by this instruction: - /// `WithdrawData` - /// - VerifyWithdraw, - - /// Verify a `TransferRangeProofData` struct - /// - /// Accounts expected by this instruction: - /// None - /// - /// Data expected by this instruction: - /// `TransferRangeProofData` - /// - VerifyTransferRangeProofData, - - /// Verify a `TransferValidityProofData` struct - /// - /// Accounts expected by this instruction: - /// None - /// - /// Data expected by this instruction: - /// `TransferValidityProofData` - /// - VerifyTransferValidityProofData, -} - -impl ProofInstruction { - pub fn encode(&self, proof: &T) -> Instruction { - let mut data = vec![ToPrimitive::to_u8(self).unwrap()]; - data.extend_from_slice(pod_bytes_of(proof)); - Instruction { - program_id: crate::zk_token_proof_program::id(), - accounts: vec![], - data, - } - } - - pub fn decode_type(program_id: &Pubkey, input: &[u8]) -> Option { - if *program_id != crate::zk_token_proof_program::id() || input.is_empty() { - None - } else { - FromPrimitive::from_u8(input[0]) - } - } - - pub fn decode_data(input: &[u8]) -> Option<&T> { - if input.is_empty() { - None - } else { - pod_from_bytes(&input[1..]) - } - } -} diff --git a/zk-token-sdk/src/zk_token_proof_program.rs b/zk-token-sdk/src/zk_token_proof_program.rs deleted file mode 100644 index 498c4cce8..000000000 --- a/zk-token-sdk/src/zk_token_proof_program.rs +++ /dev/null @@ -1,2 +0,0 @@ -// Program Id of the ZkToken Proof program -solana_program::declare_id!("ZkTokenProof1111111111111111111111111111111");