fix(web-client): add missing setSignCb method to WebClient class#40
Open
bigeez wants to merge 4 commits into
Open
fix(web-client): add missing setSignCb method to WebClient class#40bigeez wants to merge 4 commits into
bigeez wants to merge 4 commits into
Conversation
035d740 to
525c091
Compare
525c091 to
05dab64
Compare
Author
|
Hey @WiktorStarczewski — could you approve the CI workflows when you get a chance? Happy to update the branch in the meantime. Let me know if anything needs changing on the implementation side. |
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.
Summary
Adds a missing
setSignCbmethod to theWebClientclass incrates/web-client/js/index.js. The method is declared injs/types/index.d.tsand called byMidenProvider.tsx, but was never actually implemented on the class.Problem
The TypeScript declarations advertise
setSignCb(signCb: SignCallback | null | undefined): voidas part of theWebClientAPI.MidenProvider.tsxcallsstore.client.setSignCb(wrappedSignCb)whenever an external signer reconnects (e.g. after a page focus/blur cycle, wallet unlock, or token refresh).However, the actual
WebClientclass only assignsthis.signCb = signCbonce in the constructor and never exposes a setter. ThecreateClientProxygettrap therefore returnsundefinedforsetSignCb, and callingundefined(wrappedSignCb)throws:This affects every user with an external signer (Para, Turnkey, MidenFi wallet adapter) on any signer reconnect.Why tests didn't catch it
The mocks in
__tests__/mocks/miden-sdk.ts:262and__tests__/setup.ts:64patchsetSignCbasvi.fn(), satisfying the type contract while silently papering over the missing implementation. No test exercises this code path against the real proxy.Fix
Added a
setSignCbmethod toWebClientnext to other lifecycle/control methods, following the same pattern asthis.signCbconstructor assignment and using?? nullto match the declaredSignCallback | null | undefinedtype.The message handler at line 459 already reads
this.signCbfresh on every callback invocation, so a simple property assignment is all that's needed.Changes
crates/web-client/js/index.js