Skip to content

Restore Uint8Array pubkeys after localStorage round-trip - #45

Merged
pyramation merged 1 commit into
hyperweb-io:mainfrom
Steve0x2a:fix/restore-uint8array-pubkey-localstorage
Oct 2, 2026
Merged

pyramation merged 1 commit into
hyperweb-io:mainfrom
Steve0x2a:fix/restore-uint8array-pubkey-localstorage

Conversation

@Steve0x2a

Copy link
Copy Markdown
Contributor

JSON.stringify/parse in LocalStorage turned Uint8Array pubkeys into {0:…,1:…} objects. After a reload, WalletManagerStore.restore() loaded that state unchanged and ChainWalletStore.getAccount() returned the cached account, so signing failed with "length of pubkey is incorrect".

LocalStorage.load() now revives those numeric-key objects back into Uint8Array, so every consumer of persisted store state gets a real pubkey.

Thanks @drimchansky for reporting this in #40.

Fixes #40.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

pyramation added a commit that referenced this pull request Oct 2, 2026
@pyramation
pyramation merged commit 5c69234 into hyperweb-io:main Oct 2, 2026
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.

Uint8Array pubkeys degrade to plain objects after localStorage round-trip

2 participants