fix(deploy): remove unreachable null-signer guard in resolveSignerSetup#110
Merged
Conversation
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.
Contributor
|
Dev build ready — try this branch: |
Contributor
E2E Test Pass · ✅ PASSTag:
Sentry traces: view spans for this run |
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.
Context
Closes #104 (Bug 2).
Bug 1 from that issue (error message not mentioning
--suri) was already fixed onmain—SignerNotAvailableErrornow reads'No signer available. Run "dot init" to log in, or pass --suri //Alice for dev.'This PR addresses Bug 2 only.
Problem
resolveSignerSetupinsrc/utils/deploy/signerMode.tscontained a dead error branch:The
!opts.userSignerguard can never be true whenpublishToPlaygroundis true. The invariant is enforced one level up:shouldResolveUserSigner()returnstruewheneveropts.publishToPlayground === true(signerMode.ts:256)true,resolveSigner()is called in the preflight (deploy/index.ts:203)resolveSigner()either produces aResolvedSigneror throwsSignerNotAvailableError— it never returnsnullSignerNotAvailableErrorwhenpublishToPlaygroundis set (deploy/index.ts:208-209)So by the time
resolveSignerSetupis called,userSigneris guaranteed non-null. The throw was dead code.Fix
if (!opts.userSigner) throwbranchopts.userSigner!(non-null assertion) to keep TypeScript happyTesting
pnpm exec tsc --noEmit— passes clean