Project improvements: correctness fixes, DRY refactors, logger, tests/CI, tooling#52
Merged
Conversation
- apiCard: use static HEIGHT_CLASSES map so Tailwind JIT keeps h-10/16/24
(dynamic h-${height} was purged, silently no-op'ing getAllInfoCard)
- providers: fix useContext guards (=== undefined -> !context; default is null)
- cardanoProvider: rename connect() param requestId -> requestIdentification
- rename yoroiProvider -> cardanoProvider, useYoroi -> useCardano across 13 files
- Wrap cardanoProvider callbacks in useCallback and context value in useMemo (match ethereumProvider; avoids re-rendering all consumers each render) - Move connect() above the mount effect and add it to deps (stable identity) - Fix provider nesting indentation in index.js
- Add src/utils/logger.js: debug/log/info gated on NODE_ENV==='development' or REACT_APP_DEBUG==='true'; warn/error always print - Route all 159 console.* calls across 53 files through logger.*
- Persist an enabled override in localStorage (key 'dapp:debug')
- Expose window.dappLogs { on, off, toggle, status, reset } so logs can be
toggled live from the console without rebuilding
- Falls back to build default (dev, or REACT_APP_DEBUG=true) when no override
- setupTests.js loads @testing-library/jest-dom - ethereumUtils: chainName, wei/eth conversions, shortAddress, ERC-20 encoders - utils: bytesToHex/hexToBytes round-trip - logger: gating, always-on warn/error, persisted override, window.dappLogs toggle - ApiCard: render, click, height class map, color prop - add test:ci script and .github/workflows/test.yml (runs on push/PR) - 24 tests across 4 suites, all passing
- Add src/utils/runApiCall.js: shared waiting/raw/response/error envelope with parse, rawText and stringify options (+ unit tests) - Convert 22 API cards to runApiCall, removing the repeated then/catch boilerplate - Left signTransactionCard (multi-step build) and cip95getRegisteredPubStakeKeys (per-branch stringify) on the explicit form to preserve exact behavior
- Extend InputWithLabel with placeholder, min, step, disabled and wrapperClassName props (disabled swaps to the disabled input style) - Replace ~22 hand-rolled label+input blocks across 11 cards with InputWithLabel - Removes duplicated CommonStyles.inputStyles / contentLabelStyle markup
- Add src/hooks/useResponseState.js (currentText/rawCurrentText/waiterState + setResponse/setRawCurrentText/setWaiterState) - Replace the duplicated state + setResponse block in 7 subtabs - Left testTxsTab (drives currentText directly) on its own state - Skipped optional SubtabShell to avoid per-tab layout divergence
- Add src/utils/buildCert.js: shared onWaiting/getCertBuilder/try-catch(onError) envelope for the governance cert + vote panels - Convert all 8 govActions panels to buildCert; early returns now still clear the waiting flag (previously left it stuck)
- Add both array-decode helpers to cslTools.js - Replace the duplicated for-loops in helpFunctions.js (3 address + 1 utxo) - Route the address/utxo cards through the named helpers instead of inline .map
- parseCredential() in cslTools: dedupe the two identical handleInputCreds copies - ChainStatusMessage: shared status banner for the 3 chain main tabs - AccessButtonShell: shared chrome for the 3 access buttons (eth had it 3x) - Skipped CardCell (would require a context abstraction, against the project's explicit-over-abstraction philosophy for marginal gain)
- Add ToastProvider/useToast + ToastContainer (top-right auto-dismissing banners) - Wrap the app in ToastProvider (outermost) so providers can surface errors - Cardano + Ethereum connect failures now show a toast (Cardano stays silent on the background reconnect); previously connect errors only hit the console - Add ToastProvider tests (show, manual dismiss, auto-dismiss, guard)
Format all source files per .prettierrc (printWidth 120, no semi, single quotes, no bracket spacing, trailing commas). Formatting only, no logic changes. (import-order plugin not installed, so import ordering unchanged.)
- Add prettier devDep + lint/lint:fix/format/format:check scripts - Remove dead import-order options from .prettierrc (plugin was never installed) - CI (test.yml): run format:check + lint before tests on push/PR - CI (build.yml): write production .env (REACT_APP_DEBUG=false) before build - Expand README (chains, stack, setup, scripts, structure, logging, testing) - Add .env.example documenting REACT_APP_DEBUG - logger.test.js: disable false-positive testing-library/no-debugging-utils
- Add useConnectionState(): shared NOT_CONNECTED/IN_PROGRESS/CONNECTED/NO_PROVIDER machine with named transitions (setConnected/setNotConnected/setInProgress/ setNoProvider) + raw setter; keeps setter identities stable - Adopt it in Cardano, Ethereum and Bitcoin providers (replaces per-provider useState + scattered setConnectionState calls); behavior unchanged - Add chainProvider.js documenting the common ChainProvider contract (CLAUDE.md) - Add useConnectionState tests. Kept providers otherwise explicit/separate per the project's clarity-over-abstraction philosophy (light step 9; step 10 BTC deferred pending a support decision)
…page Material Tailwind keeps inactive <TabPanel>s mounted and absolutely positioned; with no positioned ancestor they collapsed to the top-left of the viewport and overlaid the network toggle, swallowing clicks on the Cardano/Ethereum titles. Render only the active tab's content (keep the Material Tailwind header).
- Move chunkMessageTo64Bytes cslTools.js -> utils.js (pure fn; Buffer.byteLength instead of TextEncoder so it also runs under the jsdom test env) - cip20Tab imports it from utils - NFTTab: replace char-based sliceBy64Char (could exceed 64 bytes on multibyte text) with a thin adapter over the shared byte-based util, keeping CIP-25's string-or-array output - Add chunkMessageTo64Bytes tests
…ntain permissions' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
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.
Summary
Correctness fixes, DRY refactors, a debug-gated logger, tests + CI, error toasts, tooling/docs, and a light shared chain abstraction — plus two UI/util fixes found while testing. Behavior-preserving throughout (or better); reviewed and verified.
What's included
Correctness
ApiCardheight via a static Tailwind class map (dynamich-${n}was being purged).useContextguards=== undefined→!context(default wasnull, so they never fired).connect()paramrequestId→requestIdentification.TabPanels overlaid the page; now render only the active tab's content.Refactors (DRY)
yoroiProvider→cardanoProvider/useYoroi→useCardano.cardanoProvider; shareduseConnectionStatestate machine adopted by all providers; documentedChainProvidercontract.runApiCallhelper (22 cards),useResponseState(7 subtabs),buildCert(8 gov panels),hexArrayToBech32Addresses/hexArrayToUtxos,parseCredential,ChainStatusMessage,AccessButtonShell,InputWithLabelextended (routed ~22 input blocks), sharedchunkMessageTo64Bytes.Logging
loggerreplacing 159console.*calls; runtime toggle viawindow.dappLogs(persisted in localStorage) — flip logs on a deployed build without rebuilding.Tests & CI
test.ymlruns format/lint/tests on push+PR;build.ymlwrites a production.env(REACT_APP_DEBUG=false).Error UX
Tooling / docs
prettierdep +lint/formatscripts; expanded README;.env.example.Notes
npm run lint,npm run format:check,npm run test:ci(39 pass),CI=truebuild all green.🤖 Generated with Claude Code
Note
Medium Risk
Wide touch across wallet API cards and providers with behavior intended to stay the same; tab and Tailwind fixes are localized UI risks, while refactors could subtly change error/waiting handling if runApiCall options differ per card.
Overview
This release (2.4.0) is a broad maintainability and correctness pass: shared helpers and hooks, a debug-gated logger, visible error toasts, automated checks in CI, and a couple of UI fixes—without changing the dApp’s core wallet flows.
Correctness & UI:
ApiCardnow maps heights to static Tailwind classes so production builds don’t strip dynamich-${n}classes.tabsComponentonly mounts the active tab (fixes Material Tailwind panels overlaying the network toggle). Provider hooks use!contextfor missing-provider errors. CardanoconnectusesrequestIdentificationinstead ofrequestId.Architecture:
yoroiProvideris renamed tocardanoProvider/useCardano. ShareduseConnectionState,useResponseState,runApiCall(many API cards),buildCert(gov panels),parseCredential,AccessButtonShell,ChainStatusMessage, and extendedInputWithLabelcut duplicated code.console.*is replaced byloggerwithREACT_APP_DEBUGand runtimedappLogstoggles. Wallet connect failures surface viaToastProvider.Tooling: New
test.yml(format, lint,test:ci);build.ymlwrites production.env; Prettier/lint scripts,.env.example, and README updates. Adds unit tests (e.g. ApiCard, hooks, logger).Reviewed by Cursor Bugbot for commit 56a23dc. Bugbot is set up for automated code reviews on this repo. Configure here.