From 386704cc0f973c79b0e27269ea9c941c2661169c Mon Sep 17 00:00:00 2001 From: Julian Date: Sun, 26 Sep 2021 17:50:38 -0300 Subject: [PATCH 1/3] remove useActions for many proposal screens --- src/components/Garden/Agreement/Agreement.js | 6 ++- .../Garden/DecisionDetail/DecisionDetail.js | 18 +++++++- src/components/Garden/Home.js | 5 +-- .../ClaimRewardsScreens.js | 5 +-- .../ExecuteProposalScreens.js | 5 +-- .../RaiseDisputeScreens.js | 4 +- .../RemoveProposalScreens.js | 5 +-- .../SettleProposalScreens.js | 4 +- .../SignAgreementScreens.js | 7 ++-- .../SupportProposal/SupportProposalScreens.js | 5 +-- .../WrapTokenScreens/WrapTokenScreens.js | 4 +- .../Garden/ProposalDetail/ProposalDetail.js | 41 ++++++++++++++++--- 12 files changed, 69 insertions(+), 40 deletions(-) diff --git a/src/components/Garden/Agreement/Agreement.js b/src/components/Garden/Agreement/Agreement.js index 71a1e5e68..6d8714968 100644 --- a/src/components/Garden/Agreement/Agreement.js +++ b/src/components/Garden/Agreement/Agreement.js @@ -13,12 +13,16 @@ import MultiModal from '@components/MultiModal/MultiModal' import SignAgreementScreens from '../ModalFlows/SignAgreementScreens/SignAgreementScreens' import { useAgreement } from '@hooks/useAgreement' import { useWallet } from '@providers/Wallet' +import useGardenLogic from '@/logic/garden-logic' import warningSvg from './assets/warning.svg' function Agreement() { const [agreement, loading] = useAgreement() const [signModalVisible, setSignModalVisible] = useState(false) + const { + actions, + } = useGardenLogic() const signed = agreement.signedLatest @@ -46,7 +50,7 @@ function Agreement() { /> - + ) diff --git a/src/components/Garden/DecisionDetail/DecisionDetail.js b/src/components/Garden/DecisionDetail/DecisionDetail.js index 5fecd4eef..2b40bdb1b 100644 --- a/src/components/Garden/DecisionDetail/DecisionDetail.js +++ b/src/components/Garden/DecisionDetail/DecisionDetail.js @@ -324,9 +324,23 @@ function DecisionDetail({ proposal, actions }) { /> )} {modalMode === 'settle' && ( - + + )} + {modalMode === 'dispute' && ( + )} - {modalMode === 'dispute' && } ) diff --git a/src/components/Garden/Home.js b/src/components/Garden/Home.js index 7ce54b296..a3311a819 100644 --- a/src/components/Garden/Home.js +++ b/src/components/Garden/Home.js @@ -32,7 +32,6 @@ const Home = React.memo(function Home() { proposals, proposalsFetchedCount, } = useGardenLogic() - const history = useHistory() const { account } = useWallet() @@ -216,9 +215,9 @@ const Home = React.memo(function Home() { )} {(modalMode === 'wrap' || modalMode === 'unwrap') && ( - + )} - {modalMode === 'claim' && } + {modalMode === 'claim' && } )} diff --git a/src/components/Garden/ModalFlows/ClaimRewardsScreens/ClaimRewardsScreens.js b/src/components/Garden/ModalFlows/ClaimRewardsScreens/ClaimRewardsScreens.js index 1f3aa1dc4..91626c1d2 100644 --- a/src/components/Garden/ModalFlows/ClaimRewardsScreens/ClaimRewardsScreens.js +++ b/src/components/Garden/ModalFlows/ClaimRewardsScreens/ClaimRewardsScreens.js @@ -2,11 +2,8 @@ import React, { useCallback, useMemo, useState } from 'react' import ClaimRewards from './ClaimRewards' import ModalFlowBase from '../ModalFlowBase' -import useActions from '@hooks/useActions' - -function ClaimRewardsScreens() { +function ClaimRewardsScreens({ unipoolActions }) { const [transactions, setTransactions] = useState([]) - const { unipoolActions } = useActions() const getTransactions = useCallback( async onComplete => { diff --git a/src/components/Garden/ModalFlows/ExecuteProposalScreens/ExecuteProposalScreens.js b/src/components/Garden/ModalFlows/ExecuteProposalScreens/ExecuteProposalScreens.js index dbf80c24c..62ff01144 100644 --- a/src/components/Garden/ModalFlows/ExecuteProposalScreens/ExecuteProposalScreens.js +++ b/src/components/Garden/ModalFlows/ExecuteProposalScreens/ExecuteProposalScreens.js @@ -2,11 +2,8 @@ import React, { useMemo, useState, useCallback } from 'react' import ModalFlowBase from '../ModalFlowBase' import ExecuteProposal from './ExecuteProposal' -import useActions from '@hooks/useActions' - -function ExecuteProposalScreens({ proposal }) { +function ExecuteProposalScreens({ proposal, convictionActions }) { const [transactions, setTransactions] = useState([]) - const { convictionActions } = useActions() const { id: proposalId } = proposal diff --git a/src/components/Garden/ModalFlows/RaiseDisputeScreens/RaiseDisputeScreens.js b/src/components/Garden/ModalFlows/RaiseDisputeScreens/RaiseDisputeScreens.js index ad6c7baa0..f4eb1f4a2 100644 --- a/src/components/Garden/ModalFlows/RaiseDisputeScreens/RaiseDisputeScreens.js +++ b/src/components/Garden/ModalFlows/RaiseDisputeScreens/RaiseDisputeScreens.js @@ -3,18 +3,16 @@ import PropTypes from 'prop-types' import ModalFlowBase from '../ModalFlowBase' import RaiseDisputeRequirements from './RaiseDisputeRequirements' -import useActions from '@hooks/useActions' import { useCelesteSynced } from '@hooks/useCeleste' import { useDisputeFees } from '@hooks/useDispute' import BigNumber from '@lib/bigNumber' const ZERO_BN = new BigNumber('0') -function RaiseDisputeScreens({ proposal }) { +function RaiseDisputeScreens({ proposal, agreementActions }) { const [transactions, setTransactions] = useState([]) const [celesteSynced, celesteSyncLoading] = useCelesteSynced() const disputeFees = useDisputeFees() - const { agreementActions } = useActions() const temporatyTrx = useRef([]) diff --git a/src/components/Garden/ModalFlows/RemoveProposalScreens/RemoveProposalScreens.js b/src/components/Garden/ModalFlows/RemoveProposalScreens/RemoveProposalScreens.js index 9daf309fc..6d93a52b3 100644 --- a/src/components/Garden/ModalFlows/RemoveProposalScreens/RemoveProposalScreens.js +++ b/src/components/Garden/ModalFlows/RemoveProposalScreens/RemoveProposalScreens.js @@ -2,11 +2,8 @@ import React, { useMemo, useState, useCallback } from 'react' import ModalFlowBase from '../ModalFlowBase' import RemoveProposal from './RemoveProposal' -import useActions from '@hooks/useActions' - -function RemoveProposalScreens({ proposal, mode }) { +function RemoveProposalScreens({ proposal, mode, convictionActions }) { const [transactions, setTransactions] = useState([]) - const { convictionActions } = useActions() const { id: proposalId } = proposal diff --git a/src/components/Garden/ModalFlows/SettleProposalScreens/SettleProposalScreens.js b/src/components/Garden/ModalFlows/SettleProposalScreens/SettleProposalScreens.js index 47d0e7ada..36640d3d9 100644 --- a/src/components/Garden/ModalFlows/SettleProposalScreens/SettleProposalScreens.js +++ b/src/components/Garden/ModalFlows/SettleProposalScreens/SettleProposalScreens.js @@ -2,14 +2,12 @@ import React, { useState, useCallback, useMemo } from 'react' import { addressesEqual } from '@1hive/1hive-ui' import ModalFlowBase from '../ModalFlowBase' import SettlementDetails from './SettlementDetails' -import useActions from '@hooks/useActions' import { useWallet } from '@providers/Wallet' -function SettleProposalScreens({ proposal }) { +function SettleProposalScreens({ proposal, agreementActions }) { const [transactions, setTransactions] = useState([]) const { account } = useWallet() - const { agreementActions } = useActions() const isChallenger = addressesEqual(account, proposal.challenger) diff --git a/src/components/Garden/ModalFlows/SignAgreementScreens/SignAgreementScreens.js b/src/components/Garden/ModalFlows/SignAgreementScreens/SignAgreementScreens.js index 5026eaeb4..138e666fd 100644 --- a/src/components/Garden/ModalFlows/SignAgreementScreens/SignAgreementScreens.js +++ b/src/components/Garden/ModalFlows/SignAgreementScreens/SignAgreementScreens.js @@ -4,12 +4,11 @@ import { useHistory } from 'react-router' import { Button } from '@1hive/1hive-ui' import ModalFlowBase from '../ModalFlowBase' import SignOverview from './SignOverview' -import useActions from '@hooks/useActions' import { buildGardenPath } from '@utils/routing-utils' -function SignAgreementScreens({ versionId }) { - const actions = useActions() +function SignAgreementScreens({ versionId, actions }) { + const { agreementActions } = actions const [transactions, setTransactions] = useState([]) const history = useHistory() @@ -32,7 +31,7 @@ function SignAgreementScreens({ versionId }) { const getTransactions = useCallback( async onComplete => { - await actions.agreementActions.signAgreement({ versionId }, intent => { + await agreementActions.signAgreement({ versionId }, intent => { setTransactions(intent.transactions) onComplete() }) diff --git a/src/components/Garden/ModalFlows/SupportProposal/SupportProposalScreens.js b/src/components/Garden/ModalFlows/SupportProposal/SupportProposalScreens.js index 43b0a58a7..00b6c1c99 100644 --- a/src/components/Garden/ModalFlows/SupportProposal/SupportProposalScreens.js +++ b/src/components/Garden/ModalFlows/SupportProposal/SupportProposalScreens.js @@ -3,11 +3,8 @@ import ModalFlowBase from '../ModalFlowBase' import ChangeSupport from './ChangeSupport' import SupportProposal from './SupportProposal' -import useActions from '@hooks/useActions' - -function SupportProposalScreens({ proposal, mode }) { +function SupportProposalScreens({ proposal, mode, convictionActions }) { const [transactions, setTransactions] = useState([]) - const { convictionActions } = useActions() const { id: proposalId } = proposal diff --git a/src/components/Garden/ModalFlows/WrapTokenScreens/WrapTokenScreens.js b/src/components/Garden/ModalFlows/WrapTokenScreens/WrapTokenScreens.js index d6140f774..8ea95f27c 100644 --- a/src/components/Garden/ModalFlows/WrapTokenScreens/WrapTokenScreens.js +++ b/src/components/Garden/ModalFlows/WrapTokenScreens/WrapTokenScreens.js @@ -3,16 +3,14 @@ import ModalFlowBase from '../ModalFlowBase' import WrapUnwrap from './WrapUnwrap' import { useGardenState } from '@providers/GardenState' -import useActions from '@hooks/useActions' import BigNumber from '@lib/bigNumber' const ZERO_BN = new BigNumber(0) -function WrapTokenScreens({ mode }) { +function WrapTokenScreens({ mode, hookedTokenManagerActions }) { const [transactions, setTransactions] = useState([]) const { token, wrappableToken } = useGardenState() - const { hookedTokenManagerActions } = useActions() const temporatyTrx = useRef([]) diff --git a/src/components/Garden/ProposalDetail/ProposalDetail.js b/src/components/Garden/ProposalDetail/ProposalDetail.js index d2c7291e7..880239f3a 100644 --- a/src/components/Garden/ProposalDetail/ProposalDetail.js +++ b/src/components/Garden/ProposalDetail/ProposalDetail.js @@ -441,17 +441,48 @@ function ProposalDetail({ /> )} {modalMode === 'settle' && ( - + + )} + {modalMode === 'dispute' && ( + )} - {modalMode === 'dispute' && } {(modalMode === 'support' || modalMode === 'update') && ( - + )} {modalMode === 'remove' && ( - + )} {modalMode === 'execute' && ( - + )} From e4993c2c4efe003de6cd387156dd4966d76cab9a Mon Sep 17 00:00:00 2001 From: Harthor Date: Sun, 26 Sep 2021 18:52:48 -0300 Subject: [PATCH 2/3] prettier fixes --- src/components/Garden/Agreement/Agreement.js | 9 +++++---- src/components/Garden/Home.js | 9 +++++++-- src/components/Garden/ProposalDetail/ProposalDetail.js | 6 +++--- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/components/Garden/Agreement/Agreement.js b/src/components/Garden/Agreement/Agreement.js index 6d8714968..0bb9cfadb 100644 --- a/src/components/Garden/Agreement/Agreement.js +++ b/src/components/Garden/Agreement/Agreement.js @@ -20,9 +20,7 @@ import warningSvg from './assets/warning.svg' function Agreement() { const [agreement, loading] = useAgreement() const [signModalVisible, setSignModalVisible] = useState(false) - const { - actions, - } = useGardenLogic() + const { actions } = useGardenLogic() const signed = agreement.signedLatest @@ -50,7 +48,10 @@ function Agreement() { /> - + ) diff --git a/src/components/Garden/Home.js b/src/components/Garden/Home.js index a3311a819..0aa3255f9 100644 --- a/src/components/Garden/Home.js +++ b/src/components/Garden/Home.js @@ -215,9 +215,14 @@ const Home = React.memo(function Home() { )} {(modalMode === 'wrap' || modalMode === 'unwrap') && ( - + + )} + {modalMode === 'claim' && ( + )} - {modalMode === 'claim' && } )} diff --git a/src/components/Garden/ProposalDetail/ProposalDetail.js b/src/components/Garden/ProposalDetail/ProposalDetail.js index 880239f3a..8a0b0691a 100644 --- a/src/components/Garden/ProposalDetail/ProposalDetail.js +++ b/src/components/Garden/ProposalDetail/ProposalDetail.js @@ -464,14 +464,14 @@ function ProposalDetail({ mode={modalMode} convictionActions={{ stakeToProposal: actions.stakeToProposal, - withdrawFromProposal: actions.withdrawFromProposal + withdrawFromProposal: actions.withdrawFromProposal, }} /> )} {modalMode === 'remove' && ( @@ -479,7 +479,7 @@ function ProposalDetail({ {modalMode === 'execute' && ( From c110e0d089c8ccead816064b7c57dbd6fded6f5e Mon Sep 17 00:00:00 2001 From: Harthor Date: Sun, 26 Sep 2021 19:19:35 -0300 Subject: [PATCH 3/3] rremoved unnecesary actions on SignAgreementScreen --- src/components/Garden/Agreement/Agreement.js | 2 +- .../ModalFlows/SignAgreementScreens/SignAgreementScreens.js | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/components/Garden/Agreement/Agreement.js b/src/components/Garden/Agreement/Agreement.js index 0bb9cfadb..f2aa90dec 100644 --- a/src/components/Garden/Agreement/Agreement.js +++ b/src/components/Garden/Agreement/Agreement.js @@ -50,7 +50,7 @@ function Agreement() { diff --git a/src/components/Garden/ModalFlows/SignAgreementScreens/SignAgreementScreens.js b/src/components/Garden/ModalFlows/SignAgreementScreens/SignAgreementScreens.js index 138e666fd..640d85b17 100644 --- a/src/components/Garden/ModalFlows/SignAgreementScreens/SignAgreementScreens.js +++ b/src/components/Garden/ModalFlows/SignAgreementScreens/SignAgreementScreens.js @@ -7,8 +7,7 @@ import SignOverview from './SignOverview' import { buildGardenPath } from '@utils/routing-utils' -function SignAgreementScreens({ versionId, actions }) { - const { agreementActions } = actions +function SignAgreementScreens({ versionId, agreementActions }) { const [transactions, setTransactions] = useState([]) const history = useHistory() @@ -36,7 +35,7 @@ function SignAgreementScreens({ versionId, actions }) { onComplete() }) }, - [actions, versionId] + [agreementActions, versionId] ) const screens = useMemo(