Skip to content

Commit

Permalink
feat(campaign): enter now go to swap with first eligible token (#1240)
Browse files Browse the repository at this point in the history
  • Loading branch information
nhd98z authored Aug 15, 2022
1 parent 7ab9429 commit d837dcf
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/pages/Campaign/CampaignButtonWithOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,12 @@ export default function CampaignButtonWithOptions({
onClick={async () => {
if (type === 'enter_now') {
mixpanelHandler(MIXPANEL_TYPE.CAMPAIGN_ENTER_NOW_CLICKED, { campaign_name: campaign?.name })
window.open(campaign?.enterNowUrl + '?networkId=' + chainId)
let url = campaign?.enterNowUrl + '?networkId=' + chainId
if (campaign?.eligibleTokens?.length) {
const outputCurrency = campaign?.eligibleTokens[0].address
url += '&outputCurrency=' + outputCurrency
}
window.open(url)
} else {
mixpanelHandler(MIXPANEL_TYPE.CAMPAIGN_CLAIM_REWARDS_CLICKED, { campaign_name: campaign?.name })
await changeNetwork(chainId, () => claimRewards(chainId))
Expand Down
1 change: 1 addition & 0 deletions src/state/campaigns/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export interface CampaignData {
enterNowUrl: string
rewardDistribution: RewardDistribution[]
campaignState: CampaignState
eligibleTokens: SerializedToken[]
chainIds: string
rewardChainIds: string
tradingVolumeRequired: number
Expand Down
12 changes: 12 additions & 0 deletions src/state/campaigns/updater.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,18 @@ export default function CampaignsUpdater(): null {
chainIds: campaign.chainIds,
rewardChainIds: campaign.rewardChainIds,
tradingVolumeRequired: campaign.tradingVolumeRequired,
eligibleTokens: campaign.eligibleTokens.map(
({ chainId, name, symbol, address, logoURI, decimals }: any): SerializedToken => {
return {
chainId,
name,
symbol,
address,
logoURI,
decimals,
}
},
),
}
})
return formattedCampaigns
Expand Down

0 comments on commit d837dcf

Please sign in to comment.