1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 01:39:44 +01:00

Fix EIP-712 input validation order (#17156)

This commit is contained in:
Frederik Bolding 2023-01-13 16:57:08 +01:00 committed by GitHub
parent 00aee11c2a
commit 7b852c3ff2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -197,10 +197,6 @@ export default class TypedMessageManager extends EventEmitter {
data = JSON.parse(params.data);
}, '"data" must be a valid JSON string.');
const validation = jsonschema.validate(data, TYPED_MESSAGE_SCHEMA);
assert.ok(
data.primaryType in data.types,
`Primary type of "${data.primaryType}" has no type definition.`,
);
if (validation.errors.length !== 0) {
throw ethErrors.rpc.invalidParams({
message:
@ -208,6 +204,10 @@ export default class TypedMessageManager extends EventEmitter {
data: validation.errors.map((v) => v.message.toString()),
});
}
assert.ok(
data.primaryType in data.types,
`Primary type of "${data.primaryType}" has no type definition.`,
);
let { chainId } = data.domain;
if (chainId) {
const activeChainId = parseInt(this._getCurrentChainId(), 16);