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(synapse-interface): post transaction balances #2079

Merged
merged 55 commits into from
Mar 8, 2024

Conversation

bigboydiamonds
Copy link
Collaborator

@bigboydiamonds bigboydiamonds commented Feb 21, 2024

Description

  • Add function to check for a Transaction Receipt / Transaction Not Found specific error type (rooting from RPC error)
  • If executeBridge() callback bubbles a Transaction Receipt error, invoke Origin Chain balance fetch post-transaction
  • Update portfolio balances after successful executeBridge() and executeSwap() callbacks
  • Update Pool Info, User LP Balance + Staked Balance on specific Pool Page after executing addLiquidity (deposit() / removeLiquidity (withdraw() )
  • Update Pools Page for accurate LP balances (staked + unstaked totals) following executing stake() / unstake()
  • Update claimable rewards balance after executing claimStake()
  • Have isLoading state in poolDataSlice to display loading dots on Pool Data instead of entire Pool Page UI so when we refetch for pool data we don't cause entire page to refresh
  • Catch + handle tx execution errors around "Transaction Not Found" / "Timed out while waiting for transaction"

Recreation of #2035 without merging with master.

Summary by CodeRabbit

  • New Features

    • Improved deposit, withdrawal, and stake actions for a seamless user experience with enhanced error handling.
    • Implemented custom hooks for efficient state management in pool and stake functionalities.
  • Refactor

    • Enhanced functions to boost code maintainability and performance in deposit, withdrawal, and stake features.
    • Transitioned to custom hooks for improved application state management.
  • Bug Fixes

    • Addressed transaction resolution issues to ensure smoother handling of success and error cases.

9be195fd03a4d717aa758da7e4a9ff7d08f0272b: synapse-interface preview link
ac103163f2eaf88a2f64029b898cc1ae5d19e9ff: synapse-interface preview link
26db21cfa8d60cdef8c9e56cf23ac42ddefb4c32: synapse-interface preview link
7b2dd85132b41c9bb56bf846bf052b2416dfaa01: synapse-interface preview link
b14e1f5832b1e565395523dc5a8e04a489b4dcd8: synapse-interface preview link
8f1b90eec11423d38ef10b4e35fbef74b4a7c5a6: synapse-interface preview link
f8ab7f9fe169ca0fa00e814835e554fd3713a340: synapse-interface preview link
78ffcc4fada2b96c69a3fc361ba2d5aa46bce66c: synapse-interface preview link
ed2f8b8b4ad1990a3b3752343a8131063aaae963: synapse-interface preview link
1cea2f0c56923d0d7a66fd8f6cdffe86d7efc97b: synapse-interface preview link
358b9a953184ec009df529c06af69533e022cb8f: synapse-interface preview link
2ff6fdefd333d57ad03138e075d625a745b45d98: synapse-interface preview link
399b55d628a538b09c79c719fa1eea6e19fdabb7: synapse-interface preview link

Copy link
Contributor

coderabbitai bot commented Feb 21, 2024

Walkthrough

The updates across various components of the Synapse Interface aim to enhance state management, error handling, and user experience. Custom hooks replace useSelector for streamlined data access, while transaction handling improvements ensure smoother operations. Integration of actions to fetch and update portfolio balances post transactions signifies a move towards dynamic state updates.

Changes

Files Change Summary
.../poolManagement/Deposit.tsx Custom hooks for state, refined transaction handling, added balance fetch on reset.
.../poolManagement/Withdraw.tsx Custom hooks for state, optimized dispatch usage, improved error handling, balance updates post actions.
.../stake/StakeCard.tsx Added dispatch and balance fetch utilities, refactored state updates using function calls.
.../hooks/usePendingTxWrapper.tsx Altered return structure from object to array.

🐇✨
In the realm of code and flux,
Where bits and bytes do intermix,
Changes come both big and small,
With a hop, a skip, we heed the call.
Across Synapse's radiant expanse,
We refine with a coding dance.
🌟🚀🐰

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:

  • 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.
    • Open a follow-up GitHub issue for this discussion.
  • 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 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: 2

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between 7e405f3 and c5132f8.
Files selected for processing (2)
  • packages/synapse-interface/pages/state-managed-bridge/index.tsx (3 hunks)
  • packages/synapse-interface/utils/isTransactionReceiptError.ts (1 hunks)
Additional comments: 2
packages/synapse-interface/pages/state-managed-bridge/index.tsx (2)
  • 76-76: The import of isTransactionReceiptError is correctly added to enable enhanced error handling within the StateManagedBridge component. This aligns with the PR objectives to improve error handling related to transaction receipts.
  • 455-455: Increasing the timeout for transaction receipt fetching from 30,000ms to 60,000ms is a sensible adjustment given the variability of blockchain transaction times. This change should help reduce premature timeout errors, improving the user experience by allowing more time for transactions to be processed.

Copy link

codecov bot commented Feb 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 47.84792%. Comparing base (f3cb57e) to head (120b836).
Report is 8 commits behind head on master.

Additional details and impacted files
@@                 Coverage Diff                 @@
##              master       #2079         +/-   ##
===================================================
- Coverage   47.98060%   47.84792%   -0.13269%     
===================================================
  Files            364         360          -4     
  Lines          27013       26881        -132     
  Branches          83          83                 
===================================================
- Hits           12961       12862         -99     
+ Misses         12709       12680         -29     
+ Partials        1343        1339          -4     
Flag Coverage Δ
packages 90.62500% <ø> (ø)
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

cloudflare-workers-and-pages bot commented Feb 21, 2024

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 120b836
Status: ✅  Deploy successful!
Preview URL: https://a8f1ab31.sanguine.pages.dev
Branch Preview URL: https://fe-post-transaction-balance.sanguine.pages.dev

View logs

@github-actions github-actions bot added the size/m label Mar 2, 2024
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: 0

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between 2922dd5 and b177047.
Files selected for processing (22)
  • packages/synapse-interface/components/buttons/TransactionButton.tsx (1 hunks)
  • packages/synapse-interface/components/ui/tailwind/LoadingDots.tsx (1 hunks)
  • packages/synapse-interface/pages/pool/NoPoolBody.tsx (1 hunks)
  • packages/synapse-interface/pages/pool/PoolBody.tsx (4 hunks)
  • packages/synapse-interface/pages/pool/PoolInfoSection/index.tsx (2 hunks)
  • packages/synapse-interface/pages/pool/[poolId].tsx (4 hunks)
  • packages/synapse-interface/pages/pool/poolManagement/Deposit.tsx (4 hunks)
  • packages/synapse-interface/pages/pool/poolManagement/DepositButton.tsx (2 hunks)
  • packages/synapse-interface/pages/pool/poolManagement/Withdraw.tsx (4 hunks)
  • packages/synapse-interface/pages/pool/poolManagement/WithdrawButton.tsx (2 hunks)
  • packages/synapse-interface/pages/pool/poolManagement/index.tsx (2 hunks)
  • packages/synapse-interface/pages/pools/PoolCard.tsx (3 hunks)
  • packages/synapse-interface/pages/pools/PoolCards.tsx (1 hunks)
  • packages/synapse-interface/pages/pools/index.tsx (2 hunks)
  • packages/synapse-interface/pages/stake/StakeCard.tsx (5 hunks)
  • packages/synapse-interface/slices/poolDataSlice.ts (1 hunks)
  • packages/synapse-interface/slices/poolUserDataSlice.ts (3 hunks)
  • packages/synapse-interface/slices/pools/hooks.ts (1 hunks)
  • packages/synapse-interface/slices/portfolio/reducer.ts (1 hunks)
  • packages/synapse-interface/utils/isTransactionReceiptError.ts (1 hunks)
  • packages/synapse-interface/utils/isTransactionUserRejectedError.ts (1 hunks)
  • packages/synapse-interface/utils/types/index.tsx (1 hunks)
Files skipped from review due to trivial changes (1)
  • packages/synapse-interface/components/buttons/TransactionButton.tsx
Additional comments: 29
packages/synapse-interface/components/ui/tailwind/LoadingDots.tsx (1)
  • 9-9: The simplification of the conditional class assignment for the shift prop in the LoadingDots component looks good and should make the code more readable. However, please ensure that the visual layout remains consistent with this change, especially when shift is false.
packages/synapse-interface/utils/isTransactionUserRejectedError.ts (1)
  • 3-19: The implementation of isTransactionUserRejectedError function is well-structured, correctly identifying UserRejectedRequestError instances and matching specific error messages. It's recommended to add a comment explaining the regex pattern used for matching error messages for future maintainability.
packages/synapse-interface/slices/pools/hooks.ts (1)
  • 4-18: The custom hooks introduced for accessing pool-related states (usePoolDataState, usePoolUserDataState, usePoolWithdrawState, and usePoolDepositState) are correctly implemented using useAppSelector. This approach enhances modularity and maintainability by encapsulating state access logic within dedicated hooks.
packages/synapse-interface/utils/isTransactionReceiptError.ts (1)
  • 6-27: The implementation of isTransactionReceiptError function is comprehensive, correctly identifying instances of WaitForTransactionReceiptTimeoutError and TransactionNotFoundError, as well as matching specific error messages. It's recommended to add a comment explaining the regex pattern used for matching error messages for future maintainability.
packages/synapse-interface/pages/pools/PoolCards.tsx (1)
  • 3-3: Reordering import statements to bring PoolCard above LoaderIcon is generally safe and may improve code organization. However, please ensure there are no unintended side effects due to this change, especially if any of the modules have side effects upon import.
packages/synapse-interface/pages/pool/NoPoolBody.tsx (1)
  • 4-5: Reordering import statements for getNetworkTextColor and CHAINS_BY_ID is generally safe and may improve code organization. However, please ensure there are no unintended side effects due to this change, especially if any of the modules have side effects upon import.
packages/synapse-interface/pages/pool/poolManagement/index.tsx (1)
  • 1-15: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [3-83]

The refactoring to use custom hooks (useAppDispatch, usePoolDataState, usePoolUserDataState) for Redux state management and dispatch in poolManagement/index.tsx is well-implemented, enhancing code readability and maintainability. Additionally, the reordering of imports improves code organization. Please ensure that all functionalities remain consistent after these changes.

packages/synapse-interface/slices/poolUserDataSlice.ts (1)
  • 45-62: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [19-59]

The addition of the stakedBalance field to the PoolUserData interface and the update to the fetchPoolUserData function to include staked balance data are well-implemented. These changes enhance the data model and improve the application's functionality by providing more comprehensive user data. Ensure that the getStakedBalance function is thoroughly tested to confirm accurate data fetching.

packages/synapse-interface/pages/pool/PoolInfoSection/index.tsx (1)
  • 21-69: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [10-66]

The update to the PoolInfoSection component to use usePoolDataState for fetching pool data and handling loading states is well-implemented. This change simplifies state access and improves code readability. Additionally, the conditional rendering based on isLoading enhances the user experience by providing visual feedback during data loading. Ensure that all functionalities remain consistent after these changes.

packages/synapse-interface/pages/pool/[poolId].tsx (1)
  • 1-23: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [4-90]

The updates in [poolId].tsx, including the use of custom hooks for state management and dispatch (usePoolDataState, useAppDispatch), and the addition of a new useEffect for fetching user pool data, are well-implemented. These changes enhance code organization, readability, and functionality. Additionally, the reordering of imports improves code readability. Please ensure that all functionalities remain consistent after these changes.

packages/synapse-interface/pages/pool/poolManagement/WithdrawButton.tsx (1)
  • 2-9: The updates in WithdrawButton.tsx, including the use of custom hooks (usePoolDataState, usePoolWithdrawState, usePoolUserDataState) for state access, reorganization of imports, and refactoring of state initialization and logic, are well-implemented. These changes enhance code readability, maintainability, and functionality. Ensure that the logic related to poolDecimals, needsInput, and isBalanceEnough is thoroughly tested to confirm accurate behavior.
packages/synapse-interface/slices/poolDataSlice.ts (1)
  • 41-41: Setting the initial isLoading state to true in poolDataSlice.ts is a good practice, as it accurately reflects the state of data fetching and enhances the user experience by indicating that data is being loaded. This change is well-implemented and should ensure that users are provided with a loading indicator until the data is fully loaded.
packages/synapse-interface/slices/portfolio/reducer.ts (1)
  • 88-97: The handling of poolTokenBalances in the fetchAndStoreSingleNetworkPortfolioBalances.fulfilled case is a valuable addition, enhancing the portfolioSlice reducer by including pool token balances in the state. This change improves the comprehensiveness and functionality of the portfolio state management. Ensure that the logic for merging balances and poolTokenBalances into the state is thoroughly tested to confirm accurate state updates.
packages/synapse-interface/pages/pool/poolManagement/Deposit.tsx (7)
  • 4-4: The addition of formatBigIntToString import aligns with the changes made in the file to handle big integer formatting. This is a good practice for handling large numbers accurately in blockchain applications.
  • 16-17: The imports of isTransactionReceiptError and isTransactionUserRejectedError utilities are crucial for the enhanced error handling mechanism described in the PR objectives. These utilities will allow for more precise error handling related to transaction receipts and user-rejected transactions.
  • 35-38: The replacement of useSelector with custom hooks usePoolDataState, usePoolUserDataState, and usePoolDepositState is a positive change towards more modular and readable code. Custom hooks can encapsulate complex logic and state management, making the component cleaner and easier to understand.
  • 33-33: The addition of fetchAndStoreSingleNetworkPortfolioBalances import indicates an enhancement in balance fetching post-transaction, as mentioned in the PR objectives. This is a significant improvement for ensuring that the user's balance information is accurate and up-to-date.
  • 177-182: The onSuccessDeposit function now dispatches additional actions to fetch pool data, user data, and update the portfolio balances. This ensures that the application state is synchronized with the blockchain state after a successful deposit, aligning with the PR's objective to improve balance fetching and user experience.
  • 200-203: Extending the transaction receipt timeout to 60 seconds (line 202) is a thoughtful adjustment to accommodate longer blockchain confirmation times. This change reduces the likelihood of prematurely triggering error handling mechanisms due to network delays, which is in line with the PR objectives.
  • 207-213: The error handling logic in the depositTxn function now includes a check for transaction receipt errors using isTransactionReceiptError. Assuming transaction success in case of a receipt error (likely due to RPC issues) and calling onSuccessDeposit is a strategic decision to improve user experience under specific error conditions. However, this approach assumes that the transaction will eventually succeed, which might not always be the case. It's important to monitor the impact of this assumption on user experience and system reliability.
packages/synapse-interface/pages/pool/poolManagement/Withdraw.tsx (6)
  • 5-6: The addition of waitForTransaction and useAppDispatch imports supports the enhancements made in this file, particularly in asynchronous transaction handling and Redux state management. Using useAppDispatch is a best practice for dispatching actions in a React-Redux application.
  • 17-18: The imports of isTransactionReceiptError and isTransactionUserRejectedError utilities are essential for the enhanced error handling mechanism. These utilities will allow for more precise error handling related to transaction receipts and user-rejected transactions, similar to the changes in Deposit.tsx.
  • 30-33: Replacing useSelector with custom hooks usePoolDataState, usePoolUserDataState, and usePoolWithdrawState is a positive change towards more modular and readable code. Custom hooks encapsulate complex logic and state management, making the component cleaner and easier to understand.
  • 202-207: The onSuccessWithdraw function now dispatches additional actions to fetch pool data, user data, and update the portfolio balances. This ensures that the application state is synchronized with the blockchain state after a successful withdrawal, aligning with the PR's objective to improve balance fetching and user experience.
  • 227-230: Extending the transaction receipt timeout to 60 seconds (line 229) is a thoughtful adjustment to accommodate longer blockchain confirmation times. This change reduces the likelihood of prematurely triggering error handling mechanisms due to network delays, which is in line with the PR objectives.
  • 234-240: The error handling logic in the withdrawTxn function now includes a check for transaction receipt errors using isTransactionReceiptError. Assuming transaction success in case of a receipt error (likely due to RPC issues) and calling onSuccessWithdraw is a strategic decision to improve user experience under specific error conditions. However, this approach assumes that the transaction will eventually succeed, which might not always be the case. It's important to monitor the impact of this assumption on user experience and system reliability.
packages/synapse-interface/pages/stake/StakeCard.tsx (3)
  • 26-27: The addition of useAppDispatch and fetchAndStoreSingleNetworkPortfolioBalances imports supports the enhancements made in this file, particularly in Redux state management and balance updating after staking actions. This aligns with the PR's objective to ensure accurate user balance updates.
  • 315-320: Dispatching fetchAndStoreSingleNetworkPortfolioBalances after a successful stake action ensures that the user's balance information is updated and accurate. This is a significant improvement for ensuring that users have access to the most current information regarding their assets after staking.
  • 345-350: Similarly, dispatching fetchAndStoreSingleNetworkPortfolioBalances after a successful unstake action ensures that the user's balance information is accurate and up-to-date. This aligns with the PR's objective to improve balance fetching and user experience in the context of staking actions.

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: 1

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between b177047 and a7aa01c.
Files selected for processing (2)
  • packages/synapse-interface/components/StateManagedSwap/SwapInputContainer.tsx (2 hunks)
  • packages/synapse-interface/pages/swap/index.tsx (5 hunks)
Additional comments: 6
packages/synapse-interface/components/StateManagedSwap/SwapInputContainer.tsx (1)
  • 55-57: The addition of a conditional check to set showValue to initialState.swapFromValue when swapFromValue equals initialState.swapFromValue is a logical enhancement. This ensures that the displayed value resets to the initial state under specific conditions, which can improve user experience by providing a clear and expected behavior when interacting with the swap input field. However, ensure that this behavior is consistent with the overall application logic and user expectations.
packages/synapse-interface/pages/swap/index.tsx (5)
  • 18-18: The addition of waitForTransaction from @wagmi/core is appropriate for handling asynchronous transaction confirmations. This utility will be crucial for implementing the extended transaction receipt timeout and ensuring that the application waits for a transaction to be confirmed or times out accordingly.
  • 34-36: Importing fetchAndStoreSingleNetworkPortfolioBalances from @/slices/portfolio/hooks is a strategic move to facilitate the updating of portfolio balances upon successful transaction execution. This aligns with the PR's objective to enhance the user experience by ensuring that balance information is accurate and up-to-date.
  • 49-49: The addition of isTransactionReceiptError from @/utils/isTransactionReceiptError is crucial for the improved error handling mechanism. This utility function will allow the application to distinguish transaction receipt errors from other types of errors, enabling more targeted and effective error responses.
  • 244-253: The implementation of the onSuccessSwap function is well-designed to update the portfolio balances and reset relevant state upon a successful swap. This function is a key part of the PR's objective to enhance the user experience by ensuring that users have access to the most current information regarding their assets after a transaction. It's important to ensure that this function is called in all appropriate success scenarios to maintain consistency and accuracy in the application's state.
  • 310-313: Extending the transaction receipt timeout to 60,000 milliseconds (60 seconds) is a thoughtful adjustment to accommodate scenarios where transaction confirmation may take longer than previously anticipated. This change reduces the likelihood of prematurely triggering error handling mechanisms, aligning with the PR's objective to improve reliability in the transaction process. Ensure that this extended timeout is tested across different network conditions to validate its effectiveness.

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: 0

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between a7aa01c and 704c2f0.
Files selected for processing (2)
  • packages/synapse-interface/pages/pool/poolManagement/Deposit.tsx (4 hunks)
  • packages/synapse-interface/pages/pool/poolManagement/Withdraw.tsx (4 hunks)
Additional comments: 11
packages/synapse-interface/pages/pool/poolManagement/Deposit.tsx (6)
  • 4-4: The addition of formatBigIntToString import indicates an enhancement in handling big integer values for display purposes. Ensure that this utility is used consistently throughout the file for any big integer formatting needs.
  • 16-17: The imports of isTransactionReceiptError and isTransactionUserRejectedError utilities are crucial for the enhanced error handling mechanism described in the PR objectives. It's important to verify that these utilities are implemented correctly and used in all relevant transaction handling scenarios within this file.
  • 35-38: Replacing useSelector with custom hooks usePoolDataState, usePoolUserDataState, and usePoolDepositState is a positive change towards more modular and readable code. Ensure that these hooks are properly implemented and that their usage does not introduce any unintended side effects.
  • 33-33: The addition of fetchAndStoreSingleNetworkPortfolioBalances import suggests an enhancement in fetching and updating user balance information post-transaction. This aligns with the PR objectives to ensure accurate balance updates. Verify that this action is dispatched correctly in the relevant transaction handling scenarios.
  • 177-182: The onResetDeposit function has been updated to dispatch additional actions, including fetching pool data, user data, and single network portfolio balances. This is a significant improvement in ensuring that the application state is updated accurately post-transaction. However, ensure that these dispatches are necessary and do not result in redundant network requests.
  • 196-213: The modifications in the depositTxn function to handle transaction resolution and success cases, including the use of isTransactionReceiptError and isTransactionUserRejectedError, are crucial for the enhanced error handling mechanism. It's important to ensure that these changes correctly handle all possible transaction outcomes and that the error handling logic is robust.
packages/synapse-interface/pages/pool/poolManagement/Withdraw.tsx (5)
  • 5-5: The addition of waitForTransaction import is essential for implementing the extended transaction receipt timeout functionality. This aligns with the PR objectives to accommodate longer confirmation times. Ensure that this utility is used correctly in transaction handling scenarios.
  • 6-6: The use of useAppDispatch instead of the generic useDispatch hook from react-redux suggests a move towards a more typed approach in dispatching actions. This is a good practice for maintaining type safety in Redux action dispatches. Verify that useAppDispatch is implemented correctly and provides the necessary type definitions.
  • 30-33: Replacing useSelector with custom hooks usePoolDataState, usePoolUserDataState, and usePoolWithdrawState is consistent with the changes made in Deposit.tsx. This enhances code modularity and readability. Ensure that these hooks are properly implemented and used correctly throughout the file.
  • 202-206: The onResetWithdraw function has been updated to dispatch additional actions, including fetching pool data, user data, and single network portfolio balances. This ensures that the application state is accurately updated post-transaction. Verify that these dispatches are necessary and do not result in redundant network requests.
  • 223-240: The modifications in the withdrawTxn function to handle transaction resolution and success cases, including the use of isTransactionReceiptError and isTransactionUserRejectedError, are crucial for the enhanced error handling mechanism. Ensure that these changes correctly handle all possible transaction outcomes and that the error handling logic is robust.

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: 2

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between 704c2f0 and ccf06a6.
Files selected for processing (2)
  • packages/synapse-interface/pages/stake/StakeCard.tsx (7 hunks)
  • packages/synapse-interface/utils/hooks/usePendingTxWrapper.tsx (1 hunks)
Additional comments: 10
packages/synapse-interface/utils/hooks/usePendingTxWrapper.tsx (1)
  • 25-25: The change from an object to an array return type in usePendingTxWrapper simplifies the usage of this hook. Ensure that all instances where this hook is used have been updated to match the new return type.
packages/synapse-interface/pages/stake/StakeCard.tsx (9)
  • 26-27: Added imports for useAppDispatch and fetchAndStoreSingleNetworkPortfolioBalances are correctly placed and necessary for the new functionality introduced in this file.
  • 36-36: Initialization of dispatch using useAppDispatch is correctly implemented and follows Redux best practices for dispatching actions within functional components.
  • 60-65: The resetUserStakeData function correctly resets the user stake data state. This is a good practice for managing local component state, especially when the state needs to be reset based on certain conditions or events.
  • 105-108: The use of resetUserStakeData within a useEffect hook to reset state based on certain conditions is a good practice. It ensures that the component state remains consistent with the application's current state.
  • 113-117: Another instance of using resetUserStakeData within a useEffect hook correctly resets the component state based on the lpTokenBalance dependency.
  • 122-122: The call to getUserLpTokenAllowance within a useEffect hook based on the deposit dependency is correctly implemented, ensuring that the allowance is fetched whenever the deposit state changes.
  • 178-194: The onClick handler for the claim button correctly wraps the claimStake function call with pendingTxWrapFunc. This ensures that the UI can react to the pending state of the transaction. However, ensure that the transaction status check (tx?.status === 'success') aligns with the expected response structure from claimStake.

Verify that the transaction status check (tx?.status === 'success') in the onClick handler for the claim button aligns with the expected response structure from claimStake.

  • 328-333: Dispatching fetchAndStoreSingleNetworkPortfolioBalances after a successful stake operation is a good practice for ensuring that the UI reflects the most current data. This aligns with the PR's objective of updating portfolio balances in real-time.
  • 357-362: Similarly, dispatching fetchAndStoreSingleNetworkPortfolioBalances after a successful unstake operation ensures that the portfolio balances are updated in real-time, adhering to the PR's objectives.

packages/synapse-interface/pages/stake/StakeCard.tsx Outdated Show resolved Hide resolved
packages/synapse-interface/pages/stake/StakeCard.tsx Outdated Show resolved Hide resolved
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: 2

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between ccf06a6 and 0484f20.
Files selected for processing (1)
  • packages/synapse-interface/pages/stake/StakeCard.tsx (8 hunks)
Additional comments: 6
packages/synapse-interface/pages/stake/StakeCard.tsx (6)
  • 3-4: The addition of useAppDispatch and fetchAndStoreSingleNetworkPortfolioBalances imports aligns with the PR objectives of refactoring code for better state management and updating portfolio balances post-transaction. These changes are appropriate for the intended enhancements.
  • 33-33: Initialization of dispatch using useAppDispatch is a good practice for managing application state within React components. This change supports the PR's objective of code refactoring for precise state management.
  • 57-62: The resetUserStakeData function is a clean and effective way to reset user stake data to its initial state. This approach enhances maintainability and readability of the code.
  • 102-105: The use of useEffect hooks to reset user stake data and fetch user staked balance and LP token allowance upon changes in relevant dependencies is a good practice. It ensures that the component state is updated in response to changes, aligning with the PR's objectives for real-time data updates and improved UI responsiveness.

Also applies to: 110-114, 119-119

  • 181-191: The asynchronous onClick handler within the Button component for claiming stakes correctly wraps the operation in pendingTxWrapFunc and updates the user's staked balance upon success. This implementation supports the PR's objectives of enhancing error handling and updating portfolio balances post-transaction. Ensure that error handling is robust for the asynchronous operation.
  • 312-318: Dispatch calls to fetchAndStoreSingleNetworkPortfolioBalances on successful stake, approve, and unstake actions are correctly implemented. These calls are crucial for updating portfolio balances post-transaction, aligning with the PR objectives. It's important to ensure that these dispatch calls are tested thoroughly to confirm that the portfolio balances are updated accurately.

Also applies to: 332-337, 361-366

Verification successful

The verification process has confirmed that dispatch calls to fetchAndStoreSingleNetworkPortfolioBalances are correctly implemented across various transaction types, including stake, approve, unstake, swap, bridge, and pool management actions. These calls are made conditionally based on the success of the transactions, aligning with the PR objectives to update portfolio balances post-transaction accurately. The evidence supports the accuracy of the review comment regarding the implementation of these dispatch calls.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify dispatch calls update portfolio balances accurately
# This script is a placeholder for manual testing procedures or automated tests that should be conducted.
echo "Manual testing or automated tests should verify that portfolio balances are updated accurately after dispatch calls."

Length of output: 242



Script:

#!/bin/bash
# Search for occurrences of `fetchAndStoreSingleNetworkPortfolioBalances` following successful transactions
rg "fetchAndStoreSingleNetworkPortfolioBalances" --context 5

Length of output: 21558

packages/synapse-interface/pages/stake/StakeCard.tsx Outdated Show resolved Hide resolved
packages/synapse-interface/pages/stake/StakeCard.tsx Outdated Show resolved Hide resolved
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: 2

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between 0484f20 and ab98920.
Files selected for processing (1)
  • packages/synapse-interface/pages/stake/StakeCard.tsx (8 hunks)
Additional comments: 7
packages/synapse-interface/pages/stake/StakeCard.tsx (7)
  • 3-4: The addition of useAppDispatch and fetchAndStoreSingleNetworkPortfolioBalances imports aligns with the PR objectives of refactoring code for better state management and updating portfolio balances post-transaction. These changes are appropriate and follow best practices for Redux toolkit usage in a React application.
  • 33-33: Initialization of dispatch using useAppDispatch is correctly implemented. This is a standard practice for dispatching actions in a Redux toolkit-based application and is necessary for the new dispatch calls added in this PR.
  • 57-62: The resetUserStakeData function correctly resets the user stake data state. This function is crucial for ensuring that the user's stake data is accurately reset under certain conditions, such as when the user's address or chain ID changes. It's a good practice to encapsulate state updates in functions for better readability and maintainability.
  • 184-190: The logic to fetch the user's staked balance upon successful claim stake transaction is correctly implemented. This ensures that the UI reflects the most recent data after a transaction. It's a good practice to update relevant data after transactions to maintain UI consistency and accuracy.
  • 312-318: The call to getUserLpTokenAllowance after a successful approval transaction is a good practice. It ensures that the allowance state is updated to reflect the new allowance, which is crucial for the UI to display the correct information to the user.
  • 332-337: Dispatching fetchAndStoreSingleNetworkPortfolioBalances after a successful stake transaction is aligned with the PR objectives of updating portfolio balances post-transaction. This is a crucial step to ensure that the portfolio balances are accurate and up-to-date, enhancing the user experience.
  • 361-366: Similarly, dispatching fetchAndStoreSingleNetworkPortfolioBalances after a successful unstake transaction ensures that the portfolio balances are updated accordingly. This consistency in handling portfolio balance updates after transactions is commendable and improves the reliability of the displayed data.

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: 0

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between ab98920 and f506554.
Files selected for processing (1)
  • packages/synapse-interface/pages/pool/PoolInfoSection/index.tsx (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/synapse-interface/pages/pool/PoolInfoSection/index.tsx

@bigboydiamonds bigboydiamonds changed the title Fe/post transaction balance feat(synapse-interface): post transaction balances Mar 7, 2024
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: 0

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between f506554 and 8f7f5dd.
Files selected for processing (2)
  • packages/synapse-interface/pages/pool/PoolBody.tsx (4 hunks)
  • packages/synapse-interface/pages/state-managed-bridge/index.tsx (3 hunks)
Files skipped from review as they are similar to previous changes (2)
  • packages/synapse-interface/pages/pool/PoolBody.tsx
  • packages/synapse-interface/pages/state-managed-bridge/index.tsx

@abtestingalpha abtestingalpha merged commit 2a95040 into master Mar 8, 2024
42 checks passed
@abtestingalpha abtestingalpha deleted the fe/post-transaction-balance branch March 8, 2024 02:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants