From d837dcf193fa5666cb20b088f941eed4d52880b8 Mon Sep 17 00:00:00 2001 From: nguyenhuudungz <34548156+nguyenhuudungz@users.noreply.github.com> Date: Mon, 15 Aug 2022 15:58:13 +0700 Subject: [PATCH] feat(campaign): enter now go to swap with first eligible token (#1240) --- src/pages/Campaign/CampaignButtonWithOptions.tsx | 7 ++++++- src/state/campaigns/actions.ts | 1 + src/state/campaigns/updater.tsx | 12 ++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/pages/Campaign/CampaignButtonWithOptions.tsx b/src/pages/Campaign/CampaignButtonWithOptions.tsx index 0f246bb5c5..7f99636f69 100644 --- a/src/pages/Campaign/CampaignButtonWithOptions.tsx +++ b/src/pages/Campaign/CampaignButtonWithOptions.tsx @@ -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)) diff --git a/src/state/campaigns/actions.ts b/src/state/campaigns/actions.ts index d716302688..9c625903fd 100644 --- a/src/state/campaigns/actions.ts +++ b/src/state/campaigns/actions.ts @@ -81,6 +81,7 @@ export interface CampaignData { enterNowUrl: string rewardDistribution: RewardDistribution[] campaignState: CampaignState + eligibleTokens: SerializedToken[] chainIds: string rewardChainIds: string tradingVolumeRequired: number diff --git a/src/state/campaigns/updater.tsx b/src/state/campaigns/updater.tsx index bb4992069f..97c415f1f4 100644 --- a/src/state/campaigns/updater.tsx +++ b/src/state/campaigns/updater.tsx @@ -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