Skip to content

chore(tangle-cloud): adopt unified approveService(ApprovalParams)#3168

Merged
drewstone merged 1 commit intodevelopfrom
drew/sync-tnt-core-unified-approval
May 5, 2026
Merged

chore(tangle-cloud): adopt unified approveService(ApprovalParams)#3168
drewstone merged 1 commit intodevelopfrom
drew/sync-tnt-core-unified-approval

Conversation

@drewstone
Copy link
Copy Markdown
Contributor

tnt-core PR #119 collapsed five approveServiceWith* entrypoints into a single approveService(ApprovalParams). This PR pulls in the regenerated ABI and rewrites the dApp's approval hook for the new shape.

Why this is correct + useful

Concern What this PR does
API surface explosion Hook now passes a single ApprovalParams struct. Five contract function names collapse to one. Future capabilities (e.g. new commitment types) extend the struct, not the function matrix.
Optional-capability semantics securityCommitments / blsPubkey / blsPopSignature / teeCommitments are all opt-in. Default (empty / zero) values mean "skip this capability." Matches the contract's documented behaviour.
TEE callsite path is open TeeAttestationCommitment type exported; callers that want to bind TEE attestation profiles (e.g. operator-side approval UIs that read teeNonceFor(requestId)) can do so without bringing the surface back to a custom hook.
Test coverage stays honest Hook spec rewritten — minimal approval, security commitments threading, BLS+TEE opt-in path, chain-unsupported fallback. Four tests, every one named after a real failure mode.

Changes

  • libs/tangle-shared-ui/src/abi/{tangle,multiAssetDelegation,blueprintServiceManager}.ts
    regenerated via yarn sync:tnt-core-assets against tnt-core post-Listen. to accounts change on MetaMask and UI fixes #119.
    The single approveService ABI replaces the five approveServiceWith* variants.
    New getTeeCommitmentRoot view + teeNonceFor helper exposed.
  • apps/tangle-cloud/src/data/services/useServiceApproveTx.ts rewritten:
    • Single ServiceApproveParams shape with optional fields.
    • One contract call (functionName: 'approveService'); the hook builds the
      ApprovalParams tuple from the supplied fields with sensible empty/zero defaults.
    • New TeeAttestationCommitment type exported.
  • apps/tangle-cloud/src/data/services/useServiceApproveTx.spec.tsx rewritten:
    4 tests covering minimal approval, security commitments, BLS+TEE opt-in, chain-unsupported.
  • apps/tangle-cloud/src/pages/instances/Instances/PendingInstanceTable.tsx:
    onConfirmApprove no longer threads stakingPercent / tntExposureBps to the contract.
    The on-chain entrypoint derives staking percent from securityCommitments[0].exposureBps
    (or defaults to 100% when commitments are empty). Documented inline.
  • scripts/local-env/fixtures/{localtestnet-broadcast,localtestnet-state}.json
    refreshed by the sync script (anvil deployment snapshot).

Coordination

Companion PRs that must land in lockstep:

  • tnt-core #120 — Rust binding regen + crates.io publish (bindings-v0.11.0).
  • blueprint #1402 — bumps tnt-core-bindings and threads the new entrypoint through TangleClient.

This PR is ABI-only on the dApp side and doesn't depend on the Rust crate publish.

Test plan

  • yarn nx typecheck tangle-cloud clean
  • Pre-push hook ran lint + format:check + test + build across 13 projects — all green
  • Auto-generated ABI files prettier-formatted
  • CI to run the full suite for regressions
  • Reviewer to spot-check that the form's stakingPercent / tntExposureBps inputs no longer reaching the contract is acceptable (the on-chain derivation supersedes them)

tnt-core PR #119 collapsed five `approveServiceWith*` entrypoints into a single
`approveService(ApprovalParams)`. This PR pulls in the regenerated ABI and
rewrites the dApp's approval hook for the new shape.

## Changes

- `libs/tangle-shared-ui/src/abi/{tangle,multiAssetDelegation,blueprintServiceManager}.ts`
  regenerated via `yarn sync:tnt-core-assets` against the post-#119 contracts.
  The single `approveService` ABI replaces the five `approveServiceWith*`
  variants. New `getTeeCommitmentRoot` view + `teeNonceFor` helper exposed.
- `apps/tangle-cloud/src/data/services/useServiceApproveTx.ts` rewritten:
  - Single `ServiceApproveParams` shape: `{ requestId, securityCommitments?,
    blsPubkey?, blsPopSignature?, teeCommitments? }`. All optional fields
    default to empty/zero (= opt out).
  - One contract call (`functionName: 'approveService'`); the hook builds the
    `ApprovalParams` tuple from the supplied fields.
  - New `TeeAttestationCommitment` type exported for callers that want to bind
    a TEE attestation profile at approval time.
- `apps/tangle-cloud/src/data/services/useServiceApproveTx.spec.tsx` rewritten
  with four tests covering minimal approval, security commitments threading,
  BLS+TEE opt-in, and chain-unsupported fallback.
- `apps/tangle-cloud/src/pages/instances/Instances/PendingInstanceTable.tsx`:
  `onConfirmApprove` no longer passes `stakingPercent` / `tntExposureBps` —
  those are derived on-chain from `securityCommitments[0].exposureBps` (or
  default to 100% when commitments are empty). Documented inline.
- `scripts/local-env/fixtures/{localtestnet-broadcast,localtestnet-state}.json`
  refreshed by the sync script.

## Why this is correct

- The contract enforces all the safety properties (DirectTdx rejection, Unset
  enum sentinel, nonce binding, expiry cap, commitment count cap). The dapp
  hook just shapes the calldata; it doesn't need to validate.
- Empty TEE / BLS arrays mean opt-out, matching the contract's documented
  semantics. Tests assert both opt-in and opt-out paths.
- The legacy `stakingPercent` / `tntExposureBps` form fields stay in the form
  schema for now (other forms still surface them) but no longer thread to the
  contract — the on-chain derivation supersedes them.

## Verification

- [x] `yarn nx typecheck tangle-cloud` clean
- [ ] Pre-push hook runs lint + format:check + test + build (will trigger on `git push`)
@drewstone drewstone requested a review from AtelyPham as a code owner May 5, 2026 12:38
@netlify
Copy link
Copy Markdown

netlify Bot commented May 5, 2026

Deploy Preview for tangle-dapp ready!

Name Link
🔨 Latest commit ce68604
🔍 Latest deploy log https://app.netlify.com/projects/tangle-dapp/deploys/69f9e4bb07c09e000885931d
😎 Deploy Preview https://deploy-preview-3168--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.

@netlify
Copy link
Copy Markdown

netlify Bot commented May 5, 2026

Deploy Preview for tangle-leaderboard ready!

Name Link
🔨 Latest commit ce68604
🔍 Latest deploy log https://app.netlify.com/projects/tangle-leaderboard/deploys/69f9e4bbc6c1280008c7c1e7
😎 Deploy Preview https://deploy-preview-3168--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-cloud ready!

Name Link
🔨 Latest commit ce68604
🔍 Latest deploy log https://app.netlify.com/projects/tangle-cloud/deploys/69f9e4bb2f5fbd00088dd5b0
😎 Deploy Preview https://deploy-preview-3168--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.

@drewstone drewstone merged commit 7e15e70 into develop May 5, 2026
19 of 20 checks passed
@drewstone drewstone deleted the drew/sync-tnt-core-unified-approval branch May 5, 2026 12:40
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