From 7b852c3ff20faf04ae9a361627a4f9b51670792a Mon Sep 17 00:00:00 2001 From: Frederik Bolding Date: Fri, 13 Jan 2023 16:57:08 +0100 Subject: [PATCH] Fix EIP-712 input validation order (#17156) --- app/scripts/lib/typed-message-manager.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/scripts/lib/typed-message-manager.js b/app/scripts/lib/typed-message-manager.js index 397e27b0c..e41fd0fd6 100644 --- a/app/scripts/lib/typed-message-manager.js +++ b/app/scripts/lib/typed-message-manager.js @@ -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);