-
Notifications
You must be signed in to change notification settings - Fork 36
chore: export all connected accounts on useAccount hook #489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: 5366d16 The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Claude finished @ignaciosantise's task —— View job Code Review Complete ✅Tasks
Review Findings🔴 Critical Issue: Missing TypeScript Type DefinitionLocation: The new Recommendation: export interface AccountInfo {
address: string;
namespace: string;
chainId: string;
type?: AccountType;
}Then update the return type: return {
allAccounts, // Type will be AccountInfo[]
// ... rest
};🟡 Type Safety Issue: Potential Undefined ValueLocation: The Current behavior: type: _connection.type // Can be 'eoa' | 'smartAccount' | undefinedRecommendation: Consider whether
🟡 CAIP Standard Parsing IssueLocation: The code assumes CAIP addresses follow the format Current code: const [namespace, chainId, plainAddress] = account.split(':');Potential issues:
Recommendation: const parts = account.split(':');
if (parts.length !== 3) {
// Log error or skip invalid accounts
continue; // or return early
}
const [namespace, chainId, plainAddress] = parts;Or at minimum, add JSDoc documentation noting the expected format and behavior with malformed data. 📝 Documentation MissingLocation: The hook and the new
Recommendation: /**
* Returns all connected accounts across all active connections.
*
* @returns An array of account objects, each containing:
* - address: The plain address (without CAIP prefix)
* - namespace: The blockchain namespace (e.g., 'eip155', 'solana')
* - chainId: The chain ID from the CAIP address
* - type: The account type ('eoa' | 'smartAccount' | undefined)
*/
const allAccounts = useMemo(() => {
// ...
}, [connections]);✅ Positives
SummaryThe implementation is mostly sound, but needs:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances the useAccount hook to expose all connected accounts across different connections. The hook now provides a flattened list of accounts with their addresses, namespaces, chain IDs, and connection types.
Key Changes:
- Added
allAccountsproperty to theuseAccounthook return value - Implemented a memoized computation that extracts and flattens account information from all active connections
- Updated changeset to document this enhancement across all affected packages
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/appkit/src/hooks/useAccount.ts | Added allAccounts computed property that flattens and exposes all accounts from connections with their metadata |
| .changeset/stupid-cloths-admire.md | Added changeset documenting the export of account list on useAccount hook |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|



Enhancement to the
useAccounthook:useAccounthook inpackages/appkit/src/hooks/useAccount.tsnow exposes anallAccountsproperty, which provides a flattened list of all accounts from the current connections, including their addresses, namespaces, chain IDs, and types. [1] [2]Note
Expose all connected accounts via useAccount (with typed Account), normalize chain types, and re-export types; add changeset for patch releases.
packages/appkit/src/hooks/useAccount.ts):Accountinterface and exposeallAccountsaggregated from all connections (parsed from CAIP-10; logs invalid entries).chainIdnow string;chaintyped asAppKitNetwork.packages/appkit/src/index.ts):useAccountandtype Account as UseAccountReturn.Written by Cursor Bugbot for commit 5366d16. This will update automatically on new commits. Configure here.