diff --git a/app/scripts/controllers/network/createMetamaskMiddleware.js b/app/scripts/controllers/network/createMetamaskMiddleware.js index 319c5bf3e127..5dcd3a895ec2 100644 --- a/app/scripts/controllers/network/createMetamaskMiddleware.js +++ b/app/scripts/controllers/network/createMetamaskMiddleware.js @@ -12,6 +12,7 @@ function createMetamaskMiddleware ({ processEthSignMessage, processTypedMessage, processTypedMessageV3, + processTypedMessageV4, processPersonalMessage, getPendingNonce, }) { @@ -27,6 +28,7 @@ function createMetamaskMiddleware ({ processEthSignMessage, processTypedMessage, processTypedMessageV3, + processTypedMessageV4, processPersonalMessage, }), createPendingNonceMiddleware({ getPendingNonce }), diff --git a/app/scripts/lib/typed-message-manager.js b/app/scripts/lib/typed-message-manager.js index b10145f3b5c1..5e2a4cd0a1b5 100644 --- a/app/scripts/lib/typed-message-manager.js +++ b/app/scripts/lib/typed-message-manager.js @@ -141,6 +141,7 @@ module.exports = class TypedMessageManager extends EventEmitter { }, 'Expected EIP712 typed data') break case 'V3': + case 'V4': let data assert.equal(typeof params, 'object', 'Params should be an object.') assert.ok('data' in params, 'Params must include a data field.') diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 84a25b008f2e..843d8cd10179 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -318,6 +318,7 @@ module.exports = class MetamaskController extends EventEmitter { processEthSignMessage: this.newUnsignedMessage.bind(this), processTypedMessage: this.newUnsignedTypedMessage.bind(this), processTypedMessageV3: this.newUnsignedTypedMessage.bind(this), + processTypedMessageV4: this.newUnsignedTypedMessage.bind(this), processPersonalMessage: this.newUnsignedPersonalMessage.bind(this), getPendingNonce: this.getPendingNonce.bind(this), } @@ -1100,6 +1101,9 @@ module.exports = class MetamaskController extends EventEmitter { case 'V3': signature = sigUtil.signTypedData(privKey, { data: JSON.parse(cleanMsgParams.data) }) break + case 'V4': + signature = sigUtil.signTypedData_v4(privKey, { data: JSON.parse(cleanMsgParams.data) }) + break } } else { signature = await keyring.signTypedData(address, cleanMsgParams.data) @@ -1777,4 +1781,3 @@ module.exports = class MetamaskController extends EventEmitter { return this.keyringController.setLocked() } } - diff --git a/ui/app/components/app/signature-request.js b/ui/app/components/app/signature-request.js index 32823aa8e41c..d6765ed15a30 100644 --- a/ui/app/components/app/signature-request.js +++ b/ui/app/components/app/signature-request.js @@ -215,7 +215,7 @@ SignatureRequest.prototype.msgHexToText = function (hex) { } // eslint-disable-next-line react/display-name -SignatureRequest.prototype.renderTypedDataV3 = function (data) { +SignatureRequest.prototype.renderTypedData = function (data) { const { domain, message } = JSON.parse(data) return [ h('div.request-signature__typed-container', [ @@ -267,8 +267,9 @@ SignatureRequest.prototype.renderBody = function () { }), }, [notice]), - h('div.request-signature__rows', type === 'eth_signTypedData' && version === 'V3' ? - this.renderTypedDataV3(data) : + h('div.request-signature__rows', + type === 'eth_signTypedData' && (version === 'V3' || version === 'V4') ? + this.renderTypedData(data) : rows.map(({ name, value }) => { if (typeof value === 'boolean') { value = value.toString()