Skip to content

Commit e62118f

Browse files
tekkactekkac
authored andcommitted
🎨 improve
1 parent f291543 commit e62118f

File tree

3 files changed

+7
-24
lines changed

3 files changed

+7
-24
lines changed

‎src/components/vintage/vintage.cairo‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ pub mod VintageComponent {
7777
pub mod Errors {
7878
pub const INVALID_ARRAY_LENGTH: felt252 = 'Vintage: invalid array length';
7979
pub const INVALID_STARTING_YEAR: felt252 = 'Vintage: invalid starting year';
80+
pub const INVALID_CALLER: felt252 = 'Vintage: invalid caller';
8081
}
8182

8283
#[embeddable_as(VintageImpl)]
@@ -216,21 +217,16 @@ pub mod VintageComponent {
216217
let supply = *yearly_absorptions.at(index);
217218
let token_id = (index + 1).into();
218219
let old_vintage = self.Vintage_vintages.entry(token_id).read();
219-
let mut vintage = CarbonVintage {
220+
let new_vintage = CarbonVintage {
220221
year: (start_year + index).into(),
221222
supply: supply,
222223
failed: 0,
223224
created: 0,
224225
status: CarbonVintageType::Projected,
225226
};
226-
self.Vintage_vintages.entry(token_id).write(vintage);
227+
self.Vintage_vintages.entry(token_id).write(new_vintage);
227228

228-
self
229-
.emit(
230-
VintageUpdate {
231-
token_id: index.into(), old_vintage: old_vintage, new_vintage: vintage
232-
}
233-
);
229+
self.emit(VintageUpdate { token_id, old_vintage, new_vintage });
234230
index += 1;
235231
};
236232
}
@@ -273,7 +269,7 @@ pub mod VintageComponent {
273269
// [Check] Caller has role
274270
let caller = get_caller_address();
275271
let has_role = self.get_contract().has_role(role, caller);
276-
assert(has_role, 'Caller does not have role');
272+
assert(has_role, Errors::INVALID_CALLER);
277273
}
278274
}
279275
}

‎tests/test_mint.cairo‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -248,19 +248,6 @@ fn test_public_buy() {
248248
minter.public_buy(cc_to_buy);
249249

250250
let token_ids = helper_get_token_ids(project_address);
251-
// TODO: helper for amounts here?
252-
253-
// let mut cc_amounts: Array<u256> = Default::default();
254-
// let mut index = 0;
255-
// loop {
256-
// if index >= token_ids.len() {
257-
// break ();
258-
// }
259-
// let token_id = *token_ids.at(index);
260-
// let cc_value = project_contract.internal_to_cc(cc_to_buy, token_id);
261-
// cc_amounts.append(cc_value);
262-
// index += 1;
263-
// };
264251

265252
let expected_events = helper_expected_transfer_single_events(
266253
project_address, minter_address, Zero::zero(), user_address, token_ids, cc_to_buy

‎tests/test_vintage.cairo‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ fn test_set_vintages() {
9595
}
9696

9797
#[test]
98-
#[should_panic(expected: 'Caller does not have role')]
98+
#[should_panic(expected: 'Vintage: invalid caller')]
9999
fn test_set_vintages_without_owner_role() {
100100
let project_address = deploy_project();
101101
let yearly_absorptions = get_mock_absorptions();
@@ -225,7 +225,7 @@ fn test_update_vintage_status_invalid() {
225225
}
226226

227227
#[test]
228-
#[should_panic(expected: 'Caller does not have role')]
228+
#[should_panic(expected: 'Vintage: invalid caller')]
229229
fn test_update_vintage_status_without_owner_role() {
230230
let project_address = deploy_project();
231231
let user_address: ContractAddress = contract_address_const::<'USER'>();

0 commit comments

Comments
 (0)