From 10f1891f8fff4b2379f4cf8ac5eadbe92931024f Mon Sep 17 00:00:00 2001 From: Agustin Pane Date: Thu, 14 Jan 2021 08:36:55 -0300 Subject: [PATCH 01/18] (Fix) - Calculates gas for SpendingLimit transactions (#1773) * Bug: Use link tag instead of javascript navigation in apps list (#1770) * Use list instead of programmable navigation * add declaration for styled-components theme * (Fix) - Calculates gas for SpendingLimit transactions (#1773) * Calculates gas for spendingLimit transactions * Adds TransactionFees component inside UpdateSafeModal * Fix send collectible gas calculation Co-authored-by: Mikhail Mikheev --- src/logic/hooks/useEstimateTransactionGas.tsx | 26 +++++--- src/logic/safe/utils/upgradeSafe.ts | 17 +---- .../screens/ReviewCollectible/index.tsx | 2 +- .../SendModal/screens/ReviewTx/index.tsx | 1 + .../components/Settings/SafeDetails/index.tsx | 2 +- .../Settings/UpdateSafeModal/index.tsx | 65 ++++++++++++++++--- .../Settings/UpdateSafeModal/style.ts | 3 +- 7 files changed, 82 insertions(+), 34 deletions(-) diff --git a/src/logic/hooks/useEstimateTransactionGas.tsx b/src/logic/hooks/useEstimateTransactionGas.tsx index 0acb86d8f7..ba53f61027 100644 --- a/src/logic/hooks/useEstimateTransactionGas.tsx +++ b/src/logic/hooks/useEstimateTransactionGas.tsx @@ -21,6 +21,7 @@ import { List } from 'immutable' import { Confirmation } from 'src/logic/safe/store/models/types/confirmation' import { checkIfOffChainSignatureIsPossible } from 'src/logic/safe/safeTxSigner' import { ZERO_ADDRESS } from 'src/logic/wallets/ethAddresses' +import { sameString } from 'src/utils/strings' export enum EstimationStatus { LOADING = 'LOADING', @@ -28,13 +29,19 @@ export enum EstimationStatus { SUCCESS = 'SUCCESS', } -const checkIfTxIsExecution = (threshold: number, preApprovingOwner?: string, txConfirmations?: number): boolean => - txConfirmations === threshold || !!preApprovingOwner || threshold === 1 +const checkIfTxIsExecution = ( + threshold: number, + preApprovingOwner?: string, + txConfirmations?: number, + txType?: string, +): boolean => + txConfirmations === threshold || !!preApprovingOwner || threshold === 1 || sameString(txType, 'spendingLimit') -const checkIfTxIsApproveAndExecution = (threshold: number, txConfirmations: number): boolean => - txConfirmations + 1 === threshold +const checkIfTxIsApproveAndExecution = (threshold: number, txConfirmations: number, txType?: string): boolean => + txConfirmations + 1 === threshold || sameString(txType, 'spendingLimit') -const checkIfTxIsCreation = (txConfirmations: number): boolean => txConfirmations === 0 +const checkIfTxIsCreation = (txConfirmations: number, txType?: string): boolean => + txConfirmations === 0 && !sameString(txType, 'spendingLimit') type TransactionEstimationProps = { txData: string @@ -115,6 +122,7 @@ type UseEstimateTransactionGasProps = { preApprovingOwner?: string operation?: number safeTxGas?: number + txType?: string } type TransactionGasEstimationResult = { @@ -136,6 +144,7 @@ export const useEstimateTransactionGas = ({ preApprovingOwner, operation, safeTxGas, + txType, }: UseEstimateTransactionGasProps): TransactionGasEstimationResult => { const [gasEstimation, setGasEstimation] = useState({ txEstimationExecutionStatus: EstimationStatus.LOADING, @@ -159,9 +168,9 @@ export const useEstimateTransactionGas = ({ return } - const isExecution = checkIfTxIsExecution(Number(threshold), preApprovingOwner, txConfirmations?.size) - const isCreation = checkIfTxIsCreation(txConfirmations?.size || 0) - const approvalAndExecution = checkIfTxIsApproveAndExecution(Number(threshold), txConfirmations?.size || 0) + const isExecution = checkIfTxIsExecution(Number(threshold), preApprovingOwner, txConfirmations?.size, txType) + const isCreation = checkIfTxIsCreation(txConfirmations?.size || 0, txType) + const approvalAndExecution = checkIfTxIsApproveAndExecution(Number(threshold), txConfirmations?.size || 0, txType) try { const isOffChainSignature = checkIfOffChainSignatureIsPossible(isExecution, smartContractWallet, safeVersion) @@ -235,6 +244,7 @@ export const useEstimateTransactionGas = ({ safeVersion, smartContractWallet, safeTxGas, + txType, ]) return gasEstimation diff --git a/src/logic/safe/utils/upgradeSafe.ts b/src/logic/safe/utils/upgradeSafe.ts index 4f3dea1860..53caa747ee 100644 --- a/src/logic/safe/utils/upgradeSafe.ts +++ b/src/logic/safe/utils/upgradeSafe.ts @@ -6,7 +6,6 @@ import { SAFE_MASTER_COPY_ADDRESS, getGnosisSafeInstanceAt, } from 'src/logic/contracts/safeContracts' -import { DELEGATE_CALL } from 'src/logic/safe/transactions' import { getWeb3 } from 'src/logic/wallets/getWeb3' import { MultiSend } from 'src/types/contracts/MultiSend.d' @@ -49,7 +48,7 @@ export const getEncodedMultiSendCallData = (txs: MultiSendTx[], web3: Web3): str return encodedMultiSendCallData } -export const upgradeSafeToLatestVersion = async (safeAddress: string, createTransaction): Promise => { +export const getUpgradeSafeTransactionHash = async (safeAddress: string): Promise => { const safeInstance = await getGnosisSafeInstanceAt(safeAddress) const fallbackHandlerTxData = safeInstance.methods.setFallbackHandler(DEFAULT_FALLBACK_HANDLER_ADDRESS).encodeABI() const updateSafeTxData = safeInstance.methods.changeMasterCopy(SAFE_MASTER_COPY_ADDRESS).encodeABI() @@ -69,17 +68,5 @@ export const upgradeSafeToLatestVersion = async (safeAddress: string, createTran ] const web3 = getWeb3() - const encodeMultiSendCallData = getEncodedMultiSendCallData(txs, web3) - createTransaction({ - safeAddress, - to: MULTI_SEND_ADDRESS, - valueInWei: 0, - txData: encodeMultiSendCallData, - notifiedTransaction: 'STANDARD_TX', - enqueueSnackbar: () => {}, - closeSnackbar: () => {}, - operation: DELEGATE_CALL, - }) - - return + return getEncodedMultiSendCallData(txs, web3) } diff --git a/src/routes/safe/components/Balances/SendModal/screens/ReviewCollectible/index.tsx b/src/routes/safe/components/Balances/SendModal/screens/ReviewCollectible/index.tsx index 63d4c942de..a5cf3a00f6 100644 --- a/src/routes/safe/components/Balances/SendModal/screens/ReviewCollectible/index.tsx +++ b/src/routes/safe/components/Balances/SendModal/screens/ReviewCollectible/index.tsx @@ -64,7 +64,7 @@ const ReviewCollectible = ({ onClose, onPrev, tx }: Props): React.ReactElement = isCreation, } = useEstimateTransactionGas({ txData: data, - txRecipient: tx.recipientAddress, + txRecipient: tx.assetAddress, }) useEffect(() => { diff --git a/src/routes/safe/components/Balances/SendModal/screens/ReviewTx/index.tsx b/src/routes/safe/components/Balances/SendModal/screens/ReviewTx/index.tsx index 8dbb6b3cf2..f6895a9ebd 100644 --- a/src/routes/safe/components/Balances/SendModal/screens/ReviewTx/index.tsx +++ b/src/routes/safe/components/Balances/SendModal/screens/ReviewTx/index.tsx @@ -120,6 +120,7 @@ const ReviewTx = ({ onClose, onPrev, tx }: ReviewTxProps): React.ReactElement => } = useEstimateTransactionGas({ txData: data, txRecipient, + txType: tx.txType, }) const submitTx = async () => { diff --git a/src/routes/safe/components/Settings/SafeDetails/index.tsx b/src/routes/safe/components/Settings/SafeDetails/index.tsx index d071c122ab..cb74ce8681 100644 --- a/src/routes/safe/components/Settings/SafeDetails/index.tsx +++ b/src/routes/safe/components/Settings/SafeDetails/index.tsx @@ -19,7 +19,7 @@ import enqueueSnackbar from 'src/logic/notifications/store/actions/enqueueSnackb import { getNotificationsFromTxType, enhanceSnackbarForAction } from 'src/logic/notifications' import { sameAddress } from 'src/logic/wallets/ethAddresses' import { TX_NOTIFICATION_TYPES } from 'src/logic/safe/transactions' -import UpdateSafeModal from 'src/routes/safe/components/Settings/UpdateSafeModal' +import { UpdateSafeModal } from 'src/routes/safe/components/Settings/UpdateSafeModal' import { grantedSelector } from 'src/routes/safe/container/selector' import updateSafe from 'src/logic/safe/store/actions/updateSafe' import Link from 'src/components/layout/Link' diff --git a/src/routes/safe/components/Settings/UpdateSafeModal/index.tsx b/src/routes/safe/components/Settings/UpdateSafeModal/index.tsx index 3d370047f4..d002316685 100644 --- a/src/routes/safe/components/Settings/UpdateSafeModal/index.tsx +++ b/src/routes/safe/components/Settings/UpdateSafeModal/index.tsx @@ -1,9 +1,7 @@ import IconButton from '@material-ui/core/IconButton' import Close from '@material-ui/icons/Close' -import { withStyles } from '@material-ui/styles' -import React from 'react' +import React, { useEffect, useState } from 'react' import { useDispatch } from 'react-redux' -import { bindActionCreators } from 'redux' import { styles } from './style' @@ -13,17 +11,61 @@ import Button from 'src/components/layout/Button' import Hairline from 'src/components/layout/Hairline' import Paragraph from 'src/components/layout/Paragraph' import Row from 'src/components/layout/Row' -import { upgradeSafeToLatestVersion } from 'src/logic/safe/utils/upgradeSafe' +import { getUpgradeSafeTransactionHash } from 'src/logic/safe/utils/upgradeSafe' import createTransaction from 'src/logic/safe/store/actions/createTransaction' +import { makeStyles } from '@material-ui/core' +import { TransactionFees } from 'src/components/TransactionsFees' +import { useEstimateTransactionGas } from 'src/logic/hooks/useEstimateTransactionGas' +import { MULTI_SEND_ADDRESS } from 'src/logic/contracts/safeContracts' +import { DELEGATE_CALL } from 'src/logic/safe/transactions' +import { EMPTY_DATA } from 'src/logic/wallets/ethTransactions' -const UpdateSafeModal = ({ classes, onClose, safeAddress }) => { +const useStyles = makeStyles(styles) + +type Props = { + onClose: () => void + safeAddress: string +} + +export const UpdateSafeModal = ({ onClose, safeAddress }: Props): React.ReactElement => { + const classes = useStyles() const dispatch = useDispatch() + const [multiSendCallData, setMultiSendCallData] = useState(EMPTY_DATA) + + useEffect(() => { + const calculateUpgradeSafeModal = async () => { + const encodeMultiSendCallData = await getUpgradeSafeTransactionHash(safeAddress) + setMultiSendCallData(encodeMultiSendCallData) + } + calculateUpgradeSafeModal() + }, [safeAddress]) + const handleSubmit = async () => { // Call the update safe method - await upgradeSafeToLatestVersion(safeAddress, bindActionCreators(createTransaction, dispatch)) + dispatch( + createTransaction({ + safeAddress, + to: MULTI_SEND_ADDRESS, + valueInWei: '0', + txData: multiSendCallData, + notifiedTransaction: 'STANDARD_TX', + operation: DELEGATE_CALL, + }), + ) onClose() } + const { + gasCostFormatted, + txEstimationExecutionStatus, + isExecution, + isCreation, + isOffChainSignature, + } = useEstimateTransactionGas({ + txData: multiSendCallData, + txRecipient: safeAddress, + }) + return ( <> @@ -56,6 +98,15 @@ const UpdateSafeModal = ({ classes, onClose, safeAddress }) => { have to confirm the update in case more than one confirmation is required for this Safe. + + + @@ -72,5 +123,3 @@ const UpdateSafeModal = ({ classes, onClose, safeAddress }) => { ) } - -export default withStyles(styles as any)(UpdateSafeModal) diff --git a/src/routes/safe/components/Settings/UpdateSafeModal/style.ts b/src/routes/safe/components/Settings/UpdateSafeModal/style.ts index e0f9c000a1..e3f31c05ac 100644 --- a/src/routes/safe/components/Settings/UpdateSafeModal/style.ts +++ b/src/routes/safe/components/Settings/UpdateSafeModal/style.ts @@ -1,6 +1,7 @@ import { lg, md, secondaryText, sm } from 'src/theme/variables' +import { createStyles } from '@material-ui/core' -export const styles = () => ({ +export const styles = createStyles({ heading: { padding: `${sm} ${lg}`, justifyContent: 'space-between', From 5bcad40c1693f509be56237edc0a9768daee49e5 Mon Sep 17 00:00:00 2001 From: Daniel Sanchez Date: Fri, 15 Jan 2021 12:04:43 +0100 Subject: [PATCH 02/18] Fix electron app image Update and fix ledger connection for desktop app --- package.json | 18 +- public/electron.js | 3 +- public/{build => resources}/all-certs.p12 | Bin public/{build => resources}/background.png | Bin .../entitlements.mac.plist | 0 public/{build => resources}/icon.icns | Bin public/{build => resources}/icon.ico | Bin public/{build => resources}/safe.png | Bin yarn.lock | 205 ++++++------------ 9 files changed, 73 insertions(+), 153 deletions(-) rename public/{build => resources}/all-certs.p12 (100%) rename public/{build => resources}/background.png (100%) rename public/{build => resources}/entitlements.mac.plist (100%) rename public/{build => resources}/icon.icns (100%) rename public/{build => resources}/icon.ico (100%) rename public/{build => resources}/safe.png (100%) diff --git a/package.json b/package.json index 7d32b02768..189b525a71 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ }, "productName": "Safe Multisig", "build": { - "appId": "io.gnosis.safe.macos", + "appId": "io.gnosis.safe", "afterSign": "scripts/notarize.js", "extends": null, "productName": "Safe Multisig", @@ -110,14 +110,14 @@ "!yarn.lock" ], "directories": { - "buildResources": "public/build" + "buildResources": "public/resources" }, "mac": { "category": "public.app-category.productivity", "hardenedRuntime": true, - "entitlements": "public/build/entitlements.mac.plist", + "entitlements": "public/resources/entitlements.mac.plist", "gatekeeperAssess": false, - "entitlementsInherit": "public/build/entitlements.mac.plist", + "entitlementsInherit": "public/resources/entitlements.mac.plist", "target": [ "dmg", "zip" @@ -134,18 +134,18 @@ "deleteAppDataOnUninstall": true }, "linux": { + "category": "Finance", "target": [ "AppImage", "deb", "zip" - ], - "icon": "./public/build/safe.png" + ] }, "win": { "target": [ "nsis" ], - "icon": "public/build/icon.ico" + "icon": "public/resources/icon.ico" } }, "resolutions": { @@ -170,7 +170,7 @@ "@gnosis.pm/safe-contracts": "1.1.1-dev.2", "@gnosis.pm/safe-react-components": "https://github.com/gnosis/safe-react-components.git#bf3a84486b7353bd25447ddff39c406f6fafecc6", "@gnosis.pm/util-contracts": "2.0.6", - "@ledgerhq/hw-transport-node-hid-singleton": "5.34.0", + "@ledgerhq/hw-transport-node-hid-singleton": "5.38.0", "@material-ui/core": "^4.11.0", "@material-ui/icons": "4.9.1", "@material-ui/lab": "4.0.0-alpha.56", @@ -258,7 +258,7 @@ "cross-env": "^7.0.3", "dotenv": "^8.2.0", "dotenv-expand": "^5.1.0", - "electron": "^9.3.5", + "electron": "^9.4.0", "electron-builder": "22.9.1", "electron-notarize": "1.0.0", "eslint": "^7.11.0", diff --git a/public/electron.js b/public/electron.js index ae9368b84d..92626c8175 100644 --- a/public/electron.js +++ b/public/electron.js @@ -90,9 +90,10 @@ function createWindow(port = DEFAULT_PORT) { webPreferences: { preload: path.join(__dirname, '../scripts/preload.js'), allowRunningInsecureContent: true, + enableRemoteModule: true, nativeWindowOpen: true, // need to be set in order to display modal }, - icon: electron.nativeImage.createFromPath(path.join(__dirname, './build/safe.png')), + icon: electron.nativeImage.createFromPath(path.join(__dirname, '../build/resources/safe.png')), }) mainWindow.once('ready-to-show', () => { diff --git a/public/build/all-certs.p12 b/public/resources/all-certs.p12 similarity index 100% rename from public/build/all-certs.p12 rename to public/resources/all-certs.p12 diff --git a/public/build/background.png b/public/resources/background.png similarity index 100% rename from public/build/background.png rename to public/resources/background.png diff --git a/public/build/entitlements.mac.plist b/public/resources/entitlements.mac.plist similarity index 100% rename from public/build/entitlements.mac.plist rename to public/resources/entitlements.mac.plist diff --git a/public/build/icon.icns b/public/resources/icon.icns similarity index 100% rename from public/build/icon.icns rename to public/resources/icon.icns diff --git a/public/build/icon.ico b/public/resources/icon.ico similarity index 100% rename from public/build/icon.ico rename to public/resources/icon.ico diff --git a/public/build/safe.png b/public/resources/safe.png similarity index 100% rename from public/build/safe.png rename to public/resources/safe.png diff --git a/yarn.lock b/yarn.lock index 606db658dc..719844d5c1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -54,15 +54,6 @@ semver "^5.4.1" source-map "^0.5.0" -"@babel/generator@^7.12.1": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.12.1.tgz#0d70be32bdaa03d7c51c8597dda76e0df1f15468" - integrity sha512-DB+6rafIdc9o72Yc3/Ph5h+6hUjeOp66pF0naQBgUFFuPqzQwIlPTm3xZR7YNvduIMtkDIj2t21LSQwnbCrXvg== - dependencies: - "@babel/types" "^7.12.1" - jsesc "^2.5.1" - source-map "^0.5.0" - "@babel/generator@^7.12.10": version "7.12.10" resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.12.10.tgz#2b188fc329fb8e4f762181703beffc0fe6df3460" @@ -72,15 +63,6 @@ jsesc "^2.5.1" source-map "^0.5.0" -"@babel/generator@^7.12.5": - version "7.12.5" - resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.12.5.tgz#a2c50de5c8b6d708ab95be5e6053936c1884a4de" - integrity sha512-m16TQQJ8hPt7E+OS/XVQg/7U184MLXtvuGbCdA7na61vha+ImkyyNM/9DDA0unYCVZn3ZOhng+qz48/KBOT96A== - dependencies: - "@babel/types" "^7.12.5" - jsesc "^2.5.1" - source-map "^0.5.0" - "@babel/helper-annotate-as-pure@^7.0.0", "@babel/helper-annotate-as-pure@^7.10.4": version "7.10.4" resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.10.4.tgz#5bf0d495a3f757ac3bda48b5bf3b3ba309c72ba3" @@ -300,21 +282,11 @@ chalk "^2.0.0" js-tokens "^4.0.0" -"@babel/parser@^7.1.0", "@babel/parser@^7.12.1", "@babel/parser@^7.7.0": - version "7.12.3" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.12.3.tgz#a305415ebe7a6c7023b40b5122a0662d928334cd" - integrity sha512-kFsOS0IbsuhO5ojF8Hc8z/8vEIOkylVBrjiZUbLTE3XFe0Qi+uu6HjzQixkFaqr0ZPAMZcBVxEwmsnsLPZ2Xsw== - -"@babel/parser@^7.12.10": +"@babel/parser@^7.1.0", "@babel/parser@^7.12.10", "@babel/parser@^7.12.7", "@babel/parser@^7.7.0": version "7.12.10" resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.12.10.tgz#824600d59e96aea26a5a2af5a9d812af05c3ae81" integrity sha512-PJdRPwyoOqFAWfLytxrWwGrAxghCgh/yTNCYciOz8QgjflA7aZhECPZAa2VUedKg2+QMWkI0L9lynh2SNmNEgA== -"@babel/parser@^7.12.7": - version "7.12.7" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.12.7.tgz#fee7b39fe809d0e73e5b25eecaf5780ef3d73056" - integrity sha512-oWR02Ubp4xTLCAqPRiNIuMVgNO5Aif/xpXtabhzW2HWUD47XJsAB4Zd/Rg30+XeQA3juXigV7hlquOTmwqLiwg== - "@babel/plugin-proposal-async-generator-functions@^7.12.1": version "7.12.1" resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.12.1.tgz#dc6c1170e27d8aca99ff65f4925bd06b1c90550e" @@ -1133,22 +1105,7 @@ "@babel/parser" "^7.12.7" "@babel/types" "^7.12.7" -"@babel/traverse@^7.1.0", "@babel/traverse@^7.10.4", "@babel/traverse@^7.12.1", "@babel/traverse@^7.4.5", "@babel/traverse@^7.7.0": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.12.1.tgz#941395e0c5cc86d5d3e75caa095d3924526f0c1e" - integrity sha512-MA3WPoRt1ZHo2ZmoGKNqi20YnPt0B1S0GTZEPhhd+hw2KGUzBlHuVunj6K4sNuK+reEvyiPwtp0cpaqLzJDmAw== - dependencies: - "@babel/code-frame" "^7.10.4" - "@babel/generator" "^7.12.1" - "@babel/helper-function-name" "^7.10.4" - "@babel/helper-split-export-declaration" "^7.11.0" - "@babel/parser" "^7.12.1" - "@babel/types" "^7.12.1" - debug "^4.1.0" - globals "^11.1.0" - lodash "^4.17.19" - -"@babel/traverse@^7.12.10": +"@babel/traverse@^7.1.0", "@babel/traverse@^7.10.4", "@babel/traverse@^7.12.1", "@babel/traverse@^7.12.10", "@babel/traverse@^7.12.5", "@babel/traverse@^7.4.5", "@babel/traverse@^7.7.0": version "7.12.10" resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.12.10.tgz#2d1f4041e8bf42ea099e5b2dc48d6a594c00017a" integrity sha512-6aEtf0IeRgbYWzta29lePeYSk+YAFIC3kyqESeft8o5CkFlYIMX+EQDDWEiAQ9LHOA3d0oHdgrSsID/CKqXJlg== @@ -1163,31 +1120,7 @@ globals "^11.1.0" lodash "^4.17.19" -"@babel/traverse@^7.12.5": - version "7.12.9" - resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.12.9.tgz#fad26c972eabbc11350e0b695978de6cc8e8596f" - integrity sha512-iX9ajqnLdoU1s1nHt36JDI9KG4k+vmI8WgjK5d+aDTwQbL2fUnzedNedssA645Ede3PM2ma1n8Q4h2ohwXgMXw== - dependencies: - "@babel/code-frame" "^7.10.4" - "@babel/generator" "^7.12.5" - "@babel/helper-function-name" "^7.10.4" - "@babel/helper-split-export-declaration" "^7.11.0" - "@babel/parser" "^7.12.7" - "@babel/types" "^7.12.7" - debug "^4.1.0" - globals "^11.1.0" - lodash "^4.17.19" - -"@babel/types@^7.0.0", "@babel/types@^7.10.4", "@babel/types@^7.10.5", "@babel/types@^7.11.0", "@babel/types@^7.12.1", "@babel/types@^7.3.0", "@babel/types@^7.4.4", "@babel/types@^7.7.0": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.12.1.tgz#e109d9ab99a8de735be287ee3d6a9947a190c4ae" - integrity sha512-BzSY3NJBKM4kyatSOWh3D/JJ2O3CVzBybHWxtgxnggaxEuaSTTDqeiSb/xk9lrkw2Tbqyivw5ZU4rT+EfznQsA== - dependencies: - "@babel/helper-validator-identifier" "^7.10.4" - lodash "^4.17.19" - to-fast-properties "^2.0.0" - -"@babel/types@^7.12.10": +"@babel/types@^7.0.0", "@babel/types@^7.10.4", "@babel/types@^7.10.5", "@babel/types@^7.11.0", "@babel/types@^7.12.1", "@babel/types@^7.12.10", "@babel/types@^7.12.5", "@babel/types@^7.12.6", "@babel/types@^7.12.7", "@babel/types@^7.3.0", "@babel/types@^7.3.3", "@babel/types@^7.4.4", "@babel/types@^7.7.0": version "7.12.10" resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.12.10.tgz#7965e4a7260b26f09c56bcfcb0498af1f6d9b260" integrity sha512-sf6wboJV5mGyip2hIpDSKsr80RszPinEFjsHTalMxZAZkoQ2/2yQzxlcFN52SJqsyPfLtPmenL4g2KB3KJXPDw== @@ -1196,15 +1129,6 @@ lodash "^4.17.19" to-fast-properties "^2.0.0" -"@babel/types@^7.12.5", "@babel/types@^7.12.6", "@babel/types@^7.12.7", "@babel/types@^7.3.3": - version "7.12.7" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.12.7.tgz#6039ff1e242640a29452c9ae572162ec9a8f5d13" - integrity sha512-MNyI92qZq6jrQkXvtIiykvl4WtoRrVV9MPn+ZfsoEENjiWcBQ3ZSHrkxnJWgWtLX3XXqX5hrSQ+X69wkmesXuQ== - dependencies: - "@babel/helper-validator-identifier" "^7.10.4" - lodash "^4.17.19" - to-fast-properties "^2.0.0" - "@bcoe/v8-coverage@^0.2.3": version "0.2.3" resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" @@ -1827,19 +1751,19 @@ dependencies: invariant "2" -"@ledgerhq/devices@^5.34.0": - version "5.34.0" - resolved "https://registry.yarnpkg.com/@ledgerhq/devices/-/devices-5.34.0.tgz#4cb073a7bc9528f42f539241fedf44c0c6b451dc" - integrity sha512-oRoZDDfufXAv9KofQdOXc0QztISa9x/YVdiWs55iOlNRQjWYHSPFzeSP6+J+tN0Au/GS9v+wcnTf+tHCtVz27Q== +"@ledgerhq/devices@^5.38.0": + version "5.38.0" + resolved "https://registry.yarnpkg.com/@ledgerhq/devices/-/devices-5.38.0.tgz#0b805020c4f3ac40d35f1b1af6d64d04256b1e0f" + integrity sha512-1RZ+Dh+oVUDMeaPSCeQ56qzgiMHHy481dbkRCDUMRJEzkGqOLI3k34x7XdkVKy1NQdt8G8sYyobP/yixDry5ow== dependencies: - "@ledgerhq/errors" "^5.34.0" - "@ledgerhq/logs" "^5.30.0" + "@ledgerhq/errors" "^5.38.0" + "@ledgerhq/logs" "^5.38.0" rxjs "^6.6.3" -"@ledgerhq/errors@^5.34.0": - version "5.34.0" - resolved "https://registry.yarnpkg.com/@ledgerhq/errors/-/errors-5.34.0.tgz#c003b0929f8ca0c74901a11a88b3e3db4b40e4b7" - integrity sha512-8Td60sOP5wzsjmxmj9Q5hjrr1XjCfB3Vdifq+1fiD6rpjyscYLgmoP2y5GYDPceDhalA/GOrKNSf+aIVVmBNOw== +"@ledgerhq/errors@^5.34.0", "@ledgerhq/errors@^5.38.0": + version "5.38.0" + resolved "https://registry.yarnpkg.com/@ledgerhq/errors/-/errors-5.38.0.tgz#1642b87de47cbabc7b75ca93005a690895920a72" + integrity sha512-d4gQzbOLNBoGIwDtEGFNSb0w0aYN10T5Y749e+vqiJoS3dWrB+5BCSQ/U/ALet0wi/UMIyFY/xmgd1gPaPB3Hw== "@ledgerhq/hw-app-eth@^5.21.0": version "5.35.1" @@ -1852,29 +1776,29 @@ bignumber.js "^9.0.1" rlp "^2.2.6" -"@ledgerhq/hw-transport-node-hid-noevents@^5.34.0": - version "5.34.0" - resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport-node-hid-noevents/-/hw-transport-node-hid-noevents-5.34.0.tgz#c31cc3e3033f6fbf77b81c3a9c34230aadd6f3cb" - integrity sha512-n5KRdZ6nmDrmsEXFjIipNdx9rhHbEFmZ5YDoUkdShvKFmaDeKVn0h7RCBwblJRITUZl0RfBzBuBRlpNjQsFfqg== - dependencies: - "@ledgerhq/devices" "^5.34.0" - "@ledgerhq/errors" "^5.34.0" - "@ledgerhq/hw-transport" "^5.34.0" - "@ledgerhq/logs" "^5.30.0" - node-hid "2.0.0-0" - -"@ledgerhq/hw-transport-node-hid-singleton@5.34.0": - version "5.34.0" - resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport-node-hid-singleton/-/hw-transport-node-hid-singleton-5.34.0.tgz#1bba566a28efe0bbb31c1c2f214ca574a7b69104" - integrity sha512-RMgWafAyHyZtQjVe1dwu90oSsQ4W/4CpSx2ps87u5sDyWyNURti2pdraDZ1kosLhqTEYedU3VfTV4EFJZ5yfuw== - dependencies: - "@ledgerhq/devices" "^5.34.0" - "@ledgerhq/errors" "^5.34.0" - "@ledgerhq/hw-transport" "^5.34.0" - "@ledgerhq/hw-transport-node-hid-noevents" "^5.34.0" - "@ledgerhq/logs" "^5.30.0" +"@ledgerhq/hw-transport-node-hid-noevents@^5.38.0": + version "5.38.0" + resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport-node-hid-noevents/-/hw-transport-node-hid-noevents-5.38.0.tgz#ffbfb0b997e585fc08b6b220997caaa59e094554" + integrity sha512-zuxN3gWfCuN+pbK3BKc8z3VCulKI7zee1N3xhCWua9TiwL3leBTBs25Bvm22fmiLJYhzszccbF673/bpnnIQAA== + dependencies: + "@ledgerhq/devices" "^5.38.0" + "@ledgerhq/errors" "^5.38.0" + "@ledgerhq/hw-transport" "^5.38.0" + "@ledgerhq/logs" "^5.38.0" + node-hid "2.1.1" + +"@ledgerhq/hw-transport-node-hid-singleton@5.38.0": + version "5.38.0" + resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport-node-hid-singleton/-/hw-transport-node-hid-singleton-5.38.0.tgz#ea133ac3a7015aaafd5d629388da4d4a2086c761" + integrity sha512-FPpr6R2Cs6YKCamprC9vzJa+P7RieyMLQC3cG6EjYg8tmvHPtIxpmWFclNi45jZ05Ve1YvNjutoHVTVn0cOnpg== + dependencies: + "@ledgerhq/devices" "^5.38.0" + "@ledgerhq/errors" "^5.38.0" + "@ledgerhq/hw-transport" "^5.38.0" + "@ledgerhq/hw-transport-node-hid-noevents" "^5.38.0" + "@ledgerhq/logs" "^5.38.0" lodash "^4.17.20" - node-hid "2.0.0-0" + node-hid "2.1.1" usb-detection "^4.10.0" "@ledgerhq/hw-transport-u2f@^5.21.0": @@ -1887,19 +1811,19 @@ "@ledgerhq/logs" "^5.30.0" u2f-api "0.2.7" -"@ledgerhq/hw-transport@^5.34.0": - version "5.34.0" - resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport/-/hw-transport-5.34.0.tgz#b27eb0d9941a2e6220e5af3e3d4f48ce8a993982" - integrity sha512-JxhqU9sBn+WH3CPMus9b70SED7LEeW17xw0VL5aRdxFu4YS5rhy5Xf4Sd5jIQfyDkHik1ouzfJVuQEju8+GGBw== +"@ledgerhq/hw-transport@^5.34.0", "@ledgerhq/hw-transport@^5.38.0": + version "5.38.0" + resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport/-/hw-transport-5.38.0.tgz#b02bea73d77e729d13c367a967df1666f9ef940d" + integrity sha512-CAxvHukCcp+RqaEsSltmBw4Lb1yW42fiF/LTYN7JvCkZyLIQhvkndLDVCgp4hpMdtLK4bkf7RJRElqbN0vRoAQ== dependencies: - "@ledgerhq/devices" "^5.34.0" - "@ledgerhq/errors" "^5.34.0" + "@ledgerhq/devices" "^5.38.0" + "@ledgerhq/errors" "^5.38.0" events "^3.2.0" -"@ledgerhq/logs@^5.30.0": - version "5.30.0" - resolved "https://registry.yarnpkg.com/@ledgerhq/logs/-/logs-5.30.0.tgz#76e8d7e5a06a73c9b99da51fa5befd5cfd5309d4" - integrity sha512-wUhg2VTfUrWihjdGqKkH/s7TBzdIM1yyd2LiscYsfTX2I0xYDMnpE+NkMReeGU8PN3QhCPgnlg9/P9V6UWoJBA== +"@ledgerhq/logs@^5.30.0", "@ledgerhq/logs@^5.38.0": + version "5.38.0" + resolved "https://registry.yarnpkg.com/@ledgerhq/logs/-/logs-5.38.0.tgz#3c5dbd1f62c0bf5580477b218fb57c67b575643a" + integrity sha512-i87Yn89Cq2D9Y0KmrEzCm62XHzI2edeOTBENKH6vAyzESGzyF+SBoqtZNwrjJcKup3/9dNn/zHjpicY7ev94Vw== "@material-ui/core@^4.11.0": version "4.11.2" @@ -8144,10 +8068,10 @@ electron-updater@4.3.5: lodash.isequal "^4.5.0" semver "^7.3.2" -electron@^9.3.5: - version "9.3.5" - resolved "https://registry.yarnpkg.com/electron/-/electron-9.3.5.tgz#7967146b81e6d9b484773243fd4a4f671a50b884" - integrity sha512-EPmDsp7sO0UPtw7nLD1ufse/nBskP+ifXzBgUg9psCUlapkzuwYi6pmLAzKLW/bVjwgyUKwh1OKWILWfOeLGcQ== +electron@^9.4.0: + version "9.4.1" + resolved "https://registry.yarnpkg.com/electron/-/electron-9.4.1.tgz#62a2aae4cd93f1b56d794a47541505a71654177a" + integrity sha512-r4CxoVG9Ja7tBtkilWMnBsBGup8G8Z+v7icZmwysHa8/OSr0OrLjrcOF/30BAP7yPE5fz/XTxygnltzW4OTZdw== dependencies: "@electron/get" "^1.0.1" "@types/node" "^12.0.12" @@ -13871,10 +13795,10 @@ node-gyp-build@^4.2.0: resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.2.3.tgz#ce6277f853835f718829efb47db20f3e4d9c4739" integrity sha512-MN6ZpzmfNCRM+3t57PTJHgHyw/h4OWnZ6mR8P5j/uZtqQr46RRuDE/P+g3n0YR/AiYXeWixZZzaip77gdICfRg== -node-hid@2.0.0-0: - version "2.0.0-0" - resolved "https://registry.yarnpkg.com/node-hid/-/node-hid-2.0.0-0.tgz#35daffb4708f27331ca4143af0b8cf338fea9908" - integrity sha512-Ywc4WaMANhvqHDTynRmbuP52ln76WiNRjjAom5l2uLyNY1wixCVjISi+SP4/Rfgcddq9UJM1sR5+lPD0GcvvMg== +node-hid@2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/node-hid/-/node-hid-2.1.1.tgz#f83c8aa0bb4e6758b5f7383542477da93f67359d" + integrity sha512-Skzhqow7hyLZU93eIPthM9yjot9lszg9xrKxESleEs05V2NcbUptZc5HFqzjOkSmL0sFlZFr3kmvaYebx06wrw== dependencies: bindings "^1.5.0" node-addon-api "^3.0.2" @@ -17022,14 +16946,7 @@ resolve@1.18.1: is-core-module "^2.0.0" path-parse "^1.0.6" -resolve@^1.1.6, resolve@^1.10.0, resolve@^1.11.0, resolve@^1.12.0, resolve@^1.13.1, resolve@^1.17.0, resolve@^1.8.1, resolve@~1.17.0: - version "1.17.0" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.17.0.tgz#b25941b54968231cc2d1bb76a79cb7f2c0bf8444" - integrity sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w== - dependencies: - path-parse "^1.0.6" - -resolve@^1.14.2, resolve@^1.18.1: +resolve@^1.1.6, resolve@^1.10.0, resolve@^1.11.0, resolve@^1.12.0, resolve@^1.13.1, resolve@^1.14.2, resolve@^1.17.0, resolve@^1.18.1, resolve@^1.8.1: version "1.19.0" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.19.0.tgz#1af5bf630409734a067cae29318aac7fa29a267c" integrity sha512-rArEXAgsBG4UgRGcynxWIWKFvh/XZCcS8UJdHhwy91zwAvCZIbcs+vAbflgBnNjYMs/i/i+/Ux6IZhML1yPvxg== @@ -17037,6 +16954,13 @@ resolve@^1.14.2, resolve@^1.18.1: is-core-module "^2.1.0" path-parse "^1.0.6" +resolve@~1.17.0: + version "1.17.0" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.17.0.tgz#b25941b54968231cc2d1bb76a79cb7f2c0bf8444" + integrity sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w== + dependencies: + path-parse "^1.0.6" + responselike@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/responselike/-/responselike-1.0.2.tgz#918720ef3b631c5642be068f15ade5a46f4ba1e7" @@ -20690,12 +20614,7 @@ whatwg-fetch@2.0.4: resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz#dde6a5df315f9d39991aa17621853d720b85566f" integrity sha512-dcQ1GWpOD/eEQ97k66aiEVpNnapVj90/+R+SXTPYGHpYBBypfKJEQjLrvMZ7YXbKm21gXd4NcuxUTjiv1YtLng== -whatwg-fetch@^3.4.1: - version "3.4.1" - resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-3.4.1.tgz#e5f871572d6879663fa5674c8f833f15a8425ab3" - integrity sha512-sofZVzE1wKwO+EYPbWfiwzaKovWiZXf4coEzjGP9b2GBVgQRLQUZ2QcuPpQExGDAW5GItpEm6Tl4OU5mywnAoQ== - -whatwg-fetch@^3.5.0: +whatwg-fetch@^3.4.1, whatwg-fetch@^3.5.0: version "3.5.0" resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-3.5.0.tgz#605a2cd0a7146e5db141e29d1c62ab84c0c4c868" integrity sha512-jXkLtsR42xhXg7akoDKvKWE40eJeI+2KZqcp2h3NsOrRnDvtWX36KcKl30dy+hxECivdk2BVUHVNrPtoMBUx6A== From 4c45daa2e2df27467c886a7bc82facbcdd0527c8 Mon Sep 17 00:00:00 2001 From: Agustin Pane Date: Fri, 15 Jan 2021 12:35:09 -0300 Subject: [PATCH 03/18] Fix useTxData refactor Remove unnecessary useTxAmount --- .../SendModal/screens/ReviewTx/index.tsx | 26 +++------- yarn.lock | 47 ------------------- 2 files changed, 7 insertions(+), 66 deletions(-) diff --git a/src/routes/safe/components/Balances/SendModal/screens/ReviewTx/index.tsx b/src/routes/safe/components/Balances/SendModal/screens/ReviewTx/index.tsx index f6895a9ebd..4885dc8a48 100644 --- a/src/routes/safe/components/Balances/SendModal/screens/ReviewTx/index.tsx +++ b/src/routes/safe/components/Balances/SendModal/screens/ReviewTx/index.tsx @@ -37,6 +37,7 @@ import { TokenProps } from 'src/logic/tokens/store/model/token' import { RecordOf } from 'immutable' import { useEstimateTransactionGas } from 'src/logic/hooks/useEstimateTransactionGas' import { TransactionFees } from 'src/components/TransactionsFees' +import BigNumber from 'bignumber.js' const useStyles = makeStyles(styles) const { nativeCoin } = getNetworkInfo() @@ -56,20 +57,6 @@ type ReviewTxProps = { tx: ReviewTxProp } -const useTxAmount = (tx: ReviewTxProp, isSendingNativeToken: boolean, txToken?: RecordOf): string => { - const [txAmount, setTxAmount] = useState('0') - - // txAmount should be 0 if we send tokens - // the real value is encoded in txData and will be used by the contract - // if txAmount > 0 it would send ETH from the Safe (and the data will be empty) - useEffect(() => { - const txAmount = isSendingNativeToken ? toTokenUnit(tx.amount, nativeCoin.decimals) : '0' - setTxAmount(txAmount) - }, [tx.amount, txToken, isSendingNativeToken]) - - return txAmount -} - const useTxData = ( isSendingNativeToken: boolean, txAmount: string, @@ -88,7 +75,9 @@ const useTxData = ( if (!isSendingNativeToken) { const StandardToken = await getHumanFriendlyToken() const tokenInstance = await StandardToken.at(txToken.address as string) - txData = tokenInstance.contract.methods.transfer(recipientAddress, txAmount).encodeABI() + const decimals = await tokenInstance.decimals() + const erc20TransferAmount = new BigNumber(txAmount).times(10 ** decimals.toNumber()).toString() + txData = tokenInstance.contract.methods.transfer(recipientAddress, erc20TransferAmount).encodeABI() } setData(txData) } @@ -107,9 +96,8 @@ const ReviewTx = ({ onClose, onPrev, tx }: ReviewTxProps): React.ReactElement => const txToken = useMemo(() => tokens.find((token) => sameAddress(token.address, tx.token)), [tokens, tx.token]) const isSendingNativeToken = sameAddress(txToken?.address, nativeCoin.address) const txRecipient = isSendingNativeToken ? tx.recipientAddress : txToken?.address || '' - - const txAmount = useTxAmount(tx, isSendingNativeToken, txToken) - const data = useTxData(isSendingNativeToken, txAmount, tx.recipientAddress, txToken) + const txValue = isSendingNativeToken ? toTokenUnit(tx.amount, nativeCoin.decimals) : '0' + const data = useTxData(isSendingNativeToken, tx.amount, tx.recipientAddress, txToken) const { gasCostFormatted, @@ -153,7 +141,7 @@ const ReviewTx = ({ onClose, onPrev, tx }: ReviewTxProps): React.ReactElement => createTransaction({ safeAddress: safeAddress, to: txRecipient as string, - valueInWei: txAmount, + valueInWei: txValue, txData: data, notifiedTransaction: TX_NOTIFICATION_TYPES.STANDARD_TX, }), diff --git a/yarn.lock b/yarn.lock index 74f066ad6a..86b9265f8e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3558,18 +3558,6 @@ semver "^7.3.2" tsutils "^3.17.1" -"@typescript-eslint/experimental-utils@4.12.0": - version "4.12.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-4.12.0.tgz#372838e76db76c9a56959217b768a19f7129546b" - integrity sha512-MpXZXUAvHt99c9ScXijx7i061o5HEjXltO+sbYfZAAHxv3XankQkPaNi5myy0Yh0Tyea3Hdq1pi7Vsh0GJb0fA== - dependencies: - "@types/json-schema" "^7.0.3" - "@typescript-eslint/scope-manager" "4.12.0" - "@typescript-eslint/types" "4.12.0" - "@typescript-eslint/typescript-estree" "4.12.0" - eslint-scope "^5.0.0" - eslint-utils "^2.0.0" - "@typescript-eslint/experimental-utils@4.13.0", "@typescript-eslint/experimental-utils@^4.0.1": version "4.13.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-4.13.0.tgz#9dc9ab375d65603b43d938a0786190a0c72be44e" @@ -3603,14 +3591,6 @@ "@typescript-eslint/typescript-estree" "4.13.0" debug "^4.1.1" -"@typescript-eslint/scope-manager@4.12.0": - version "4.12.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.12.0.tgz#beeb8beca895a07b10c593185a5612f1085ef279" - integrity sha512-QVf9oCSVLte/8jvOsxmgBdOaoe2J0wtEmBr13Yz0rkBNkl5D8bfnf6G4Vhox9qqMIoG7QQoVwd2eG9DM/ge4Qg== - dependencies: - "@typescript-eslint/types" "4.12.0" - "@typescript-eslint/visitor-keys" "4.12.0" - "@typescript-eslint/scope-manager@4.13.0": version "4.13.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.13.0.tgz#5b45912a9aa26b29603d8fa28f5e09088b947141" @@ -3624,11 +3604,6 @@ resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-3.10.1.tgz#1d7463fa7c32d8a23ab508a803ca2fe26e758727" integrity sha512-+3+FCUJIahE9q0lDi1WleYzjCwJs5hIsbugIgnbB+dSCYUxl8L6PwmsyOPFZde2hc1DlTo/xnkOgiTLSyAbHiQ== -"@typescript-eslint/types@4.12.0": - version "4.12.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.12.0.tgz#fb891fe7ccc9ea8b2bbd2780e36da45d0dc055e5" - integrity sha512-N2RhGeheVLGtyy+CxRmxdsniB7sMSCfsnbh8K/+RUIXYYq3Ub5+sukRCjVE80QerrUBvuEvs4fDhz5AW/pcL6g== - "@typescript-eslint/types@4.13.0": version "4.13.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.13.0.tgz#6a7c6015a59a08fbd70daa8c83dfff86250502f8" @@ -3648,20 +3623,6 @@ semver "^7.3.2" tsutils "^3.17.1" -"@typescript-eslint/typescript-estree@4.12.0": - version "4.12.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.12.0.tgz#3963418c850f564bdab3882ae23795d115d6d32e" - integrity sha512-gZkFcmmp/CnzqD2RKMich2/FjBTsYopjiwJCroxqHZIY11IIoN0l5lKqcgoAPKHt33H2mAkSfvzj8i44Jm7F4w== - dependencies: - "@typescript-eslint/types" "4.12.0" - "@typescript-eslint/visitor-keys" "4.12.0" - debug "^4.1.1" - globby "^11.0.1" - is-glob "^4.0.1" - lodash "^4.17.15" - semver "^7.3.2" - tsutils "^3.17.1" - "@typescript-eslint/typescript-estree@4.13.0": version "4.13.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.13.0.tgz#cf6e2207c7d760f5dfd8d18051428fadfc37b45e" @@ -3683,14 +3644,6 @@ dependencies: eslint-visitor-keys "^1.1.0" -"@typescript-eslint/visitor-keys@4.12.0": - version "4.12.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.12.0.tgz#a470a79be6958075fa91c725371a83baf428a67a" - integrity sha512-hVpsLARbDh4B9TKYz5cLbcdMIOAoBYgFPCSP9FFS/liSF+b33gVNq8JHY3QGhHNVz85hObvL7BEYLlgx553WCw== - dependencies: - "@typescript-eslint/types" "4.12.0" - eslint-visitor-keys "^2.0.0" - "@typescript-eslint/visitor-keys@4.13.0": version "4.13.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.13.0.tgz#9acb1772d3b3183182b6540d3734143dce9476fe" From cdbe4dfc5724e5124dd64e84c8a9f27200553300 Mon Sep 17 00:00:00 2001 From: Daniel Sanchez Date: Fri, 15 Jan 2021 17:33:35 +0100 Subject: [PATCH 04/18] Cleanup erc20 amount calcs --- .../components/Balances/SendModal/screens/ReviewTx/index.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/routes/safe/components/Balances/SendModal/screens/ReviewTx/index.tsx b/src/routes/safe/components/Balances/SendModal/screens/ReviewTx/index.tsx index 4885dc8a48..d3e389a6bf 100644 --- a/src/routes/safe/components/Balances/SendModal/screens/ReviewTx/index.tsx +++ b/src/routes/safe/components/Balances/SendModal/screens/ReviewTx/index.tsx @@ -37,7 +37,6 @@ import { TokenProps } from 'src/logic/tokens/store/model/token' import { RecordOf } from 'immutable' import { useEstimateTransactionGas } from 'src/logic/hooks/useEstimateTransactionGas' import { TransactionFees } from 'src/components/TransactionsFees' -import BigNumber from 'bignumber.js' const useStyles = makeStyles(styles) const { nativeCoin } = getNetworkInfo() @@ -75,8 +74,7 @@ const useTxData = ( if (!isSendingNativeToken) { const StandardToken = await getHumanFriendlyToken() const tokenInstance = await StandardToken.at(txToken.address as string) - const decimals = await tokenInstance.decimals() - const erc20TransferAmount = new BigNumber(txAmount).times(10 ** decimals.toNumber()).toString() + const erc20TransferAmount = toTokenUnit(txAmount, txToken.decimals) txData = tokenInstance.contract.methods.transfer(recipientAddress, erc20TransferAmount).encodeABI() } setData(txData) From 0fb1824f49be303245776bd25c2a2aed393fc65e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20Longoni?= Date: Fri, 15 Jan 2021 16:06:05 -0300 Subject: [PATCH 05/18] Fix asset value column alignment (#1778) --- src/routes/safe/components/Balances/Coins/styles.ts | 1 - src/routes/safe/components/Balances/dataFetcher.ts | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/safe/components/Balances/Coins/styles.ts b/src/routes/safe/components/Balances/Coins/styles.ts index 5df6bf5138..3c10059da8 100644 --- a/src/routes/safe/components/Balances/Coins/styles.ts +++ b/src/routes/safe/components/Balances/Coins/styles.ts @@ -46,7 +46,6 @@ export const styles = createStyles({ marginRight: sm, }, currencyValueRow: { - maxWidth: '125px', textAlign: 'right', }, }) diff --git a/src/routes/safe/components/Balances/dataFetcher.ts b/src/routes/safe/components/Balances/dataFetcher.ts index c7a3f2d49d..e950560e30 100644 --- a/src/routes/safe/components/Balances/dataFetcher.ts +++ b/src/routes/safe/components/Balances/dataFetcher.ts @@ -105,6 +105,7 @@ export const generateColumns = (): List => { const value: TableColumn = { id: BALANCE_TABLE_VALUE_ID, + align: 'right', order: true, label: 'Value', custom: false, From 6cc780c994ad8faffd61c812912368b475963b52 Mon Sep 17 00:00:00 2001 From: Daniel Sanchez Date: Fri, 15 Jan 2021 20:17:13 +0100 Subject: [PATCH 06/18] Upgrade build action to use node 14 --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f6fd657672..2e0f2488f7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -52,9 +52,9 @@ jobs: yarn global add node-gyp yarn config set node_gyp "$_\node_modules\node-gyp\bin\node-gyp.js" - name: Install Node.js, NPM and Yarn - uses: actions/setup-node@v1 + uses: actions/setup-node@v2 with: - node-version: 12 + node-version: 14 - run: yarn install --frozen-lockfile --network-concurrency 1 - name: Build/Release Desktop App env: From b7f1036a603e4b3e7d3669c1c5a3f723dea2f9cb Mon Sep 17 00:00:00 2001 From: Daniel Sanchez Date: Fri, 15 Jan 2021 22:47:07 +0100 Subject: [PATCH 07/18] Disable yarn cache for electron build --- .github/workflows/release.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2e0f2488f7..05ed593d4d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,17 +28,17 @@ jobs: uses: actions/checkout@v2 # Add cache for yarn directory - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn cache dir)" + # - name: Get yarn cache directory path + # id: yarn-cache-dir-path + # run: echo "::set-output name=dir::$(yarn cache dir)" - - uses: actions/cache@v2 - id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) - with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-yarn- + # - uses: actions/cache@v2 + # id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) + # with: + # path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + # key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + # restore-keys: | + # ${{ runner.os }}-yarn- - name: Patch node gyp on windows to support Visual Studio 2019 if: startsWith(matrix.os, 'windows') From 2264b1cb7e6b2c54c5b1e3ce5c91a3e46c86b55f Mon Sep 17 00:00:00 2001 From: Daniel Sanchez Date: Sat, 16 Jan 2021 00:12:36 +0100 Subject: [PATCH 08/18] Remove unused blocknative keys Remove unused build file --- .github/ISSUE_TEMPLATE/workflows/release.yml | 55 -------------------- .github/workflows/release.yml | 1 - docs/networks.md | 2 - src/utils/constants.ts | 1 - 4 files changed, 59 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/workflows/release.yml diff --git a/.github/ISSUE_TEMPLATE/workflows/release.yml b/.github/ISSUE_TEMPLATE/workflows/release.yml deleted file mode 100644 index 550e15142b..0000000000 --- a/.github/ISSUE_TEMPLATE/workflows/release.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: Build/release - -# this will help you specify where to run -on: - push: - branches: - # this will run on the specified branch - - feature/desktop-app - -env: - REACT_APP_BLOCKNATIVE_KEY: ${{ secrets.REACT_APP_BLOCKNATIVE_KEY }} - REACT_APP_FORTMATIC_KEY: ${{ secrets.REACT_APP_FORTMATIC_KEY }} - REACT_APP_GOOGLE_ANALYTICS_ID_MAINNET: ${{ secrets.REACT_APP_GOOGLE_ANALYTICS_ID_MAINNET }} - REACT_APP_INFURA_TOKEN: ${{ secrets.REACT_APP_INFURA_TOKEN }} - REACT_APP_PORTIS_ID: ${{ secrets.REACT_APP_PORTIS_ID }} - -jobs: - release: - runs-on: ${{ matrix.os }} - - strategy: - matrix: - os: [macos-latest, ubuntu-latest] - - steps: - - name: Check out Git repository - uses: actions/checkout@v1 - - - name: Install Node.js, NPM and Yarn - uses: actions/setup-node@v1 - with: - node-version: 10.16 - - - name: Build/release Electron app - env: - # macOS notarization API key - APPLEID: ${{ secrets.APPLE_ID }} - APPLEIDPASS: ${{ secrets.APPLE_ID_PASS }} - uses: samuelmeuli/action-electron-builder@v1 - with: - #Build scipt - build_script_name: build-desktop - - # GitHub token, automatically provided to the action - # (No need to define this secret in the repo settings) - - github_token: ${{ secrets.github_token }} - - # macOS code signing certificate - mac_certs: ${{ secrets.MAC_CERTS }} - mac_certs_password: ${{ secrets.MAC_CERTS_PASSWORD }} - - # If the commit is tagged with a version (e.g. "v1.0.0"), - # release the app after building - release: ${{ startsWith(github.ref, 'refs/tags/v') }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 05ed593d4d..fc596b8cab 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,7 +5,6 @@ on: workflow_dispatch env: - REACT_APP_BLOCKNATIVE_KEY: ${{ secrets.REACT_APP_BLOCKNATIVE_KEY }} REACT_APP_FORTMATIC_KEY: ${{ secrets.REACT_APP_FORTMATIC_KEY }} REACT_APP_GOOGLE_ANALYTICS_ID_MAINNET: ${{ secrets.REACT_APP_GOOGLE_ANALYTICS_ID_MAINNET }} REACT_APP_INFURA_TOKEN: ${{ secrets.REACT_APP_INFURA_TOKEN }} diff --git a/docs/networks.md b/docs/networks.md index e1519441b6..a048fa8654 100644 --- a/docs/networks.md +++ b/docs/networks.md @@ -161,7 +161,6 @@ export type GasPriceOracle = { - **REACT_APP_GOOGLE_ANALYTICS**: Used for enabling google analytics - **REACT_APP_PORTIS_ID**: Portis ID for enabling it on given network - **REACT_APP_FORTMATIC_KEY**: Formatic yey for given network -- **REACT_APP_BLOCKNATIVE_KEY**: Blocknative key for given network --- ## How to add a network @@ -190,7 +189,6 @@ export enum ETHEREUM_NETWORK { * REACT_APP_GOOGLE_ANALYTICS * REACT_APP_PORTIS_ID * REACT_APP_FORTMATIC_KEY -* REACT_APP_BLOCKNATIVE_KEY 3) Add the **NetworkSettings** in [`src/config/networks`](/src/config/networks) as `.ts`: diff --git a/src/utils/constants.ts b/src/utils/constants.ts index c03e712140..57e6b3dd61 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -7,7 +7,6 @@ export const GOOGLE_ANALYTICS_ID = process.env.REACT_APP_GOOGLE_ANALYTICS || '' export const SENTRY_DSN = process.env.REACT_APP_SENTRY_DSN || '' export const PORTIS_ID = process.env.REACT_APP_PORTIS_ID ?? '852b763d-f28b-4463-80cb-846d7ec5806b' export const FORTMATIC_KEY = process.env.REACT_APP_FORTMATIC_KEY ?? 'pk_test_CAD437AA29BE0A40' -export const BLOCKNATIVE_KEY = process.env.REACT_APP_BLOCKNATIVE_KEY ?? '7fbb9cee-7e97-4436-8770-8b29a9a8814c' /* * Not being used export const SQUARELINK_ID = { From 6daaf0cb6db41a0c308cd2e45e33b4afb26a9546 Mon Sep 17 00:00:00 2001 From: Daniel Sanchez Date: Sat, 16 Jan 2021 00:13:17 +0100 Subject: [PATCH 09/18] Enable dev tools to test electron build --- public/electron.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/electron.js b/public/electron.js index 92626c8175..c149df06f1 100644 --- a/public/electron.js +++ b/public/electron.js @@ -102,11 +102,11 @@ function createWindow(port = DEFAULT_PORT) { mainWindow.loadURL(isDev ? 'http://localhost:3000' : `https://localhost:${port}`) - if (isDev) { + // if (isDev) { // Open the DevTools. mainWindow.webContents.openDevTools() //BrowserWindow.addDevToolsExtension(''); - } + // } mainWindow.setMenu(null) mainWindow.setMenuBarVisibility(false) From 54ed65ca4ef5c883b3622867eea6e7f57320e0d9 Mon Sep 17 00:00:00 2001 From: Daniel Sanchez Date: Mon, 18 Jan 2021 10:20:04 +0100 Subject: [PATCH 10/18] Disable devtools --- public/electron.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/electron.js b/public/electron.js index c149df06f1..92626c8175 100644 --- a/public/electron.js +++ b/public/electron.js @@ -102,11 +102,11 @@ function createWindow(port = DEFAULT_PORT) { mainWindow.loadURL(isDev ? 'http://localhost:3000' : `https://localhost:${port}`) - // if (isDev) { + if (isDev) { // Open the DevTools. mainWindow.webContents.openDevTools() //BrowserWindow.addDevToolsExtension(''); - // } + } mainWindow.setMenu(null) mainWindow.setMenuBarVisibility(false) From 4a10ed045f7498df4be48bdd8f9c9c73989ec96a Mon Sep 17 00:00:00 2001 From: Daniel Sanchez Date: Mon, 18 Jan 2021 11:14:29 +0100 Subject: [PATCH 11/18] Build desktop app using latest ubuntu runner --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fc596b8cab..9ff9aa1d41 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,7 +20,7 @@ jobs: fail-fast: false max-parallel: 15 matrix: - os: [macos-latest, windows-latest, ubuntu-latest] + os: [macos-latest, windows-latest, ubuntu-20.04] steps: - name: Check out Git repository From 4aa5955b08f525ea851ddeafcb3ded5e51fd4d13 Mon Sep 17 00:00:00 2001 From: Daniel Sanchez Date: Mon, 18 Jan 2021 12:07:34 +0100 Subject: [PATCH 12/18] Set v2.17.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 189b525a71..f846bfa3dc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "safe-react", - "version": "2.17.0", + "version": "2.17.1", "description": "Allowing crypto users manage funds in a safer way", "website": "https://github.com/gnosis/safe-react#readme", "bugs": { From ce43a97beeb1eda0a1614e28cfe0cb3698d1695a Mon Sep 17 00:00:00 2001 From: Agustin Pane Date: Mon, 18 Jan 2021 14:04:04 -0300 Subject: [PATCH 13/18] (Fix) - #1783 Trezor gas estimation fail (#1788) * Improves the way we parse the error message on getDataFromNodeErrorMessage for supporting trezor response * Fix trezor execution not working properly * Add parameter to processTransaction in ApproveTxModal Co-authored-by: Daniel Sanchez --- .../safe/store/actions/processTransaction.ts | 4 ++- .../safe/transactions/__tests__/gas.test.ts | Bin 7372 -> 8122 bytes src/logic/safe/transactions/gas.ts | 23 +++++++++++++++++- .../ExpandedTx/ApproveTxModal/index.tsx | 1 + 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/logic/safe/store/actions/processTransaction.ts b/src/logic/safe/store/actions/processTransaction.ts index 8d31d343ab..a8a352bf41 100644 --- a/src/logic/safe/store/actions/processTransaction.ts +++ b/src/logic/safe/store/actions/processTransaction.ts @@ -32,6 +32,7 @@ interface ProcessTransactionArgs { safeAddress: string tx: Transaction userAddress: string + thresholdReached: boolean } type ProcessTransactionAction = ThunkAction, AppReduxState, DispatchReturn, AnyAction> @@ -42,6 +43,7 @@ export const processTransaction = ({ safeAddress, tx, userAddress, + thresholdReached, }: ProcessTransactionArgs): ProcessTransactionAction => async ( dispatch: Dispatch, getState: () => AppReduxState, @@ -56,7 +58,7 @@ export const processTransaction = ({ const isExecution = approveAndExecute || (await shouldExecuteTransaction(safeInstance, nonce, lastTx)) const safeVersion = await getCurrentSafeVersion(safeInstance) - const preApprovingOwner = approveAndExecute ? userAddress : undefined + const preApprovingOwner = approveAndExecute && !thresholdReached ? userAddress : undefined let sigs = generateSignaturesFromTxConfirmations(tx.confirmations, preApprovingOwner) if (!sigs) { diff --git a/src/logic/safe/transactions/__tests__/gas.test.ts b/src/logic/safe/transactions/__tests__/gas.test.ts index 828d1e64f6ff53355619733c309af0a4d4c98555..028796ad206923d510f12579a643e819f097a517 100644 GIT binary patch delta 170 zcmX?OxyycoC=0uONKtB4e$ixmA?wWnER_WIRY)t!&s8V^ zt5PUW%*jbDnY@wTX!1GHbDky!DHiHnTna#t3{+bJRTc!(Y73T9P*8U*D#|aiQb?^x yO)f3T%+FION-aw*DoIVTQi#b@SJ0k3QSuxM$h66V>~?Gr%O-E&a$&C3 { return data.match(/.{2}/g)?.reduce(reducer, 0) } +interface ErrorDataJson extends JSON { + originalError?: { + data?: string + } + data?: string +} + +const getJSONOrNullFromString = (stringInput: string): ErrorDataJson | null => { + try { + return JSON.parse(stringInput) + } catch (error) { + return null + } +} + // Parses the result from the error message (GETH, OpenEthereum/Parity and Nethermind) and returns the data value export const getDataFromNodeErrorMessage = (errorMessage: string): string | undefined => { // Replace illegal characters that often comes within the error string (like � for example) @@ -35,7 +50,13 @@ export const getDataFromNodeErrorMessage = (errorMessage: string): string | unde const [, ...error] = normalizedErrorString.split('\n') try { - const errorAsJSON = JSON.parse(error.join('')) + const errorAsString = error.join('') + const errorAsJSON = getJSONOrNullFromString(errorAsString) + + // Trezor wallet returns the error not as an JSON object but directly as string + if (!errorAsJSON) { + return errorAsString.length ? errorAsString : undefined + } // For new GETH nodes they will return the data as error in the format: // { diff --git a/src/routes/safe/components/Transactions/TxsTable/ExpandedTx/ApproveTxModal/index.tsx b/src/routes/safe/components/Transactions/TxsTable/ExpandedTx/ApproveTxModal/index.tsx index 88c5c99437..f09395b108 100644 --- a/src/routes/safe/components/Transactions/TxsTable/ExpandedTx/ApproveTxModal/index.tsx +++ b/src/routes/safe/components/Transactions/TxsTable/ExpandedTx/ApproveTxModal/index.tsx @@ -105,6 +105,7 @@ export const ApproveTxModal = ({ userAddress, notifiedTransaction: TX_NOTIFICATION_TYPES.CONFIRMATION_TX, approveAndExecute: canExecute && approveAndExecute && isTheTxReadyToBeExecuted, + thresholdReached, }), ) onClose() From 0d0acacd04851416301e381033a28923bb228e9a Mon Sep 17 00:00:00 2001 From: Agustin Pane Date: Mon, 18 Jan 2021 15:25:28 -0300 Subject: [PATCH 14/18] Adds TransactionFees modal to confirm safe app tx modal (#1789) --- .../components/ConfirmTransactionModal.tsx | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/routes/safe/components/Apps/components/ConfirmTransactionModal.tsx b/src/routes/safe/components/Apps/components/ConfirmTransactionModal.tsx index 06b95a08f4..fd199a373a 100644 --- a/src/routes/safe/components/Apps/components/ConfirmTransactionModal.tsx +++ b/src/routes/safe/components/Apps/components/ConfirmTransactionModal.tsx @@ -25,6 +25,8 @@ import GasEstimationInfo from './GasEstimationInfo' import { getNetworkInfo } from 'src/config' import { TransactionParams } from './AppFrame' import { EstimationStatus, useEstimateTransactionGas } from 'src/logic/hooks/useEstimateTransactionGas' +import Row from 'src/components/layout/Row' +import { TransactionFees } from 'src/components/TransactionsFees' const isTxValid = (t: Transaction): boolean => { if (!['string', 'number'].includes(typeof t.value)) { @@ -67,6 +69,10 @@ const StyledTextBox = styled(TextBox)` max-width: 444px; ` +const Container = styled.div` + max-width: 480px; +` + type OwnProps = { isOpen: boolean app: SafeApp @@ -96,7 +102,14 @@ export const ConfirmTransactionModal = ({ }: OwnProps): React.ReactElement | null => { const [estimatedSafeTxGas, setEstimatedSafeTxGas] = useState(0) - const { gasEstimation, txEstimationExecutionStatus } = useEstimateTransactionGas({ + const { + gasEstimation, + isOffChainSignature, + isCreation, + isExecution, + gasCostFormatted, + txEstimationExecutionStatus, + } = useEstimateTransactionGas({ txData: encodeMultiSendCall(txs), txRecipient: MULTI_SEND_ADDRESS, operation: DELEGATE_CALL, @@ -159,7 +172,7 @@ export const ConfirmTransactionModal = ({ ) : ( - <> + {txs.map((tx, index) => ( @@ -195,7 +208,16 @@ export const ConfirmTransactionModal = ({ /> )} - + + + + ) return ( From f79f37709fd62020336ac63dea4390be6283292a Mon Sep 17 00:00:00 2001 From: Agustin Pane Date: Mon, 18 Jan 2021 15:43:05 -0300 Subject: [PATCH 15/18] (Feature) Disable gas estimation for WalletConnect (#1790) * Make calculateGasOf receive object param * Disable estimation of gas feature for walletConnect * Add FIXME to walletConnect estimation check Co-authored-by: Daniel Sanchez --- src/components/TransactionsFees/index.tsx | 11 +++++++++++ src/logic/contracts/safeContracts.ts | 6 +++++- src/logic/hooks/useEstimateTransactionGas.tsx | 8 +++++++- src/logic/safe/transactions/gas.ts | 6 +++++- src/logic/wallets/ethTransactions.ts | 10 ++++++++-- 5 files changed, 36 insertions(+), 5 deletions(-) diff --git a/src/components/TransactionsFees/index.tsx b/src/components/TransactionsFees/index.tsx index c5e54f1970..372c8b526f 100644 --- a/src/components/TransactionsFees/index.tsx +++ b/src/components/TransactionsFees/index.tsx @@ -3,6 +3,10 @@ import { EstimationStatus } from 'src/logic/hooks/useEstimateTransactionGas' import Paragraph from 'src/components/layout/Paragraph' import { getNetworkInfo } from 'src/config' import { TransactionFailText } from 'src/components/TransactionFailText' +import { useSelector } from 'react-redux' +import { providerNameSelector } from 'src/logic/wallets/store/selectors' +import { sameString } from 'src/utils/strings' +import { WALLETS } from 'src/config/networks/network.d' type TransactionFailTextProps = { txEstimationExecutionStatus: EstimationStatus @@ -20,6 +24,8 @@ export const TransactionFees = ({ isOffChainSignature, txEstimationExecutionStatus, }: TransactionFailTextProps): React.ReactElement | null => { + const providerName = useSelector(providerNameSelector) + let transactionAction if (isCreation) { transactionAction = 'create' @@ -29,6 +35,11 @@ export const TransactionFees = ({ transactionAction = 'approve' } + // FIXME this should be removed when estimating with WalletConnect correctly + if (!providerName || sameString(providerName, WALLETS.WALLET_CONNECT)) { + return null + } + return ( <> diff --git a/src/logic/contracts/safeContracts.ts b/src/logic/contracts/safeContracts.ts index 2555095838..384fcc8ede 100644 --- a/src/logic/contracts/safeContracts.ts +++ b/src/logic/contracts/safeContracts.ts @@ -130,7 +130,11 @@ export const estimateGasForDeployingSafe = async ( const proxyFactoryData = proxyFactoryMaster.methods .createProxyWithNonce(safeMaster.options.address, gnosisSafeData, safeCreationSalt) .encodeABI() - const gas = await calculateGasOf(proxyFactoryData, userAccount, proxyFactoryMaster.options.address) + const gas = await calculateGasOf({ + data: proxyFactoryData, + from: userAccount, + to: proxyFactoryMaster.options.address, + }) const gasPrice = await calculateGasPrice() return gas * parseInt(gasPrice, 10) diff --git a/src/logic/hooks/useEstimateTransactionGas.tsx b/src/logic/hooks/useEstimateTransactionGas.tsx index ba53f61027..f3c33747ed 100644 --- a/src/logic/hooks/useEstimateTransactionGas.tsx +++ b/src/logic/hooks/useEstimateTransactionGas.tsx @@ -22,6 +22,7 @@ import { Confirmation } from 'src/logic/safe/store/models/types/confirmation' import { checkIfOffChainSignatureIsPossible } from 'src/logic/safe/safeTxSigner' import { ZERO_ADDRESS } from 'src/logic/wallets/ethAddresses' import { sameString } from 'src/utils/strings' +import { WALLETS } from 'src/config/networks/network.d' export enum EstimationStatus { LOADING = 'LOADING', @@ -160,13 +161,17 @@ export const useEstimateTransactionGas = ({ const safeAddress = useSelector(safeParamAddressFromStateSelector) const threshold = useSelector(safeThresholdSelector) const safeVersion = useSelector(safeCurrentVersionSelector) - const { account: from, smartContractWallet } = useSelector(providerSelector) + const { account: from, smartContractWallet, name: providerName } = useSelector(providerSelector) useEffect(() => { const estimateGas = async () => { if (!txData.length) { return } + // FIXME this should be removed when estimating with WalletConnect correctly + if (!providerName || sameString(providerName, WALLETS.WALLET_CONNECT)) { + return null + } const isExecution = checkIfTxIsExecution(Number(threshold), preApprovingOwner, txConfirmations?.size, txType) const isCreation = checkIfTxIsCreation(txConfirmations?.size || 0, txType) @@ -245,6 +250,7 @@ export const useEstimateTransactionGas = ({ smartContractWallet, safeTxGas, txType, + providerName, ]) return gasEstimation diff --git a/src/logic/safe/transactions/gas.ts b/src/logic/safe/transactions/gas.ts index 7e20aedebe..37f1265525 100644 --- a/src/logic/safe/transactions/gas.ts +++ b/src/logic/safe/transactions/gas.ts @@ -272,5 +272,9 @@ export const estimateGasForTransactionApproval = async ({ from, }) const approveTransactionTxData = await safeInstance.methods.approveHash(txHash).encodeABI() - return calculateGasOf(approveTransactionTxData, from, safeAddress) + return calculateGasOf({ + data: approveTransactionTxData, + from, + to: safeAddress, + }) } diff --git a/src/logic/wallets/ethTransactions.ts b/src/logic/wallets/ethTransactions.ts index 3067de09f6..87a702f2e5 100644 --- a/src/logic/wallets/ethTransactions.ts +++ b/src/logic/wallets/ethTransactions.ts @@ -50,10 +50,16 @@ export const calculateGasPrice = async (): Promise => { } } -export const calculateGasOf = async (data: string, from: string, to: string): Promise => { +export const calculateGasOf = async (txConfig: { + to: string + from: string + data: string + gasPrice?: number + gas?: number +}): Promise => { const web3 = getWeb3() try { - const gas = await web3.eth.estimateGas({ data, from, to }) + const gas = await web3.eth.estimateGas(txConfig) return gas * 2 } catch (err) { From 0e1efc6f8f897fc2e4fa3a9d104a5fdb04a31d61 Mon Sep 17 00:00:00 2001 From: Daniel Sanchez Date: Tue, 19 Jan 2021 09:13:57 +0100 Subject: [PATCH 16/18] Set v2.18.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 920d5d5662..5d9cc76325 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "safe-react", - "version": "2.17.0", + "version": "2.18.0", "description": "Allowing crypto users manage funds in a safer way", "website": "https://github.com/gnosis/safe-react#readme", "bugs": { From d6d820ca3b0605eaddbb7822a5fed042b2252f41 Mon Sep 17 00:00:00 2001 From: Daniel Sanchez Date: Tue, 19 Jan 2021 09:40:30 +0100 Subject: [PATCH 17/18] Update packed files for desktop app --- package.json | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index f846bfa3dc..01320285b4 100644 --- a/package.json +++ b/package.json @@ -94,20 +94,13 @@ } ] }, - "files": [ - "**/*", - "!src${/*}", - "!config${/*}", - "!contracts${/*}", - "!migrations${/*}", - "!flow-typed${/*}", - "!apps${/*}", - "!out${/*}", - "!.editorconfig", - "!.gitignore", - "!README.md", - "!yarn-error.log", - "!yarn.lock" + "files": [ + "build", + "patches", + "public", + "scripts", + "dev-app-update.yml", + "package.json" ], "directories": { "buildResources": "public/resources" From e65849691e37fd529ba60c0d1cadc056bfe01f1f Mon Sep 17 00:00:00 2001 From: Daniel Sanchez Date: Tue, 19 Jan 2021 13:17:15 +0100 Subject: [PATCH 18/18] Update client signature --- public/electron.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/electron.js b/public/electron.js index 92626c8175..ac071d2537 100644 --- a/public/electron.js +++ b/public/electron.js @@ -142,7 +142,7 @@ process.on('uncaughtException', function (error) { }) app.userAgentFallback = - 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) old-airport-include/1.0.0 Chrome Electron/9.3.1 Safari/537.36' + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) old-airport-include/1.0.0 Chrome Electron/9.4.1 Safari/537.36' // We have one non-context-aware module in node_modules/usb. This is used by @ledgerhq/hw-transport-node-hid // This type of modules will be impossible to use after electron 10