Skip to content

Commit 1988832

Browse files
fix(deploy): remove unreachable null-signer guard in resolveSignerSetup (#110)
* fix(deploy): remove unreachable null-signer guard in resolveSignerSetup The throw at signerMode.ts:142-149 could never fire: shouldResolveUserSigner() returns true whenever publishToPlayground is true, so resolveSigner() in the preflight has already either produced a ResolvedSigner or rethrown before resolveSignerSetup is called. Replace the dead branch with a non-null assertion and a comment explaining the invariant so the next refactor doesn't silently reintroduce it. Closes #104. * chore: add changeset for dead-signer-guard fix * test(deploy): remove test for unreachable null-signer path in resolveSignerSetup
1 parent 62a3451 commit 1988832

3 files changed

Lines changed: 11 additions & 16 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"playground-cli": patch
3+
---
4+
5+
Remove unreachable null-signer guard in `resolveSignerSetup` (`signerMode.ts`). The dead `throw` could never fire because `shouldResolveUserSigner()` guarantees a signer is resolved before `resolveSignerSetup` is called when `--playground` is set. No user-visible behaviour change.

src/utils/deploy/signerMode.test.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,6 @@ describe("resolveSignerSetup — dev mode", () => {
2323
expect(result.publishSigner).toBeNull();
2424
});
2525

26-
it("publishToPlayground without a userSigner throws a helpful message", () => {
27-
expect(() =>
28-
resolveSignerSetup({
29-
mode: "dev",
30-
userSigner: null,
31-
publishToPlayground: true,
32-
}),
33-
).toThrow(/dot init|--playground/);
34-
});
35-
3626
it("publishToPlayground with session userSigner adds one playground approval and leaves auth empty", () => {
3727
const user = fakeSigner("session");
3828
const result = resolveSignerSetup({

src/utils/deploy/signerMode.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,14 @@ export function resolveSignerSetup(opts: ResolveOptions): DeploySignerSetup {
138138
// Playground publish always uses the user's signer so ownership ties to
139139
// their address — otherwise the registry would record a shared dev key
140140
// and the myApps view would be useless.
141+
//
142+
// userSigner is guaranteed non-null here: shouldResolveUserSigner() returns
143+
// true whenever publishToPlayground is true, so resolveSigner() in the
144+
// preflight has already either resolved a signer or thrown before we reach
145+
// this point. The null guard that previously lived here was unreachable.
141146
let publishSigner: ResolvedSigner | null = null;
142147
if (opts.publishToPlayground) {
143-
if (!opts.userSigner) {
144-
throw new Error(
145-
'Publishing to Playground requires a logged-in account. Run "dot init" first, or drop --playground.',
146-
);
147-
}
148-
publishSigner = opts.userSigner;
148+
publishSigner = opts.userSigner!;
149149
approvals.push({ phase: "playground", label: "Publish to Playground registry" });
150150
}
151151

0 commit comments

Comments
 (0)