Skip to content

Commit

Permalink
Remove unnecessary mut, minor fixes (#1032)
Browse files Browse the repository at this point in the history
* clean up code

* change array syntax

* fix fmt
  • Loading branch information
andrew-fleming authored Jul 2, 2024
1 parent 85a92c5 commit 65894fb
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 27 deletions.
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/udc.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fn deploy() -> ContractAddress {
>();
let salt = 1234567879;
let from_zero = false;
let mut calldata = array![];
let calldata = array![];
// The UDC returns the deployed contract address
dispatcher.deploy_contract(class_hash, salt, from_zero, calldata.span())
Expand Down
2 changes: 1 addition & 1 deletion src/access/ownable/dual_ownable.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl DualCaseOwnableImpl of DualCaseOwnableTrait {
}

fn renounce_ownership(self: @DualCaseOwnable) {
let mut args = array![];
let args = array![];

try_selector_with_fallback(
*self.contract_address,
Expand Down
2 changes: 1 addition & 1 deletion src/account/utils.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub const QUERY_OFFSET: u256 = 0x100000000000000000000000000000000;
pub const QUERY_VERSION: u256 = 0x100000000000000000000000000000001;

pub fn execute_calls(mut calls: Array<Call>) -> Array<Span<felt252>> {
let mut res = ArrayTrait::new();
let mut res = array![];
loop {
match calls.pop_front() {
Option::Some(call) => {
Expand Down
3 changes: 1 addition & 2 deletions src/presets/universal_deployer.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ pub(crate) mod UniversalDeployer {
let deployer: ContractAddress = get_caller_address();
let mut _salt: felt252 = salt;
if !from_zero {
let mut hash_state = PoseidonTrait::new();
_salt = hash_state.update_with(deployer).update_with(salt).finalize();
_salt = PoseidonTrait::new().update_with(deployer).update_with(salt).finalize()
}

let (address, _) = starknet::syscalls::deploy_syscall(
Expand Down
2 changes: 1 addition & 1 deletion src/tests/security/test_reentrancyguard.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ fn test_remote_callback() {
let contract = deploy_mock();

// Deploy attacker
let calldata = ArrayTrait::new();
let calldata = array![];
let attacker_addr = utils::deploy(Attacker::TEST_CLASS_HASH, calldata);

contract.count_and_call(attacker_addr);
Expand Down
4 changes: 2 additions & 2 deletions src/tests/token/erc1155/common.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ pub(crate) fn setup_camel_receiver() -> ContractAddress {
}

pub(crate) fn setup_account() -> ContractAddress {
let mut calldata = array![PUBKEY];
let calldata = array![PUBKEY];
utils::deploy(SnakeAccountMock::TEST_CLASS_HASH, calldata)
}

pub(crate) fn setup_account_with_salt(salt: felt252) -> ContractAddress {
let mut calldata = array![PUBKEY];
let calldata = array![PUBKEY];
utils::deploy_with_salt(SnakeAccountMock::TEST_CLASS_HASH, calldata, salt)
}

Expand Down
14 changes: 5 additions & 9 deletions src/tests/token/erc1155/test_dual1155_receiver.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use openzeppelin::token::erc1155::interface::{
//

fn setup_snake() -> (DualCaseERC1155Receiver, IERC1155ReceiverDispatcher) {
let mut calldata = ArrayTrait::new();
let calldata = array![];
let target = utils::deploy(SnakeERC1155ReceiverMock::TEST_CLASS_HASH, calldata);
(
DualCaseERC1155Receiver { contract_address: target },
Expand All @@ -30,7 +30,7 @@ fn setup_snake() -> (DualCaseERC1155Receiver, IERC1155ReceiverDispatcher) {
}

fn setup_camel() -> (DualCaseERC1155Receiver, IERC1155ReceiverCamelDispatcher) {
let mut calldata = ArrayTrait::new();
let calldata = array![];
let target = utils::deploy(CamelERC1155ReceiverMock::TEST_CLASS_HASH, calldata);
(
DualCaseERC1155Receiver { contract_address: target },
Expand All @@ -39,18 +39,14 @@ fn setup_camel() -> (DualCaseERC1155Receiver, IERC1155ReceiverCamelDispatcher) {
}

fn setup_non_erc1155_receiver() -> DualCaseERC1155Receiver {
let calldata = ArrayTrait::new();
let calldata = array![];
let target = utils::deploy(NonImplementingMock::TEST_CLASS_HASH, calldata);
DualCaseERC1155Receiver { contract_address: target }
}

fn setup_erc1155_receiver_panic() -> (DualCaseERC1155Receiver, DualCaseERC1155Receiver) {
let snake_target = utils::deploy(
SnakeERC1155ReceiverPanicMock::TEST_CLASS_HASH, ArrayTrait::new()
);
let camel_target = utils::deploy(
CamelERC1155ReceiverPanicMock::TEST_CLASS_HASH, ArrayTrait::new()
);
let snake_target = utils::deploy(SnakeERC1155ReceiverPanicMock::TEST_CLASS_HASH, array![]);
let camel_target = utils::deploy(CamelERC1155ReceiverPanicMock::TEST_CLASS_HASH, array![]);
(
DualCaseERC1155Receiver { contract_address: snake_target },
DualCaseERC1155Receiver { contract_address: camel_target }
Expand Down
14 changes: 5 additions & 9 deletions src/tests/token/erc721/test_dual721_receiver.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use openzeppelin::token::erc721::interface::{
//

fn setup_snake() -> (DualCaseERC721Receiver, IERC721ReceiverDispatcher) {
let mut calldata = ArrayTrait::new();
let mut calldata = array![];
let target = utils::deploy(SnakeERC721ReceiverMock::TEST_CLASS_HASH, calldata);
(
DualCaseERC721Receiver { contract_address: target },
Expand All @@ -32,7 +32,7 @@ fn setup_snake() -> (DualCaseERC721Receiver, IERC721ReceiverDispatcher) {
}

fn setup_camel() -> (DualCaseERC721Receiver, IERC721ReceiverCamelDispatcher) {
let mut calldata = ArrayTrait::new();
let mut calldata = array![];
let target = utils::deploy(CamelERC721ReceiverMock::TEST_CLASS_HASH, calldata);
(
DualCaseERC721Receiver { contract_address: target },
Expand All @@ -41,18 +41,14 @@ fn setup_camel() -> (DualCaseERC721Receiver, IERC721ReceiverCamelDispatcher) {
}

fn setup_non_erc721_receiver() -> DualCaseERC721Receiver {
let calldata = ArrayTrait::new();
let calldata = array![];
let target = utils::deploy(NonImplementingMock::TEST_CLASS_HASH, calldata);
DualCaseERC721Receiver { contract_address: target }
}

fn setup_erc721_receiver_panic() -> (DualCaseERC721Receiver, DualCaseERC721Receiver) {
let snake_target = utils::deploy(
SnakeERC721ReceiverPanicMock::TEST_CLASS_HASH, ArrayTrait::new()
);
let camel_target = utils::deploy(
CamelERC721ReceiverPanicMock::TEST_CLASS_HASH, ArrayTrait::new()
);
let snake_target = utils::deploy(SnakeERC721ReceiverPanicMock::TEST_CLASS_HASH, array![]);
let camel_target = utils::deploy(CamelERC721ReceiverPanicMock::TEST_CLASS_HASH, array![]);
(
DualCaseERC721Receiver { contract_address: snake_target },
DualCaseERC721Receiver { contract_address: camel_target }
Expand Down
2 changes: 1 addition & 1 deletion src/token/erc20/dual20.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl DualCaseERC20Impl of DualCaseERC20Trait {
}

fn total_supply(self: @DualCaseERC20) -> u256 {
let mut args = array![];
let args = array![];
try_selector_with_fallback(
*self.contract_address, selectors::total_supply, selectors::totalSupply, args.span()
)
Expand Down

0 comments on commit 65894fb

Please sign in to comment.