mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 09:57:02 +01:00
Better 712 errors (#13939)
* Added more info for EIP-712 schema errors * Changed EthereumProviderError to EthereumRpcError * Fixed error code to not be hardcoded for signTypedData
This commit is contained in:
parent
a5ee4097f5
commit
4c908d7413
@ -1,7 +1,7 @@
|
|||||||
import EventEmitter from 'events';
|
import EventEmitter from 'events';
|
||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { ObservableStore } from '@metamask/obs-store';
|
import { ObservableStore } from '@metamask/obs-store';
|
||||||
import { ethErrors } from 'eth-rpc-errors';
|
import { EthereumRpcError, ethErrors } from 'eth-rpc-errors';
|
||||||
import { typedSignatureHash, TYPED_MESSAGE_SCHEMA } from 'eth-sig-util';
|
import { typedSignatureHash, TYPED_MESSAGE_SCHEMA } from 'eth-sig-util';
|
||||||
import log from 'loglevel';
|
import log from 'loglevel';
|
||||||
import jsonschema from 'jsonschema';
|
import jsonschema from 'jsonschema';
|
||||||
@ -192,11 +192,13 @@ export default class TypedMessageManager extends EventEmitter {
|
|||||||
data.primaryType in data.types,
|
data.primaryType in data.types,
|
||||||
`Primary type of "${data.primaryType}" has no type definition.`,
|
`Primary type of "${data.primaryType}" has no type definition.`,
|
||||||
);
|
);
|
||||||
assert.equal(
|
if (validation.errors.length !== 0) {
|
||||||
validation.errors.length,
|
throw new EthereumRpcError(
|
||||||
0,
|
ethErrors.rpc.invalidParams,
|
||||||
'Signing data must conform to EIP-712 schema. See https://git.io/fNtcx.',
|
'Signing data must conform to EIP-712 schema. See https://git.io/fNtcx.',
|
||||||
);
|
validation.errors.map((v) => v.message.toString()),
|
||||||
|
);
|
||||||
|
}
|
||||||
let { chainId } = data.domain;
|
let { chainId } = data.domain;
|
||||||
if (chainId) {
|
if (chainId) {
|
||||||
const activeChainId = parseInt(this._getCurrentChainId(), 16);
|
const activeChainId = parseInt(this._getCurrentChainId(), 16);
|
||||||
|
Loading…
Reference in New Issue
Block a user