Skip to content

Commit

Permalink
feat: get_withdrawal_count() and fix get_withdrawal_keys()
Browse files Browse the repository at this point in the history
  • Loading branch information
0xted97 committed Sep 4, 2024
1 parent 51c1e11 commit 84d7a13
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/data/data_store.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,10 @@ trait IDataStore<TContractState> {
/// * `end` - The ending index of the withdrawal keys to retrieve.
fn get_withdrawal_keys(self: @TContractState, start: usize, end: usize) -> Array<felt252>;


/// Returns the number of withdrawals
fn get_withdrawal_count(self: @TContractState) ->u32;

/// Returns the number of withdrawals made by a specific account.
///
/// # Arguments
Expand Down Expand Up @@ -1316,10 +1320,15 @@ mod DataStore {
}
let withdrawal: Withdrawal = withdrawals[i];
keys.append(withdrawal.key);
i = i + 1;
};
keys
}

fn get_withdrawal_count(self: @ContractState) -> u32 {
self.withdrawals.read().len()
}

fn get_account_withdrawal_count(self: @ContractState, account: ContractAddress) -> u32 {
self.account_withdrawals.read(account).len()
}
Expand Down

0 comments on commit 84d7a13

Please sign in to comment.