@@ -24,7 +24,8 @@ pub mod CampaignDonation {
2424 DOUBLE_WITHDRAWAL , INSUFFICIENT_ALLOWANCE , INSUFFICIENT_BALANCE , MORE_THAN_TARGET ,
2525 NFT_NOT_CONFIGURED , OPERATION_OVERFLOW , PROTOCOL_FEE_ADDRESS_NOT_SET ,
2626 PROTOCOL_FEE_PERCENTAGE_EXCEED , REFUND_ALREADY_CLAIMED , TARGET_NOT_REACHED , TARGET_REACHED ,
27- WITHDRAWAL_FAILED , ZERO_ALLOWANCE , ZERO_AMOUNT ,
27+ WITHDRAWAL_FAILED , ZERO_ALLOWANCE , ZERO_AMOUNT , INVALID_DONATION_TOKEN ,
28+
2829 };
2930 use crate :: base :: types :: {Campaigns , DonationMetadata , Donations };
3031
@@ -164,13 +165,17 @@ pub mod CampaignDonation {
164165 #[abi(embed_v0)]
165166 impl CampaignDonationImpl of ICampaignDonation <ContractState > {
166167 fn create_campaign (
167- ref self : ContractState , campaign_ref : felt252 , target_amount : u256 ,
168+ ref self : ContractState ,
169+ campaign_ref : felt252 ,
170+ target_amount : u256 ,
171+ donation_token : ContractAddress ,
168172 ) -> u256 {
169173 let caller = get_caller_address ();
170174 let timestamp = get_block_timestamp ();
171175 let ref_campaign = campaign_ref . clone ();
172176 let campaign_target_amount = target_amount . clone ();
173- let campaign_id = self . _create_campaign (ref_campaign , campaign_target_amount );
177+ let campaign_id = self
178+ . _create_campaign (ref_campaign , campaign_target_amount , donation_token );
174179 self
175180 . emit (
176181 Event :: Campaign (
@@ -463,11 +468,15 @@ pub mod CampaignDonation {
463468 #[generate_trait]
464469 impl InternalImpl of InternalTrait {
465470 fn _create_campaign (
466- ref self : ContractState , campaign_ref : felt252 , target_amount : u256 ,
471+ ref self : ContractState ,
472+ campaign_ref : felt252 ,
473+ target_amount : u256 ,
474+ donation_token : ContractAddress ,
467475 ) -> u256 {
468476 assert (campaign_ref != '' , CAMPAIGN_REF_EMPTY );
469477 assert (! self . campaign_refs. read (campaign_ref ), CAMPAIGN_REF_EXISTS );
470478 assert (target_amount > 0 , ZERO_AMOUNT );
479+ assert (! donation_token . is_zero (), INVALID_DONATION_TOKEN );
471480 let campaign_id : u256 = self . campaign_counts. read () + 1 ;
472481 let caller = get_caller_address ();
473482 let current_balance : u256 = 0 ;
@@ -481,7 +490,7 @@ pub mod CampaignDonation {
481490 campaign_reference : campaign_ref ,
482491 is_closed : false ,
483492 is_goal_reached : false ,
484- donation_token : self . donation_token. read () ,
493+ donation_token : donation_token ,
485494 is_cancelled : false ,
486495 };
487496
@@ -497,7 +506,7 @@ pub mod CampaignDonation {
497506 let mut campaign = self . get_campaign (campaign_id );
498507 let contract_address = get_contract_address ();
499508
500- let donation_token = self . donation_token. read () ;
509+ let donation_token = campaign . donation_token;
501510 // cannot send more than target amount
502511 assert! (amount <= campaign . target_amount, " More than Target" );
503512
@@ -560,7 +569,7 @@ pub mod CampaignDonation {
560569
561570 assert (! self . campaign_withdrawn. read (campaign_id ), DOUBLE_WITHDRAWAL );
562571
563- let donation_token = self . donation_token. read () ;
572+ let donation_token = campaign . donation_token;
564573
565574 let token_dispatcher = IERC20Dispatcher { contract_address : donation_token };
566575
0 commit comments