Skip to content

feat(tangle-cloud): manage service requests with approval flow#3116

Merged
drewstone merged 15 commits intov2from
linh/qa/manage-service-req
Feb 4, 2026
Merged

feat(tangle-cloud): manage service requests with approval flow#3116
drewstone merged 15 commits intov2from
linh/qa/manage-service-req

Conversation

@vutuanlinh2k2
Copy link
Contributor

@vutuanlinh2k2 vutuanlinh2k2 commented Feb 4, 2026

Summary

  • Add service request management with approval/rejection flow
  • Implement service request detail modal with security requirements, commitments, and payment terms
  • Add auto-fetch blueprint config for deployment workflow
  • Add time unit selector for instance duration (TTL)
  • Fix service detail page for service ID 0 and operator access
  • Update claim button text to "Claim All Rewards" in tangle-dapp

Video

CleanShot.2026-02-04.at.21.49.16.mp4

Test plan

  • Verify service request approval flow works correctly
  • Verify service request rejection flow works correctly
  • Test blueprint deployment with auto-fetched config
  • Verify TTL time unit conversions work properly
  • Confirm service detail page loads for all service IDs including 0

🤖 Generated with Claude Code

vutuanlinh2k2 and others added 14 commits February 2, 2026 10:43
…mitments (Flow 4)

- Implement useServiceApproveTx with support for simple approval (restaking %)
  and approval with security commitments (per-asset exposure)
- Implement useServiceRejectTx for rejecting service requests
- Add useServiceRequestSecurityRequirements hook to query security requirements
  from contract and resolve token metadata
- Add ExposureCommitmentInput component for per-asset exposure commitment slider
- Update ApproveConfirmationModal to support both simple and commitments modes
  with proper loading states and validation
- Update PendingInstanceTable to show operator approval/rejection status and
  pending approval count
- Add approvedOperators and rejectedOperators fields to ServiceRequest
- Add success/error snackbar notifications to useContractWrite
- Update .gitignore to exclude docs/cloud-qa

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add minimum 1% exposure validation (contract rejects 0)
- Improve permitted caller input placeholder clarity
- Fix asset info layout with consistent widths and truncation
- Update slider defaults to match contract requirements

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace seconds-only input with a user-friendly duration input that
supports hours, days, and weeks. Users can now enter values like
"7 days" instead of calculating "604800 seconds".

- Add DURATION_UNITS constant with hours/days/weeks conversion
- Add toSeconds/fromSeconds utility functions
- Update schema to track duration value and unit separately
- Add dynamic validation based on selected unit (min 1 hour, max 365 days)
- Update UI with Input + Select combo for value and unit selection
- Show dynamic helper text with valid range for selected unit

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add operator stake querying to show how many tokens are at risk when
approving service requests. The ExposureCommitmentInput now displays
the delegated amount and calculates/displays "tokens at risk" based
on the selected exposure percentage.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…e request

The TTL value was being passed directly to the contract without converting
based on the selected duration unit (hours/days/weeks). This caused
TTLBelowMinimum errors when deploying blueprints since entering "1 hour"
sent 1 second instead of 3600 seconds.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…tor access

- Fix service ID validation to properly handle ID 0 (BigInt zero is falsy)
- Add useServicesByOperator to allow operators to access service details
- Refactor approve/reject hooks to use onSuccess callbacks instead of useEffect

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…days

Replace weeks with seconds and minutes for more granular duration control.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…legationsByAsset

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…types

Add new data hooks for fetching service request details:
- useServiceRequestDetails: fetch contract details for a service request
- useBlueprintConfig: fetch blueprint configuration (membership model, pricing)
- useTokenMetadata: fetch token name, symbol, and decimals

Extend useServices GraphQL hook:
- Add approvalCount and securityRequirements fields to ServiceRequest
- Add useOperatorActedServiceRequests hook for requests operator has acted on

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add reusable components for displaying service request information:
- BlueprintInfoCard: display blueprint metadata
- CommitmentSection: display security commitment requirements
- OperatorStatusSection: show operator approval/rejection status
- PaymentTermsSection: display pricing and payment terms
- SecurityRequirementsSection: display asset security requirements
- ServiceRequestSummary: summary component for key request details

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add types and utility functions for service requests:
- MembershipModel enum (Fixed/Dynamic)
- OperatorApprovalStatus and OperatorWithStatus types
- formatTtl, formatCreatedAt, getMembershipLabel utilities

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…request detail modal

Refactor service request approval flow:
- Replace separate ApproveConfirmationModal and RejectConfirmationModal with unified ServiceRequestDetailModal
- Add ApprovedInstanceTable to show requests operator has approved/rejected
- Update PendingInstanceTable to filter out requests operator has already acted on
- Add "Review" button instead of separate Approve/Reject buttons
- Add new "Approved" tab in instances page for operator's acted requests

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Improve deployment flow by fetching blueprint configuration from contract:
- Fetch blueprint config (membership model, min operators) using useBlueprintConfig
- Auto-set approval model and min approval based on blueprint's membership model
- Show membership model indicator (Fixed/Dynamic) in operator selection step
- Improve form handling for instance duration input
- Set default minExposurePercent to 1 (minimum required by schema)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Resolve conflict in ClaimableRewardsCard.tsx by accepting v2 changes
and applying button text update to "Claim All Rewards"

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@vutuanlinh2k2
Copy link
Contributor Author

@claude review this PR

@claude
Copy link

claude bot commented Feb 4, 2026

Claude finished @vutuanlinh2k2's task —— View job


PR Review Complete ✅

I've conducted a comprehensive review of this service request management PR with approval flow implementation. Here are my findings:

Review Progress:

  • Examine new service request detail components
  • Review data hooks and API integration
  • Check approval/rejection transaction logic
  • Analyze security requirements implementation
  • Review blueprint deployment workflow changes
  • Check TypeScript types and interfaces
  • Verify error handling and edge cases
  • Overall code quality and best practices assessment

Overall Assessment: ✅ Excellent Implementation

This is a well-architected PR that successfully implements a comprehensive service request management system. The code quality is high and follows React/TypeScript best practices.

Strengths 💪

1. Excellent Component Architecture

  • ServiceRequestDetailModal.tsx:479: Well-structured modal with clear separation between details and approval views
  • Modular components: Clean separation of concerns with dedicated components for different sections (BlueprintInfoCard, SecurityRequirementsSection, etc.)
  • Proper state management: Uses react-hook-form effectively with proper validation

2. Robust Data Layer

  • useServiceRequestDetails.ts:171: Comprehensive hook with proper error handling and type safety
  • useServiceRequestSecurityRequirements.ts:233: Smart logic for handling simple vs custom security requirements
  • useBlueprintConfig.ts:124: Auto-fetch functionality properly implemented

3. Strong TypeScript Implementation

  • Excellent type definitions: Clear interfaces and enums (MembershipModel, AssetKind, etc.)
  • Type safety: Proper use of Address types and bigint handling
  • serviceRequest.ts:61: Well-defined utility functions for formatting

4. Smart Security Requirements Logic

  • Line 197-218 in useServiceRequestSecurityRequirements.ts: Intelligent detection of simple vs custom requirements
  • Proper basis points handling: Consistent use of basis points (0-10000) throughout
  • Asset kind abstraction: Clean handling of native vs ERC20 tokens

5. Good Error Handling Patterns

  • Graceful degradation: Components handle loading and error states properly
  • Try-catch blocks: Appropriate error handling in data hooks with console.warn for debugging
  • Null safety: Proper handling of undefined/null values throughout components

Areas for Improvement 🔧

1. Minor: Magic Numbers

// In useServiceRequestSecurityRequirements.ts:16-17
const DEFAULT_TNT_MIN_EXPOSURE_BPS = 1000; // 10%
const DEFAULT_TNT_MAX_EXPOSURE_BPS = 10000; // 100%

Suggestion: Consider moving these to a shared constants file if used elsewhere.

2. Minor: Error Message Consistency

ServiceRequestDetailModal.tsx:360: Form validation errors could use more consistent messaging patterns across all inputs.

3. Minor: Component Size

ServiceRequestDetailModal.tsx is quite large (479 lines). Consider extracting the approval form logic into a separate component.

Security Considerations ✅

  • Proper input validation: Form validation with min/max constraints for security commitments
  • Type-safe address handling: Consistent use of Address type from viem
  • Safe bigint operations: Proper handling of large numbers without overflow concerns
  • No hardcoded credentials: All configuration properly externalized

Technical Debt Assessment ✅

  • Code follows established patterns in the codebase
  • Consistent with existing architecture
  • No major technical debt introduced
  • Good separation of concerns maintained

Test Coverage Recommendations 📋

While I didn't see test files in this PR, consider adding tests for:

  1. Service request approval/rejection flows
  2. Security requirements validation logic
  3. Edge cases like zero amounts and invalid addresses
  4. Error state handling in components

Conclusion 🎯

This is a high-quality implementation that successfully adds comprehensive service request management functionality. The code is well-structured, type-safe, and follows React best practices. The approval flow logic is robust and handles both simple and complex security requirement scenarios effectively.

Recommendation: ✅ Approve - This PR is ready for merge after addressing any minor feedback.


@vutuanlinh2k2 vutuanlinh2k2 self-assigned this Feb 4, 2026
@drewstone drewstone merged commit 41433ff into v2 Feb 4, 2026
1 check passed
@drewstone drewstone deleted the linh/qa/manage-service-req branch February 4, 2026 16:01
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.

2 participants