Skip to content

Fix/frontend state management#259

Merged
sanmipaul merged 27 commits into
mainfrom
fix/frontend-state-management
May 29, 2026
Merged

Fix/frontend state management#259
sanmipaul merged 27 commits into
mainfrom
fix/frontend-state-management

Conversation

@sanmipaul
Copy link
Copy Markdown
Owner

No description provided.

sanmipaul added 27 commits May 29, 2026 23:43
The useLocalStorage hook was imported but never used anywhere in the component.
Removing it cleans up the import section and eliminates the unused-import warning.
FocusTrapWrapper was imported but never directly referenced in App.tsx.
It is used within child components like WalletActionModals, not at this level.
This function was defined but never called anywhere in the component.
Network detection is handled by the NetworkStatus component instead.
debouncedWithdrawAmount was declared but only debouncedDepositAmount
is referenced elsewhere in the component. Removing the unused variable
eliminates the dead-code warning.
handleRefreshStats called an undefined fetchStats and was never
invoked from any event handler or effect in the component.
connectionError was referenced in JSX for error display and set in
connectWithStacks but never declared with useState, causing a runtime
reference error.
…walletManager states

These state variables were referenced throughout the component but
never declared, causing TypeScript errors and potential runtime crashes.
walletManager is lazily initialized via useState factory to avoid
unnecessary instantiation on re-renders.
… undefined

fetchUserStats was called in setTimeout after deposit and withdraw
transactions but never defined. The function fetches balance and points
from the stats API and updates the component state accordingly.
…tent

The </ErrorBoundary> tag at the end of AppContent's JSX had no matching
opening tag within the component. The ErrorBoundary wraps AppContent in
the parent App component. This extra closing tag would cause a React
rendering error.
Previously, handle2FAVerify returned false for both network errors and
authentication failures without distinction. Added logger.warn for
HTTP error status codes and logger.error for network exceptions.
Previously, handleWalletConnectSession assumed stacksAccount.split(':')[2]
always existed without validation, which could crash on malformed
account strings. Added null-check on the extracted address and proper
error messages for invalid sessions.
…osit/withdraw

The validateNetwork function was called in both handleDeposit and
handleWithdraw but was never defined, which would cause a runtime
ReferenceError. The function checks the networkMismatch state and
displays an appropriate error message.
…ReadOnlyFunction and standardPrincipalCV

The local trackAnalytics function called getAnalyticsUrl without importing
it, causing a ReferenceError at runtime. Also removed unused imports of
callReadOnlyFunction and standardPrincipalCV from @stacks/transactions.
…ons imports

These types were imported but never used in the component. Removing
them cleans up warnings and reduces bundle size marginally.
…enContractCall

Previously signTransaction returned the StacksContractCallOptions object
directly as a placeholder instead of actually signing via the Leather wallet.
Now uses openContractCall from @stacks/connect which prompts the user to
sign the transaction in their Leather wallet extension.
…tractCall

Previously signTransaction returned options object as stub and connect
only checked deprecated window.HiroWallet. Now uses StacksProvider or
HiroWallet for connection, implements proper signTransaction via
openContractCall, and handles disconnect via the provider API.
…der API

Previously signTransaction returned the options object as a stub and
connect only checked the deprecated window.XverseWallet. Now uses
XverseProvider or XverseWallet for connection and implements proper
signTransaction via the Stacks Provider API's stx_signTransaction method.
Previously signTransaction called .serialize() directly on StacksContractCallOptions which
does not have that method, causing a runtime crash. Now uses makeContractCall to build
the transaction first, then serializes the resulting StacksTransaction object.
…quest method to WalletKitService

Previously handleWalletConnectTransaction was a stub that only showed a placeholder
message without actually submitting any transaction. Now it properly builds the
transaction using WalletConnectProvider, signs it, broadcasts via Stacks network,
sends notifications, and tracks analytics.
Also added a request() method to WalletKitService for sending RPC calls to
connected wallet sessions.
…ng and signing

Previously WalletConnectProvider returned placeholder addresses and a
stub signTransaction. Now it properly retrieves active WalletConnect
sessions, extracts Stacks addresses, supports proper disconnect via
WalletKitService, and signs transactions using makeContractCall.
Removed enableWalletConnect, enableInjected, enableEIP6963, enableCoinbase,
featuredWalletIds, and swaps as these are EVM-specific options not supported
by createAppKit for Stacks chain. Keeping only Stacks-valid configuration
options to prevent runtime errors during AppKit initialization.
Previously signTransaction called .serialize() directly on StacksContractCallOptions
and tried to set .auth.spendingCondition.signature on the options object, both of
which would cause runtime errors. Now builds the transaction via makeContractCall
and returns a proper SignedTransactionResult.
…fresh method

stopWebSocketUpdates did not clear the associated refresh interval,
causing zombie intervals for tracked addresses. Also removed the
duplicate setRefreshInterval method that overlapped with startAutoRefresh,
reducing the risk of double-interval creation.
…ransactionResult

Previously signTransaction returned objects with non-standard fields like
status, currentSignatures, and requiredSignatures that didn't match the
SignedTransactionResult interface. Now returns properly typed objects.
Also fixed combineSignatures to return a valid SignedTransactionResult
instead of spreading the StacksContractCallOptions object.
…Effect in useDebouncedValidation

Previous implementation used Promise.resolve().then() to schedule state
updates, which is fragile with React concurrent mode and can cause subtle
timing bugs. Replaced with a proper useEffect that watches the debounced
value and clears isPending in the commit phase.
Previously pushManager.subscribe was called with an empty key when
REACT_APP_VAPID_PUBLIC_KEY was not set, causing a confusing browser error.
Now validates that the key exists and returns early with a clear log message.
…uests

Previously analytics fetch calls could hang indefinitely if the analytics
service was slow or unresponsive. Added a 3-second timeout via
AbortController to prevent lingering connections and silent failures.
@sanmipaul sanmipaul merged commit 3dbfd11 into main May 29, 2026
0 of 2 checks passed
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