Skip to content

feat(tangle-cloud): broadcast serviceContext + chain to embedded iframes#3240

Merged
drewstone merged 1 commit into
developfrom
feat/iframe-parent-service-context-calljob
May 25, 2026
Merged

feat(tangle-cloud): broadcast serviceContext + chain to embedded iframes#3240
drewstone merged 1 commit into
developfrom
feat/iframe-parent-service-context-calljob

Conversation

@drewstone
Copy link
Copy Markdown
Contributor

Parent-side half of the thin-iframe SDK protocol (@tangle-network/blueprint-ui/iframe). The dapp now tells embedded blueprint iframes which blueprint/service they render for + the active chain, so the SDK's useTangleService() + useTanglePublicClient() resolve.

Wired

  • Protocol: signTypedData, callJob, serviceContext, jobResult types + validators on the canonical iframe/protocol.ts.
  • serviceContext broadcast: useIframeBridge broadcasts { blueprintId, serviceId, operators, jobs, mode, chain } on mount + change. Chain config derived from the active wagmi chain.
  • Policy: signTypedData gated like signMessage; callJob gated like readAccount.

Deferred (clean errors, not hangs)

callJob and signTypedData are protocol-complete but their execution paths (quote/sign/submit + typed-data approval modal) aren't wired — they respond immediately with a clear error. Each deserves its own carefully-reviewed PR; the financial submit path shouldn't be a tail-of-session bolt-on. Tracked as follow-ups.

Why serviceContext alone is the keystone

Read-only + safe + unlocks the whole thin-iframe read model: the iframe learns its context, then does direct operator HTTP + injected-publicClient reads for ~90% of a rich blueprint UX. The reference llm-inference blueprint demonstrates exactly this.

Test plan

  • yarn nx typecheck/build/test/lint tangle-cloud — clean (162/162)
  • After merge: embedded iframe receives serviceContext with chain; SDK hooks resolve
  • Follow-up PRs: callJob quote/submit + signTypedData approval modal

Parent-side half of the thin-iframe SDK protocol. The dapp now tells
embedded blueprint iframes which blueprint/service they render for and
what chain the user is on — so `useTangleService()` and
`useTanglePublicClient()` in `@tangle-network/blueprint-ui/iframe`
resolve.

## What's wired

  - **Protocol** — added `signTypedData`, `callJob`, `serviceContext`,
    `jobResult` request/response/event types + validators to the
    canonical `iframe/protocol.ts` (the SDK mirrors these).
  - **serviceContext broadcast** — `useIframeBridge` now accepts a
    `serviceContext` option and broadcasts `{ blueprintId, serviceId,
    operators, jobs, mode, chain }` on mount + on change. Chain config
    is derived from the active wagmi chain (id, name, public RPC,
    explorer, native currency) so the iframe can build a read-only
    viem client. `BlueprintAppFrameHost` assembles the context from
    its props.
  - **Policy** — `signTypedData` gated like `signMessage`; `callJob`
    gated like `readAccount` (baseline embedded capability; the actual
    spend still goes through the user's wallet approval downstream).

## What's deferred (clean errors, not hangs)

`callJob` and `signTypedData` are protocol-complete but their
parent-side execution paths aren't wired yet:

  - `callJob` → responds with a `jobResult` error directing the iframe
    to use direct operator HTTP for reads (on-chain submission coming).
  - `signTypedData` → responds with a `signTypedDataResult` error.

Both return immediately with a clear message rather than hanging on the
iframe's request timeout. The financial submit path (quote → sign →
submit) and the typed-data approval-modal wiring each deserve their own
focused, carefully-reviewed PR — not a bolt-on. Tracked as follow-ups.

## Why serviceContext alone is the keystone

It's read-only + safe + unlocks the whole thin-iframe read model: the
iframe learns its blueprint/service/operators/chain, then does direct
operator HTTP + injected-publicClient reads for everything. That's the
90% of a rich blueprint UX that doesn't need signing. The reference
llm-inference blueprint (next) demonstrates exactly this.

## Verification

  - `yarn nx typecheck/build/test/lint tangle-cloud` — clean
    (162/162 tests)
@drewstone drewstone requested a review from AtelyPham as a code owner May 25, 2026 14:37
@drewstone drewstone merged commit 665457a into develop May 25, 2026
8 checks passed
@drewstone drewstone deleted the feat/iframe-parent-service-context-calljob branch May 25, 2026 14:44
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