diff --git a/renderer/components/Profile/PaneSignMessage/PaneSignMessage.js b/renderer/components/Profile/PaneSignMessage/PaneSignMessage.js index f3337bc6306..1350c43d117 100644 --- a/renderer/components/Profile/PaneSignMessage/PaneSignMessage.js +++ b/renderer/components/Profile/PaneSignMessage/PaneSignMessage.js @@ -1,33 +1,36 @@ import React, { useState, useRef } from 'react' import PropTypes from 'prop-types' -import { grpc } from 'workers' import { FormattedMessage, injectIntl, intlShape } from 'react-intl' import { Box, Flex } from 'rebass' -import { Bar, CopyBox, DataRow, TextArea, Text, Form, Button } from 'components/UI' +import { grpc } from 'workers' +import { Bar, CopyBox, TextArea, Text, Form, Button } from 'components/UI' import messages from './messages' const ProfilePaneNodeInfo = ({ intl, showNotification, ...rest }) => { const [sig, setSig] = useState(null) + const formApiRef = useRef(null) const notifyOfCopy = () => showNotification(intl.formatMessage({ ...messages.sig_copied_notification_description })) + const onSignMessage = async () => { try { const { current: formApi } = formApiRef const message = formApi.getValue('message') const { signature } = await grpc.services.Lightning.signMessage({ msg: Buffer.from(message) }) - setSig(signature) } catch { - setSig('Can not create sig') + setSig(intl.formatMessage({ ...messages.sign_error })) } } + return (
{ formApiRef.current = api }} + onSubmit={onSignMessage} > @@ -48,7 +51,7 @@ const ProfilePaneNodeInfo = ({ intl, showNotification, ...rest }) => { field="message" spellCheck="false" /> - {sig && ( @@ -73,13 +76,8 @@ const ProfilePaneNodeInfo = ({ intl, showNotification, ...rest }) => { } ProfilePaneNodeInfo.propTypes = { - activeWalletSettings: PropTypes.object.isRequired, - backupProvider: PropTypes.string, - commitString: PropTypes.string, intl: intlShape.isRequired, - nodeUriOrPubkey: PropTypes.string.isRequired, showNotification: PropTypes.func.isRequired, - versionString: PropTypes.string.isRequired, } export default injectIntl(ProfilePaneNodeInfo) diff --git a/renderer/components/Profile/ProfileMenu/ProfileMenu.js b/renderer/components/Profile/ProfileMenu/ProfileMenu.js index c7fa11b8f27..86ab841af69 100644 --- a/renderer/components/Profile/ProfileMenu/ProfileMenu.js +++ b/renderer/components/Profile/ProfileMenu/ProfileMenu.js @@ -2,7 +2,7 @@ import React from 'react' import PropTypes from 'prop-types' import { FormattedMessage } from 'react-intl' import { Menu } from 'components/UI' -import { PANE_NODEINFO, PANE_LNDCONNECT } from '../constants' +import { PANE_NODEINFO, PANE_LNDCONNECT, PANE_SIGNMESSAGE } from '../constants' import messages from './messages' const ProfileMenu = ({ group, setGroup, isLocalWallet, ...rest }) => { @@ -18,9 +18,15 @@ const ProfileMenu = ({ group, setGroup, isLocalWallet, ...rest }) => { onClick: () => setGroup(PANE_LNDCONNECT), } + const signMessageLink = { + id: PANE_SIGNMESSAGE, + title: , + onClick: () => setGroup(PANE_SIGNMESSAGE), + } + // Get set of menu links based on wallet type. - const getLocalLinks = () => [nodeInfoLink] - const getRemoteLinks = () => [nodeInfoLink, connectLink] + const getLocalLinks = () => [nodeInfoLink, signMessageLink] + const getRemoteLinks = () => [nodeInfoLink, connectLink, signMessageLink] const items = isLocalWallet ? getLocalLinks() : getRemoteLinks() return diff --git a/renderer/components/Profile/constants.js b/renderer/components/Profile/constants.js index 090da1ac862..80ba8845cb7 100644 --- a/renderer/components/Profile/constants.js +++ b/renderer/components/Profile/constants.js @@ -1,3 +1,4 @@ export const PANE_NODEINFO = 'nodeinfo' export const PANE_LNDCONNECT = 'lndconnect' +export const PANE_SIGNMESSAGE = 'signmessage' export const DEFAULT_PANE = PANE_NODEINFO diff --git a/renderer/containers/Profile/PaneSignMessage.js b/renderer/containers/Profile/PaneSignMessage.js new file mode 100644 index 00000000000..4dba5c171f4 --- /dev/null +++ b/renderer/containers/Profile/PaneSignMessage.js @@ -0,0 +1,12 @@ +import { connect } from 'react-redux' +import { showNotification } from 'reducers/notification' +import PaneSignMessage from 'components/Profile/PaneSignMessage' + +const mapDispatchToProps = { + showNotification, +} + +export default connect( + null, + mapDispatchToProps +)(PaneSignMessage)