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

refactor: remove usage of __typename for the tx feed #6186

Merged
merged 3 commits into from
Oct 28, 2024

Conversation

jeanregisser
Copy link
Member

Description

__typename was inherited from GraphQL and is not needed anymore.
It was duplicating the type property and making it a bit difficult to see which one should be used now.

Test plan

  • Tests pass

Related issues

N/A

Backwards compatibility

Almost, but the analytics event earn_feed_item_select will now return the type value instead of __typename for the origin property.

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)

@jeanregisser jeanregisser force-pushed the jeanregisser/remove-typename branch from 96934e5 to c90411f Compare October 24, 2024 17:00
Comment on lines -1617 to +1621
origin: 'EarnDeposit' | 'EarnWithdraw' | 'EarnClaimReward' | 'EarnSwapDeposit'
origin:
| TokenTransactionTypeV2.EarnDeposit
| TokenTransactionTypeV2.EarnWithdraw
| TokenTransactionTypeV2.EarnClaimReward
| TokenTransactionTypeV2.EarnSwapDeposit
Copy link
Member Author

Choose a reason for hiding this comment

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

@satish-ravi do you think this could be a problem?
The value will be different now.

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 we generally try to avoid breaking changes for analytics in case there's some dashboard dependencies. We have had instances in the past where we had to workaround to avoid this. But maybe fine here, I don't think this is a critical analytics event. Would be good to confirm with product

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks yes I'll check.

Copy link

codecov bot commented Oct 24, 2024

Codecov Report

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

Project coverage is 88.88%. Comparing base (25039d0) to head (67ad8b6).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
src/transactions/feed/TransactionFeed.tsx 42.10% 8 Missing and 3 partials ⚠️
src/transactions/feed/TransactionFeedV2.tsx 40.00% 2 Missing and 1 partial ⚠️
src/transactions/feed/TransactionDetailsScreen.tsx 91.66% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #6186      +/-   ##
==========================================
- Coverage   88.90%   88.88%   -0.02%     
==========================================
  Files         733      733              
  Lines       31142    31166      +24     
  Branches     5717     5736      +19     
==========================================
+ Hits        27686    27702      +16     
- Misses       3259     3265       +6     
- Partials      197      199       +2     
Files with missing lines Coverage Δ
src/analytics/Properties.tsx 100.00% <ø> (ø)
src/earn/saga.ts 95.58% <ø> (ø)
src/fiatExchanges/saga.ts 85.86% <100.00%> (ø)
src/fiatconnect/saga.ts 92.32% <ø> (ø)
src/firebase/notifications.ts 95.91% <ø> (ø)
src/jumpstart/saga.ts 89.87% <ø> (ø)
src/redux/migrations.ts 97.07% <100.00%> (+<0.01%) ⬆️
src/redux/store.ts 80.00% <ø> (ø)
src/send/saga.ts 77.52% <ø> (ø)
src/swap/saga.ts 94.30% <ø> (-0.05%) ⬇️
... and 18 more

... and 2 files 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 25039d0...67ad8b6. Read the comment docs.

Comment on lines -298 to +307
return <SwapFeedItem key={tx.transactionHash} transaction={tx as TokenExchange} />
return <SwapFeedItem key={tx.transactionHash} transaction={tx} />
case TokenTransactionTypeV2.Sent:
case TokenTransactionTypeV2.Received:
return <TransferFeedItem key={tx.transactionHash} transfer={tx as TokenTransfer} />
return <TransferFeedItem key={tx.transactionHash} transfer={tx} />
case TokenTransactionTypeV2.NftSent:
case TokenTransactionTypeV2.NftReceived:
return <NftFeedItem key={tx.transactionHash} transaction={tx as NftTransfer} />
return <NftFeedItem key={tx.transactionHash} transaction={tx} />
case TokenTransactionTypeV2.Approval:
return <TokenApprovalFeedItem key={tx.transactionHash} transaction={tx as TokenApproval} />
return <TokenApprovalFeedItem key={tx.transactionHash} transaction={tx} />
case TokenTransactionTypeV2.EarnDeposit:
case TokenTransactionTypeV2.EarnSwapDeposit:
case TokenTransactionTypeV2.EarnWithdraw:
case TokenTransactionTypeV2.EarnClaimReward:
return <EarnFeedItem key={tx.transactionHash} transaction={tx as TokenEarn} />
return <EarnFeedItem key={tx.transactionHash} transaction={tx} />
Copy link
Member Author

Choose a reason for hiding this comment

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

All these casts could be removed now

Copy link
Member Author

Choose a reason for hiding this comment

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

Same here, we don't need to cast anymore.

Copy link
Collaborator

@kathaypacific kathaypacific left a comment

Choose a reason for hiding this comment

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

love this!

case 'TokenExchangeV3':
case 'CrossChainTokenExchange':
switch (tx.type) {
case TokenTransactionTypeV2.Exchange:
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we need to add this exchange type? was thinking that we could remove it, since it hasn't been queried for in a long time and is not part of the graphql transactions query?

Copy link
Member Author

@jeanregisser jeanregisser Oct 28, 2024

Choose a reason for hiding this comment

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

Not anymore but without it, TS complains, I'm planning to remove this separately.

@@ -1924,4 +1924,5 @@ export const migrations = {
feedFirstPage: [],
},
}),
235: (state: any) => state,
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we need a migration for this change? it feels odd to update the root schema without incrementing the schema number but this migration doesn't remove the __typename property on persisted transactions which is the only thing that changes about the state...the persisted transactions are replaced on app start very quickly anyway?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes I decided to increase the schema number (and hence the no-op migration) to make this change more explicit.
But we could have skipped it.

@jeanregisser jeanregisser added this pull request to the merge queue Oct 28, 2024
Merged via the queue into main with commit 53d9187 Oct 28, 2024
15 checks passed
@jeanregisser jeanregisser deleted the jeanregisser/remove-typename branch October 28, 2024 11:22
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.

3 participants