Repository navigation
feat: useCofheDecryptFn, useCofheDecryptForTx and a configurable decrypt timeout - #452
Draft
alexshchur wants to merge 3 commits into
Draft
alexshchur wants to merge 3 commits into
alexshchur wants to merge 3 commits into
Conversation
…ole submit + poll budget The overall budget of one decrypt (submit attempts, 204/404 submit retries and status polling together) was a fixed 5 minutes in tnSealOutputV2 and tnDecryptV2. Both builders now take it per request; the default stays. The validation lives next to the 404 retry window's in submitRetry.ts.
`useCofheDecryptFn` returns a function that decrypts one handle on demand, for a job over many handles run from a `useMutation`. Each call is the same query `useCofheDecrypt` runs (key, ACP gate, persistence, activity row), through `queryClient.fetchQuery`, so a handle decrypted either way is decrypted once; calls run at most `concurrency` at a time. The query's key, `queryFn` and `meta` move into `cofheDecryptQuery`, shared by both. `useCofheDecryptForTx` is a mutation hook around `client.decryptForTx`, shaped like `useCofheEncrypt`; `acp: null` selects `withoutACP()`. Both hooks and `useCofheDecrypt` take `timeoutMs` for the builder's new overall budget.
…ooks and `setTimeout` A page for the three decrypt hooks, one per shape of work: a value to render (`useCofheDecrypt`), a job over many handles (`useCofheDecryptFn`), a plaintext with proof (`useCofheDecryptForTx`). Reachable by link like /react/acp; the React section stays out of the sidebar.
🦋 Changeset detectedLatest commit: 41510d2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
alexshchur
added this pull request to stack #453
October 19, 2026 12:07
Contributor
|
Vercel previews (commit
|
This branch was successfully deployed
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.
Stacked on #450 (
feat/acp-sharing-writers, the1.1.0-alpha.0commit); the diff against it is three commits.An app that decrypts a list of handles in a job the user starts (a transfer history to sum, a set of bids to reveal) had no way to do it through the SDK's React layer:
useCofheDecryptis one handle per mount, and the React package exposes neither an imperative read through its query cache nor the decrypt key. Such apps callclient.decryptForViewdirectly and reinvent the cache, the ACP gate and the concurrency cap. Likewiseclient.decryptForTxhad no hook, and the overall decrypt timeout was fixed at 5 minutes.@cofhe/sdk.setTimeout(timeoutMs)ondecryptForViewanddecryptForTx: the whole budget of one decrypt (submit attempts,204/404submit retries, status polling), threaded throughtnSealOutputV2/tnDecryptV2; the default stays 5 minutes (DEFAULT_DECRYPT_TIMEOUT_MS). Validation (assertDecryptTimeoutMs) sits next to the 404 window's insubmitRetry.ts.@cofhe/reactuseCofheDecryptFn({ chainId?, acp?, concurrency? })returns{ decrypt, isReady, acp }.decrypt(input, options?)runsqueryClient.fetchQuerywith the same key,queryFnandmetaasuseCofheDecrypt, so a value decrypted either way is one cache entry, persisted under the same rule (self ACP only) and listed once in the activity panel. Same gate, as rejections: no valid ACP →ACPRequired/ACPExpired, SNAPSHOT share without the handle →ACPDenied, never a request. A zero handle resolves to the type's zero. Calls run at mostconcurrencyat a time (4). Per-call options:meta,context,onPoll,timeoutMs,staleTime(Infinity),retry.useCofheDecryptForTx(options?):useInternalMutationaroundclient.decryptForTx, shaped likeuseCofheEncrypt(decryptForTxAsync,decryptForTx,isDecrypting).acpselects the mode:null→withoutACP(), omitted → active ACP, ACP or hash →withACP(x);chainId,account,onPoll,timeoutMs,retry404TimeoutMsmap onto the builder.useCofheDecrypt: the query's key /queryFn/metamove into the sharedcofheDecryptQuery, the invalid-ACP purge intouseDropDecryptsOfInvalidACP, the default retry intodefaultDecryptRetry; it takestimeoutMs. Behaviour unchanged, the existing test is untouched.Docs
New
/react/decrypt(reachable by link, like/react/acp): the three hooks, one per shape of work..setTimeoutsections on both builder pages; the lifecycle page names the budget. Changeset: react minor + sdk minor.Verification
@cofhe/sdk:tsc --noEmitclean apart from the pre-existing@cofhe/test-setuperrors;decryptBuilders.test.ts46 pass (6 new:setTimeoutstored, rejected for 0 / NaN / negative, forwarded to the threshold network call on both builders).@cofhe/react:tsc --noEmitclean; vitest 90 pass (6 new foruseCofheDecryptFn: key + persisted meta + default retry, builder configured from call options with a scoped ACP, zero handle, invalid ACP, out-of-scope handle, concurrency; 5 new foruseCofheDecryptForTx: mutation key, the three ACP modes, variable mapping, no client). eslint clean on the touched files. Prettier clean.Follow-up on the platform side: the sites that call
client.decryptForViewdirectly move touseCofheDecryptFn; the app-localuseDecryptForTxwrappers touseCofheDecryptForTx.