From 1c4ead1ea4330f0770e91fb74bed304eb8e95164 Mon Sep 17 00:00:00 2001 From: Alexey Padalko Date: Wed, 7 Aug 2019 11:08:07 +0300 Subject: [PATCH] refactor: extract sign/verify grpc interactions into actions --- .../ProfilePaneSignMessage.js | 12 +++++----- .../ProfilePaneVerifyMessage.js | 18 ++++++-------- .../Profile/ProfilePaneSignMessage.js | 2 ++ .../Profile/ProfilePaneVerifyMessage.js | 2 ++ renderer/reducers/lnd.js | 24 +++++++++++++++++++ 5 files changed, 41 insertions(+), 17 deletions(-) diff --git a/renderer/components/Profile/ProfilePaneSignMessage/ProfilePaneSignMessage.js b/renderer/components/Profile/ProfilePaneSignMessage/ProfilePaneSignMessage.js index a0f4161d2d5..187c3b79909 100644 --- a/renderer/components/Profile/ProfilePaneSignMessage/ProfilePaneSignMessage.js +++ b/renderer/components/Profile/ProfilePaneSignMessage/ProfilePaneSignMessage.js @@ -2,11 +2,10 @@ import React, { useState, useRef } from 'react' import PropTypes from 'prop-types' import { FormattedMessage, injectIntl, intlShape } from 'react-intl' import { Box, Flex } from 'rebass' -import { grpc } from 'workers' import { Bar, CopyBox, TextArea, Text, Form, Button } from 'components/UI' import messages from './messages' -const ProfilePaneNodeInfo = ({ intl, showNotification, ...rest }) => { +const ProfilePaneNodeInfo = ({ intl, signMessage, showNotification, ...rest }) => { const [sig, setSig] = useState(null) const formApiRef = useRef(null) @@ -17,7 +16,7 @@ const ProfilePaneNodeInfo = ({ intl, showNotification, ...rest }) => { try { const { current: formApi } = formApiRef const message = formApi.getValue('message') - const { signature } = await grpc.services.Lightning.signMessage({ msg: Buffer.from(message) }) + const { signature } = await signMessage(message) setSig(signature) } catch (e) { setSig(intl.formatMessage({ ...messages.sign_error })) @@ -45,10 +44,10 @@ const ProfilePaneNodeInfo = ({ intl, showNotification, ...rest }) => { word-break: break-all; `} description={intl.formatMessage({ ...messages.sign_message_desc })} + field="message" isRequired label={intl.formatMessage({ ...messages.sign_message_label })} - {...rest} - field="message" + onChange={() => setSig(null)} spellCheck="false" />