Skip to content

Commit

Permalink
Merge pull request #131 from EmmanuelAR/feat/fix_test_u256_refactor
Browse files Browse the repository at this point in the history
Fix u256 test refactor
  • Loading branch information
EmmanuelAR authored Oct 11, 2024
2 parents 129a5fb + 04a7089 commit 9685c33
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 11 deletions.
1 change: 1 addition & 0 deletions contracts/src/constants/funds.cairo
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pub mod state_constants;
pub mod fund_constants;
pub mod starknet_constants;
1 change: 0 additions & 1 deletion contracts/src/constants/funds/fund_constants.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ pub mod FundConstants {
pub const UP_VOTES_NEEDED: u32 = 100;
pub const INITIAL_UP_VOTES: u32 = 0;
pub const INITIAL_GOAL: u256 = 0;
pub const STRK_TOKEN_ADDRESS: felt252 = 0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d;
}
8 changes: 8 additions & 0 deletions contracts/src/constants/funds/starknet_constants.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use starknet::ContractAddress;

// *************************************************************************
// STARKNET CONSTANTS
// *************************************************************************
pub mod StarknetConstants {
pub const STRK_TOKEN_ADDRESS: felt252 = 0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d;
}
18 changes: 10 additions & 8 deletions contracts/src/fundManager.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use starknet::class_hash::ClassHash;

#[starknet::interface]
pub trait IFundManager<TContractState> {
fn newFund(ref self: TContractState, name: felt252, goal: u64);
fn newFund(ref self: TContractState, name: felt252, goal: u256);
fn getCurrentId(self: @TContractState) -> u128;
fn getFund(self: @TContractState, id: u128) -> ContractAddress;
fn getOwner(self: @TContractState) -> ContractAddress;
Expand All @@ -21,6 +21,8 @@ mod FundManager {
use starknet::syscalls::deploy_syscall;
use starknet::class_hash::ClassHash;
use starknet::get_caller_address;
use openzeppelin::utils::serde::SerializedAppend;


// ***************************************************************************************
// STORAGE
Expand Down Expand Up @@ -48,14 +50,14 @@ mod FundManager {
// ***************************************************************************************
#[abi(embed_v0)]
impl FundManagerImpl of super::IFundManager<ContractState> {
fn newFund(ref self: ContractState, name: felt252, goal: u64) {
let mut calldata = ArrayTrait::<felt252>::new();
calldata.append(self.current_id.read().try_into().unwrap());
calldata.append(get_caller_address().try_into().unwrap());
calldata.append(name);
calldata.append(goal.try_into().unwrap());
fn newFund(ref self: ContractState, name: felt252, goal: u256) {
let mut call_data: Array<felt252> = array![];
Serde::serialize(@self.current_id.read(), ref call_data);
Serde::serialize(@get_caller_address(), ref call_data);
Serde::serialize(@name, ref call_data);
Serde::serialize(@goal, ref call_data);
let (address_0, _) = deploy_syscall(
self.fund_class_hash.read(), 12345, calldata.span(), false
self.fund_class_hash.read(), 12345, call_data.span(), false
)
.unwrap();
self.current_id.write(self.current_id.read() + 1);
Expand Down
2 changes: 1 addition & 1 deletion contracts/tests/test_fund.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn NAME() -> felt252 {
fn REASON() -> ByteArray {
"Lorem impsum, Lorem impsum, Lorem impsum, Lorem impsum, Lorem impsum, Lorem impsum, Lorem impsum, Lorem impsum"
}
fn GOAL() -> u64 {
fn GOAL() -> u256 {
1000
}
fn _setup_() -> ContractAddress {
Expand Down
2 changes: 1 addition & 1 deletion contracts/tests/test_fund_manager.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn NAME() -> felt252 {
fn REASON() -> ByteArray {
"Lorem impsum, Lorem impsum, Lorem impsum, Lorem impsum, Lorem impsum, Lorem impsum, Lorem impsum, Lorem impsum"
}
fn GOAL() -> u64 {
fn GOAL() -> u256 {
1000
}

Expand Down

0 comments on commit 9685c33

Please sign in to comment.