Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/message signing #683

Closed
wants to merge 64 commits into from
Closed
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
944bb24
prettier
drcmda Jan 17, 2019
af603e1
fix eslint errors
drcmda Jan 17, 2019
dd690fb
merge master
drcmda Jan 21, 2019
e73944a
fix onBlur, merge master
drcmda Jan 22, 2019
9255199
eslint errors
drcmda Jan 22, 2019
3fe7228
timetags
drcmda Jan 24, 2019
2edc744
reinstate badge reset + fix, notification.close, colors
drcmda Jan 24, 2019
c707ff7
eslint
drcmda Jan 25, 2019
44a19c4
Merge remote-tracking branch 'origin/master' into notifications
2color Apr 3, 2019
3081916
Add mising props
2color Apr 3, 2019
088fe2a
Add activity provider
2color Apr 3, 2019
25043e0
Move activities to context from wrapper state
2color Apr 4, 2019
ea5f53f
Remove unused SignerPanel onClose prop
2color Apr 4, 2019
705a740
Fix bug with activity panel not closing properly
2color Apr 4, 2019
629ac3b
Rename to activity
2color Apr 5, 2019
102076c
Always show the activity count in menubar badge
2color Apr 5, 2019
b9d4c53
Add transaction activities with its data structure
2color Apr 5, 2019
baa7f77
Unread activity functionality
2color Apr 5, 2019
35b1d46
Use transactionHash as the key for notifications list
2color Apr 8, 2019
675ad43
Filter single activity item
2color Apr 8, 2019
28ec0c2
Organise compnents and render relative time
2color Apr 8, 2019
fea3c09
Renaming from notifcations to activity
2color Apr 8, 2019
c55e446
Merge remote-tracking branch 'origin/master' into activity-panel
2color Apr 8, 2019
d343700
Render activity status
2color Apr 8, 2019
9585ee4
Update activity status
2color Apr 8, 2019
dedafed
add support for message signing https://github.com/aragonone/product/…
Schwartz10 Apr 5, 2019
b303f36
Scope rendered activities to user and DAO
2color Apr 9, 2019
d9a5891
Remove about from relative time
2color Apr 9, 2019
45a9dec
Render progress bar conditionally
2color Apr 9, 2019
5b1508c
Make description smaller
2color Apr 9, 2019
0360024
fixup! Scope rendered activities to user and DAO
2color Apr 9, 2019
772da76
Set activity items to timed out after pending for 10 minutes
2color Apr 9, 2019
648a30f
Update status to failed
2color Apr 9, 2019
bc1e8f9
Add proxy addresses
2color Apr 9, 2019
91140ce
add status messages for msg signatures
Schwartz10 Apr 9, 2019
2eb27d2
handle appAddress name change
Schwartz10 Apr 9, 2019
10c6487
decorate app address with name and icon in panel
Schwartz10 Apr 9, 2019
ded5205
reuse web3 signing panel components
Schwartz10 Apr 9, 2019
2de9e0e
fix bug
Schwartz10 Apr 9, 2019
11b39bc
change function name
Schwartz10 Apr 9, 2019
ce07567
ensure ImpossibleContent gets correct prop types
Schwartz10 Apr 9, 2019
938fede
change requestingApp naming
Schwartz10 Apr 9, 2019
807eadf
Merge remote-tracking branch 'upstream/master' into feat/message-signing
Schwartz10 Apr 10, 2019
9870588
fix unresolved import after upstream merge
Schwartz10 Apr 10, 2019
7e953b5
Set activity none after submitting transaction
2color Apr 10, 2019
11fb67c
Merge branch 'master' into activity-panel
bpierre Apr 10, 2019
90f27ac
Remove automatic closing of activity panel
2color Apr 10, 2019
e7d2fdd
Refresh activity status on load
2color Apr 10, 2019
dd78e84
Fix the activity button
bpierre Apr 10, 2019
d0b31d0
Update the notifications layout
bpierre Apr 11, 2019
21b3194
Update src/components/SignerPanel/SignerPanel.js
2color Apr 11, 2019
b696f9a
resolve change requests
Schwartz10 Apr 11, 2019
95dc4cd
correct componentDidUpdate conditional logic
Schwartz10 Apr 11, 2019
e24e6f2
Layout fixes + empty state
bpierre Apr 11, 2019
7e87267
implement basic show/hide message functionality
Schwartz10 Apr 11, 2019
c43326a
add content toggle
Schwartz10 Apr 11, 2019
f80fcd4
polish UI
Schwartz10 Apr 11, 2019
33b2cfe
update copy according to designs
Schwartz10 Apr 11, 2019
78232a8
Update src/components/SignerPanel/SignerPanel.js
2color Apr 12, 2019
9211a3d
Scope activities in localStorage per account
2color Apr 12, 2019
385051c
Remove intent when resolving transaction bag
2color Apr 12, 2019
f478612
Merge branch 'activity-panel' into activity-panel-ui
bpierre Apr 13, 2019
f24975a
fix merge conflicts
Schwartz10 Apr 13, 2019
dd22a19
resolve change requests
Schwartz10 Apr 13, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class App extends React.Component {
],
showDeprecatedBanner: false,
transactionBag: null,
signatureBag: null,
walletNetwork: '',
walletWeb3: null,
wrapper: null,
Expand Down Expand Up @@ -243,6 +244,10 @@ class App extends React.Component {
log('transaction bag', transactionBag)
this.setState({ transactionBag })
},
onSignatures: signatureBag => {
log('signature bag', signatureBag)
this.setState({ signatureBag })
},
onIdentityIntent: async identityIntent => {
// set the state for modifying a specific address identity
let name = null
Expand Down Expand Up @@ -336,6 +341,7 @@ class App extends React.Component {
selectorNetworks,
showDeprecatedBanner,
transactionBag,
signatureBag,
walletNetwork,
walletProviderId,
walletWeb3,
Expand Down Expand Up @@ -392,6 +398,7 @@ class App extends React.Component {
onRequestEnable={this.handleRequestEnable}
permissionsLoading={permissionsLoading}
transactionBag={transactionBag}
signatureBag={signatureBag}
walletNetwork={walletNetwork}
walletWeb3={walletWeb3}
wrapper={wrapper}
Expand Down
4 changes: 4 additions & 0 deletions src/Wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class Wrapper extends React.PureComponent {
permissionsLoading: PropTypes.bool.isRequired,
autoClosingPanel: PropTypes.bool.isRequired,
transactionBag: PropTypes.object,
signatureBag: PropTypes.object,
walletNetwork: PropTypes.string,
walletProviderId: PropTypes.string,
walletWeb3: PropTypes.object,
Expand All @@ -57,6 +58,7 @@ class Wrapper extends React.PureComponent {
banner: false,
connected: false,
transactionBag: null,
signatureBag: null,
walletNetwork: '',
walletProviderId: '',
walletWeb3: null,
Expand Down Expand Up @@ -197,6 +199,7 @@ class Wrapper extends React.PureComponent {
onRequestAppsReload,
onRequestEnable,
transactionBag,
signatureBag,
walletNetwork,
walletProviderId,
walletWeb3,
Expand Down Expand Up @@ -259,6 +262,7 @@ class Wrapper extends React.PureComponent {
locator={locator}
onRequestEnable={onRequestEnable}
transactionBag={transactionBag}
signatureBag={signatureBag}
walletNetwork={walletNetwork}
walletProviderId={walletProviderId}
walletWeb3={walletWeb3}
Expand Down
13 changes: 12 additions & 1 deletion src/aragonjs-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,22 @@ export const pollNetwork = pollEvery((provider, onNetwork) => {
// Subscribe to aragon.js observables
const subscribe = (
wrapper,
{ onApps, onPermissions, onForwarders, onTransaction, onIdentityIntent },
{
onApps,
onPermissions,
onForwarders,
onTransaction,
onSignatures,
onIdentityIntent,
},
{ ipfsConf }
) => {
const {
apps,
permissions,
forwarders,
transactions,
signatures,
identityIntents,
} = wrapper

Expand All @@ -251,6 +259,7 @@ const subscribe = (
forwarders: forwarders.subscribe(onForwarders),
identityIntents: identityIntents.subscribe(onIdentityIntent),
transactions: transactions.subscribe(onTransaction),
signatures: signatures.subscribe(onSignatures),
workers: apps.subscribe(apps => {
// Asynchronously launch webworkers for each new app that has a background
// script defined
Expand Down Expand Up @@ -344,6 +353,7 @@ const initWrapper = async (
onPermissions = noop,
onForwarders = noop,
onTransaction = noop,
onSignatures = noop,
onDaoAddress = noop,
onWeb3 = noop,
onIdentityIntent = noop,
Expand Down Expand Up @@ -405,6 +415,7 @@ const initWrapper = async (
onPermissions,
onForwarders,
onTransaction,
onSignatures,
onIdentityIntent,
},
{ ipfsConf }
Expand Down
1 change: 1 addition & 0 deletions src/assets/arrow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
84 changes: 84 additions & 0 deletions src/components/SignerPanel/ConfirmMsgSign.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import React from 'react'
Schwartz10 marked this conversation as resolved.
Show resolved Hide resolved
import PropTypes from 'prop-types'
import { isElectron, noop } from '../../utils'

import { AppType } from '../../prop-types'
import { NoWeb3Provider, AccountLocked } from './Web3Errors'
import { ImpossibleContent } from './ImpossibleContent'
import SignMsgContent from './SignMsgContent'

class ConfirmMsgSign extends React.Component {
static propTypes = {
account: PropTypes.string,
apps: PropTypes.arrayOf(AppType).isRequired,
hasAccount: PropTypes.bool.isRequired,
hasWeb3: PropTypes.bool.isRequired,
intent: PropTypes.object,
onClose: PropTypes.func.isRequired,
onRequestEnable: PropTypes.func,
onSign: PropTypes.func.isRequired,
signError: PropTypes.string,
signingEnabled: PropTypes.bool.isRequired,
walletProviderId: PropTypes.string.isRequired,
}

static defaultProps = {
account: '',
intent: {},
onRequestEnable: noop,
}
render() {
const {
account,
apps,
intent,
hasAccount,
hasWeb3,
onClose,
onRequestEnable,
onSign,
signError,
signingEnabled,
walletProviderId,
} = this.props

if (!hasWeb3) {
return (
<NoWeb3Provider
intent={intent}
isElectron={isElectron()}
onClose={onClose}
/>
)
}

if (!hasAccount) {
return (
<AccountLocked
intent={intent}
onClose={onClose}
onRequestEnable={onRequestEnable}
walletProviderId={walletProviderId}
/>
)
}

return !signError ? (
<SignMsgContent
account={account}
apps={apps}
intent={intent}
onSign={onSign}
signingEnabled={signingEnabled}
/>
) : (
<ImpossibleContent
error={!!signError}
intent={intent}
onClose={onClose}
/>
)
}
}

export default ConfirmMsgSign
138 changes: 10 additions & 128 deletions src/components/SignerPanel/ConfirmTransaction.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import React from 'react'
import PropTypes from 'prop-types'
import styled from 'styled-components'
import { Info, SafeLink, theme } from '@aragon/ui'
import { isElectron, noop } from '../../utils'
import providerString from '../../provider-strings'
import ActionPathsContent from './ActionPathsContent'
import SignerButton from './SignerButton'
import AddressLink from './AddressLink'
import { NoWeb3Provider, AccountLocked, WrongNetwork } from './Web3Errors'
import { ImpossibleContent } from './ImpossibleContent'

class ConfirmTransaction extends React.Component {
static propTypes = {
Expand Down Expand Up @@ -51,76 +48,33 @@ class ConfirmTransaction extends React.Component {
} = this.props

if (!hasWeb3) {
if (isElectron()) {
return (
<Web3ProviderError
intent={intent}
onClose={onClose}
neededText="You need to have Frame installed and enabled"
actionText={
<span>
Please install and enable{' '}
<SafeLink href="https://frame.sh/" target="_blank">
Frame
</SafeLink>
.
</span>
}
/>
)
}
return (
<Web3ProviderError
<NoWeb3Provider
intent={intent}
isElectron={isElectron()}
onClose={onClose}
neededText="You need to have an Ethereum provider installed and enabled"
actionText={
<span>
Please install and enable{' '}
<SafeLink href="https://metamask.io/" target="_blank">
Metamask
</SafeLink>
.
</span>
}
/>
)
}

if (!hasAccount) {
return (
<Web3ProviderError
<AccountLocked
intent={intent}
onClose={onClose}
neededText={`You need to unlock and enable ${providerString(
'your Ethereum provider',
walletProviderId
)}`}
actionText={
<span>
Please unlock and{' '}
<ButtonLink onClick={onRequestEnable}>enable</ButtonLink>{' '}
{providerString('your Ethereum provider', walletProviderId)}.
</span>
}
onRequestEnable={onRequestEnable}
walletProviderId={walletProviderId}
/>
)
}

if (walletNetworkType !== networkType) {
return (
<Web3ProviderError
<WrongNetwork
intent={intent}
onClose={onClose}
neededText={`
You need to be connected to the ${networkType} network
`}
actionText={`
Please connect ${providerString(
'your Ethereum provider',
walletProviderId
)} to the ${networkType} network.
`}
networkType={networkType}
walletProviderId={walletProviderId}
/>
)
}
Expand All @@ -145,76 +99,4 @@ class ConfirmTransaction extends React.Component {
}
}

const ImpossibleContent = ({
error,
intent: { description, name, to },
onClose,
}) => (
<React.Fragment>
<Info.Permissions title="Action impossible">
The action {description && `“${description}”`} failed to execute
{name && (
<React.Fragment>
on <AddressLink to={to}>{name}</AddressLink>}
</React.Fragment>
)}
.{' '}
{error
? 'An error occurred when we tried to find a path or send a transaction for this action.'
: 'You may not have the required permissions.'}
</Info.Permissions>
<SignerButton onClick={onClose}>Close</SignerButton>
</React.Fragment>
)

ImpossibleContent.propTypes = {
error: PropTypes.bool,
intent: PropTypes.object.isRequired,
onClose: PropTypes.func.isRequired,
}

const Web3ProviderError = ({
intent: { description, name, to },
onClose,
neededText = '',
actionText = '',
}) => {
return (
<React.Fragment>
<Info.Action title="You can't perform any action">
{neededText} in order to perform{' '}
{description ? `"${description}"` : 'this action'}
{name && (
<React.Fragment>
on <AddressLink to={to}>{name}</AddressLink>
</React.Fragment>
)}
.<ActionMessage>{actionText}</ActionMessage>
</Info.Action>
<SignerButton onClick={onClose}>Close</SignerButton>
</React.Fragment>
)
}

Web3ProviderError.propTypes = {
actionText: PropTypes.node.isRequired,
intent: PropTypes.object.isRequired,
neededText: PropTypes.string.isRequired,
onClose: PropTypes.func.isRequired,
}

const ActionMessage = styled.p`
margin-top: 15px;
`

const ButtonLink = styled.button.attrs({ type: 'button' })`
padding: 0;
font-size: inherit;
text-decoration: underline;
color: ${theme.textPrimary};
cursor: pointer;
background: none;
border: 0;
`

export default ConfirmTransaction
Loading