From 830a8697c6edf8f3f0bcff1bfd7ec739502035ff Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Sat, 12 Oct 2024 21:59:12 +0300 Subject: [PATCH 01/38] removed ada wallet actions --- .../app/actions/ada/ada-wallets-actions.js | 13 ------------- packages/yoroi-extension/app/actions/ada/index.js | 3 --- .../containers/wallet/CreateWalletPageContainer.js | 2 +- .../wallet/dialogs/WalletCreateDialogContainer.js | 7 +++---- .../app/stores/ada/AdaWalletsStore.js | 14 ++++++-------- 5 files changed, 10 insertions(+), 29 deletions(-) delete mode 100644 packages/yoroi-extension/app/actions/ada/ada-wallets-actions.js diff --git a/packages/yoroi-extension/app/actions/ada/ada-wallets-actions.js b/packages/yoroi-extension/app/actions/ada/ada-wallets-actions.js deleted file mode 100644 index 4fbe1b7445..0000000000 --- a/packages/yoroi-extension/app/actions/ada/ada-wallets-actions.js +++ /dev/null @@ -1,13 +0,0 @@ -// @flow -import { AsyncAction } from '../lib/Action'; - -// ======= WALLET ACTIONS ======= - -export default class AdaWalletsActions { - startWalletCreation: AsyncAction<{| name: string, password: string |}> = new AsyncAction(); - createWallet: AsyncAction<{| - walletName: string, - walletPassword: string, - recoveryPhrase: Array, - |}> = new AsyncAction(); -} diff --git a/packages/yoroi-extension/app/actions/ada/index.js b/packages/yoroi-extension/app/actions/ada/index.js index bea5ee7284..4afba6a388 100644 --- a/packages/yoroi-extension/app/actions/ada/index.js +++ b/packages/yoroi-extension/app/actions/ada/index.js @@ -1,5 +1,4 @@ // @flow -import AdaWalletsActions from './ada-wallets-actions'; import HWConnectActions from './hw-connect-actions'; import TrezorSendActions from './trezor-send-actions'; import LedgerSendActions from './ledger-send-actions'; @@ -8,7 +7,6 @@ import DelegationTransactionActions from './delegation-transaction-actions'; import VotingActions from './voting-actions'; export type AdaActionsMap = {| - wallets: AdaWalletsActions, trezorConnect: HWConnectActions, trezorSend: TrezorSendActions, ledgerConnect: HWConnectActions, @@ -19,7 +17,6 @@ export type AdaActionsMap = {| |}; const adaActionsMap: AdaActionsMap = Object.freeze({ - wallets: new AdaWalletsActions(), trezorConnect: new HWConnectActions(), trezorSend: new TrezorSendActions(), ledgerConnect: new HWConnectActions(), diff --git a/packages/yoroi-extension/app/containers/wallet/CreateWalletPageContainer.js b/packages/yoroi-extension/app/containers/wallet/CreateWalletPageContainer.js index 71c79edb1e..f9f963747e 100644 --- a/packages/yoroi-extension/app/containers/wallet/CreateWalletPageContainer.js +++ b/packages/yoroi-extension/app/containers/wallet/CreateWalletPageContainer.js @@ -22,7 +22,7 @@ export default class CreateWalletPageContainer extends Component stores.substores.ada.wallets.createWallet(request)} setSelectedNetwork={actions.profile.setSelectedNetwork.trigger} selectedNetwork={stores.profile.selectedNetwork} openDialog={dialog => this.props.actions.dialogs.open.trigger({ dialog })} diff --git a/packages/yoroi-extension/app/containers/wallet/dialogs/WalletCreateDialogContainer.js b/packages/yoroi-extension/app/containers/wallet/dialogs/WalletCreateDialogContainer.js index 6c5ffb38fb..8e6caf521e 100644 --- a/packages/yoroi-extension/app/containers/wallet/dialogs/WalletCreateDialogContainer.js +++ b/packages/yoroi-extension/app/containers/wallet/dialogs/WalletCreateDialogContainer.js @@ -5,18 +5,17 @@ import { observer } from 'mobx-react'; import WalletCreateDialog from '../../../components/wallet/WalletCreateDialog'; import type { StoresAndActionsProps } from '../../../types/injectedProps.types'; -type Props = {| - ...StoresAndActionsProps, +type LocalProps = {| +onClose: void => void, |}; @observer -export default class WalletCreateDialogContainer extends Component { +export default class WalletCreateDialogContainer extends Component<{| ...StoresAndActionsProps, ...LocalProps |}> { render(): Node { return ( this.props.stores.substores.ada.wallets.startWalletCreation(request)} onCancel={this.props.onClose} /> ); diff --git a/packages/yoroi-extension/app/stores/ada/AdaWalletsStore.js b/packages/yoroi-extension/app/stores/ada/AdaWalletsStore.js index bcb8e77a37..d179aee30d 100644 --- a/packages/yoroi-extension/app/stores/ada/AdaWalletsStore.js +++ b/packages/yoroi-extension/app/stores/ada/AdaWalletsStore.js @@ -29,10 +29,8 @@ export default class AdaWalletsStore extends Store { setup(): void { super.setup(); - const { ada, walletBackup } = this.actions; + const { walletBackup } = this.actions; walletBackup.finishWalletBackup.listen(this._createInDb); - ada.wallets.startWalletCreation.listen(this._startWalletCreation); - ada.wallets.createWallet.listen(this._createWallet) } // =================== SEND MONEY ==================== // @@ -225,13 +223,13 @@ export default class AdaWalletsStore extends Store { // =================== WALLET RESTORATION ==================== // - _startWalletCreation: ({| + startWalletCreation: ({| name: string, password: string, |}) => Promise = async params => { const recoveryPhrase = await this.generateWalletRecoveryPhraseRequest.execute({}).promise; if (recoveryPhrase == null) { - throw new Error(`${nameof(this._startWalletCreation)} failed to generate recovery phrase`); + throw new Error(`${nameof(this.startWalletCreation)} failed to generate recovery phrase`); } this.actions.walletBackup.initiateWalletBackup.trigger({ recoveryPhrase, @@ -244,7 +242,7 @@ export default class AdaWalletsStore extends Store { const recoveryPhrase = await this.generateWalletRecoveryPhraseRequest.execute({}).promise; if (recoveryPhrase == null) { - throw new Error(`${nameof(this._startWalletCreation)} failed to generate recovery phrase`); + throw new Error(`${nameof(this.startWalletCreation)} failed to generate recovery phrase`); } return recoveryPhrase; @@ -252,14 +250,14 @@ export default class AdaWalletsStore extends Store { /** Create the wallet and go to wallet summary screen */ _createInDb: void => Promise = async () => { - await this._createWallet({ + await this.createWallet({ recoveryPhrase: this.stores.walletBackup.recoveryPhrase, walletPassword: this.stores.walletBackup.password, walletName: this.stores.walletBackup.name, }); }; - _createWallet: {| + createWallet: {| recoveryPhrase: Array, walletPassword: string, walletName: string, From 7e91ca6c8ad70a52ac71017c5cfd23c8db743cd3 Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Sat, 12 Oct 2024 22:50:09 +0300 Subject: [PATCH 02/38] removed ada delegation actions --- packages/yoroi-extension/app/Routes.js | 15 ++-- .../ada/delegation-transaction-actions.js | 17 ----- .../yoroi-extension/app/actions/ada/index.js | 3 - .../transfer/DeregisterDialogContainer.js | 26 +++---- .../wallet/staking/CardanoStakingPage.js | 51 ++++++------- .../wallet/staking/StakingDashboardPage.js | 12 ++-- .../wallet/staking/StakingPageContent.js | 72 ++++++++----------- .../ada/AdaDelegationTransactionStore.js | 18 ++--- 8 files changed, 88 insertions(+), 126 deletions(-) delete mode 100644 packages/yoroi-extension/app/actions/ada/delegation-transaction-actions.js diff --git a/packages/yoroi-extension/app/Routes.js b/packages/yoroi-extension/app/Routes.js index 18b96f082c..006c268597 100644 --- a/packages/yoroi-extension/app/Routes.js +++ b/packages/yoroi-extension/app/Routes.js @@ -557,21 +557,20 @@ export function wrapReceive(receiveProps: StoresAndActionsProps, children: Node) // NEW UI - TODO: to be refactred export function wrapGovernance(governanceProps: StoresAndActionsProps, children: Node): Node { - const currentWalletInfo = createCurrrentWalletInfo(governanceProps.stores); - - const { delegationTransaction } = governanceProps.stores.substores.ada; + const { stores, actions } = governanceProps; + const currentWalletInfo = createCurrrentWalletInfo(stores); + const { delegationTransaction } = stores.substores.ada; const delegationTxResult = delegationTransaction.createDelegationTx.result; const delegationTxError = delegationTransaction.createDelegationTx.error; - return ( stores.delegation.createDrepDelegationTransaction(request)} + signDelegationTransaction={request => stores.substores.ada.delegationTransaction.signTransaction(request)} txDelegationResult={delegationTxResult} txDelegationError={delegationTxError} - tokenInfo={governanceProps.stores.tokenInfoStore.tokenInfo} - triggerBuySellAdaDialog={() => governanceProps.actions.dialogs.open.trigger({ dialog: BuySellDialog })} + tokenInfo={stores.tokenInfoStore.tokenInfo} + triggerBuySellAdaDialog={() => actions.dialogs.open.trigger({ dialog: BuySellDialog })} > {children}; diff --git a/packages/yoroi-extension/app/actions/ada/delegation-transaction-actions.js b/packages/yoroi-extension/app/actions/ada/delegation-transaction-actions.js deleted file mode 100644 index 8b122f4de7..0000000000 --- a/packages/yoroi-extension/app/actions/ada/delegation-transaction-actions.js +++ /dev/null @@ -1,17 +0,0 @@ -// @flow -import { AsyncAction, Action } from '../lib/Action'; -import type { WalletState } from '../../../chrome/extension/background/types'; - -export default class DelegationTransactionActions { - createWithdrawalTxForWallet: AsyncAction<{| - wallet: WalletState, - |}> = new AsyncAction(); - signTransaction: AsyncAction<{| - password?: string, - wallet: WalletState, - dialog?: any, - |}> = new AsyncAction(); - setShouldDeregister: Action = new Action(); - complete: Action = new Action(); - reset: Action<{| justTransaction: boolean |}> = new Action(); -} diff --git a/packages/yoroi-extension/app/actions/ada/index.js b/packages/yoroi-extension/app/actions/ada/index.js index 4afba6a388..f362e5bcfa 100644 --- a/packages/yoroi-extension/app/actions/ada/index.js +++ b/packages/yoroi-extension/app/actions/ada/index.js @@ -3,7 +3,6 @@ import HWConnectActions from './hw-connect-actions'; import TrezorSendActions from './trezor-send-actions'; import LedgerSendActions from './ledger-send-actions'; import HWVerifyAddressActions from './hw-verify-address-actions'; -import DelegationTransactionActions from './delegation-transaction-actions'; import VotingActions from './voting-actions'; export type AdaActionsMap = {| @@ -12,7 +11,6 @@ export type AdaActionsMap = {| ledgerConnect: HWConnectActions, ledgerSend: LedgerSendActions, hwVerifyAddress: HWVerifyAddressActions, - delegationTransaction: DelegationTransactionActions, voting: VotingActions, |}; @@ -22,7 +20,6 @@ const adaActionsMap: AdaActionsMap = Object.freeze({ ledgerConnect: new HWConnectActions(), ledgerSend: new LedgerSendActions(), hwVerifyAddress: new HWVerifyAddressActions(), - delegationTransaction: new DelegationTransactionActions(), voting: new VotingActions, }); diff --git a/packages/yoroi-extension/app/containers/transfer/DeregisterDialogContainer.js b/packages/yoroi-extension/app/containers/transfer/DeregisterDialogContainer.js index 5ef3cfb9d5..61eda18144 100644 --- a/packages/yoroi-extension/app/containers/transfer/DeregisterDialogContainer.js +++ b/packages/yoroi-extension/app/containers/transfer/DeregisterDialogContainer.js @@ -12,12 +12,6 @@ import WarningBox from '../../components/widgets/WarningBox'; import DangerousActionDialog from '../../components/widgets/DangerousActionDialog'; -type Props = {| - ...StoresAndActionsProps, - +onNext: void => void, - +alwaysShowDeregister: boolean, -|}; - const dialogMessages = defineMessages({ title: { id: 'wallet.transfer.deregister.title', @@ -60,17 +54,23 @@ const dialogMessages = defineMessages({ }, }); +type LocalProps = {| + +onNext: void => void, + +alwaysShowDeregister: boolean, +|}; + @observer -export default class DeregisterDialogContainer extends Component { +export default class DeregisterDialogContainer extends Component<{| ...StoresAndActionsProps, ...LocalProps |}> { static contextTypes: {| intl: $npm$ReactIntl$IntlFormat |} = { intl: intlShape.isRequired, }; componentDidMount() { - this.props.actions.ada.delegationTransaction.setShouldDeregister.trigger(false); + const { stores } = this.props; + stores.substores.ada.delegationTransaction.setShouldDeregister(false); if ( this.props.alwaysShowDeregister === false && - this.props.stores.profile.selectedComplexityLevel !== ComplexityLevels.Advanced + stores.profile.selectedComplexityLevel !== ComplexityLevels.Advanced ) { this.props.onNext(); } @@ -85,7 +85,7 @@ export default class DeregisterDialogContainer extends Component { render(): Node { const { intl } = this.context; - + const { actions, stores } = this.props; return ( { secondaryButton={{ label: intl.formatMessage(dialogMessages.keep), onClick: () => { - this.props.actions.ada.delegationTransaction.setShouldDeregister.trigger(false); + stores.substores.ada.delegationTransaction.setShouldDeregister(false); this.props.onNext(); }, primary: true, }} - onCancel={this.props.actions.dialogs.closeActiveDialog.trigger} + onCancel={actions.dialogs.closeActiveDialog.trigger} primaryButton={{ label: intl.formatMessage(dialogMessages.deregisterOption), onClick: () => { - this.props.actions.ada.delegationTransaction.setShouldDeregister.trigger(true); + stores.substores.ada.delegationTransaction.setShouldDeregister(true); this.props.onNext(); }, }} diff --git a/packages/yoroi-extension/app/containers/wallet/staking/CardanoStakingPage.js b/packages/yoroi-extension/app/containers/wallet/staking/CardanoStakingPage.js index 784f76de28..ce3e25a7a6 100644 --- a/packages/yoroi-extension/app/containers/wallet/staking/CardanoStakingPage.js +++ b/packages/yoroi-extension/app/containers/wallet/staking/CardanoStakingPage.js @@ -59,12 +59,13 @@ class CardanoStakingPage extends Component { @observable notificationElementId: string = ''; cancel: void => void = () => { - const selectedWallet = this.props.stores.wallets.selected; - this.props.stores.delegation.setPoolTransitionConfig(selectedWallet, { + const { stores } = this.props; + const selectedWallet = stores.wallets.selected; + stores.delegation.setPoolTransitionConfig(selectedWallet, { shouldUpdatePool: false, show: 'idle', }); - this.props.actions.ada.delegationTransaction.reset.trigger({ justTransaction: true }); + stores.substores.ada.delegationTransaction.reset({ justTransaction: true }); }; UNSAFE_componentWillMount(): * { @@ -78,8 +79,9 @@ class CardanoStakingPage extends Component { } async componentWillUnmount() { - this.props.actions.ada.delegationTransaction.reset.trigger({ justTransaction: false }); - this.props.stores.delegation.poolInfoQuery.reset(); + const { stores } = this.props; + stores.substores.ada.delegationTransaction.reset({ justTransaction: false }); + stores.delegation.poolInfoQuery.reset(); } render(): null | Node { @@ -322,11 +324,12 @@ class CardanoStakingPage extends Component { getDialog: void => void | Node = () => { const { intl } = this.context; - const { delegationTransaction } = this.props.stores.substores.ada; + const { stores } = this.props; + const { delegationTransaction } = stores.substores.ada; const delegationTx = delegationTransaction.createDelegationTx.result; - const uiDialogs = this.props.stores.uiDialogs; + const uiDialogs = stores.uiDialogs; - const selectedWallet = this.props.stores.wallets.selected; + const selectedWallet = stores.wallets.selected; if (selectedWallet == null) { return null; } @@ -338,7 +341,7 @@ class CardanoStakingPage extends Component { ); const approximateReward = tokenEntry => { - const tokenRow = this.props.stores.tokenInfoStore.tokenInfo + const tokenRow = stores.tokenInfoStore.tokenInfo .get(tokenEntry.networkId.toString()) ?.get(tokenEntry.identifier); if (tokenRow == null) @@ -355,15 +358,15 @@ class CardanoStakingPage extends Component { }; const showSignDialog = - this.props.stores.wallets.sendMoneyRequest.isExecuting || - !this.props.stores.wallets.sendMoneyRequest.wasExecuted || - this.props.stores.wallets.sendMoneyRequest.error != null; + stores.wallets.sendMoneyRequest.isExecuting || + !stores.wallets.sendMoneyRequest.wasExecuted || + stores.wallets.sendMoneyRequest.error != null; const selectedPoolInfo = this._getPoolInfo(selectedWallet); - if (this.props.stores.delegation.poolInfoQuery.error != null) { + if (stores.delegation.poolInfoQuery.error != null) { return undefined; } - if (this.props.stores.delegation.poolInfoQuery.isExecuting) { + if (stores.delegation.poolInfoQuery.isExecuting) { return ( { ); } - if (this.props.stores.delegation.poolInfoQuery.error != null) { - return this._errorDialog(this.props.stores.delegation.poolInfoQuery.error); + if (stores.delegation.poolInfoQuery.error != null) { + return this._errorDialog(stores.delegation.poolInfoQuery.error); } if (delegationTransaction.createDelegationTx.isExecuting) { return ( @@ -411,21 +414,21 @@ class CardanoStakingPage extends Component { approximateReward={approximateReward( delegationTx.totalAmountToDelegate.getDefaultEntry() )} - getTokenInfo={genLookupOrFail(this.props.stores.tokenInfoStore.tokenInfo)} - isSubmitting={this.props.stores.wallets.sendMoneyRequest.isExecuting} + getTokenInfo={genLookupOrFail(stores.tokenInfoStore.tokenInfo)} + isSubmitting={stores.wallets.sendMoneyRequest.isExecuting} isHardware={selectedWallet.type !== 'mnemonic'} onCancel={this.cancel} onSubmit={async ({ password }) => { - await this.props.actions.ada.delegationTransaction.signTransaction.trigger({ + await stores.substores.ada.delegationTransaction.signTransaction({ password, wallet: selectedWallet, dialog: DelegationSuccessDialog, }); }} - classicTheme={this.props.stores.profile.isClassicTheme} - error={this.props.stores.wallets.sendMoneyRequest.error} + classicTheme={stores.profile.isClassicTheme} + error={stores.wallets.sendMoneyRequest.error} selectedExplorer={ - this.props.stores.explorers.selectedExplorer.get( + stores.explorers.selectedExplorer.get( selectedWallet.networkId ) ?? (() => { @@ -438,8 +441,8 @@ class CardanoStakingPage extends Component { if (uiDialogs.isOpen(DelegationSuccessDialog)) { return ( stores.substores.ada.delegationTransaction.complete()} + classicTheme={stores.profile.isClassicTheme} /> ); } diff --git a/packages/yoroi-extension/app/containers/wallet/staking/StakingDashboardPage.js b/packages/yoroi-extension/app/containers/wallet/staking/StakingDashboardPage.js index 36c596f408..8e76513317 100644 --- a/packages/yoroi-extension/app/containers/wallet/staking/StakingDashboardPage.js +++ b/packages/yoroi-extension/app/containers/wallet/staking/StakingDashboardPage.js @@ -21,7 +21,7 @@ import WithdrawalTxDialogContainer from '../../transfer/WithdrawalTxDialogContai import { genLookupOrFail, getTokenName } from '../../../stores/stateless/tokenHelpers'; import { truncateToken } from '../../../utils/formatters'; import { generateGraphData } from '../../../utils/graph'; -import { maybe } from '../../../coreUtils'; +import { maybe, noop } from '../../../coreUtils'; import type { WalletState } from '../../../../chrome/extension/background/types'; @observer @@ -33,7 +33,7 @@ export default class StakingDashboardPage extends Component { // note: purposely don't await since the next dialog will properly render the spinner - this.props.actions.ada.delegationTransaction.createWithdrawalTxForWallet.trigger({ - wallet, - }); + noop(stores.substores.ada.delegationTransaction.createWithdrawalTxForWallet({ wallet })); this.props.actions.dialogs.open.trigger({ dialog: WithdrawalTxDialogContainer }); }} /> @@ -253,9 +251,7 @@ export default class StakingDashboardPage extends Component { - this.props.actions.ada.delegationTransaction.reset.trigger({ - justTransaction: false, - }); + stores.substores.ada.delegationTransaction.reset({ justTransaction: false }); this.props.actions.dialogs.closeActiveDialog.trigger(); }} /> diff --git a/packages/yoroi-extension/app/containers/wallet/staking/StakingPageContent.js b/packages/yoroi-extension/app/containers/wallet/staking/StakingPageContent.js index 3d01c04fe5..ace90d2dce 100644 --- a/packages/yoroi-extension/app/containers/wallet/staking/StakingPageContent.js +++ b/packages/yoroi-extension/app/containers/wallet/staking/StakingPageContent.js @@ -3,10 +3,13 @@ import { observer } from 'mobx-react'; import moment from 'moment'; import type { ComponentType, Node } from 'react'; import { Component } from 'react'; +import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; import { intlShape } from 'react-intl'; import type { ConfigType } from '../../../../config/config-types'; +import type { LayoutComponentMap } from '../../../styles/context/layout'; import { withLayout } from '../../../styles/context/layout'; import type { TokenEntry } from '../../../api/common/lib/MultiToken'; +import { MultiToken } from '../../../api/common/lib/MultiToken'; import { Box, styled } from '@mui/system'; import BuySellDialog from '../../../components/buySell/BuySellDialog'; import DelegatedStakePoolCard from '../../../components/wallet/staking/dashboard-revamp/DelegatedStakePoolCard'; @@ -27,10 +30,7 @@ import WalletEmptyBanner from '../WalletEmptyBanner'; import { GovernanceParticipateDialog } from '../dialogs/GovernanceParticipateDialog'; import CardanoStakingPage from './CardanoStakingPage'; import WithdrawRewardsDialog from './WithdrawRewardsDialog'; -import type { LayoutComponentMap } from '../../../styles/context/layout'; import type { StoresAndActionsProps } from '../../../types/injectedProps.types'; -import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; -import { MultiToken } from '../../../api/common/lib/MultiToken'; // populated by ConfigWebpackPlugin declare var CONFIG: ConfigType; @@ -75,15 +75,11 @@ class StakingPageContent extends Component { }; createWithdrawalTx: (shouldDeregister: boolean) => void = shouldDeregister => { - const publicDeriver = this.props.stores.wallets.selected; - if (publicDeriver == null) { - throw new Error(`${nameof(StakingPageContent)} no public deriver. Should never happen`); - } - - this.props.actions.ada.delegationTransaction.setShouldDeregister.trigger(shouldDeregister); - const { delegationTransaction } = this.props.actions.ada; - delegationTransaction.createWithdrawalTxForWallet.trigger({ wallet: publicDeriver }); - this.props.actions.dialogs.open.trigger({ + const { actions, stores } = this.props; + const wallet = stores.wallets.selectedOrFail; + stores.substores.ada.delegationTransaction.setShouldDeregister(shouldDeregister); + noop(stores.substores.ada.delegationTransaction.createWithdrawalTxForWallet({ wallet })); + actions.dialogs.open.trigger({ dialog: WithdrawRewardsDialog, }); }; @@ -186,30 +182,30 @@ class StakingPageContent extends Component { }; render(): Node { - const publicDeriver = this.props.stores.wallets.selected; - if (publicDeriver == null) { + const wallet = this.props.stores.wallets.selected; + if (wallet == null) { throw new Error(`${nameof(StakingPageContent)} no public deriver. Should never happen`); } const { actions, stores } = this.props; const { uiDialogs, delegation: delegationStore } = stores; - const delegationRequests = delegationStore.getDelegationRequests(publicDeriver.publicDeriverId); + const delegationRequests = delegationStore.getDelegationRequests(wallet.publicDeriverId); if (delegationRequests == null) { throw new Error(`${nameof(StakingPageContent)} opened for non-reward wallet`); } - const balance = publicDeriver.balance; + const balance = wallet.balance; const isWalletWithNoFunds = balance != null && balance.getDefaultEntry().amount.isZero(); const errorIfPresent = maybe(delegationRequests.error, error => ({ error })); const showRewardAmount = errorIfPresent == null && - stores.delegation.isExecutedDelegatedBalance(publicDeriver.publicDeriverId); + stores.delegation.isExecutedDelegatedBalance(wallet.publicDeriverId); - const isStakeRegistered = stores.delegation.isStakeRegistered(publicDeriver.publicDeriverId); - const currentlyDelegating = stores.delegation.isCurrentlyDelegating(publicDeriver.publicDeriverId); - const delegatedUtxo = stores.delegation.getDelegatedUtxoBalance(publicDeriver.publicDeriverId); - const delegatedRewards = stores.delegation.getRewardBalanceOrZero(publicDeriver); + const isStakeRegistered = stores.delegation.isStakeRegistered(wallet.publicDeriverId); + const currentlyDelegating = stores.delegation.isCurrentlyDelegating(wallet.publicDeriverId); + const delegatedUtxo = stores.delegation.getDelegatedUtxoBalance(wallet.publicDeriverId); + const delegatedRewards = stores.delegation.getRewardBalanceOrZero(wallet); const isParticipatingToGovernance = stores.delegation.governanceStatus?.drepDelegation !== null; return ( @@ -245,16 +241,16 @@ class StakingPageContent extends Component { if (!showRewardAmount) return undefined; return currentlyDelegating ? maybe(delegatedUtxo, w => delegatedRewards.joinAddCopy(w)) - : new MultiToken([], publicDeriver.balance.getDefaults()); + : new MultiToken([], wallet.balance.getDefaults()); })()} graphData={generateGraphData({ delegationRequests, - currentEpoch: stores.substores.ada.time.getCurrentTimeRequests(publicDeriver).currentEpoch, + currentEpoch: stores.substores.ada.time.getCurrentTimeRequests(wallet).currentEpoch, shouldHideBalance: stores.profile.shouldHideBalance, getLocalPoolInfo: stores.delegation.getLocalPoolInfo, tokenInfo: stores.tokenInfoStore.tokenInfo, - networkId: publicDeriver.networkId, - defaultTokenId: publicDeriver.defaultTokenId, + networkId: wallet.networkId, + defaultTokenId: wallet.defaultTokenId, })} onOpenRewardList={() => actions.dialogs.open.trigger({ @@ -263,8 +259,8 @@ class StakingPageContent extends Component { } /> - {!errorIfPresent && this.getStakePoolMeta(publicDeriver)} - {!errorIfPresent && this.getEpochProgress(publicDeriver)} + {!errorIfPresent && this.getStakePoolMeta(wallet)} + {!errorIfPresent && this.getEpochProgress(wallet)} ) : null} @@ -273,7 +269,7 @@ class StakingPageContent extends Component { stores={this.props.stores} actions={this.props.actions} urlTemplate={CONFIG.poolExplorer.simpleTemplate} - poolTransition={delegationStore.getPoolTransitionInfo(publicDeriver)} + poolTransition={delegationStore.getPoolTransitionInfo(wallet)} /> {uiDialogs.isOpen(OverviewModal) ? ( @@ -306,10 +302,8 @@ class StakingPageContent extends Component { stores={stores} alwaysShowDeregister onNext={() => { - // note: purposely don't await - // since the next dialog will properly render the spinner - const { delegationTransaction } = this.props.actions.ada; - delegationTransaction.createWithdrawalTxForWallet.trigger({ wallet: publicDeriver }); + // note: purposely don't await since the next dialog will properly render the spinner + noop(stores.substores.ada.delegationTransaction.createWithdrawalTxForWallet({ wallet })); this.props.actions.dialogs.open.trigger({ // dialog: WithdrawalTxDialogContainer, dialog: WithdrawRewardsDialog, @@ -328,9 +322,7 @@ class StakingPageContent extends Component { actions={actions} stores={stores} onClose={() => { - this.props.actions.ada.delegationTransaction.reset.trigger({ - justTransaction: false, - }); + stores.substores.ada.delegationTransaction.reset({ justTransaction: false }); this.props.actions.dialogs.closeActiveDialog.trigger(); }} /> @@ -340,9 +332,7 @@ class StakingPageContent extends Component { actions={actions} stores={stores} onClose={() => { - this.props.actions.ada.delegationTransaction.reset.trigger({ - justTransaction: false, - }); + stores.substores.ada.delegationTransaction.reset({ justTransaction: false }); this.props.actions.dialogs.closeActiveDialog.trigger(); }} /> @@ -352,12 +342,12 @@ class StakingPageContent extends Component { onClose={this.onClose} graphData={generateGraphData({ delegationRequests, - currentEpoch: stores.substores.ada.time.getCurrentTimeRequests(publicDeriver).currentEpoch, + currentEpoch: stores.substores.ada.time.getCurrentTimeRequests(wallet).currentEpoch, shouldHideBalance: stores.profile.shouldHideBalance, getLocalPoolInfo: stores.delegation.getLocalPoolInfo, tokenInfo: stores.tokenInfoStore.tokenInfo, - networkId: publicDeriver.networkId, - defaultTokenId: publicDeriver.defaultTokenId, + networkId: wallet.networkId, + defaultTokenId: wallet.defaultTokenId, })} /> ) : null} diff --git a/packages/yoroi-extension/app/stores/ada/AdaDelegationTransactionStore.js b/packages/yoroi-extension/app/stores/ada/AdaDelegationTransactionStore.js index f29a173354..e321b85cdd 100644 --- a/packages/yoroi-extension/app/stores/ada/AdaDelegationTransactionStore.js +++ b/packages/yoroi-extension/app/stores/ada/AdaDelegationTransactionStore.js @@ -49,16 +49,10 @@ export default class AdaDelegationTransactionStore extends Store void = shouldDeregister => { + setShouldDeregister: boolean => void = shouldDeregister => { this.shouldDeregister = shouldDeregister; }; @@ -97,7 +91,7 @@ export default class AdaDelegationTransactionStore extends Store Promise = async request => { this.createWithdrawalTx.reset(); @@ -133,14 +127,14 @@ export default class AdaDelegationTransactionStore extends Store Promise = async request => { const result = this.createDelegationTx.result; if (result == null) { - throw new Error(`${nameof(this._signTransaction)} no tx to broadcast`); + throw new Error(`${nameof(this.signTransaction)} no tx to broadcast`); } const refreshWallet = () => { this.stores.delegation.disablePoolTransitionState(request.wallet); @@ -173,7 +167,7 @@ export default class AdaDelegationTransactionStore extends Store void = () => { + complete: void => void = () => { this.actions.dialogs.closeActiveDialog.trigger(); this.goToDashboardRoute(); }; From 84cf6efff8958a185086b25b036c7aaa87207cae Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Sat, 12 Oct 2024 23:25:23 +0300 Subject: [PATCH 03/38] removed ada verify address actions --- .../actions/ada/hw-verify-address-actions.js | 13 --------- .../yoroi-extension/app/actions/ada/index.js | 3 -- .../containers/wallet/WalletReceivePage.js | 28 +++++++++---------- .../app/stores/ada/HWVerifyAddressStore.js | 20 ++++++------- 4 files changed, 22 insertions(+), 42 deletions(-) delete mode 100644 packages/yoroi-extension/app/actions/ada/hw-verify-address-actions.js diff --git a/packages/yoroi-extension/app/actions/ada/hw-verify-address-actions.js b/packages/yoroi-extension/app/actions/ada/hw-verify-address-actions.js deleted file mode 100644 index f3fd2e661c..0000000000 --- a/packages/yoroi-extension/app/actions/ada/hw-verify-address-actions.js +++ /dev/null @@ -1,13 +0,0 @@ -// @flow -import { AsyncAction, Action } from '../lib/Action'; - -import type { WalletState } from '../../../chrome/extension/background/types'; -import type { StandardAddress } from '../../types/AddressFilterTypes'; - -// ======= ADDRESSES ACTIONS ======= - -export default class HWVerifyAddressActions { - closeAddressDetailDialog: Action = new Action(); - selectAddress: AsyncAction<$ReadOnly> = new AsyncAction(); - verifyAddress: AsyncAction = new AsyncAction(); -} diff --git a/packages/yoroi-extension/app/actions/ada/index.js b/packages/yoroi-extension/app/actions/ada/index.js index f362e5bcfa..13fd09efaa 100644 --- a/packages/yoroi-extension/app/actions/ada/index.js +++ b/packages/yoroi-extension/app/actions/ada/index.js @@ -2,7 +2,6 @@ import HWConnectActions from './hw-connect-actions'; import TrezorSendActions from './trezor-send-actions'; import LedgerSendActions from './ledger-send-actions'; -import HWVerifyAddressActions from './hw-verify-address-actions'; import VotingActions from './voting-actions'; export type AdaActionsMap = {| @@ -10,7 +9,6 @@ export type AdaActionsMap = {| trezorSend: TrezorSendActions, ledgerConnect: HWConnectActions, ledgerSend: LedgerSendActions, - hwVerifyAddress: HWVerifyAddressActions, voting: VotingActions, |}; @@ -19,7 +17,6 @@ const adaActionsMap: AdaActionsMap = Object.freeze({ trezorSend: new TrezorSendActions(), ledgerConnect: new HWConnectActions(), ledgerSend: new LedgerSendActions(), - hwVerifyAddress: new HWVerifyAddressActions(), voting: new VotingActions, }); diff --git a/packages/yoroi-extension/app/containers/wallet/WalletReceivePage.js b/packages/yoroi-extension/app/containers/wallet/WalletReceivePage.js index a29795a278..ec9a9fface 100644 --- a/packages/yoroi-extension/app/containers/wallet/WalletReceivePage.js +++ b/packages/yoroi-extension/app/containers/wallet/WalletReceivePage.js @@ -136,7 +136,7 @@ class WalletReceivePage extends Component { const notification = uiNotifications.getTooltipActiveNotification(this.notificationElementId); const selectedExplorerForNetwork = - this.props.stores.explorers.selectedExplorer.get( + stores.explorers.selectedExplorer.get( publicDeriver.networkId ) ?? (() => { @@ -147,7 +147,7 @@ class WalletReceivePage extends Component { defaultNetworkId: publicDeriver.networkId, defaultIdentifier: publicDeriver.defaultTokenId, }; - const defaultTokenInfo = genLookupOrFail(this.props.stores.tokenInfoStore.tokenInfo)({ + const defaultTokenInfo = genLookupOrFail(stores.tokenInfoStore.tokenInfo)({ identifier: defaultToken.defaultIdentifier, networkId: defaultToken.defaultNetworkId, }); @@ -164,9 +164,9 @@ class WalletReceivePage extends Component { onGenerateAddress={this.handleGenerateAddress} onCopyAddressTooltip={onCopyAddressTooltip} notification={notification} - isSubmitting={this.props.stores.addresses.createAddressRequest.isExecuting} - error={this.props.stores.addresses.error} - isFilterActive={this.props.stores.addresses.addressFilter !== AddressFilter.None} + isSubmitting={stores.addresses.createAddressRequest.isExecuting} + error={stores.addresses.error} + isFilterActive={stores.addresses.addressFilter !== AddressFilter.None} /> ); } @@ -205,9 +205,9 @@ class WalletReceivePage extends Component { onGenerateAddress={this.handleGenerateAddress} onCopyAddressTooltip={onCopyAddressTooltip} notification={notification} - isSubmitting={this.props.stores.addresses.createAddressRequest.isExecuting} - error={this.props.stores.addresses.error} - isFilterActive={this.props.stores.addresses.addressFilter !== AddressFilter.None} + isSubmitting={stores.addresses.createAddressRequest.isExecuting} + error={stores.addresses.error} + isFilterActive={stores.addresses.addressFilter !== AddressFilter.None} /> ); } @@ -235,13 +235,13 @@ class WalletReceivePage extends Component { { onCopyAddressTooltip={onCopyAddressTooltip} notification={notification} onVerifyAddress={async (request: $ReadOnly) => { - await actions.ada.hwVerifyAddress.selectAddress.trigger(request); + await stores.substores.ada.hwVerifyAddress.selectAddress(request); this.openVerifyAddressDialog(); }} onGeneratePaymentURI={ @@ -353,8 +353,8 @@ class WalletReceivePage extends Component { }} notification={uiNotifications.getTooltipActiveNotification(this.notificationElementId)} isHardware={isHwWallet} - verify={() => actions.ada.hwVerifyAddress.verifyAddress.trigger(publicDeriver)} - cancel={actions.ada.hwVerifyAddress.closeAddressDetailDialog.trigger} + verify={() => stores.substores.ada.hwVerifyAddress.verifyAddress(publicDeriver)} + cancel={stores.substores.ada.hwVerifyAddress.closeAddressDetailDialog} classicTheme={profile.isClassicTheme} complexityLevel={profile.selectedComplexityLevel} /> diff --git a/packages/yoroi-extension/app/stores/ada/HWVerifyAddressStore.js b/packages/yoroi-extension/app/stores/ada/HWVerifyAddressStore.js index de87ec2cde..d5f03a9a46 100644 --- a/packages/yoroi-extension/app/stores/ada/HWVerifyAddressStore.js +++ b/packages/yoroi-extension/app/stores/ada/HWVerifyAddressStore.js @@ -43,24 +43,20 @@ export default class HWVerifyAddressStore extends Store { setup(): void { super.setup(); - const actions = this.actions.ada.hwVerifyAddress; - actions.selectAddress.listen(this._selectAddress); - actions.verifyAddress.listen(this._verifyAddress); - actions.closeAddressDetailDialog.listen(this._closeAddressDetailDialog); } - @action _verifyAddress: (WalletState) => Promise = async ( + @action verifyAddress: (WalletState) => Promise = async ( wallet, ) => { - Logger.info(`${nameof(HWVerifyAddressStore)}::${nameof(this._verifyAddress)} called`); + Logger.info(`${nameof(HWVerifyAddressStore)}::${nameof(this.verifyAddress)} called`); if (!this.selectedAddress) { - throw new Error(`${nameof(HWVerifyAddressStore)}::${nameof(this._verifyAddress)} called with no address selected`); + throw new Error(`${nameof(HWVerifyAddressStore)}::${nameof(this.verifyAddress)} called with no address selected`); } // remove null/undefined type to satisfy Flow const selectedAddress = this.selectedAddress; if (!selectedAddress.addressing) { - throw new Error(`${nameof(HWVerifyAddressStore)}::${nameof(this._verifyAddress)} called with no addressing information`); + throw new Error(`${nameof(HWVerifyAddressStore)}::${nameof(this.verifyAddress)} called with no addressing information`); } // need to unwrap observable otherwise bridge will fail @@ -75,7 +71,7 @@ export default class HWVerifyAddressStore extends Store { } else if (wallet.type === 'trezor') { await this.trezorVerifyAddress(path, address, getNetworkById(wallet.networkId)); } else { - throw new Error(`${nameof(HWVerifyAddressStore)}::${nameof(this._verifyAddress)} called with unrecognized hardware wallet`); + throw new Error(`${nameof(HWVerifyAddressStore)}::${nameof(this.verifyAddress)} called with unrecognized hardware wallet`); } this._setActionProcessing(false); @@ -159,8 +155,8 @@ export default class HWVerifyAddressStore extends Store { } } - @action _selectAddress: $ReadOnly => Promise = async (params) => { - Logger.info(`${nameof(HWVerifyAddressStore)}::${nameof(this._selectAddress)} called: ` + params.address); + @action selectAddress: $ReadOnly => Promise = async (params) => { + Logger.info(`${nameof(HWVerifyAddressStore)}::${nameof(this.selectAddress)} called: ` + params.address); this.selectedAddress = params; } @@ -172,7 +168,7 @@ export default class HWVerifyAddressStore extends Store { this.error = error; } - @action _closeAddressDetailDialog: void => void = () => { + @action closeAddressDetailDialog: void => void = () => { if (this.ledgerConnect != null) { this.ledgerConnect.dispose(); } From 96c6e2436bcc2c6fadc4ae2a3626373c0c66056a Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Sat, 12 Oct 2024 23:55:01 +0300 Subject: [PATCH 04/38] removed ada voting actions --- .../yoroi-extension/app/actions/ada/index.js | 3 - .../app/actions/ada/voting-actions.js | 23 ------- .../dialogs/voting/RegisterDialogContainer.js | 6 +- .../voting/TransactionDialogContainer.js | 17 ++--- .../VotingRegistrationDialogContainer.js | 33 ++++----- .../app/stores/ada/VotingStore.js | 69 ++++++++----------- 6 files changed, 53 insertions(+), 98 deletions(-) delete mode 100644 packages/yoroi-extension/app/actions/ada/voting-actions.js diff --git a/packages/yoroi-extension/app/actions/ada/index.js b/packages/yoroi-extension/app/actions/ada/index.js index 13fd09efaa..0c5d1fda21 100644 --- a/packages/yoroi-extension/app/actions/ada/index.js +++ b/packages/yoroi-extension/app/actions/ada/index.js @@ -2,14 +2,12 @@ import HWConnectActions from './hw-connect-actions'; import TrezorSendActions from './trezor-send-actions'; import LedgerSendActions from './ledger-send-actions'; -import VotingActions from './voting-actions'; export type AdaActionsMap = {| trezorConnect: HWConnectActions, trezorSend: TrezorSendActions, ledgerConnect: HWConnectActions, ledgerSend: LedgerSendActions, - voting: VotingActions, |}; const adaActionsMap: AdaActionsMap = Object.freeze({ @@ -17,7 +15,6 @@ const adaActionsMap: AdaActionsMap = Object.freeze({ trezorSend: new TrezorSendActions(), ledgerConnect: new HWConnectActions(), ledgerSend: new LedgerSendActions(), - voting: new VotingActions, }); export default adaActionsMap; diff --git a/packages/yoroi-extension/app/actions/ada/voting-actions.js b/packages/yoroi-extension/app/actions/ada/voting-actions.js deleted file mode 100644 index 2bd6d217eb..0000000000 --- a/packages/yoroi-extension/app/actions/ada/voting-actions.js +++ /dev/null @@ -1,23 +0,0 @@ -// @flow -import { AsyncAction, Action } from '../lib/Action'; -import type { WalletState } from '../../../chrome/extension/background/types'; - -export default class VotingActions { - generateCatalystKey: AsyncAction = new AsyncAction(); - createTransaction: AsyncAction = new AsyncAction(); - signTransaction: AsyncAction<{| - password?: string, - wallet: WalletState, - |}> = new AsyncAction(); - cancel: Action = new Action(); - submitGenerate: Action = new Action(); - goBackToGenerate: Action = new Action(); - submitConfirm: AsyncAction = new AsyncAction(); - submitConfirmError: Action = new Action(); - submitRegister: Action = new Action(); - submitRegisterError: Action = new Action(); - goBackToRegister: Action = new Action(); - finishQRCode: Action = new Action(); - submitTransaction: Action = new Action(); - submitTransactionError: Action = new Action(); -} diff --git a/packages/yoroi-extension/app/containers/wallet/dialogs/voting/RegisterDialogContainer.js b/packages/yoroi-extension/app/containers/wallet/dialogs/voting/RegisterDialogContainer.js index d01e6b6e79..ebd46b2371 100644 --- a/packages/yoroi-extension/app/containers/wallet/dialogs/voting/RegisterDialogContainer.js +++ b/packages/yoroi-extension/app/containers/wallet/dialogs/voting/RegisterDialogContainer.js @@ -37,7 +37,7 @@ class RegisterDialogContainer extends Component { }; render(): Node { - const { submit, cancel, onError, classicTheme, stepsList } = this.props; + const { submit, cancel, onError, classicTheme, stepsList, stores } = this.props; const votingStore = this.props.stores.substores.ada.votingStore; if (votingStore.createVotingRegTx.error != null) { @@ -52,9 +52,7 @@ class RegisterDialogContainer extends Component { progressInfo={votingStore.progressInfo} submit={async (walletPassword: string) => { try { - await this.props.actions.ada.voting.createTransaction.trigger( - walletPassword - ); + await stores.substores.ada.votingStore.createTransaction(walletPassword); await submit(); } catch (error) { onError(error); diff --git a/packages/yoroi-extension/app/containers/wallet/dialogs/voting/TransactionDialogContainer.js b/packages/yoroi-extension/app/containers/wallet/dialogs/voting/TransactionDialogContainer.js index fbaa562024..55fffc064b 100644 --- a/packages/yoroi-extension/app/containers/wallet/dialogs/voting/TransactionDialogContainer.js +++ b/packages/yoroi-extension/app/containers/wallet/dialogs/voting/TransactionDialogContainer.js @@ -33,13 +33,13 @@ class TransactionDialogContainer extends Component { }; render(): Node { - const { stepsList, submit, cancel, goBack, onError, walletType } = this.props; - const selectedWallet = this.props.stores.wallets.selected; - if (selectedWallet == null) { + const { stepsList, submit, cancel, goBack, onError, walletType, stores } = this.props; + const wallet = stores.wallets.selected; + if (wallet == null) { return null; } - const { votingStore } = this.props.stores.substores.ada; + const { votingStore } = stores.substores.ada; const votingRegTx = votingStore.createVotingRegTx.result; if (votingRegTx != null) { @@ -49,16 +49,13 @@ class TransactionDialogContainer extends Component { progressInfo={votingStore.progressInfo} staleTx={votingStore.isStale} transactionFee={votingRegTx.fee()} - isSubmitting={this.props.stores.wallets.sendMoneyRequest.isExecuting} - getTokenInfo={genLookupOrFail(this.props.stores.tokenInfoStore.tokenInfo)} + isSubmitting={stores.wallets.sendMoneyRequest.isExecuting} + getTokenInfo={genLookupOrFail(stores.tokenInfoStore.tokenInfo)} onCancel={cancel} goBack={goBack} onSubmit={async ({ password }) => { try { - await this.props.actions.ada.voting.signTransaction.trigger({ - password, - wallet: selectedWallet, - }); + await stores.substores.ada.votingStore.signTransaction({ wallet, password }); await submit(); } catch (error) { onError(error); diff --git a/packages/yoroi-extension/app/containers/wallet/dialogs/voting/VotingRegistrationDialogContainer.js b/packages/yoroi-extension/app/containers/wallet/dialogs/voting/VotingRegistrationDialogContainer.js index 14cfeca4ab..f34fc04a07 100644 --- a/packages/yoroi-extension/app/containers/wallet/dialogs/voting/VotingRegistrationDialogContainer.js +++ b/packages/yoroi-extension/app/containers/wallet/dialogs/voting/VotingRegistrationDialogContainer.js @@ -15,6 +15,7 @@ import TransactionDialogContainer from './TransactionDialogContainer'; import RegisterDialogContainer from './RegisterDialogContainer'; import globalMessages from '../../../../i18n/global-messages'; import CreateTxExecutingDialog from '../../../../components/wallet/voting/CreateTxExecutingDialog'; +import { noop } from '../../../../coreUtils'; type Props = {| ...StoresAndActionsProps, @@ -31,25 +32,25 @@ type AllProps = {| ...Props, ...InjectedLayoutProps |}; class VotingRegistrationDialogContainer extends Component { cancel: () => void = () => { this.props.onClose(); - this.props.actions.ada.voting.cancel.trigger(); + this.props.stores.substores.ada.votingStore.cancel(); }; componentDidMount() { - this.props.actions.ada.voting.generateCatalystKey.trigger(); + // there should be a better way to trigger key generation then a component mount + noop(this.props.stores.substores.ada.votingStore.generateCatalystKey()); } async componentWillUnmount() { - this.props.actions.ada.voting.cancel.trigger(); + this.props.stores.substores.ada.votingStore.cancel(); } render(): null | Node { const { actions, stores } = this.props; - const votingStore = this.props.stores.substores.ada.votingStore; + const votingStore = stores.substores.ada.votingStore; if (votingStore.createVotingRegTx.isExecuting) { return ; } const { profile } = this.props.stores; - const votingActions = this.props.actions.ada.voting; const walletType = this.props.walletType; const stepsList = [ { step: ProgressStep.GENERATE, message: globalMessages.stepPin }, @@ -70,7 +71,7 @@ class VotingRegistrationDialogContainer extends Component { stepsList={stepsList} progressInfo={votingStore.progressInfo} pin={votingStore.pin} - next={votingActions.submitGenerate.trigger} + next={votingStore.submitGenerate} cancel={this.cancel} classicTheme={profile.isClassicTheme} onBack={this.props.onClose} @@ -84,9 +85,9 @@ class VotingRegistrationDialogContainer extends Component { isRevamp={this.props.isRevampLayout} stepsList={stepsList} progressInfo={votingStore.progressInfo} - goBack={votingActions.goBackToGenerate.trigger} - submit={votingActions.submitConfirm.trigger} - error={votingActions.submitConfirmError.trigger} + goBack={votingStore.goBackToGenerate} + submit={votingStore.submitConfirm} + error={votingStore.submitConfirmError} cancel={this.cancel} classicTheme={profile.isClassicTheme} pinValidation={enteredPin => { @@ -103,11 +104,11 @@ class VotingRegistrationDialogContainer extends Component { actions={actions} stores={stores} stepsList={stepsList} - submit={votingActions.submitRegister.trigger} - goBack={votingActions.goBackToRegister.trigger} + submit={votingStore.submitRegister} + goBack={votingStore.goBackToRegister} cancel={this.cancel} classicTheme={profile.isClassicTheme} - onError={votingActions.submitRegisterError.trigger} + onError={votingStore.submitRegisterError} /> ); break; @@ -119,9 +120,9 @@ class VotingRegistrationDialogContainer extends Component { stepsList={stepsList} classicTheme={profile.isClassicTheme} cancel={this.cancel} - submit={votingActions.submitTransaction.trigger} - goBack={votingActions.goBackToRegister.trigger} - onError={votingActions.submitTransactionError.trigger} + submit={votingStore.submitTransaction} + goBack={votingStore.goBackToRegister} + onError={votingStore.submitTransactionError} walletType={walletType} /> ); @@ -132,7 +133,7 @@ class VotingRegistrationDialogContainer extends Component { stepsList={stepsList} progressInfo={votingStore.progressInfo} onExternalLinkClick={handleExternalLinkClick} - submit={votingActions.finishQRCode.trigger} + submit={votingStore.finishQRCode} cancel={this.cancel} classicTheme={profile.isClassicTheme} votingKey={votingStore.encryptedKey} diff --git a/packages/yoroi-extension/app/stores/ada/VotingStore.js b/packages/yoroi-extension/app/stores/ada/VotingStore.js index 84ce70f00f..9b3a3b937b 100644 --- a/packages/yoroi-extension/app/stores/ada/VotingStore.js +++ b/packages/yoroi-extension/app/stores/ada/VotingStore.js @@ -29,7 +29,7 @@ import { CoreAddressTypes } from '../../api/ada/lib/storage/database/primitives/ import { derivePublicByAddressing } from '../../api/ada/lib/cardanoCrypto/deriveByAddressing'; import type { WalletState } from '../../../chrome/extension/background/types'; import { getPrivateStakingKey, getProtocolParameters } from '../../api/thunk'; -import { bytesToHex } from '../../coreUtils'; +import { bytesToHex, noop } from '../../coreUtils'; export const ProgressStep = Object.freeze({ GENERATE: 0, @@ -82,25 +82,10 @@ export default class VotingStore extends Store { setup(): void { super.setup(); - const { voting: votingActions } = this.actions.ada; this.reset({ justTransaction: false }); - votingActions.generateCatalystKey.listen(this._generateCatalystKey); - votingActions.createTransaction.listen(this._createTransaction); - votingActions.signTransaction.listen(this._signTransaction); - votingActions.submitRegister.listen(this._submitRegister); - votingActions.submitRegisterError.listen(this._submitRegisterError); - votingActions.finishQRCode.listen(this._finishQRCode); - votingActions.goBackToGenerate.listen(this._goBackToGenerate); - votingActions.submitConfirm.listen(this._submitConfirm); - votingActions.submitConfirmError.listen(this._submitConfirmError); - votingActions.goBackToRegister.listen(this._goBackToRegister); - votingActions.submitGenerate.listen(this._submitGenerate); - votingActions.submitTransaction.listen(this._submitTransaction); - votingActions.submitTransactionError.listen(this._submitTransactionError); - votingActions.cancel.listen(this._cancel); - this.actions.wallets.setActiveWallet.listen(() => {this._updateCatalystRoundInfo()}); - this._loadCatalystRoundInfo(); - this._updateCatalystRoundInfo(); + this.actions.wallets.setActiveWallet.listen(() => {noop(this._updateCatalystRoundInfo())}); + noop(this._loadCatalystRoundInfo()); + noop(this._updateCatalystRoundInfo()); } get isActionProcessing(): boolean { @@ -137,33 +122,33 @@ export default class VotingStore extends Store { } } - @action _goBackToRegister: void => void = () => { + @action goBackToRegister: void => void = () => { this.createVotingRegTx.reset(); this.error = null; this.progressInfo.currentStep = ProgressStep.REGISTER; this.progressInfo.stepState = StepState.LOAD; }; - @action _submitTransaction: void => void = () => { + @action submitTransaction: void => void = () => { this.progressInfo.currentStep = ProgressStep.QR_CODE; this.progressInfo.stepState = StepState.LOAD; }; - @action _submitGenerate: void => void = () => { + @action submitGenerate: void => void = () => { this.progressInfo.currentStep = ProgressStep.CONFIRM; this.progressInfo.stepState = StepState.LOAD; }; - @action _submitConfirm: void => Promise = async () => { + @action submitConfirm: void => Promise = async () => { const selected = this.stores.wallets.selected; if (!selected) { - throw new Error(`${nameof(this._submitConfirm)} no public deriver. Should never happen`); + throw new Error(`${nameof(this.submitConfirm)} no public deriver. Should never happen`); } let nextStep; if ( selected.type !== 'mnemonic' ) { - await this.actions.ada.voting.createTransaction.trigger(null); + await this.createTransaction(null); nextStep = ProgressStep.TRANSACTION; } else { nextStep = ProgressStep.REGISTER; @@ -174,35 +159,35 @@ export default class VotingStore extends Store { }) }; - @action _submitConfirmError: void => void = () => { + @action submitConfirmError: void => void = () => { this.progressInfo.currentStep = ProgressStep.CONFIRM; this.progressInfo.stepState = StepState.ERROR; }; - @action _goBackToGenerate: void => void = () => { + @action goBackToGenerate: void => void = () => { this.progressInfo.currentStep = ProgressStep.GENERATE; this.progressInfo.stepState = StepState.LOAD; }; - @action _finishQRCode: void => void = () => { + @action finishQRCode: void => void = () => { this.actions.dialogs.closeActiveDialog.trigger(); this.actions.router.goToRoute.trigger({ route: ROUTES.WALLETS.TRANSACTIONS }); this.reset({ justTransaction: false }); } - @action _submitRegister: void => void = () => { + @action submitRegister: void => void = () => { this.progressInfo.currentStep = ProgressStep.TRANSACTION; this.progressInfo.stepState = StepState.LOAD; }; - @action _submitRegisterError: Error => void = (error) => { + @action submitRegisterError: Error => void = (error) => { this.error = convertToLocalizableError(error); this.progressInfo.currentStep = ProgressStep.REGISTER; this.progressInfo.stepState = StepState.ERROR; }; - @action _submitTransactionError: Error => void = (error) => { + @action submitTransactionError: Error => void = (error) => { this.error = convertToLocalizableError(error); this.progressInfo.currentStep = ProgressStep.TRANSACTION; this.progressInfo.stepState = StepState.ERROR; @@ -211,7 +196,7 @@ export default class VotingStore extends Store { // For mnemonic wallet, we need password for transaction building to sign // the voting key with stake key as part of metadata. @action - _createTransaction: (null | string) => Promise = async spendingPassword => { + createTransaction: (null | string) => Promise = async spendingPassword => { this.progressInfo.stepState = StepState.PROCESS; const publicDeriver = this.stores.wallets.selected; if (!publicDeriver) { @@ -227,7 +212,7 @@ export default class VotingStore extends Store { const catalystPrivateKey = this.catalystPrivateKey; if(catalystPrivateKey === undefined){ - throw new Error(`${nameof(this._createTransaction)} should never happen`); + throw new Error(`${nameof(this.createTransaction)} should never happen`); } const firstAddress = publicDeriver.externalAddressesByType[CoreAddressTypes.CARDANO_BASE][0]; @@ -279,12 +264,12 @@ export default class VotingStore extends Store { protocolParameters, }).promise; } else { - throw new Error(`${nameof(this._createTransaction)} unexpected hardware wallet type`); + throw new Error(`${nameof(this.createTransaction)} unexpected hardware wallet type`); } } else { if (spendingPassword === null) { - throw new Error(`${nameof(this._createTransaction)} expect a password`); + throw new Error(`${nameof(this.createTransaction)} expect a password`); } // todo: optimize this away, use one round-trip const stakingKey = await getPrivateStakingKey({ @@ -310,20 +295,20 @@ export default class VotingStore extends Store { } if (votingRegTxPromise == null) { - throw new Error(`${nameof(this._createTransaction)} should never happen`); + throw new Error(`${nameof(this.createTransaction)} should never happen`); } await votingRegTxPromise; this.markStale(false); }; @action - _signTransaction: ({| + signTransaction: ({| password?: string, wallet: WalletState, |}) => Promise = async request => { const result = this.createVotingRegTx.result; if (result == null) { - throw new Error(`${nameof(this._signTransaction)} no tx to broadcast`); + throw new Error(`${nameof(this.signTransaction)} no tx to broadcast`); } if (request.wallet.type === 'ledger') { await this.stores.substores.ada.wallets.adaSendAndRefresh({ @@ -352,7 +337,7 @@ export default class VotingStore extends Store { // normal password-based wallet if (request.password == null) { - throw new Error(`${nameof(this._signTransaction)} missing password for non-hardware signing`); + throw new Error(`${nameof(this.signTransaction)} missing password for non-hardware signing`); } await this.stores.substores.ada.wallets.adaSendAndRefresh({ broadcastRequest: { @@ -366,9 +351,9 @@ export default class VotingStore extends Store { }); }; - @action _generateCatalystKey: void => Promise = async () => { + @action generateCatalystKey: void => Promise = async () => { Logger.info( - `${nameof(VotingStore)}::${nameof(this._generateCatalystKey)} called` + `${nameof(VotingStore)}::${nameof(this.generateCatalystKey)} called` ); const pin = cryptoRandomString({ length: 4, type: 'numeric' }); @@ -386,7 +371,7 @@ export default class VotingStore extends Store { }); }; - @action _cancel: void => void = () => { + @action cancel: void => void = () => { this.reset({ justTransaction: false }); } @action.bound From c572ea5a755c3eee54f97d99f5e659af03df4135 Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Sun, 13 Oct 2024 00:23:22 +0300 Subject: [PATCH 05/38] removed base profile actions --- .../app/actions/base/base-profile-actions.js | 19 ---------- .../app/actions/profile-actions.js | 3 +- .../wallet/restore/RestoreWalletPage.js | 2 +- .../app/connector/actions/index.js | 3 -- .../connector/containers/ConnectContainer.js | 2 +- .../toplevel/ConnectorCoinPriceStore.js | 3 +- .../connector/stores/toplevel/ProfileStore.js | 3 +- .../app/containers/NavBarContainer.js | 7 ++-- .../app/containers/NavBarContainerRevamp.js | 7 ++-- .../containers/profile/ComplexityLevelPage.js | 14 ++++---- .../profile/LanguageSelectionPage.js | 8 ++--- .../app/containers/profile/NightlyPage.js | 2 +- .../containers/profile/OptForAnalyticsPage.js | 2 +- .../categories/AnalyticsSettingsPage.js | 2 +- .../categories/ComplexityLevelSettingsPage.js | 4 +-- .../categories/GeneralSettingsPage.js | 11 +++--- .../app/containers/wallet/MyWalletsPage.js | 16 ++++----- .../app/containers/wallet/Wallet.js | 2 +- .../dialogs/WalletRestoreDialogContainer.js | 7 ++-- .../app/stores/base/BaseCoinPriceStore.js | 6 ++-- .../app/stores/base/BaseProfileStore.js | 36 +++++++------------ .../app/stores/toplevel/CoinPriceStore.js | 3 +- .../app/stores/toplevel/ProfileStore.js | 6 ++-- 23 files changed, 62 insertions(+), 106 deletions(-) delete mode 100644 packages/yoroi-extension/app/actions/base/base-profile-actions.js diff --git a/packages/yoroi-extension/app/actions/base/base-profile-actions.js b/packages/yoroi-extension/app/actions/base/base-profile-actions.js deleted file mode 100644 index 067a1cbdcc..0000000000 --- a/packages/yoroi-extension/app/actions/base/base-profile-actions.js +++ /dev/null @@ -1,19 +0,0 @@ -// @flow -import { AsyncAction, Action } from '../lib/Action'; -import type { UnitOfAccountSettingType } from '../../types/unitOfAccountType'; -import type { ComplexityLevelType } from '../../types/complexityLevelType'; - -// ======= PROFILE ACTIONS ======= - -export default class BaseProfileActions { - selectComplexityLevel: AsyncAction = new AsyncAction(); - updateTentativeLocale: Action<{| locale: string |}> = new Action(); - updateLocale: AsyncAction<{| locale: string |}> = new AsyncAction(); - resetLocale: AsyncAction = new AsyncAction(); - commitLocaleToStorage: AsyncAction = new AsyncAction(); - updateHideBalance: AsyncAction = new AsyncAction(); - acceptNightly: Action = new Action(); - updateUnitOfAccount: AsyncAction = new AsyncAction(); - optForAnalytics: Action = new Action(); - markRevampAsAnnounced: AsyncAction < void> = new AsyncAction(); -} diff --git a/packages/yoroi-extension/app/actions/profile-actions.js b/packages/yoroi-extension/app/actions/profile-actions.js index 77b2eb044c..625e7c4964 100644 --- a/packages/yoroi-extension/app/actions/profile-actions.js +++ b/packages/yoroi-extension/app/actions/profile-actions.js @@ -1,11 +1,10 @@ // @flow import { AsyncAction, Action } from './lib/Action'; import type { NetworkRow } from '../api/ada/lib/storage/database/primitives/tables'; -import BaseProfileActions from './base/base-profile-actions'; import type { WalletsNavigation } from '../api/localStorage'; // ======= PROFILE ACTIONS ======= -export default class ProfileActions extends BaseProfileActions { +export default class ProfileActions { acceptTermsOfUse: AsyncAction = new AsyncAction(); acceptUriScheme: AsyncAction = new AsyncAction(); toggleSidebar: AsyncAction = new AsyncAction(); diff --git a/packages/yoroi-extension/app/components/wallet/restore/RestoreWalletPage.js b/packages/yoroi-extension/app/components/wallet/restore/RestoreWalletPage.js index 4380f52493..73692f182f 100644 --- a/packages/yoroi-extension/app/components/wallet/restore/RestoreWalletPage.js +++ b/packages/yoroi-extension/app/components/wallet/restore/RestoreWalletPage.js @@ -89,7 +89,7 @@ function RestoreWalletPage(props: Props & Intl): Node { balance: duplicatedWallet.balance, shouldHideBalance: profileData.shouldHideBalance, tokenInfo: tokenInfoStore.tokenInfo, - updateHideBalance: () => profile.updateHideBalance.trigger(), + updateHideBalance: () => stores.profile.updateHideBalance(), }; }; diff --git a/packages/yoroi-extension/app/connector/actions/index.js b/packages/yoroi-extension/app/connector/actions/index.js index 38a17ded6e..06d15f52a6 100644 --- a/packages/yoroi-extension/app/connector/actions/index.js +++ b/packages/yoroi-extension/app/connector/actions/index.js @@ -1,12 +1,10 @@ // @flow -import BaseProfileActions from '../../actions/base/base-profile-actions'; import DialogsActions from '../../actions/dialogs-actions'; import NotificationsActions from '../../actions/notifications-actions'; import ConnectorActions from './connector-actions'; import ExplorerActions from '../../actions/common/explorer-actions'; export type ActionsMap = {| - profile: BaseProfileActions, dialogs: DialogsActions, explorers: ExplorerActions, notifications: NotificationsActions, @@ -14,7 +12,6 @@ export type ActionsMap = {| |}; const actionsMap: ActionsMap = Object.freeze({ - profile: new BaseProfileActions(), connector: new ConnectorActions(), dialogs: new DialogsActions(), explorers: new ExplorerActions(), diff --git a/packages/yoroi-extension/app/connector/containers/ConnectContainer.js b/packages/yoroi-extension/app/connector/containers/ConnectContainer.js index f80da8c547..e02ea3e114 100644 --- a/packages/yoroi-extension/app/connector/containers/ConnectContainer.js +++ b/packages/yoroi-extension/app/connector/containers/ConnectContainer.js @@ -161,7 +161,7 @@ export default class ConnectContainer extends Component< }; updateHideBalance: void => Promise = async () => { - await this.props.actions.profile.updateHideBalance.trigger(); + await this.props.stores.profile.updateHideBalance(); }; render(): Node { diff --git a/packages/yoroi-extension/app/connector/stores/toplevel/ConnectorCoinPriceStore.js b/packages/yoroi-extension/app/connector/stores/toplevel/ConnectorCoinPriceStore.js index cdc5fe0bbe..caf6dcb447 100644 --- a/packages/yoroi-extension/app/connector/stores/toplevel/ConnectorCoinPriceStore.js +++ b/packages/yoroi-extension/app/connector/stores/toplevel/ConnectorCoinPriceStore.js @@ -1,10 +1,9 @@ // @flow -import type { ActionsMap } from '../../actions/index'; import type { StoresMap } from '../index'; import BaseCoinPriceStore from '../../../stores/base/BaseCoinPriceStore'; -export default class ConnectorCoinPriceStore extends BaseCoinPriceStore { +export default class ConnectorCoinPriceStore extends BaseCoinPriceStore { setup(): void { super.setup(); } diff --git a/packages/yoroi-extension/app/connector/stores/toplevel/ProfileStore.js b/packages/yoroi-extension/app/connector/stores/toplevel/ProfileStore.js index 83857210c4..1b4e475abc 100644 --- a/packages/yoroi-extension/app/connector/stores/toplevel/ProfileStore.js +++ b/packages/yoroi-extension/app/connector/stores/toplevel/ProfileStore.js @@ -1,9 +1,8 @@ // @flow import BaseProfileStore from '../../../stores/base/BaseProfileStore'; -import type { ActionsMap } from '../../actions/index'; import type { StoresMap } from '../index'; -export default class ProfileStore extends BaseProfileStore { +export default class ProfileStore extends BaseProfileStore { setup(): void { super.setup(); diff --git a/packages/yoroi-extension/app/containers/NavBarContainer.js b/packages/yoroi-extension/app/containers/NavBarContainer.js index 662d880bf7..786e902a42 100644 --- a/packages/yoroi-extension/app/containers/NavBarContainer.js +++ b/packages/yoroi-extension/app/containers/NavBarContainer.js @@ -18,19 +18,18 @@ import BuySellDialog from '../components/buySell/BuySellDialog'; import globalMessages from '../i18n/global-messages'; import { MultiToken } from '../api/common/lib/MultiToken'; -type Props = {| - ...StoresAndActionsProps, +type LocalProps = {| title: Node, |}; @observer -export default class NavBarContainer extends Component { +export default class NavBarContainer extends Component<{| ...StoresAndActionsProps, ...LocalProps |}> { static contextTypes: {| intl: $npm$ReactIntl$IntlFormat |} = { intl: intlShape.isRequired, }; updateHideBalance: void => Promise = async () => { - await this.props.actions.profile.updateHideBalance.trigger(); + await this.props.stores.profile.updateHideBalance(); }; switchToNewWallet: (number) => void = publicDeriverId => { diff --git a/packages/yoroi-extension/app/containers/NavBarContainerRevamp.js b/packages/yoroi-extension/app/containers/NavBarContainerRevamp.js index 1e6e1d3448..44e000ead5 100644 --- a/packages/yoroi-extension/app/containers/NavBarContainerRevamp.js +++ b/packages/yoroi-extension/app/containers/NavBarContainerRevamp.js @@ -17,15 +17,14 @@ import BuySellAdaButton from '../components/topbar/BuySellAdaButton'; import { ampli } from '../../ampli/index'; import { MultiToken } from '../api/common/lib/MultiToken'; -type Props = {| - ...StoresAndActionsProps, +type LocalProps = {| title: Node, menu?: Node, pageBanner?: Node, |}; @observer -export default class NavBarContainerRevamp extends Component { +export default class NavBarContainerRevamp extends Component<{| ...StoresAndActionsProps, ...LocalProps |}> { static contextTypes: {| intl: $npm$ReactIntl$IntlFormat |} = { intl: intlShape.isRequired, }; @@ -35,7 +34,7 @@ export default class NavBarContainerRevamp extends Component { }; updateHideBalance: void => Promise = async () => { - await this.props.actions.profile.updateHideBalance.trigger(); + await this.props.stores.profile.updateHideBalance(); }; onSelectWallet: (number) => void = newWalletId => { diff --git a/packages/yoroi-extension/app/containers/profile/ComplexityLevelPage.js b/packages/yoroi-extension/app/containers/profile/ComplexityLevelPage.js index dc319c87a9..a4d9a48eb7 100644 --- a/packages/yoroi-extension/app/containers/profile/ComplexityLevelPage.js +++ b/packages/yoroi-extension/app/containers/profile/ComplexityLevelPage.js @@ -27,10 +27,10 @@ export default class ComplexityLevelPage extends Component @@ -50,10 +50,10 @@ export default class ComplexityLevelPage extends Component ); diff --git a/packages/yoroi-extension/app/containers/profile/LanguageSelectionPage.js b/packages/yoroi-extension/app/containers/profile/LanguageSelectionPage.js index d2699437ff..b7808679cd 100644 --- a/packages/yoroi-extension/app/containers/profile/LanguageSelectionPage.js +++ b/packages/yoroi-extension/app/containers/profile/LanguageSelectionPage.js @@ -36,20 +36,20 @@ export default class LanguageSelectionPage extends Component void = (values) => { - this.props.actions.profile.updateTentativeLocale.trigger(values); + this.props.stores.profile.updateTentativeLocale(values); }; onSubmit: {| locale: string |} => Promise = async (_values) => { // Important! The order of triggering these two events must not be exchanged! await this.props.actions.profile.acceptTermsOfUse.trigger(); - await this.props.actions.profile.commitLocaleToStorage.trigger(); + await this.props.stores.profile.acceptLocale(); }; renderByron(props: StoresAndActionsProps): Node { diff --git a/packages/yoroi-extension/app/containers/profile/NightlyPage.js b/packages/yoroi-extension/app/containers/profile/NightlyPage.js index 5d70a10474..74c0e50055 100644 --- a/packages/yoroi-extension/app/containers/profile/NightlyPage.js +++ b/packages/yoroi-extension/app/containers/profile/NightlyPage.js @@ -24,7 +24,7 @@ export default class NightlyPage extends Component { }; acceptNightly: void => void = () => { - this.props.actions.profile.acceptNightly.trigger(); + this.props.stores.profile.acceptNightly(); }; render(): Node { diff --git a/packages/yoroi-extension/app/containers/profile/OptForAnalyticsPage.js b/packages/yoroi-extension/app/containers/profile/OptForAnalyticsPage.js index 81c95e6dcc..f7241b4cbf 100644 --- a/packages/yoroi-extension/app/containers/profile/OptForAnalyticsPage.js +++ b/packages/yoroi-extension/app/containers/profile/OptForAnalyticsPage.js @@ -21,7 +21,7 @@ export default class OptForAnalyticsPage extends Component diff --git a/packages/yoroi-extension/app/containers/settings/categories/AnalyticsSettingsPage.js b/packages/yoroi-extension/app/containers/settings/categories/AnalyticsSettingsPage.js index d2336a3d1d..0f7b0ecaa5 100644 --- a/packages/yoroi-extension/app/containers/settings/categories/AnalyticsSettingsPage.js +++ b/packages/yoroi-extension/app/containers/settings/categories/AnalyticsSettingsPage.js @@ -16,7 +16,7 @@ export default class AnalyticsSettingsPage extends Component diff --git a/packages/yoroi-extension/app/containers/settings/categories/ComplexityLevelSettingsPage.js b/packages/yoroi-extension/app/containers/settings/categories/ComplexityLevelSettingsPage.js index 57fd56d694..93946ac6ed 100644 --- a/packages/yoroi-extension/app/containers/settings/categories/ComplexityLevelSettingsPage.js +++ b/packages/yoroi-extension/app/containers/settings/categories/ComplexityLevelSettingsPage.js @@ -4,12 +4,12 @@ import { observer } from 'mobx-react'; import ComplexityLevel from '../../../components/profile/complexity-level/ComplexityLevelForm'; import { useTheme } from '@mui/material'; -const ComplexityLevelSettingsPage: any = observer(({ stores, actions }) => { +const ComplexityLevelSettingsPage: any = observer(({ stores }) => { const { name } = useTheme(); return ( Promise = async value => { const unitOfAccount = value === 'ADA' ? unitOfAccountDisabledValue : { enabled: true, currency: value }; - await this.props.actions.profile.updateUnitOfAccount.trigger(unitOfAccount); + await this.props.stores.profile.updateUnitOfAccount(unitOfAccount); }; render(): Node { const { intl } = this.context; - const profileStore = this.props.stores.profile; - const coinPriceStore = this.props.stores.coinPriceStore; + const { stores } = this.props; + const profileStore = stores.profile; + const coinPriceStore = stores.coinPriceStore; const isSubmittingLocale = profileStore.setProfileLocaleRequest.isExecuting; const isSubmittingUnitOfAccount = @@ -100,7 +101,7 @@ export default class GeneralSettingsPage extends Component )} - + ); } diff --git a/packages/yoroi-extension/app/containers/wallet/MyWalletsPage.js b/packages/yoroi-extension/app/containers/wallet/MyWalletsPage.js index 890fa482d9..afe2e9448c 100644 --- a/packages/yoroi-extension/app/containers/wallet/MyWalletsPage.js +++ b/packages/yoroi-extension/app/containers/wallet/MyWalletsPage.js @@ -1,14 +1,14 @@ // @flow -import type { Node, ComponentType } from 'react'; +import type { ComponentType, Node } from 'react'; +import { Component } from 'react'; import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; +import { intlShape } from 'react-intl'; import type { StoresAndActionsProps } from '../../types/injectedProps.types'; import type { LayoutComponentMap } from '../../styles/context/layout'; -import { Component } from 'react'; +import { withLayout } from '../../styles/context/layout'; import { observer } from 'mobx-react'; -import { intlShape } from 'react-intl'; import { ROUTES } from '../../routes-config'; import { genLookupOrFail, getTokenName } from '../../stores/stateless/tokenHelpers'; -import { withLayout } from '../../styles/context/layout'; import { Box } from '@mui/system'; import MyWallets from '../../components/wallet/my-wallets/MyWallets'; import TopBarLayout from '../../components/layout/TopBarLayout'; @@ -31,10 +31,8 @@ import NavBarRevamp from '../../components/topbar/NavBarRevamp'; import { MultiToken } from '../../api/common/lib/MultiToken'; import type { WalletState } from '../../../chrome/extension/background/types'; -type Props = StoresAndActionsProps; - type InjectedLayoutProps = {| +renderLayoutComponent: LayoutComponentMap => Node |}; -type AllProps = {| ...Props, ...InjectedLayoutProps |}; +type AllProps = {| ...StoresAndActionsProps, ...InjectedLayoutProps |}; @observer class MyWalletsPage extends Component { @@ -51,7 +49,7 @@ class MyWalletsPage extends Component { }; updateHideBalance: void => Promise = async () => { - await this.props.actions.profile.updateHideBalance.trigger(); + await this.props.stores.profile.updateHideBalance(); }; handleWalletNavItemClick: number => void = ( @@ -240,4 +238,4 @@ class MyWalletsPage extends Component { return walletSubRow; }; } -export default (withLayout(MyWalletsPage): ComponentType); +export default (withLayout(MyWalletsPage): ComponentType); diff --git a/packages/yoroi-extension/app/containers/wallet/Wallet.js b/packages/yoroi-extension/app/containers/wallet/Wallet.js index f546c11519..c76774e49e 100644 --- a/packages/yoroi-extension/app/containers/wallet/Wallet.js +++ b/packages/yoroi-extension/app/containers/wallet/Wallet.js @@ -275,7 +275,7 @@ class Wallet extends Component { return ( { - this.props.actions.profile.markRevampAsAnnounced.trigger(); + this.props.stores.profile.markRevampAsAnnounced(); this.props.actions.dialogs.closeActiveDialog.trigger(); }} /> diff --git a/packages/yoroi-extension/app/containers/wallet/dialogs/WalletRestoreDialogContainer.js b/packages/yoroi-extension/app/containers/wallet/dialogs/WalletRestoreDialogContainer.js index 98eb6a6a1b..dc82026540 100644 --- a/packages/yoroi-extension/app/containers/wallet/dialogs/WalletRestoreDialogContainer.js +++ b/packages/yoroi-extension/app/containers/wallet/dialogs/WalletRestoreDialogContainer.js @@ -35,8 +35,7 @@ const messages = defineMessages({ }, }); -type Props = {| - ...StoresAndActionsProps, +type LocalProps = {| +onClose: void => void, +mode: RestoreModeType, +introMessage?: string, @@ -44,7 +43,7 @@ type Props = {| |}; @observer -export default class WalletRestoreDialogContainer extends Component { +export default class WalletRestoreDialogContainer extends Component<{| ...StoresAndActionsProps, ...LocalProps |}> { static contextTypes: {| intl: $npm$ReactIntl$IntlFormat |} = { intl: intlShape.isRequired, }; @@ -79,7 +78,7 @@ export default class WalletRestoreDialogContainer extends Component { }; updateHideBalance: void => Promise = async () => { - await this.props.actions.profile.updateHideBalance.trigger(); + await this.props.stores.profile.updateHideBalance(); }; openToTransactions: (number) => void = publicDeriverId => { diff --git a/packages/yoroi-extension/app/stores/base/BaseCoinPriceStore.js b/packages/yoroi-extension/app/stores/base/BaseCoinPriceStore.js index a9013f35e4..f4cc390b3e 100644 --- a/packages/yoroi-extension/app/stores/base/BaseCoinPriceStore.js +++ b/packages/yoroi-extension/app/stores/base/BaseCoinPriceStore.js @@ -9,7 +9,6 @@ import { import type { Ticker, PriceDataRow } from '../../api/ada/lib/storage/database/prices/tables'; import { getPrice, getPriceKey } from '../../api/common/lib/storage/bridge/prices'; import type { ConfigType } from '../../../config/config-types'; -import BaseProfileActions from '../../actions/base/base-profile-actions'; import type { UnitOfAccountSettingType } from '../../types/unitOfAccountType'; import { listenForCoinPriceUpdate, getHistoricalCoinPrices, refreshCurrentCoinPrice } from '../../api/thunk'; @@ -25,10 +24,9 @@ export default class BaseCoinPriceStore ..., }, ..., - }, - TActions: { +profile: BaseProfileActions, ... } + } > - extends Store + extends Store { @observable currentPriceTickers: Array<{| From: string, To: string, Price: number |}> = []; @observable lastUpdateTimestamp: number|null = null; diff --git a/packages/yoroi-extension/app/stores/base/BaseProfileStore.js b/packages/yoroi-extension/app/stores/base/BaseProfileStore.js index 9d1ac851a7..3013d35cff 100644 --- a/packages/yoroi-extension/app/stores/base/BaseProfileStore.js +++ b/packages/yoroi-extension/app/stores/base/BaseProfileStore.js @@ -11,7 +11,6 @@ import { unitOfAccountDisabledValue } from '../../types/unitOfAccountType'; import type { UnitOfAccountSettingType } from '../../types/unitOfAccountType'; import { SUPPORTED_CURRENCIES } from '../../config/unitOfAccount'; import type { ComplexityLevelType } from '../../types/complexityLevelType'; -import BaseProfileActions from '../../actions/base/base-profile-actions'; import { CURRENT_TOS_VERSION } from '../../i18n/locales/terms-of-use/ada/index'; import { ampli } from '../../../ampli/index'; import type { LoadOptionsWithEnvironment } from '../../../ampli/index'; @@ -28,10 +27,9 @@ export default class BaseProfileStore TStores: { +loading: LoadingStore, ... - }, - TActions: { +profile: BaseProfileActions, ... } + } > - extends Store + extends Store { LANGUAGE_OPTIONS: Array = [ @@ -149,16 +147,6 @@ export default class BaseProfileStore setup(): void { super.setup(); - this.actions.profile.updateLocale.listen(this._updateLocale); - this.actions.profile.resetLocale.listen(this._resetLocale); - this.actions.profile.updateTentativeLocale.listen(this._updateTentativeLocale); - this.actions.profile.selectComplexityLevel.listen(this._selectComplexityLevel); - this.actions.profile.commitLocaleToStorage.listen(this._acceptLocale); - this.actions.profile.updateHideBalance.listen(this._updateHideBalance); - this.actions.profile.updateUnitOfAccount.listen(this._updateUnitOfAccount); - this.actions.profile.acceptNightly.listen(this._acceptNightly); - this.actions.profile.optForAnalytics.listen(this._onOptForAnalytics); - this.actions.profile.markRevampAsAnnounced.listen(this._markRevampAsAnnounced); this.registerReactions([ this._setBigNumberFormat, this._updateMomentJsLocaleAfterLocaleChange, @@ -261,27 +249,27 @@ export default class BaseProfileStore } @action - _markRevampAsAnnounced: void => Promise = async () => { + markRevampAsAnnounced: void => Promise = async () => { await this.setUserRevampAnnouncementStatusRequest.execute(true); await this.getUserRevampAnnouncementStatusRequest.execute(); }; @action - _updateTentativeLocale: ({| locale: string |}) => void = request => { + updateTentativeLocale: ({| locale: string |}) => void = request => { this.inMemoryLanguage = request.locale; }; - _updateLocale: ({| locale: string |}) => Promise = async ({ locale }) => { + updateLocale: ({| locale: string |}) => Promise = async ({ locale }) => { await this.setProfileLocaleRequest.execute(locale); await this.getProfileLocaleRequest.execute(); // eagerly cache }; - _resetLocale: void => Promise = async () => { + resetLocale: void => Promise = async () => { await this.unsetProfileLocaleRequest.execute(); await this.getProfileLocaleRequest.execute(); }; - _acceptLocale: void => Promise = async () => { + acceptLocale: void => Promise = async () => { // commit in-memory language to storage await this.setProfileLocaleRequest.execute( this.inMemoryLanguage != null ? this.inMemoryLanguage : BaseProfileStore.getDefaultLocale() @@ -411,7 +399,7 @@ export default class BaseProfileStore return !!this.getComplexityLevelRequest.result; } - _selectComplexityLevel: ComplexityLevelType => Promise = async ( + selectComplexityLevel: ComplexityLevelType => Promise = async ( level: ComplexityLevelType ): Promise => { await this.setComplexityLevelRequest.execute(level); @@ -453,7 +441,7 @@ export default class BaseProfileStore return result === true; } - _updateHideBalance: void => Promise = async () => { + updateHideBalance: void => Promise = async () => { const shouldHideBalance = this.shouldHideBalance; await this.setHideBalanceRequest.execute(shouldHideBalance); await this.getHideBalanceRequest.execute(); @@ -462,7 +450,7 @@ export default class BaseProfileStore // ========== Accept nightly ========== // @action - _acceptNightly: void => void = () => { + acceptNightly: void => void = () => { this.acceptedNightly = true; }; @@ -487,7 +475,7 @@ export default class BaseProfileStore return this.getUnitOfAccountRequest.result; }; - _updateUnitOfAccount: UnitOfAccountSettingType => Promise = async currency => { + updateUnitOfAccount: UnitOfAccountSettingType => Promise = async currency => { await this.setUnitOfAccountRequest.execute(currency); await this.getUnitOfAccountRequest.execute(); // eagerly cache }; @@ -496,7 +484,7 @@ export default class BaseProfileStore return this.getUnitOfAccountRequest.wasExecuted && this.getUnitOfAccountRequest.result !== null; } - _onOptForAnalytics: (boolean) => void = (isAnalyticsAllowed) => { + onOptForAnalytics: (boolean) => void = (isAnalyticsAllowed) => { this.getIsAnalyticsAllowed.patch(_ => isAnalyticsAllowed); this.api.localStorage.saveIsAnalysticsAllowed(isAnalyticsAllowed); ampli.client.setOptOut(!isAnalyticsAllowed); diff --git a/packages/yoroi-extension/app/stores/toplevel/CoinPriceStore.js b/packages/yoroi-extension/app/stores/toplevel/CoinPriceStore.js index 1eafca1b8b..1c6c50dae2 100644 --- a/packages/yoroi-extension/app/stores/toplevel/CoinPriceStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/CoinPriceStore.js @@ -1,10 +1,9 @@ // @flow -import type { ActionsMap } from '../../actions/index'; import type { StoresMap } from '../index'; import BaseCoinPriceStore from '../base/BaseCoinPriceStore'; -export default class CoinPriceStore extends BaseCoinPriceStore { +export default class CoinPriceStore extends BaseCoinPriceStore { setup(): void { super.setup(); } diff --git a/packages/yoroi-extension/app/stores/toplevel/ProfileStore.js b/packages/yoroi-extension/app/stores/toplevel/ProfileStore.js index 8256964bc0..5f834f8259 100644 --- a/packages/yoroi-extension/app/stores/toplevel/ProfileStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/ProfileStore.js @@ -6,14 +6,14 @@ import Request from '../lib/LocalizedRequest'; import environment from '../../environment'; import { ROUTES } from '../../routes-config'; import type { NetworkRow } from '../../api/ada/lib/storage/database/primitives/tables'; -import type { ActionsMap } from '../../actions/index'; import type { StoresMap } from '../index'; import { ComplexityLevels } from '../../types/complexityLevelType'; import type { WalletsNavigation } from '../../api/localStorage' import { ampli } from '../../../ampli/index'; import { subscribe } from '../../api/thunk'; +import { noop } from '../../coreUtils'; -export default class ProfileStore extends BaseProfileStore { +export default class ProfileStore extends BaseProfileStore { @observable __selectedNetwork: void | $ReadOnly = undefined; /** @@ -64,7 +64,7 @@ export default class ProfileStore extends BaseProfileStore Date: Sun, 13 Oct 2024 00:38:14 +0300 Subject: [PATCH 06/38] removed ada hw connect actions --- .../app/actions/ada/hw-connect-actions.js | 14 ----------- .../yoroi-extension/app/actions/ada/index.js | 5 ---- .../app/containers/wallet/AddWalletPage.js | 4 ++-- .../WalletLedgerConnectDialogContainer.js | 20 +++++++--------- .../WalletTrezorConnectDialogContainer.js | 16 ++++++------- .../app/stores/ada/LedgerConnectStore.js | 24 +++++++------------ .../app/stores/ada/TrezorConnectStore.js | 22 ++++++----------- .../app/types/HWConnectStoreTypes.js | 12 +++++----- 8 files changed, 39 insertions(+), 78 deletions(-) delete mode 100644 packages/yoroi-extension/app/actions/ada/hw-connect-actions.js diff --git a/packages/yoroi-extension/app/actions/ada/hw-connect-actions.js b/packages/yoroi-extension/app/actions/ada/hw-connect-actions.js deleted file mode 100644 index ceb51eec02..0000000000 --- a/packages/yoroi-extension/app/actions/ada/hw-connect-actions.js +++ /dev/null @@ -1,14 +0,0 @@ -// @flow -import { AsyncAction, Action } from '../lib/Action'; - -// ======= HARDWARE WALLET CONNECT ACTIONS ======= - -export default class HWConnectActions { - init: Action = new Action(); - cancel: Action = new Action(); - submitCheck: Action = new Action(); - goBackToCheck: Action = new Action(); - submitConnect: AsyncAction = new AsyncAction(); - submitSave: AsyncAction = new AsyncAction(); - finishTransfer: Action = new Action(); -} diff --git a/packages/yoroi-extension/app/actions/ada/index.js b/packages/yoroi-extension/app/actions/ada/index.js index 0c5d1fda21..d5e9f9f770 100644 --- a/packages/yoroi-extension/app/actions/ada/index.js +++ b/packages/yoroi-extension/app/actions/ada/index.js @@ -1,19 +1,14 @@ // @flow -import HWConnectActions from './hw-connect-actions'; import TrezorSendActions from './trezor-send-actions'; import LedgerSendActions from './ledger-send-actions'; export type AdaActionsMap = {| - trezorConnect: HWConnectActions, trezorSend: TrezorSendActions, - ledgerConnect: HWConnectActions, ledgerSend: LedgerSendActions, |}; const adaActionsMap: AdaActionsMap = Object.freeze({ - trezorConnect: new HWConnectActions(), trezorSend: new TrezorSendActions(), - ledgerConnect: new HWConnectActions(), ledgerSend: new LedgerSendActions(), }); diff --git a/packages/yoroi-extension/app/containers/wallet/AddWalletPage.js b/packages/yoroi-extension/app/containers/wallet/AddWalletPage.js index de62701c0d..a8f5e105fc 100644 --- a/packages/yoroi-extension/app/containers/wallet/AddWalletPage.js +++ b/packages/yoroi-extension/app/containers/wallet/AddWalletPage.js @@ -81,7 +81,7 @@ class AddWalletPage extends Component { dialog: WalletTrezorConnectDialogContainer, }); // - this.props.actions.ada.trezorConnect.init.trigger(); + stores.substores.ada.trezorConnect.init(); }; const openLedgerConnectDialog = () => { if (selectedNetwork === undefined) { @@ -91,7 +91,7 @@ class AddWalletPage extends Component { dialog: WalletLedgerConnectDialogContainer, }); // - this.props.actions.ada.ledgerConnect.init.trigger(); + stores.substores.ada.ledgerConnect.init(); }; let activeDialog = null; diff --git a/packages/yoroi-extension/app/containers/wallet/dialogs/WalletLedgerConnectDialogContainer.js b/packages/yoroi-extension/app/containers/wallet/dialogs/WalletLedgerConnectDialogContainer.js index 83d3cffa59..0c673eecfe 100644 --- a/packages/yoroi-extension/app/containers/wallet/dialogs/WalletLedgerConnectDialogContainer.js +++ b/packages/yoroi-extension/app/containers/wallet/dialogs/WalletLedgerConnectDialogContainer.js @@ -15,14 +15,13 @@ import UpgradeTxDialogContainer from '../../transfer/UpgradeTxDialogContainer'; import { ProgressStep } from '../../../types/HWConnectStoreTypes'; import type { NetworkRow } from '../../../api/ada/lib/storage/database/primitives/tables'; -type Props = {| - ...StoresAndActionsProps, +type LocalProps = {| +onClose: void => void, +onBack: void => void, |}; @observer -export default class WalletLedgerConnectDialogContainer extends Component { +export default class WalletLedgerConnectDialogContainer extends Component<{| ...StoresAndActionsProps, ...LocalProps |}> { getSelectedNetwork: void => $ReadOnly = () => { const { selectedNetwork } = this.props.stores.profile; @@ -34,14 +33,13 @@ export default class WalletLedgerConnectDialogContainer extends Component cancel: (() => void) = () => { this.props.onClose(); - this.props.actions.ada.ledgerConnect.cancel.trigger(); + this.props.stores.substores.ada.ledgerConnect.cancel(); }; render(): null | Node { const { actions, stores } = this.props; const { profile } = this.props.stores; const ledgerConnectStore = this.props.stores.substores.ada.ledgerConnect; - const hwConnectActions = this.props.actions.ada.ledgerConnect; let component = null; @@ -53,7 +51,7 @@ export default class WalletLedgerConnectDialogContainer extends Component isActionProcessing={ledgerConnectStore.isActionProcessing} error={ledgerConnectStore.error} onExternalLinkClick={handleExternalLinkClick} - submit={hwConnectActions.submitCheck.trigger} + submit={ledgerConnectStore.submitCheck} cancel={this.cancel} classicTheme={profile.isClassicTheme} onBack={this.props.onBack} @@ -66,8 +64,8 @@ export default class WalletLedgerConnectDialogContainer extends Component isActionProcessing={ledgerConnectStore.isActionProcessing} error={ledgerConnectStore.error} onExternalLinkClick={handleExternalLinkClick} - goBack={hwConnectActions.goBackToCheck.trigger} - submit={hwConnectActions.submitConnect.trigger} + goBack={ledgerConnectStore.goBackToCheck} + submit={ledgerConnectStore.submitConnect} cancel={this.cancel} classicTheme={profile.isClassicTheme} />); @@ -77,8 +75,8 @@ export default class WalletLedgerConnectDialogContainer extends Component ); break; case ProgressStep.SAVE: @@ -89,7 +87,7 @@ export default class WalletLedgerConnectDialogContainer extends Component error={ledgerConnectStore.error} defaultWalletName={ledgerConnectStore.defaultWalletName} onExternalLinkClick={handleExternalLinkClick} - submit={hwConnectActions.submitSave.trigger} + submit={ledgerConnectStore.submitSave} cancel={this.cancel} classicTheme={profile.isClassicTheme} />); diff --git a/packages/yoroi-extension/app/containers/wallet/dialogs/WalletTrezorConnectDialogContainer.js b/packages/yoroi-extension/app/containers/wallet/dialogs/WalletTrezorConnectDialogContainer.js index 25fbda6f57..84096372bc 100644 --- a/packages/yoroi-extension/app/containers/wallet/dialogs/WalletTrezorConnectDialogContainer.js +++ b/packages/yoroi-extension/app/containers/wallet/dialogs/WalletTrezorConnectDialogContainer.js @@ -14,14 +14,13 @@ import SaveDialog from '../../../components/wallet/hwConnect/trezor/SaveDialog'; import { ProgressStep } from '../../../types/HWConnectStoreTypes'; import type { NetworkRow } from '../../../api/ada/lib/storage/database/primitives/tables'; -type Props = {| - ...StoresAndActionsProps, +type LocalProps = {| +onClose: (void) => void, +onBack: void => void, |}; @observer -export default class WalletTrezorConnectDialogContainer extends Component { +export default class WalletTrezorConnectDialogContainer extends Component<{| ...StoresAndActionsProps, ...LocalProps |}> { getSelectedNetwork: void => $ReadOnly = () => { const { selectedNetwork } = this.props.stores.profile; @@ -33,13 +32,12 @@ export default class WalletTrezorConnectDialogContainer extends Component cancel: void => void = () => { this.props.onClose(); - this.props.actions.ada.trezorConnect.cancel.trigger(); + this.props.stores.substores.ada.trezorConnect.cancel(); }; render(): null | Node { const { profile } = this.props.stores; const trezorConnectStore = this.props.stores.substores.ada.trezorConnect; - const hwConnectActions = this.props.actions.ada.trezorConnect; let component = null; @@ -51,7 +49,7 @@ export default class WalletTrezorConnectDialogContainer extends Component isActionProcessing={trezorConnectStore.isActionProcessing} error={trezorConnectStore.error} onExternalLinkClick={handleExternalLinkClick} - submit={hwConnectActions.submitCheck.trigger} + submit={trezorConnectStore.submitCheck} cancel={this.cancel} onBack={this.props.onBack} classicTheme={profile.isClassicTheme} @@ -64,8 +62,8 @@ export default class WalletTrezorConnectDialogContainer extends Component isActionProcessing={trezorConnectStore.isActionProcessing} error={trezorConnectStore.error} onExternalLinkClick={handleExternalLinkClick} - goBack={hwConnectActions.goBackToCheck.trigger} - submit={hwConnectActions.submitConnect.trigger} + goBack={trezorConnectStore.goBackToCheck} + submit={trezorConnectStore.submitConnect} cancel={this.cancel} classicTheme={profile.isClassicTheme} />); @@ -78,7 +76,7 @@ export default class WalletTrezorConnectDialogContainer extends Component error={trezorConnectStore.error} defaultWalletName={trezorConnectStore.defaultWalletName} onExternalLinkClick={handleExternalLinkClick} - submit={hwConnectActions.submitSave.trigger} + submit={trezorConnectStore.submitSave} cancel={this.cancel} classicTheme={profile.isClassicTheme} />); diff --git a/packages/yoroi-extension/app/stores/ada/LedgerConnectStore.js b/packages/yoroi-extension/app/stores/ada/LedgerConnectStore.js index 888c3b4d8d..8400fd9e50 100644 --- a/packages/yoroi-extension/app/stores/ada/LedgerConnectStore.js +++ b/packages/yoroi-extension/app/stores/ada/LedgerConnectStore.js @@ -59,23 +59,15 @@ export default class LedgerConnectStore setup(): void { super.setup(); this._reset(); - const ledgerConnectAction = this.actions.ada.ledgerConnect; - ledgerConnectAction.init.listen(this._init); - ledgerConnectAction.cancel.listen(this._cancel); - ledgerConnectAction.submitCheck.listen(this._submitCheck); - ledgerConnectAction.goBackToCheck.listen(this._goBackToCheck); - ledgerConnectAction.submitConnect.listen(this._submitConnect); - ledgerConnectAction.submitSave.listen(this._submitSave); - ledgerConnectAction.finishTransfer.listen(this._finishTransfer); } /** setup() is called when stores are being created * _init() is called when connect dialog is about to show */ - _init: void => void = () => { - Logger.debug(`${nameof(LedgerConnectStore)}::${nameof(this._init)} called`); + init: void => void = () => { + Logger.debug(`${nameof(LedgerConnectStore)}::${nameof(this.init)} called`); } - @action _cancel: void => void = () => { + @action cancel: void => void = () => { this.teardown(); if (this.ledgerConnect) { this.ledgerConnect.dispose(); @@ -108,7 +100,7 @@ export default class LedgerConnectStore // =================== CHECK =================== // /** CHECK dialog submit(Next button) */ - @action _submitCheck: void => void = () => { + @action submitCheck: void => void = () => { this.error = undefined; this.progressInfo.currentStep = ProgressStep.CONNECT; this.progressInfo.stepState = StepState.LOAD; @@ -117,14 +109,14 @@ export default class LedgerConnectStore // =================== CONNECT =================== // /** CONNECT dialog goBack button */ - @action _goBackToCheck: void => void = () => { + @action goBackToCheck: void => void = () => { this.error = undefined; this.progressInfo.currentStep = ProgressStep.CHECK; this.progressInfo.stepState = StepState.LOAD; }; /** CONNECT dialog submit (Connect button) */ - @action _submitConnect: void => Promise = async () => { + @action submitConnect: void => Promise = async () => { this.error = undefined; this.progressInfo.currentStep = ProgressStep.CONNECT; this.progressInfo.stepState = StepState.PROCESS; @@ -318,7 +310,7 @@ export default class LedgerConnectStore }; /** SAVE dialog submit (Save button) */ - @action _submitSave: (string) => Promise = async ( + @action submitSave: (string) => Promise = async ( walletName, ) => { this.error = null; @@ -420,7 +412,7 @@ export default class LedgerConnectStore } } - _finishTransfer: void => void = () => { + finishTransfer: void => void = () => { this.actions.dialogs.closeActiveDialog.trigger(); this.actions.router.goToRoute.trigger({ route: ROUTES.WALLETS.ROOT }); diff --git a/packages/yoroi-extension/app/stores/ada/TrezorConnectStore.js b/packages/yoroi-extension/app/stores/ada/TrezorConnectStore.js index 55b967a495..524ba86271 100644 --- a/packages/yoroi-extension/app/stores/ada/TrezorConnectStore.js +++ b/packages/yoroi-extension/app/stores/ada/TrezorConnectStore.js @@ -72,14 +72,6 @@ export default class TrezorConnectStore setup(): void { super.setup(); this._reset(); - const trezorConnectAction = this.actions.ada.trezorConnect; - trezorConnectAction.init.listen(this._init); - trezorConnectAction.cancel.listen(this._cancel); - trezorConnectAction.submitCheck.listen(this._submitCheck); - trezorConnectAction.goBackToCheck.listen(this._goBackToCheck); - trezorConnectAction.submitConnect.listen(this._submitConnect); - trezorConnectAction.submitSave.listen(this._submitSave); - try { const trezorManifest = getTrezorManifest(); wrapWithoutFrame(trezor => trezor.manifest(trezorManifest)); @@ -90,8 +82,8 @@ export default class TrezorConnectStore /** setup() is called when stores are being created * _init() is called when connect dialog is about to show */ - _init: void => void = () => { - Logger.debug(`${nameof(TrezorConnectStore)}::${nameof(this._init)} called`); + init: void => void = () => { + Logger.debug(`${nameof(TrezorConnectStore)}::${nameof(this.init)} called`); } teardown(): void { @@ -109,13 +101,13 @@ export default class TrezorConnectStore this.trezorEventDevice = undefined; }; - @action _cancel: void => void = () => { + @action cancel: void => void = () => { this.teardown(); }; // =================== CHECK =================== // /** CHECK dialog submit(Next button) */ - @action _submitCheck: void => void = () => { + @action submitCheck: void => void = () => { this.error = undefined; this.trezorEventDevice = undefined; this.progressInfo.currentStep = ProgressStep.CONNECT; @@ -125,14 +117,14 @@ export default class TrezorConnectStore // =================== CONNECT =================== // /** CONNECT dialog goBack button */ - @action _goBackToCheck: void => void = () => { + @action goBackToCheck: void => void = () => { this.error = undefined; this.progressInfo.currentStep = ProgressStep.CHECK; this.progressInfo.stepState = StepState.LOAD; }; /** CONNECT dialog submit (Connect button) */ - @action _submitConnect: void => Promise = async () => { + @action submitConnect: void => Promise = async () => { this.error = undefined; this.progressInfo.currentStep = ProgressStep.CONNECT; this.progressInfo.stepState = StepState.PROCESS; @@ -268,7 +260,7 @@ export default class TrezorConnectStore }; /** SAVE dialog submit (Save button) */ - @action _submitSave: string => Promise = async ( + @action submitSave: string => Promise = async ( walletName, ) => { this.error = null; diff --git a/packages/yoroi-extension/app/types/HWConnectStoreTypes.js b/packages/yoroi-extension/app/types/HWConnectStoreTypes.js index 5ccef5539b..eda0dba7aa 100644 --- a/packages/yoroi-extension/app/types/HWConnectStoreTypes.js +++ b/packages/yoroi-extension/app/types/HWConnectStoreTypes.js @@ -58,25 +58,25 @@ export interface HWConnectStoreTypes { /** setup() is called when stores are being created * _init() is called when connect dialog is about to show */ - _init(): void; + init(): void; teardown(): void; _reset(): void; - _cancel(): void; + cancel(): void; // =================== CHECK =================== // /** CHECK dialog submit(Next button) */ - _submitCheck(): void; + submitCheck(): void; // =================== CHECK =================== // // =================== CONNECT =================== // /** CONNECT dialog goBack button */ - _goBackToCheck(): void; + goBackToCheck(): void; /** CONNECT dialog submit (Connect button) */ - _submitConnect(): Promise; + submitConnect(): Promise; _goToConnectError(): void; @@ -94,7 +94,7 @@ export interface HWConnectStoreTypes { _goToSaveLoad(): void; /** SAVE dialog submit (Save button) */ - _submitSave(walletName: string): Promise; + submitSave(walletName: string): Promise; _goToSaveError(): void; From 828a015420112a143536a50bcee8e1c55a17ef02 Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Sun, 13 Oct 2024 01:04:08 +0300 Subject: [PATCH 07/38] removed ada hw send actions --- .../yoroi-extension/app/actions/ada/index.js | 15 ---- .../app/actions/ada/ledger-send-actions.js | 44 ----------- .../app/actions/ada/trezor-send-actions.js | 29 ------- packages/yoroi-extension/app/actions/index.js | 4 - .../wallet/send/WalletSendFormRevamp.js | 8 +- .../WalletSendPreviewStepContainer.js | 16 ++-- .../containers/transfer/TransferSendPage.js | 23 +++--- .../transfer/UpgradeTxDialogContainer.js | 7 +- .../app/containers/wallet/WalletSendPage.js | 16 ++-- .../wallet/staking/WithdrawRewardsDialog.js | 23 +++--- .../app/stores/ada/send/LedgerSendStore.js | 77 ++++++++----------- .../app/stores/ada/send/TrezorSendStore.js | 26 +++---- 12 files changed, 91 insertions(+), 197 deletions(-) delete mode 100644 packages/yoroi-extension/app/actions/ada/index.js delete mode 100644 packages/yoroi-extension/app/actions/ada/ledger-send-actions.js delete mode 100644 packages/yoroi-extension/app/actions/ada/trezor-send-actions.js diff --git a/packages/yoroi-extension/app/actions/ada/index.js b/packages/yoroi-extension/app/actions/ada/index.js deleted file mode 100644 index d5e9f9f770..0000000000 --- a/packages/yoroi-extension/app/actions/ada/index.js +++ /dev/null @@ -1,15 +0,0 @@ -// @flow -import TrezorSendActions from './trezor-send-actions'; -import LedgerSendActions from './ledger-send-actions'; - -export type AdaActionsMap = {| - trezorSend: TrezorSendActions, - ledgerSend: LedgerSendActions, -|}; - -const adaActionsMap: AdaActionsMap = Object.freeze({ - trezorSend: new TrezorSendActions(), - ledgerSend: new LedgerSendActions(), -}); - -export default adaActionsMap; diff --git a/packages/yoroi-extension/app/actions/ada/ledger-send-actions.js b/packages/yoroi-extension/app/actions/ada/ledger-send-actions.js deleted file mode 100644 index 06f273fd48..0000000000 --- a/packages/yoroi-extension/app/actions/ada/ledger-send-actions.js +++ /dev/null @@ -1,44 +0,0 @@ -// @flow -import { AsyncAction, Action } from '../lib/Action'; -import type { ISignRequest } from '../../api/common/lib/transactions/ISignRequest'; -import type { HaskellShelleyTxSignRequest } from '../../api/ada/transactions/shelley/HaskellShelleyTxSignRequest'; -import { RustModule } from '../../api/ada/lib/cardanoCrypto/rustLoader'; -import type { - Addressing, -} from '../../api/ada/lib/storage/models/PublicDeriver/interfaces'; - -export type SendUsingLedgerParams = {| - signRequest: ISignRequest, -|}; - -// ======= Sending ADA using Ledger ACTIONS ======= - -export default class LedgerSendActions { - init: Action = new Action(); - cancel: Action = new Action(); - sendUsingLedgerWallet: AsyncAction<{| - params: SendUsingLedgerParams, - onSuccess?: void => void, - +wallet: { - publicDeriverId: number, - stakingAddressing: Addressing, - publicKey: string, - pathToPublic: Array, - networkId: number, - hardwareWalletDeviceId: ?string, - +plate: { TextPart: string, ... }, - ... - }, - |}> = new AsyncAction(); - sendUsingLedgerKey: AsyncAction<{| - signRequest: HaskellShelleyTxSignRequest, - publicKey: {| - key: RustModule.WalletV4.Bip32PublicKey, - ...Addressing, - |}, - publicDeriverId: number, - addressingMap: string => (void | $PropertyType), - expectedSerial: string | void, - networkId: number, - |}> = new AsyncAction(); -} diff --git a/packages/yoroi-extension/app/actions/ada/trezor-send-actions.js b/packages/yoroi-extension/app/actions/ada/trezor-send-actions.js deleted file mode 100644 index 4bb4caf835..0000000000 --- a/packages/yoroi-extension/app/actions/ada/trezor-send-actions.js +++ /dev/null @@ -1,29 +0,0 @@ -// @flow -import { AsyncAction, Action } from '../lib/Action'; -import type { ISignRequest } from '../../api/common/lib/transactions/ISignRequest'; -import type { Addressing } from '../../api/ada/lib/storage/models/PublicDeriver/interfaces'; - -export type SendUsingTrezorParams = {| - signRequest: ISignRequest, -|}; - -// ======= Sending ADA using Trezor ACTIONS ======= - -export default class TrezorSendActions { - cancel: Action = new Action(); - reset: Action = new Action(); - sendUsingTrezor: AsyncAction<{| - params: SendUsingTrezorParams, - onSuccess?: void => void, - +wallet: { - publicDeriverId: number, - stakingAddressing: Addressing, - publicKey: string, - pathToPublic: Array, - networkId: number, - hardwareWalletDeviceId: ?string, - +plate: { TextPart: string, ... }, - ... - }, - |}> = new AsyncAction(); -} diff --git a/packages/yoroi-extension/app/actions/index.js b/packages/yoroi-extension/app/actions/index.js index 9be733a5cc..43c74b85ab 100644 --- a/packages/yoroi-extension/app/actions/index.js +++ b/packages/yoroi-extension/app/actions/index.js @@ -15,8 +15,6 @@ import TxBuilderActions from './common/tx-builder-actions'; import ExplorerActions from './common/explorer-actions'; import DelegationActions from './common/delegation-actions'; import WalletSettingsActions from './common/wallet-settings-actions'; -import adaActionsMap from './ada/index'; -import type { AdaActionsMap } from './ada/index'; import ConnectorActionsMap from '../connector/actions/connector-actions'; import ServerConnectionActions from './server-connection-actions'; @@ -37,7 +35,6 @@ export type ActionsMap = {| walletRestore: WalletRestoreActions, delegation: DelegationActions, explorers: ExplorerActions, - ada: AdaActionsMap, connector: ConnectorActionsMap, serverConnection: ServerConnectionActions, |}; @@ -60,7 +57,6 @@ const actionsMap: ActionsMap = Object.freeze({ transactions: new TransactionsActions(), explorers: new ExplorerActions(), connector: new ConnectorActionsMap(), - ada: adaActionsMap, serverConnection: new ServerConnectionActions(), }); diff --git a/packages/yoroi-extension/app/components/wallet/send/WalletSendFormRevamp.js b/packages/yoroi-extension/app/components/wallet/send/WalletSendFormRevamp.js index f8b2595fe2..e5a2d4b5e4 100644 --- a/packages/yoroi-extension/app/components/wallet/send/WalletSendFormRevamp.js +++ b/packages/yoroi-extension/app/components/wallet/send/WalletSendFormRevamp.js @@ -54,12 +54,12 @@ import { ampli } from '../../../../ampli/index'; import type { DomainResolverFunc, DomainResolverResponse } from '../../../stores/ada/AdaAddressesStore'; import { isResolvableDomain } from '@yoroi/resolver'; import SupportedAddressDomainsBanner from '../../../containers/wallet/SupportedAddressDomainsBanner'; -import TrezorSendActions from '../../../actions/ada/trezor-send-actions'; -import LedgerSendActions from '../../../actions/ada/ledger-send-actions'; import type { SendMoneyRequest } from '../../../stores/toplevel/WalletStore'; import type { MaxSendableAmountRequest } from '../../../stores/toplevel/TransactionBuilderStore'; import type { WalletState } from '../../../../chrome/extension/background/types'; import LoadingSpinner from '../../widgets/LoadingSpinner'; +import LedgerSendStore from '../../../stores/ada/send/LedgerSendStore'; +import TrezorSendStore from '../../../stores/ada/send/TrezorSendStore'; const messages = defineMessages({ receiverLabel: { @@ -224,8 +224,8 @@ type Props = {| |}) => Promise, +ledgerSendError: null | LocalizableError, +trezorSendError: null | LocalizableError, - +ledgerSend: LedgerSendActions, - +trezorSend: TrezorSendActions, + +ledgerSend: LedgerSendStore, + +trezorSend: TrezorSendStore, |}; const SMemoTextField = styled(MemoTextField)(({ theme }) => ({ diff --git a/packages/yoroi-extension/app/components/wallet/send/WalletSendFormSteps/WalletSendPreviewStepContainer.js b/packages/yoroi-extension/app/components/wallet/send/WalletSendFormSteps/WalletSendPreviewStepContainer.js index ea39bb169a..4e34c9188d 100644 --- a/packages/yoroi-extension/app/components/wallet/send/WalletSendFormSteps/WalletSendPreviewStepContainer.js +++ b/packages/yoroi-extension/app/components/wallet/send/WalletSendFormSteps/WalletSendPreviewStepContainer.js @@ -11,11 +11,11 @@ import type { ISignRequest } from '../../../../api/common/lib/transactions/ISign import type { TokenRow } from '../../../../api/ada/lib/storage/database/primitives/tables'; import type { MultiToken, TokenLookupKey } from '../../../../api/common/lib/MultiToken'; import { ampli } from '../../../../../ampli/index'; -import TrezorSendActions from '../../../../actions/ada/trezor-send-actions'; -import LedgerSendActions from '../../../../actions/ada/ledger-send-actions'; import type { SendMoneyRequest } from '../../../../stores/toplevel/WalletStore'; import { getNetworkById } from '../../../../api/ada/lib/storage/database/prepackaged/networks'; import type { WalletState } from '../../../../../chrome/extension/background/types'; +import LedgerSendStore from '../../../../stores/ada/send/LedgerSendStore'; +import TrezorSendStore from '../../../../stores/ada/send/TrezorSendStore'; // TODO: unmagic the constants const MAX_VALUE_BYTES = 5000; @@ -50,8 +50,8 @@ type Props = {| |}) => Promise, +ledgerSendError: null | LocalizableError, +trezorSendError: null | LocalizableError, - +ledgerSend: LedgerSendActions, - +trezorSend: TrezorSendActions, + +ledgerSend: LedgerSendStore, + +trezorSend: TrezorSendStore, selectedExplorer: Map, +selectedWallet: WalletState, receiverHandle: ?{| @@ -64,8 +64,8 @@ type Props = {| export default class WalletSendPreviewStepContainer extends Component { componentWillUnmount() { this.props.sendMoneyRequest.reset(); - this.props.ledgerSend.cancel.trigger(); - this.props.trezorSend.cancel.trigger(); + this.props.ledgerSend.cancel(); + this.props.trezorSend.cancel(); } onSubmit: ({| password: string |}) => Promise = async ({ password }) => { @@ -79,13 +79,13 @@ export default class WalletSendPreviewStepContainer extends Component { }); if (selectedWallet.type === 'ledger') { - await ledgerSend.sendUsingLedgerWallet.trigger({ + await ledgerSend.sendUsingLedgerWallet({ params: { signRequest }, onSuccess: openTransactionSuccessDialog, wallet: selectedWallet, }); } else if (selectedWallet.type === 'trezor') { - await trezorSend.sendUsingTrezor.trigger({ + await trezorSend.sendUsingTrezor({ params: { signRequest }, onSuccess: openTransactionSuccessDialog, wallet: selectedWallet, diff --git a/packages/yoroi-extension/app/containers/transfer/TransferSendPage.js b/packages/yoroi-extension/app/containers/transfer/TransferSendPage.js index 4bc87996f2..31f160082a 100644 --- a/packages/yoroi-extension/app/containers/transfer/TransferSendPage.js +++ b/packages/yoroi-extension/app/containers/transfer/TransferSendPage.js @@ -29,8 +29,7 @@ import { getNetworkById } from '../../api/ada/lib/storage/database/prepackaged/n // populated by ConfigWebpackPlugin declare var CONFIG: ConfigType; -type Props = {| - ...StoresAndActionsProps, +type LocalProps = {| +onClose: {| +trigger: void => void, +label: string, @@ -49,7 +48,7 @@ type Props = {| |}; @observer -export default class TransferSendPage extends Component { +export default class TransferSendPage extends Component<{| ...StoresAndActionsProps, ...LocalProps |}> { static contextTypes: {|intl: $npm$ReactIntl$IntlFormat|} = { intl: intlShape.isRequired, @@ -67,14 +66,16 @@ export default class TransferSendPage extends Component { } componentWillUnmount() { - this.props.stores.wallets.sendMoneyRequest.reset(); + const { stores } = this.props; + stores.wallets.sendMoneyRequest.reset(); this.props.transactionRequest.reset(); - this.props.actions.ada.ledgerSend.cancel.trigger(); - this.props.actions.ada.trezorSend.cancel.trigger(); + stores.substores.ada.ledgerSend.cancel(); + stores.substores.ada.trezorSend.cancel(); } submit: void => Promise = async () => { - const selected = this.props.stores.wallets.selected; + const { stores } = this.props; + const selected = stores.wallets.selected; if (selected == null) { throw new Error(`${nameof(TransferSendPage)} no wallet selected`); } @@ -82,18 +83,18 @@ export default class TransferSendPage extends Component { if (signRequest == null) return; if (this.spendingPasswordForm == null) { if (selected.type === 'trezor') { - await this.props.actions.ada.trezorSend.sendUsingTrezor.trigger({ + await stores.substores.ada.trezorSend.sendUsingTrezor({ params: { signRequest }, wallet: selected, }); } if (selected.type === 'ledger') { - await this.props.actions.ada.ledgerSend.sendUsingLedgerWallet.trigger({ + await stores.substores.ada.ledgerSend.sendUsingLedgerWallet({ params: { signRequest }, wallet: selected, }); } - if (this.props.stores.wallets.sendMoneyRequest.error == null) { + if (stores.wallets.sendMoneyRequest.error == null) { this.props.onSubmit.trigger(); } } else { @@ -105,7 +106,7 @@ export default class TransferSendPage extends Component { password: walletPassword, wallet: selected, }); - if (this.props.stores.wallets.sendMoneyRequest.error == null) { + if (stores.wallets.sendMoneyRequest.error == null) { this.props.onSubmit.trigger(); } }, diff --git a/packages/yoroi-extension/app/containers/transfer/UpgradeTxDialogContainer.js b/packages/yoroi-extension/app/containers/transfer/UpgradeTxDialogContainer.js index 565ccbb549..5900bcd2e8 100644 --- a/packages/yoroi-extension/app/containers/transfer/UpgradeTxDialogContainer.js +++ b/packages/yoroi-extension/app/containers/transfer/UpgradeTxDialogContainer.js @@ -25,8 +25,7 @@ import { getTokenName, genLookupOrFail } from '../../stores/stateless/tokenHelpe import { truncateToken } from '../../utils/formatters'; import { getNetworkById } from '../../api/ada/lib/storage/database/prepackaged/networks'; -type Props = {| - ...StoresAndActionsProps, +type LocalProps = {| +onClose: void => void, +onSubmit: void => void, |}; @@ -40,7 +39,7 @@ const messages = defineMessages({ // TODO: probably a lot of this can be de-duplicated with TransferSendPage @observer -export default class UpgradeTxDialogContainer extends Component { +export default class UpgradeTxDialogContainer extends Component<{| ...StoresAndActionsProps, ...LocalProps |}> { static contextTypes: {|intl: $npm$ReactIntl$IntlFormat|} = { intl: intlShape.isRequired, @@ -57,7 +56,7 @@ export default class UpgradeTxDialogContainer extends Component { expectedSerial: string | void, networkId: number, |} => Promise = async (request) => { - await this.props.actions.ada.ledgerSend.sendUsingLedgerKey.trigger({ + await this.props.stores.substores.ada.ledgerSend.sendUsingLedgerKey({ ...request, }); this.props.onSubmit(); diff --git a/packages/yoroi-extension/app/containers/wallet/WalletSendPage.js b/packages/yoroi-extension/app/containers/wallet/WalletSendPage.js index b91530bf7e..49fee5cbc5 100644 --- a/packages/yoroi-extension/app/containers/wallet/WalletSendPage.js +++ b/packages/yoroi-extension/app/containers/wallet/WalletSendPage.js @@ -239,8 +239,8 @@ class WalletSendPage extends Component { sendMoney={this.props.actions.wallets.sendMoney.trigger} ledgerSendError={this.props.stores.substores.ada.ledgerSend.error || null} trezorSendError={this.props.stores.substores.ada.trezorSend.error || null} - ledgerSend={this.props.actions.ada.ledgerSend} - trezorSend={this.props.actions.ada.trezorSend} + ledgerSend={this.props.stores.substores.ada.ledgerSend} + trezorSend={this.props.stores.substores.ada.trezorSend} /> {this.renderDialog()} @@ -390,9 +390,8 @@ class WalletSendPage extends Component { infoLine2: globalMessages.txConfirmationLedgerNanoLine2, sendUsingHWButtonLabel: messages.sendUsingLedgerNano, }; - const ledgerSendAction = this.props.actions.ada.ledgerSend; - ledgerSendAction.init.trigger(); const ledgerSendStore = this.props.stores.substores.ada.ledgerSend; + ledgerSendStore.init(); hwSendConfirmationDialog = ( { isSubmitting={ledgerSendStore.isActionProcessing} error={ledgerSendStore.error} onSubmit={ - () => ledgerSendAction.sendUsingLedgerWallet.trigger({ + () => ledgerSendStore.sendUsingLedgerWallet({ params: { signRequest }, onSuccess: this.openTransactionSuccessDialog, wallet: selected, }) } - onCancel={ledgerSendAction.cancel.trigger} + onCancel={ledgerSendStore.cancel} unitOfAccountSetting={this.props.stores.profile.unitOfAccount} addressToDisplayString={addr => addressToDisplayString(addr, getNetworkById(selected.networkId)) @@ -426,7 +425,6 @@ class WalletSendPage extends Component { infoLine2: globalMessages.txConfirmationTrezorTLine2, sendUsingHWButtonLabel: messages.sendUsingTrezorT, }; - const trezorSendAction = this.props.actions.ada.trezorSend; const trezorSendStore = this.props.stores.substores.ada.trezorSend; hwSendConfirmationDialog = ( { isSubmitting={trezorSendStore.isActionProcessing} error={trezorSendStore.error} onSubmit={ - () => trezorSendAction.sendUsingTrezor.trigger({ + () => trezorSendStore.sendUsingTrezor({ params: { signRequest }, onSuccess: this.openTransactionSuccessDialog, wallet: selected, }) } - onCancel={trezorSendAction.cancel.trigger} + onCancel={trezorSendStore.cancel} unitOfAccountSetting={this.props.stores.profile.unitOfAccount} addressToDisplayString={addr => addressToDisplayString(addr, getNetworkById(selected.networkId)) diff --git a/packages/yoroi-extension/app/containers/wallet/staking/WithdrawRewardsDialog.js b/packages/yoroi-extension/app/containers/wallet/staking/WithdrawRewardsDialog.js index 91bd1f10a1..a4a977fa37 100644 --- a/packages/yoroi-extension/app/containers/wallet/staking/WithdrawRewardsDialog.js +++ b/packages/yoroi-extension/app/containers/wallet/staking/WithdrawRewardsDialog.js @@ -53,13 +53,12 @@ const messages = defineMessages({ }, }); -type Props = {| - ...StoresAndActionsProps, +type LocalProps = {| +onClose: void => void, |}; @observer -export default class WithdrawRewardsDialog extends Component { +export default class WithdrawRewardsDialog extends Component<{| ...StoresAndActionsProps, ...LocalProps |}> { static contextTypes: {| intl: $npm$ReactIntl$IntlFormat |} = { intl: intlShape.isRequired, }; @@ -72,27 +71,29 @@ export default class WithdrawRewardsDialog extends Component { } componentWillUnmount() { - this.props.stores.wallets.sendMoneyRequest.reset(); - this.props.stores.substores.ada.delegationTransaction.createWithdrawalTx.reset(); - this.props.actions.ada.ledgerSend.cancel.trigger(); - this.props.actions.ada.trezorSend.cancel.trigger(); + const { stores } = this.props; + stores.wallets.sendMoneyRequest.reset(); + stores.substores.ada.delegationTransaction.createWithdrawalTx.reset(); + stores.substores.ada.ledgerSend.cancel(); + stores.substores.ada.trezorSend.cancel(); } submit: void => Promise = async () => { - const selected = this.props.stores.wallets.selected; + const { stores } = this.props; + const selected = stores.wallets.selected; if (selected == null) throw new Error(`${nameof(WithdrawRewardsDialog)} no wallet selected`); - const signRequest = this.props.stores.substores.ada.delegationTransaction.createWithdrawalTx.result; + const signRequest = stores.substores.ada.delegationTransaction.createWithdrawalTx.result; if (signRequest == null) return; if (this.spendingPasswordForm == null) { if (selected.type === 'trezor') { - await this.props.actions.ada.trezorSend.sendUsingTrezor.trigger({ + await stores.substores.ada.trezorSend.sendUsingTrezor({ params: { signRequest }, wallet: selected, }); } if (selected.type === 'ledger') { - await this.props.actions.ada.ledgerSend.sendUsingLedgerWallet.trigger({ + await stores.substores.ada.ledgerSend.sendUsingLedgerWallet({ params: { signRequest }, wallet: selected, }); diff --git a/packages/yoroi-extension/app/stores/ada/send/LedgerSendStore.js b/packages/yoroi-extension/app/stores/ada/send/LedgerSendStore.js index c49ee9d19c..155208878c 100644 --- a/packages/yoroi-extension/app/stores/ada/send/LedgerSendStore.js +++ b/packages/yoroi-extension/app/stores/ada/send/LedgerSendStore.js @@ -1,28 +1,16 @@ // @flow import { action, observable } from 'mobx'; +import type { SignTransactionResponse as LedgerSignTxResponse } from '@cardano-foundation/ledgerjs-hw-app-cardano'; import { TxAuxiliaryDataSupplementType } from '@cardano-foundation/ledgerjs-hw-app-cardano'; -import type { - SignTransactionResponse as LedgerSignTxResponse -} from '@cardano-foundation/ledgerjs-hw-app-cardano'; import Store from '../../base/Store'; import LocalizableError from '../../../i18n/LocalizableError'; -import type { - SendUsingLedgerParams -} from '../../../actions/ada/ledger-send-actions'; +import { convertToLocalizableError } from '../../../domain/LedgerLocalizedError'; -import { - convertToLocalizableError -} from '../../../domain/LedgerLocalizedError'; - -import { - Logger, - stringifyData, - stringifyError, -} from '../../../utils/logging'; +import { Logger, stringifyData, stringifyError, } from '../../../utils/logging'; import { buildConnectorSignedTransaction, @@ -33,20 +21,23 @@ import { LedgerConnect } from '../../../utils/hwConnectHandler'; import { ROUTES } from '../../../routes-config'; import { RustModule } from '../../../api/ada/lib/cardanoCrypto/rustLoader'; import { HaskellShelleyTxSignRequest } from '../../../api/ada/transactions/shelley/HaskellShelleyTxSignRequest'; -import type { - Addressing, -} from '../../../api/ada/lib/storage/models/PublicDeriver/interfaces'; +import type { Addressing, } from '../../../api/ada/lib/storage/models/PublicDeriver/interfaces'; import { genAddressingLookup } from '../../stateless/addressStores'; import type { ActionsMap } from '../../../actions/index'; import type { StoresMap } from '../../index'; import { - generateRegistrationMetadata, generateCip15RegistrationMetadata, + generateRegistrationMetadata, } from '../../../api/ada/lib/cardanoCrypto/catalyst'; import { getNetworkById } from '../../../api/ada/lib/storage/database/prepackaged/networks.js'; import { broadcastTransaction } from '../../../api/thunk'; import { transactionHexToBodyHex, transactionHexToHash } from '../../../api/ada/lib/cardanoCrypto/utils'; import { fail } from '../../../coreUtils'; +import type { ISignRequest } from '../../../api/common/lib/transactions/ISignRequest'; + +export type SendUsingLedgerParams = {| + signRequest: ISignRequest, +|}; /** Note: Handles Ledger Signing */ export default class LedgerSendStore extends Store { @@ -56,29 +47,10 @@ export default class LedgerSendStore extends Store { @observable error: ?LocalizableError; // =================== VIEW RELATED =================== // - setup(): void { - super.setup(); - const ledgerSendAction = this.actions.ada.ledgerSend; - ledgerSendAction.init.listen(this._init); - ledgerSendAction.sendUsingLedgerWallet.listen(this._sendWrapper); - ledgerSendAction.sendUsingLedgerKey.listen( - // drop the return type - async (request) => { - await this.stores.wallets.sendAndRefresh({ - publicDeriverId: undefined, - plateTextPart: undefined, - broadcastRequest: async () => await this.signAndBroadcast(request), - refreshWallet: async () => {} - }) - } - ); - ledgerSendAction.cancel.listen(this._cancel); - } - /** setup() is called when stores are being created * _init() is called when Confirmation dialog is about to show */ - _init: void => void = () => { - Logger.debug(`${nameof(LedgerSendStore)}::${nameof(this._init)} called`); + init: void => void = () => { + Logger.debug(`${nameof(LedgerSendStore)}::${nameof(this.init)} called`); } _reset(): void { @@ -93,7 +65,26 @@ export default class LedgerSendStore extends Store { } } - _sendWrapper: {| + sendUsingLedgerKey: {| + signRequest: HaskellShelleyTxSignRequest, + publicKey: {| + key: RustModule.WalletV4.Bip32PublicKey, + ...Addressing, + |}, + publicDeriverId: number, + addressingMap: string => (void | $PropertyType), + expectedSerial: string | void, + networkId: number, + |} => Promise = async (request) => { + await this.stores.wallets.sendAndRefresh({ + publicDeriverId: undefined, + plateTextPart: undefined, + broadcastRequest: async () => await this.signAndBroadcast(request), + refreshWallet: async () => {} + }) + } + + sendUsingLedgerWallet: {| params: SendUsingLedgerParams, onSuccess?: void => void, +wallet: { @@ -113,7 +104,7 @@ export default class LedgerSendStore extends Store { throw new Error('Can’t send another transaction if one transaction is in progress.'); } if (!(request.params.signRequest instanceof HaskellShelleyTxSignRequest)) { - throw new Error(`${nameof(this._sendWrapper)} wrong tx sign request`); + throw new Error(`${nameof(this.sendUsingLedgerWallet)} wrong tx sign request`); } const { signRequest } = request.params; @@ -435,7 +426,7 @@ export default class LedgerSendStore extends Store { } }; - _cancel: void => void = () => { + cancel: void => void = () => { if (!this.isActionProcessing) { this.actions.dialogs.closeActiveDialog.trigger(); this._reset(); diff --git a/packages/yoroi-extension/app/stores/ada/send/TrezorSendStore.js b/packages/yoroi-extension/app/stores/ada/send/TrezorSendStore.js index 09d6b6d4c4..b343ff5637 100644 --- a/packages/yoroi-extension/app/stores/ada/send/TrezorSendStore.js +++ b/packages/yoroi-extension/app/stores/ada/send/TrezorSendStore.js @@ -4,7 +4,6 @@ import { action, observable } from 'mobx'; import Store from '../../base/Store'; import { wrapWithFrame } from '../../lib/TrezorWrapper'; -import type { SendUsingTrezorParams } from '../../../actions/ada/trezor-send-actions'; import { Logger, stringifyData, stringifyError, } from '../../../utils/logging'; import { convertToLocalizableError } from '../../../domain/TrezorLocalizedError'; import LocalizableError from '../../../i18n/LocalizableError'; @@ -25,6 +24,11 @@ import { broadcastTransaction } from '../../../api/thunk'; import { transactionHexToBodyHex } from '../../../api/ada/lib/cardanoCrypto/utils'; import { fail } from '../../../coreUtils'; import { genAddressingLookup } from '../../stateless/addressStores'; +import type { ISignRequest } from '../../../api/common/lib/transactions/ISignRequest'; + +export type SendUsingTrezorParams = {| + signRequest: ISignRequest, +|}; /** Note: Handles Trezor Signing */ export default class TrezorSendStore extends Store { @@ -36,20 +40,12 @@ export default class TrezorSendStore extends Store { // =================== API RELATED =================== // - setup(): void { - super.setup(); - const trezorSendAction = this.actions.ada.trezorSend; - trezorSendAction.sendUsingTrezor.listen(this._sendWrapper); - trezorSendAction.cancel.listen(this._cancel); - trezorSendAction.reset.listen(this._reset); - } - - _reset: void => void = () => { + reset: void => void = () => { this._setActionProcessing(false); this._setError(null); } - _sendWrapper: {| + sendUsingTrezor: {| params: SendUsingTrezorParams, onSuccess?: void => void, +wallet: { @@ -69,7 +65,7 @@ export default class TrezorSendStore extends Store { throw new Error('Can’t send another transaction if one transaction is in progress.'); } if (!(request.params.signRequest instanceof HaskellShelleyTxSignRequest)) { - throw new Error(`${nameof(this._sendWrapper)} wrong tx sign request`); + throw new Error(`${nameof(this.sendUsingTrezor)} wrong tx sign request`); } const { signRequest } = request.params; @@ -93,7 +89,7 @@ export default class TrezorSendStore extends Store { } else { this.actions.router.goToRoute.trigger({ route: ROUTES.WALLETS.TRANSACTIONS }); } - this._reset(); + this.reset(); Logger.info('SUCCESS: ADA sent using Trezor SignTx'); } catch (e) { @@ -333,10 +329,10 @@ export default class TrezorSendStore extends Store { } } - _cancel: void => void = () => { + cancel: void => void = () => { if (!this.isActionProcessing) { this.actions.dialogs.closeActiveDialog.trigger(); - this._reset(); + this.reset(); } } From 1643f69779b5793b601ff1f8b42e04d7f7ad805b Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Sun, 13 Oct 2024 07:43:37 +0300 Subject: [PATCH 08/38] removed address actions --- .../app/actions/common/addresses-actions.js | 13 ------------- packages/yoroi-extension/app/actions/index.js | 3 --- .../app/containers/wallet/Receive.js | 9 ++++----- .../app/containers/wallet/WalletReceivePage.js | 10 ++++++---- .../app/stores/toplevel/AddressesStore.js | 15 ++++----------- 5 files changed, 14 insertions(+), 36 deletions(-) delete mode 100644 packages/yoroi-extension/app/actions/common/addresses-actions.js diff --git a/packages/yoroi-extension/app/actions/common/addresses-actions.js b/packages/yoroi-extension/app/actions/common/addresses-actions.js deleted file mode 100644 index 96147ba240..0000000000 --- a/packages/yoroi-extension/app/actions/common/addresses-actions.js +++ /dev/null @@ -1,13 +0,0 @@ -// @flow -import { AsyncAction, Action } from '../lib/Action'; -import type { AddressFilterKind } from '../../types/AddressFilterTypes'; -import type { WalletState } from '../../../chrome/extension/background/types'; - -// ======= ADDRESSES ACTIONS ======= - -export default class AddressesActions { - createAddress: AsyncAction = new AsyncAction(); - resetErrors: Action = new Action(); - setFilter: Action = new Action(); - resetFilter: Action = new Action(); -} diff --git a/packages/yoroi-extension/app/actions/index.js b/packages/yoroi-extension/app/actions/index.js index 43c74b85ab..09c5935c83 100644 --- a/packages/yoroi-extension/app/actions/index.js +++ b/packages/yoroi-extension/app/actions/index.js @@ -7,7 +7,6 @@ import NotificationsActions from './notifications-actions'; import LoadingActions from './loading-actions'; import MemosActions from './memos-actions'; import WalletActions from './wallet-actions'; -import AddressesActions from './common/addresses-actions'; import TransactionsActions from './common/transactions-actions'; import WalletRestoreActions from './common/wallet-restore-actions'; import YoroiTransferActions from './common/yoroi-transfer-actions'; @@ -30,7 +29,6 @@ export type ActionsMap = {| memos: MemosActions, loading: LoadingActions, wallets: WalletActions, - addresses: AddressesActions, transactions: TransactionsActions, walletRestore: WalletRestoreActions, delegation: DelegationActions, @@ -51,7 +49,6 @@ const actionsMap: ActionsMap = Object.freeze({ memos: new MemosActions(), loading: new LoadingActions(), wallets: new WalletActions(), - addresses: new AddressesActions(), walletRestore: new WalletRestoreActions(), delegation: new DelegationActions(), transactions: new TransactionsActions(), diff --git a/packages/yoroi-extension/app/containers/wallet/Receive.js b/packages/yoroi-extension/app/containers/wallet/Receive.js index d070d8a233..633c630107 100644 --- a/packages/yoroi-extension/app/containers/wallet/Receive.js +++ b/packages/yoroi-extension/app/containers/wallet/Receive.js @@ -11,13 +11,12 @@ import { routeForStore, allAddressSubgroups } from '../../stores/stateless/addre import { Box } from '@mui/material'; import ReceiveWithNavigation from '../../components/wallet/layouts/ReceiveWithNavigation'; -type Props = {| - ...StoresAndActionsProps, +type LocalProps = {| +children?: Node, |}; @observer -export default class Receive extends Component { +export default class Receive extends Component<{| ...StoresAndActionsProps, ...LocalProps |}> { static defaultProps: {| children: void |} = { children: undefined, }; @@ -50,7 +49,7 @@ export default class Receive extends Component { } } componentWillUnmount() { - this.props.actions.addresses.resetFilter.trigger(); + this.props.stores.addresses.resetFilter(); } render(): Node { @@ -85,7 +84,7 @@ export default class Receive extends Component { this.props.actions.addresses.setFilter.trigger(filter)} + setFilter={filter => this.props.stores.addresses.setFilter(filter)} activeFilter={this.props.stores.addresses.addressFilter} > {this.props.children} diff --git a/packages/yoroi-extension/app/containers/wallet/WalletReceivePage.js b/packages/yoroi-extension/app/containers/wallet/WalletReceivePage.js index ec9a9fface..9779b62ade 100644 --- a/packages/yoroi-extension/app/containers/wallet/WalletReceivePage.js +++ b/packages/yoroi-extension/app/containers/wallet/WalletReceivePage.js @@ -62,22 +62,24 @@ class WalletReceivePage extends Component { componentWillUnmount() { this.closeNotification(); this.resetErrors(); - this.props.actions.addresses.resetFilter.trigger(); + this.props.stores.addresses.resetFilter(); } handleGenerateAddress: void => Promise = async () => { - const publicDeriver = this.props.stores.wallets.selected; + const { stores } = this.props; + const publicDeriver = stores.wallets.selected; if (publicDeriver != null) { + // there's gotta be a better way to render loading while waiting for a request result this.props.actions.dialogs.open.trigger({ dialog: LoadingSpinner, }); - await this.props.actions.addresses.createAddress.trigger(publicDeriver); + await stores.addresses.createAddress(publicDeriver); this.props.actions.dialogs.closeActiveDialog.trigger(); } }; resetErrors: void => void = () => { - this.props.actions.addresses.resetErrors.trigger(); + this.props.stores.addresses.resetErrors(); }; closeNotification: void => void = () => { diff --git a/packages/yoroi-extension/app/stores/toplevel/AddressesStore.js b/packages/yoroi-extension/app/stores/toplevel/AddressesStore.js index 28b29aa745..273e2389c8 100644 --- a/packages/yoroi-extension/app/stores/toplevel/AddressesStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/AddressesStore.js @@ -36,13 +36,6 @@ export default class AddressesStore extends Store { setup(): void { super.setup(); - - const actions = this.actions.addresses; - actions.createAddress.listen(this._createAddress); - actions.resetErrors.listen(this._resetErrors); - actions.setFilter.listen(this._setFilter); - actions.resetFilter.listen(this._resetFilter); - for (const store of allAddressSubgroups) { this._addressSubgroupMap.set(store.class, new store.class({ stores: this.stores, @@ -56,7 +49,7 @@ export default class AddressesStore extends Store { return this._addressSubgroupMap; } - _createAddress: WalletState => Promise = async ( + createAddress: WalletState => Promise = async ( publicDeriver ) => { try { @@ -76,7 +69,7 @@ export default class AddressesStore extends Store { return address; }; - @action _resetErrors: void => void = () => { + @action resetErrors: void => void = () => { this.error = null; }; @@ -191,11 +184,11 @@ export default class AddressesStore extends Store { return addresses; } - @action _setFilter: AddressFilterKind => void = (filter) => { + @action setFilter: AddressFilterKind => void = (filter) => { this.addressFilter = filter; } - @action _resetFilter: void => void = () => { + @action resetFilter: void => void = () => { this.addressFilter = AddressFilter.None; } } From 97f1234a011bdcbe50b18d376b88a3b526cf2043 Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Sun, 13 Oct 2024 07:48:29 +0300 Subject: [PATCH 09/38] removed delegation actions --- .../app/actions/common/delegation-actions.js | 7 ------ packages/yoroi-extension/app/actions/index.js | 3 --- .../wallet/staking/StakingDashboardPage.js | 25 ++++++++++--------- .../app/stores/toplevel/DelegationStore.js | 4 +-- 4 files changed, 14 insertions(+), 25 deletions(-) delete mode 100644 packages/yoroi-extension/app/actions/common/delegation-actions.js diff --git a/packages/yoroi-extension/app/actions/common/delegation-actions.js b/packages/yoroi-extension/app/actions/common/delegation-actions.js deleted file mode 100644 index bcfc993480..0000000000 --- a/packages/yoroi-extension/app/actions/common/delegation-actions.js +++ /dev/null @@ -1,7 +0,0 @@ -// @flow - -import { Action, } from '../lib/Action'; - -export default class DelegationActions { - setSelectedPage: Action = new Action(); -} diff --git a/packages/yoroi-extension/app/actions/index.js b/packages/yoroi-extension/app/actions/index.js index 09c5935c83..96c6838654 100644 --- a/packages/yoroi-extension/app/actions/index.js +++ b/packages/yoroi-extension/app/actions/index.js @@ -12,7 +12,6 @@ import WalletRestoreActions from './common/wallet-restore-actions'; import YoroiTransferActions from './common/yoroi-transfer-actions'; import TxBuilderActions from './common/tx-builder-actions'; import ExplorerActions from './common/explorer-actions'; -import DelegationActions from './common/delegation-actions'; import WalletSettingsActions from './common/wallet-settings-actions'; import ConnectorActionsMap from '../connector/actions/connector-actions'; import ServerConnectionActions from './server-connection-actions'; @@ -31,7 +30,6 @@ export type ActionsMap = {| wallets: WalletActions, transactions: TransactionsActions, walletRestore: WalletRestoreActions, - delegation: DelegationActions, explorers: ExplorerActions, connector: ConnectorActionsMap, serverConnection: ServerConnectionActions, @@ -50,7 +48,6 @@ const actionsMap: ActionsMap = Object.freeze({ loading: new LoadingActions(), wallets: new WalletActions(), walletRestore: new WalletRestoreActions(), - delegation: new DelegationActions(), transactions: new TransactionsActions(), explorers: new ExplorerActions(), connector: new ConnectorActionsMap(), diff --git a/packages/yoroi-extension/app/containers/wallet/staking/StakingDashboardPage.js b/packages/yoroi-extension/app/containers/wallet/staking/StakingDashboardPage.js index 8e76513317..96f2782d54 100644 --- a/packages/yoroi-extension/app/containers/wallet/staking/StakingDashboardPage.js +++ b/packages/yoroi-extension/app/containers/wallet/staking/StakingDashboardPage.js @@ -37,11 +37,12 @@ export default class StakingDashboardPage extends Component this.props.actions.delegation.setSelectedPage.trigger(page), + goToPage: page => stores.delegation.setSelectedPage(page), } } - hasAnyPending={this.props.stores.transactions.hasAnyPending} + hasAnyPending={stores.transactions.hasAnyPending} stakePools={stakePools} userSummary={this._generateUserSummary({ wallet: publicDeriver, @@ -77,18 +78,18 @@ export default class StakingDashboardPage extends Component diff --git a/packages/yoroi-extension/app/stores/toplevel/DelegationStore.js b/packages/yoroi-extension/app/stores/toplevel/DelegationStore.js index 7a8f4ed1f7..da09634cd4 100644 --- a/packages/yoroi-extension/app/stores/toplevel/DelegationStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/DelegationStore.js @@ -124,13 +124,11 @@ export default class DelegationStore extends Store { setup(): void { super.setup(); - const { delegation } = this.actions; this.registerReactions([this._changeWallets]); - delegation.setSelectedPage.listen(this._setSelectedPage); } @action - _setSelectedPage: number => void = newPage => { + setSelectedPage: number => void = newPage => { this.selectedPage = newPage; }; From fe726b16b425e33cb8a9dc5d4c852b715928871f Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Sun, 13 Oct 2024 07:55:19 +0300 Subject: [PATCH 10/38] removed explorer actions --- .../app/actions/common/explorer-actions.js | 8 -------- packages/yoroi-extension/app/actions/index.js | 3 --- .../yoroi-extension/app/connector/actions/index.js | 3 --- .../app/connector/stores/toplevel/ExplorerStore.js | 3 +-- .../settings/categories/BlockchainSettingsPage.js | 10 +++++----- .../app/stores/base/BaseExplorerStore.js | 10 ++-------- .../app/stores/toplevel/ExplorerStore.js | 3 +-- 7 files changed, 9 insertions(+), 31 deletions(-) delete mode 100644 packages/yoroi-extension/app/actions/common/explorer-actions.js diff --git a/packages/yoroi-extension/app/actions/common/explorer-actions.js b/packages/yoroi-extension/app/actions/common/explorer-actions.js deleted file mode 100644 index da976a578d..0000000000 --- a/packages/yoroi-extension/app/actions/common/explorer-actions.js +++ /dev/null @@ -1,8 +0,0 @@ -// @flow -import { AsyncAction, } from '../lib/Action'; - -export default class ExplorerActions { - updateSelectedExplorer: AsyncAction<{| - networkId: number, explorerId: string, - |}> = new AsyncAction(); -} diff --git a/packages/yoroi-extension/app/actions/index.js b/packages/yoroi-extension/app/actions/index.js index 96c6838654..698e05c469 100644 --- a/packages/yoroi-extension/app/actions/index.js +++ b/packages/yoroi-extension/app/actions/index.js @@ -11,7 +11,6 @@ import TransactionsActions from './common/transactions-actions'; import WalletRestoreActions from './common/wallet-restore-actions'; import YoroiTransferActions from './common/yoroi-transfer-actions'; import TxBuilderActions from './common/tx-builder-actions'; -import ExplorerActions from './common/explorer-actions'; import WalletSettingsActions from './common/wallet-settings-actions'; import ConnectorActionsMap from '../connector/actions/connector-actions'; import ServerConnectionActions from './server-connection-actions'; @@ -30,7 +29,6 @@ export type ActionsMap = {| wallets: WalletActions, transactions: TransactionsActions, walletRestore: WalletRestoreActions, - explorers: ExplorerActions, connector: ConnectorActionsMap, serverConnection: ServerConnectionActions, |}; @@ -49,7 +47,6 @@ const actionsMap: ActionsMap = Object.freeze({ wallets: new WalletActions(), walletRestore: new WalletRestoreActions(), transactions: new TransactionsActions(), - explorers: new ExplorerActions(), connector: new ConnectorActionsMap(), serverConnection: new ServerConnectionActions(), }); diff --git a/packages/yoroi-extension/app/connector/actions/index.js b/packages/yoroi-extension/app/connector/actions/index.js index 06d15f52a6..3e0e637553 100644 --- a/packages/yoroi-extension/app/connector/actions/index.js +++ b/packages/yoroi-extension/app/connector/actions/index.js @@ -2,11 +2,9 @@ import DialogsActions from '../../actions/dialogs-actions'; import NotificationsActions from '../../actions/notifications-actions'; import ConnectorActions from './connector-actions'; -import ExplorerActions from '../../actions/common/explorer-actions'; export type ActionsMap = {| dialogs: DialogsActions, - explorers: ExplorerActions, notifications: NotificationsActions, connector: ConnectorActions, |}; @@ -14,7 +12,6 @@ export type ActionsMap = {| const actionsMap: ActionsMap = Object.freeze({ connector: new ConnectorActions(), dialogs: new DialogsActions(), - explorers: new ExplorerActions(), notifications: new NotificationsActions(), }); diff --git a/packages/yoroi-extension/app/connector/stores/toplevel/ExplorerStore.js b/packages/yoroi-extension/app/connector/stores/toplevel/ExplorerStore.js index 9ba65ff0e2..e528d3df09 100644 --- a/packages/yoroi-extension/app/connector/stores/toplevel/ExplorerStore.js +++ b/packages/yoroi-extension/app/connector/stores/toplevel/ExplorerStore.js @@ -1,7 +1,6 @@ // @flow import BaseExplorerStore from '../../../stores/base/BaseExplorerStore'; -import type { ActionsMap } from '../../actions/index'; import type { StoresMap } from '../index'; -export default class ExplorerStore extends BaseExplorerStore { +export default class ExplorerStore extends BaseExplorerStore { } diff --git a/packages/yoroi-extension/app/containers/settings/categories/BlockchainSettingsPage.js b/packages/yoroi-extension/app/containers/settings/categories/BlockchainSettingsPage.js index caadf4342f..c160cdcea8 100644 --- a/packages/yoroi-extension/app/containers/settings/categories/BlockchainSettingsPage.js +++ b/packages/yoroi-extension/app/containers/settings/categories/BlockchainSettingsPage.js @@ -20,13 +20,13 @@ export default class BlockchainSettingsPage extends Component; - } - const { stores } = this.props; + } const { intl } = this.context; const isSubmittingExplorer = stores.explorers.setSelectedExplorerRequest.isExecuting; @@ -48,7 +48,7 @@ export default class BlockchainSettingsPage extends Component - this.props.actions.explorers.updateSelectedExplorer.trigger( + stores.explorers.setSelectedExplorer( { explorerId, networkId: selected.networkId } ) } diff --git a/packages/yoroi-extension/app/stores/base/BaseExplorerStore.js b/packages/yoroi-extension/app/stores/base/BaseExplorerStore.js index 8eeb5b2334..3134b59df8 100644 --- a/packages/yoroi-extension/app/stores/base/BaseExplorerStore.js +++ b/packages/yoroi-extension/app/stores/base/BaseExplorerStore.js @@ -10,15 +10,13 @@ import { getSelectedExplorer, getAllExplorers, saveSelectedExplorer, } from '../ import type { GetAllExplorersResponse } from '../../api/ada/lib/storage/bridge/explorers'; import { prepackagedExplorers, } from '../../api/ada/lib/storage/database/prepackaged/explorers'; import { SelectedExplorer, defaultToSelectedExplorer } from '../../domain/SelectedExplorer'; -import ExplorerActions from '../../actions/common/explorer-actions'; export default class BaseExplorerStore < TStores: { ..., - }, - TActions: { +explorers: ExplorerActions, ... }, - > extends Store { + } + > extends Store { @observable getSelectedExplorerRequest: Request = new Request(getSelectedExplorer); @@ -29,10 +27,6 @@ export default class BaseExplorerStore @observable getAllExplorerRequest: Request = new Request(getAllExplorers); - setup(): void { - this.actions.explorers.updateSelectedExplorer.listen(this.setSelectedExplorer); - } - // ========== Selected Explorer ========== // @computed get selectedExplorer(): Map { diff --git a/packages/yoroi-extension/app/stores/toplevel/ExplorerStore.js b/packages/yoroi-extension/app/stores/toplevel/ExplorerStore.js index 8a0d8dc34e..87382c0515 100644 --- a/packages/yoroi-extension/app/stores/toplevel/ExplorerStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/ExplorerStore.js @@ -1,7 +1,6 @@ // @flow import BaseExplorerStore from '../base/BaseExplorerStore'; -import type { ActionsMap } from '../../actions/index'; import type { StoresMap } from '../index'; -export default class ExplorerStore extends BaseExplorerStore { +export default class ExplorerStore extends BaseExplorerStore { } From 2f62cdbeee98a7b850d0f0ae01b26832b4d80d9c Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Sun, 13 Oct 2024 08:43:47 +0300 Subject: [PATCH 11/38] removed transactions actions --- .../actions/common/transactions-actions.js | 21 -------- packages/yoroi-extension/app/actions/index.js | 3 -- .../wallet/export/ExportTransactionDialog.js | 2 +- .../containers/wallet/WalletSummaryPage.js | 52 +++++++++---------- .../app/stores/toplevel/TransactionsStore.js | 38 +++++--------- 5 files changed, 39 insertions(+), 77 deletions(-) delete mode 100644 packages/yoroi-extension/app/actions/common/transactions-actions.js diff --git a/packages/yoroi-extension/app/actions/common/transactions-actions.js b/packages/yoroi-extension/app/actions/common/transactions-actions.js deleted file mode 100644 index 7d1d455c58..0000000000 --- a/packages/yoroi-extension/app/actions/common/transactions-actions.js +++ /dev/null @@ -1,21 +0,0 @@ -// @flow -import { AsyncAction, Action } from '../lib/Action'; -import { Moment } from 'moment'; -import type { WalletState } from '../../../chrome/extension/background/types'; - -// ======= TRANSACTIONS ACTIONS ======= - -export type TransactionRowsToExportRequest = {| - startDate: typeof Moment, - endDate: typeof Moment, -|}; - -export default class TransactionsActions { - loadMoreTransactions: AsyncAction = new AsyncAction(); - exportTransactionsToFile: AsyncAction<{| - publicDeriver: WalletState, - exportRequest: TransactionRowsToExportRequest, - |}> = new AsyncAction(); - closeExportTransactionDialog: Action = new Action(); - closeDelegationBanner: Action = new Action(); -} diff --git a/packages/yoroi-extension/app/actions/index.js b/packages/yoroi-extension/app/actions/index.js index 698e05c469..0ff640ad70 100644 --- a/packages/yoroi-extension/app/actions/index.js +++ b/packages/yoroi-extension/app/actions/index.js @@ -7,7 +7,6 @@ import NotificationsActions from './notifications-actions'; import LoadingActions from './loading-actions'; import MemosActions from './memos-actions'; import WalletActions from './wallet-actions'; -import TransactionsActions from './common/transactions-actions'; import WalletRestoreActions from './common/wallet-restore-actions'; import YoroiTransferActions from './common/yoroi-transfer-actions'; import TxBuilderActions from './common/tx-builder-actions'; @@ -27,7 +26,6 @@ export type ActionsMap = {| memos: MemosActions, loading: LoadingActions, wallets: WalletActions, - transactions: TransactionsActions, walletRestore: WalletRestoreActions, connector: ConnectorActionsMap, serverConnection: ServerConnectionActions, @@ -46,7 +44,6 @@ const actionsMap: ActionsMap = Object.freeze({ loading: new LoadingActions(), wallets: new WalletActions(), walletRestore: new WalletRestoreActions(), - transactions: new TransactionsActions(), connector: new ConnectorActionsMap(), serverConnection: new ServerConnectionActions(), }); diff --git a/packages/yoroi-extension/app/components/wallet/export/ExportTransactionDialog.js b/packages/yoroi-extension/app/components/wallet/export/ExportTransactionDialog.js index 4c4a5dc817..f2d37dfa68 100644 --- a/packages/yoroi-extension/app/components/wallet/export/ExportTransactionDialog.js +++ b/packages/yoroi-extension/app/components/wallet/export/ExportTransactionDialog.js @@ -5,7 +5,6 @@ import { observer } from 'mobx-react'; import { defineMessages, intlShape } from 'react-intl'; import LocalizableError from '../../../i18n/LocalizableError'; import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; -import type { TransactionRowsToExportRequest } from '../../../actions/common/transactions-actions'; import Dialog from '../../widgets/Dialog'; import DialogCloseButton from '../../widgets/DialogCloseButton'; import ErrorBlock from '../../widgets/ErrorBlock'; @@ -17,6 +16,7 @@ import { Moment } from 'moment'; import { withLayout } from '../../../styles/context/layout'; import type { InjectedLayoutProps } from '../../../styles/context/layout'; import { Checkbox, FormControlLabel } from '@mui/material'; +import type { TransactionRowsToExportRequest } from '../../../stores/toplevel/TransactionsStore'; const messages = defineMessages({ dialogTitle: { diff --git a/packages/yoroi-extension/app/containers/wallet/WalletSummaryPage.js b/packages/yoroi-extension/app/containers/wallet/WalletSummaryPage.js index f2aa942b30..ce405db07a 100644 --- a/packages/yoroi-extension/app/containers/wallet/WalletSummaryPage.js +++ b/packages/yoroi-extension/app/containers/wallet/WalletSummaryPage.js @@ -34,6 +34,7 @@ import BuySellDialog from '../../components/buySell/BuySellDialog'; import WalletEmptyBanner from './WalletEmptyBanner'; import { Box } from '@mui/material'; import { getNetworkById } from '../../api/ada/lib/storage/database/prepackaged/networks'; +import { noop } from '../../coreUtils'; type Props = StoresAndActionsProps; type InjectedLayoutProps = {| @@ -57,8 +58,7 @@ class WalletSummaryPage extends Component { render(): Node { const { intl } = this.context; - const actions = this.props.actions; - const { wallets } = this.props.stores; + const { actions, stores } = this.props; const { hasAny, hasMoreToLoad, @@ -68,21 +68,19 @@ class WalletSummaryPage extends Component { isExporting, exportError, isLoading, - } = this.props.stores.transactions; - const { selected } = wallets; + } = stores.transactions; + const { selected } = stores.wallets; let walletTransactions = null; // Guard against potential null values if (selected == null) { Logger.error('[WalletSummaryPage::render] Active wallet required'); return null; } - this.props.stores.delegation.checkPoolTransition(); - - const { exportTransactionsToFile, closeExportTransactionDialog } = actions.transactions; + noop(stores.delegation.checkPoolTransition()); const walletId = selected.plate.TextPart; - const { uiDialogs, profile, memos, uiNotifications } = this.props.stores; + const { uiDialogs, profile, memos, uiNotifications } = stores; const tooltipNotification = { duration: config.wallets.ADDRESS_COPY_TOOLTIP_NOTIFICATION_DURATION, @@ -116,9 +114,9 @@ class WalletSummaryPage extends Component { { @@ -127,7 +125,7 @@ class WalletSummaryPage extends Component { } isLoadingTransactions={isLoadingMore} hasMoreToLoad={hasMoreToLoad} - onLoadMore={() => actions.transactions.loadMoreTransactions.trigger(selected)} + onLoadMore={() => stores.transactions.loadMoreTransactions(selected)} assuranceMode={selected.assuranceMode} shouldHideBalance={profile.shouldHideBalance} onAddMemo={transaction => @@ -149,20 +147,20 @@ class WalletSummaryPage extends Component { }) } unitOfAccountSetting={profile.unitOfAccount} - getHistoricalPrice={this.props.stores.coinPriceStore.getHistoricalPrice} - getTokenInfo={genLookupOrNull(this.props.stores.tokenInfoStore.tokenInfo)} + getHistoricalPrice={stores.coinPriceStore.getHistoricalPrice} + getTokenInfo={genLookupOrNull(stores.tokenInfoStore.tokenInfo)} addressLookup={genAddressLookup( selected.networkId, intl, route => this.props.actions.router.goToRoute.trigger({ route }), - this.props.stores.addresses.addressSubgroupMap + stores.addresses.addressSubgroupMap )} onCopyAddressTooltip={onCopyAddressTooltip} notification={notificationToolTip} addressToDisplayString={addr => addressToDisplayString(addr, getNetworkById(selected.networkId)) } - complexityLevel={this.props.stores.profile.selectedComplexityLevel} + complexityLevel={stores.profile.selectedComplexityLevel} id="wallet:transaction-transactionsList-box" /> ); @@ -187,14 +185,14 @@ class WalletSummaryPage extends Component { isActionProcessing={isExporting} error={exportError} submit={exportRequest => - exportTransactionsToFile.trigger({ + stores.transactions.exportTransactionsToFile({ exportRequest, publicDeriver: selected, }) } - toggleIncludeTxIds={this.props.stores.transactions.toggleIncludeTxIds} - shouldIncludeTxIds={this.props.stores.transactions.shouldIncludeTxIds} - cancel={closeExportTransactionDialog.trigger} + toggleIncludeTxIds={stores.transactions.toggleIncludeTxIds} + shouldIncludeTxIds={stores.transactions.shouldIncludeTxIds} + cancel={stores.transactions.closeExportTransactionDialog} /> ); } @@ -221,8 +219,8 @@ class WalletSummaryPage extends Component { } openExportTxToFileDialog={this.openExportTransactionDialog} unitOfAccountSetting={profile.unitOfAccount} - getTokenInfo={genLookupOrFail(this.props.stores.tokenInfoStore.tokenInfo)} - getHistoricalPrice={this.props.stores.coinPriceStore.getHistoricalPrice} + getTokenInfo={genLookupOrFail(stores.tokenInfoStore.tokenInfo)} + getHistoricalPrice={stores.coinPriceStore.getHistoricalPrice} /> {walletTransactions} @@ -254,7 +252,7 @@ class WalletSummaryPage extends Component { actions.router.goToRoute.trigger({ route: ROUTES.SETTINGS.EXTERNAL_STORAGE }); }} onAcknowledge={() => { - this.props.stores.uiDialogs.getParam<(void) => void>('continuation')?.(); + stores.uiDialogs.getParam<(void) => void>('continuation')?.(); }} /> ) : null} @@ -265,7 +263,7 @@ class WalletSummaryPage extends Component { existingMemo={(() => { if (memos.selectedTransaction == null) throw new Error('no selected transaction. Should never happen'); const txid = memos.selectedTransaction.txid; - const memo = this.props.stores.memos.txMemoMap.get(walletId)?.get(txid); + const memo = stores.memos.txMemoMap.get(walletId)?.get(txid); if (memo == null) throw new Error('Should never happen'); return memo; })()} @@ -317,8 +315,8 @@ class WalletSummaryPage extends Component { } openExportTxToFileDialog={this.openExportTransactionDialog} unitOfAccountSetting={profile.unitOfAccount} - getTokenInfo={genLookupOrFail(this.props.stores.tokenInfoStore.tokenInfo)} - getHistoricalPrice={this.props.stores.coinPriceStore.getHistoricalPrice} + getTokenInfo={genLookupOrFail(stores.tokenInfoStore.tokenInfo)} + getHistoricalPrice={stores.coinPriceStore.getHistoricalPrice} shouldShowEmptyBanner={!isLoading && !hasAny} emptyBannerComponent={ this.props.actions.dialogs.open.trigger({ dialog: BuySellDialog })} /> @@ -354,7 +352,7 @@ class WalletSummaryPage extends Component { actions.router.goToRoute.trigger({ route: ROUTES.SETTINGS.EXTERNAL_STORAGE }); }} onAcknowledge={() => { - this.props.stores.uiDialogs.getParam<(void) => void>('continuation')?.(); + stores.uiDialogs.getParam<(void) => void>('continuation')?.(); }} /> ) : null} @@ -365,7 +363,7 @@ class WalletSummaryPage extends Component { existingMemo={(() => { if (memos.selectedTransaction == null) throw new Error('no selected transaction. Should never happen'); const txid = memos.selectedTransaction.txid; - const memo = this.props.stores.memos.txMemoMap.get(walletId)?.get(txid); + const memo = stores.memos.txMemoMap.get(walletId)?.get(txid); if (memo == null) throw new Error('Should never happen'); return memo; })()} diff --git a/packages/yoroi-extension/app/stores/toplevel/TransactionsStore.js b/packages/yoroi-extension/app/stores/toplevel/TransactionsStore.js index 0d9ce83087..942d9e63fb 100644 --- a/packages/yoroi-extension/app/stores/toplevel/TransactionsStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/TransactionsStore.js @@ -12,17 +12,13 @@ import type { UnconfirmedAmount } from '../../types/unconfirmedAmount.types'; import LocalizedRequest from '../lib/LocalizedRequest'; import LocalizableError, { UnexpectedError } from '../../i18n/LocalizableError'; import { Logger, stringifyError } from '../../utils/logging'; -import type { TransactionRowsToExportRequest } from '../../actions/common/transactions-actions'; import globalMessages from '../../i18n/global-messages'; -import { - isCardanoHaskell, - getNetworkById, -} from '../../api/ada/lib/storage/database/prepackaged/networks'; +import { getNetworkById, isCardanoHaskell, } from '../../api/ada/lib/storage/database/prepackaged/networks'; import { MultiToken } from '../../api/common/lib/MultiToken'; import { genLookupOrFail, getTokenName } from '../stateless/tokenHelpers'; import type { ActionsMap } from '../../actions/index'; import type { StoresMap } from '../index'; -import moment from 'moment'; +import moment, { Moment } from 'moment'; import { toRequestAddresses } from '../../api/ada/lib/storage/bridge/updateTransactions' import type { TransactionExportRow } from '../../api/export'; import type { HistoryRequest } from '../../api/ada/lib/state-fetch/types'; @@ -47,6 +43,11 @@ type TxHistoryState = {| const EXPORT_START_DELAY = 800; // in milliseconds [1000 = 1sec] +export type TransactionRowsToExportRequest = {| + startDate: typeof Moment, + endDate: typeof Moment, +|}; + export default class TransactionsStore extends Store { /** Track transactions for a set of wallets */ @observable txHistoryStates: Array = []; @@ -73,15 +74,6 @@ export default class TransactionsStore extends Store { @observable exportError: ?LocalizableError; @observable shouldIncludeTxIds: boolean = false; - setup(): void { - super.setup(); - const actions = this.actions.transactions; - actions.loadMoreTransactions.listen(this._loadMore); - actions.exportTransactionsToFile.listen(this._exportTransactionsToFile); - actions.closeExportTransactionDialog.listen(this._closeExportTransactionDialog); - actions.closeDelegationBanner.listen(this._closeDelegationBanner); - } - /** Calculate information about transactions that are still realistically reversible */ @computed get unconfirmedAmount(): UnconfirmedAmount { const defaultUnconfirmedAmount = { @@ -195,7 +187,7 @@ export default class TransactionsStore extends Store { ]); } - @action _loadMore: (WalletState) => Promise = async (publicDeriver) => { + @action loadMoreTransactions: (WalletState) => Promise = async (publicDeriver) => { const { publicDeriverId } = publicDeriver; const state = this.getTxHistoryState(publicDeriverId); const { tailRequest } = state.requests; @@ -262,7 +254,7 @@ export default class TransactionsStore extends Store { return foundState; }; - @action _exportTransactionsToFile: ({| + @action exportTransactionsToFile: ({| publicDeriver: WalletState, exportRequest: TransactionRowsToExportRequest, |}) => Promise = async (request) => { @@ -272,7 +264,7 @@ export default class TransactionsStore extends Store { this.getTransactionRowsToExportRequest.reset(); this.exportTransactions.reset(); - const continuation = await this.exportTransactionsToFile(request); + const continuation = await this._exportTransactionsToFileInternal(request); /** Intentionally added delay to feel smooth flow */ setTimeout(async () => { @@ -292,7 +284,7 @@ export default class TransactionsStore extends Store { this._setExportError(localizableError); this._setExporting(false); Logger.error( - `${nameof(TransactionsStore)}::${nameof(this._exportTransactionsToFile)} ${stringifyError( + `${nameof(TransactionsStore)}::${nameof(this.exportTransactionsToFile)} ${stringifyError( error )}` ); @@ -310,7 +302,7 @@ export default class TransactionsStore extends Store { this.exportError = error; }; - @action _closeExportTransactionDialog: void => void = () => { + @action closeExportTransactionDialog: void => void = () => { if (!this.isExporting) { this.actions.dialogs.closeActiveDialog.trigger(); this._setExporting(false); @@ -318,11 +310,7 @@ export default class TransactionsStore extends Store { } }; - @action _closeDelegationBanner: void => void = () => { - this.showDelegationBanner = false; - }; - - exportTransactionsToFile: ({| + _exportTransactionsToFileInternal: ({| +publicDeriver: WalletState, exportRequest: TransactionRowsToExportRequest, |}) => Promise<(void) => Promise> = async request => { From 4db21ceb9e0ce04bf5a6e6dc748582ca658858a7 Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Sun, 13 Oct 2024 08:48:24 +0300 Subject: [PATCH 12/38] removed loading actions --- packages/yoroi-extension/app/actions/index.js | 3 --- packages/yoroi-extension/app/actions/loading-actions.js | 8 -------- .../yoroi-extension/app/stores/toplevel/LoadingStore.js | 3 +-- .../yoroi-extension/app/stores/toplevel/ProfileStore.js | 2 +- 4 files changed, 2 insertions(+), 14 deletions(-) delete mode 100644 packages/yoroi-extension/app/actions/loading-actions.js diff --git a/packages/yoroi-extension/app/actions/index.js b/packages/yoroi-extension/app/actions/index.js index 0ff640ad70..6451b682b9 100644 --- a/packages/yoroi-extension/app/actions/index.js +++ b/packages/yoroi-extension/app/actions/index.js @@ -4,7 +4,6 @@ import WalletBackupActions from './wallet-backup-actions'; import ProfileActions from './profile-actions'; import DialogsActions from './dialogs-actions'; import NotificationsActions from './notifications-actions'; -import LoadingActions from './loading-actions'; import MemosActions from './memos-actions'; import WalletActions from './wallet-actions'; import WalletRestoreActions from './common/wallet-restore-actions'; @@ -24,7 +23,6 @@ export type ActionsMap = {| notifications: NotificationsActions, yoroiTransfer: YoroiTransferActions, memos: MemosActions, - loading: LoadingActions, wallets: WalletActions, walletRestore: WalletRestoreActions, connector: ConnectorActionsMap, @@ -41,7 +39,6 @@ const actionsMap: ActionsMap = Object.freeze({ notifications: new NotificationsActions(), yoroiTransfer: new YoroiTransferActions(), memos: new MemosActions(), - loading: new LoadingActions(), wallets: new WalletActions(), walletRestore: new WalletRestoreActions(), connector: new ConnectorActionsMap(), diff --git a/packages/yoroi-extension/app/actions/loading-actions.js b/packages/yoroi-extension/app/actions/loading-actions.js deleted file mode 100644 index 6c2f93ba35..0000000000 --- a/packages/yoroi-extension/app/actions/loading-actions.js +++ /dev/null @@ -1,8 +0,0 @@ -// @flow -import { Action } from './lib/Action'; - -// ======= LOADING ACTIONS ======= - -export default class LoadingActions { - redirect: Action = new Action(); -} diff --git a/packages/yoroi-extension/app/stores/toplevel/LoadingStore.js b/packages/yoroi-extension/app/stores/toplevel/LoadingStore.js index 15f8f2e505..2c692d3838 100644 --- a/packages/yoroi-extension/app/stores/toplevel/LoadingStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/LoadingStore.js @@ -40,7 +40,6 @@ export default class LoadingStore extends BaseLoadingStore void = () => { + redirect: void => void = () => { this._shouldRedirect = false; this.actions.router.goToRoute.trigger({ route: this._redirectUri diff --git a/packages/yoroi-extension/app/stores/toplevel/ProfileStore.js b/packages/yoroi-extension/app/stores/toplevel/ProfileStore.js index 5f834f8259..29f36ae780 100644 --- a/packages/yoroi-extension/app/stores/toplevel/ProfileStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/ProfileStore.js @@ -129,7 +129,7 @@ export default class ProfileStore extends BaseProfileStore { } } if (this.stores.loading.shouldRedirect) { - this.actions.loading.redirect.trigger(); + this.stores.loading.redirect(); } runInAction(() => { this.hasRedirected = true; From b409ae08654aceee8a2bf3f94e1a0c0940bb28b8 Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Sun, 13 Oct 2024 08:50:15 +0300 Subject: [PATCH 13/38] removed server connection actions --- packages/yoroi-extension/app/actions/index.js | 3 --- .../app/actions/server-connection-actions.js | 8 -------- 2 files changed, 11 deletions(-) delete mode 100644 packages/yoroi-extension/app/actions/server-connection-actions.js diff --git a/packages/yoroi-extension/app/actions/index.js b/packages/yoroi-extension/app/actions/index.js index 6451b682b9..e8f6355087 100644 --- a/packages/yoroi-extension/app/actions/index.js +++ b/packages/yoroi-extension/app/actions/index.js @@ -11,7 +11,6 @@ import YoroiTransferActions from './common/yoroi-transfer-actions'; import TxBuilderActions from './common/tx-builder-actions'; import WalletSettingsActions from './common/wallet-settings-actions'; import ConnectorActionsMap from '../connector/actions/connector-actions'; -import ServerConnectionActions from './server-connection-actions'; export type ActionsMap = {| txBuilderActions: TxBuilderActions, @@ -26,7 +25,6 @@ export type ActionsMap = {| wallets: WalletActions, walletRestore: WalletRestoreActions, connector: ConnectorActionsMap, - serverConnection: ServerConnectionActions, |}; const actionsMap: ActionsMap = Object.freeze({ @@ -42,7 +40,6 @@ const actionsMap: ActionsMap = Object.freeze({ wallets: new WalletActions(), walletRestore: new WalletRestoreActions(), connector: new ConnectorActionsMap(), - serverConnection: new ServerConnectionActions(), }); export default actionsMap; diff --git a/packages/yoroi-extension/app/actions/server-connection-actions.js b/packages/yoroi-extension/app/actions/server-connection-actions.js deleted file mode 100644 index 3dc262e658..0000000000 --- a/packages/yoroi-extension/app/actions/server-connection-actions.js +++ /dev/null @@ -1,8 +0,0 @@ -// @flow -import { Action } from './lib/Action'; - -// ======= WALLET ACTIONS ======= - -export default class ServerConnectionActions { - parallelSyncStateChange: Action = new Action(); -} From 160566f8b5e252ee47c3fe96555a74c8c76fb2e2 Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Sun, 13 Oct 2024 09:58:12 +0300 Subject: [PATCH 14/38] removed router actions --- packages/yoroi-extension/app/actions/index.js | 3 -- .../app/actions/router-actions.js | 16 -------- .../page-preparation/PagePreparation.js | 2 +- .../wallet/restore/RestoreWalletPage.js | 4 +- .../app/containers/ExchangeEndPage.js | 2 +- .../app/containers/NavBarContainer.js | 22 +++++------ .../app/containers/NavBarContainerRevamp.js | 33 +++++++++------- .../app/containers/SidebarContainer.js | 8 ++-- .../ConnectedWebsitesContainer.js | 4 +- .../containers/experimental/YoroiPalette.js | 4 +- .../containers/experimental/yoroiThemes.js | 4 +- .../app/containers/settings/Settings.js | 2 +- .../app/containers/swap/SwapPageContainer.js | 2 +- .../containers/swap/asset-swap/SwapPage.js | 31 ++++++++------- .../containers/transfer/YoroiTransferPage.js | 19 ++++----- .../app/containers/uri/URILandingPage.js | 7 ++-- .../app/containers/wallet/AddWalletPage.js | 16 ++++---- .../wallet/CreateWalletPageContainer.js | 2 +- .../app/containers/wallet/MyWalletsPage.js | 8 ++-- .../app/containers/wallet/Receive.js | 24 ++++++------ .../app/containers/wallet/Wallet.js | 31 ++++++++------- .../app/containers/wallet/WalletSendPage.js | 9 +++-- .../containers/wallet/WalletSummaryPage.js | 6 +-- .../dialogs/GovernanceParticipateDialog.js | 18 +++++---- .../dialogs/WalletRestoreDialogContainer.js | 2 +- .../wallet/staking/StakingPageContent.js | 2 +- packages/yoroi-extension/app/environment.js | 1 + .../ada/AdaDelegationTransactionStore.js | 2 +- .../app/stores/ada/LedgerConnectStore.js | 13 ++++--- .../app/stores/ada/TrezorConnectStore.js | 7 ++-- .../app/stores/ada/VotingStore.js | 2 +- .../stores/ada/send/AdaMnemonicSendStore.js | 9 +++-- .../app/stores/ada/send/LedgerSendStore.js | 9 +++-- .../app/stores/ada/send/TrezorSendStore.js | 9 +++-- .../app/stores/toplevel/AppStore.js | 14 ++----- .../app/stores/toplevel/LoadingStore.js | 11 +++--- .../app/stores/toplevel/ProfileStore.js | 39 ++++++++++--------- .../app/stores/toplevel/WalletStore.js | 2 +- 38 files changed, 195 insertions(+), 204 deletions(-) delete mode 100644 packages/yoroi-extension/app/actions/router-actions.js diff --git a/packages/yoroi-extension/app/actions/index.js b/packages/yoroi-extension/app/actions/index.js index e8f6355087..3a519c6367 100644 --- a/packages/yoroi-extension/app/actions/index.js +++ b/packages/yoroi-extension/app/actions/index.js @@ -1,5 +1,4 @@ // @flow -import RouterActions from './router-actions'; import WalletBackupActions from './wallet-backup-actions'; import ProfileActions from './profile-actions'; import DialogsActions from './dialogs-actions'; @@ -15,7 +14,6 @@ import ConnectorActionsMap from '../connector/actions/connector-actions'; export type ActionsMap = {| txBuilderActions: TxBuilderActions, walletSettings: WalletSettingsActions, - router: RouterActions, walletBackup: WalletBackupActions, profile: ProfileActions, dialogs: DialogsActions, @@ -30,7 +28,6 @@ export type ActionsMap = {| const actionsMap: ActionsMap = Object.freeze({ txBuilderActions: new TxBuilderActions(), walletSettings: new WalletSettingsActions(), - router: new RouterActions(), walletBackup: new WalletBackupActions(), profile: new ProfileActions(), dialogs: new DialogsActions(), diff --git a/packages/yoroi-extension/app/actions/router-actions.js b/packages/yoroi-extension/app/actions/router-actions.js deleted file mode 100644 index af31bef3aa..0000000000 --- a/packages/yoroi-extension/app/actions/router-actions.js +++ /dev/null @@ -1,16 +0,0 @@ -// @flow -import { Action } from './lib/Action'; - -// ======= ROUTER ACTIONS ======= - -export default class RouterActions { - goToRoute: Action<{| - route: string, - params?: ?Object, - publicDeriverId?: null | number, - |}> = new Action(); - redirect: Action<{| - route: string, - params?: ?Object, - |}> = new Action(); -} diff --git a/packages/yoroi-extension/app/components/page-preparation/PagePreparation.js b/packages/yoroi-extension/app/components/page-preparation/PagePreparation.js index c594ca2f55..47a1e08116 100644 --- a/packages/yoroi-extension/app/components/page-preparation/PagePreparation.js +++ b/packages/yoroi-extension/app/components/page-preparation/PagePreparation.js @@ -56,7 +56,7 @@ export default class PagePreparation extends Component {