Skip to content

Commit

Permalink
cairo-format
Browse files Browse the repository at this point in the history
  • Loading branch information
archseer committed Aug 28, 2023
1 parent 09b0430 commit 2a7b8c1
Show file tree
Hide file tree
Showing 15 changed files with 57 additions and 63 deletions.
4 changes: 2 additions & 2 deletions contracts/src/libraries/token/erc677.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ mod ERC677 {
#[event]
#[derive(Drop, starknet::Event)]
enum Event {
Transfer: Transfer,
Transfer: Transfer,
}

#[derive(Drop, starknet::Event)]
Expand All @@ -51,7 +51,7 @@ mod ERC677 {
self
.emit(
Event::Transfer(
Transfer { from: sender, to: to, value: value, data: data.clone(), }
Transfer { from: sender, to: to, value: value, data: data.clone(), }
)
);

Expand Down
12 changes: 6 additions & 6 deletions contracts/src/multisig.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use starknet::ContractAddress;
use starknet::class_hash::ClassHash;

fn assert_unique_values<
T, impl TCopy: Copy<T>, impl TDrop: Drop<T>, impl TPartialEq: PartialEq<T>,
T, impl TCopy: Copy<T>, impl TDrop: Drop<T>, impl TPartialEq: PartialEq<T>,
>(
a: @Array::<T>
) {
Expand All @@ -13,7 +13,7 @@ fn assert_unique_values<
}

fn _assert_unique_values_loop<
T, impl TCopy: Copy<T>, impl TDrop: Drop<T>, impl TPartialEq: PartialEq<T>,
T, impl TCopy: Copy<T>, impl TDrop: Drop<T>, impl TPartialEq: PartialEq<T>,
>(
a: @Array::<T>, len: usize, j: usize, k: usize
) {
Expand Down Expand Up @@ -170,7 +170,7 @@ mod Multisig {
self._is_signer.read(address)
}

fn get_signers_len(self: @ContractState, ) -> usize {
fn get_signers_len(self: @ContractState,) -> usize {
self._signers_len.read()
}

Expand All @@ -181,11 +181,11 @@ mod Multisig {
signers
}

fn get_threshold(self: @ContractState, ) -> usize {
fn get_threshold(self: @ContractState,) -> usize {
self._threshold.read()
}

fn get_transactions_len(self: @ContractState, ) -> u128 {
fn get_transactions_len(self: @ContractState,) -> u128 {
self._next_nonce.read()
}

Expand All @@ -208,7 +208,7 @@ mod Multisig {
(transaction, calldata)
}

fn type_and_version(self: @ContractState, ) -> felt252 {
fn type_and_version(self: @ContractState,) -> felt252 {
'Multisig 1.0.0'
}

Expand Down
4 changes: 2 additions & 2 deletions contracts/src/tests/test_access_controller.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn setup() -> ContractAddress {

#[test]
#[available_gas(2000000)]
#[should_panic(expected: ('Ownable: caller is not owner', ))]
#[should_panic(expected: ('Ownable: caller is not owner',))]
fn test_upgrade_not_owner() {
let sender = setup();
let mut state = STATE();
Expand All @@ -43,7 +43,7 @@ fn test_access_control() {
let owner = setup();
// Deploy access controller
let calldata = array![owner.into(), // owner
];
];
let (accessControllerAddr, _) = deploy_syscall(
AccessController::TEST_CLASS_HASH.try_into().unwrap(), 0, calldata.span(), false
)
Expand Down
39 changes: 18 additions & 21 deletions contracts/src/tests/test_aggregator.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ fn setup() -> (

// deploy billing access controller
let calldata = array![acc1.into(), // owner = acc1;
];
];
let (billingAccessControllerAddr, _) = deploy_syscall(
AccessController::TEST_CLASS_HASH.try_into().unwrap(), 0, calldata.span(), false
)
Expand All @@ -93,7 +93,7 @@ fn setup() -> (
// deploy link token contract
let calldata = array![acc1.into(), // minter = acc1;
acc1.into(), // owner = acc1;
];
];
let (linkTokenAddr, _) = deploy_syscall(
LinkToken::TEST_CLASS_HASH.try_into().unwrap(), 0, calldata.span(), false
)
Expand Down Expand Up @@ -151,7 +151,7 @@ fn test_access_control() {

#[test]
#[available_gas(2000000)]
#[should_panic(expected: ('Ownable: caller is not owner', ))]
#[should_panic(expected: ('Ownable: caller is not owner',))]
fn test_upgrade_non_owner() {
let sender = setup();
let mut state = STATE();
Expand All @@ -162,7 +162,7 @@ fn test_upgrade_non_owner() {

#[test]
#[available_gas(2000000)]
#[should_panic(expected: ('Ownable: caller is not owner', ))]
#[should_panic(expected: ('Ownable: caller is not owner',))]
fn test_set_billing_access_controller_not_owner() {
let (owner, acc2, billingAccessController, _) = setup();
let mut state = STATE();
Expand All @@ -177,7 +177,7 @@ fn test_set_billing_access_controller_not_owner() {

#[test]
#[available_gas(2000000)]
#[should_panic(expected: ('caller does not have access', ))]
#[should_panic(expected: ('caller does not have access',))]
fn test_set_billing_config_no_access() {
let (owner, acc2, billingAccessController, _) = setup();
let mut state = STATE();
Expand Down Expand Up @@ -278,15 +278,15 @@ fn test_set_billing_config_as_acc_with_access() {

#[test]
#[available_gas(2000000)]
#[should_panic(expected: ('Ownable: caller is not owner', ))]
#[should_panic(expected: ('Ownable: caller is not owner',))]
fn test_set_payees_caller_not_owner() {
let (owner, acc2, _, _) = setup();
let mut state = STATE();
Aggregator::constructor(
ref state, owner, contract_address_const::<777>(), 0, 100, acc2, 8, 123
);

let payees = array![PayeeConfig { transmitter: acc2, payee: acc2, }, ];
let payees = array![PayeeConfig { transmitter: acc2, payee: acc2, },];

// set payee should revert if caller is not owner
set_caller_address(acc2);
Expand All @@ -302,7 +302,7 @@ fn test_set_single_payee() {
ref state, owner, contract_address_const::<777>(), 0, 100, acc2, 8, 123
);

let payees = array![PayeeConfig { transmitter: acc2, payee: acc2, }, ];
let payees = array![PayeeConfig { transmitter: acc2, payee: acc2, },];

set_caller_address(owner);
PayeeManagementImpl::set_payees(ref state, payees);
Expand All @@ -318,11 +318,8 @@ fn test_set_multiple_payees() {
);

let payees = array![
PayeeConfig {
transmitter: acc2, payee: acc2,
}, PayeeConfig {
transmitter: owner, payee: owner,
},
PayeeConfig { transmitter: acc2, payee: acc2, },
PayeeConfig { transmitter: owner, payee: owner, },
];

set_caller_address(owner);
Expand All @@ -331,7 +328,7 @@ fn test_set_multiple_payees() {

#[test]
#[available_gas(2000000)]
#[should_panic(expected: ('only current payee can update', ))]
#[should_panic(expected: ('only current payee can update',))]
fn test_transfer_payeeship_caller_not_payee() {
let (owner, acc2, _, _) = setup();
let mut state = STATE();
Expand All @@ -340,7 +337,7 @@ fn test_transfer_payeeship_caller_not_payee() {
);

let transmitter = contract_address_const::<123>();
let payees = array![PayeeConfig { transmitter: transmitter, payee: acc2, }, ];
let payees = array![PayeeConfig { transmitter: transmitter, payee: acc2, },];

set_caller_address(owner);
PayeeManagementImpl::set_payees(ref state, payees);
Expand All @@ -349,7 +346,7 @@ fn test_transfer_payeeship_caller_not_payee() {

#[test]
#[available_gas(2000000)]
#[should_panic(expected: ('cannot transfer to self', ))]
#[should_panic(expected: ('cannot transfer to self',))]
fn test_transfer_payeeship_to_self() {
let (owner, acc2, _, _) = setup();
let mut state = STATE();
Expand All @@ -358,7 +355,7 @@ fn test_transfer_payeeship_to_self() {
);

let transmitter = contract_address_const::<123>();
let payees = array![PayeeConfig { transmitter: transmitter, payee: acc2, }, ];
let payees = array![PayeeConfig { transmitter: transmitter, payee: acc2, },];

set_caller_address(owner);
PayeeManagementImpl::set_payees(ref state, payees);
Expand All @@ -368,7 +365,7 @@ fn test_transfer_payeeship_to_self() {

#[test]
#[available_gas(2000000)]
#[should_panic(expected: ('only proposed payee can accept', ))]
#[should_panic(expected: ('only proposed payee can accept',))]
fn test_accept_payeeship_caller_not_proposed_payee() {
let (owner, acc2, _, _) = setup();
let mut state = STATE();
Expand All @@ -377,7 +374,7 @@ fn test_accept_payeeship_caller_not_proposed_payee() {
);

let transmitter = contract_address_const::<123>();
let payees = array![PayeeConfig { transmitter: transmitter, payee: acc2, }, ];
let payees = array![PayeeConfig { transmitter: transmitter, payee: acc2, },];

set_caller_address(owner);
PayeeManagementImpl::set_payees(ref state, payees);
Expand All @@ -396,7 +393,7 @@ fn test_transfer_and_accept_payeeship() {
);

let transmitter = contract_address_const::<123>();
let payees = array![PayeeConfig { transmitter: transmitter, payee: acc2, }, ];
let payees = array![PayeeConfig { transmitter: transmitter, payee: acc2, },];

set_caller_address(owner);
PayeeManagementImpl::set_payees(ref state, payees);
Expand All @@ -422,7 +419,7 @@ fn test_owed_payment_no_rounds() {
);

let transmitter = contract_address_const::<123>();
let mut payees = array![PayeeConfig { transmitter: transmitter, payee: acc2, }, ];
let mut payees = array![PayeeConfig { transmitter: transmitter, payee: acc2, },];

set_caller_address(owner);
PayeeManagementImpl::set_payees(ref state, payees);
Expand Down
8 changes: 4 additions & 4 deletions contracts/src/tests/test_aggregator_proxy.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ fn test_ownable() {
let (account, mockAggregatorAddr, _, _, _) = setup();
// Deploy aggregator proxy
let calldata = array![account.into(), // owner = account
mockAggregatorAddr.into(), ];
mockAggregatorAddr.into(),];
let (aggregatorProxyAddr, _) = deploy_syscall(
AggregatorProxy::TEST_CLASS_HASH.try_into().unwrap(), 0, calldata.span(), false
)
Expand All @@ -80,7 +80,7 @@ fn test_access_control() {
let (account, mockAggregatorAddr, _, _, _) = setup();
// Deploy aggregator proxy
let calldata = array![account.into(), // owner = account
mockAggregatorAddr.into(), ];
mockAggregatorAddr.into(),];
let (aggregatorProxyAddr, _) = deploy_syscall(
AggregatorProxy::TEST_CLASS_HASH.try_into().unwrap(), 0, calldata.span(), false
)
Expand All @@ -91,7 +91,7 @@ fn test_access_control() {

#[test]
#[available_gas(2000000)]
#[should_panic(expected: ('Ownable: caller is not owner', ))]
#[should_panic(expected: ('Ownable: caller is not owner',))]
fn test_upgrade_non_owner() {
let (_, _, _, _, _) = setup();
let mut state = STATE();
Expand Down Expand Up @@ -119,7 +119,7 @@ fn test_query_latest_round_data() {

#[test]
#[available_gas(2000000)]
#[should_panic(expected: ('user does not have read access', ))]
#[should_panic(expected: ('user does not have read access',))]
fn test_query_latest_round_data_without_access() {
let (owner, mockAggregatorAddr, mockAggregator, _, _) = setup();
let mut state = STATE();
Expand Down
6 changes: 3 additions & 3 deletions contracts/src/tests/test_erc677.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ fn transfer_and_call(receiver: ContractAddress) {

#[test]
#[available_gas(2000000)]
#[should_panic(expected: ('ERC20: transfer to 0', ))]
#[should_panic(expected: ('ERC20: transfer to 0',))]
fn test_to_zero_address() {
setup();
transfer_and_call(Zeroable::zero());
Expand All @@ -82,7 +82,7 @@ fn test_valid_transfer_and_call() {

#[test]
#[available_gas(2000000)]
#[should_panic(expected: ('ENTRYPOINT_NOT_FOUND', ))]
#[should_panic(expected: ('ENTRYPOINT_NOT_FOUND',))]
fn test_invalid_receiver_supports_interface_true() {
setup();
let (receiver_address, receiver) = setup_invalid_receiver();
Expand All @@ -104,7 +104,7 @@ fn test_invalid_receiver_supports_interface_false() {

#[test]
#[available_gas(2000000)]
#[should_panic(expected: ('CONTRACT_NOT_DEPLOYED', ))]
#[should_panic(expected: ('CONTRACT_NOT_DEPLOYED',))]
fn test_nonexistent_receiver() {
setup();

Expand Down
10 changes: 5 additions & 5 deletions contracts/src/tests/test_link_token.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fn test_ownable() {

#[test]
#[available_gas(2000000)]
#[should_panic(expected: ('minter is 0', ))]
#[should_panic(expected: ('minter is 0',))]
fn test_constructor_zero_address() {
let sender = setup();
let mut state = STATE();
Expand Down Expand Up @@ -89,7 +89,7 @@ fn test_permissioned_mint_from_minter() {

#[test]
#[available_gas(2000000)]
#[should_panic(expected: ('only minter', ))]
#[should_panic(expected: ('only minter',))]
fn test_permissioned_mint_from_nonminter() {
let sender = setup();
let mut state = STATE();
Expand All @@ -103,7 +103,7 @@ fn test_permissioned_mint_from_nonminter() {

#[test]
#[available_gas(2000000)]
#[should_panic(expected: ('u256_sub Overflow', ))]
#[should_panic(expected: ('u256_sub Overflow',))]
fn test_permissioned_burn_from_minter() {
let zero = 0;
let sender = setup();
Expand Down Expand Up @@ -132,7 +132,7 @@ fn test_permissioned_burn_from_minter() {

#[test]
#[available_gas(2000000)]
#[should_panic(expected: ('only minter', ))]
#[should_panic(expected: ('only minter',))]
fn test_permissioned_burn_from_nonminter() {
let sender = setup();
let mut state = STATE();
Expand All @@ -146,7 +146,7 @@ fn test_permissioned_burn_from_nonminter() {

#[test]
#[available_gas(2000000)]
#[should_panic(expected: ('Ownable: caller is not owner', ))]
#[should_panic(expected: ('Ownable: caller is not owner',))]
fn test_upgrade_non_owner() {
let sender = setup();
let mut state = STATE();
Expand Down
10 changes: 5 additions & 5 deletions contracts/src/tests/test_multisig.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ fn test_execute_confirmation_below_threshold() {

#[test]
#[available_gas(2000000)]
#[should_panic(expected: ('only multisig allowed', ))]
#[should_panic(expected: ('only multisig allowed',))]
fn test_upgrade_not_multisig() {
let mut state = STATE();
let account = contract_address_const::<777>();
Expand Down Expand Up @@ -325,7 +325,7 @@ fn test_execute() {

#[test]
#[available_gas(8000000)]
#[should_panic(expected: ('invalid signer', ))]
#[should_panic(expected: ('invalid signer',))]
fn test_execute_not_signer() {
let mut state = STATE();
let signer1 = contract_address_const::<1>();
Expand All @@ -349,7 +349,7 @@ fn test_execute_not_signer() {

#[test]
#[available_gas(8000000)]
#[should_panic(expected: ('transaction invalid', ))]
#[should_panic(expected: ('transaction invalid',))]
fn test_execute_after_set_signers() {
let mut state = STATE();
let contract_address = contract_address_const::<100>();
Expand Down Expand Up @@ -379,7 +379,7 @@ fn test_execute_after_set_signers() {

#[test]
#[available_gas(8000000)]
#[should_panic(expected: ('transaction invalid', ))]
#[should_panic(expected: ('transaction invalid',))]
fn test_execute_after_set_signers_and_threshold() {
let mut state = STATE();
let contract_address = contract_address_const::<100>();
Expand Down Expand Up @@ -409,7 +409,7 @@ fn test_execute_after_set_signers_and_threshold() {

#[test]
#[available_gas(8000000)]
#[should_panic(expected: ('transaction invalid', ))]
#[should_panic(expected: ('transaction invalid',))]
fn test_execute_after_set_threshold() {
let mut state = STATE();
let contract_address = contract_address_const::<100>();
Expand Down
Loading

0 comments on commit 2a7b8c1

Please sign in to comment.