Skip to content

Commit

Permalink
fix: adopt to ethers changes
Browse files Browse the repository at this point in the history
  • Loading branch information
janek26 committed Aug 29, 2022
1 parent debee32 commit b1240c1
Showing 1 changed file with 25 additions and 18 deletions.
43 changes: 25 additions & 18 deletions packages/extension/src/background/schema/backup.schema.ts
@@ -1,27 +1,32 @@
import { array, number, object, string } from "yup"

const cryptoValidation = object()
.default(undefined)
.optional()
.shape({
cipher: string().required(),
ciphertext: string().required(),
kdf: string().required(),
mac: string().required(),
cipherparams: object().required().shape({
iv: string().required(),
}),
kdfparams: object().required().shape({
salt: string().required(),
n: number().required(),
dklen: number().required(),
p: number().required(),
r: number().required(),
}),
})

export default object({
// standard backup/keystore file
address: string().required(),
version: number().integer().required(),
Crypto: object()
.required()
.shape({
cipher: string().required(),
ciphertext: string().required(),
kdf: string().required(),
mac: string().required(),
cipherparams: object().required().shape({
iv: string().required(),
}),
kdfparams: object().required().shape({
salt: string().required(),
n: number().required(),
dklen: number().required(),
p: number().required(),
r: number().required(),
}),
}),
// one of both must be there
crypto: cryptoValidation,
Crypto: cryptoValidation,
// ethers.js additions
"x-ethers": object().required().shape({
mnemonicCounter: string().required(),
Expand All @@ -47,4 +52,6 @@ export default object({
}),
),
}),
}).test("crypto", "just one of crypto or Crypto must be present", (val) => {
return !val.crypto !== !val.Crypto
})

0 comments on commit b1240c1

Please sign in to comment.