From 655ad1b0de4b43bf7bc701c23a945f82de4b27c5 Mon Sep 17 00:00:00 2001 From: Daniel McCartney Date: Sun, 30 Jul 2023 15:11:17 -0400 Subject: [PATCH] feat: be less scary with the alert about needing a Safe --- web/src/components/SafeSweepCard.js | 246 +++++++++++++++------------- 1 file changed, 128 insertions(+), 118 deletions(-) diff --git a/web/src/components/SafeSweepCard.js b/web/src/components/SafeSweepCard.js index 2543a4b..5c28108 100644 --- a/web/src/components/SafeSweepCard.js +++ b/web/src/components/SafeSweepCard.js @@ -328,14 +328,8 @@ function SafeAlert({ sx, nodeAddress }) { ? nodeAddress : null; if (!safeAddress) { - return ( - - Sweep requires the node or its withdrawal address to be a{" "} - - Safe - - - ); + // No alert when it has no Safe address. + return null; } if (connector?.id === "safe") { // No alert when it is already open as a Safe app. @@ -908,6 +902,9 @@ export default function SafeSweepCard({ sx, nodeAddress }) { overall, } = sweeper; let withdrawalAddress = useNodeWithdrawalAddress(nodeAddress); + let hasSafeWithdrawalAddress = useCouldBeSafeContract(withdrawalAddress); + let hasSafeNodeAddress = useCouldBeSafeContract(nodeAddress); + let hasAnySafeAddress = hasSafeWithdrawalAddress || hasSafeNodeAddress; const isSafeConnected = connector?.id === "safe"; const isNodeOrWithdrawalAddress = address === nodeAddress || address === withdrawalAddress; @@ -938,126 +935,139 @@ export default function SafeSweepCard({ sx, nodeAddress }) { arrow // placement="bottom-start" title={ - - - - {!isClaimingInterval ? null : ( - <> - - - + + + + + {!isClaimingInterval ? null : ( + <> + + - {rewardIndexes?.length} - {" "} - interval{rewardIndexes?.length === 1 ? "" : "s"} - - - - - - - - - - - )} - {!isDistributingTipsMev ? null : ( - <> - - - + {rewardIndexes?.length} + {" "} + interval{rewardIndexes?.length === 1 ? "" : "s"} + + + + + - tips/MEV - - - - - - - - - - )} - {!isDistributingConsensus ? null : ( - <> - - - + + + + + )} + {!isDistributingTipsMev ? null : ( + <> + + + + tips/MEV + + + + + + + + + + )} + {!isDistributingConsensus ? null : ( + <> + + - {currentBatch?.length} - {" "} - minipool{currentBatch?.length === 1 ? "" : "s"} - - - - - - - - - - )} - - - + + {currentBatch?.length} + {" "} + minipool{currentBatch?.length === 1 ? "" : "s"} + + + + + + + + + + )} + + + + {!hasAnySafeAddress && ( + + Sweeping it all in one transaction requires the node or its + withdrawal address to be a{" "} + + Safe + + . Otherwise, you can still "Distribute" or "Claim" each reward + individually. + + )} + } >