aboutsummaryrefslogtreecommitdiffstats
path: root/old-ui
diff options
context:
space:
mode:
authorbitpshr <mail@bitpshr.net>2018-09-11 05:11:57 +0800
committerbitpshr <mail@bitpshr.net>2018-09-14 03:40:57 +0800
commit36dd0354e777e6786ae0d2284ffcb1adbc6d85f7 (patch)
treee5c965249db37ce354e61820800e13bb33d00497 /old-ui
parentad6e31ec84d4e2c3a0ed7a3a6ceea499db2644b8 (diff)
downloadtangerine-wallet-browser-36dd0354e777e6786ae0d2284ffcb1adbc6d85f7.tar
tangerine-wallet-browser-36dd0354e777e6786ae0d2284ffcb1adbc6d85f7.tar.gz
tangerine-wallet-browser-36dd0354e777e6786ae0d2284ffcb1adbc6d85f7.tar.bz2
tangerine-wallet-browser-36dd0354e777e6786ae0d2284ffcb1adbc6d85f7.tar.lz
tangerine-wallet-browser-36dd0354e777e6786ae0d2284ffcb1adbc6d85f7.tar.xz
tangerine-wallet-browser-36dd0354e777e6786ae0d2284ffcb1adbc6d85f7.tar.zst
tangerine-wallet-browser-36dd0354e777e6786ae0d2284ffcb1adbc6d85f7.zip
Implement latest EIP-712 protocol
Diffstat (limited to 'old-ui')
-rw-r--r--old-ui/app/components/pending-typed-msg-details.js3
-rw-r--r--old-ui/app/components/typed-message-renderer.js27
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' }),
+ ]) : '',
+ ]
+}