From 88d04531682ebbbdf731eb50f500fc84e9cf8799 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Mart=C3=ADnez?= Date: Thu, 21 Nov 2019 13:09:31 +0100 Subject: [PATCH 1/2] Fix generation of signatures from tx confirmations --- .../safe/store/actions/processTransaction.js | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/routes/safe/store/actions/processTransaction.js b/src/routes/safe/store/actions/processTransaction.js index e3425387..7953e531 100644 --- a/src/routes/safe/store/actions/processTransaction.js +++ b/src/routes/safe/store/actions/processTransaction.js @@ -31,18 +31,27 @@ export const generateSignaturesFromTxConfirmations = ( ) => { // The constant parts need to be sorted so that the recovered signers are sorted ascending // (natural order) by address (not checksummed). - let confirmedAdresses = confirmations.map((conf) => conf.owner.address) + const confirmationsMap = confirmations.reduce((map, obj) => { + map[obj.owner.address] = obj // eslint-disable-line no-param-reassign + return map + }, {}) if (preApprovingOwner) { - confirmedAdresses = confirmedAdresses.push(preApprovingOwner) + confirmationsMap[preApprovingOwner] = { owner: preApprovingOwner } } let sigs = '0x' - confirmedAdresses.sort().forEach((addr) => { - sigs += `000000000000000000000000${addr.replace( - '0x', - '', - )}000000000000000000000000000000000000000000000000000000000000000001` + Object.keys(confirmationsMap).sort().forEach((addr) => { + const conf = confirmationsMap[addr] + if (conf.signature) { + sigs += conf.signature.slice(2) + } else { + // https://gnosis-safe.readthedocs.io/en/latest/contracts/signatures.html#pre-validated-signatures + sigs += `000000000000000000000000${addr.replace( + '0x', + '', + )}000000000000000000000000000000000000000000000000000000000000000001` + } }) return sigs } From 0bd9353e603506b974cb87ea89c248f2c1b3a582 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Mart=C3=ADnez?= Date: Fri, 22 Nov 2019 12:24:23 +0100 Subject: [PATCH 2/2] Fix confirmation+execution check --- .../TxsTable/ExpandedTx/ApproveTxModal/index.jsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/routes/safe/components/Transactions/TxsTable/ExpandedTx/ApproveTxModal/index.jsx b/src/routes/safe/components/Transactions/TxsTable/ExpandedTx/ApproveTxModal/index.jsx index a8dadc3f..55414fda 100644 --- a/src/routes/safe/components/Transactions/TxsTable/ExpandedTx/ApproveTxModal/index.jsx +++ b/src/routes/safe/components/Transactions/TxsTable/ExpandedTx/ApproveTxModal/index.jsx @@ -64,10 +64,10 @@ const ApproveTxModal = ({ enqueueSnackbar, closeSnackbar, }: Props) => { - const [approveAndExecute, setApproveAndExecute] = useState(true) + const oneConfirmationLeft = !thresholdReached && tx.confirmations.size + 1 === threshold + const [approveAndExecute, setApproveAndExecute] = useState(oneConfirmationLeft || thresholdReached) const [gasCosts, setGasCosts] = useState('< 0.001') const { title, description } = getModalTitleAndDescription(thresholdReached) - const oneConfirmationLeft = tx.confirmations.size + 1 === threshold useEffect(() => { let isCurrent = true @@ -107,7 +107,7 @@ const ApproveTxModal = ({ TX_NOTIFICATION_TYPES.CONFIRMATION_TX, enqueueSnackbar, closeSnackbar, - approveAndExecute, + approveAndExecute && oneConfirmationLeft, ) onClose() } @@ -131,7 +131,7 @@ const ApproveTxModal = ({
{tx.nonce} - {!thresholdReached && oneConfirmationLeft && ( + {oneConfirmationLeft && ( <> Approving this transaction executes it right away. If you want approve but execute the transaction