-
Notifications
You must be signed in to change notification settings - Fork 20
feat(tangle-cloud): improve service management flows and job schema handling #3117
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
Conversation
…crow hooks - Fix PricingModel enum (PayOnce/Subscription/EventDriven) - Implement useServiceTerminateTx with real contract call and cache invalidation - Create useServiceDetails hook for on-chain service data - Create useServiceEscrow hook for escrow balance - Create useErc20Approval hook for token approvals - Fix useSubmitJobTx to support native token payments with value param - Update JobSubmissionForm with payment display, balance validation, and ERC20 approval flow Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
… 5 Phase 2) - Add useIsPermittedCaller hook to check job submission permissions - Add useFundServiceTx hook for funding service escrow - Add useBillSubscriptionTx hook for billing subscription services - Add useAddPermittedCallerTx and useRemovePermittedCallerTx hooks - Add ServiceOnChainDetails component displaying TTL, membership, pricing model, escrow balance, and payment info - Add FundServiceModal for funding service escrow with ERC20 approval - Update service detail page with on-chain details section - Add permission gating for job submission form Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…ement (Flow 5 Phase 3) Implements operator join/leave functionality and exit queue management for dynamic membership services. Operators can now join services with configurable exposure, schedule exits with queue duration, and service owners can force-exit operators when allowed. Read hooks: - useExitConfig, useExitStatus, useExitRequest, useCanScheduleExit - useServiceOperators, useIsServiceOperator Transaction hooks: - useScheduleExitTx, useExecuteExitTx, useCancelExitTx, useForceExitTx - useJoinServiceTx, useJoinServiceWithCommitmentsTx, useLeaveServiceTx UI components: - OperatorMembershipPanel: Join/leave service interface - OperatorExitPanel: Exit queue management with countdown timer - JoinServiceModal: Configure exposure and join service Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Use optimistic cache update to immediately remove terminated service from Running Instances table instead of waiting for indexer - Add delayed refetches (2s, 5s, 10s, 20s) to sync with indexer - Remove useEffect-based refetch that caused UI flickering due to stale indexer data Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…ctor submitJob hook Align GraphQL field names with the updated indexer schema (serviceId→service_id, submitter→caller, result→output, etc.) and refactor useSubmitJobTx to use the shared useContractWrite hook. Also improve JobSubmissionForm validation and reset behavior. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… and UX polish Fetch job definitions from the Tangle contract via useBlueprintJobs hook instead of using static blueprint requestParams. Add copy-to-clipboard for hex inputs/results in job results modal, improve column headers in job history table, and add validation for job index bounds in submission form. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Hide the Fund Service button and escrow details for non-subscription pricing models. Also fix controlled input and simplify fund button label. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…visibility Allow any user to view service details by replacing owner/operator-scoped queries with useServiceById on the detail page. Add an "All Services" tab to the instances page for discovering services to join, while keeping the Running tab scoped to the user's own services. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…Modal Replace single exposure slider with per-asset commitment inputs that query security requirements from the contract via new useServiceSecurityRequirements hook, matching the approval flow pattern. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Rename "All Services" tab to "Joinable" and filter to only show services whose blueprints the operator is registered for. Add blueprint registration check in OperatorMembershipPanel with a warning when not registered. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove simple-case TNT-only UI path from ServiceRequestDetailModal, always showing per-asset commitment inputs. Add blueprint link on service detail page and center the permission denied message. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ewBox Bake viewBox into PlayFillIcon, fix exit timing with chain time offset for dev environments, restructure exit panel UI with grouped actions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…er refetches Staggered refetches after service termination were overwriting the optimistic cache with stale indexer data, causing the terminated instance to briefly reappear before disappearing again. Now re-applies the optimistic filter after each refetch until the indexer catches up. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…t UI feedback After submitting a job, the table now updates instantly via an optimistic cache insert instead of waiting ~10s for the Envio indexer. Fixes duplicate row bug caused by event decoding failure producing a bogus fallback callId. Dedup now uses fuzzy matching (serviceId + jobIndex + submitter + submittedAt within 60s) and reconciliation polls with exponential backoff until optimistic rows clear. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ning services stat Use formatDisplayAmount instead of addCommasToNumber for service escrow values to fix malformed number display (e.g. "1.0,000" → "1"). Show running services count for non-operator users in account stats. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add flex alignment to the hidden content span during loading to prevent layout inconsistency. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@vutuanlinh2k2 some merge conflicts here still |
# Conflicts: # apps/tangle-cloud/src/pages/blueprints/create/page.tsx # apps/tangle-cloud/src/pages/services/[id]/JobSubmissionForm.tsx
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@claude review this PR |
|
Claude finished @vutuanlinh2k2's task —— View job PR Review: Service Management Flows and Job Schema HandlingI've completed my comprehensive review of this large feature PR that adds service management functionality to tangle-cloud. Here's my detailed analysis: Review Todo List
Overall AssessmentThis is a well-implemented, comprehensive feature that significantly enhances tangle-cloud's service management capabilities. The code demonstrates good architecture, proper TypeScript usage, and follows the repository's established patterns. 🔍 Code Quality HighlightsExcellent Architecture
Robust Schema System
Smart State Management
🚨 Security & Performance IssuesCritical: Potential Integer OverflowLocation: const encodeBigIntBE = (value: bigint, byteSize: number, signed: boolean): Uint8Array => {
// Missing bounds validation for signed/unsigned ranges
let n = value;
if (signed && n < BigInt(0)) {
n = (BigInt(1) << totalBits) + n; // Could overflow
}Risk: No validation that values fit within their declared bit ranges. Could cause silent overflow. Moderate: Address ValidationLocation: if (kind === BlueprintFieldKind.Address) {
// Missing address format validation
}Risk: User could input invalid address formats that pass client validation but fail on-chain. Minor: Case-sensitive Address ComparisonsFound: Multiple files use const key = req.asset.token.toLowerCase(); // Good
// But some comparisons might miss this normalizationRisk: Could cause address matching failures. 🏗️ Architecture ImprovementsService Lifecycle ManagementThe new service management hooks are well-designed:
UI Components
Job System Enhancements
🔧 Minor Code Quality IssuesError HandlingLocation: let contracts: ReturnType<typeof getContractsByChainId> | null = null;
try {
contracts = chainId ? getContractsByChainId(chainId) : null;
} catch {
contracts = null; // Silent failure - should log
}Recommendation: Add error logging for debugging. Magic NumbersLocation: [2_000, 5_000, 10_000, 20_000].forEach((delayMs) => {Recommendation: Extract to named constants with documentation. Type SafetySome areas could benefit from stricter typing:
📊 Performance ConsiderationsPositive
Minor Optimizations
🎯 RecommendationsHigh Priority
Medium Priority
Low Priority
✅ What's Working Well
🚢 Ship RecommendationThis PR is ready to merge with the minor security fixes recommended above. The core functionality is solid, well-tested through the provided videos, and follows good patterns. The identified issues are minor and can be addressed in follow-up PRs if needed. The service management feature adds significant value and the implementation quality is high. Great work on this comprehensive enhancement! 🎉 |
|
@claude fixed high and medium priority issues, help me review again |
|
Claude finished @vutuanlinh2k2's task —— View job Re-reviewing Service Management PR After Fixes ✅Thanks for addressing the issues! Let me review the fixes for the high and medium priority issues I identified. Review Progress
✅ Excellent Fixes Applied!🔒 High Priority Security Issues - RESOLVED1. Integer Overflow Protection ✅Location: The critical integer overflow issue has been completely resolved: const validateBigIntBounds = (
value: bigint,
byteSize: number,
signed: boolean,
): void => {
const bits = BigInt(byteSize * 8);
const min = signed ? -(BigInt(1) << (bits - BigInt(1))) : BigInt(0);
const max = signed
? (BigInt(1) << (bits - BigInt(1))) - BigInt(1)
: (BigInt(1) << bits) - BigInt(1);
if (value < min || value > max) {
const intType = `${signed ? 'int' : 'uint'}${byteSize * 8}`;
throw new Error(
`Integer ${value.toString()} is out of range for ${intType} (${min.toString()}..${max.toString()})`,
);
}
};Perfect implementation:
2. Address Validation ✅Location: Address validation has been significantly improved: if (kind === BlueprintFieldKind.Address) {
const addressValue = (value as string) ?? '';
const trimmedAddress = addressValue.trim();
const addressError =
trimmedAddress.length > 0 && !isAddress(trimmedAddress)
? 'Invalid EVM address format'
: undefined;
// Proper error display with aria-invalid for accessibility
<Input
isInvalid={!!addressError}
errorMessage={addressError}
aria-invalid={addressError ? 'true' : undefined}
/>Excellent improvements:
🛠️ Medium Priority Issues - RESOLVED3. Consistent Address Comparison ✅Location: A comprehensive address utility system has been created: export const addressesEqual = (
a: string | undefined,
b: string | undefined,
): boolean => {
if (!a || !b) {
return false;
}
return a.toLowerCase() === b.toLowerCase();
};
export const normalizeAddress = (value: string | undefined): Address | null => {
return safeParseAddress(value);
};Great centralization:
🔍 Additional Code Quality VerificationPayload Encoding SystemThe TLV v2 codec system is robust and well-designed:
Schema Field ComponentsThe form generation system shows excellent architecture:
Error HandlingThroughout the changes:
📊 Updated AssessmentSecurity: A+ ✨
Code Quality: A ✨
Architecture: A ✨
🚀 Final RecommendationAPPROVED FOR MERGE ✅ This PR is now in excellent condition. All high and medium priority security issues have been thoroughly addressed with high-quality implementations. The fixes demonstrate:
The service management feature is production-ready and represents a significant enhancement to tangle-cloud. Outstanding work on addressing all the feedback! 🎉 |
Summary of changes
This PR delivers the service-management flow updates for
tangle-cloud, including on-chain service lifecycle actions, job UX/schema handling, and related shared hooks.All Servicestab, service detail panels, join modal, operator membership/exit panels, and funding modal.PlayFillIconviewBox fix) and formatting cleanup.Proposed area of change
Put an
xin the boxes that apply.apps/tangle-dappapps/tangle-cloudapps/leaderboardlibs/tangle-shared-uilibs/ui-componentsAssociated issue(s)
Specify any issues that can be closed from these changes (e.g.
Closes #233).Screen Recording
If possible provide screenshots and/or a screen recording of proposed change.
Terminate Service
terminate_instances.mp4
Join Service
join_service.mp4
Fund Service
fund_service.mp4
Schedule & Cancel Exit Service
schedule_cancel_leave.mp4
Execute Leave Service
execute_leave.mp4
Submit Job
submit_job.mp4
View Job Result
view_job_result.mp4