diff options
Implement latest EIP-712 protocol
Diffstat (limited to 'old-ui')
-rw-r--r-- | old-ui/app/components/pending-typed-msg-details.js | 3 | ||||
-rw-r--r-- | old-ui/app/components/typed-message-renderer.js | 27 |
2 files changed, 27 insertions, 3 deletions
diff --git a/old-ui/app/components/pending-typed-msg-details.js b/old-ui/app/components/pending-typed-msg-details.js index b5fd29f71..f95bf43a7 100644 --- a/old-ui/app/components/pending-typed-msg-details.js +++ b/old-ui/app/components/pending-typed-msg-details.js @@ -21,7 +21,7 @@ PendingMsgDetails.prototype.render = function () { var identity = state.identities[address] || { address: address } var account = state.accounts[address] || { address: address } - var { data } = msgParams + var { data, version } = msgParams return ( h('div', { @@ -48,6 +48,7 @@ PendingMsgDetails.prototype.render = function () { h('label.font-small', { style: { display: 'block' } }, 'YOU ARE SIGNING'), h(TypedMessageRenderer, { value: data, + version, style: { height: '215px', }, diff --git a/old-ui/app/components/typed-message-renderer.js b/old-ui/app/components/typed-message-renderer.js index 19e46f4fc..0eacb2129 100644 --- a/old-ui/app/components/typed-message-renderer.js +++ b/old-ui/app/components/typed-message-renderer.js @@ -2,6 +2,7 @@ const Component = require('react').Component const h = require('react-hyperscript') const inherits = require('util').inherits const extend = require('xtend') +const { ObjectInspector } = require('react-inspector') module.exports = TypedMessageRenderer @@ -12,8 +13,16 @@ function TypedMessageRenderer () { TypedMessageRenderer.prototype.render = function () { const props = this.props - const { value, style } = props - const text = renderTypedData(value) + const { value, version, style } = props + let text + switch (version) { + case 'V1': + text = renderTypedData(value) + break + case 'V2': + text = renderTypedDataV2(value) + break + } const defaultStyle = extend({ width: '315px', @@ -44,3 +53,17 @@ function renderTypedData (values) { ]) }) } + +function renderTypedDataV2 (values) { + const { domain, message } = JSON.parse(values) + return [ + domain ? h('div', [ + h('h1', 'Domain'), + h(ObjectInspector, { data: domain, expandLevel: 1, name: 'domain' }), + ]) : '', + message ? h('div', [ + h('h1', 'Message'), + h(ObjectInspector, { data: message, expandLevel: 1, name: 'message' }), + ]) : '', + ] +} |