Repository navigation
fix(sdk): match ACP store accounts case-insensitively - #401
Merged
architect-dev merged 1 commit intoOct 14, 2026
Merged
Conversation
ACPs are written under the wallet client's checksummed address, but reads use whatever account the caller passes. A lowercased address (from an indexer, a URL or user input) did not match the stored key, so decryptForView(...).setAccount(addr) failed with ACPNotFound and getOrCreateSelfACP never found the active ACP, creating a new one and asking the wallet for another signature on every call. Resolve the account to the key it is already stored under before reading or writing. A new account keeps the spelling it is first written with, so existing persisted data and the React hooks, which read the raw snapshot, are unaffected.
🦋 Changeset detectedLatest commit: 2bbd6ba 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 |
architect-dev
approved these changes
Oct 14, 2026
architect-dev
left a comment
Collaborator
There was a problem hiding this comment.
Good fix. Will probably remove this changeset after it merges. I don't think its necessary to document this as a change since its a small bugfix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ACPs are written under the wallet client's address (
storeACP/storeActiveACPincore/acps.tsusewalletClient.account.address, which viem returns checksummed), but reads use the account the caller passes:getOrCreateSelfACP(chainId, account),getActiveACP(chainId, account), anddecryptForView(...).setAccount(account)/decryptForTx(...).setAccount(account). The store inacps/store.tskeys by the raw string, so the same address in a different case does not match.In practice an address that comes lowercased from an indexer, a URL or user input:
decryptForView(...).setAccount(addr)fail withACPNotFoundalthough an active ACP exists for that account;getOrCreateSelfACP(chainId, lowercaseAddr)miss the active ACP every time, so it creates a new one and asks the wallet for another signature on each call.The issuer checks in
core/acps.tsalready compare addresses withtoLowerCase().This adds a small
resolveAccountKeythat maps an account to the key it is already stored under (case-insensitive match), used by every read and write in the store. It does not rewrite keys: a new account keeps the spelling it is first written with, which is the connected wallet's address in practice, so existing persisted data and the@cofhe/reacthooks that read the raw snapshot (state.acps[chainId][account]) keep working.Tests:
core/test/acpStoreAccountCase.test.tscovers the lowercase lookup of the active ACP,getOrCreateSelfACPwith a lowercase account (no second signature), and one bucket per account across cases. It uses a local signing wallet and a stubbed EIP-712 domain, so it needs no RPC. All 3 fail on master and pass with the fix. Theacps/testsuites still pass, and in the node test project the only failures are the existing network-dependent ones, identical with and without this change. eslint and prettier are clean on the changed files. A changeset is included.Note
Low Risk
Scoped to client-side ACP localStorage key resolution; no auth or on-chain behavior changes, and existing stored key spellings are preserved.
Overview
ACP persisted store lookups now treat account addresses as case-insensitive, fixing misses when callers pass a lowercased address (indexer, URL, user input) while data was saved under the wallet’s checksummed key.
A new
resolveAccountKeymaps any account string to the existing bucket key (or keeps the incoming spelling on first write) and is wired through all store getters/setters for ACPs and active ACP hashes, sogetOrCreateSelfACP,decryptForView/setAccount, and related paths reuse the same ACP instead of raisingACPNotFoundor triggering repeat wallet signatures. Persisted localStorage keys are not migrated—only lookup/write resolution changes.Adds offline Vitest coverage for lowercase reads, single-signature reuse, and one bucket per account across cases, plus a patch changeset for
@cofhe/sdk.Reviewed by Cursor Bugbot for commit 2bbd6ba. Bugbot is set up for automated code reviews on this repo. Configure here.