feat(tangle-cloud): broadcast serviceContext + chain to embedded iframes#3240
Merged
Merged
Conversation
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)
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.
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
signTypedData,callJob,serviceContext,jobResulttypes + validators on the canonicaliframe/protocol.ts.useIframeBridgebroadcasts{ blueprintId, serviceId, operators, jobs, mode, chain }on mount + change. Chain config derived from the active wagmi chain.Deferred (clean errors, not hangs)
callJobandsignTypedDataare 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)