Skip to content

Commit

Permalink
New smart contract (#497)
Browse files Browse the repository at this point in the history
  • Loading branch information
HamdiBenK authored Sep 14, 2023
1 parent 00089ed commit 6044a79
Showing 1 changed file with 20 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -572,12 +572,24 @@ export class PasswordModalComponent implements OnInit {
);
}

launchCampaignWithPerPerformanceReward(campaign_info: any) {
// Common logic for launching campaigns, handles date conversion and common actions.
private commonCampaignLogic(campaign_info: any, createCampaign: boolean): Observable<any> {
// Convert the start date to Unix timestamp
const startDateUnix = Math.floor(campaign_info.startDate.getTime() / 1000);
campaign_info.startDate = startDateUnix;
if(campaign_info.currency === 'BNB') campaign_info.tokenAddress = null;
return this.campaignService.createCompaign(campaign_info).pipe(

if (campaign_info.currency === 'BNB') {
campaign_info.tokenAddress = null;
}

// Determine which campaign method to call based on the 'createCampaign' flag
const campaignObservable = createCampaign
&& this.campaignService.createCompaign(campaign_info)
|| this.campaignService.launchCampaignWithBounties(campaign_info);

return campaignObservable.pipe(
tap(() => {
// Reset common UI elements and flags after campaign launch
this.gasError = false;
this.showButtonSend = true;
this.loadingButton = false;
Expand All @@ -586,17 +598,12 @@ export class PasswordModalComponent implements OnInit {
);
}

launchCampaignWithPerPublicationReward(campaign_info: any) {
return this.campaignService.launchCampaignWithBounties(campaign_info).pipe(
tap(() => {
this.gasError = false;
launchCampaignWithPerPerformanceReward(campaign_info: any) : Observable<any> {
return this.commonCampaignLogic(campaign_info, true);
}

//let _campaign_Hash = Object.assign({}, this.campaign as any);
this.showButtonSend = true;
this.loadingButton = false;
this.passwordForm.reset();
})
);
launchCampaignWithPerPublicationReward(campaign_info: any) : Observable<any> {
return this.commonCampaignLogic(campaign_info, false);
}

handleLaunchResponseError(error: any, token: any) {
Expand Down

0 comments on commit 6044a79

Please sign in to comment.