chore(tangle-cloud): adopt unified approveService(ApprovalParams)#3168
Merged
chore(tangle-cloud): adopt unified approveService(ApprovalParams)#3168
Conversation
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`)
✅ Deploy Preview for tangle-dapp ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for tangle-leaderboard ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for tangle-cloud ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
tnt-core PR #119 collapsed five
approveServiceWith*entrypoints into a singleapproveService(ApprovalParams). This PR pulls in the regenerated ABI and rewrites the dApp's approval hook for the new shape.Why this is correct + useful
ApprovalParamsstruct. Five contract function names collapse to one. Future capabilities (e.g. new commitment types) extend the struct, not the function matrix.securityCommitments/blsPubkey/blsPopSignature/teeCommitmentsare all opt-in. Default (empty / zero) values mean "skip this capability." Matches the contract's documented behaviour.TeeAttestationCommitmenttype exported; callers that want to bind TEE attestation profiles (e.g. operator-side approval UIs that readteeNonceFor(requestId)) can do so without bringing the surface back to a custom hook.Changes
libs/tangle-shared-ui/src/abi/{tangle,multiAssetDelegation,blueprintServiceManager}.tsregenerated via
yarn sync:tnt-core-assetsagainst tnt-core post-Listen. to accounts change on MetaMask and UI fixes #119.The single
approveServiceABI replaces the fiveapproveServiceWith*variants.New
getTeeCommitmentRootview +teeNonceForhelper exposed.apps/tangle-cloud/src/data/services/useServiceApproveTx.tsrewritten:ServiceApproveParamsshape with optional fields.functionName: 'approveService'); the hook builds theApprovalParamstuple from the supplied fields with sensible empty/zero defaults.TeeAttestationCommitmenttype exported.apps/tangle-cloud/src/data/services/useServiceApproveTx.spec.tsxrewritten:4 tests covering minimal approval, security commitments, BLS+TEE opt-in, chain-unsupported.
apps/tangle-cloud/src/pages/instances/Instances/PendingInstanceTable.tsx:onConfirmApproveno longer threadsstakingPercent/tntExposureBpsto 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}.jsonrefreshed by the sync script (anvil deployment snapshot).
Coordination
Companion PRs that must land in lockstep:
bindings-v0.11.0).tnt-core-bindingsand threads the new entrypoint throughTangleClient.This PR is ABI-only on the dApp side and doesn't depend on the Rust crate publish.
Test plan
yarn nx typecheck tangle-cloudcleanstakingPercent/tntExposureBpsinputs no longer reaching the contract is acceptable (the on-chain derivation supersedes them)