diff --git a/package.json b/package.json index 0cdb717f..96bc91d1 100644 --- a/package.json +++ b/package.json @@ -113,7 +113,7 @@ "babel-plugin-transform-es3-property-literals": "^6.22.0", "babel-polyfill": "^6.26.0", "classnames": "^2.2.6", - "css-loader": "3.3.2", + "css-loader": "3.4.0", "detect-port": "^1.3.0", "eslint": "6.7.2", "eslint-config-airbnb": "18.0.1", @@ -132,15 +132,15 @@ "jest": "24.9.0", "jest-dom": "4.0.0", "json-loader": "^0.5.7", - "mini-css-extract-plugin": "0.8.0", + "mini-css-extract-plugin": "0.8.1", "postcss-loader": "^3.0.0", "postcss-mixins": "6.2.3", "postcss-simple-vars": "^5.0.2", "pre-commit": "^1.2.2", "prettier-eslint-cli": "5.0.0", "run-with-testrpc": "0.3.1", - "style-loader": "1.0.1", - "terser-webpack-plugin": "2.3.0", + "style-loader": "1.0.2", + "terser-webpack-plugin": "2.3.1", "truffle": "5.1.4", "truffle-contract": "4.0.31", "truffle-solidity-loader": "0.1.32", diff --git a/src/routes/safe/components/Transactions/TxsTable/ExpandedTx/TxDescription/index.jsx b/src/routes/safe/components/Transactions/TxsTable/ExpandedTx/TxDescription/index.jsx index 6ab40b9f..a9f5a0c5 100644 --- a/src/routes/safe/components/Transactions/TxsTable/ExpandedTx/TxDescription/index.jsx +++ b/src/routes/safe/components/Transactions/TxsTable/ExpandedTx/TxDescription/index.jsx @@ -1,5 +1,5 @@ // @flow -import React from 'react' +import React, { useState } from 'react' import { withStyles } from '@material-ui/core/styles' import { type Transaction } from '~/routes/safe/store/models/transaction' import Bold from '~/components/layout/Bold' @@ -8,6 +8,8 @@ import Paragraph from '~/components/layout/Paragraph' import Block from '~/components/layout/Block' import { md, lg } from '~/theme/variables' import { getTxData } from './utils' +import { shortVersionOf } from '~/logic/wallets/ethAddresses' +import LinkWithRef from '~/components/layout/Link' export const TRANSACTIONS_DESC_ADD_OWNER_TEST_ID = 'tx-description-add-owner' export const TRANSACTIONS_DESC_REMOVE_OWNER_TEST_ID = 'tx-description-remove-owner' @@ -23,6 +25,13 @@ export const styles = () => ({ txData: { wordBreak: 'break-all', }, + txDataParagraph: { + whiteSpace: 'normal', + }, + linkTxData: { + textDecoration: 'underline', + cursor: 'pointer', + }, }) type Props = { @@ -91,28 +100,59 @@ const SettingsDescription = ({ removedOwner, addedOwner, newThreshold }: Descrip const CustomDescription = ({ data, value = 0, recipient, classes, -}: CustomDescProps) => ( - <> - - - Send - {' '} - {value} - {' '} - ETH - {' '} - to: - - - - - Data (hex encoded): - - {data} - - - -) +}: CustomDescProps) => { + const [showTxData, setShowTxData] = useState(false) + return ( + <> + + + Send + {' '} + {value} + {' '} + ETH + {' '} + to: + + + + + Data (hex encoded): + + {showTxData ? ( + <> + {data} + {' '} + setShowTxData(false)} + rel="noopener noreferrer" + target="_blank" + className={classes.linkTxData} + > + Show Less + + + ) : ( + <> + {shortVersionOf(data, 20)} + {' '} + setShowTxData(true)} + rel="noopener noreferrer" + target="_blank" + className={classes.linkTxData} + > + Show More + + + )} + + + + ) +} const TxDescription = ({ tx, classes }: Props) => { const { diff --git a/src/routes/safe/store/actions/fetchSafe.js b/src/routes/safe/store/actions/fetchSafe.js index 55eb19fa..427a905c 100644 --- a/src/routes/safe/store/actions/fetchSafe.js +++ b/src/routes/safe/store/actions/fetchSafe.js @@ -12,6 +12,7 @@ import { loadFromStorage } from '~/utils/storage' import removeSafeOwner from '~/routes/safe/store/actions/removeSafeOwner' import addSafeOwner from '~/routes/safe/store/actions/addSafeOwner' import updateSafeThreshold from '~/routes/safe/store/actions/updateSafeThreshold' +import { sameAddress } from '~/logic/wallets/ethAddresses' const buildOwnersFrom = ( safeOwners: string[], @@ -59,16 +60,17 @@ export const checkAndUpdateSafe = (safeAddress: string) => async (dispatch: Redu localSafe.threshold = threshold.toNumber() dispatch(updateSafeThreshold({ safeAddress, threshold: threshold.toNumber() })) + // If the remote owners does not contain a local address, we remove that local owner localOwners.forEach((localAddress) => { - if (!remoteOwners.includes(localAddress)) { + if (remoteOwners.findIndex((remoteAddress) => sameAddress(remoteAddress, localAddress)) !== -1) { dispatch(removeSafeOwner({ safeAddress, ownerAddress: localAddress })) } }) // If the remote has an owner that we don't have locally, we add it remoteOwners.forEach((remoteAddress) => { - if (!localOwners.includes(remoteAddress)) { + if (localOwners.findIndex((localAddress) => sameAddress(remoteAddress, localAddress)) !== -1) { dispatch(addSafeOwner({ safeAddress, ownerAddress: remoteAddress, ownerName: 'UNKNOWN' })) } }) diff --git a/src/routes/safe/store/actions/fetchTransactions.js b/src/routes/safe/store/actions/fetchTransactions.js index f89bcf2b..06d09b85 100644 --- a/src/routes/safe/store/actions/fetchTransactions.js +++ b/src/routes/safe/store/actions/fetchTransactions.js @@ -79,7 +79,7 @@ export const buildTransactionFrom = async ( ) const modifySettingsTx = sameAddress(tx.to, safeAddress) && Number(tx.value) === 0 && !!tx.data const cancellationTx = sameAddress(tx.to, safeAddress) && Number(tx.value) === 0 && !tx.data - const isSendTokenTx = await isTokenTransfer(tx.data, tx.value) + const isSendTokenTx = await isTokenTransfer(tx.data, Number(tx.value)) const customTx = !sameAddress(tx.to, safeAddress) && !!tx.data && !isSendTokenTx let refundParams = null @@ -204,7 +204,7 @@ export const buildIncomingTransactionFrom = async (tx: IncomingTxServiceModel) = symbol = tokenSymbol decimals = tokenDecimals } catch (err) { - const { methods } = new web3.eth.Contract(ALTERNATIVE_TOKEN_ABI, tx.to) + const { methods } = new web3.eth.Contract(ALTERNATIVE_TOKEN_ABI, tx.tokenAddress) const [tokenSymbol, tokenDecimals] = await Promise.all([methods.symbol, methods.decimals].map((m) => m().call())) symbol = web3.utils.toAscii(tokenSymbol) decimals = tokenDecimals @@ -225,8 +225,6 @@ export const buildIncomingTransactionFrom = async (tx: IncomingTxServiceModel) = } export const loadSafeTransactions = async (safeAddress: string) => { - web3 = await getWeb3() - let transactions: TxServiceModel[] = addMockSafeCreationTx(safeAddress) try { const url = buildTxServiceUrl(safeAddress) @@ -254,7 +252,7 @@ export const loadSafeIncomingTransactions = async (safeAddress: string) => { incomingTransactions = response.data.results } } catch (err) { - console.error(`Requests for incomming transactions for ${safeAddress} failed with 404`, err) + console.error(`Requests for incoming transactions for ${safeAddress} failed with 404`, err) } const incomingTxsRecord = await Promise.all(incomingTransactions.map(buildIncomingTransactionFrom)) @@ -263,6 +261,8 @@ export const loadSafeIncomingTransactions = async (safeAddress: string) => { } export default (safeAddress: string) => async (dispatch: ReduxDispatch) => { + web3 = await getWeb3() + const transactions: Map> = await loadSafeTransactions(safeAddress) const incomingTransactions: Map> = await loadSafeIncomingTransactions(safeAddress) diff --git a/yarn.lock b/yarn.lock index 9ee0dabc..3d24bc38 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4895,10 +4895,10 @@ css-declaration-sorter@^4.0.1: postcss "^7.0.1" timsort "^0.3.0" -css-loader@3.3.2: - version "3.3.2" - resolved "https://registry.yarnpkg.com/css-loader/-/css-loader-3.3.2.tgz#41b2086528aa4fbf8c0692e874bc14f081129b21" - integrity sha512-4XSiURS+YEK2fQhmSaM1onnUm0VKWNf6WWBYjkp9YbSDGCBTVZ5XOM6Gkxo8tLgQlzkZOBJvk9trHlDk4gjEYg== +css-loader@3.4.0: + version "3.4.0" + resolved "https://registry.yarnpkg.com/css-loader/-/css-loader-3.4.0.tgz#9fb263436783117a41d014e45e8eaeba54dd6670" + integrity sha512-JornYo4RAXl1Mzt0lOSVPmArzAMV3rGY2VuwtaDc732WTWjdwTaeS19nCGWMcSCf305Q396lhhDAJEWWM0SgPQ== dependencies: camelcase "^5.3.1" cssesc "^3.0.0" @@ -7260,10 +7260,10 @@ find-cache-dir@^2.0.0, find-cache-dir@^2.1.0: make-dir "^2.0.0" pkg-dir "^3.0.0" -find-cache-dir@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-3.1.0.tgz#9935894999debef4cf9f677fdf646d002c4cdecb" - integrity sha512-zw+EFiNBNPgI2NTrKkDd1xd7q0cs6wr/iWnr/oUkI0yF9K9GqQ+riIt4aiyFaaqpaWbxPrJXHI+QvmNUQbX+0Q== +find-cache-dir@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-3.2.0.tgz#e7fe44c1abc1299f516146e563108fd1006c1874" + integrity sha512-1JKclkYYsf1q9WIJKLZa9S9muC+08RIjzAlLrK4QcYLJMS6mk9yombQ9qf+zJ7H9LS800k0s44L4sDq9VYzqyg== dependencies: commondir "^1.0.1" make-dir "^3.0.0" @@ -10977,10 +10977,10 @@ mini-create-react-context@^0.3.0: gud "^1.0.0" tiny-warning "^1.0.2" -mini-css-extract-plugin@0.8.0: - version "0.8.0" - resolved "https://registry.yarnpkg.com/mini-css-extract-plugin/-/mini-css-extract-plugin-0.8.0.tgz#81d41ec4fe58c713a96ad7c723cdb2d0bd4d70e1" - integrity sha512-MNpRGbNA52q6U92i0qbVpQNsgk7LExy41MdAlG84FeytfDOtRIf/mCHdEgG8rpTKOaNKiqUnZdlptF469hxqOw== +mini-css-extract-plugin@0.8.1: + version "0.8.1" + resolved "https://registry.yarnpkg.com/mini-css-extract-plugin/-/mini-css-extract-plugin-0.8.1.tgz#0b3cd3f9610e60860c58493ed170ca6d3c35daf3" + integrity sha512-YOMfkqV07IlP3xVFMuTXze8K+fa5WXW8PE3rb2P01XAD5UxpbrwMHIYQ/DPfWaOmTnS16TD7d8CRi8AyOmgJ8g== dependencies: loader-utils "^1.1.0" normalize-url "1.9.1" @@ -14998,10 +14998,10 @@ strip-json-comments@^3.0.1: resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.0.1.tgz#85713975a91fb87bf1b305cca77395e40d2a64a7" integrity sha512-VTyMAUfdm047mwKl+u79WIdrZxtFtn+nBxHeb844XBQ9uMNTuTHdx2hc5RiAJYqwTj3wc/xe5HLSdJSkJ+WfZw== -style-loader@1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/style-loader/-/style-loader-1.0.1.tgz#aec6d4c61d0ed8d0a442faed741d4dfc6573888a" - integrity sha512-CnpEkSR1C+REjudiTWCv4+ssP7SCiuaQZJTZDWBRwTJoS90mdqkB8uOGMHKgVeUzpaU7IfLWoyQbvvs5Joj3Xw== +style-loader@1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/style-loader/-/style-loader-1.0.2.tgz#433d72eab8d1dd7d64c648b8ad7d9cbff3184111" + integrity sha512-xehHGWeCPrr+R/bU82To0j7L7ENzH30RHYmMhmAumbuIpQ/bHmv3SAj1aTRfBSszkXoqNtpKnJyWXEDydS+KeA== dependencies: loader-utils "^1.2.3" schema-utils "^2.0.1" @@ -15208,18 +15208,18 @@ temp@^0.8.3: dependencies: rimraf "~2.6.2" -terser-webpack-plugin@2.3.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-2.3.0.tgz#00fd8f792a330dc572e2e2b468fd7cb5ffd7ea51" - integrity sha512-yez0HdpDf/iQVYGf+e/o8ZYWLb1g9d1nRRi5FIOZ4KfXbfSPT259UoqxPiSLhCnr0mlDoh+bucpYQSFbU0cEsQ== +terser-webpack-plugin@2.3.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-2.3.1.tgz#6a63c27debc15b25ffd2588562ee2eeabdcab923" + integrity sha512-dNxivOXmDgZqrGxOttBH6B4xaxT4zNC+Xd+2K8jwGDMK5q2CZI+KZMA1AAnSRT+BTRvuzKsDx+fpxzPAmAMVcA== dependencies: cacache "^13.0.1" - find-cache-dir "^3.1.0" + find-cache-dir "^3.2.0" jest-worker "^24.9.0" schema-utils "^2.6.1" serialize-javascript "^2.1.2" source-map "^0.6.1" - terser "^4.4.2" + terser "^4.4.3" webpack-sources "^1.4.3" terser-webpack-plugin@^1.4.3: @@ -15237,10 +15237,10 @@ terser-webpack-plugin@^1.4.3: webpack-sources "^1.4.0" worker-farm "^1.7.0" -terser@^4.1.2, terser@^4.4.2: - version "4.4.2" - resolved "https://registry.yarnpkg.com/terser/-/terser-4.4.2.tgz#448fffad0245f4c8a277ce89788b458bfd7706e8" - integrity sha512-Uufrsvhj9O1ikwgITGsZ5EZS6qPokUOkCegS7fYOdGTv+OA90vndUbU6PEjr5ePqHfNUbGyMO7xyIZv2MhsALQ== +terser@^4.1.2, terser@^4.4.3: + version "4.4.3" + resolved "https://registry.yarnpkg.com/terser/-/terser-4.4.3.tgz#401abc52b88869cf904412503b1eb7da093ae2f0" + integrity sha512-0ikKraVtRDKGzHrzkCv5rUNDzqlhmhowOBqC0XqUHFpW+vJ45+20/IFBcebwKfiS2Z9fJin6Eo+F1zLZsxi8RA== dependencies: commander "^2.20.0" source-map "~0.6.1"