Skip to content

Commit

Permalink
✨ add get_balances method
Browse files Browse the repository at this point in the history
  • Loading branch information
tekkac committed Jan 7, 2025
1 parent ce696bc commit cd92942
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/contracts/project.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ pub trait IExternal<TContractState> {
fn cc_to_internal(self: @TContractState, cc_value_to_send: u256, token_id: u256) -> u256;

fn internal_to_cc(self: @TContractState, internal_value_to_send: u256, token_id: u256) -> u256;
fn get_balances(self: @TContractState, account: ContractAddress) -> Span<u256>;
}


Expand Down Expand Up @@ -425,6 +426,19 @@ pub mod Project {
let initial_project_supply = self.vintage.get_initial_project_cc_supply();
internal_value_to_send * vintage_supply / initial_project_supply
}

fn get_balances(self: @ContractState, account: ContractAddress) -> Span<u256> {
let mut token_ids = array![];
let mut accounts = array![];
let num_vintages = self.vintage.get_num_vintages();
for i in 0
..num_vintages {
let token_id = (i + 1).into();
token_ids.append(token_id);
accounts.append(account);
};
super::IExternal::balance_of_batch(self, accounts.span(), token_ids.span())
}
}

#[abi(embed_v0)]
Expand Down Expand Up @@ -638,3 +652,4 @@ pub mod Project {
}
}
}

0 comments on commit cd92942

Please sign in to comment.