Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(hack): Add CTA for live links rewards #6387

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/abis/IWalletJumpstart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,25 @@ const jumpstart = {
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{
internalType: 'address',
name: '',
type: 'address',
},
],
name: 'referrer',
outputs: [
{
internalType: 'address',
name: '',
type: 'address',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{
Expand Down
2 changes: 1 addition & 1 deletion src/app/reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const initialState = {
fiatConnectCashInEnabled: REMOTE_CONFIG_VALUES_DEFAULTS.fiatConnectCashInEnabled,
fiatConnectCashOutEnabled: REMOTE_CONFIG_VALUES_DEFAULTS.fiatConnectCashOutEnabled,
coinbasePayEnabled: REMOTE_CONFIG_VALUES_DEFAULTS.coinbasePayEnabled,
showSwapMenuInDrawerMenu: REMOTE_CONFIG_VALUES_DEFAULTS.showSwapMenuInDrawerMenu,
showSwapMenuInDrawerMenu: true,
maxSwapSlippagePercentage: REMOTE_CONFIG_VALUES_DEFAULTS.maxSwapSlippagePercentage,
inviterAddress: null,
networkTimeoutSeconds: REMOTE_CONFIG_VALUES_DEFAULTS.networkTimeoutSeconds,
Expand Down
2 changes: 1 addition & 1 deletion src/dappsExplorer/DappFeaturedActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ interface Props {
style?: StyleProp<ViewStyle>
}

function FeaturedAction({ title, description, Image, style, onPress }: Props) {
export function FeaturedAction({ title, description, Image, style, onPress }: Props) {
return (
<Touchable
style={[styles.pressableCard, style]}
Expand Down
17 changes: 17 additions & 0 deletions src/home/TabHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useTranslation } from 'react-i18next'
import { FlatList, RefreshControl, RefreshControlProps, StyleSheet } from 'react-native'
import Animated from 'react-native-reanimated'
import { SafeAreaView, useSafeAreaInsets } from 'react-native-safe-area-context'
import { Colors } from 'react-native/Libraries/NewAppScreen'
import { showMessage } from 'src/alert/actions'
import { AppState } from 'src/app/actions'
import {
Expand All @@ -14,6 +15,7 @@ import {
showNotificationSpotlightSelector,
} from 'src/app/selectors'
import { ALERT_BANNER_DURATION, DEFAULT_TESTNET, SHOW_TESTNET_BANNER } from 'src/config'
import { FeaturedAction } from 'src/dappsExplorer/DappFeaturedActions'
import ActionsCarousel from 'src/home/ActionsCarousel'
import NotificationBox from 'src/home/NotificationBox'
import { refreshAllBalances, visitHome } from 'src/home/actions'
Expand All @@ -24,7 +26,9 @@ import {
showNftCelebrationSelector,
showNftRewardSelector,
} from 'src/home/selectors'
import Trophy from 'src/icons/Trophy'
import { importContacts } from 'src/identity/actions'
import { navigate } from 'src/navigator/NavigationService'
import { Screens } from 'src/navigator/Screens'
import { StackParamList } from 'src/navigator/types'
import { phoneRecipientCacheSelector } from 'src/recipients/reducer'
Expand Down Expand Up @@ -129,6 +133,19 @@ function TabHome(_props: Props) {
key: 'NotificationBox',
component: <NotificationBox showOnlyHomeScreenNotifications={true} />,
},
{
key: 'ReferralCTA',
component: (
<FeaturedAction
title={'Refer your friends to earn rewards'}
description={
'Send your friend a live link and start earning a portion of the revenue they generate.'
}
Image={<Trophy color={Colors.black} />}
onPress={() => navigate(Screens.JumpstartEnterAmount)}
/>
),
},
{
key: 'TransactionFeed',
component: <TransactionFeed />,
Expand Down
4 changes: 1 addition & 3 deletions src/jumpstart/saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ export function* jumpstartClaim(privateKey: Hex, networkId: NetworkId, walletAdd
try {
yield* put(jumpstartClaimStarted())

const contractAddress = getDynamicConfigParams(
DynamicConfigs[StatsigDynamicConfigs.WALLET_JUMPSTART_CONFIG]
).jumpstartContracts?.[networkId]?.contractAddress
const contractAddress = '0x4BefF9F9965aca255bF21407169744AbDba853A7'

if (!contractAddress) {
throw new Error(`Contract address for ${networkId} is not provided in dynamic config`)
Expand Down
2 changes: 1 addition & 1 deletion src/jumpstart/usePrepareJumpstartTransactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export function usePrepareJumpstartTransactions() {
}

const baseTransactions = await createBaseJumpstartTransactions(
jumpstartContractConfig.contractAddress,
'0x4BefF9F9965aca255bF21407169744AbDba853A7',
sendTokenAmountInSmallestUnit,
address,
networkId,
Expand Down
2 changes: 1 addition & 1 deletion src/navigator/selectors.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { RootState } from 'src/redux/reducers'

export const isAppSwapsEnabledSelector = (state: RootState) => state.app.showSwapMenuInDrawerMenu
export const isAppSwapsEnabledSelector = (state: RootState) => true
11 changes: 11 additions & 0 deletions src/swap/useSwapQuote.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import BigNumber from 'bignumber.js'
import { useAsyncCallback } from 'react-async-hook'
import walletJumpstart from 'src/abis/IWalletJumpstart'
import { useSelector } from 'src/redux/hooks'
import {
FetchQuoteResponse,
Expand Down Expand Up @@ -193,6 +194,15 @@ function useSwapQuote({
return null
}

const client = publicClient[networkIdToNetwork[networkId]]

const referrer = await client.readContract({
address: '0x4BefF9F9965aca255bF21407169744AbDba853A7' as Address, // Add the new WalletJumpstartHack address here
abi: walletJumpstart.abi,
functionName: 'referrer',
args: [walletAddress as Address],
})

const swapAmountParam = updatedField === Field.FROM ? 'sellAmount' : 'buyAmount'
const params = {
...(toToken.address && { buyToken: toToken.address }),
Expand All @@ -205,6 +215,7 @@ function useSwapQuote({
userAddress: walletAddress ?? '',
slippagePercentage,
...(enableAppFee === true && { enableAppFee: enableAppFee.toString() }),
referrer,
}
const queryParams = new URLSearchParams({ ...params }).toString()
const requestUrl = `${networkConfig.getSwapQuoteUrl}?${queryParams}`
Expand Down
14 changes: 14 additions & 0 deletions src/transactions/feed/TransactionFeedV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,20 @@ import {
Text,
View,
} from 'react-native'
import { Colors } from 'react-native/Libraries/NewAppScreen'
import AppAnalytics from 'src/analytics/AppAnalytics'
import { SwapEvents } from 'src/analytics/Events'
import { NotificationVariant } from 'src/components/InLineNotification'
import SectionHead from 'src/components/SectionHead'
import Toast from 'src/components/Toast'
import { FeaturedAction } from 'src/dappsExplorer/DappFeaturedActions'
import ActionsCarousel from 'src/home/ActionsCarousel'
import GetStarted from 'src/home/GetStarted'
import NotificationBox from 'src/home/NotificationBox'
import Trophy from 'src/icons/Trophy'
import { getLocalCurrencyCode } from 'src/localCurrency/selectors'
import { navigate } from 'src/navigator/NavigationService'
import { Screens } from 'src/navigator/Screens'
import { useDispatch, useSelector } from 'src/redux/hooks'
import { store } from 'src/redux/store'
import { getFeatureGate, getMultichainFeatures } from 'src/statsig'
Expand Down Expand Up @@ -515,6 +520,15 @@ export default function TransactionFeedV2() {
<>
<ActionsCarousel />
<NotificationBox showOnlyHomeScreenNotifications={true} />
<FeaturedAction
title={'Refer your friends to earn rewards'}
description={
'Send your friend a live link and start earning a portion of the revenue they generate.'
}
Image={<Trophy color={Colors.black} />}
onPress={() => navigate(Screens.JumpstartEnterAmount)}
style={{ marginLeft: 16, marginVertical: 16 }}
/>
</>
}
ListEmptyComponent={!showUKCompliantVariant ? <GetStarted /> : <NoActivity />}
Expand Down
11 changes: 1 addition & 10 deletions src/transactions/feed/TransferFeedItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ import { jumpstartReclaimFlowStarted } from 'src/jumpstart/slice'
import { navigate } from 'src/navigator/NavigationService'
import { Screens } from 'src/navigator/Screens'
import { useDispatch } from 'src/redux/hooks'
import { getDynamicConfigParams } from 'src/statsig'
import { DynamicConfigs } from 'src/statsig/constants'
import { StatsigDynamicConfigs } from 'src/statsig/types'
import colors from 'src/styles/colors'
import { typeScale } from 'src/styles/fonts'
import { Spacing } from 'src/styles/styles'
Expand Down Expand Up @@ -99,13 +96,7 @@ function TransferFeedItem({ transfer }: Props) {
}

function isJumpstartTransaction(tx: TokenTransfer) {
const jumpstartConfig = getDynamicConfigParams(
DynamicConfigs[StatsigDynamicConfigs.WALLET_JUMPSTART_CONFIG]
).jumpstartContracts[tx.networkId]
const jumpstartAddresses = [
jumpstartConfig?.contractAddress,
...(jumpstartConfig?.retiredContractAddresses ?? []),
].filter(isPresent)
const jumpstartAddresses = ['0x4BefF9F9965aca255bF21407169744AbDba853A7'].filter(isPresent)

return jumpstartAddresses.includes(tx.address)
}
Expand Down
6 changes: 3 additions & 3 deletions src/web3/networkConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,13 @@ const RESOLVE_ID_MAINNET = `${CLOUD_FUNCTIONS_MAINNET}/resolveId`

const NFTS_APP_URL = 'https://nfts.valoraapp.com/'

const GET_SWAP_QUOTE_URL = `${CLOUD_FUNCTIONS_MAINNET}/getSwapQuote`
const GET_SWAP_QUOTE_URL = `https://us-central1-celo-mobile-mainnet.cloudfunctions.net/getSwapQuoteHack`

const HOOKS_API_URL_MAINNET = `${CLOUD_FUNCTIONS_MAINNET}/hooks-api`
const HOOKS_API_URL_ALFAJORES = `${CLOUD_FUNCTIONS_STAGING}/hooks-api`

const JUMPSTART_CLAIM_URL_ALFAJORES = `${CLOUD_FUNCTIONS_STAGING}/walletJumpstart`
const JUMPSTART_CLAIM_URL_MAINNET = `${CLOUD_FUNCTIONS_MAINNET}/walletJumpstart`
const JUMPSTART_CLAIM_URL_ALFAJORES = `${CLOUD_FUNCTIONS_STAGING}/walletJumpstartHack`
const JUMPSTART_CLAIM_URL_MAINNET = `https://us-central1-celo-mobile-mainnet.cloudfunctions.net/walletJumpstartHack`

const GET_NFTS_BY_OWNER_ADDRESS_ALFAJORES = `${CLOUD_FUNCTIONS_STAGING}/getNfts`
const GET_NFTS_BY_OWNER_ADDRESS_MAINNET = `${CLOUD_FUNCTIONS_MAINNET}/getNfts`
Expand Down
Loading