Skip to content

Commit

Permalink
fix(core): remove circular import in store.ts & MnemonicWallet (#279)
Browse files Browse the repository at this point in the history
The circular import: `src/wallets/mnemonic` imports `src/store`, which imports a
few types from `src/wallets`. The `src/wallets/mnemonic` is still loaded when
`src/store` imports `src/wallet` despite nothing from `src/wallets/mnemonic`
being used.

In short, `src/wallets/mnemonic` imports `src/store`, which indirectly imports
`src/wallets/mnemonic`.

This circular import caused an odd issue where the persisted mnemonic
had "undefined_mnemonic" as the key in localStorage because `LOCAL_STORAGE_KEY`
constant (defined in `src/store.ts` before building the package) was used before
it was defined in the `dist/index.js` build output file. The bundler got
confused by the circular import and put the modules in the resulting
`dist/index.js` in the wrong order.
  • Loading branch information
No-Cash-7970 authored Oct 1, 2024
1 parent b3451d7 commit d3f2764
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/use-wallet/src/store.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import algosdk from 'algosdk'
import { logger } from 'src/logger'
import { NetworkId, isValidNetworkId } from 'src/network'
import { WalletId, type WalletAccount } from 'src/wallets'
import { WalletId, type WalletAccount } from 'src/wallets/types'
import type { Store } from '@tanstack/store'

export type WalletState = {
Expand Down

0 comments on commit d3f2764

Please sign in to comment.