Skip to content

Commit c50f93a

Browse files
katspaughclaude
andcommitted
refactor: Use generateWalletId() for single source of truth
Replaces inline randomBytes(16).toString('hex') calls in wallet-store.ts with the centralized generateWalletId() utility function to eliminate code duplication and maintain consistency. Changes: - Import generateWalletId from key-generation.ts - Replace wallet ID generation in importWallet() (line 122) - Replace wallet ID generation in importLedgerWallet() (line 165) This ensures all wallet IDs are generated using the same method across the codebase. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent a5cf17d commit c50f93a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/storage/wallet-store.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { Wallet, WalletStore, PrivateKeyWallet, LedgerWallet } from '../typ
55
import { WalletError } from '../utils/errors.js'
66
import { isValidPrivateKey, normalizePrivateKey } from '../utils/validation.js'
77
import { checksumAddress } from '../utils/ethereum.js'
8+
import { generateWalletId } from '../utils/key-generation.js'
89

910
// Simple encryption for private keys
1011
// Note: For production, consider using OS keychain (keytar/keychain)
@@ -118,7 +119,7 @@ export class WalletStorageService {
118119
}
119120

120121
// Create wallet metadata
121-
const walletId = randomBytes(16).toString('hex')
122+
const walletId = generateWalletId()
122123
const wallet: PrivateKeyWallet = {
123124
type: 'private-key',
124125
id: walletId,
@@ -161,7 +162,7 @@ export class WalletStorageService {
161162
}
162163

163164
// Create wallet metadata
164-
const walletId = randomBytes(16).toString('hex')
165+
const walletId = generateWalletId()
165166
const wallet: LedgerWallet = {
166167
type: 'ledger',
167168
id: walletId,

0 commit comments

Comments
 (0)