Skip to content

Commit 3512093

Browse files
committed
chore: fix cairo formatting
1 parent 4633adc commit 3512093

File tree

3 files changed

+24
-10
lines changed

3 files changed

+24
-10
lines changed

contract/src/interfaces/ipredifi.cairo

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@ pub trait IPredifi<TContractState> {
3535
// Role Management
3636
fn assign_role(ref self: TContractState, role: felt252, account: ContractAddress);
3737
fn revoke_role(ref self: TContractState, role: felt252, account: ContractAddress);
38-
fn transfer_role(ref self: TContractState, role: felt252, new_account: ContractAddress, old_account: ContractAddress);
38+
fn transfer_role(
39+
ref self: TContractState,
40+
role: felt252,
41+
new_account: ContractAddress,
42+
old_account: ContractAddress,
43+
);
3944
fn has_role(self: @TContractState, role: felt252, account: ContractAddress) -> bool;
4045
}
4146

contract/src/predifi.cairo

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub mod Predifi {
1111
use starknet::{ContractAddress, get_block_timestamp, get_caller_address, get_contract_address};
1212
use crate::base::errors::Errors::{
1313
AMOUNT_ABOVE_MAXIMUM, AMOUNT_BELOW_MINIMUM, INACTIVE_POOL, INVALID_POOL_OPTION,
14-
UNAUTHORIZED, INVALID_ROLE, SELF_REVOKE_ERROR, ROLE_NOT_ASSIGNED,
14+
INVALID_ROLE, ROLE_NOT_ASSIGNED, SELF_REVOKE_ERROR, UNAUTHORIZED,
1515
};
1616
// oz imports
1717

@@ -278,16 +278,22 @@ pub mod Predifi {
278278
ref self: ContractState,
279279
role: felt252,
280280
new_account: ContractAddress,
281-
old_account: ContractAddress
281+
old_account: ContractAddress,
282282
) {
283283
let caller = get_caller_address();
284284
assert(self.roles.read(('ADMIN', caller)), UNAUTHORIZED);
285285
assert(self.roles.read((role, old_account)), ROLE_NOT_ASSIGNED);
286286

287287
self.roles.write((role, new_account), true);
288288
self.roles.write((role, old_account), false);
289-
self.emit(Event::RoleGranted(RoleGranted { role, account: new_account, sender: caller }));
290-
self.emit(Event::RoleRevoked(RoleRevoked { role, account: old_account, sender: caller }));
289+
self
290+
.emit(
291+
Event::RoleGranted(RoleGranted { role, account: new_account, sender: caller }),
292+
);
293+
self
294+
.emit(
295+
Event::RoleRevoked(RoleRevoked { role, account: old_account, sender: caller }),
296+
);
291297
}
292298

293299
fn has_role(self: @ContractState, role: felt252, account: ContractAddress) -> bool {

contract/tests/test_contract.cairo

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ use contract::base::types::{Category, Pool, PoolDetails, Status};
22
use contract::interfaces::ipredifi::{IPredifiDispatcher, IPredifiDispatcherTrait};
33
use core::felt252;
44
use core::traits::Into;
5-
use snforge_std::{ContractClassTrait, DeclareResultTrait, declare, start_cheat_caller_address, stop_cheat_caller_address, start_cheat_caller_address_global, stop_cheat_caller_address_global};
5+
use snforge_std::{
6+
ContractClassTrait, DeclareResultTrait, declare, start_cheat_caller_address,
7+
start_cheat_caller_address_global, stop_cheat_caller_address, stop_cheat_caller_address_global,
8+
};
69
use starknet::{
710
ClassHash, ContractAddress, get_block_timestamp, get_caller_address, get_contract_address,
811
};
@@ -549,16 +552,16 @@ fn test_get_pool_vote() {
549552
#[test]
550553
fn test_role_management() {
551554
let admin: ContractAddress = 'admin'.try_into().unwrap();
552-
let user: ContractAddress = 'user'.try_into().unwrap();
553-
555+
let user: ContractAddress = 'user'.try_into().unwrap();
556+
554557
// Cheat caller for the constructor
555558
start_cheat_caller_address_global(admin);
556559
let contract = deploy_predifi();
557560
stop_cheat_caller_address_global();
558561

559562
// Verify admin
560563
assert(contract.has_role('ADMIN', admin), 'Admin should have ADMIN role');
561-
564+
562565
// Now prank as admin to assign role
563566
start_cheat_caller_address(contract.contract_address, admin);
564567
contract.assign_role('OPERATOR', user);
@@ -587,7 +590,7 @@ fn test_transfer_role() {
587590
start_cheat_caller_address(contract.contract_address, admin);
588591
contract.assign_role('OPERATOR', user1);
589592
assert(contract.has_role('OPERATOR', user1), 'User1 should have role');
590-
593+
591594
contract.transfer_role('OPERATOR', user2, user1);
592595
stop_cheat_caller_address(contract.contract_address);
593596

0 commit comments

Comments
 (0)