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: earn transaction feed items #5414

Merged
merged 17 commits into from
May 17, 2024
Merged

feat: earn transaction feed items #5414

merged 17 commits into from
May 17, 2024

Conversation

MuckT
Copy link
Collaborator

@MuckT MuckT commented May 15, 2024

Description

Adds the EarnFeedItem.tsx, types and associated GraphQL queries to populate the transaction feed.

Screenshots

iOS transaction Feed iOS Details

Test plan

  • Tested locally on iOS
  • Tested locally on Android
  • Unit tests added

Related issues

Backwards compatibility

Yes

Network scalability

If a new NetworkId and/or Network are added in the future, the changes in this PR will:

  • Continue to work without code changes, OR trigger a compilation error (guaranteeing we find it when a new network is added)

Copy link

codecov bot commented May 15, 2024

Codecov Report

Attention: Patch coverage is 82.55814% with 15 lines in your changes are missing coverage. Please review.

Project coverage is 86.26%. Comparing base (99d3822) to head (8075033).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #5414      +/-   ##
==========================================
- Coverage   86.27%   86.26%   -0.02%     
==========================================
  Files         753      754       +1     
  Lines       30700    30785      +85     
  Branches     5238     5257      +19     
==========================================
+ Hits        26487    26557      +70     
- Misses       3986     4001      +15     
  Partials      227      227              
Files Coverage Δ
src/analytics/Events.tsx 100.00% <100.00%> (ø)
src/analytics/Properties.tsx 100.00% <ø> (ø)
src/icons/UpwardGraph.tsx 100.00% <100.00%> (+33.33%) ⬆️
src/transactions/feed/EarnFeedItem.tsx 100.00% <100.00%> (ø)
src/transactions/feed/TransactionFeedItemImage.tsx 94.28% <100.00%> (+0.53%) ⬆️
src/transactions/feed/queryHelper.ts 95.10% <ø> (ø)
src/transactions/types.ts 97.72% <100.00%> (+0.16%) ⬆️
src/transactions/feed/TransactionFeed.tsx 87.30% <20.00%> (-5.81%) ⬇️
src/transactions/feed/TransactionDetailsScreen.tsx 80.61% <0.00%> (-10.20%) ⬇️

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 99d3822...8075033. Read the comment docs.

transaction: EarnWithdraw | EarnDeposit | EarnClaimReward
}

export default function EarnFeedItem({ transaction }: Props) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not make 3 separate components (deposit, withdraw, reward claim)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could, I just thought this would lead to a lot of duplicate code across the components.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess these are similar enough to be in a single component, but not a fan of the multiple conditional rendering inside title and subtitle, how about something like

const TX_TYPE_TO_STRINGS = {
  'EarnDeposit': {
    title: t('earnFlow.transactionFeed.earnDepositTitle'),
    subtitle: t('...'),
  }
  ..
}

and then you can do TX_TYPE_TO_STRINGS[transaction.__typename].title / subtitle in the JSX
or you can also do a switch case similar to AmountDisplay

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used a switch in be4243d!

transaction: EarnWithdraw | EarnDeposit | EarnClaimReward
}

export default function EarnFeedItem({ transaction }: Props) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess these are similar enough to be in a single component, but not a fan of the multiple conditional rendering inside title and subtitle, how about something like

const TX_TYPE_TO_STRINGS = {
  'EarnDeposit': {
    title: t('earnFlow.transactionFeed.earnDepositTitle'),
    subtitle: t('...'),
  }
  ..
}

and then you can do TX_TYPE_TO_STRINGS[transaction.__typename].title / subtitle in the JSX
or you can also do a switch case similar to AmountDisplay

src/transactions/feed/EarnFeedItem.tsx Show resolved Hide resolved
src/transactions/feed/EarnFeedItem.tsx Show resolved Hide resolved
src/transactions/feed/TransactionDetailsScreen.tsx Outdated Show resolved Hide resolved
src/transactions/feed/EarnFeedItem.tsx Outdated Show resolved Hide resolved
src/transactions/feed/queryHelper.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@satish-ravi satish-ravi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good mostly, just a couple of BC related questions

Comment on lines +387 to +389
...EarnDepositItem
...EarnWithdrawItem
...EarnClaimRewardItem
Copy link
Contributor

@satish-ravi satish-ravi May 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one side effect of starting to query these items is that, even if the gate is off, we'll still be getting and displaying earn txs. Maybe that's ok, but just wanted to call it out. cc @silasbw

Copy link
Collaborator Author

@MuckT MuckT May 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In testing we are already displaying them currently just as swaps and a payment received.

Example from Main


function Description({ transaction }: DescriptionProps) {
const { t } = useTranslation()
const { providerName } = getDynamicConfigParams(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably a rare edge case, but in case there are multiple providers in the future, and someone is on the app version that gets the name from the dynamic config, and have earn txs from a different provider, they'll see the Aave name.. maybe one option would be to just filter by provider id (hardcoded aave-v3) for now to be extra safe?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'll have a similar issue with the bottom sheet so I think its fine for now and when we have multiple providers we can have a more robust solution.

# Conflicts:
#	locales/base/translation.json
#	src/analytics/Events.tsx
#	src/analytics/Properties.tsx
#	src/analytics/docs.ts
@MuckT MuckT enabled auto-merge May 17, 2024 19:44
@MuckT MuckT added this pull request to the merge queue May 17, 2024
Merged via the queue into main with commit 64fd9eb May 17, 2024
16 checks passed
@MuckT MuckT deleted the tomm/act-1182 branch May 17, 2024 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants