Skip to content
This repository was archived by the owner on May 11, 2026. It is now read-only.

chore: simplify codebase without changing behavior#635

Open
bonustrack wants to merge 1 commit into
masterfrom
chore/simplify-codebase
Open

chore: simplify codebase without changing behavior#635
bonustrack wants to merge 1 commit into
masterfrom
chore/simplify-codebase

Conversation

@bonustrack

Copy link
Copy Markdown
Member

Summary

  • Mechanical, behavior-preserving cleanup across 18 files
  • Net change: −43 LOC (91 insertions, 134 deletions)
  • No feature or behavior changes; all error messages, validation orderings, and API response shapes preserved

What changed

Dead code

Env var consolidation

  • Added BROVIDER_URL and SCORE_API_URL exports to src/helpers/utils.ts
  • Replaced inline process.env.* reads across 9 files — process.env now lives only in helpers/utils.ts
  • Constants use the same UPPER_CASE casing as existing NETWORK/DEFAULT_NETWORK

Micro-simplifications

Shared helpers

  • Moved isAuthorized({ space, address }) to src/helpers/actions.ts and reused in flag-proposal.ts and delete-proposal.ts (kept settings.ts untouched — it checks admins only, switching would allow moderators through)
  • Added resolvePrivacy(spacePrivacy, payloadPrivacy) in utils.ts, used by proposal.ts and update-proposal.ts
  • Consolidated proposal JSON-field parsing in scores.ts into a field array

Control flow

Test plan

  • yarn lint passes
  • yarn typecheck passes
  • yarn test:unit — pass/fail counts identical to master (43 pass, 51 pre-existing failures, 22 todo)
  • yarn test:integration (requires DB — verify before merge)
  • yarn test:e2e (requires DB — verify before merge)
  • Smoke-test a POST / vote/proposal request in dev

🤖 Generated with Claude Code

- Remove dead code (commented-out isLimitReached and start-date check)
- Centralize BROVIDER_URL, SCORE_API_URL, NETWORK, DEFAULT_NETWORK in helpers/utils.ts
- Simplify requestDeduplicator promise chain using .finally()
- Modernize scores.ts pagination with Array.from({length}) and .entries()
- Inline trivial query/params triplets in flag-proposal and update-proposal
- Extract shared isAuthorized helper into helpers/actions.ts
- Extract resolvePrivacy helper for privacy resolution
- Replace recursive moderation run() with while(true) loop
- Rename broviderUrl/scoreAPIUrl to BROVIDER_URL/SCORE_API_URL to match existing convention

Net: 18 files changed, -43 LOC (91 insertions, 134 deletions)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@bonustrack
bonustrack requested a review from ChaituVR April 23, 2026 08:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant