Restore Uint8Array pubkeys after localStorage round-trip - #45
pyramation merged 1 commit into
Conversation
There was a problem hiding this comment.
LGTM — thanks for the fix and for the thorough tests; sorry for the wait. Reviving at the LocalStorage.load() boundary is the right place: WalletManagerStore.restore() consumes that output directly, so every consumer of persisted chainWalletStates gets a real Uint8Array back (fixes #40). The revivePubkey helper correctly handles both the { "0": 1, "1": 2, ... } JSON shape and an already-typed array, and the account mapping leaves other fields untouched.
Verified on a local merge onto current main: pnpm install, pnpm build, pnpm test all pass (store 176/176, incl. the new save/load round-trip test); eslint src __tests__ in packages/store shows the same pre-existing issues as main, nothing new. Merges cleanly together with #39, #42 and #44.
Reviewed by Devin on behalf of @pyramation
JSON.stringify/parse in
LocalStorageturnedUint8Arraypubkeys into{0:…,1:…}objects. After a reload,WalletManagerStore.restore()loaded that state unchanged andChainWalletStore.getAccount()returned the cached account, so signing failed with "length of pubkey is incorrect".LocalStorage.load()now revives those numeric-key objects back intoUint8Array, so every consumer of persisted store state gets a real pubkey.Thanks @drimchansky for reporting this in #40.
Fixes #40.