#![cfg_attr(not(feature = "std"), no_std)]
#[ink::contract]
mod crowd_funding {
use ink::storage::Mapping;
#[derive(scale::Decode, scale::Encode)]
#[cfg_attr(
feature = "std",
derive(scale_info::TypeInfo, ink::storage::traits::StorageLayout)
)]
pub struct IndividualFundMe {
account_id: AccountId,
go_fund_id: u64,
name: String,
reason_for_fund: String,
amount_needed: Balance,
amount_gotten: Balance,
status: bool,
donators: Vec<AccountId>
}
#[ink(storage)]
pub struct CrowdFunding {
go_funds: Mapping<AccountId, IndividualFundMe>,
all_go_funds: Vec<IndividualFundMe>,
successfull_go_funds: Vec<IndividualFundMe>,
go_fund_id: u64
}
impl CrowdFunding {
#[ink(constructor)]
pub fn new() -> Self {
Self {
go_funds: Mapping::new(),
all_go_funds: Vec::new(),
successfull_go_funds: Vec::new(),
go_fund_id: 1
}
}
#[ink(message)]
pub fn create_crowdfund(&mut self, _name: String, _reason_for_fund: String, _amount_needed: Balance) {
let new_gofund = IndividualFundMe {
account_id: self.env().caller(),
go_fund_id: self.go_fund_id,
name: _name.clone(),
reason_for_fund: _reason_for_fund.clone(),
amount_needed: _amount_needed,
amount_gotten: 0,
status: false,
donators: Vec::new()
};
self.go_funds.insert(self.env().caller(), &new_gofund);
self.all_go_funds.push(new_gofund);
self.go_fund_id += 1;
}
}
}
Below is the compiler error
`IndividualFundMe` doesn't implement `Debug`
the trait `Debug` is not implemented for `IndividualFundMe`
add `#[derive(Debug)]` to `IndividualFundMe` or manually `impl Debug for IndividualFundMe`
the trait `Debug` is implemented for `Vec<T, A>`