Skip to content

Commit

Permalink
feat : Add project type (#251)
Browse files Browse the repository at this point in the history
  • Loading branch information
abhath-labs committed Dec 22, 2023
1 parent c4ecd97 commit f159cf9
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 7 deletions.
11 changes: 4 additions & 7 deletions pallets/carbon-credits/src/migration.rs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub mod v3 {
pub struct MigrateToV3<T>(sp_std::marker::PhantomData<T>);
impl<T: Config> OnRuntimeUpgrade for MigrateToV3<T> {
fn on_runtime_upgrade() -> Weight {
log::info!("V3 MIGRATION : About to execute carbon-credits migration!");
log::info!("V4 MIGRATION : About to execute carbon-credits migration!");

// convert the project type to new format
Projects::<T>::translate::<OldProjectDetail<T>, _>(
Expand All @@ -33,17 +33,14 @@ pub mod v3 {
batch_groups: old.batch_groups,
created: old.created,
updated: old.updated,
approved: match old.approved {
// modified field
true => ProjectApprovalStatus::Approved,
false => ProjectApprovalStatus::Rejected,
},
approved: old.approved,
project_type: None,
};
Some(converted_data)
},
);

log::info!("V3 MIGRATION : Carbon credits migration complete!");
log::info!("V4 MIGRATION : Carbon credits migration complete!");

T::DbWeight::get().reads_writes(1, 1)
}
Expand Down
4 changes: 4 additions & 0 deletions pallets/carbon-credits/src/types.rs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ pub struct ProjectCreateParams<T: pallet::Config> {
pub royalties: Option<RoyaltyRecipientsOf<T>>,
/// List of batch groups in the project
pub batch_groups: BatchGroupListOf<T>,
/// Type of carbon credit project
pub project_type: Option<ProjectType>,
}

/// Details of the project stored on-chain
Expand Down Expand Up @@ -119,6 +121,8 @@ pub struct ProjectDetail<T: pallet::Config> {
pub royalties: Option<RoyaltyRecipientsOf<T>>,
/// groups included in the project
pub batch_groups: BatchGroupMapOf<T>,
/// Type of carbon credit project
pub project_type: Option<ProjectType>,
// origination details
/// Creation time of project
pub created: T::BlockNumber,
Expand Down
30 changes: 30 additions & 0 deletions primitives/src/carbon_credits.rs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,33 @@ pub trait CarbonCreditsValidator {
amount: Self::Amount,
) -> DispatchResult;
}

/// Represents different types of projects related to environmental impact assessment.
pub enum ProjectType {
/// Projects related to agriculture, forestry, and other land use.
AGRICULTURE_FORESTRY_AND_OTHER_LAND_USE,
/// Projects related to the chemical industry.
CHEMICAL_INDUSTRY,
/// Projects related to energy demand.
ENERGY_DEMAND,
/// Projects related to energy distribution.
ENERGY_DISTRIBUTION,
/// Projects related to energy industries.
ENERGY_INDUSTRIES,
/// Projects related to fugitive emissions from fuels.
FUGITIVE_EMISSIONS_FROM_FUELS,
/// Projects related to fugitive emissions from carbons.
FUGITIVE_EMISSIONS_FROM_CARBONS,
/// Projects related to livestock.
LIVESTOCK,
/// Projects related to manufacturing industries.
MANUFACTURING_INDUSTRIES,
/// Projects related to metal production.
METAL_PRODUCTION,
/// Projects related to mining and mineral production.
MINING_MINERAL_PRODUCTION,
/// Projects related to transport.
TRANSPORT,
/// Projects related to waste handling.
WASTE_HANDLING,
}

0 comments on commit f159cf9

Please sign in to comment.