fedimint / ui

https://ui-umber-ten.vercel.app
MIT License
27 stars 41 forks source link

feat: Balance Sheet #424

Closed Kodylow closed 4 months ago

Kodylow commented 4 months ago

Adds a balance sheet view of all modules.

image

Summary by CodeRabbit

coderabbitai[bot] commented 4 months ago
Walkthrough ## Walkthrough The recent updates to the `guardian-ui` application primarily focus on enhancing the layout and functionality of several components, particularly within the `FederationAdmin` and `BalanceCard` components. Significant changes include the repositioning and resizing of components, the introduction of a new `BalanceTable` component, and improvements in state management and user interface elements. Additionally, there are updates to the internationalization files and type definitions to support these changes. ## Changes | File Path | Change Summary | |-----------------------------------------------------|----------------------------------------------------------------------------------------------------------| | `apps/guardian-ui/src/admin/FederationAdmin.tsx` | Adjusted layout: Repositioned `BalanceCard`, modified width of `Flex` container, moved `FederationInfoCard`. | | `apps/guardian-ui/src/components/BalanceCard.tsx` | Updated imports, removed `walletBalance` logic, added state for `unit`, updated layout, added unit selection buttons, replaced `KeyValues` with `BalanceTable`. | | `apps/guardian-ui/src/components/BalanceTable.tsx` | Introduced `BalanceTable` component, added `unit` property, formatted values based on unit, updated table layout. | | `apps/guardian-ui/src/components/FederationInfoCard.tsx` | Updated layout using `SimpleGrid` for `KeyValues` component. | | `apps/guardian-ui/src/languages/en.json` | Changed label from "Balance" to "Balance Sheet". | | `packages/types/src/modules.ts` | Added `Unknown` to `ModuleKind` enum, updated `FedimintModule` interface. | | `packages/utils/src/format.tsx` | Added `formatValue` function to format values based on unit. | ## Sequence Diagram(s) (Beta) ```mermaid sequenceDiagram participant User participant FederationAdmin participant BalanceCard participant BalanceTable User->>FederationAdmin: Access Federation Admin page FederationAdmin->>BalanceCard: Render BalanceCard BalanceCard->>BalanceTable: Pass balance data and selected unit BalanceTable-->>BalanceCard: Display formatted balance information BalanceCard-->>FederationAdmin: Display updated BalanceCard FederationAdmin-->>User: Show updated Federation Admin page ``` ```mermaid sequenceDiagram participant Developer participant TypeModule participant FormatUtil Developer->>TypeModule: Add `Unknown` to `ModuleKind` enum TypeModule-->>Developer: Updated enum and interface Developer->>FormatUtil: Add `formatValue` function FormatUtil-->>Developer: Updated utility functions ```

Recent Review Details **Configuration used: CodeRabbit UI** **Review profile: CHILL**
Commits Files that changed from the base of the PR and between ed051b95411ecf5a249dbeaa8a74ab19661e977c and e49342e5c2d6ce2ec4652d78e861f18c545089c5.
Files selected for processing (7) * apps/guardian-ui/src/admin/FederationAdmin.tsx (1 hunks) * apps/guardian-ui/src/components/BalanceCard.tsx (2 hunks) * apps/guardian-ui/src/components/BalanceTable.tsx (1 hunks) * apps/guardian-ui/src/components/FederationInfoCard.tsx (2 hunks) * apps/guardian-ui/src/languages/en.json (1 hunks) * packages/types/src/modules.ts (2 hunks) * packages/utils/src/format.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (1) * apps/guardian-ui/src/languages/en.json
Additional Context Used
Biome (13)
apps/guardian-ui/src/admin/FederationAdmin.tsx (4)
1-1: The default import is only used as a type. --- 2-7: All these imports are only used as types. --- 31-31: Use Number.parseInt instead of the equivalent global. --- 34-34: Use Number.parseInt instead of the equivalent global.
apps/guardian-ui/src/components/BalanceCard.tsx (2)
1-1: The default import is only used as a type. --- 10-11: All these imports are only used as types.
apps/guardian-ui/src/components/BalanceTable.tsx (2)
1-1: All these imports are only used as types. --- 17-18: Some named imports are only used as types.
apps/guardian-ui/src/components/FederationInfoCard.tsx (2)
1-1: The default import is only used as a type. --- 2-3: All these imports are only used as types.
packages/types/src/modules.ts (2)
1-1: All these imports are only used as types. --- 1-2: All these imports are only used as types.
packages/utils/src/format.tsx (1)
1-1: All these imports are only used as types.
Additional comments not posted (2)
packages/types/src/modules.ts (1)
`8-8`: Ensure integration of new `ModuleKind` values. The new `ModuleKind.Unknown` and configurations for `Meta` and `Unknown` are added. Verify their usage across the application to ensure proper integration. Also applies to: 48-49
Verification successful --- The new `ModuleKind.Unknown` and `ModuleKind.Meta` values are integrated into the application logic. - `ModuleKind.Unknown` is used in `apps/guardian-ui/src/components/BalanceTable.tsx`. - `ModuleKind.Meta` is used in `apps/guardian-ui/src/components/FederationConfigCard.tsx`.
Scripts Executed The following scripts were executed for the analysis: --- Script: ```shell #!/bin/bash # Description: Verify the integration of new module kinds `Meta` and `Unknown`. # Test: Search for the usage of `ModuleKind.Meta` and `ModuleKind.Unknown`. Expect: Proper handling in the application logic. rg --type typescript $'ModuleKind.Meta|ModuleKind.Unknown' ``` Length of output: 94 --- --- Script: ```shell #!/bin/bash # Description: Verify the integration of new module kinds `Meta` and `Unknown`. # Test: Search for the usage of `ModuleKind.Meta` and `ModuleKind.Unknown`. Expect: Proper handling in the application logic. rg --type ts $'ModuleKind.Meta|ModuleKind.Unknown' ``` Length of output: 459
apps/guardian-ui/src/components/BalanceTable.tsx (1)
`30-32`: Filter out the `Unknown` module to avoid confusion. The logic to filter out the `Unknown` module is correctly implemented, ensuring it does not appear in the balance calculations.
---
Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit .` - `Generate unit testing code 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 testing code 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 testing code.` - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.` - `@coderabbitai help me debug CodeRabbit configuration file.` 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 an incremental review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai full review` to full the review from scratch and review all the files again. - `@coderabbitai summary` to regenerate the summary of the PR. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository. - `@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. - Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information. - 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/schema.v2.json` ### Documentation and Community - Visit our [Documentation](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](https://discord.com/invite/GsXnASn26c) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.
Kodylow commented 4 months ago

Added a filter to now put the "unknown" module in the balance sheet, that's just there to test if it'll break clients and it doesn't have any assets/liabilities

elsirion commented 4 months ago

~That unknown module would be confusing to users imo, but it's only present in test environments afaik, so this should be fine.~

Missed your last comment.

Kodylow commented 4 months ago

Okay added an Equity (Guardian Fees) column and adjusted the check to "Is Full Reserve" checking that assets > liabilities and equity is > 0

image
Kodylow commented 4 months ago

Actually that took up a lot of real estate, moved into separate cards for Full reserve and fees calculations, if there's no fees it just doesn't show that card:

image