Skip to content

refactor(wt+sdk): S3776 long-tail in manager + bignumber + contacts#100

Merged
sirdeggen merged 2 commits intomainfrom
sonar/w5-mgr-sdk
May 8, 2026
Merged

refactor(wt+sdk): S3776 long-tail in manager + bignumber + contacts#100
sirdeggen merged 2 commits intomainfrom
sonar/w5-mgr-sdk

Conversation

@sirdeggen
Copy link
Copy Markdown
Contributor

Summary

  • Reduces Cognitive Complexity (S3776) to ≤12 in all 11 flagged functions across 4 files
  • Extracts focused private-helper methods: no behaviour changes, no API surface changes
  • BigNumber.ts | 0 integer-validation preserved; eslint-disable comment added per playbook
  • All security/permission logic in WalletPermissionsManager left intact — only structural decomposition

Files changed

File Flagged functions Strategy
WalletPermissionsManager.ts 6 (CC 16–26) Extract isBasketUsageRequired, isPiggybacking, piggybackOnExistingQueue, resolveGroupedFlow, enqueueAndFireEvent, buildProtocolFilterTags, collectProtocolTokens, collectCertificateTokens, collectNonPBaskets, enforceSignAndProcess, encryptActionMetadata, callCreateActionWithPModules
CWIStyleWalletManager.ts 2 (CC 31–36) Extract buildUMPTokenFields, resolveOldTokenInput, createUMPAction, broadcastFinishedUMPAction, signAndBroadcastWithOldToken, signAndBroadcastNewToken, handleExistingUserPassword, handleNewUserPassword
BigNumber.ts 3 (CC 19–58) Extract _initFromString, _initFromHexString, _initFromNonHexString, _zeroPaddedChunk, _computeMod, _bigNumberFromSigned
ContactsManager.ts 3 (CC 18–27) Extract loadCachedContacts, buildIdentityKeyTags, decryptContactOutputs, hashIdentityKey, findExistingOutput, encryptAndLock, updateContactOutput, createContactOutput, trySpendContactOutput

Test plan

  • pnpm --filter @bsv/sdk run build — passes
  • pnpm --filter @bsv/wallet-toolbox run build — passes
  • pnpm --filter @bsv/sdk exec jest --runInBand --testPathPatterns='BigNumber|Contacts' — 165/165 pass
  • pnpm --filter @bsv/wallet-toolbox exec jest --runInBand --testPathPatterns='WalletPermissions|CWIStyle' — 175/175 pass

Refs #38 #44.

🤖 Generated with Claude Code

Reduce cognitive complexity to ≤12 in all flagged functions across
WalletPermissionsManager, CWIStyleWalletManager, BigNumber and
ContactsManager. Extracts focused private helpers; no logic changes.
BigNumber `| 0` integer-validation guarded by eslint-disable comment.
Refs #38 #44.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 7, 2026

Codecov Report

❌ Patch coverage is 94.11765% with 9 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
packages/sdk/src/primitives/BigNumber.ts 88.52% 7 Missing ⚠️
packages/sdk/src/identity/ContactsManager.ts 97.82% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

Conflicts in ContactsManager.ts (4 hunks) and BigNumber.ts (2 hunks).
Resolved by keeping HEAD's helper-method refactors which already
incorporate the W3 S2486 catch renames and other origin/main changes
into the extracted private helpers (loadCachedContacts,
updateContactOutput, createContactOutput, trySpendContactOutput,
_initFromString, _computeMod, _bigNumberFromSigned).
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 7, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
43.4% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@sirdeggen sirdeggen merged commit 01d0406 into main May 8, 2026
8 of 9 checks passed
sirdeggen added a commit that referenced this pull request May 8, 2026
Conflict in BigNumber.ts resolved by taking origin/main's structure
(uses _initFromString helper from W5 PR #100) and applying the W6 S2486
catch rename (_bigIntParseError) to the helper's BigInt parse path.
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