Skip to content

Commit

Permalink
🚨 fix Scarb linting
Browse files Browse the repository at this point in the history
  • Loading branch information
tekkac committed Jul 21, 2024
1 parent 7333689 commit fe39713
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/interfaces/vintage.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use metadata::metadata::vintages::models::CarbonVintage;
trait IVintage<TContractState> {
/// Returns the vintage start and end years.
fn get_vintage_range(self: @TContractState) -> (u32, u32);

/// Returns the project total carbon credits.
fn get_project_carbon(self: @TContractState) -> u128;

Expand Down
2 changes: 1 addition & 1 deletion src/metadata/vintages/models.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ struct CPV3TemplateData {
sdg_count: String,
// Components data
background_image: String,
status_component: String,
status_component: String,
border_component: String,
}

Expand Down
8 changes: 1 addition & 7 deletions src/metadata/vintages/template/storage.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ fn fetch_data(contract_address: ContractAddress, token_id: u256) -> CPV3StorageD
};

CPV3StorageData {
component_provider,
project_carbon,
token_id,
vintage,
timestamp,
start_year,
end_year,
component_provider, project_carbon, token_id, vintage, timestamp, start_year, end_year,
}
}
21 changes: 10 additions & 11 deletions src/tests/mocks/cpv3_project.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -66,45 +66,44 @@ mod CPV3ProjectMock {
fn get_vintage_range(self: @ContractState) -> (u32, u32) {
(2023, 2025)
}

fn get_project_carbon(self: @ContractState) -> u128 {
3133700000000
}

/// Returns the number of vintages of the project.
fn get_num_vintages(self: @ContractState) -> usize {
3
}

/// Returns all available vintage details.
fn get_cc_vintages(self: @ContractState) -> Span<CarbonVintage> {
array![
CarbonVintage {
year: 2023,
supply : 133700000000,
failed: 0,
status: CarbonVintageType::Audited,
year: 2023, supply: 133700000000, failed: 0, status: CarbonVintageType::Audited,
},
CarbonVintage {
year: 2024,
supply : 1000000000000,
supply: 1000000000000,
failed: 0,
status: CarbonVintageType::Projected,
},
CarbonVintage {
year: 2025,
supply : 2000000000000,
supply: 2000000000000,
failed: 0,
status: CarbonVintageType::Projected,
}
].span()
]
.span()
}

/// Returns the vintage details with the given token_id.
fn get_carbon_vintage(self: @ContractState, token_id: u256) -> CarbonVintage {
let v = self.get_cc_vintages();
*v[token_id.try_into().unwrap()]
}

/// Get number of decimal for total supply to have a carbon credit
fn get_cc_decimals(self: @ContractState) -> u8 {
8
Expand Down
4 changes: 3 additions & 1 deletion src/tests/test_cpv3_metadata.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ use test::test_utils::assert_eq;

use metadata::metadata::vintages::banegas_farm::contract::BanegasCPV3Uri;
use metadata::tests::mocks::cpv3_project::CPV3ProjectMock;
use metadata::interfaces::slot_descriptor::{IUriDescriptorLibraryDispatcher, IUriDescriptorDispatcherTrait};
use metadata::interfaces::slot_descriptor::{
IUriDescriptorLibraryDispatcher, IUriDescriptorDispatcherTrait
};
use metadata::interfaces::component_provider::{
IComponentProviderDispatcher, IComponentProviderDispatcherTrait
};
Expand Down

0 comments on commit fe39713

Please sign in to comment.