Skip to content

Conversation

mjkeaton
Copy link
Contributor

@mjkeaton mjkeaton commented Feb 26, 2025

PR Type

Enhancement, Tests, Dependencies, Other


Description

  • Added QuoteActions component and enhanced Quote and QuoteList components for better quote management and display.

  • Updated type definitions and OpenAPI specifications to include new schemas and fields like BillInfo and Witness.

  • Enhanced mock database and handlers to support new quote actions and accepted quotes.

  • Updated dependencies including tailwindcss, lucide-react, and msw, and improved development tools.

  • Refactored Breadcrumbs rendering logic for better structure and simplicity.

  • Updated favicon links for better compatibility across devices and platforms.

  • Upgraded mock service worker to version 2.7.3 with improved integrity checksum.


Changes walkthrough 📝

Relevant files
Enhancement
6 files
QuotePage.tsx
Added quote actions and enhanced quote display.                   

src/pages/quotes/QuotePage.tsx

  • Added QuoteActions component for handling quote actions like "deny"
    and "offer".
  • Enhanced Quote component to include badges for status and formatted
    bill display.
  • Integrated useMutation and useQueryClient for quote actions.
  • Improved loading indicators and conditional rendering for fetching
    states.
  • +104/-12
    QuotesPage.tsx
    Added accepted quotes and improved pending quotes display.

    src/pages/quotes/QuotesPage.tsx

  • Added QuoteListAccepted component to display accepted quotes.
  • Enhanced QuoteListPending with loading indicators and navigation.
  • Updated DevSection to include accepted and pending quotes in
    development mode.
  • Improved suspense handling for multiple quote lists.
  • +82/-15 
    types.gen.ts
    Updated type definitions for quote and bill structures.   

    src/generated/client/types.gen.ts

  • Updated InfoReply and related types to include BillInfo structure.
  • Added new types like Witness, P2PkWitness, and HtlcWitness.
  • Enhanced type definitions for quote-related data structures.
  • +53/-24 
    Breadcrumbs.tsx
    Refactored breadcrumbs rendering logic.                                   

    src/components/Breadcrumbs.tsx

  • Simplified Breadcrumbs rendering logic.
  • Improved structure for breadcrumb items and separators.
  • +4/-6     
    openapi.json
    Update OpenAPI specification for quote service with new schemas and
    paths.

    opt/wildcat/openapi.json

  • Updated the info.title field to "bcr-wdc-quote-service".
  • Modified several API paths to adjust operations and parameters,
    including switching HTTP methods and adding UUID formats.
  • Introduced new schemas such as BillInfo, BlindSignatureDleq, and
    updated existing schemas to reference BillInfo.
  • Enhanced schema descriptions and added new properties like signature
    in EnquireRequest.
  • +1/-1     
    __dev_openapi.json
    Revise development OpenAPI specification with updated paths and
    schemas.

    opt/wildcat/__dev_openapi.json

  • Changed the info.title field to "bcr-wdc-quote-service".
  • Swapped HTTP methods for certain paths and updated operation IDs.
  • Added new schemas such as BillInfo, BlindSignatureDleq, and Witness,
    and updated references in existing schemas.
  • Enhanced schema properties, including adding UUID formats and new
    fields like signature in EnquireRequest.
  • +127/-78
    Tests
    3 files
    admin_quotes.ts
    Added handlers for accepted quotes and quote updates.       

    src/mocks/handlers/admin_quotes.ts

  • Added handler for fetching accepted quotes.
  • Implemented updateAdminQuote handler for quote actions like "deny" and
    "offer".
  • Enhanced mock data handling for quotes.
  • +53/-3   
    db.ts
    Enhanced mock database schema for quotes.                               

    src/mocks/db.ts

  • Updated mock database schema to include detailed bill structure.
  • Added sample data for quotes with enhanced bill details.
  • +14/-2   
    handlers.ts
    Added new handlers for quote actions.                                       

    src/mocks/handlers.ts

  • Registered new handlers for accepted quotes and quote updates.
  • Updated handlers array to include additional quote-related endpoints.
  • +14/-2   
    Dependencies
    3 files
    mockServiceWorker.js
    Updated mock service worker version.                                         

    public/mockServiceWorker.js

  • Updated mock service worker to version 2.7.3.
  • Improved integrity checksum for the worker script.
  • +1/-1     
    package-lock.json
    Updated dependencies and added platform-specific packages.

    package-lock.json

  • Updated dependencies including tailwindcss, lucide-react, and msw.
  • Added new optional dependencies for various platforms.
  • Improved dependency integrity and versioning.
  • +661/-191
    package.json
    Updated project dependencies and development tools.           

    package.json

  • Updated versions for dependencies like tailwindcss, lucide-react, and
    msw.
  • Improved development dependencies for ESLint and TypeScript.
  • +10/-10 
    Configuration changes
    1 files
    index.html
    Updated favicon links for better compatibility.                   

    index.html

  • Updated favicon links to include additional formats and sizes.
  • Improved compatibility for different devices and platforms.
  • +3/-1     

    Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • @mjkeaton mjkeaton self-assigned this Feb 26, 2025
     @tailwindcss/vite         ^4.0.8  →    ^4.0.9
     @vitest/coverage-v8       ^3.0.6  →    ^3.0.7
     eslint-config-prettier   ^10.0.1  →   ^10.0.2
     globals                 ^15.14.0  →   ^16.0.0
     lucide-react            ^0.475.0  →  ^0.476.0
     msw                       ^2.7.1  →    ^2.7.3
     tailwindcss               ^4.0.8  →    ^4.0.9
     typescript-eslint        ^8.24.1  →   ^8.25.0
     vite                      ^6.1.1  →    ^6.2.0
     vitest                    ^3.0.6  →    ^3.0.7
    @mjkeaton mjkeaton marked this pull request as ready for review February 26, 2025 15:13
    Copy link

    Qodo Merge was enabled for this repository. To continue using it, please link your Git account with your Qodo account here.

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Hardcoded Values

    The discount and ttl values in onOfferQuote() are hardcoded to "1", which may not be appropriate for production use. These values should be configurable or passed as parameters.

      action: "offer",
      discount: "1",
      ttl: "1",
    },
    Error Handling

    The error handling in denyQuote and offerQuote mutations only logs to console without proper user feedback or error recovery mechanisms.

      ...resolveQuoteMutation(),
      onError: (error) => {
        console.log(error)
      },
      onSuccess: () => {
        void queryClient.invalidateQueries({
          queryKey: adminLookupQuoteQueryKey({
            path: {
              id: value.id,
            },
          }),
        })
      },
    })
    const offerQuote = useMutation({
      ...resolveQuoteMutation(),
      onError: (error) => {
        console.log(error)
      },
      onSuccess: () => {
        void queryClient.invalidateQueries({
          queryKey: adminLookupQuoteQueryKey({
            path: {
              id: value.id,
            },
          }),
        })
      },
    })
    Type Safety

    The quote status update in updateAdminQuote handler directly modifies the status without type checking or validation of allowed status transitions.

    if (body.action === "deny") {
      quote.status = "denied"
    }
    if (body.action === "offer") {
      quote.status = "offered"
      quote.ttl = body.ttl ?? null
    }

    Copy link

    qodo-merge-pro bot commented Feb 26, 2025

    Qodo Merge was enabled for this repository. To continue using it, please link your Git account with your Qodo account here.

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Fix incorrect query options usage

    The listPendingQuotesOptions is incorrectly used twice in DevSection - the
    second query for accepted quotes should use listAcceptedQuotesOptions instead,
    which could lead to incorrect data being displayed.

    src/pages/quotes/QuotesPage.tsx [118-120]

     const { data: quotesAccepted } = useSuspenseQuery({
    -  ...listPendingQuotesOptions({}),
    +  ...listAcceptedQuotesOptions({}),
     })
    • Apply this suggestion
    Suggestion importance[1-10]: 9

    __

    Why: This suggestion fixes a critical bug where the wrong query options are being used for accepted quotes, which would cause incorrect data to be displayed in the UI.

    High
    Security
    Add signature format validation

    Add input validation for the signature field in EnquireRequest schema to ensure
    it contains a valid cryptographic signature format. This helps prevent signature
    forgery attacks.

    opt/wildcat/openapi.json [430-432]

     "signature": {
    -  "type": "string"
    +  "type": "string",
    +  "pattern": "^[A-Fa-f0-9]{128}$",
    +  "description": "Cryptographic signature in hex format"
     }

    [To ensure code accuracy, apply this suggestion manually]

    Suggestion importance[1-10]: 8

    __

    Why: Adding strict validation for cryptographic signatures is crucial for security, preventing signature forgery attacks by ensuring proper format and length.

    Medium
    Add length constraint for ID

    Add a maximum length constraint to the id field in BillInfo schema to prevent
    potential buffer overflow attacks and ensure data consistency.

    opt/wildcat/openapi.json [308-310]

     "id": {
    -  "type": "string"
    +  "type": "string",
    +  "maxLength": 64,
    +  "description": "Unique identifier for the bill"
     }

    [To ensure code accuracy, apply this suggestion manually]

    Suggestion importance[1-10]: 7

    __

    Why: Setting a maximum length for ID fields is important for preventing buffer overflow attacks and ensuring consistent data handling across the system.

    Medium
    General
    Reduce mutation code duplication

    The quote actions (deny/offer) share identical error handling and success logic.
    Extract this common functionality into a reusable hook or utility function to
    avoid code duplication and ensure consistent behavior.

    src/pages/quotes/QuotePage.tsx [30-59]

    -const denyQuote = useMutation({
    -  ...resolveQuoteMutation(),
    -  onError: (error) => {
    -    console.log(error)
    -  },
    -  onSuccess: () => {
    -    void queryClient.invalidateQueries({
    -      queryKey: adminLookupQuoteQueryKey({
    -        path: {
    -          id: value.id,
    -        },
    -      }),
    -    })
    -  },
    -})
    -const offerQuote = useMutation({
    -  ...resolveQuoteMutation(),
    -  onError: (error) => {
    -    console.log(error)
    -  },
    -  onSuccess: () => {
    -    void queryClient.invalidateQueries({
    -      queryKey: adminLookupQuoteQueryKey({
    -        path: {
    -          id: value.id,
    -        },
    -      }),
    -    })
    -  },
    -})
    +const createQuoteAction = (action: "deny" | "offer") =>
    +  useMutation({
    +    ...resolveQuoteMutation(),
    +    onError: (error) => {
    +      console.log(error)
    +    },
    +    onSuccess: () => {
    +      void queryClient.invalidateQueries({
    +        queryKey: adminLookupQuoteQueryKey({
    +          path: { id: value.id },
    +        }),
    +      })
    +    },
    +  })
     
    +const denyQuote = createQuoteAction("deny")
    +const offerQuote = createQuoteAction("offer")
    +
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    __

    Why: The suggestion effectively reduces code duplication by extracting identical mutation logic into a reusable function, improving maintainability and reducing potential inconsistencies between quote actions.

    Medium
    • Update

    @mtbitcr
    Copy link

    mtbitcr commented Feb 27, 2025

    Hey @mjkeaton , can you check QODO code suggestions. I think 1st one maybe make sense. But im not sure

    Copy link

    codecov bot commented Mar 4, 2025

    @mjkeaton mjkeaton merged commit 347b7db into master Mar 4, 2025
    4 checks passed
    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.

    3 participants