diff --git a/app/scripts/lib/decrypt-message-manager.js b/app/scripts/lib/decrypt-message-manager.js index 24b8e8dd7..cf67ee03e 100644 --- a/app/scripts/lib/decrypt-message-manager.js +++ b/app/scripts/lib/decrypt-message-manager.js @@ -3,6 +3,7 @@ import ObservableStore from 'obs-store' import ethUtil from 'ethereumjs-util' import { ethErrors } from 'eth-json-rpc-errors' import createId from './random-id' +import { MESSAGE_TYPE } from './enums' const hexRe = /^[0-9A-Fa-f]+$/g import log from 'loglevel' @@ -124,7 +125,7 @@ export default class DecryptMessageManager extends EventEmitter { msgParams: msgParams, time: time, status: 'unapproved', - type: 'eth_decrypt', + type: MESSAGE_TYPE.ETH_DECRYPT, } this.addMsg(msgData) diff --git a/app/scripts/lib/encryption-public-key-manager.js b/app/scripts/lib/encryption-public-key-manager.js index 4055104c0..a714f60e4 100644 --- a/app/scripts/lib/encryption-public-key-manager.js +++ b/app/scripts/lib/encryption-public-key-manager.js @@ -3,6 +3,7 @@ import ObservableStore from 'obs-store' import { ethErrors } from 'eth-json-rpc-errors' import createId from './random-id' import log from 'loglevel' +import { MESSAGE_TYPE } from './enums' /** * Represents, and contains data about, an 'eth_getEncryptionPublicKey' type request. These are created when @@ -114,7 +115,7 @@ export default class EncryptionPublicKeyManager extends EventEmitter { msgParams: address, time: time, status: 'unapproved', - type: 'eth_getEncryptionPublicKey', + type: MESSAGE_TYPE.ETH_GET_ENCRYPTION_PUBLIC_KEY, } if (req) { diff --git a/app/scripts/lib/enums.js b/app/scripts/lib/enums.js index 50a8ccf68..4e6efc07e 100644 --- a/app/scripts/lib/enums.js +++ b/app/scripts/lib/enums.js @@ -9,11 +9,20 @@ const PLATFORM_EDGE = 'Edge' const PLATFORM_FIREFOX = 'Firefox' const PLATFORM_OPERA = 'Opera' +const MESSAGE_TYPE = { + ETH_DECRYPT: 'eth_decrypt', + ETH_GET_ENCRYPTION_PUBLIC_KEY: 'eth_getEncryptionPublicKey', + ETH_SIGN: 'eth_sign', + ETH_SIGN_TYPED_DATA: 'eth_signTypedData', + PERSONAL_SIGN: 'personal_sign', +} + export { ENVIRONMENT_TYPE_POPUP, ENVIRONMENT_TYPE_NOTIFICATION, ENVIRONMENT_TYPE_FULLSCREEN, ENVIRONMENT_TYPE_BACKGROUND, + MESSAGE_TYPE, PLATFORM_BRAVE, PLATFORM_CHROME, PLATFORM_EDGE, diff --git a/app/scripts/lib/message-manager.js b/app/scripts/lib/message-manager.js index 387ccce47..228b407a8 100644 --- a/app/scripts/lib/message-manager.js +++ b/app/scripts/lib/message-manager.js @@ -3,6 +3,7 @@ import ObservableStore from 'obs-store' import ethUtil from 'ethereumjs-util' import { ethErrors } from 'eth-json-rpc-errors' import createId from './random-id' +import { MESSAGE_TYPE } from './enums' /** * Represents, and contains data about, an 'eth_sign' type signature request. These are created when a signature for @@ -116,7 +117,7 @@ export default class MessageManager extends EventEmitter { msgParams: msgParams, time: time, status: 'unapproved', - type: 'eth_sign', + type: MESSAGE_TYPE.ETH_SIGN, } this.addMsg(msgData) diff --git a/app/scripts/lib/personal-message-manager.js b/app/scripts/lib/personal-message-manager.js index 88cdee44b..1050abefd 100644 --- a/app/scripts/lib/personal-message-manager.js +++ b/app/scripts/lib/personal-message-manager.js @@ -3,6 +3,7 @@ import ObservableStore from 'obs-store' import ethUtil from 'ethereumjs-util' import { ethErrors } from 'eth-json-rpc-errors' import createId from './random-id' +import { MESSAGE_TYPE } from './enums' const hexRe = /^[0-9A-Fa-f]+$/g import log from 'loglevel' @@ -125,7 +126,7 @@ export default class PersonalMessageManager extends EventEmitter { msgParams: msgParams, time: time, status: 'unapproved', - type: 'personal_sign', + type: MESSAGE_TYPE.PERSONAL_SIGN, } this.addMsg(msgData) diff --git a/app/scripts/lib/typed-message-manager.js b/app/scripts/lib/typed-message-manager.js index 346051e30..147180ffd 100644 --- a/app/scripts/lib/typed-message-manager.js +++ b/app/scripts/lib/typed-message-manager.js @@ -6,7 +6,7 @@ import { ethErrors } from 'eth-json-rpc-errors' import sigUtil from 'eth-sig-util' import log from 'loglevel' import jsonschema from 'jsonschema' - +import { MESSAGE_TYPE } from './enums' /** * Represents, and contains data about, an 'eth_signTypedData' type signature request. These are created when a * signature for an eth_signTypedData call is requested. @@ -118,7 +118,7 @@ export default class TypedMessageManager extends EventEmitter { msgParams: msgParams, time: time, status: 'unapproved', - type: 'eth_signTypedData', + type: MESSAGE_TYPE.ETH_SIGN_TYPED_DATA, } this.addMsg(msgData) diff --git a/ui/app/components/app/signature-request-original/signature-request-original.component.js b/ui/app/components/app/signature-request-original/signature-request-original.component.js index 01bb0b8c4..b89d6f1e8 100644 --- a/ui/app/components/app/signature-request-original/signature-request-original.component.js +++ b/ui/app/components/app/signature-request-original/signature-request-original.component.js @@ -4,7 +4,7 @@ import ethUtil from 'ethereumjs-util' import classnames from 'classnames' import { ObjectInspector } from 'react-inspector' -import { ENVIRONMENT_TYPE_NOTIFICATION } from '../../../../../app/scripts/lib/enums' +import { ENVIRONMENT_TYPE_NOTIFICATION, MESSAGE_TYPE } from '../../../../../app/scripts/lib/enums' import { getEnvironmentType } from '../../../../../app/scripts/lib/util' import Identicon from '../../ui/identicon' import AccountListItem from '../../../pages/send/account-list-item/account-list-item.component' @@ -208,11 +208,11 @@ export default class SignatureRequestOriginal extends Component { const { txData } = this.props const { type, msgParams: { data } } = txData - if (type === 'personal_sign') { + if (type === MESSAGE_TYPE.PERSONAL_SIGN) { rows = [{ name: this.context.t('message'), value: this.msgHexToText(data) }] - } else if (type === 'eth_signTypedData') { + } else if (type === MESSAGE_TYPE.ETH_SIGN_TYPED_DATA) { rows = data - } else if (type === 'eth_sign') { + } else if (type === MESSAGE_TYPE.ETH_SIGN) { rows = [{ name: this.context.t('message'), value: data }] notice = this.context.t('signNotice') } @@ -223,12 +223,12 @@ export default class SignatureRequestOriginal extends Component { { this.renderRequestInfo() }