-
Notifications
You must be signed in to change notification settings - Fork 9
feat: introduce custody ledger #400
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
base: main
Are you sure you want to change the base?
Changes from all commits
7a8cbc9
90f3f38
9b16cbc
72aa29f
9095c06
7f8d7fc
338bc81
92f01f4
e679fe0
3ebf9f1
7dd164a
1fcb2de
ed77f24
eb410b7
8306d55
eaccf4f
67fa831
6b234b8
cfb077c
d35d5a8
566b3a6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,3 +69,5 @@ scripts/private | |
|
|
||
| # nix | ||
| /result | ||
|
|
||
| ledger-penumbra | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,13 @@ | ||
| import { ExtensionStorageMigrations } from '../base'; | ||
|
|
||
| import local_v0_v1 from './local-v0-v1'; | ||
| import local_v1_v2 from './local-v1-v2'; | ||
| import local_v2_v3 from './local-v2-v3'; | ||
|
|
||
| import type { LocalStorageVersion } from '../local'; | ||
|
|
||
| export const localMigrations: ExtensionStorageMigrations<LocalStorageVersion, 0 | 1> = { | ||
| export const localMigrations: ExtensionStorageMigrations<LocalStorageVersion, 0 | 1 | 2> = { | ||
| 0: local_v0_v1, | ||
| 1: local_v1_v2, | ||
| 2: local_v2_v3, | ||
| } as const; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,11 @@ export default { | |
| knownSites: old.knownSites?.value ?? [], | ||
| params: old.params?.value, | ||
| numeraires: old.numeraires?.value ?? [], | ||
|
|
||
| // absent values now explicitly required | ||
| backupReminderSeen: undefined, | ||
| compactFrontierBlockHeight: undefined, | ||
| walletCreationBlockHeight: undefined, | ||
|
Comment on lines
+27
to
+30
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. comment: why the explicit requirement here? |
||
| }), | ||
| } satisfies MIGRATION; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,16 @@ export default { | |
| passwordKeyPrint: isVestigialItem(old.passwordKeyPrint) | ||
| ? old.passwordKeyPrint.value | ||
| : old.passwordKeyPrint, | ||
|
|
||
| // lol | ||
| backupReminderSeen: | ||
| typeof old.backupReminderSeen === 'boolean' ? old.backupReminderSeen : undefined, | ||
| compactFrontierBlockHeight: | ||
| typeof old.compactFrontierBlockHeight === 'number' | ||
| ? old.compactFrontierBlockHeight | ||
| : undefined, | ||
| walletCreationBlockHeight: | ||
| typeof old.walletCreationBlockHeight === 'number' ? old.walletCreationBlockHeight : undefined, | ||
|
Comment on lines
+27
to
+35
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. comment: can't we do without this? |
||
| }), | ||
| } satisfies MIGRATION; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import type * as FROM from '../versions/v2'; | ||
| import type * as TO from '../versions/v3'; | ||
| import { expectVersion, type Migration } from './util'; | ||
|
|
||
| type MIGRATION = Migration<FROM.VERSION, FROM.LOCAL, TO.VERSION, TO.LOCAL>; | ||
|
|
||
| export default { | ||
| version: v => expectVersion(v, 2, 3), | ||
| transform: ({ | ||
| knownSites, | ||
| numeraires, | ||
| wallets, | ||
|
|
||
| backupReminderSeen, | ||
| compactFrontierBlockHeight, | ||
| frontendUrl, | ||
| fullSyncHeight, | ||
| grpcEndpoint, | ||
| params, | ||
| passwordKeyPrint, | ||
| walletCreationBlockHeight, | ||
| }) => ({ | ||
| knownSites: knownSites ?? [], | ||
| numeraires: numeraires ?? [], | ||
| wallets: wallets ?? [], | ||
|
|
||
| backupReminderSeen, | ||
| compactFrontierBlockHeight, | ||
| frontendUrl, | ||
| fullSyncHeight, | ||
| grpcEndpoint, | ||
| params, | ||
| passwordKeyPrint, | ||
| walletCreationBlockHeight, | ||
| }), | ||
| } satisfies MIGRATION; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,13 @@ | ||
| export type Explicit<T> = { | ||
| [K in keyof Required<T>]: T[K]; | ||
| }; | ||
|
|
||
| export interface Migration< | ||
| FromV extends number, | ||
| FromState extends Record<string, unknown> = Record<string, unknown>, | ||
| ToV extends number = number, | ||
| ToState extends Record<string, unknown> = Record<string, unknown>, | ||
| > { | ||
| version(iv: FromV): ToV; | ||
| transform(fs: Partial<FromState>): ToState | Promise<ToState>; | ||
| transform(fs: Partial<FromState>): Explicit<ToState> | Promise<Explicit<ToState>>; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. comment: explicit flag here requires older migrations set optional keys to undefined to satisfy the type. don't know what the implication of that is, but i'd rather not change this. let's revert and remove absent values that are now explicitly required. |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| export { type LOCAL, type SYNC, type VERSION }; | ||
|
|
||
| type VERSION = 3; | ||
|
|
||
| type SYNC = void; | ||
|
|
||
| type LOCAL = { | ||
| // required values | ||
| knownSites: { choice: 'Approved' | 'Denied' | 'Ignored'; date: number; origin: string }[]; | ||
| /** Stringified AssetId */ | ||
| numeraires: string[]; | ||
| wallets: { | ||
| custody: | ||
| | { encryptedSeedPhrase: { cipherText: string; nonce: string } } | ||
| | { encryptedSpendKey: { cipherText: string; nonce: string } } | ||
| | { ledgerUsb: { cipherText: string; nonce: string } }; | ||
| /** Stringified FullViewingKey */ | ||
| fullViewingKey: string; | ||
| /** Stringified WalletId */ | ||
| id: string; | ||
| label: string; | ||
| }[]; | ||
|
|
||
| // optional values | ||
| backupReminderSeen?: boolean; | ||
| /** integer */ | ||
| compactFrontierBlockHeight?: number; | ||
| /** url string */ | ||
| frontendUrl?: string; | ||
| /** integer */ | ||
| fullSyncHeight?: number; | ||
| /** url string */ | ||
| grpcEndpoint?: string; | ||
| /** Stringified AppParameters */ | ||
| params?: string; | ||
| /** KeyPrintJson */ | ||
| passwordKeyPrint?: { hash: string; salt: string }; | ||
| /** integer */ | ||
| walletCreationBlockHeight?: number; | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| snapshots-tmp | ||
| ledger-penumbra |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment: this caught my eye. v3 schema suggests that param is stored as a string, not a parsed object. let's revert this back to
AppParameters.fromJsonString(stored).