Repository navigation
feat(wallet-sdk): accounts slice (step 6) #1167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
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
7 changes: 0 additions & 7 deletions
7
apps/web-wallet/app/features/accounts/account-service-hooks.ts
This file was deleted.
Oops, something went wrong.
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
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
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
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
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
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
56 changes: 56 additions & 0 deletions
56
apps/web-wallet/app/features/shared/session-key-queries.test.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| import { describe, expect, it } from 'bun:test'; | ||
| import { QueryClient } from '@tanstack/react-query'; | ||
| import { seedQueryOptions, xpubQueryOptions } from './cashu-query-options'; | ||
| import { encryptionQueryOptions } from './encryption-hooks'; | ||
| import { | ||
| derivedKeyQueryPrefix, | ||
| evictDerivedKeyQueries, | ||
| } from './session-key-queries'; | ||
| import { sparkMnemonicQueryOptions } from './spark-query-options'; | ||
|
|
||
| describe('evictDerivedKeyQueries', () => { | ||
| it('drops every derived-key query under the shared prefix (incl. derivation-path variants) in one removeQueries, and leaves others', () => { | ||
| const queryClient = new QueryClient(); | ||
| // The five derived-key queries, each under the shared prefix, mirroring the | ||
| // shapes the query defs produce (two carry a derivation-path segment). | ||
| const derivedKeys = [ | ||
| [derivedKeyQueryPrefix, 'encryption'], | ||
| [derivedKeyQueryPrefix, 'cashu-seed'], | ||
| [derivedKeyQueryPrefix, 'cashu-xpub', "m/0'"], | ||
| [derivedKeyQueryPrefix, 'cashu-private-key', "m/0'"], | ||
| [derivedKeyQueryPrefix, 'spark-mnemonic'], | ||
| ]; | ||
| for (const queryKey of derivedKeys) { | ||
| queryClient.setQueryData(queryKey, 'previous-user'); | ||
| } | ||
| // A non-derived query must survive the prefix eviction. | ||
| queryClient.setQueryData(['auth-state'], 'keep'); | ||
|
|
||
| evictDerivedKeyQueries(queryClient); | ||
|
|
||
| for (const queryKey of derivedKeys) { | ||
| expect(queryClient.getQueryData(queryKey)).toBeUndefined(); | ||
| } | ||
| expect(queryClient.getQueryData<string>(['auth-state'])).toBe('keep'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('derived-key query defs', () => { | ||
| it('key every derived-key query under the shared prefix, so evictDerivedKeyQueries drops them', () => { | ||
| // Asserts the defs themselves adopt the prefix: a def regressing to a bare | ||
| // key — a silent cache-key mismatch typecheck cannot catch — fails here, not | ||
| // only in the grep gate. Covers the cashu-xpub derivation-path variant both | ||
| // with and without a path. | ||
| const queryClient = new QueryClient(); | ||
| const derivedKeyDefs = [ | ||
| encryptionQueryOptions().queryKey, | ||
| seedQueryOptions().queryKey, | ||
| xpubQueryOptions({ queryClient, derivationPath: "m/0'" }).queryKey, | ||
| xpubQueryOptions({ queryClient }).queryKey, | ||
| sparkMnemonicQueryOptions().queryKey, | ||
| ]; | ||
| for (const queryKey of derivedKeyDefs) { | ||
| expect(queryKey[0]).toBe(derivedKeyQueryPrefix); | ||
| } | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.