Skip to content

Commit

Permalink
rename get_pledgers_as_arr->array
Browse files Browse the repository at this point in the history
  • Loading branch information
Nenad authored and julio4 committed Jun 26, 2024
1 parent cfd7694 commit 5c39c5a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions listings/applications/crowdfunding/src/campaign.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ pub mod Campaign {
}

fn get_pledgers(self: @ContractState) -> Array<ContractAddress> {
self.pledges.get_pledgers_as_arr()
self.pledges.array()
}

fn pledge(ref self: ContractState, amount: u256) {
Expand Down Expand Up @@ -339,7 +339,7 @@ pub mod Campaign {
}

fn _refund_all(ref self: ContractState, reason: ByteArray) {
let mut pledges = self.pledges.get_pledgers_as_arr();
let mut pledges = self.pledges.array();
while let Option::Some(pledger) = pledges.pop_front() {
self._refund(pledger);
};
Expand Down
12 changes: 6 additions & 6 deletions listings/applications/crowdfunding/src/campaign/pledgeable.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub trait IPledgeable<TContractState> {
fn add(ref self: TContractState, pledger: ContractAddress, amount: u256);
fn get(self: @TContractState, pledger: ContractAddress) -> u256;
fn get_pledger_count(self: @TContractState) -> u32;
fn get_pledgers_as_arr(self: @TContractState) -> Array<ContractAddress>;
fn array(self: @TContractState) -> Array<ContractAddress>;
fn get_total(self: @TContractState) -> u256;
fn remove(ref self: TContractState, pledger: ContractAddress) -> u256;
}
Expand Down Expand Up @@ -58,7 +58,7 @@ pub mod pledgeable_component {
self.pledger_count.read()
}

fn get_pledgers_as_arr(self: @ComponentState<TContractState>) -> Array<ContractAddress> {
fn array(self: @ComponentState<TContractState>) -> Array<ContractAddress> {
let mut result = array![];

let mut index = self.pledger_count.read();
Expand Down Expand Up @@ -485,7 +485,7 @@ mod tests {
}

#[test]
fn test_get_pledgers_as_arr() {
fn test_array() {
let mut pledgeable: TestingState = Default::default();
let pledger_1 = contract_address_const::<'pledger_1'>();
let pledger_2 = contract_address_const::<'pledger_2'>();
Expand All @@ -497,7 +497,7 @@ mod tests {
// 2nd pledge by pledger_2 *should not* increase the pledge count
pledgeable.add(pledger_2, 1500);

let pledgers_arr = pledgeable.get_pledgers_as_arr();
let pledgers_arr = pledgeable.array();

assert_eq!(pledgers_arr.len(), 3);
assert_eq!(pledger_3, *pledgers_arr[0]);
Expand All @@ -509,7 +509,7 @@ mod tests {
}

#[test]
fn test_get_pledgers_as_arr_1000_pledgers() {
fn test_array_1000_pledgers() {
let mut pledgeable: TestingState = Default::default();

// set up 1000 pledgers
Expand All @@ -523,7 +523,7 @@ mod tests {
i -= 1;
};

let pledgers_arr: Array::<ContractAddress> = pledgeable.get_pledgers_as_arr();
let pledgers_arr: Array::<ContractAddress> = pledgeable.array();

assert_eq!(pledgers_arr.len(), pledgers.len());

Expand Down
4 changes: 2 additions & 2 deletions listings/applications/crowdfunding/src/mock_upgrade.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ pub mod MockUpgrade {
}

fn get_pledgers(self: @ContractState) -> Array<ContractAddress> {
self.pledges.get_pledgers_as_arr()
self.pledges.array()
}

fn pledge(ref self: ContractState, amount: u256) {
Expand Down Expand Up @@ -279,7 +279,7 @@ pub mod MockUpgrade {
}

fn _refund_all(ref self: ContractState, reason: ByteArray) {
let mut pledges = self.pledges.get_pledgers_as_arr();
let mut pledges = self.pledges.array();
while let Option::Some(pledger) = pledges.pop_front() {
self._refund(pledger);
};
Expand Down

0 comments on commit 5c39c5a

Please sign in to comment.