mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
Fix nip19 decode type inference with explicit type assertion
Add explicit type assertion to nip19.decode() result to avoid TypeScript version differences in discriminated union handling. This ensures consistent type checking across different TypeScript versions used in CI/CD vs local.
This commit is contained in:
1 parent
c037bd1376
commit
70fa01a640
1 file changed
+5
-5
@@ -217,12 +217,12 @@ export function PullRequestDialog({
|
||||
// Convert npub to hex if needed
|
||||
if (pubkeyOrNpub.startsWith('npub1')) {
|
||||
try {
|
||||
const decoded = nip19.decode(pubkeyOrNpub);
|
||||
// Type guard: ensure we have an npub
|
||||
if (decoded.type === 'npub' && typeof decoded.data === 'string') {
|
||||
owner = decoded.data; // hex pubkey
|
||||
const result = nip19.decode(pubkeyOrNpub) as { type: string; data: string };
|
||||
// Validate that we got an npub (public key)
|
||||
if (result.type === 'npub') {
|
||||
owner = result.data;
|
||||
} else {
|
||||
throw new Error('Expected npub but got ' + decoded.type);
|
||||
throw new Error('Invalid npub - expected public key but got: ' + result.type);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to decode npub:', err);
|
||||
|
||||
Reference in new issue
Block a user