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/external txs #850

Merged
merged 13 commits into from
Aug 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"dependencies": {
"@aragon/templates-tokens": "^1.2.1",
"@aragon/ui": "^1.0.0-alpha.15",
"@aragon/wrapper": "^5.0.0-rc.14",
"@aragon/wrapper": "^5.0.0-rc.15",
"@babel/polyfill": "^7.0.0",
"@sentry/browser": "^5.5.0",
"@ungap/event-target": "^0.1.0",
Expand Down
31 changes: 31 additions & 0 deletions src/components/SignerPanel/ActionPathsContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class ActionPathsContent extends React.Component {
static propTypes = {
dao: PropTypes.string.isRequired,
direct: PropTypes.bool.isRequired,
installed: PropTypes.bool.isRequired,
external: PropTypes.bool.isRequired,
intent: PropTypes.object.isRequired,
paths: PropTypes.array.isRequired,
pretransaction: PropTypes.object,
Expand Down Expand Up @@ -173,8 +175,10 @@ class ActionPathsContent extends React.Component {
}
render() {
const {
installed,
intent,
direct,
external,
paths,
pretransaction,
signingEnabled,
Expand Down Expand Up @@ -241,6 +245,33 @@ class ActionPathsContent extends React.Component {
<Info mode="description" title="Action to be triggered">
{this.renderDescription(showPaths, intent)}
</Info>
{external && (
<div
css={`
margin-top: ${3 * GU}px;
`}
>
<Info mode="warning" title="Warning">
{installed ? (
`Be aware that this is an attempt to execute a transaction on
another app that is installed in this organization. You may
want to double check that app’s functionality before
proceeding.`
) : (
<span>
Be aware that this is an attempt to execute a transaction on
an <strong css="font-weight: 800">external contract</strong>{' '}
that has not been reviewed or audited. This means that it
might behave unexpectedly. Please{' '}
<strong css="font-weight: 800">
be sure you trust this contract
</strong>{' '}
before proceeding.
</span>
)}
</Info>
</div>
)}
{pretransaction && (
<Info
title="Two transactions required"
Expand Down
8 changes: 7 additions & 1 deletion src/components/SignerPanel/ConfirmTransaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import ImpossibleAction from './ImpossibleAction'
const ConfirmTransaction = ({
direct,
intent,
installed,
external,
dao,
onClose,
onSign,
Expand All @@ -20,9 +22,11 @@ const ConfirmTransaction = ({

return possible ? (
<ActionPathsContent
intent={intent}
direct={direct}
dao={dao}
external={external}
installed={installed}
intent={intent}
onSign={onSign}
paths={paths}
pretransaction={pretransaction}
Expand All @@ -36,7 +40,9 @@ const ConfirmTransaction = ({

ConfirmTransaction.propTypes = {
direct: PropTypes.bool.isRequired,
installed: PropTypes.bool.isRequired,
intent: PropTypes.object.isRequired,
external: PropTypes.bool.isRequired,
dao: PropTypes.string,
onClose: PropTypes.func.isRequired,
onSign: PropTypes.func.isRequired,
Expand Down
13 changes: 11 additions & 2 deletions src/components/SignerPanel/SignerPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,19 @@ class SignerPanel extends React.PureComponent {
// This is a temporary method to reshape the transaction bag
// to the future format we expect from Aragon.js
stateFromTransactionBag(bag) {
const { path, transaction } = bag
const { apps } = this.props
const { external, path, transaction } = bag
const decoratedPaths = path.map(path => ({
...path,
name: getAppName(this.props.apps, path.to),
name: getAppName(apps, path.to),
}))

return {
intent: (transaction && this.transactionIntent(bag)) || {},
external: Boolean(external),
installed: apps.some(
({ proxyAddress }) => proxyAddress === transaction.to
),
directPath: decoratedPaths.length === 1,
actionPaths: decoratedPaths.length ? [decoratedPaths] : [],
pretransaction: (transaction && transaction.pretransaction) || null,
Expand Down Expand Up @@ -297,6 +302,8 @@ class SignerPanel extends React.PureComponent {
actionPaths,
pretransaction,
status,
external,
installed,
} = this.state

const isTransaction = isTxSignerStatus(status)
Expand Down Expand Up @@ -344,6 +351,8 @@ class SignerPanel extends React.PureComponent {
<ConfirmTransaction
dao={dao}
direct={directPath}
external={external}
installed={installed}
intent={intent}
onClose={this.handleSignerClose}
onSign={this.handleSign}
Expand Down