Skip to content

Commit 45cd30f

Browse files
committed
Loosen the strictness of the vault records persisted
This relax on whether existing records follow the valid shape defined by the cleaners is only because during development, the underlying types change and cause a permanently broken state for the account. In the future, we can harden this API to throw an error to not risk losing data if we desire to.
1 parent bba0718 commit 45cd30f

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/util/vault/edgeVault.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,22 @@ export const makeEdgeVault = (config: EdgeVaultConfig): EdgeVault => {
6060
>(
6161
uuid: string,
6262
info: T
63-
): Promise<VaultRecord<T>> => {
63+
): Promise<VaultRecord<T> | undefined> => {
6464
let existingRecord: VaultRecord<T>
6565
const recordText = await vaultDisklet.getText(`${info.type}/${uuid}.json`)
6666

67-
if (info.type === 'personalInfo') {
68-
existingRecord = asVaultPersonalRecord(recordText) as VaultRecord<T>
69-
} else if (info.type === 'addressInfo') {
70-
existingRecord = asVaultAddressRecord(recordText) as VaultRecord<T>
71-
} else {
72-
existingRecord = asVaultBankAccountRecord(recordText) as VaultRecord<T>
67+
try {
68+
if (info.type === 'personalInfo') {
69+
existingRecord = asVaultPersonalRecord(recordText) as VaultRecord<T>
70+
} else if (info.type === 'addressInfo') {
71+
existingRecord = asVaultAddressRecord(recordText) as VaultRecord<T>
72+
} else {
73+
existingRecord = asVaultBankAccountRecord(recordText) as VaultRecord<T>
74+
}
75+
} catch (_) {
76+
// TODO: Remove this, and `undefined` from the return type, once
77+
// EdgeVault is stable and in production
78+
return undefined
7379
}
7480

7581
return existingRecord

0 commit comments

Comments
 (0)