Skip to content

Commit

Permalink
implem get_project_carbon
Browse files Browse the repository at this point in the history
  • Loading branch information
tekkac committed Jan 30, 2025
1 parent 3e86734 commit 3690dc8
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/components/vintage/vintage.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,22 @@ pub mod VintageComponent {
+IAccessControl<TContractState>
> of IVintage<ComponentState<TContractState>> {
fn get_project_carbon(self: @ComponentState<TContractState>) -> u256 {
self.Vintage_project_carbon.read()
let mut project_supply: u256 = 0;
let num_vintage = self.Vintage_vintages_len.read();
let mut index = 0;
loop {
if index >= num_vintage {
break ();
}
let token_id = (index + 1).into();
let vintage_supply = self.get_carbon_vintage(token_id).supply;
project_supply += vintage_supply;
index += 1;
};
project_supply
}


fn get_num_vintages(self: @ComponentState<TContractState>) -> usize {
self.Vintage_vintages_len.read()
}
Expand Down

0 comments on commit 3690dc8

Please sign in to comment.