Skip to content

refactor(tangle-cloud): unify approval form to securityCommitments[]#3169

Merged
drewstone merged 1 commit into
developfrom
drew/approval-form-cleanup
May 5, 2026
Merged

refactor(tangle-cloud): unify approval form to securityCommitments[]#3169
drewstone merged 1 commit into
developfrom
drew/approval-form-cleanup

Conversation

@drewstone
Copy link
Copy Markdown
Contributor

Summary

Closes the silent-data-drop bug in PendingInstanceTable introduced when the
contract collapsed five approveServiceWith* overloads into one
approveService(ApprovalParams) entrypoint (tnt-core #119). The form was
passing stakingPercent / tntExposureBps fields that useServiceApproveTx
no longer reads, so the operator's slider value for the default-TNT case
reached the contract as "no commitment" — the contract then auto-filled at
the requirement's minExposureBps regardless of what the operator typed.

What changed

  • ApprovalConfirmationFormFields: drop dead stakingPercent and
    tntExposureBps. The form now produces a single securityCommitments[]
    array — the only thing the unified contract entrypoint accepts.
  • ServiceRequestDetailModal: collapse the two render branches (custom vs
    default-TNT) into one. Every requirement renders as a per-asset slider
    bound to commitments.\${tokenKey}. The default-TNT case keeps the
    operator-recommended-exposure marker via derivedSimpleStakingPercent.
  • useServiceApproveTx: type-safe TeeBackend const so callers can't pass
    invalid backends (Unset = 0 and DirectTdx = 5 are rejected on-chain
    and thus unrepresentable in the type).

Net -45 LOC.

Verification

  • `yarn nx run tangle-cloud:typecheck` ✓
  • `yarn nx run tangle-cloud:lint` ✓
  • `yarn prettier --check` ✓ on every modified file
  • `yarn vitest run useServiceApproveTx.spec.tsx` ✓ (4/4)

Test plan

  • Approve a request with the default TNT-only requirement; verify the
    contract receives securityCommitments[0].exposureBps matching the
    operator's slider (not auto-filled at min).
  • Approve a request with custom multi-asset requirements; verify each
    slider value reaches the contract.
  • Approve with no requirements (legacy path); verify empty
    securityCommitments[] is sent and the contract takes the
    effectiveStakingPercent = 100 path.

…mitments

The unified `approveService(ApprovalParams)` entrypoint takes a single
`securityCommitments[]` array; the operator's slider value for the
default-TNT case was being silently dropped because the form sent
`stakingPercent` / `tntExposureBps` fields that the hook ignored.

- Drop `stakingPercent` and `tntExposureBps` from `ApprovalConfirmationFormFields`.
- Render every requirement (custom or default-TNT) through one `commitments.${key}`
  controller; the operator's slider always reaches the contract via
  `securityCommitments[]`.
- Type-safe `TeeBackend` const for `useServiceApproveTx` (Phala, AwsNitro,
  GcpConfidential, AzureSkr only — Unset and DirectTdx are rejected on-chain
  and thus unrepresentable in the type).

Net -45 LOC. typecheck + lint + format + vitest pass.
@drewstone drewstone requested a review from AtelyPham as a code owner May 5, 2026 13:24
@netlify
Copy link
Copy Markdown

netlify Bot commented May 5, 2026

Deploy Preview for tangle-cloud ready!

Name Link
🔨 Latest commit 4ac6d57
🔍 Latest deploy log https://app.netlify.com/projects/tangle-cloud/deploys/69f9ef7c6da7c30008964d0c
😎 Deploy Preview https://deploy-preview-3169--tangle-cloud.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify Bot commented May 5, 2026

Deploy Preview for tangle-leaderboard ready!

Name Link
🔨 Latest commit 4ac6d57
🔍 Latest deploy log https://app.netlify.com/projects/tangle-leaderboard/deploys/69f9ef7c1f9e5800088c4d09
😎 Deploy Preview https://deploy-preview-3169--tangle-leaderboard.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify Bot commented May 5, 2026

Deploy Preview for tangle-dapp ready!

Name Link
🔨 Latest commit 4ac6d57
🔍 Latest deploy log https://app.netlify.com/projects/tangle-dapp/deploys/69f9ef7c15a3f1000895eaee
😎 Deploy Preview https://deploy-preview-3169--tangle-dapp.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@drewstone drewstone merged commit 7b26231 into develop May 5, 2026
20 checks passed
@drewstone drewstone deleted the drew/approval-form-cleanup branch May 5, 2026 13:37
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.

1 participant