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

Agent: read-only UI #1082

Merged
merged 60 commits into from
Mar 12, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
e5fc23a
Agent: add initial background script
sohkai Aug 27, 2019
10c5cc6
Agent: update script to pass transaction hashes
sohkai Aug 27, 2019
c6e2bc2
Agent: rename `address` to `token` for token address inside tokenTran…
sohkai Aug 27, 2019
2d2a365
Agent: handle ProxyDeposit events
sohkai Aug 27, 2019
b674ea3
Integrate darkmode, fix script initialization, heavy component refactor
Evalir Feb 14, 2020
dc08652
Add correct transaction types
Evalir Feb 17, 2020
d325f8a
Temporarily correct transfer bugs to repair build
Evalir Feb 17, 2020
c42f205
Fix dataview design debt
Evalir Feb 17, 2020
2b0b4a5
Working multiple token transfers
Evalir Feb 18, 2020
680d559
Update aragon ui, use tokenIconUrl() for tokens
Evalir Feb 18, 2020
e06595f
Fix token icons
Evalir Feb 18, 2020
1085ae1
Add custom badge functionality
Evalir Feb 19, 2020
bd5bbc8
Fix token display, add colors to entry expansion
Evalir Feb 19, 2020
8d1d283
Fix double scroll UI bug :-)
Evalir Feb 19, 2020
5b64d49
Fix mobile network bug, add initial filtering
Evalir Feb 20, 2020
4b4ed03
Demo-ready
Evalir Feb 20, 2020
65a5a21
Find target contract interaction if there are no token transfers, mod…
Evalir Feb 20, 2020
02427d1
Minor cosmetic refactor
Evalir Feb 20, 2020
e0c7359
Refactor script, memoize transaction list
Evalir Feb 20, 2020
29e82d6
Cosmetic code cleanup
Evalir Feb 21, 2020
ba4f435
Revert empty results memoization
Evalir Feb 21, 2020
e0ea6cb
Refactor transactions, add proper mobile view and other points from d…
Evalir Feb 27, 2020
8978d65
Code cleanup
Evalir Feb 27, 2020
c4b3e7d
ESLint: add exhaustive deps
bpierre Feb 28, 2020
dcc3be1
ESLint fixes
bpierre Feb 28, 2020
bfcb6f6
Optimize SVG
bpierre Mar 1, 2020
eab5bff
Add code review suggestions
Evalir Mar 2, 2020
f54be2d
Correct format error, remove console logs
Evalir Mar 2, 2020
255748b
Remove lodash throttle, remove firefox translate3d fix
Evalir Mar 2, 2020
2ddb817
Remove unused prop
bpierre Mar 2, 2020
d88e4f1
Use ROUNDING_AMOUNT
bpierre Mar 2, 2020
f481717
Fix addresses not resolving on CSV
Evalir Mar 2, 2020
a1e326d
Fix badges taking column width
Evalir Mar 2, 2020
c1f3a0e
Non-breaking spaces
bpierre Mar 2, 2020
813d22f
Create CSV data on demand
bpierre Mar 2, 2020
a4a29c7
Merge branch 'agent-readonly-ui' of github.com:aragon/aragon-apps int…
bpierre Mar 2, 2020
4628555
Date formats
bpierre Mar 2, 2020
2ded25b
Use DataView empty state
bpierre Mar 2, 2020
e4e080b
Code style
bpierre Mar 2, 2020
c8ac569
CSV files: escape double quotes in content
bpierre Mar 3, 2020
021e81b
CSV: add type
bpierre Mar 3, 2020
b4d4b31
Remove TRANSACTION_TYPES_STRING
bpierre Mar 3, 2020
0fe37e3
Merge branch 'master' into agent-readonly-ui
bpierre Mar 3, 2020
560a623
Merge branch 'master' into agent-readonly-ui
Evalir Mar 6, 2020
bc22da5
Fix aragonUI update breaking changes
Evalir Mar 6, 2020
9950bcf
Manually checkout the other apps
bpierre Mar 6, 2020
956e538
Manually checkout future-apps
bpierre Mar 6, 2020
e8d2acc
More cleanup after the manual checkout
bpierre Mar 6, 2020
38d796d
Remove unused component
bpierre Mar 7, 2020
74cf959
Apply most code review suggestions
Evalir Mar 8, 2020
0a93f26
Merge branch 'agent-readonly-ui' of https://github.com/aragon/aragon-…
Evalir Mar 9, 2020
e734e9c
Change 'marshal' to 'marshalTransactionDetails'
Evalir Mar 11, 2020
8938ace
Remove agent ABIs, fix entity logic for badges, minor cosmetic code c…
Evalir Mar 11, 2020
160a8ac
Add agent app address and transaction hash to file
Evalir Mar 11, 2020
09b7807
use event target to get the target contract
Evalir Mar 11, 2020
e3adf63
Remove console log and unused findTargetFromReceipt function in token…
Evalir Mar 11, 2020
ca89180
Merge branch 'master' into agent-readonly-ui
Evalir Mar 11, 2020
2b0a618
Merge branch 'master' into agent-readonly-ui
Evalir Mar 11, 2020
6f2e235
Update manifest.json and add screenshots
Evalir Mar 11, 2020
727f62f
Agent: Fix test color on dataview expansion
Evalir Mar 11, 2020
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
4 changes: 2 additions & 2 deletions apps/agent/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"private": true,
"license": "AGPL-3.0-or-later",
"dependencies": {
"@aragon/api": "^2.0.0-beta.6",
"@aragon/api-react": "^2.0.0-beta.6",
"@aragon/api": "^2.0.0-beta.9",
"@aragon/api-react": "^2.0.0-beta.9",
"@aragon/templates-tokens": "^1.2.0",
"@aragon/ui": "^1.3.0",
"@babel/polyfill": "^7.0.0",
Expand Down
27 changes: 27 additions & 0 deletions apps/agent/app/src/abi/agent-execute-event.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
Evalir marked this conversation as resolved.
Show resolved Hide resolved
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "sender",
"type": "address"
},
{
"indexed": true,
"name": "target",
"type": "address"
},
{
"indexed": false,
"name": "ethValue",
"type": "uint256"
},
{
"indexed": false,
"name": "data",
"type": "bytes"
}
],
"name": "Execute",
"type": "event"
}
22 changes: 22 additions & 0 deletions apps/agent/app/src/abi/agent-safe-execute-event.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "sender",
"type": "address"
},
{
"indexed": true,
"name": "target",
"type": "address"
},
{
"indexed": false,
"name": "data",
"type": "bytes"
}
],
"name": "SafeExecute",
"type": "event"
}
2 changes: 1 addition & 1 deletion apps/agent/app/src/components/InstallFrame.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState } from 'react'
import { ButtonBase, GU, Info, Link, useTheme } from '@aragon/ui'
import { GU, Info, Link } from '@aragon/ui'
import FrameSvg from './FrameSvg'
import FrameModal from './FrameModal'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import React from 'react'
import PropTypes from 'prop-types'
import styled from 'styled-components'
import { useNetwork } from '@aragon/api-react'
import { Badge, IdentityBadge, font } from '@aragon/ui'
import { useIdentity } from '../IdentityManager/IdentityManager'

const LocalIdentityBadge = ({ entity, ...props }) => {
const network = useNetwork()
const [label, showLocalIdentityModal] = useIdentity(entity)
const handleClick = () => showLocalIdentityModal(entity)
return (
<IdentityBadge
{...props}
networkType={network && network.type}
customLabel={label || ''}
entity={entity}
popoverAction={{
Expand Down
181 changes: 87 additions & 94 deletions apps/agent/app/src/components/Transactions.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import React, { useCallback, useEffect, useMemo } from 'react'
import PropTypes from 'prop-types'
import { useAragonApi } from '@aragon/api-react'
import { compareDesc, format } from 'date-fns'
Evalir marked this conversation as resolved.
Show resolved Hide resolved
import styled from 'styled-components'
import {
useAragonApi,
useConnectedAccount,
useNetwork,
} from '@aragon/api-react'
import {
AppBadge,
blockExplorerUrl,
Expand All @@ -11,32 +16,23 @@ import {
DataView,
GU,
IconExternal,
IconToken,
IconLabel,
IconToken,
textStyle,
useLayout,
useTheme,
} from '@aragon/ui'
import { useConnectedAccount, useNetwork } from '@aragon/api-react'
import { useIdentity } from './IdentityManager/IdentityManager'
import LocalIdentityBadge from './LocalIdentityBadge/LocalIdentityBadge'
import TransactionFilters from './TransactionFilters'
import { TRANSACTION_TYPES_LABELS } from '../transaction-types'
import useFilteredTransactions from './useFilteredTransactions'
import useDownloadData from './useDownloadData'
Evalir marked this conversation as resolved.
Show resolved Hide resolved
import useFilteredTransactions from './useFilteredTransactions'
import { formatTokenAmount, ROUNDING_AMOUNT } from '../lib/utils'
import { ISO_FORMAT, MMDDYY_FUNC_FORMAT } from '../lib/date-utils'
import { addressesEqual, toChecksumAddress } from '../lib/web3-utils'
import AgentSvg from './assets/agent_badge.svg'

const tokenDetailsReducer = (details, { address, decimals, symbol }) => {
details[toChecksumAddress(address)] = {
decimals,
symbol,
}
return details
}

const Transactions = React.memo(function Transactions({
agentAddress,
tokens,
Expand All @@ -60,9 +56,19 @@ const Transactions = React.memo(function Transactions({
selectedDateRange,
selectedToken,
selectedTransactionType,
symbols,
} = useFilteredTransactions({ transactions, tokens })

const tokenDetails = tokens.reduce(tokenDetailsReducer, {})
const tokenDetails = tokens.reduce(
(details, { address, decimals, symbol }) => {
details[toChecksumAddress(address)] = {
decimals,
symbol,
}
return details
},
{}
)

const { onDownload } = useDownloadData({
filteredTransactions,
Expand All @@ -72,7 +78,6 @@ const Transactions = React.memo(function Transactions({
})

const { isSyncing } = appState
const symbols = tokens.map(({ symbol }) => symbol)
const compactMode = layoutName === 'small'

const sortedTransactions = useMemo(
Expand All @@ -95,7 +100,7 @@ const Transactions = React.memo(function Transactions({
if (emptyResultsViaFilters) {
return 'empty-filters'
}
if (appState.isSyncing) {
if (isSyncing) {
return 'loading'
}
return 'default'
Expand Down Expand Up @@ -131,7 +136,7 @@ const Transactions = React.memo(function Transactions({
onDateRangeChange={handleSelectedDateRangeChange}
onTokenChange={handleTokenChange}
onTransactionTypeChange={handleTransactionTypeChange}
symbols={['All tokens', ...symbols]}
symbols={symbols}
tokenFilter={selectedToken}
transactionTypeFilter={selectedTransactionType}
transactionTypes={Object.values(TRANSACTION_TYPES_LABELS)}
Expand Down Expand Up @@ -170,6 +175,8 @@ const Transactions = React.memo(function Transactions({
const [{ token, amount, to, from } = {}] = tokenTransfers
const entity = to || from
const formattedDate = format(date, ISO_FORMAT)
const isValidEntity =
typeof targetContract === 'string' && tokenTransfers.length > 0

const dateNode = (
<time
Expand Down Expand Up @@ -200,19 +207,13 @@ const Transactions = React.memo(function Transactions({
>
<LocalIdentityBadge
connectedAccount={addressesEqual(entity, connectedAccount)}
networkType={network && network.type}
entity={entity}
/>
</div>
) : (
<LocalIdentityBadge
badgeOnly={typeof targetContract !== 'string'}
entity={
(!tokenTransfers.length && targetContract) || 'Multiple accounts'
}
networkType={
typeof targetContract === 'string' && network ? network.type : ''
}
badgeOnly={isValidEntity}
entity={!isValidEntity ? targetContract : 'Multiple accounts'}
/>
)
const typeNode = (
Expand Down Expand Up @@ -307,6 +308,7 @@ const Transactions = React.memo(function Transactions({
{ rounding: ROUNDING_AMOUNT }
)
const amountColor = isIncoming ? theme.positive : theme.negative

return (
<div
key={to || from}
Expand All @@ -319,38 +321,20 @@ const Transactions = React.memo(function Transactions({
justify-content: space-between;
${compactMode &&
`
width: 100%;
display: flex;
flex-direction: column
align-items: flex-end;
justify-content: space-between;
margin-top: ${5 * GU}px;
margin-left: ${4 * GU}px;
margin-bottom: ${5 * GU}px;
`}
`}
>
<div
css={`
color: ${theme.surfaceContentSecondary};
${textStyle('label2')};
font-weight: 400;
display: inline-grid;
grid-template-columns: auto 1fr;
grid-gap: ${1 * GU}px;
align-items: center;
width: 200px;
${compactMode &&
`
width: 100%;
display: flex;
Evalir marked this conversation as resolved.
Show resolved Hide resolved
flex-direction: row;
align-items: space-between;
flex-direction: column
align-items: flex-end;
justify-content: space-between;
width: 100%;
margin-right: ${5 * GU}px;
margin-top: ${5 * GU}px;
margin-left: ${4 * GU}px;
margin-bottom: ${5 * GU}px;
`};
`}
`}
`}
>
<BadgeContainer
color={theme.surfaceContentSecondary}
compactMode={compactMode}
>
From{' '}
{!from ? (
Expand All @@ -369,28 +353,10 @@ const Transactions = React.memo(function Transactions({
/>
</div>
)}
</div>
<div
css={`
color: ${theme.surfaceContentSecondary};
${textStyle('label2')};
font-weight: 400;
display: inline-grid;
grid-template-columns: auto 1fr;
grid-gap: ${1 * GU}px;
align-items: center;
width: 200px;
${compactMode &&
`
display: flex;
flex-direction: row;
align-items: space-between;
justify-content: space-between;
width: 100%;
margin-right: ${5 * GU}px;
margin-bottom: ${5 * GU}px;
`};
`}
</BadgeContainer>
<BadgeContainer
color={theme.surfaceContentSecondary}
compactMode={compactMode}
>
To{' '}
{!to ? (
Expand All @@ -409,32 +375,37 @@ const Transactions = React.memo(function Transactions({
/>
</div>
)}
</div>
</BadgeContainer>
<div
css={`
text-align: right;
.amount-label {
color: ${theme.surfaceContentSecondary};
${textStyle('label2')};
font-weight: 400;
}
.token-amount {
color: ${amountColor};
}
${compactMode &&
`
display: flex;
flex-direction: row;
align-items: space-between;
justify-content: space-between;
width: 100%;
margin-right: ${5 * GU}px;
`}
display: flex;
flex-direction: row;
align-items: space-between;
justify-content: space-between;
width: 100%;
margin-right: ${5 * GU}px;
`}
`}
>
{compactMode && <span className="amount-label">Amount</span>}
<span className="token-amount">
{' '}
{compactMode && (
<span
css={`
color: ${theme.surfaceContentSecondary};
${textStyle('label2')};
font-weight: 400;
`}
>
Amount
</span>
)}
<span
css={`
color: ${amountColor};
`}
>
{formattedAmount} {symbol}
</span>
</div>
Expand Down Expand Up @@ -501,4 +472,26 @@ function ContextMenuViewTransaction({ transactionHash, network }) {
)
}

const BadgeContainer = styled.div`
color: ${({ surfaceColor }) => surfaceColor};
${textStyle('label2')};
font-weight: 400;
display: inline-grid;
grid-template-columns: auto 1fr;
grid-gap: ${1 * GU}px;
align-items: center;
width: 200px;
Evalir marked this conversation as resolved.
Show resolved Hide resolved
${({ compactMode }) =>
compactMode &&
`
display: flex;
flex-direction: row;
align-items: space-between;
justify-content: space-between;
width: 100%;
margin-right: ${5 * GU}px;
margin-bottom: ${5 * GU}px;
`};
`

export default Transactions
Loading