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

Fe/activity pending sdk #1749

Closed
wants to merge 10 commits into from
Closed

Conversation

bigboydiamonds
Copy link
Collaborator

@bigboydiamonds bigboydiamonds commented Jan 7, 2024

Add MVP _Transaction component + flow (to be refactored into existing Activity/Transaction flow) that relies on Synapse SDK to track tx status for #1650

Summary by CodeRabbit

  • New Features

    • Enhanced the Portfolio Activity section with conditional rendering of "Pending" transactions.
    • Integrated account connectivity in the PortfolioTabManager to display transactions.
    • Introduced new transaction components for detailed transaction management and display.
  • Improvements

    • Implemented helper utilities for generating blockchain explorer links.
    • Developed custom hooks for transaction status tracking and state management.
  • Refactor

    • Created a Redux slice for transaction handling, including actions for managing transaction state.
  • Chores

    • Updated the main app component to include transaction updaters.
    • Added the transaction reducer to the store for state persistence.

0feb777de6897f06836eaa5c4c84623cf31c6473: synapse-interface preview link

Copy link
Contributor

coderabbitai bot commented Jan 7, 2024

Walkthrough

The recent updates involve enhancing the transaction management and UI components of the Synapse interface. A new feature is introduced to display pending transactions conditionally and manage transaction status updates more effectively. The updates integrate the wagmi hook for account information, add new components for individual and lists of transactions, establish constants for blockchain explorers, and implement custom hooks for transaction status. Redux is utilized for state management with new slices and updaters.

Changes

File Path Change Summary
.../Portfolio/Activity.tsx Modified conditional rendering logic for the "Pending" section.
.../Portfolio/PortfolioTabManager.tsx
.../slices/_transactions/updater.tsx
Added useAccount hook usage and connected address handling.
.../_Transaction/_Transaction.tsx
.../_Transaction/_Transactions.tsx
Introduced new components for displaying and managing transactions.
.../_Transaction/helpers/... Added helper functions and constants for blockchain explorer links and a custom hook for transaction status.
.../pages/_app.tsx
.../store/reducer.ts
Integrated _TransactionsUpdater and added _transactions reducer to the store.
.../slices/_transactions/hooks.ts
.../slices/_transactions/reducer.ts
Created new hooks and reducers for transaction state management in Redux.

Poem

🐇 "To the code we hop and tweak,
🌟 With every push, the future's not bleak,
💻 Transactions flow, the state's now chic,
🚀 Synapse shines, no more antique."

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit's AI:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 4

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between b8c97de and 1c5af4f.
Files selected for processing (13)
  • packages/synapse-interface/components/Portfolio/Activity.tsx (2 hunks)
  • packages/synapse-interface/components/Portfolio/PortfolioTabManager.tsx (2 hunks)
  • packages/synapse-interface/components/_Transaction/_Transaction.tsx (1 hunks)
  • packages/synapse-interface/components/_Transaction/_Transactions.tsx (1 hunks)
  • packages/synapse-interface/components/_Transaction/helpers/constants.ts (1 hunks)
  • packages/synapse-interface/components/_Transaction/helpers/getExplorerAddressLink.ts (1 hunks)
  • packages/synapse-interface/components/_Transaction/helpers/getTxBlockExplorerLink.ts (1 hunks)
  • packages/synapse-interface/components/_Transaction/helpers/useBridgeTxStatus.tsx (1 hunks)
  • packages/synapse-interface/pages/_app.tsx (2 hunks)
  • packages/synapse-interface/slices/_transactions/hooks.ts (1 hunks)
  • packages/synapse-interface/slices/_transactions/reducer.ts (1 hunks)
  • packages/synapse-interface/slices/_transactions/updater.tsx (1 hunks)
  • packages/synapse-interface/store/reducer.ts (2 hunks)
Files skipped from review due to trivial changes (1)
  • packages/synapse-interface/components/_Transaction/helpers/constants.ts
Additional comments: 8
packages/synapse-interface/slices/_transactions/hooks.ts (1)
  • 4-6: The use_TransactionsState hook correctly uses the useAppSelector custom hook to access the _transactions slice of the Redux state.
packages/synapse-interface/slices/_transactions/updater.tsx (1)
  • 9-37: The Updater component is implemented correctly, following React and Redux best practices for managing side effects in the application state.
packages/synapse-interface/store/reducer.ts (1)
  • 24-24: The addition of the _transactions reducer to the persistedReducers object is correctly implemented for setting up persisted state in Redux.
packages/synapse-interface/components/_Transaction/_Transactions.tsx (1)
  • 9-60: The _Transactions component is implemented correctly, using hooks for state and effect management, and conditionally rendering transaction details based on the state.
packages/synapse-interface/components/_Transaction/helpers/useBridgeTxStatus.tsx (1)
  • 15-79: The useBridgeTxStatus hook is implemented correctly, managing the status of a bridge transaction and following React best practices for custom hooks and state management.
packages/synapse-interface/components/Portfolio/PortfolioTabManager.tsx (1)
  • 1-15: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [1-40]

The changes to the PortfolioTabManager component, including the use of useAccount from 'wagmi' and the inclusion of the _Transactions component with the connectedAddress prop, are correctly implemented.

packages/synapse-interface/pages/_app.tsx (1)
  • 141-141: The addition of the _TransactionsUpdater component to the Updaters function is correctly implemented, following the common pattern for global updaters in Next.js applications.
packages/synapse-interface/components/Portfolio/Activity.tsx (1)
  • 232-238: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [235-279]

The commented-out section for rendering pending transactions in the Activity component may indicate ongoing development or refactoring. Ensure that this is intentional and that any necessary logic is handled elsewhere if this section is to remain commented out.

Comment on lines +3 to +15
export const getExplorerAddressLink = (chainId: number, address: string) => {
const blockExplorer = ExplorerLinks[chainId]

if (blockExplorer && address) {
const explorerUrl = `${blockExplorer}/address/${address}`
const explorerName = ExplorerNames[chainId]

return [explorerUrl, explorerName]
}

console.error('getExplorerAddressLink: ChainId or Address missing')
return [null, null]
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider improving the error handling in getExplorerAddressLink by throwing an error or returning undefined instead of [null, null] to avoid potential type issues when the function is used.

Comment on lines +3 to +15
export const getTxBlockExplorerLink = (chainId: number, txHash: string) => {
const blockExplorer = ExplorerLinks[chainId]

if (blockExplorer && txHash) {
const explorerUrl = `${blockExplorer}/tx/${txHash}`
const explorerName = ExplorerNames[chainId]

return [explorerUrl, explorerName]
}

console.error('getTxBlockExplorerLink: ChainID or Transaction Hash missing')
return [null, null]
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider improving the error handling in getTxBlockExplorerLink by throwing an error or returning undefined instead of [null, null] to avoid potential type issues when the function is used.

Comment on lines +88 to +90
clearTransactions: (transactions: _TransactionsState) => {
transactions = {} // eslint-disable-line
},
Copy link
Contributor

Choose a reason for hiding this comment

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

The clearTransactions reducer should return a new object instead of directly assigning an empty object to the transactions parameter to maintain Redux's principle of pure functions.

- transactions = {} // eslint-disable-line
+ return {}

Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
clearTransactions: (transactions: _TransactionsState) => {
transactions = {} // eslint-disable-line
},
clearTransactions: (transactions: _TransactionsState) => {
return {}
},

Comment on lines +125 to +127
const handleClearTransaction = useCallback(() => {
dispatch(removeTransaction({ originTxHash }))
}, [dispatch])
Copy link
Contributor

Choose a reason for hiding this comment

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

The useCallback hook for handleClearTransaction should include its dependencies to avoid unnecessary re-creations of the callback function.

- const handleClearTransaction = useCallback(() => {
+ const handleClearTransaction = useCallback(() => {
+ }, [originTxHash, dispatch])

Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
const handleClearTransaction = useCallback(() => {
dispatch(removeTransaction({ originTxHash }))
}, [dispatch])
const handleClearTransaction = useCallback(() => {
dispatch(removeTransaction({ originTxHash }))
}, [originTxHash, dispatch])

Copy link

codecov bot commented Jan 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (b8c97de) 52.26669% compared to head (1c5af4f) 51.80723%.

Additional details and impacted files
@@                 Coverage Diff                 @@
##              master       #1749         +/-   ##
===================================================
- Coverage   52.26669%   51.80723%   -0.45946%     
===================================================
  Files            372         360         -12     
  Lines          25588       24651        -937     
  Branches         285         285                 
===================================================
- Hits           13374       12771        -603     
+ Misses         10906       10638        -268     
+ Partials        1308        1242         -66     
Flag Coverage Δ
cctp-relayer ?
packages 92.01065% <ø> (+0.13315%) ⬆️
promexporter ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1c5af4f
Status: ✅  Deploy successful!
Preview URL: https://af737ff9.sanguine.pages.dev
Branch Preview URL: https://fe-activity-pending-sdk.sanguine.pages.dev

View logs

@trajan0x trajan0x mentioned this pull request Jan 7, 2024
33 tasks
@aureliusbtc aureliusbtc closed this Jan 7, 2024
@aureliusbtc
Copy link
Contributor

Merged into #1695

@github-actions github-actions bot deleted the fe/activity-pending-sdk branch January 7, 2024 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants