Преглед изворни кода

contract/dao: Prefix structs with Dao namespace.

parazyd пре 3 година
родитељ
комит
2cbc0264ac

+ 9 - 9
src/contract/dao/src/dao_client/exec.rs

@@ -1,6 +1,6 @@
 /* This file is part of DarkFi (https://dark.fi)
  *
- * Copyright (C) 2020-2022 Dyne.org foundation
+ * Copyright (C) 2020-2023 Dyne.org foundation
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Affero General Public License as
@@ -30,11 +30,11 @@ use darkfi::{
     Result,
 };
 
-use super::{DaoInfo, ProposalInfo};
-use crate::dao_model::{BlindAggregateVote, ExecCallParams};
+use super::{DaoInfo, DaoProposalInfo};
+use crate::dao_model::{DaoBlindAggregateVote, DaoExecParams};
 
-pub struct ExecCall {
-    pub proposal: ProposalInfo,
+pub struct DaoExecCall {
+    pub proposal: DaoProposalInfo,
     pub dao: DaoInfo,
     pub yes_vote_value: u64,
     pub all_vote_value: u64,
@@ -50,12 +50,12 @@ pub struct ExecCall {
     pub signature_secret: SecretKey,
 }
 
-impl ExecCall {
+impl DaoExecCall {
     pub fn make(
         self,
         exec_zkbin: &ZkBinary,
         exec_pk: &ProvingKey,
-    ) -> Result<(ExecCallParams, Vec<Proof>)> {
+    ) -> Result<(DaoExecParams, Vec<Proof>)> {
         debug!(target: "dao", "build()");
         let mut proofs = vec![];
 
@@ -185,11 +185,11 @@ impl ExecCall {
             .expect("DAO::exec() proving error!)");
         proofs.push(input_proof);
 
-        let params = ExecCallParams {
+        let params = DaoExecParams {
             proposal: proposal_bulla,
             coin_0,
             coin_1,
-            blind_total_vote: BlindAggregateVote { yes_vote_commit, all_vote_commit },
+            blind_total_vote: DaoBlindAggregateVote { yes_vote_commit, all_vote_commit },
             input_value_commit,
         };
 

+ 3 - 3
src/contract/dao/src/dao_client/mint.rs

@@ -25,7 +25,7 @@ use darkfi_sdk::crypto::{pallas, poseidon_hash, PublicKey, TokenId};
 use log::debug;
 use rand::rngs::OsRng;
 
-use crate::dao_model::MintCallParams;
+use crate::dao_model::DaoMintParams;
 
 #[derive(Clone)]
 pub struct DaoInfo {
@@ -42,7 +42,7 @@ pub fn make_mint_call(
     dao: &DaoInfo,
     dao_mint_zkbin: &ZkBinary,
     dao_mint_pk: &ProvingKey,
-) -> Result<(MintCallParams, Vec<Proof>)> {
+) -> Result<(DaoMintParams, Vec<Proof>)> {
     debug!(target: "dao", "Building DAO contract mint transaction");
 
     let dao_proposer_limit = pallas::Base::from(dao.proposer_limit);
@@ -80,7 +80,7 @@ pub fn make_mint_call(
     let circuit = ZkCircuit::new(prover_witnesses, dao_mint_zkbin.clone());
     let proof = Proof::create(dao_mint_pk, &[circuit], &public, &mut OsRng)?;
 
-    let dao_mint_params = MintCallParams { dao_bulla: dao_bulla.into() };
+    let dao_mint_params = DaoMintParams { dao_bulla: dao_bulla.into() };
 
     Ok((dao_mint_params, vec![proof]))
 }

+ 29 - 11
src/contract/dao/src/dao_client/mod.rs

@@ -1,26 +1,44 @@
+/* This file is part of DarkFi (https://dark.fi)
+ *
+ * Copyright (C) 2020-2023 Dyne.org foundation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+
 pub mod mint;
 pub use mint::{make_mint_call, DaoInfo};
 
 /// Provides core structs for DAO::propose()
 ///
-/// * `ProposalInfo` is the main info about the proposal.
-/// * `ProposeStakeInput` are the staking inputs used to meet the `proposer_limit` threshold.
-/// * `ProposeCall` is what creates the call data used on chain.
-/// * `ProposeNote` is the secret shared info transmitted between DAO members.
+/// * `DaoProposalInfo` is the main info about the proposal.
+/// * `DaoProposeStakeInput` are the staking inputs used to meet the `proposer_limit` threshold.
+/// * `DaoProposeCall` is what creates the call data used on chain.
+/// * `DaoProposeNote` is the secret shared info transmitted between DAO members.
 pub mod propose;
-pub use propose::{ProposalInfo, ProposeCall, ProposeNote, ProposeStakeInput};
+pub use propose::{DaoProposalInfo, DaoProposeCall, DaoProposeNote, DaoProposeStakeInput};
 
 /// Provides core structs for DAO::vote()
 ///
-/// * `VoteInfo` is the main info about the vote.
-/// * `VoteStakeInput` are the staking inputs used in actual voting.
-/// * `VoteCall` is what creates the call data used on chain.
-/// * `VoteNote` is the secret shared info transmitted between DAO members.
+/// * `DaoVoteInfo` is the main info about the vote.
+/// * `DaoVoteStakeInput` are the staking inputs used in actual voting.
+/// * `DaoVoteCall` is what creates the call data used on chain.
+/// * `DaoVoteNote` is the secret shared info transmitted between DAO members.
 pub mod vote;
-pub use vote::{VoteCall, VoteInput, VoteNote};
+pub use vote::{DaoVoteCall, DaoVoteInput, DaoVoteNote};
 
 pub mod exec;
-pub use exec::ExecCall;
+pub use exec::DaoExecCall;
 
 // Wallet SQL table constant names. These have to represent the SQL schema.
 pub const DAO_DAOS_TABLE: &str = "dao_daos";

+ 14 - 14
src/contract/dao/src/dao_client/propose.rs

@@ -1,6 +1,6 @@
 /* This file is part of DarkFi (https://dark.fi)
  *
- * Copyright (C) 2020-2022 Dyne.org foundation
+ * Copyright (C) 2020-2023 Dyne.org foundation
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Affero General Public License as
@@ -30,14 +30,14 @@ use darkfi::{
 };
 
 use crate::{
-    dao_model::{ProposeCallParams, ProposeCallParamsInput},
+    dao_model::{DaoProposeParams, DaoProposeParamsInput},
     note,
 };
 
 use super::DaoInfo;
 
 #[derive(SerialEncodable, SerialDecodable, Clone)]
-pub struct ProposalInfo {
+pub struct DaoProposalInfo {
     pub dest: PublicKey,
     pub amount: u64,
     pub serial: pallas::Base,
@@ -46,11 +46,11 @@ pub struct ProposalInfo {
 }
 
 #[derive(SerialEncodable, SerialDecodable)]
-pub struct ProposeNote {
-    pub proposal: ProposalInfo,
+pub struct DaoProposeNote {
+    pub proposal: DaoProposalInfo,
 }
 
-pub struct ProposeStakeInput {
+pub struct DaoProposeStakeInput {
     pub secret: SecretKey,
     //pub note: money::transfer::wallet::Note,
     pub note: darkfi_money_contract::client::Note,
@@ -59,23 +59,23 @@ pub struct ProposeStakeInput {
     pub signature_secret: SecretKey,
 }
 
-pub struct ProposeCall {
-    pub inputs: Vec<ProposeStakeInput>,
-    pub proposal: ProposalInfo,
+pub struct DaoProposeCall {
+    pub inputs: Vec<DaoProposeStakeInput>,
+    pub proposal: DaoProposalInfo,
     pub dao: DaoInfo,
     pub dao_leaf_position: MerklePosition,
     pub dao_merkle_path: Vec<MerkleNode>,
     pub dao_merkle_root: MerkleNode,
 }
 
-impl ProposeCall {
+impl DaoProposeCall {
     pub fn make(
         self,
         burn_zkbin: &ZkBinary,
         burn_pk: &ProvingKey,
         main_zkbin: &ZkBinary,
         main_pk: &ProvingKey,
-    ) -> Result<(ProposeCallParams, Vec<Proof>)> {
+    ) -> Result<(DaoProposeParams, Vec<Proof>)> {
         let mut proofs = vec![];
 
         let gov_token_blind = pallas::Base::random(&mut OsRng);
@@ -163,7 +163,7 @@ impl ProposeCall {
                 .expect("DAO::propose() proving error!");
             proofs.push(input_proof);
 
-            let input = ProposeCallParamsInput { value_commit, merkle_root, signature_public };
+            let input = DaoProposeParamsInput { value_commit, merkle_root, signature_public };
             inputs.push(input);
         }
 
@@ -247,9 +247,9 @@ impl ProposeCall {
             .expect("DAO::propose() proving error!");
         proofs.push(main_proof);
 
-        let note = ProposeNote { proposal: self.proposal };
+        let note = DaoProposeNote { proposal: self.proposal };
         let enc_note = note::encrypt(&note, &self.dao.public_key).unwrap();
-        let params = ProposeCallParams {
+        let params = DaoProposeParams {
             dao_merkle_root: self.dao_merkle_root,
             proposal_bulla,
             token_commit,

+ 13 - 13
src/contract/dao/src/dao_client/vote.rs

@@ -1,6 +1,6 @@
 /* This file is part of DarkFi (https://dark.fi)
  *
- * Copyright (C) 2020-2022 Dyne.org foundation
+ * Copyright (C) 2020-2023 Dyne.org foundation
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Affero General Public License as
@@ -30,14 +30,14 @@ use darkfi::{
     Result,
 };
 
-use super::{DaoInfo, ProposalInfo};
+use super::{DaoInfo, DaoProposalInfo};
 use crate::{
-    dao_model::{VoteCallParams, VoteCallParamsInput},
+    dao_model::{DaoVoteParams, DaoVoteParamsInput},
     note,
 };
 
 #[derive(SerialEncodable, SerialDecodable)]
-pub struct VoteNote {
+pub struct DaoVoteNote {
     pub vote_option: bool,
     pub yes_vote_blind: pallas::Scalar,
     // yes_vote_value = vote_option * all_vote_value
@@ -45,7 +45,7 @@ pub struct VoteNote {
     pub all_vote_blind: pallas::Scalar,
 }
 
-pub struct VoteInput {
+pub struct DaoVoteInput {
     pub secret: SecretKey,
     //pub note: money::transfer::wallet::Note,
     pub note: darkfi_money_contract::client::Note,
@@ -56,23 +56,23 @@ pub struct VoteInput {
 
 // TODO: should be token locking voting?
 // Inside ZKproof, check proposal is correct.
-pub struct VoteCall {
-    pub inputs: Vec<VoteInput>,
+pub struct DaoVoteCall {
+    pub inputs: Vec<DaoVoteInput>,
     pub vote_option: bool,
     pub yes_vote_blind: pallas::Scalar,
     pub vote_keypair: Keypair,
-    pub proposal: ProposalInfo,
+    pub proposal: DaoProposalInfo,
     pub dao: DaoInfo,
 }
 
-impl VoteCall {
+impl DaoVoteCall {
     pub fn make(
         self,
         burn_zkbin: &ZkBinary,
         burn_pk: &ProvingKey,
         main_zkbin: &ZkBinary,
         main_pk: &ProvingKey,
-    ) -> Result<(VoteCallParams, Vec<Proof>)> {
+    ) -> Result<(DaoVoteParams, Vec<Proof>)> {
         debug!(target: "dao", "build()");
         let mut proofs = vec![];
 
@@ -165,7 +165,7 @@ impl VoteCall {
                 .expect("DAO::vote() proving error!");
             proofs.push(input_proof);
 
-            let input = VoteCallParamsInput {
+            let input = DaoVoteParamsInput {
                 nullifier: Nullifier::from(nullifier),
                 vote_commit,
                 merkle_root,
@@ -264,7 +264,7 @@ impl VoteCall {
             .expect("DAO::vote() proving error!");
         proofs.push(main_proof);
 
-        let note = VoteNote {
+        let note = DaoVoteNote {
             vote_option: self.vote_option,
             yes_vote_blind: self.yes_vote_blind,
             all_vote_value,
@@ -272,7 +272,7 @@ impl VoteCall {
         };
         let enc_note = note::encrypt(&note, &self.vote_keypair.public).unwrap();
 
-        let params = VoteCallParams {
+        let params = DaoVoteParams {
             token_commit,
             proposal_bulla,
             yes_vote_commit,

+ 18 - 26
src/contract/dao/src/dao_model.rs

@@ -34,56 +34,50 @@ impl From<pallas::Base> for DaoBulla {
     }
 }
 
-// DAO::mint()
-
 #[derive(SerialEncodable, SerialDecodable)]
-pub struct MintCallParams {
+pub struct DaoMintParams {
     pub dao_bulla: DaoBulla,
 }
 
 #[derive(SerialEncodable, SerialDecodable)]
-pub struct MintCallUpdate {
+pub struct DaoMintUpdate {
     pub dao_bulla: DaoBulla,
 }
 
-// DAO::propose()
-
 #[derive(SerialEncodable, SerialDecodable)]
-pub struct ProposeCallParams {
+pub struct DaoProposeParams {
     pub dao_merkle_root: MerkleNode,
     pub token_commit: pallas::Base,
     pub proposal_bulla: pallas::Base,
     pub ciphertext: Vec<u8>,
     pub ephem_public: PublicKey,
-    pub inputs: Vec<ProposeCallParamsInput>,
+    pub inputs: Vec<DaoProposeParamsInput>,
 }
 
 #[derive(Clone, SerialEncodable, SerialDecodable)]
-pub struct ProposeCallParamsInput {
+pub struct DaoProposeParamsInput {
     pub value_commit: pallas::Point,
     pub merkle_root: MerkleNode,
     pub signature_public: PublicKey,
 }
 
 #[derive(SerialEncodable, SerialDecodable)]
-pub struct ProposeCallUpdate {
+pub struct DaoProposeUpdate {
     pub proposal_bulla: pallas::Base,
 }
 
-// DAO::vote()
-
 #[derive(SerialEncodable, SerialDecodable)]
-pub struct VoteCallParams {
+pub struct DaoVoteParams {
     pub token_commit: pallas::Base,
     pub proposal_bulla: pallas::Base,
     pub yes_vote_commit: pallas::Point,
     pub ciphertext: Vec<u8>,
     pub ephem_public: PublicKey,
-    pub inputs: Vec<VoteCallParamsInput>,
+    pub inputs: Vec<DaoVoteParamsInput>,
 }
 
 #[derive(SerialEncodable, SerialDecodable)]
-pub struct VoteCallParamsInput {
+pub struct DaoVoteParamsInput {
     pub nullifier: Nullifier,
     pub vote_commit: pallas::Point,
     pub merkle_root: MerkleNode,
@@ -91,29 +85,29 @@ pub struct VoteCallParamsInput {
 }
 
 #[derive(SerialEncodable, SerialDecodable)]
-pub struct VoteCallUpdate {
+pub struct DaoVoteUpdate {
     pub proposal_bulla: pallas::Base,
-    pub proposal_votes: BlindAggregateVote,
+    pub proposal_votes: DaoBlindAggregateVote,
     pub vote_nullifiers: Vec<Nullifier>,
 }
 
 /// Represents a single or multiple blinded votes. These can be summed together.
 #[derive(SerialEncodable, SerialDecodable)]
-pub struct BlindAggregateVote {
+pub struct DaoBlindAggregateVote {
     /// Weighted vote commit
     pub yes_vote_commit: pallas::Point,
     /// All value staked in the vote
     pub all_vote_commit: pallas::Point,
 }
 
-impl BlindAggregateVote {
-    pub fn aggregate(&mut self, other: BlindAggregateVote) {
+impl DaoBlindAggregateVote {
+    pub fn aggregate(&mut self, other: Self) {
         self.yes_vote_commit += other.yes_vote_commit;
         self.all_vote_commit += other.all_vote_commit;
     }
 }
 
-impl Default for BlindAggregateVote {
+impl Default for DaoBlindAggregateVote {
     fn default() -> Self {
         Self {
             yes_vote_commit: pallas::Point::identity(),
@@ -122,18 +116,16 @@ impl Default for BlindAggregateVote {
     }
 }
 
-// DAO::exec()
-
 #[derive(SerialEncodable, SerialDecodable)]
-pub struct ExecCallParams {
+pub struct DaoExecParams {
     pub proposal: pallas::Base,
     pub coin_0: pallas::Base,
     pub coin_1: pallas::Base,
-    pub blind_total_vote: BlindAggregateVote,
+    pub blind_total_vote: DaoBlindAggregateVote,
     pub input_value_commit: pallas::Point,
 }
 
 #[derive(SerialEncodable, SerialDecodable)]
-pub struct ExecCallUpdate {
+pub struct DaoExecUpdate {
     pub proposal: pallas::Base,
 }

+ 21 - 21
src/contract/dao/src/entrypoint.rs

@@ -38,8 +38,8 @@ use darkfi_money_contract::{
 
 use crate::{
     dao_model::{
-        BlindAggregateVote, ExecCallParams, ExecCallUpdate, MintCallParams, MintCallUpdate,
-        ProposeCallParams, ProposeCallUpdate, VoteCallParams, VoteCallUpdate,
+        DaoBlindAggregateVote, DaoExecParams, DaoExecUpdate, DaoMintParams, DaoMintUpdate,
+        DaoProposeParams, DaoProposeUpdate, DaoVoteParams, DaoVoteUpdate,
     },
     DaoFunction, DAO_CONTRACT_ZKAS_DAO_EXEC_NS, DAO_CONTRACT_ZKAS_DAO_MINT_NS,
     DAO_CONTRACT_ZKAS_DAO_PROPOSE_BURN_NS, DAO_CONTRACT_ZKAS_DAO_PROPOSE_MAIN_NS,
@@ -166,7 +166,7 @@ fn process_instruction(cid: ContractId, ix: &[u8]) -> ContractResult {
 
     match func {
         DaoFunction::Mint => {
-            let params: MintCallParams = deserialize(&self_.data[1..])?;
+            let params: DaoMintParams = deserialize(&self_.data[1..])?;
             let dao_bulla = params.dao_bulla.inner();
 
             // Check the DAO bulla doesn't already exist
@@ -176,7 +176,7 @@ fn process_instruction(cid: ContractId, ix: &[u8]) -> ContractResult {
                 return Err(ContractError::Custom(1))
             }
 
-            let update = MintCallUpdate { dao_bulla: params.dao_bulla };
+            let update = DaoMintUpdate { dao_bulla: params.dao_bulla };
             let mut update_data = vec![];
             update_data.write_u8(DaoFunction::Mint as u8)?;
             update.encode(&mut update_data)?;
@@ -187,7 +187,7 @@ fn process_instruction(cid: ContractId, ix: &[u8]) -> ContractResult {
         }
 
         DaoFunction::Propose => {
-            let params: ProposeCallParams = deserialize(&self_.data[1..])?;
+            let params: DaoProposeParams = deserialize(&self_.data[1..])?;
 
             // Check the Merkle roots for the input coins are valid
             let money_cid = *MONEY_CONTRACT_ID;
@@ -214,7 +214,7 @@ fn process_instruction(cid: ContractId, ix: &[u8]) -> ContractResult {
                 return Err(ContractError::Custom(4))
             }
 
-            let update = ProposeCallUpdate { proposal_bulla: params.proposal_bulla };
+            let update = DaoProposeUpdate { proposal_bulla: params.proposal_bulla };
             let mut update_data = vec![];
             update_data.write_u8(DaoFunction::Propose as u8)?;
             update.encode(&mut update_data)?;
@@ -225,7 +225,7 @@ fn process_instruction(cid: ContractId, ix: &[u8]) -> ContractResult {
         }
 
         DaoFunction::Vote => {
-            let params: VoteCallParams = deserialize(&self_.data[1..])?;
+            let params: DaoVoteParams = deserialize(&self_.data[1..])?;
 
             let money_cid = *MONEY_CONTRACT_ID;
 
@@ -235,7 +235,7 @@ fn process_instruction(cid: ContractId, ix: &[u8]) -> ContractResult {
                 msg!("Invalid proposal {:?}", params.proposal_bulla);
                 return Err(ContractError::Custom(4))
             };
-            let mut proposal_votes: BlindAggregateVote = deserialize(&proposal_votes)?;
+            let mut proposal_votes: DaoBlindAggregateVote = deserialize(&proposal_votes)?;
 
             // Check the Merkle roots and nullifiers for the input coins are valid
             let money_roots_db = db_lookup(money_cid, MONEY_CONTRACT_COIN_ROOTS_TREE)?;
@@ -272,7 +272,7 @@ fn process_instruction(cid: ContractId, ix: &[u8]) -> ContractResult {
 
             proposal_votes.yes_vote_commit += params.yes_vote_commit;
 
-            let update = VoteCallUpdate {
+            let update = DaoVoteUpdate {
                 proposal_bulla: params.proposal_bulla,
                 proposal_votes,
                 vote_nullifiers,
@@ -287,7 +287,7 @@ fn process_instruction(cid: ContractId, ix: &[u8]) -> ContractResult {
         }
 
         DaoFunction::Exec => {
-            let params: ExecCallParams = deserialize(&self_.data[1..])?;
+            let params: DaoExecParams = deserialize(&self_.data[1..])?;
 
             // =============================
             // Enforce tx has correct format
@@ -326,13 +326,13 @@ fn process_instruction(cid: ContractId, ix: &[u8]) -> ContractResult {
                 msg!("Proposal {:?} not found in db", params.proposal);
                 return Err(ContractError::Custom(1));
             };
-            let proposal_votes: BlindAggregateVote = deserialize(&proposal_votes)?;
+            let proposal_votes: DaoBlindAggregateVote = deserialize(&proposal_votes)?;
 
             // 4. Check yes_vote_commit and all_vote_commit are the same as in BlindAggregateVote
             assert!(proposal_votes.yes_vote_commit == params.blind_total_vote.yes_vote_commit);
             assert!(proposal_votes.all_vote_commit == params.blind_total_vote.all_vote_commit);
 
-            let update = ExecCallUpdate { proposal: params.proposal };
+            let update = DaoExecUpdate { proposal: params.proposal };
             let mut update_data = vec![];
             update_data.write_u8(DaoFunction::Exec as u8)?;
             update.encode(&mut update_data)?;
@@ -347,7 +347,7 @@ fn process_instruction(cid: ContractId, ix: &[u8]) -> ContractResult {
 fn process_update(cid: ContractId, ix: &[u8]) -> ContractResult {
     match DaoFunction::try_from(ix[0])? {
         DaoFunction::Mint => {
-            let update: MintCallUpdate = deserialize(&ix[1..])?;
+            let update: DaoMintUpdate = deserialize(&ix[1..])?;
             let dao_bulla = update.dao_bulla.inner();
 
             let info_db = db_lookup(cid, DB_INFO)?;
@@ -363,10 +363,10 @@ fn process_update(cid: ContractId, ix: &[u8]) -> ContractResult {
         }
 
         DaoFunction::Propose => {
-            let update: ProposeCallUpdate = deserialize(&ix[1..])?;
+            let update: DaoProposeUpdate = deserialize(&ix[1..])?;
 
             let proposal_vote_db = db_lookup(cid, DB_PROPOSAL_BULLAS)?;
-            let pv = BlindAggregateVote::default();
+            let pv = DaoBlindAggregateVote::default();
 
             db_set(proposal_vote_db, &serialize(&update.proposal_bulla), &serialize(&pv))?;
 
@@ -374,7 +374,7 @@ fn process_update(cid: ContractId, ix: &[u8]) -> ContractResult {
         }
 
         DaoFunction::Vote => {
-            let update: VoteCallUpdate = deserialize(&ix[1..])?;
+            let update: DaoVoteUpdate = deserialize(&ix[1..])?;
 
             // Perform this code:
             //   total_yes_vote_commit += update.yes_vote_commit
@@ -401,7 +401,7 @@ fn process_update(cid: ContractId, ix: &[u8]) -> ContractResult {
         }
 
         DaoFunction::Exec => {
-            let update: ExecCallUpdate = deserialize(&ix[1..])?;
+            let update: DaoExecUpdate = deserialize(&ix[1..])?;
 
             // Remove proposal from db
             let proposal_vote_db = db_lookup(cid, DB_PROPOSAL_BULLAS)?;
@@ -420,7 +420,7 @@ fn get_metadata(_: ContractId, ix: &[u8]) -> ContractResult {
 
     match DaoFunction::try_from(self_.data[0])? {
         DaoFunction::Mint => {
-            let params: MintCallParams = deserialize(&self_.data[1..])?;
+            let params: DaoMintParams = deserialize(&self_.data[1..])?;
 
             let mut zk_public_values: Vec<(String, Vec<pallas::Base>)> = vec![];
             // TODO: Why no signatures? Should it be signed with the DAO keypair?
@@ -439,7 +439,7 @@ fn get_metadata(_: ContractId, ix: &[u8]) -> ContractResult {
         }
 
         DaoFunction::Propose => {
-            let params: ProposeCallParams = deserialize(&self_.data[1..])?;
+            let params: DaoProposeParams = deserialize(&self_.data[1..])?;
             assert!(!params.inputs.is_empty());
 
             let mut zk_public_values: Vec<(String, Vec<pallas::Base>)> = vec![];
@@ -489,7 +489,7 @@ fn get_metadata(_: ContractId, ix: &[u8]) -> ContractResult {
         }
 
         DaoFunction::Vote => {
-            let params: VoteCallParams = deserialize(&self_.data[1..])?;
+            let params: DaoVoteParams = deserialize(&self_.data[1..])?;
             assert!(!params.inputs.is_empty());
 
             let mut zk_public_values: Vec<(String, Vec<pallas::Base>)> = vec![];
@@ -543,7 +543,7 @@ fn get_metadata(_: ContractId, ix: &[u8]) -> ContractResult {
         }
 
         DaoFunction::Exec => {
-            let params: ExecCallParams = deserialize(&self_.data[1..])?;
+            let params: DaoExecParams = deserialize(&self_.data[1..])?;
 
             let mut zk_public_values: Vec<(String, Vec<pallas::Base>)> = vec![];
             let signature_pubkeys: Vec<PublicKey> = vec![];

+ 1 - 1
src/contract/dao/src/money_client.rs

@@ -1,6 +1,6 @@
 /* This file is part of DarkFi (https://dark.fi)
  *
- * Copyright (C) 2020-2022 Dyne.org foundation
+ * Copyright (C) 2020-2023 Dyne.org foundation
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Affero General Public License as

+ 1 - 1
src/contract/dao/tests/harness.rs

@@ -1,6 +1,6 @@
 /* This file is part of DarkFi (https://dark.fi)
  *
- * Copyright (C) 2020-2022 Dyne.org foundation
+ * Copyright (C) 2020-2023 Dyne.org foundation
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Affero General Public License as

+ 16 - 16
src/contract/dao/tests/integration.rs

@@ -374,7 +374,7 @@ async fn integration_test() -> Result<()> {
     // TODO: is it possible for an invalid transfer() to be constructed on exec()?
     //       need to look into this
     let signature_secret = SecretKey::random(&mut OsRng);
-    let input = dao_client::ProposeStakeInput {
+    let input = dao_client::DaoProposeStakeInput {
         secret: dao_th.alice_kp.secret,
         note: gov_recv[0].note.clone(),
         leaf_position: money_leaf_position,
@@ -389,7 +389,7 @@ async fn integration_test() -> Result<()> {
         (merkle_path, root)
     };
 
-    let proposal = dao_client::ProposalInfo {
+    let proposal = dao_client::DaoProposalInfo {
         dest: receiver_keypair.public,
         amount: 1000,
         serial: pallas::Base::random(&mut OsRng),
@@ -397,7 +397,7 @@ async fn integration_test() -> Result<()> {
         blind: pallas::Base::random(&mut OsRng),
     };
 
-    let call = dao_client::ProposeCall {
+    let call = dao_client::DaoProposeCall {
         inputs: vec![input],
         proposal,
         dao: dao.clone(),
@@ -433,7 +433,7 @@ async fn integration_test() -> Result<()> {
             ciphertext: params.ciphertext,
             ephem_public: params.ephem_public,
         };
-        let note: dao_client::ProposeNote = enc_note.decrypt(&dao_th.dao_kp.secret).unwrap();
+        let note: dao_client::DaoProposeNote = enc_note.decrypt(&dao_th.dao_kp.secret).unwrap();
 
         // TODO: check it belongs to DAO bulla
 
@@ -487,7 +487,7 @@ async fn integration_test() -> Result<()> {
     };
 
     let signature_secret = SecretKey::random(&mut OsRng);
-    let input = dao_client::VoteInput {
+    let input = dao_client::DaoVoteInput {
         secret: dao_th.alice_kp.secret,
         note: gov_recv[0].note.clone(),
         leaf_position: money_leaf_position,
@@ -502,7 +502,7 @@ async fn integration_test() -> Result<()> {
     // For the demo MVP, you can just use the dao_keypair secret
     let vote_keypair_1 = Keypair::random(&mut OsRng);
 
-    let call = dao_client::VoteCall {
+    let call = dao_client::DaoVoteCall {
         inputs: vec![input],
         vote_option,
         yes_vote_blind: pallas::Scalar::random(&mut OsRng),
@@ -537,7 +537,7 @@ async fn integration_test() -> Result<()> {
             ciphertext: params.ciphertext,
             ephem_public: params.ephem_public,
         };
-        let note: dao_client::VoteNote = enc_note.decrypt(&vote_keypair_1.secret).unwrap();
+        let note: dao_client::DaoVoteNote = enc_note.decrypt(&vote_keypair_1.secret).unwrap();
         note
     };
     debug!(target: "dao", "User 1 voted!");
@@ -555,7 +555,7 @@ async fn integration_test() -> Result<()> {
     };
 
     let signature_secret = SecretKey::random(&mut OsRng);
-    let input = dao_client::VoteInput {
+    let input = dao_client::DaoVoteInput {
         //secret: gov_keypair_2.secret,
         secret: dao_th.bob_kp.secret,
         note: gov_recv[1].note.clone(),
@@ -570,7 +570,7 @@ async fn integration_test() -> Result<()> {
     // We create a new keypair to encrypt the vote.
     let vote_keypair_2 = Keypair::random(&mut OsRng);
 
-    let call = dao_client::VoteCall {
+    let call = dao_client::DaoVoteCall {
         inputs: vec![input],
         vote_option,
         yes_vote_blind: pallas::Scalar::random(&mut OsRng),
@@ -602,7 +602,7 @@ async fn integration_test() -> Result<()> {
             ciphertext: params.ciphertext,
             ephem_public: params.ephem_public,
         };
-        let note: dao_client::VoteNote = enc_note.decrypt(&vote_keypair_2.secret).unwrap();
+        let note: dao_client::DaoVoteNote = enc_note.decrypt(&vote_keypair_2.secret).unwrap();
         note
     };
     debug!(target: "dao", "User 2 voted!");
@@ -620,7 +620,7 @@ async fn integration_test() -> Result<()> {
     };
 
     let signature_secret = SecretKey::random(&mut OsRng);
-    let input = dao_client::VoteInput {
+    let input = dao_client::DaoVoteInput {
         //secret: gov_keypair_3.secret,
         secret: dao_th.charlie_kp.secret,
         note: gov_recv[2].note.clone(),
@@ -635,7 +635,7 @@ async fn integration_test() -> Result<()> {
     // We create a new keypair to encrypt the vote.
     let vote_keypair_3 = Keypair::random(&mut OsRng);
 
-    let call = dao_client::VoteCall {
+    let call = dao_client::DaoVoteCall {
         inputs: vec![input],
         vote_option,
         yes_vote_blind: pallas::Scalar::random(&mut OsRng),
@@ -670,7 +670,7 @@ async fn integration_test() -> Result<()> {
             ciphertext: params.ciphertext,
             ephem_public: params.ephem_public,
         };
-        let note: dao_client::VoteNote = enc_note.decrypt(&vote_keypair_3.secret).unwrap();
+        let note: dao_client::DaoVoteNote = enc_note.decrypt(&vote_keypair_3.secret).unwrap();
         note
     };
     debug!(target: "dao", "User 3 voted!");
@@ -689,7 +689,7 @@ async fn integration_test() -> Result<()> {
     let mut total_yes_vote_value = 0;
     let mut total_all_vote_value = 0;
 
-    let mut blind_total_vote = dao_model::BlindAggregateVote::default();
+    let mut blind_total_vote = dao_model::DaoBlindAggregateVote::default();
 
     // Just keep track of these for the assert statements after the for loop
     // but they aren't needed otherwise.
@@ -712,7 +712,7 @@ async fn integration_test() -> Result<()> {
         let yes_vote_commit = pedersen_commitment_u64(yes_vote_value, note.yes_vote_blind);
         let all_vote_commit = pedersen_commitment_u64(note.all_vote_value, note.all_vote_blind);
 
-        let blind_vote = dao_model::BlindAggregateVote { yes_vote_commit, all_vote_commit };
+        let blind_vote = dao_model::DaoBlindAggregateVote { yes_vote_commit, all_vote_commit };
         blind_total_vote.aggregate(blind_vote);
 
         // Just for the debug
@@ -820,7 +820,7 @@ async fn integration_test() -> Result<()> {
     xfer_params.encode(&mut data)?;
     let xfer_call = ContractCall { contract_id: *MONEY_CONTRACT_ID, data };
 
-    let call = dao_client::ExecCall {
+    let call = dao_client::DaoExecCall {
         proposal,
         dao,
         yes_vote_value: total_yes_vote_value,