-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathlib.rs
executable file
·106 lines (93 loc) · 3.42 KB
/
lib.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#![cfg_attr(not(feature = "std"), no_std, no_main)]
// # ✒️ Challenge 5: Build a UI for your DAO
//
// NOTE: Using this contract to combine the functionalities of challenge 4 contract and challenge 3 contract. Compile and deploy on Pop Network then building a UI for it.
//
// - **Difficulty:** Mid
// - **Submission Criteria:** The UI must support
// - Registering & viewing members
// - Voting on and viewing proposals
// - Viewing overall proposal votes
// - **Submission Guidelines:** Verify with R0GUE or Dedot DevRel, and post on X
// - **Prize:** Sub0 merch & ink! sports towel
#[ink::contract]
mod dao {
use ink::{
contract_ref,
prelude::{string::String, vec},
storage::StorageVec,
xcm::prelude::*,
};
use minidao_common::*;
use superdao_traits::{Call, ChainCall, ContractCall, SuperDao, Vote};
#[ink(storage)]
pub struct Dao {
superdao: contract_ref!(SuperDao),
voters: StorageVec<AccountId>,
name: String,
}
impl Dao {
// Constructor that initializes the values for the contract.
#[ink(constructor)]
pub fn new(name: String, superdao: AccountId) -> Self {
// Register your Dao as a member of the Superdao.
let mut instance = Self {
name,
superdao: superdao.into(),
voters: StorageVec::new(),
};
instance
}
#[ink(message)]
pub fn get_name(&self) -> String {
// - Returns the name of the Dao
todo!()
}
#[ink(message)]
pub fn register_voter(&mut self) -> Result<(), DaoError> {
// - Error: Throw error `DaoError::VoterAlreadyRegistered` if the voter is registered
// - Success: Register a new `voter` to the Dao
Ok(())
}
#[ink(message)]
pub fn deregister_voter(&mut self) -> Result<(), DaoError> {
// - Error: Throw error `DaoError::VoterNotRegistered` if the voter is not registered
// - Success: Deregister a new `voter` from the Dao
Ok(())
}
#[ink(message)]
pub fn has_voter(&self, voter: AccountId) -> bool {
todo!();
}
#[ink(message)]
pub fn create_superdao_cross_chain_proposal(&mut self) -> Result<(), DaoError> {
// - Error: Throw error `DaoError::VoterNotRegistered` if the voter is not registered
// - Success: Create a SuperDao proposal to execute a cross-chain message.
Ok(())
}
#[ink(message)]
pub fn create_superdao_contract_call_proposal(
&mut self,
call: ContractCall,
) -> Result<(), DaoError> {
// - Error: Throw error `DaoError::VoterNotRegistered` if the voter is not registered
// - Success: Create a SuperDao proposal to call a contract method.
Ok(())
}
#[ink(message)]
pub fn vote_proposal(&mut self, proposal_id: u32, vote: bool) -> Result<(), DaoError> {
// - Error: Throw error `DaoError::VoterNotRegistered` if the voter is not registered
// - Success: Vote a SuperDao proposal.
Ok(())
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::dao::Dao;
#[ink::test]
fn test_vote_superdao_cross_chain_proposal() {
todo!("Challenge 4");
}
}
}