-
Notifications
You must be signed in to change notification settings - Fork 5
/
lib.rs
executable file
·57 lines (49 loc) · 1.54 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
#![cfg_attr(not(feature = "std"), no_std, no_main)]
// # ✒️ Challenge 1: Basics of ink! and setting up a DAO contract
//
// - **Difficulty**: Easy
// - **Submission Criteria:** ink! contract must
// - Have a constructor accepting a name parameter.
// - Have a storage field for the DAO name.
// - Implement the provided methods.
// - Unit test for constructor and setting DAO name.
// - Be built and deployed on Pop Network testnet.
// - **Submission Guidelines:**
// - Verify with R0GUE DevRel, and post on X.
// - **Prize:** sub0 merch
#[ink::contract]
mod dao {
use ink::prelude::string::String;
#[ink(storage)]
pub struct Dao {
value: bool,
}
impl Dao {
// Constructor that initializes the values for the contract.
#[ink(constructor)]
pub fn new(init_value: bool) -> Self {
Self { value: init_value }
}
// Constructor that initializes the default values for the contract.
#[ink(constructor)]
pub fn default() -> Self {
Self::new(Default::default())
}
#[ink(message)]
pub fn get_name(&self) -> String {
// - Returns the name of the Dao
todo!();
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::dao::Dao;
#[ink::test]
fn test_name() {
let dao = Dao::new(String::from("any name"));
assert_eq!(dao.name, dao.get_name());
assert_eq!(dao.get_name(), String::from("any name"));
}
}
}