Просмотр исходного кода

daod: disabled as_any() method on UpdateBase and added note re: disabled checks

lunar-mining 3 лет назад
Родитель
Сommit
cdecb92313

+ 3 - 3
bin/daod/src/dao_contract/exec/validate.rs

@@ -189,7 +189,7 @@ impl UpdateBase for Update {
             .expect("Return type is not of type State");
             .expect("Return type is not of type State");
         state.proposal_votes.remove(&HashableBase(self.proposal)).unwrap();
         state.proposal_votes.remove(&HashableBase(self.proposal)).unwrap();
     }
     }
-    fn as_any(&self) -> &dyn Any {
-        self
-    }
+    //fn as_any(&self) -> &dyn Any {
+    //    self
+    //}
 }
 }

+ 3 - 3
bin/daod/src/dao_contract/mint/validate.rs

@@ -36,9 +36,9 @@ impl UpdateBase for Update {
         // Add dao_bulla to state.dao_bullas
         // Add dao_bulla to state.dao_bullas
         state.add_dao_bulla(self.dao_bulla);
         state.add_dao_bulla(self.dao_bulla);
     }
     }
-    fn as_any(&self) -> &dyn Any {
-        self
-    }
+    //fn as_any(&self) -> &dyn Any {
+    //    self
+    //}
 }
 }
 
 
 #[derive(Debug, Clone, thiserror::Error)]
 #[derive(Debug, Clone, thiserror::Error)]

+ 3 - 3
bin/daod/src/dao_contract/propose/validate.rs

@@ -172,7 +172,7 @@ impl UpdateBase for Update {
         let state = states.lookup_mut::<DaoState>(&"DAO".to_string()).unwrap();
         let state = states.lookup_mut::<DaoState>(&"DAO".to_string()).unwrap();
         state.add_proposal_bulla(self.proposal_bulla);
         state.add_proposal_bulla(self.proposal_bulla);
     }
     }
-    fn as_any(&self) -> &dyn Any {
-        self
-    }
+    //fn as_any(&self) -> &dyn Any {
+    //    self
+    //}
 }
 }

+ 3 - 3
bin/daod/src/dao_contract/vote/validate.rs

@@ -207,7 +207,7 @@ impl UpdateBase for Update {
         votes_info.value_commits += self.value_commit;
         votes_info.value_commits += self.value_commit;
         votes_info.vote_nulls.append(&mut self.vote_nulls);
         votes_info.vote_nulls.append(&mut self.vote_nulls);
     }
     }
-    fn as_any(&self) -> &dyn Any {
-        self
-    }
+    //fn as_any(&self) -> &dyn Any {
+    //    self
+    //}
 }
 }

+ 5 - 2
bin/daod/src/demo.rs

@@ -180,8 +180,8 @@ impl StateRegistry {
 pub trait UpdateBase {
 pub trait UpdateBase {
     fn apply(self: Box<Self>, states: &mut StateRegistry);
     fn apply(self: Box<Self>, states: &mut StateRegistry);
 
 
-    // For upcasting to Update
-    fn as_any(&self) -> &dyn Any;
+    // For upcasting to Update. Used for testing.
+    // fn as_any(&self) -> &dyn Any;
 }
 }
 
 
 ///////////////////////////////////////////////////
 ///////////////////////////////////////////////////
@@ -1044,6 +1044,9 @@ pub async fn demo() -> Result<()> {
     let mut total_value_commit = pallas::Point::identity();
     let mut total_value_commit = pallas::Point::identity();
     let mut total_vote_commit = pallas::Point::identity();
     let mut total_vote_commit = pallas::Point::identity();
 
 
+    // We were previously saving votes to a Vec<Update> for testing.
+    // However since Update is now UpdateBase it gets moved into update.apply().
+    // So we need to think of another way to run these tests.
     //assert!(updates.len() == 3);
     //assert!(updates.len() == 3);
 
 
     for (i, note /* update*/) in [vote_note_1, vote_note_2, vote_note_3]
     for (i, note /* update*/) in [vote_note_1, vote_note_2, vote_note_3]

+ 3 - 3
bin/daod/src/example_contract/foo/validate.rs

@@ -82,7 +82,7 @@ impl UpdateBase for Update {
         let example_state = states.lookup_mut::<State>(&"Example".to_string()).unwrap();
         let example_state = states.lookup_mut::<State>(&"Example".to_string()).unwrap();
         example_state.add_public_value(self.public_value);
         example_state.add_public_value(self.public_value);
     }
     }
-    fn as_any(&self) -> &dyn Any {
-        self
-    }
+    //fn as_any(&self) -> &dyn Any {
+    //    self
+    //}
 }
 }

+ 3 - 3
bin/daod/src/money_contract/transfer/validate.rs

@@ -60,9 +60,9 @@ impl UpdateBase for Update {
             state.wallet_cache.try_decrypt_note(coin, enc_note, &mut state.tree);
             state.wallet_cache.try_decrypt_note(coin, enc_note, &mut state.tree);
         }
         }
     }
     }
-    fn as_any(&self) -> &dyn Any {
-        self
-    }
+    //fn as_any(&self) -> &dyn Any {
+    //    self
+    //}
 }
 }
 
 
 pub fn state_transition(
 pub fn state_transition(