Skip to content

fix(web-client): add missing setSignCb method to WebClient class#40

Open
bigeez wants to merge 4 commits into
0xMiden:nextfrom
bigeez:fix/missing-setSignCb-method
Open

fix(web-client): add missing setSignCb method to WebClient class#40
bigeez wants to merge 4 commits into
0xMiden:nextfrom
bigeez:fix/missing-setSignCb-method

Conversation

@bigeez
Copy link
Copy Markdown

@bigeez bigeez commented Apr 28, 2026

Summary

Adds a missing setSignCb method to the WebClient class in crates/web-client/js/index.js. The method is declared in js/types/index.d.ts and called by MidenProvider.tsx, but was never actually implemented on the class.

Problem

The TypeScript declarations advertise setSignCb(signCb: SignCallback | null | undefined): void as part of the WebClient API. MidenProvider.tsx calls store.client.setSignCb(wrappedSignCb) whenever an external signer reconnects (e.g. after a page focus/blur cycle, wallet unlock, or token refresh).

However, the actual WebClient class only assigns this.signCb = signCb once in the constructor and never exposes a setter. The createClientProxy get trap therefore returns undefined for setSignCb, and calling undefined(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:262 and __tests__/setup.ts:64 patch setSignCb as vi.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 setSignCb method to WebClient next to other lifecycle/control methods, following the same pattern as this.signCb constructor assignment and using ?? null to match the declared SignCallback | null | undefined type.

setSignCb(signCb) {
  this.signCb = signCb ?? null;
}

The message handler at line 459 already reads this.signCb fresh on every callback invocation, so a simple property assignment is all that's needed.

Changes

  • 1 file changed, 14 insertions(+)
  • crates/web-client/js/index.js

@bigeez bigeez force-pushed the fix/missing-setSignCb-method branch from 035d740 to 525c091 Compare April 28, 2026 22:44
@bigeez bigeez force-pushed the fix/missing-setSignCb-method branch from 525c091 to 05dab64 Compare April 28, 2026 22:45
@WiktorStarczewski WiktorStarczewski self-requested a review April 28, 2026 22:54
@bigeez
Copy link
Copy Markdown
Author

bigeez commented May 5, 2026

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.

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