From 2a7b8c1d1182cfa40801460954d57a1cc7b9bc28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Fri, 25 Aug 2023 16:25:24 +0900 Subject: [PATCH] cairo-format --- contracts/src/libraries/token/erc677.cairo | 4 +- contracts/src/multisig.cairo | 12 +++--- .../src/tests/test_access_controller.cairo | 4 +- contracts/src/tests/test_aggregator.cairo | 39 +++++++++---------- .../src/tests/test_aggregator_proxy.cairo | 8 ++-- contracts/src/tests/test_erc677.cairo | 6 +-- contracts/src/tests/test_link_token.cairo | 10 ++--- contracts/src/tests/test_multisig.cairo | 10 ++--- .../tests/test_sequencer_uptime_feed.cairo | 4 +- contracts/src/tests/test_upgradeable.cairo | 2 +- contracts/src/token/link_token.cairo | 2 +- .../token/mock/valid_erc667_receiver.cairo | 2 +- .../src/ocr2/consumer.cairo | 2 +- .../ocr2/price_consumer_with_sequencer.cairo | 10 ++--- .../proxy-consumer/src/proxy_consumer.cairo | 5 +-- 15 files changed, 57 insertions(+), 63 deletions(-) diff --git a/contracts/src/libraries/token/erc677.cairo b/contracts/src/libraries/token/erc677.cairo index c0f390218..630edf093 100644 --- a/contracts/src/libraries/token/erc677.cairo +++ b/contracts/src/libraries/token/erc677.cairo @@ -30,7 +30,7 @@ mod ERC677 { #[event] #[derive(Drop, starknet::Event)] enum Event { - Transfer: Transfer, + Transfer: Transfer, } #[derive(Drop, starknet::Event)] @@ -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(), } ) ); diff --git a/contracts/src/multisig.cairo b/contracts/src/multisig.cairo index 7220d1697..3aae1181f 100644 --- a/contracts/src/multisig.cairo +++ b/contracts/src/multisig.cairo @@ -4,7 +4,7 @@ use starknet::ContractAddress; use starknet::class_hash::ClassHash; fn assert_unique_values< - T, impl TCopy: Copy, impl TDrop: Drop, impl TPartialEq: PartialEq, + T, impl TCopy: Copy, impl TDrop: Drop, impl TPartialEq: PartialEq, >( a: @Array:: ) { @@ -13,7 +13,7 @@ fn assert_unique_values< } fn _assert_unique_values_loop< - T, impl TCopy: Copy, impl TDrop: Drop, impl TPartialEq: PartialEq, + T, impl TCopy: Copy, impl TDrop: Drop, impl TPartialEq: PartialEq, >( a: @Array::, len: usize, j: usize, k: usize ) { @@ -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() } @@ -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() } @@ -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' } diff --git a/contracts/src/tests/test_access_controller.cairo b/contracts/src/tests/test_access_controller.cairo index f9d270b50..862dc5248 100644 --- a/contracts/src/tests/test_access_controller.cairo +++ b/contracts/src/tests/test_access_controller.cairo @@ -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(); @@ -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 ) diff --git a/contracts/src/tests/test_aggregator.cairo b/contracts/src/tests/test_aggregator.cairo index db6eb6c70..b004bd9fa 100644 --- a/contracts/src/tests/test_aggregator.cairo +++ b/contracts/src/tests/test_aggregator.cairo @@ -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 ) @@ -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 ) @@ -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(); @@ -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(); @@ -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(); @@ -278,7 +278,7 @@ 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(); @@ -286,7 +286,7 @@ fn test_set_payees_caller_not_owner() { 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); @@ -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); @@ -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); @@ -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(); @@ -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); @@ -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(); @@ -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); @@ -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(); @@ -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); @@ -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); @@ -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); diff --git a/contracts/src/tests/test_aggregator_proxy.cairo b/contracts/src/tests/test_aggregator_proxy.cairo index 4ce1087e9..6f1462691 100644 --- a/contracts/src/tests/test_aggregator_proxy.cairo +++ b/contracts/src/tests/test_aggregator_proxy.cairo @@ -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 ) @@ -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 ) @@ -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(); @@ -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(); diff --git a/contracts/src/tests/test_erc677.cairo b/contracts/src/tests/test_erc677.cairo index 3b64e0f65..77bef112d 100644 --- a/contracts/src/tests/test_erc677.cairo +++ b/contracts/src/tests/test_erc677.cairo @@ -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()); @@ -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(); @@ -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(); diff --git a/contracts/src/tests/test_link_token.cairo b/contracts/src/tests/test_link_token.cairo index 267ebf1dc..111d4d951 100644 --- a/contracts/src/tests/test_link_token.cairo +++ b/contracts/src/tests/test_link_token.cairo @@ -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(); @@ -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(); @@ -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(); @@ -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(); @@ -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(); diff --git a/contracts/src/tests/test_multisig.cairo b/contracts/src/tests/test_multisig.cairo index d8b64c3a3..179dd3472 100644 --- a/contracts/src/tests/test_multisig.cairo +++ b/contracts/src/tests/test_multisig.cairo @@ -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>(); @@ -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>(); @@ -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>(); @@ -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>(); @@ -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>(); diff --git a/contracts/src/tests/test_sequencer_uptime_feed.cairo b/contracts/src/tests/test_sequencer_uptime_feed.cairo index 1292e394e..558f40b2b 100644 --- a/contracts/src/tests/test_sequencer_uptime_feed.cairo +++ b/contracts/src/tests/test_sequencer_uptime_feed.cairo @@ -83,7 +83,7 @@ fn test_set_l1_sender() { #[test] #[available_gas(2000000)] -#[should_panic(expected: ('user does not have read access', ))] +#[should_panic(expected: ('user does not have read access',))] fn test_latest_round_data_no_access() { let (owner, sequencerFeedAddr, _) = setup(); let mut proxy = PROXY(); @@ -93,7 +93,7 @@ fn test_latest_round_data_no_access() { #[test] #[available_gas(2000000)] -#[should_panic(expected: ('user does not have read access', ))] +#[should_panic(expected: ('user does not have read access',))] fn test_aggregator_proxy_response() { let (owner, sequencerFeedAddr, _) = setup(); let mut proxy = PROXY(); diff --git a/contracts/src/tests/test_upgradeable.cairo b/contracts/src/tests/test_upgradeable.cairo index 4788d74b0..3da6b6991 100644 --- a/contracts/src/tests/test_upgradeable.cairo +++ b/contracts/src/tests/test_upgradeable.cairo @@ -27,7 +27,7 @@ fn test_upgrade() { #[test] #[available_gas(2000000)] -#[should_panic(expected: ('Class hash cannot be zero', ))] +#[should_panic(expected: ('Class hash cannot be zero',))] fn test_upgrade_zero_hash() { let sender = setup(); diff --git a/contracts/src/token/link_token.cairo b/contracts/src/token/link_token.cairo index eb534871b..6134de169 100644 --- a/contracts/src/token/link_token.cairo +++ b/contracts/src/token/link_token.cairo @@ -28,7 +28,7 @@ mod LinkToken { #[storage] struct Storage { - _minter: ContractAddress, + _minter: ContractAddress, } // diff --git a/contracts/src/token/mock/valid_erc667_receiver.cairo b/contracts/src/token/mock/valid_erc667_receiver.cairo index fce48fe5c..33e72c129 100644 --- a/contracts/src/token/mock/valid_erc667_receiver.cairo +++ b/contracts/src/token/mock/valid_erc667_receiver.cairo @@ -12,7 +12,7 @@ mod ValidReceiver { #[storage] struct Storage { - _sender: ContractAddress, + _sender: ContractAddress, } #[constructor] diff --git a/examples/contracts/aggregator-consumer/src/ocr2/consumer.cairo b/examples/contracts/aggregator-consumer/src/ocr2/consumer.cairo index 3da49258e..3b3916316 100644 --- a/examples/contracts/aggregator-consumer/src/ocr2/consumer.cairo +++ b/examples/contracts/aggregator-consumer/src/ocr2/consumer.cairo @@ -10,7 +10,7 @@ mod AggregatorConsumer { #[storage] struct Storage { - _ocr_address: ContractAddress, + _ocr_address: ContractAddress, } #[constructor] diff --git a/examples/contracts/aggregator-consumer/src/ocr2/price_consumer_with_sequencer.cairo b/examples/contracts/aggregator-consumer/src/ocr2/price_consumer_with_sequencer.cairo index 2e4536cf7..f279d9985 100644 --- a/examples/contracts/aggregator-consumer/src/ocr2/price_consumer_with_sequencer.cairo +++ b/examples/contracts/aggregator-consumer/src/ocr2/price_consumer_with_sequencer.cairo @@ -35,16 +35,14 @@ mod AggregatorPriceConsumerWithSequencer { #[extrnal(v0)] fn get_latest_price(self: @ContractState) -> u128 { assert_sequencer_healthy(self); - let round = IAggregatorDispatcher { - contract_address: self._aggregator_address.read() - }.latest_round_data(); + let round = IAggregatorDispatcher { contract_address: self._aggregator_address.read() } + .latest_round_data(); round.answer } fn assert_sequencer_healthy(self: @ContractState) { - let round = IAggregatorDispatcher { - contract_address: self._uptime_feed_address.read() - }.latest_round_data(); + let round = IAggregatorDispatcher { contract_address: self._uptime_feed_address.read() } + .latest_round_data(); let timestamp = starknet::info::get_block_info().unbox().block_timestamp; // After 60 sec the report is considered stale diff --git a/examples/contracts/proxy-consumer/src/proxy_consumer.cairo b/examples/contracts/proxy-consumer/src/proxy_consumer.cairo index 1ea30585b..5be522cd5 100644 --- a/examples/contracts/proxy-consumer/src/proxy_consumer.cairo +++ b/examples/contracts/proxy-consumer/src/proxy_consumer.cairo @@ -34,9 +34,8 @@ mod ProxyConsumer { #[external(v0)] fn get_latest_round_data(ref self: ContractState) -> Round { - let round = IAggregatorDispatcher { - contract_address: self._proxy_address.read() - }.latest_round_data(); + let round = IAggregatorDispatcher { contract_address: self._proxy_address.read() } + .latest_round_data(); self._feed_data.write(round); round }