Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use latest signTypedData version from eth-sig-util #6930

Merged
merged 1 commit into from
Aug 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/scripts/controllers/network/createMetamaskMiddleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ function createMetamaskMiddleware ({
processEthSignMessage,
processTypedMessage,
processTypedMessageV3,
processTypedMessageV4,
processPersonalMessage,
getPendingNonce,
}) {
Expand All @@ -27,6 +28,7 @@ function createMetamaskMiddleware ({
processEthSignMessage,
processTypedMessage,
processTypedMessageV3,
processTypedMessageV4,
processPersonalMessage,
}),
createPendingNonceMiddleware({ getPendingNonce }),
Expand Down
1 change: 1 addition & 0 deletions app/scripts/lib/typed-message-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.')
Expand Down
5 changes: 4 additions & 1 deletion app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -1777,4 +1781,3 @@ module.exports = class MetamaskController extends EventEmitter {
return this.keyringController.setLocked()
}
}

7 changes: 4 additions & 3 deletions ui/app/components/app/signature-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', [
Expand Down Expand Up @@ -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()
Expand Down