From ab54497bee5680421b946797eb2219608d2a671e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20Longoni?= Date: Thu, 10 Feb 2022 13:05:29 -0300 Subject: [PATCH 1/6] remove 'already traded' message --- .../components/AffiliateStatusCheck/index.tsx | 20 +------------------ 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/src/custom/components/AffiliateStatusCheck/index.tsx b/src/custom/components/AffiliateStatusCheck/index.tsx index a9bd872bd..a4fb3e7a7 100644 --- a/src/custom/components/AffiliateStatusCheck/index.tsx +++ b/src/custom/components/AffiliateStatusCheck/index.tsx @@ -5,28 +5,22 @@ import NotificationBanner from 'components/NotificationBanner' import { useReferralAddress, useResetReferralAddress } from 'state/affiliate/hooks' import { updateAppDataHash } from 'state/affiliate/actions' import { useAppDispatch } from 'state/hooks' -import { hasTrades } from 'utils/trade' import { generateReferralMetadataDoc, uploadMetadataDocToIpfs } from 'utils/metadata' -import { retry, RetryOptions } from 'utils/retry' import { SupportedChainId } from 'constants/chains' import useParseReferralQueryParam from 'hooks/useParseReferralQueryParam' import useRecentActivity from 'hooks/useRecentActivity' import { OrderStatus } from 'state/orders/actions' -type AffiliateStatus = 'NOT_CONNECTED' | 'OWN_LINK' | 'ALREADY_TRADED' | 'ACTIVE' | 'UNSUPPORTED_NETWORK' +type AffiliateStatus = 'NOT_CONNECTED' | 'OWN_LINK' | 'ACTIVE' | 'UNSUPPORTED_NETWORK' const STATUS_TO_MESSAGE_MAPPING: Record = { NOT_CONNECTED: 'Affiliate program: Please connect your wallet to participate.', OWN_LINK: 'Affiliate program: Your affiliate code works! Any new user following this link would credit you their trading volume.', - ALREADY_TRADED: - 'Invalid affiliate code: The currently connected wallet has traded before or is already part of the affiliate program.', ACTIVE: 'Valid affiliate code: You can now do your first trade to join the program.', UNSUPPORTED_NETWORK: 'Affiliate program: Only Mainnet is supported. Please change the network to participate.', } -const DEFAULT_RETRY_OPTIONS: RetryOptions = { n: 3, minWait: 1000, maxWait: 3000 } - export default function AffiliateStatusCheck() { const appDispatch = useAppDispatch() const resetReferralAddress = useResetReferralAddress() @@ -71,18 +65,6 @@ export default function AffiliateStatusCheck() { return } - try { - // we first validate that the user hasn't already traded - const userHasTrades = await retry(() => hasTrades(chainId, account), DEFAULT_RETRY_OPTIONS).promise - if (userHasTrades) { - setAffiliateState('ALREADY_TRADED') - return - } - } catch (error) { - console.error(error) - setError('There was an error validating existing trades. Please try again later.') - return - } setAffiliateState('ACTIVE') isFirstTrade.current = true }, [referralAddress, chainId, account, fulfilledActivity.length, history, resetReferralAddress]) From f12d94e1bfb5d8ff5ef3565b5f1f2d71cd8b98d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20Longoni?= Date: Thu, 10 Feb 2022 16:19:52 -0300 Subject: [PATCH 2/6] improve ownlink message --- src/custom/components/AffiliateStatusCheck/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/custom/components/AffiliateStatusCheck/index.tsx b/src/custom/components/AffiliateStatusCheck/index.tsx index a4fb3e7a7..06c5e39ab 100644 --- a/src/custom/components/AffiliateStatusCheck/index.tsx +++ b/src/custom/components/AffiliateStatusCheck/index.tsx @@ -16,7 +16,7 @@ type AffiliateStatus = 'NOT_CONNECTED' | 'OWN_LINK' | 'ACTIVE' | 'UNSUPPORTED_NE const STATUS_TO_MESSAGE_MAPPING: Record = { NOT_CONNECTED: 'Affiliate program: Please connect your wallet to participate.', OWN_LINK: - 'Affiliate program: Your affiliate code works! Any new user following this link would credit you their trading volume.', + 'Affiliate program: Your affiliate code works! By sharing it, others would credit you their trading volume.', ACTIVE: 'Valid affiliate code: You can now do your first trade to join the program.', UNSUPPORTED_NETWORK: 'Affiliate program: Only Mainnet is supported. Please change the network to participate.', } From 2d92dce6235ec368d255a46a5753e8564c1a3e9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20Longoni?= Date: Fri, 11 Feb 2022 12:08:16 -0300 Subject: [PATCH 3/6] revert changes --- .../components/AffiliateStatusCheck/index.tsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/custom/components/AffiliateStatusCheck/index.tsx b/src/custom/components/AffiliateStatusCheck/index.tsx index 06c5e39ab..8da77d35a 100644 --- a/src/custom/components/AffiliateStatusCheck/index.tsx +++ b/src/custom/components/AffiliateStatusCheck/index.tsx @@ -5,7 +5,9 @@ import NotificationBanner from 'components/NotificationBanner' import { useReferralAddress, useResetReferralAddress } from 'state/affiliate/hooks' import { updateAppDataHash } from 'state/affiliate/actions' import { useAppDispatch } from 'state/hooks' +import { hasTrades } from 'utils/trade' import { generateReferralMetadataDoc, uploadMetadataDocToIpfs } from 'utils/metadata' +import { retry, RetryOptions } from 'utils/retry' import { SupportedChainId } from 'constants/chains' import useParseReferralQueryParam from 'hooks/useParseReferralQueryParam' import useRecentActivity from 'hooks/useRecentActivity' @@ -21,6 +23,8 @@ const STATUS_TO_MESSAGE_MAPPING: Record = { UNSUPPORTED_NETWORK: 'Affiliate program: Only Mainnet is supported. Please change the network to participate.', } +const DEFAULT_RETRY_OPTIONS: RetryOptions = { n: 3, minWait: 1000, maxWait: 3000 } + export default function AffiliateStatusCheck() { const appDispatch = useAppDispatch() const resetReferralAddress = useResetReferralAddress() @@ -65,6 +69,18 @@ export default function AffiliateStatusCheck() { return } + try { + // we first validate that the user hasn't already traded + const userHasTrades = await retry(() => hasTrades(chainId, account), DEFAULT_RETRY_OPTIONS).promise + if (userHasTrades) { + return + } + } catch (error) { + console.error(error) + setError('There was an error validating existing trades. Please try again later.') + return + } + setAffiliateState('ACTIVE') isFirstTrade.current = true }, [referralAddress, chainId, account, fulfilledActivity.length, history, resetReferralAddress]) From 9e9859f82d47f902dd2e9ec9b0ff1867861f7e62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20Longoni?= Date: Fri, 11 Feb 2022 12:11:30 -0300 Subject: [PATCH 4/6] messages improvements --- src/custom/components/AffiliateStatusCheck/index.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/custom/components/AffiliateStatusCheck/index.tsx b/src/custom/components/AffiliateStatusCheck/index.tsx index 8da77d35a..db3dd7374 100644 --- a/src/custom/components/AffiliateStatusCheck/index.tsx +++ b/src/custom/components/AffiliateStatusCheck/index.tsx @@ -19,8 +19,8 @@ const STATUS_TO_MESSAGE_MAPPING: Record = { NOT_CONNECTED: 'Affiliate program: Please connect your wallet to participate.', OWN_LINK: 'Affiliate program: Your affiliate code works! By sharing it, others would credit you their trading volume.', - ACTIVE: 'Valid affiliate code: You can now do your first trade to join the program.', - UNSUPPORTED_NETWORK: 'Affiliate program: Only Mainnet is supported. Please change the network to participate.', + ACTIVE: 'Valid affiliate code: Please do your first trade to join the program!', + UNSUPPORTED_NETWORK: 'Affiliate program works in Ethereum only. Please change the network to participate.', } const DEFAULT_RETRY_OPTIONS: RetryOptions = { n: 3, minWait: 1000, maxWait: 3000 } @@ -57,7 +57,7 @@ export default function AffiliateStatusCheck() { } if (!referralAddress.isValid) { - setError('The referral address is invalid.') + setError('Affiliate program: The referral address is invalid.') return } @@ -77,7 +77,7 @@ export default function AffiliateStatusCheck() { } } catch (error) { console.error(error) - setError('There was an error validating existing trades. Please try again later.') + setError('Affiliate program: There was an error loading trades. Please try again later.') return } @@ -93,7 +93,7 @@ export default function AffiliateStatusCheck() { appDispatch(updateAppDataHash(appDataHash)) } catch (e) { console.error(e) - setError('There was an error while uploading the referral document to IPFS. Please try again later.') + setError('Affiliate program: There was an error with uploading your referral data. Please try again later.') } } if (affiliateState === 'ACTIVE') handleReferralAddress(referralAddress) From 2fd46570eb134dea20a492ae2a7a365c94ed9be0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20Longoni?= Date: Mon, 14 Feb 2022 12:54:40 -0300 Subject: [PATCH 5/6] delete duplicate message --- src/custom/components/AffiliateStatusCheck/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/custom/components/AffiliateStatusCheck/index.tsx b/src/custom/components/AffiliateStatusCheck/index.tsx index db3dd7374..7fd43af52 100644 --- a/src/custom/components/AffiliateStatusCheck/index.tsx +++ b/src/custom/components/AffiliateStatusCheck/index.tsx @@ -133,7 +133,7 @@ export default function AffiliateStatusCheck() { if (error) { return ( - Affiliate program error: {error} + {error} ) } From e664334f3aa9bb123ac3e2bbe9098f2ba74729a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20Longoni?= Date: Wed, 16 Feb 2022 09:53:21 -0300 Subject: [PATCH 6/6] wording Co-authored-by: Leandro Boscariol --- src/custom/components/AffiliateStatusCheck/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/custom/components/AffiliateStatusCheck/index.tsx b/src/custom/components/AffiliateStatusCheck/index.tsx index 7fd43af52..1e60187ea 100644 --- a/src/custom/components/AffiliateStatusCheck/index.tsx +++ b/src/custom/components/AffiliateStatusCheck/index.tsx @@ -93,7 +93,7 @@ export default function AffiliateStatusCheck() { appDispatch(updateAppDataHash(appDataHash)) } catch (e) { console.error(e) - setError('Affiliate program: There was an error with uploading your referral data. Please try again later.') + setError('Affiliate program: There was an error while uploading your referral data. Please try again later.') } } if (affiliateState === 'ACTIVE') handleReferralAddress(referralAddress)