From 830a8697c6edf8f3f0bcff1bfd7ec739502035ff Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Sat, 12 Oct 2024 21:59:12 +0300 Subject: [PATCH 01/76] 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/76] 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/76] 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/76] 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/76] 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/76] 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/76] 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/76] 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/76] 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/76] 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/76] 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/76] 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/76] 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/76] 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 { diff --git a/packages/yoroi-extension/app/components/widgets/forms/SpendingPasswordInput.js b/packages/yoroi-extension/app/components/widgets/forms/SpendingPasswordInput.js index 22078d7781..6f7840c2c3 100644 --- a/packages/yoroi-extension/app/components/widgets/forms/SpendingPasswordInput.js +++ b/packages/yoroi-extension/app/components/widgets/forms/SpendingPasswordInput.js @@ -12,7 +12,6 @@ import type { InjectedLayoutProps } from '../../../styles/context/layout'; type Props = {| +setForm: ReactToolboxMobxForm => void, - +classicTheme: boolean, +initValues?: string, +isSubmitting: boolean, |}; @@ -35,7 +34,6 @@ class SpendingPasswordInput extends Component { true} fieldName="walletPassword" validCheck={_password => true} diff --git a/packages/yoroi-extension/app/containers/profile/LanguageSelectionPage.js b/packages/yoroi-extension/app/containers/profile/LanguageSelectionPage.js index d2699437ff..bc27da1fdc 100644 --- a/packages/yoroi-extension/app/containers/profile/LanguageSelectionPage.js +++ b/packages/yoroi-extension/app/containers/profile/LanguageSelectionPage.js @@ -2,10 +2,9 @@ import type { Node } from 'react'; import { Component } from 'react'; import { observer } from 'mobx-react'; -import { defineMessages, intlShape } from 'react-intl'; +import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; +import { intlShape } from 'react-intl'; import environment from '../../environment'; -import StaticTopbarTitle from '../../components/topbar/StaticTopbarTitle'; -import TopBar from '../../components/topbar/TopBar'; import TopBarLayout from '../../components/layout/TopBarLayout'; import LanguageSelectionForm from '../../components/profile/language-selection/LanguageSelectionForm'; import type { StoresAndActionsProps } from '../../types/injectedProps.types'; @@ -13,14 +12,6 @@ import TestnetWarningBanner from '../../components/topbar/banners/TestnetWarning import ServerErrorBanner from '../../components/topbar/banners/ServerErrorBanner'; import IntroBanner from '../../components/profile/language-selection/IntroBanner'; import { ServerStatusErrors } from '../../types/serverStatusErrorType'; -import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; - -const messages = defineMessages({ - title: { - id: 'profile.languageSelect.title', - defaultMessage: '!!!Language Select', - }, -}); @observer export default class LanguageSelectionPage extends Component { @@ -53,15 +44,8 @@ export default class LanguageSelectionPage extends Component - ); const { selected } = this.props.stores.wallets; const isWalletTestnet = Boolean(selected && selected.isTestnet); - const topBar = props.stores.profile.isClassicTheme ? ( - ) : undefined; const displayedBanner = props.stores .serverConnectionStore.checkAdaServerStatus === ServerStatusErrors.Healthy ? @@ -71,7 +55,6 @@ export default class LanguageSelectionPage extends Component; return ( diff --git a/packages/yoroi-extension/app/containers/profile/UriPromptPage.js b/packages/yoroi-extension/app/containers/profile/UriPromptPage.js index c3b421c67e..7e68d40a16 100644 --- a/packages/yoroi-extension/app/containers/profile/UriPromptPage.js +++ b/packages/yoroi-extension/app/containers/profile/UriPromptPage.js @@ -51,7 +51,6 @@ export default class UriPromptPage extends Component { return ; } @@ -59,7 +58,6 @@ export default class UriPromptPage extends Component { return ; } diff --git a/packages/yoroi-extension/app/containers/settings/categories/WalletSettingsPage.js b/packages/yoroi-extension/app/containers/settings/categories/WalletSettingsPage.js index 7e98f2352b..6f5fc42b4d 100644 --- a/packages/yoroi-extension/app/containers/settings/categories/WalletSettingsPage.js +++ b/packages/yoroi-extension/app/containers/settings/categories/WalletSettingsPage.js @@ -82,7 +82,6 @@ export default class WalletSettingsPage extends Component cancelEditingWalletField.trigger()} activeField={walletFieldBeingEdited} nameValidator={name => isValidWalletName(name)} - classicTheme={profile.isClassicTheme} /> {selectedWallet.type === 'mnemonic' && ( )} { ); } @@ -159,7 +158,6 @@ export default class TransferSendPage extends Component { ? ( this.setSpendingPasswordForm(form)} - classicTheme={this.props.stores.profile.isClassicTheme} isSubmitting={this.props.stores.wallets.sendMoneyRequest.isExecuting} /> ) : null; diff --git a/packages/yoroi-extension/app/containers/transfer/YoroiPaperWalletFormPage.js b/packages/yoroi-extension/app/containers/transfer/YoroiPaperWalletFormPage.js index 84541a9f8e..dfa0010f31 100644 --- a/packages/yoroi-extension/app/containers/transfer/YoroiPaperWalletFormPage.js +++ b/packages/yoroi-extension/app/containers/transfer/YoroiPaperWalletFormPage.js @@ -29,7 +29,6 @@ type Props = {| +mnemonicLength: number, +passwordMatches: string => boolean, +includeLengthCheck: boolean, - +classicTheme: boolean, |}; @observer @@ -111,13 +110,11 @@ export default class YoroiPaperWalletFormPage extends Component { mnemonicValidator={this.props.mnemonicValidator} validWords={this.props.validWords} mnemonicLength={this.props.mnemonicLength} - classicTheme={this.props.classicTheme} /> this.setPaperPasswordFrom(form)} passwordMatches={this.props.passwordMatches} includeLengthCheck={this.props.includeLengthCheck} - classicTheme={this.props.classicTheme} /> ); diff --git a/packages/yoroi-extension/app/containers/transfer/YoroiTransferErrorPage.js b/packages/yoroi-extension/app/containers/transfer/YoroiTransferErrorPage.js index 7fed461a94..726166cea9 100644 --- a/packages/yoroi-extension/app/containers/transfer/YoroiTransferErrorPage.js +++ b/packages/yoroi-extension/app/containers/transfer/YoroiTransferErrorPage.js @@ -12,7 +12,6 @@ import { GenerateTransferTxError } from '../../api/common/errors'; type Props = {| +error?: ?LocalizableError, +onCancel: void => void, - +classicTheme: boolean, |}; @observer @@ -27,7 +26,7 @@ export default class YoroiTransferErrorPage extends Component { render(): Node { const { intl } = this.context; - const { error, onCancel, classicTheme } = this.props; + const { error, onCancel } = this.props; return ( { backButtonLabel={intl.formatMessage(globalMessages.cancel)} onCancel={onCancel} error={error} - classicTheme={classicTheme} /> ); } diff --git a/packages/yoroi-extension/app/containers/transfer/YoroiTransferPage.js b/packages/yoroi-extension/app/containers/transfer/YoroiTransferPage.js index 796af3161a..e12943dc8d 100644 --- a/packages/yoroi-extension/app/containers/transfer/YoroiTransferPage.js +++ b/packages/yoroi-extension/app/containers/transfer/YoroiTransferPage.js @@ -102,7 +102,6 @@ export default class YoroiTransferPage extends Component render(): null | Node { const { actions, stores } = this.props; - const { profile } = stores; const yoroiTransfer = this.props.stores.yoroiTransfer; const publicDeriver = this.props.stores.wallets.selected; @@ -124,7 +123,6 @@ export default class YoroiTransferPage extends Component mnemonicLength={config.wallets.YOROI_PAPER_RECOVERY_PHRASE_WORD_COUNT} passwordMatches={_password => true} includeLengthCheck={false} - classicTheme={profile.isClassicTheme} /> ); case TransferStatus.DISPLAY_CHECKSUM: @@ -188,14 +186,11 @@ export default class YoroiTransferPage extends Component ); case TransferStatus.SUCCESS: return ( - + ); default: return null; diff --git a/packages/yoroi-extension/app/containers/transfer/YoroiTransferSuccessPage.js b/packages/yoroi-extension/app/containers/transfer/YoroiTransferSuccessPage.js index 428434365f..055fe467fc 100644 --- a/packages/yoroi-extension/app/containers/transfer/YoroiTransferSuccessPage.js +++ b/packages/yoroi-extension/app/containers/transfer/YoroiTransferSuccessPage.js @@ -19,7 +19,6 @@ const messages = defineMessages({ }); type Props = {| - +classicTheme: boolean, |}; @observer @@ -30,12 +29,10 @@ export default class YoroiTransferSuccessPage extends Component { render(): Node { const { intl } = this.context; - const { classicTheme } = this.props; return (); } } diff --git a/packages/yoroi-extension/app/containers/uri/URILandingDialogContainer.js b/packages/yoroi-extension/app/containers/uri/URILandingDialogContainer.js index f963f4c9b4..cbf37c159c 100644 --- a/packages/yoroi-extension/app/containers/uri/URILandingDialogContainer.js +++ b/packages/yoroi-extension/app/containers/uri/URILandingDialogContainer.js @@ -81,7 +81,6 @@ export default class URILandingDialogContainer extends Component { ); } diff --git a/packages/yoroi-extension/app/containers/wallet/Wallet.js b/packages/yoroi-extension/app/containers/wallet/Wallet.js index f546c11519..00f70f6b94 100644 --- a/packages/yoroi-extension/app/containers/wallet/Wallet.js +++ b/packages/yoroi-extension/app/containers/wallet/Wallet.js @@ -193,7 +193,6 @@ class Wallet extends Component { {this.props.children} {isInitialSyncing && ( this.navigateToMyWallets(ROUTES.MY_WALLETS)} /> )} diff --git a/packages/yoroi-extension/app/containers/wallet/WalletReceivePage.js b/packages/yoroi-extension/app/containers/wallet/WalletReceivePage.js index a29795a278..69134a34bb 100644 --- a/packages/yoroi-extension/app/containers/wallet/WalletReceivePage.js +++ b/packages/yoroi-extension/app/containers/wallet/WalletReceivePage.js @@ -288,7 +288,6 @@ class WalletReceivePage extends Component { onGenerate={(address, amount) => { this.generateURI(address, amount); }} - classicTheme={profile.isClassicTheme} tokenInfo={defaultTokenInfo} validateAmount={(amount, tokenRow) => validateAmount( @@ -355,7 +354,6 @@ class WalletReceivePage extends Component { isHardware={isHwWallet} verify={() => actions.ada.hwVerifyAddress.verifyAddress.trigger(publicDeriver)} cancel={actions.ada.hwVerifyAddress.closeAddressDetailDialog.trigger} - classicTheme={profile.isClassicTheme} complexityLevel={profile.selectedComplexityLevel} /> ) : null} diff --git a/packages/yoroi-extension/app/containers/wallet/WalletSendPage.js b/packages/yoroi-extension/app/containers/wallet/WalletSendPage.js index b91530bf7e..b4c1900d67 100644 --- a/packages/yoroi-extension/app/containers/wallet/WalletSendPage.js +++ b/packages/yoroi-extension/app/containers/wallet/WalletSendPage.js @@ -139,7 +139,6 @@ class WalletSendPage extends Component { const { uiDialogs, - profile, transactionBuilderStore, protocolParameters, } = this.props.stores; @@ -199,7 +198,6 @@ class WalletSendPage extends Component { onSubmit={txBuilderActions.updateTentativeTx.trigger} totalInput={transactionBuilderStore.totalInput} hasAnyPending={hasAnyPending} - isClassicTheme={profile.isClassicTheme} shouldSendAll={transactionBuilderStore.shouldSendAll} updateReceiver={(addr: void | string) => txBuilderActions.updateReceiver.trigger(addr)} updateAmount={(value: ?BigNumber) => txBuilderActions.updateAmount.trigger(value)} @@ -264,7 +262,6 @@ class WalletSendPage extends Component { onSubmit={onSubmit} totalInput={transactionBuilderStore.totalInput} hasAnyPending={hasAnyPending} - classicTheme={profile.isClassicTheme} updateReceiver={(addr: void | string) => txBuilderActions.updateReceiver.trigger(addr)} updateAmount={(value: ?BigNumber) => txBuilderActions.updateAmount.trigger(value)} updateMemo={(content: void | string) => txBuilderActions.updateMemo.trigger(content)} @@ -309,7 +306,6 @@ class WalletSendPage extends Component { ); } @@ -556,7 +552,6 @@ class WalletSendPage extends Component { onClose={this.props.actions.dialogs.closeActiveDialog.trigger} spendableBalance={this.props.stores.transactions.balance} getTokenInfo={genLookupOrFail(this.props.stores.tokenInfoStore.tokenInfo)} - classicTheme={this.props.stores.profile.isClassicTheme} updateAmount={(value: ?BigNumber) => txBuilderActions.updateAmount.trigger(value)} onAddToken={txBuilderActions.addToken.trigger} onRemoveTokens={txBuilderActions.removeTokens.trigger} diff --git a/packages/yoroi-extension/app/containers/wallet/WalletSummaryPage.js b/packages/yoroi-extension/app/containers/wallet/WalletSummaryPage.js index f2aa942b30..10d40f11b0 100644 --- a/packages/yoroi-extension/app/containers/wallet/WalletSummaryPage.js +++ b/packages/yoroi-extension/app/containers/wallet/WalletSummaryPage.js @@ -241,7 +241,6 @@ class WalletSummaryPage extends Component { onSubmit={values => { return actions.memos.saveTxMemo.trigger(values); }} - classicTheme={profile.isClassicTheme} plateTextPart={selected.plate.TextPart} /> ) : null} @@ -275,7 +274,6 @@ class WalletSummaryPage extends Component { onSubmit={values => { return actions.memos.updateTxMemo.trigger(values); }} - classicTheme={profile.isClassicTheme} plateTextPart={selected.plate.TextPart} /> ) : null} @@ -341,7 +339,6 @@ class WalletSummaryPage extends Component { onSubmit={values => { return actions.memos.saveTxMemo.trigger(values); }} - classicTheme={profile.isClassicTheme} plateTextPart={selected.plate.TextPart} /> ) : null} @@ -375,7 +372,6 @@ class WalletSummaryPage extends Component { onSubmit={values => { return actions.memos.updateTxMemo.trigger(values); }} - classicTheme={profile.isClassicTheme} plateTextPart={selected.plate.TextPart} /> ) : null} diff --git a/packages/yoroi-extension/app/containers/wallet/dialogs/ChangeWalletPasswordDialogContainer.js b/packages/yoroi-extension/app/containers/wallet/dialogs/ChangeWalletPasswordDialogContainer.js index 5af7f37df9..6286769fc2 100644 --- a/packages/yoroi-extension/app/containers/wallet/dialogs/ChangeWalletPasswordDialogContainer.js +++ b/packages/yoroi-extension/app/containers/wallet/dialogs/ChangeWalletPasswordDialogContainer.js @@ -47,7 +47,6 @@ export default class ChangeWalletPasswordDialogContainer extends Component ); diff --git a/packages/yoroi-extension/app/containers/wallet/dialogs/WalletBackupDialogContainer.js b/packages/yoroi-extension/app/containers/wallet/dialogs/WalletBackupDialogContainer.js index 6caa327a43..098f1c4081 100644 --- a/packages/yoroi-extension/app/containers/wallet/dialogs/WalletBackupDialogContainer.js +++ b/packages/yoroi-extension/app/containers/wallet/dialogs/WalletBackupDialogContainer.js @@ -78,7 +78,6 @@ export default class WalletBackupDialogContainer extends Component { }} onRestartBackup={restartWalletBackup.trigger} recoveryPhraseSorted={recoveryPhraseSorted} - classicTheme={stores.profile.isClassicTheme} /> ); } diff --git a/packages/yoroi-extension/app/containers/wallet/dialogs/WalletCreateDialogContainer.js b/packages/yoroi-extension/app/containers/wallet/dialogs/WalletCreateDialogContainer.js index 6c5ffb38fb..f93e28cc16 100644 --- a/packages/yoroi-extension/app/containers/wallet/dialogs/WalletCreateDialogContainer.js +++ b/packages/yoroi-extension/app/containers/wallet/dialogs/WalletCreateDialogContainer.js @@ -15,7 +15,6 @@ export default class WalletCreateDialogContainer extends Component { render(): Node { return ( diff --git a/packages/yoroi-extension/app/containers/wallet/dialogs/WalletLedgerConnectDialogContainer.js b/packages/yoroi-extension/app/containers/wallet/dialogs/WalletLedgerConnectDialogContainer.js index 83d3cffa59..5b617df033 100644 --- a/packages/yoroi-extension/app/containers/wallet/dialogs/WalletLedgerConnectDialogContainer.js +++ b/packages/yoroi-extension/app/containers/wallet/dialogs/WalletLedgerConnectDialogContainer.js @@ -39,7 +39,6 @@ export default class WalletLedgerConnectDialogContainer extends Component 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; @@ -55,7 +54,6 @@ export default class WalletLedgerConnectDialogContainer extends Component onExternalLinkClick={handleExternalLinkClick} submit={hwConnectActions.submitCheck.trigger} cancel={this.cancel} - classicTheme={profile.isClassicTheme} onBack={this.props.onBack} />); break; @@ -69,7 +67,6 @@ export default class WalletLedgerConnectDialogContainer extends Component goBack={hwConnectActions.goBackToCheck.trigger} submit={hwConnectActions.submitConnect.trigger} cancel={this.cancel} - classicTheme={profile.isClassicTheme} />); break; case ProgressStep.TRANSFER: @@ -91,7 +88,6 @@ export default class WalletLedgerConnectDialogContainer extends Component onExternalLinkClick={handleExternalLinkClick} submit={hwConnectActions.submitSave.trigger} cancel={this.cancel} - classicTheme={profile.isClassicTheme} />); break; default: diff --git a/packages/yoroi-extension/app/containers/wallet/dialogs/WalletRestoreDialogContainer.js b/packages/yoroi-extension/app/containers/wallet/dialogs/WalletRestoreDialogContainer.js index 98eb6a6a1b..003e583fbf 100644 --- a/packages/yoroi-extension/app/containers/wallet/dialogs/WalletRestoreDialogContainer.js +++ b/packages/yoroi-extension/app/containers/wallet/dialogs/WalletRestoreDialogContainer.js @@ -121,7 +121,6 @@ export default class WalletRestoreDialogContainer extends Component { onCancel={this.onCancel} onBack={this.props.onBack} error={restoreRequest.error} - classicTheme={this.props.stores.profile.isClassicTheme} initValues={walletRestore.walletRestoreMeta} introMessage={this.props.introMessage || ''} /> @@ -215,7 +214,6 @@ export default class WalletRestoreDialogContainer extends Component { onClose={this.onCancel} onSkip={walletRestoreActions.startRestore.trigger} onCheck={walletRestoreActions.startCheck.trigger} - classicTheme={this.props.stores.profile.isClassicTheme} isSubmitting={restoreRequest.isExecuting} /> ); @@ -232,7 +230,6 @@ export default class WalletRestoreDialogContainer extends Component { const { yoroiTransfer } = this.props.stores; const walletRestoreActions = this.props.actions.walletRestore; - const { profile } = this.props.stores; const { intl } = this.context; switch (yoroiTransfer.status) { @@ -290,7 +287,6 @@ export default class WalletRestoreDialogContainer extends Component { onCancel={this.onCancel} title="" backButtonLabel={intl.formatMessage(globalMessages.cancel)} - classicTheme={profile.isClassicTheme} /> ); } @@ -298,7 +294,6 @@ export default class WalletRestoreDialogContainer extends Component { addressToDisplayString(addr, getNetworkById(publicDeriver.networkId)) diff --git a/packages/yoroi-extension/app/containers/wallet/dialogs/WalletTrezorConnectDialogContainer.js b/packages/yoroi-extension/app/containers/wallet/dialogs/WalletTrezorConnectDialogContainer.js index 25fbda6f57..ac53435254 100644 --- a/packages/yoroi-extension/app/containers/wallet/dialogs/WalletTrezorConnectDialogContainer.js +++ b/packages/yoroi-extension/app/containers/wallet/dialogs/WalletTrezorConnectDialogContainer.js @@ -37,7 +37,6 @@ export default class WalletTrezorConnectDialogContainer extends Component }; render(): null | Node { - const { profile } = this.props.stores; const trezorConnectStore = this.props.stores.substores.ada.trezorConnect; const hwConnectActions = this.props.actions.ada.trezorConnect; @@ -54,7 +53,6 @@ export default class WalletTrezorConnectDialogContainer extends Component submit={hwConnectActions.submitCheck.trigger} cancel={this.cancel} onBack={this.props.onBack} - classicTheme={profile.isClassicTheme} />); break; case ProgressStep.CONNECT: @@ -67,7 +65,6 @@ export default class WalletTrezorConnectDialogContainer extends Component goBack={hwConnectActions.goBackToCheck.trigger} submit={hwConnectActions.submitConnect.trigger} cancel={this.cancel} - classicTheme={profile.isClassicTheme} />); break; case ProgressStep.SAVE: @@ -80,7 +77,6 @@ export default class WalletTrezorConnectDialogContainer extends Component onExternalLinkClick={handleExternalLinkClick} submit={hwConnectActions.submitSave.trigger} cancel={this.cancel} - classicTheme={profile.isClassicTheme} />); break; default: 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..b6bbdff9ad 100644 --- a/packages/yoroi-extension/app/containers/wallet/dialogs/voting/RegisterDialogContainer.js +++ b/packages/yoroi-extension/app/containers/wallet/dialogs/voting/RegisterDialogContainer.js @@ -21,7 +21,6 @@ type Props = {| +cancel: void => void, +goBack: void => void, +onError: Error => void, - +classicTheme: boolean, |}; type InjectedLayoutProps = {| @@ -37,7 +36,7 @@ class RegisterDialogContainer extends Component { }; render(): Node { - const { submit, cancel, onError, classicTheme, stepsList } = this.props; + const { submit, cancel, onError, stepsList } = this.props; const votingStore = this.props.stores.substores.ada.votingStore; if (votingStore.createVotingRegTx.error != null) { @@ -62,7 +61,6 @@ class RegisterDialogContainer extends Component { }} isProcessing={votingStore.isActionProcessing} cancel={cancel} - classicTheme={classicTheme} isRevamp={this.props.isRevampLayout} /> ); 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..68ec3977fb 100644 --- a/packages/yoroi-extension/app/containers/wallet/dialogs/voting/TransactionDialogContainer.js +++ b/packages/yoroi-extension/app/containers/wallet/dialogs/voting/TransactionDialogContainer.js @@ -16,7 +16,6 @@ type Props = {| +submit: void => PossiblyAsync, +cancel: void => void, +goBack: void => void, - +classicTheme: boolean, +onError: Error => void, +walletType: WalletType, |}; @@ -64,7 +63,6 @@ class TransactionDialogContainer extends Component { onError(error); } }} - classicTheme={this.props.classicTheme} error={votingStore.error} walletType={walletType} isRevamp={this.props.isRevampLayout} 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..8c807fe5aa 100644 --- a/packages/yoroi-extension/app/containers/wallet/dialogs/voting/VotingRegistrationDialogContainer.js +++ b/packages/yoroi-extension/app/containers/wallet/dialogs/voting/VotingRegistrationDialogContainer.js @@ -48,7 +48,6 @@ class VotingRegistrationDialogContainer extends Component { return ; } - const { profile } = this.props.stores; const votingActions = this.props.actions.ada.voting; const walletType = this.props.walletType; const stepsList = [ @@ -72,7 +71,6 @@ class VotingRegistrationDialogContainer extends Component { pin={votingStore.pin} next={votingActions.submitGenerate.trigger} cancel={this.cancel} - classicTheme={profile.isClassicTheme} onBack={this.props.onClose} isRevamp={this.props.isRevampLayout} /> @@ -88,7 +86,6 @@ class VotingRegistrationDialogContainer extends Component { submit={votingActions.submitConfirm.trigger} error={votingActions.submitConfirmError.trigger} cancel={this.cancel} - classicTheme={profile.isClassicTheme} pinValidation={enteredPin => { const pin = votingStore.pin.join(''); return pin === enteredPin; @@ -106,7 +103,6 @@ class VotingRegistrationDialogContainer extends Component { submit={votingActions.submitRegister.trigger} goBack={votingActions.goBackToRegister.trigger} cancel={this.cancel} - classicTheme={profile.isClassicTheme} onError={votingActions.submitRegisterError.trigger} /> ); @@ -117,7 +113,6 @@ class VotingRegistrationDialogContainer extends Component { actions={actions} stores={stores} stepsList={stepsList} - classicTheme={profile.isClassicTheme} cancel={this.cancel} submit={votingActions.submitTransaction.trigger} goBack={votingActions.goBackToRegister.trigger} @@ -134,7 +129,6 @@ class VotingRegistrationDialogContainer extends Component { onExternalLinkClick={handleExternalLinkClick} submit={votingActions.finishQRCode.trigger} cancel={this.cancel} - classicTheme={profile.isClassicTheme} votingKey={votingStore.encryptedKey} /> ); diff --git a/packages/yoroi-extension/app/containers/wallet/staking/CardanoStakingPage.js b/packages/yoroi-extension/app/containers/wallet/staking/CardanoStakingPage.js index 784f76de28..f9ac11fb30 100644 --- a/packages/yoroi-extension/app/containers/wallet/staking/CardanoStakingPage.js +++ b/packages/yoroi-extension/app/containers/wallet/staking/CardanoStakingPage.js @@ -259,7 +259,6 @@ class CardanoStakingPage extends Component { } hash={selectedPoolInfo.poolId} moreInfo={moreInfo} - classicTheme={this.props.stores.profile.isClassicTheme} onCopyAddressTooltip={(address, elementId) => { if (!this.props.stores.uiNotifications.isOpen(elementId)) { runInAction(() => { @@ -422,7 +421,6 @@ class CardanoStakingPage extends Component { dialog: DelegationSuccessDialog, }); }} - classicTheme={this.props.stores.profile.isClassicTheme} error={this.props.stores.wallets.sendMoneyRequest.error} selectedExplorer={ this.props.stores.explorers.selectedExplorer.get( @@ -439,7 +437,6 @@ class CardanoStakingPage extends Component { return ( ); } diff --git a/packages/yoroi-extension/app/containers/wallet/staking/StakingDashboardPage.js b/packages/yoroi-extension/app/containers/wallet/staking/StakingDashboardPage.js index 36c596f408..0bdf692a3b 100644 --- a/packages/yoroi-extension/app/containers/wallet/staking/StakingDashboardPage.js +++ b/packages/yoroi-extension/app/containers/wallet/staking/StakingDashboardPage.js @@ -184,7 +184,6 @@ export default class StakingDashboardPage extends Component { if (!uiNotifications.isOpen(elementId)) { runInAction(() => { diff --git a/packages/yoroi-extension/app/containers/wallet/staking/WithdrawRewardsDialog.js b/packages/yoroi-extension/app/containers/wallet/staking/WithdrawRewardsDialog.js index 91bd1f10a1..c7cade6465 100644 --- a/packages/yoroi-extension/app/containers/wallet/staking/WithdrawRewardsDialog.js +++ b/packages/yoroi-extension/app/containers/wallet/staking/WithdrawRewardsDialog.js @@ -161,7 +161,7 @@ export default class WithdrawRewardsDialog extends Component { const formatValue = genFormatTokenAmount(genLookupOrFail(this.props.stores.tokenInfoStore.tokenInfo)); if (createWithdrawalTx.error != null) - return ; + return ; const tentativeTx = createWithdrawalTx.result; if (!tentativeTx) @@ -194,7 +194,6 @@ export default class WithdrawRewardsDialog extends Component { publicDeriver.type !== 'mnemonic' ? undefined : ( this.setSpendingPasswordForm(form)} - classicTheme={false} isSubmitting={isSubmitting} /> ); diff --git a/packages/yoroi-extension/app/stores/base/BaseProfileStore.js b/packages/yoroi-extension/app/stores/base/BaseProfileStore.js index 9d1ac851a7..d557a508ec 100644 --- a/packages/yoroi-extension/app/stores/base/BaseProfileStore.js +++ b/packages/yoroi-extension/app/stores/base/BaseProfileStore.js @@ -327,20 +327,6 @@ export default class BaseProfileStore return true; } - /** - * - */ - @computed get isModernTheme(): boolean { - return false; - } - - /** - * - */ - @computed get isClassicTheme(): boolean { - return false; - } - /** * */ From a9f10663801a7b76e7e50f15c750a397e0dea3ae Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Sun, 13 Oct 2024 16:49:23 +0300 Subject: [PATCH 16/76] removed legacy `isRevampTheme`, `isCurrentThemeSet`, `didUserMigratedToRevampTheme`, `hasLoadedCurrentTheme`, `hasCustomTheme` --- .../app/components/common/TextField.js | 1 + .../app/components/loading/Loading.js | 7 +- .../settings/ChangeWalletPasswordDialog.js | 1 - .../app/containers/LoadingPage.js | 1 - .../categories/BlockchainSettingsPage.js | 9 +- .../categories/GeneralSettingsPage.js | 10 +-- .../settings/categories/WalletSettingsPage.js | 10 +-- .../app/containers/transfer/Transfer.js | 3 - .../app/containers/wallet/AddWalletPage.js | 5 -- .../app/containers/wallet/Wallet.js | 90 +++---------------- .../ChangeWalletPasswordDialogContainer.js | 3 +- .../ada/AdaDelegationTransactionStore.js | 5 +- .../app/stores/base/BaseProfileStore.js | 36 -------- .../app/stores/toplevel/ProfileStore.js | 25 ++---- .../app/styles/context/layout.js | 10 +-- 15 files changed, 38 insertions(+), 178 deletions(-) diff --git a/packages/yoroi-extension/app/components/common/TextField.js b/packages/yoroi-extension/app/components/common/TextField.js index a064830dd1..4ac89485a9 100644 --- a/packages/yoroi-extension/app/components/common/TextField.js +++ b/packages/yoroi-extension/app/components/common/TextField.js @@ -69,6 +69,7 @@ function TextField({ event.preventDefault(); }; + // pending removal cuz always true? the `-light` part is SUS const isRevampTheme = appTheme.name === 'revamp-light'; return ( diff --git a/packages/yoroi-extension/app/components/loading/Loading.js b/packages/yoroi-extension/app/components/loading/Loading.js index 0aa25ae35e..f6f88d96d5 100644 --- a/packages/yoroi-extension/app/components/loading/Loading.js +++ b/packages/yoroi-extension/app/components/loading/Loading.js @@ -22,7 +22,6 @@ const messages = defineMessages({ type Props = {| +isLoadingDataForNextScreen: boolean, +hasLoadedCurrentLocale: boolean, - +hasLoadedCurrentTheme: boolean, +error: ?LocalizableError, +onExternalLinkClick: MouseEvent => void, +downloadLogs: void => void @@ -40,17 +39,13 @@ export default class Loading extends Component { const { isLoadingDataForNextScreen, hasLoadedCurrentLocale, - hasLoadedCurrentTheme, error } = this.props; const componentStyles = classNames([ styles.component, ]); - const yoroiLogoStyles = classNames([ - styles.yoroiLogo, - hasLoadedCurrentTheme ? null : styles.hide, - ]); + const yoroiLogoStyles = classNames([styles.yoroiLogo]); const renderError = error != null && hasLoadedCurrentLocale ? (

diff --git a/packages/yoroi-extension/app/components/wallet/settings/ChangeWalletPasswordDialog.js b/packages/yoroi-extension/app/components/wallet/settings/ChangeWalletPasswordDialog.js index 5b3cdf2858..2289635af5 100644 --- a/packages/yoroi-extension/app/components/wallet/settings/ChangeWalletPasswordDialog.js +++ b/packages/yoroi-extension/app/components/wallet/settings/ChangeWalletPasswordDialog.js @@ -43,7 +43,6 @@ type Props = {| +onPasswordSwitchToggle: void => void, +isSubmitting: boolean, +error: ?LocalizableError, - +isRevampTheme: boolean, |}; @observer diff --git a/packages/yoroi-extension/app/containers/LoadingPage.js b/packages/yoroi-extension/app/containers/LoadingPage.js index e9f65118b8..fe406b7211 100644 --- a/packages/yoroi-extension/app/containers/LoadingPage.js +++ b/packages/yoroi-extension/app/containers/LoadingPage.js @@ -16,7 +16,6 @@ export default class LoadingPage extends Component { ; @@ -41,11 +40,9 @@ export default class BlockchainSettingsPage extends Component - {profileStore.isRevampTheme && ( - - {intl.formatMessage(settingsMenuMessages.blockchain)} - - )} + + {intl.formatMessage(settingsMenuMessages.blockchain)} + this.props.actions.explorers.updateSelectedExplorer.trigger( diff --git a/packages/yoroi-extension/app/containers/settings/categories/GeneralSettingsPage.js b/packages/yoroi-extension/app/containers/settings/categories/GeneralSettingsPage.js index 7ac21bf539..750ea1c228 100644 --- a/packages/yoroi-extension/app/containers/settings/categories/GeneralSettingsPage.js +++ b/packages/yoroi-extension/app/containers/settings/categories/GeneralSettingsPage.js @@ -93,12 +93,10 @@ export default class GeneralSettingsPage extends Component - {profileStore.isRevampTheme && ( - - {intl.formatMessage(settingsMenuMessages.general)} - - )} + + + {intl.formatMessage(settingsMenuMessages.general)} + {this.getDialog(selectedWallet.publicDeriverId)} - {profile.isRevampTheme && ( - - {intl.formatMessage(globalMessages.walletLabel)} - - )} + + {intl.formatMessage(globalMessages.walletLabel)} + { render(): Node { const { actions, stores } = this.props; - if (this.props.stores.profile.isRevampTheme) { - return null; - } const sidebarContainer = ; const navbar = ( { this.props.actions.dialogs.open.trigger({ dialog }); }; - componentDidMount() { - const { isRevampTheme } = this.props.stores.profile; - if (!isRevampTheme) this.props.actions.wallets.unselectWallet.trigger(); - } - render(): Node { const { selectedNetwork } = this.props.stores.profile; const { actions, stores } = this.props; diff --git a/packages/yoroi-extension/app/containers/wallet/Wallet.js b/packages/yoroi-extension/app/containers/wallet/Wallet.js index 00f70f6b94..90a7c9cdbe 100644 --- a/packages/yoroi-extension/app/containers/wallet/Wallet.js +++ b/packages/yoroi-extension/app/containers/wallet/Wallet.js @@ -1,48 +1,32 @@ // @flow +import type { Node } from 'react'; import { Component } from 'react'; -import type { Node, ComponentType } from 'react'; import { observer } from 'mobx-react'; -import { intlShape, defineMessages } from 'react-intl'; +import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; +import { intlShape } from 'react-intl'; import TopBarLayout from '../../components/layout/TopBarLayout'; import VerticallyCenteredLayout from '../../components/layout/VerticallyCenteredLayout'; import SidebarContainer from '../SidebarContainer'; import NavBarContainer from '../NavBarContainer'; import BannerContainer from '../banners/BannerContainer'; -import WalletWithNavigation from '../../components/wallet/layouts/WalletWithNavigation'; -import NavBarBack from '../../components/topbar/NavBarBack'; import LoadingSpinner from '../../components/widgets/LoadingSpinner'; import { ROUTES } from '../../routes-config'; -import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; import type { StoresAndActionsProps } from '../../types/injectedProps.types'; -import { allCategories, allSubcategoriesRevamp } from '../../stores/stateless/topbarCategories'; -import { withLayout } from '../../styles/context/layout'; -import type { LayoutComponentMap } from '../../styles/context/layout'; +import { allSubcategoriesRevamp } from '../../stores/stateless/topbarCategories'; import NavBarContainerRevamp from '../NavBarContainerRevamp'; import globalMessages from '../../i18n/global-messages'; import NavBarTitle from '../../components/topbar/NavBarTitle'; import SubMenu from '../../components/topbar/SubMenu'; -import WalletSyncingOverlay from '../../components/wallet/syncingOverlay/WalletSyncingOverlay'; import WalletLoadingAnimation from '../../components/wallet/WalletLoadingAnimation'; import { RevampAnnouncementDialog } from './dialogs/RevampAnnouncementDialog'; import { PoolTransitionDialog } from './dialogs/pool-transition/PoolTransitionDialog'; import { Redirect } from 'react-router'; type Props = {| - ...StoresAndActionsProps, +children: Node, |}; -type InjectedLayoutProps = {| +renderLayoutComponent: LayoutComponentMap => Node |}; -type AllProps = {| ...Props, ...InjectedLayoutProps |}; - -const messages = defineMessages({ - backButton: { - id: 'wallet.nav.backButton', - defaultMessage: '!!!Back to my wallets', - }, -}); - @observer -class Wallet extends Component { +export default class Wallet extends Component<{| ...Props, ...StoresAndActionsProps |}> { static contextTypes: {| intl: $npm$ReactIntl$IntlFormat |} = { intl: intlShape.isRequired, }; @@ -53,10 +37,8 @@ class Wallet extends Component { } checkRoute(): void | string { - const isRevamp = this.props.stores.profile.isRevampTheme; - const categories = isRevamp ? allSubcategoriesRevamp : allCategories; - - if (isRevamp && this.props.stores.app.currentRoute.startsWith(ROUTES.TRANSFER.ROOT)) { + const categories = allSubcategoriesRevamp; + if (this.props.stores.app.currentRoute.startsWith(ROUTES.TRANSFER.ROOT)) { return ROUTES.WALLETS.TRANSACTIONS; } @@ -104,7 +86,7 @@ class Wallet extends Component { return ; } const { intl } = this.context; - const selectedWallet = stores.wallets.selected; + const selectedWallet = stores.wallets.selectedOrFail; if (!selectedWallet) { return ( @@ -121,7 +103,6 @@ class Wallet extends Component { ); } const warning = this.getWarning(selectedWallet.publicDeriverId); - if (selectedWallet == null) throw new Error(`${nameof(Wallet)} no public deriver`); const isInitialSyncing = stores.wallets.isInitialSyncing(selectedWallet.publicDeriverId); const spendableBalance = stores.transactions.balance; @@ -155,60 +136,16 @@ class Wallet extends Component { ); const sidebarContainer = ; - const walletClassic = ( - } - sidebar={sidebarContainer} - navbar={ - - } - /> - } - showInContainer - showAsCard - > - {warning} - c.isVisible(visibilityContext)) - .map(category => ({ - className: category.className, - icon: category.icon, - label: category.label, - isActive: this.props.stores.app.currentRoute.startsWith(category.route), - onClick: () => - this.props.actions.router.goToRoute.trigger({ - route: category.route, - }), - }))} - > - {this.props.children} - {isInitialSyncing && ( - this.navigateToMyWallets(ROUTES.MY_WALLETS)} - /> - )} - - - ); - const walletRevamp = ( + return ( } + banner={} sidebar={sidebarContainer} navbar={ } + title={} menu={isInitialSyncing ? null : menu} /> } @@ -217,7 +154,7 @@ class Wallet extends Component { > {warning} {isInitialSyncing ? ( - + ) : ( <> {this.props.children} @@ -226,8 +163,6 @@ class Wallet extends Component { )} ); - - return this.props.renderLayoutComponent({ CLASSIC: walletClassic, REVAMP: walletRevamp }); } getWarning: (number) => void | Node = publicDeriverId => { @@ -283,4 +218,3 @@ class Wallet extends Component { return null; }; } -export default (withLayout(Wallet): ComponentType); diff --git a/packages/yoroi-extension/app/containers/wallet/dialogs/ChangeWalletPasswordDialogContainer.js b/packages/yoroi-extension/app/containers/wallet/dialogs/ChangeWalletPasswordDialogContainer.js index 6286769fc2..6cc443ce0e 100644 --- a/packages/yoroi-extension/app/containers/wallet/dialogs/ChangeWalletPasswordDialogContainer.js +++ b/packages/yoroi-extension/app/containers/wallet/dialogs/ChangeWalletPasswordDialogContainer.js @@ -15,7 +15,7 @@ export default class ChangeWalletPasswordDialogContainer extends Component ); } diff --git a/packages/yoroi-extension/app/stores/ada/AdaDelegationTransactionStore.js b/packages/yoroi-extension/app/stores/ada/AdaDelegationTransactionStore.js index f29a173354..9d83494f5b 100644 --- a/packages/yoroi-extension/app/stores/ada/AdaDelegationTransactionStore.js +++ b/packages/yoroi-extension/app/stores/ada/AdaDelegationTransactionStore.js @@ -1,6 +1,6 @@ // @flow -import { observable, action, reaction } from 'mobx'; +import { action, observable, reaction } from 'mobx'; import BigNumber from 'bignumber.js'; import Store from '../base/Store'; import LocalizedRequest from '../lib/LocalizedRequest'; @@ -194,8 +194,7 @@ export default class AdaDelegationTransactionStore extends Store - */ - @computed get isRevampTheme(): boolean { - return true; - } - - /** - * - */ - @computed get isCurrentThemeSet(): boolean { - return true; - } - - /** - * - */ - @computed get didUserMigratedToRevampTheme(): boolean { - return true; - } - - /** - * - */ - @computed get hasLoadedCurrentTheme(): boolean { - return true; - } - - /** - * - */ - hasCustomTheme: void => boolean = (): boolean => { - return false; - }; - // ========== Terms of Use ========== // @computed get termsOfUse(): string { diff --git a/packages/yoroi-extension/app/stores/toplevel/ProfileStore.js b/packages/yoroi-extension/app/stores/toplevel/ProfileStore.js index 8256964bc0..fee536d365 100644 --- a/packages/yoroi-extension/app/stores/toplevel/ProfileStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/ProfileStore.js @@ -1,5 +1,5 @@ // @flow -import { action, observable, computed, runInAction } from 'mobx'; +import { action, computed, observable, runInAction } from 'mobx'; import BigNumber from 'bignumber.js'; import BaseProfileStore from '../base/BaseProfileStore'; import Request from '../lib/LocalizedRequest'; @@ -109,24 +109,11 @@ export default class ProfileStore extends BaseProfileStore disabling legacy UI export type LayoutComponentMap = {| [key: Layouts]: Node, |}; @@ -17,18 +18,15 @@ const LayoutContext = React.createContext(); const LayoutProvider = (props: Object): Node => { const { layout } = props; - const localLayout: 'REVAMP' = 'REVAMP'; - return ( disabling legacy UI renderLayoutComponent: (layoutMap: LayoutComponentMap = {}) => { - const selectedComponent = layoutMap[localLayout]; - return selectedComponent; + return layoutMap.REVAMP; }, }} {...props} From 5ff500ed6433a6b69124fe66f1616954ab5c8011 Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Sun, 13 Oct 2024 17:28:21 +0300 Subject: [PATCH 17/76] `currentTheme` usages removed --- packages/yoroi-extension/app/App.js | 9 +- .../wallet/transactions/TransactionRevamp.js | 15 +- .../transactions/WalletTransactionsList.js | 204 ------------------ .../transactions/WalletTransactionsList.scss | 34 --- .../WalletTransactionsListRevamp.js | 4 +- .../WalletTransactionsListRevamp.scss | 3 + packages/yoroi-extension/app/connector/App.js | 3 +- .../containers/wallet/WalletSummaryPage.js | 13 +- .../app/styles/context/layout.js | 4 +- packages/yoroi-extension/app/styles/themes.js | 2 + 10 files changed, 24 insertions(+), 267 deletions(-) delete mode 100644 packages/yoroi-extension/app/components/wallet/transactions/WalletTransactionsList.js delete mode 100644 packages/yoroi-extension/app/components/wallet/transactions/WalletTransactionsList.scss create mode 100644 packages/yoroi-extension/app/components/wallet/transactions/WalletTransactionsListRevamp.scss diff --git a/packages/yoroi-extension/app/App.js b/packages/yoroi-extension/app/App.js index cc243640ca..a365eeb3e4 100644 --- a/packages/yoroi-extension/app/App.js +++ b/packages/yoroi-extension/app/App.js @@ -15,7 +15,7 @@ import { LayoutProvider } from './styles/context/layout'; import { ColorModeProvider } from './styles/context/mode'; import { CssBaseline } from '@mui/material'; import { globalStyles } from './styles/globalStyles'; -import { changeToplevelTheme, MuiThemes, THEMES } from './styles/themes'; +import { changeToplevelTheme, MuiThemes } from './styles/themes'; import ThemeManager from './ThemeManager'; import environment from './environment'; import MaintenancePage from './containers/MaintenancePage'; @@ -82,17 +82,14 @@ class App extends Component { '--default-font': !environment.isProduction() ? 'wingdings' : 'Times New Roman', }; - const currentTheme = stores.profile.currentTheme || THEMES.YOROI_BASE; - + const currentTheme = stores.profile.currentTheme; changeToplevelTheme(currentTheme); - const muiTheme = MuiThemes[currentTheme]; - Logger.debug(`[yoroi] themes changed`); return (
- + {globalStyles(muiTheme)} diff --git a/packages/yoroi-extension/app/components/wallet/transactions/TransactionRevamp.js b/packages/yoroi-extension/app/components/wallet/transactions/TransactionRevamp.js index a876326bd7..c652270478 100644 --- a/packages/yoroi-extension/app/components/wallet/transactions/TransactionRevamp.js +++ b/packages/yoroi-extension/app/components/wallet/transactions/TransactionRevamp.js @@ -67,7 +67,7 @@ type Props = {| +onCopyAddressTooltip: (string, string) => void, +notification: ?Notification, +addressToDisplayString: string => string, - +getTokenInfo: ($ReadOnly>) => $ReadOnly, + +getTokenInfo: ($ReadOnly>) => $ReadOnly | null, +complexityLevel: ?ComplexityLevelType, id: string, txIndex: number, @@ -209,8 +209,9 @@ export default class TransactionRevamp extends Component { if (this.props.unitOfAccountSetting.enabled) { const tokenInfo = this.props.getTokenInfo(request.entry); - const shiftedAmount = request.entry.amount.shiftedBy(-tokenInfo.Metadata.numberOfDecimals); - const ticker = tokenInfo.Metadata.ticker; + const numberOfDecimals = tokenInfo?.Metadata.numberOfDecimals ?? 0; + const shiftedAmount = request.entry.amount.shiftedBy(- numberOfDecimals); + const ticker = tokenInfo?.Metadata.ticker; if (ticker == null) { throw new Error('unexpected main token type'); } @@ -293,16 +294,16 @@ export default class TransactionRevamp extends Component { } const defaultEntry = request.amount.getDefaultEntry(); const tokenInfo = this.props.getTokenInfo(defaultEntry); - const shiftedAmount = defaultEntry.amount.shiftedBy(-tokenInfo.Metadata.numberOfDecimals).abs(); - - const [beforeDecimalRewards, afterDecimalRewards] = splitAmount(shiftedAmount, tokenInfo.Metadata.numberOfDecimals); + const decimalPlaces = tokenInfo?.Metadata.numberOfDecimals ?? 0; + const shiftedAmount = defaultEntry.amount.shiftedBy(-decimalPlaces).abs(); + const [beforeDecimalRewards, afterDecimalRewards] = splitAmount(shiftedAmount, decimalPlaces); if (this.props.unitOfAccountSetting.enabled) { const { currency } = this.props.unitOfAccountSetting; if (currency == null) { throw new Error(`unexpected unit of account ${String(currency)}`); } - const ticker = tokenInfo.Metadata.ticker; + const ticker = tokenInfo?.Metadata.ticker; if (ticker == null) { throw new Error('unexpected main token type'); } diff --git a/packages/yoroi-extension/app/components/wallet/transactions/WalletTransactionsList.js b/packages/yoroi-extension/app/components/wallet/transactions/WalletTransactionsList.js deleted file mode 100644 index 91ecb53d75..0000000000 --- a/packages/yoroi-extension/app/components/wallet/transactions/WalletTransactionsList.js +++ /dev/null @@ -1,204 +0,0 @@ -// @flow -import { Component } from 'react'; -import type { Node } from 'react'; -import { observer } from 'mobx-react'; -import { defineMessages, intlShape } from 'react-intl'; -import { Button } from '@mui/material'; -import moment from 'moment'; -import styles from './WalletTransactionsList.scss'; -import Transaction from './Transaction'; -import WalletTransaction from '../../../domain/WalletTransaction'; -import LoadingSpinner from '../../widgets/LoadingSpinner'; -import type { AssuranceMode } from '../../../types/transactionAssurance.types'; -import { Logger } from '../../../utils/logging'; -import { SelectedExplorer } from '../../../domain/SelectedExplorer'; -import type { UnitOfAccountSettingType } from '../../../types/unitOfAccountType'; -import OneSideBarDecoration from '../../widgets/OneSideBarDecoration'; -import globalMessages from '../../../i18n/global-messages'; -import type { TxMemoTableRow } from '../../../api/ada/lib/storage/database/memos/tables'; -import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; -import type { Notification } from '../../../types/notification.types'; -import { genAddressLookup } from '../../../stores/stateless/addressStores'; -import type { TokenLookupKey } from '../../../api/common/lib/MultiToken'; -import type { TokenRow } from '../../../api/ada/lib/storage/database/primitives/tables'; -import type { ComplexityLevelType } from '../../../types/complexityLevelType'; - -const messages = defineMessages({ - showMoreTransactionsButtonLabel: { - id: 'wallet.summary.page.showMoreTransactionsButtonLabel', - defaultMessage: '!!!Show more transactions', - }, -}); - -const dateFormat = 'YYYY-MM-DD'; - -type Props = {| - +transactions: Array, - +lastSyncBlock: number, - +memoMap: Map>, - +isLoadingTransactions: boolean, - +hasMoreToLoad: boolean, - +selectedExplorer: SelectedExplorer, - +assuranceMode: AssuranceMode, - +onLoadMore: void => PossiblyAsync, - +shouldHideBalance: boolean, - +onAddMemo: WalletTransaction => void, - +onEditMemo: WalletTransaction => void, - +unitOfAccountSetting: UnitOfAccountSettingType, - +getHistoricalPrice: (from: string, to: string, timestamp: number) => ?string, - +addressLookup: ReturnType, - +onCopyAddressTooltip: (string, string) => void, - +notification: ?Notification, - +addressToDisplayString: string => string, - +getTokenInfo: ($ReadOnly>) => ?$ReadOnly, - +complexityLevel: ?ComplexityLevelType, -|}; - -@observer -export default class WalletTransactionsList extends Component { - static contextTypes: {| intl: $npm$ReactIntl$IntlFormat |} = { - intl: intlShape.isRequired, - }; - - // eslint-disable-next-line camelcase - UNSAFE_componentWillMount(): void { - this.localizedDateFormat = moment.localeData().longDateFormat('L'); - // Localized dateFormat: - // English - MM/DD/YYYY - // Japanese - YYYY/MM/DD - } - - list: HTMLElement; - loadingSpinner: ?LoadingSpinner; - localizedDateFormat: 'MM/DD/YYYY'; - - groupTransactionsByDay( - transactions: Array - ): Array<{| - date: string, - transactions: Array, - |}> { - const groups: Array<{| - date: string, - transactions: Array, - |}> = []; - for (const transaction of transactions) { - const date: string = moment(transaction.date).format(dateFormat); - // find the group this transaction belongs in - let group = groups.find(g => g.date === date); - // if first transaction in this group, create the group - if (!group) { - group = { date, transactions: [] }; - groups.push(group); - } - group.transactions.push(transaction); - } - return groups.sort( - (a, b) => b.transactions[0].date.getTime() - a.transactions[0].date.getTime() - ); - } - - localizedDate(date: string): string { - const { intl } = this.context; - const today = moment().format(dateFormat); - if (date === today) return intl.formatMessage(globalMessages.dateToday); - const yesterday = moment().subtract(1, 'days').format(dateFormat); - if (date === yesterday) return intl.formatMessage(globalMessages.dateYesterday); - return moment(date).format(this.localizedDateFormat); - } - - getTransactionKey(transactions: Array): string { - if (transactions.length) { - const firstTransaction = transactions[0]; - return firstTransaction.uniqueKey; - } - // this branch should not happen - Logger.error( - '[WalletTransactionsList::getTransactionKey] tried to render empty transaction group' - ); - return ''; - } - - render(): Node { - const { intl } = this.context; - const { - transactions, - isLoadingTransactions, - hasMoreToLoad, - assuranceMode, - onLoadMore, - onAddMemo, - onEditMemo, - notification, - onCopyAddressTooltip, - } = this.props; - const transactionsGroups = this.groupTransactionsByDay(transactions); - - const loadingSpinner = isLoadingTransactions ? ( -
- { - this.loadingSpinner = component; - }} - /> -
- ) : null; - - return ( -
- {transactionsGroups.map(group => ( -
-
- -
{this.localizedDate(group.date)}
-
-
-
- {group.transactions.map((transaction, transactionIndex) => ( - - ))} -
-
- ))} - {loadingSpinner} - {!isLoadingTransactions && hasMoreToLoad && ( - - )} -
- ); - } -} diff --git a/packages/yoroi-extension/app/components/wallet/transactions/WalletTransactionsList.scss b/packages/yoroi-extension/app/components/wallet/transactions/WalletTransactionsList.scss deleted file mode 100644 index b4cefc0aa6..0000000000 --- a/packages/yoroi-extension/app/components/wallet/transactions/WalletTransactionsList.scss +++ /dev/null @@ -1,34 +0,0 @@ -.component { - margin-top: 22px; - // min-width: fit-content; - overflow-y: overlay; - - .group { - &:last-child { - margin-bottom: 17px; - } - } - - .bar { - padding-right: 24px; - - .groupDate { - padding-left: 24px; - font-size: 14px; - line-height: 1.38; - color: var(--yoroi-palette-gray-600); - } - } - - .list { - margin-bottom: 20px; - - &:last-child { - margin: 0; - } - } -} - -.loading { - margin: 20px 0; -} diff --git a/packages/yoroi-extension/app/components/wallet/transactions/WalletTransactionsListRevamp.js b/packages/yoroi-extension/app/components/wallet/transactions/WalletTransactionsListRevamp.js index 8542a65f2e..4ff55e673e 100644 --- a/packages/yoroi-extension/app/components/wallet/transactions/WalletTransactionsListRevamp.js +++ b/packages/yoroi-extension/app/components/wallet/transactions/WalletTransactionsListRevamp.js @@ -5,7 +5,7 @@ import { observer } from 'mobx-react'; import { defineMessages, intlShape } from 'react-intl'; import { Button, Typography } from '@mui/material'; import moment from 'moment'; -import styles from './WalletTransactionsList.scss'; +import styles from './WalletTransactionsListRevamp.scss'; import WalletTransaction from '../../../domain/WalletTransaction'; import LoadingSpinner from '../../widgets/LoadingSpinner'; import type { AssuranceMode } from '../../../types/transactionAssurance.types'; @@ -50,7 +50,7 @@ type Props = {| +onCopyAddressTooltip: (string, string) => void, +notification: ?Notification, +addressToDisplayString: string => string, - +getTokenInfo: ($ReadOnly>) => $ReadOnly, + +getTokenInfo: ($ReadOnly>) => $ReadOnly | null, +complexityLevel: ?ComplexityLevelType, id: string, |}; diff --git a/packages/yoroi-extension/app/components/wallet/transactions/WalletTransactionsListRevamp.scss b/packages/yoroi-extension/app/components/wallet/transactions/WalletTransactionsListRevamp.scss new file mode 100644 index 0000000000..193f8ccafb --- /dev/null +++ b/packages/yoroi-extension/app/components/wallet/transactions/WalletTransactionsListRevamp.scss @@ -0,0 +1,3 @@ +.loading { + margin: 20px 0; +} diff --git a/packages/yoroi-extension/app/connector/App.js b/packages/yoroi-extension/app/connector/App.js index 45a11ff962..1b0db8035f 100644 --- a/packages/yoroi-extension/app/connector/App.js +++ b/packages/yoroi-extension/app/connector/App.js @@ -106,12 +106,11 @@ class App extends Component { const currentTheme = stores.profile.currentTheme; const muiTheme = MuiThemes[currentTheme]; - changeToplevelTheme(currentTheme); return (
- + {globalStyles(muiTheme)} diff --git a/packages/yoroi-extension/app/containers/wallet/WalletSummaryPage.js b/packages/yoroi-extension/app/containers/wallet/WalletSummaryPage.js index 10d40f11b0..07b6444986 100644 --- a/packages/yoroi-extension/app/containers/wallet/WalletSummaryPage.js +++ b/packages/yoroi-extension/app/containers/wallet/WalletSummaryPage.js @@ -13,7 +13,6 @@ import LoadingSpinner from '../../components/widgets/LoadingSpinner'; import globalMessages from '../../i18n/global-messages'; import { ReactComponent as successIcon } from '../../assets/images/success-small.inline.svg'; import type { StoresAndActionsProps } from '../../types/injectedProps.types'; -import WalletTransactionsList from '../../components/wallet/transactions/WalletTransactionsList'; import WalletTransactionsListRevamp from '../../components/wallet/transactions/WalletTransactionsListRevamp'; import WalletSummary from '../../components/wallet/summary/WalletSummary'; import VerticalFlexContainer from '../../components/layout/VerticalFlexContainer'; @@ -34,6 +33,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 = {| @@ -76,7 +76,7 @@ class WalletSummaryPage extends Component { Logger.error('[WalletSummaryPage::render] Active wallet required'); return null; } - this.props.stores.delegation.checkPoolTransition(); + noop(this.props.stores.delegation.checkPoolTransition()); const { exportTransactionsToFile, closeExportTransactionDialog } = actions.transactions; @@ -104,16 +104,9 @@ class WalletSummaryPage extends Component { const notificationToolTip = uiNotifications.getTooltipActiveNotification(this.notificationElementId); if (recent.length > 0) { - const mapWalletTransactionLayout = { - CLASSIC: WalletTransactionsList, - REVAMP: WalletTransactionsListRevamp, - }; - - const WalletTransactionsListComp = mapWalletTransactionLayout[this.props.selectedLayout]; - if (isLoading || hasAny) { walletTransactions = ( - disabling legacy UI @@ -17,12 +18,11 @@ export type InjectedLayoutProps = {| const LayoutContext = React.createContext(); const LayoutProvider = (props: Object): Node => { - const { layout } = props; return ( disabling legacy UI renderLayoutComponent: (layoutMap: LayoutComponentMap = {}) => { diff --git a/packages/yoroi-extension/app/styles/themes.js b/packages/yoroi-extension/app/styles/themes.js index e7977fdd3e..09af4eb1ba 100644 --- a/packages/yoroi-extension/app/styles/themes.js +++ b/packages/yoroi-extension/app/styles/themes.js @@ -6,6 +6,8 @@ import { baseLightTheme } from './themes/light-theme-mui'; import { classicTheme } from './themes/legacy/classic-theme'; import { modernTheme } from './themes/legacy/modern-theme'; +// legacy themes + export const THEMES = Object.freeze({ YOROI_CLASSIC: 'YoroiClassic', YOROI_MODERN: 'YoroiModern', From 88a9ec73d883205429f9042dafb5f392ec49af83 Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Sun, 13 Oct 2024 17:47:15 +0300 Subject: [PATCH 18/76] removed legacy prop `selectedLayout` --- .../app/components/topbar/Sidebar.js | 110 --- .../app/components/topbar/Sidebar.scss | 72 -- .../components/wallet/send/WalletSendForm.js | 650 ------------------ .../wallet/send/WalletSendForm.scss | 105 --- .../wallet/summary/WalletSummary.js | 251 ------- .../app/containers/ExchangeEndPage.js | 30 +- .../app/containers/SidebarContainer.js | 48 +- .../app/containers/wallet/WalletSendPage.js | 159 ++--- .../containers/wallet/WalletSummaryPage.js | 152 +--- .../containers/wallet/staking/SeizaFetcher.js | 17 +- .../app/stores/stateless/sidebarCategories.js | 1 + .../app/styles/context/layout.js | 2 - 12 files changed, 67 insertions(+), 1530 deletions(-) delete mode 100644 packages/yoroi-extension/app/components/topbar/Sidebar.js delete mode 100644 packages/yoroi-extension/app/components/topbar/Sidebar.scss delete mode 100644 packages/yoroi-extension/app/components/wallet/send/WalletSendForm.js delete mode 100644 packages/yoroi-extension/app/components/wallet/send/WalletSendForm.scss delete mode 100644 packages/yoroi-extension/app/components/wallet/summary/WalletSummary.js diff --git a/packages/yoroi-extension/app/components/topbar/Sidebar.js b/packages/yoroi-extension/app/components/topbar/Sidebar.js deleted file mode 100644 index ab1c81f959..0000000000 --- a/packages/yoroi-extension/app/components/topbar/Sidebar.js +++ /dev/null @@ -1,110 +0,0 @@ -// @flow -import { Component } from 'react'; -import type { Node } from 'react'; -import { observer } from 'mobx-react'; -import SideBarCategory from './SideBarCategory'; -import styles from './Sidebar.scss'; -import type { SidebarCategory } from '../../stores/stateless/sidebarCategories'; -import classnames from 'classnames'; -import { intlShape } from 'react-intl'; -import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; - -import { ReactComponent as yoroiLogo } from '../../assets/images/sidebar/yoroi-logo.inline.svg'; -import { ReactComponent as yoroiLogoExpanded } from '../../assets/images/sidebar/yoroi-logo-expanded.inline.svg'; -import { ReactComponent as toggleIcon } from '../../assets/images/sidebar/open-sidebar.inline.svg'; -import globalMessages from '../../i18n/global-messages'; - -type Props = {| - +children?: ?Node, - +categories?: Array, - +isActiveCategory?: SidebarCategory => boolean, - +onCategoryClicked?: SidebarCategory => void, - +onToggleSidebar: void => Promise, - +isSidebarExpanded: boolean, -|}; - -@observer -export default class Sidebar extends Component { - static contextTypes: {| intl: $npm$ReactIntl$IntlFormat |} = { - intl: intlShape.isRequired, - }; - - static defaultProps: {| - categories: void, - children: void, - isActiveCategory: void, - onCategoryClicked: void, - |} = { - children: undefined, - categories: undefined, - isActiveCategory: undefined, - onCategoryClicked: undefined, - }; - - render(): Node { - const { intl } = this.context; - const { - categories, - isActiveCategory, - onCategoryClicked, - isSidebarExpanded, - onToggleSidebar, - } = this.props; - - const ToggleIcon = toggleIcon; - const YoroiLogo = yoroiLogo; - const YoroiLogoExpanded = yoroiLogoExpanded; - - return ( -
- {this.props.children} -
- {isSidebarExpanded ? : } -
-
- {categories - ? categories.map(category => { - return ( - { - if (onCategoryClicked) { - onCategoryClicked(category); - } - }} - /> - ); - }) - : null} -
- - -
- ); - } -} diff --git a/packages/yoroi-extension/app/components/topbar/Sidebar.scss b/packages/yoroi-extension/app/components/topbar/Sidebar.scss deleted file mode 100644 index 5b270053c9..0000000000 --- a/packages/yoroi-extension/app/components/topbar/Sidebar.scss +++ /dev/null @@ -1,72 +0,0 @@ -.wrapper { - min-height: 100%; - display: flex; - flex-direction: column; - background: var(--yoroi-sidebar-background); -} - -.header { - padding: 18px; - min-height: 74px; - & svg > path { - fill: var(--yoroi-sidebar-text); - } -} - -.categories { - display: flex; - flex-direction: column; - flex: 1; -} - -.footer { - display: flex; - align-items: center; - justify-content: space-between; - flex-wrap: wrap; -} - -.faq { - max-width: 47px; - text-transform: uppercase; - border-radius: 20px; - background: #1737A3; - text-decoration: none; - color: #FFFFFF; - font-weight: 400; - font-size: 12px; - padding: 14px 12px; - height: 24px; - display: flex; - align-items: center; - justify-content: center; - text-align: center; - margin: 0px 12px; - - &:hover { - background-color: #122770; - } -} - -.toggleButton { - padding: 20px 24px; - align-self: flex-end; - display: flex; - justify-content: center; - & svg > path { - fill: var(--yoroi-sidebar-text); - } - &:hover { - cursor: pointer; - & svg > path { - fill: var(--yoroi-palette-secondary-300); - } - } - & .iconRotate { - transform: rotate(180deg); - } - - &.toggleActive { - justify-content: flex-end; - } -} diff --git a/packages/yoroi-extension/app/components/wallet/send/WalletSendForm.js b/packages/yoroi-extension/app/components/wallet/send/WalletSendForm.js deleted file mode 100644 index c72b1989fc..0000000000 --- a/packages/yoroi-extension/app/components/wallet/send/WalletSendForm.js +++ /dev/null @@ -1,650 +0,0 @@ -// @flow -import { Component } from 'react'; -import type { Node } from 'react'; -import { observer } from 'mobx-react'; -import { reaction } from 'mobx'; -import { Button, MenuItem, Typography } from '@mui/material'; -import TextField from '../../common/TextField'; -import { defineMessages, intlShape } from 'react-intl'; -import { isValidMemoOptional, isValidMemo } from '../../../utils/validations'; -import ReactToolboxMobxForm from '../../../utils/ReactToolboxMobxForm'; -import vjf from 'mobx-react-form/lib/validators/VJF'; -import { AmountInput } from '../../common/NumericInputRP'; -import { ReactComponent as AddMemoSvg } from '../../../assets/images/add-memo.inline.svg'; -import BorderedBox from '../../widgets/BorderedBox'; -import styles from './WalletSendForm.scss'; -import globalMessages, { memoMessages } from '../../../i18n/global-messages'; -import type { UriParams } from '../../../utils/URIHandling'; -import { - getAddressPayload, - isValidReceiveAddress, -} from '../../../api/ada/lib/storage/bridge/utils'; -import { MAX_MEMO_SIZE } from '../../../config/externalStorageConfig'; -import type { TokenRow, NetworkRow } from '../../../api/ada/lib/storage/database/primitives/tables'; -import { - formattedAmountToBigNumber, - formattedAmountToNaturalUnits, - truncateToken, -} from '../../../utils/formatters'; -import config from '../../../config'; -import LocalizableError from '../../../i18n/LocalizableError'; -import WarningBox from '../../widgets/WarningBox'; -import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; -import { - getTokenName, - genFormatTokenAmount, - getTokenStrictName, - getTokenIdentifierIfExists, -} from '../../../stores/stateless/tokenHelpers'; -import { MultiToken } from '../../../api/common/lib/MultiToken'; -import type { TokenEntry, TokenLookupKey } from '../../../api/common/lib/MultiToken'; -import Select from '../../common/Select'; -import { Box } from '@mui/system'; -import TokenOptionRow from '../../widgets/tokenOption/TokenOptionRow'; -import BigNumber from 'bignumber.js'; -import classnames from 'classnames'; - -const messages = defineMessages({ - receiverLabel: { - id: 'wallet.send.form.receiver.label', - defaultMessage: '!!!Receiver', - }, - receiverHint: { - id: 'wallet.send.form.receiver.hint', - defaultMessage: '!!!Wallet Address', - }, - dropdownAmountLabel: { - id: 'wallet.send.form.sendAll.dropdownAmountLabel', - defaultMessage: '!!!Send all {currency}', - }, - dropdownSendNFTLabel: { - id: 'wallet.send.form.sendAll.dropdownSendNFTLabel', - defaultMessage: '!!!Send {currency}', - }, - allTokens: { - id: 'wallet.send.form.sendAll.allTokens', - defaultMessage: '!!! + all tokens', - }, - selectedAmountLable: { - id: 'wallet.send.form.sendAll.selectedAmountLable', - defaultMessage: '!!!Amount Options', - }, - customAmount: { - id: 'wallet.send.form.sendAll.customAmount', - defaultMessage: '!!!Custom Amount', - }, - transactionFeeError: { - id: 'wallet.send.form.transactionFeeError', - defaultMessage: '!!!Not enough Ada for fees. Try sending a smaller amount.', - }, - calculatingFee: { - id: 'wallet.send.form.calculatingFee', - defaultMessage: '!!!Calculating the fee, please wait.', - }, - memoInvalidOptional: { - id: 'wallet.transaction.memo.optional.invalid', - defaultMessage: '!!!Memo cannot be more than {maxMemo} characters.', - }, - willSendAll: { - id: 'wallet.send.form.willSendAll', - defaultMessage: '!!!ATTENTION! You will send all of your tokens below:', - }, -}); - -type Props = {| - +selectedNetwork: $ReadOnly, - +hasAnyPending: boolean, - +validateAmount: ( - amountInNaturalUnits: BigNumber, - tokenRow: $ReadOnly - ) => Promise<[boolean, void | string]>, - +onSubmit: void => void, - +totalInput: ?MultiToken, - +updateReceiver: (void | string) => void, - +updateAmount: (?BigNumber) => void, - +updateMemo: (void | string) => void, - +shouldSendAll: boolean, - +updateSendAllStatus: (void | boolean) => void, - +fee: ?MultiToken, - +isCalculatingFee: boolean, - +reset: void => void, - +error: ?LocalizableError, - +uriParams: ?UriParams, - +resetUriParams: void => void, - +showMemo: boolean, - +onAddMemo: void => void, - +getTokenInfo: ($ReadOnly>) => $ReadOnly, - +defaultToken: $ReadOnly, // need since no guarantee input in non-null - +onAddToken: ({| - token: void | $ReadOnly, - shouldSendAll?: boolean, - shouldReset?: boolean, - |}) => void, - +spendableBalance: ?MultiToken, - +selectedToken: void | $ReadOnly, -|}; -const CUSTOM_AMOUNT = 'CUSTOM_AMOUNT'; - -@observer -export default class WalletSendForm extends Component { - static contextTypes: {| intl: $npm$ReactIntl$IntlFormat |} = { - intl: intlShape.isRequired, - }; - - amountFieldReactionDisposer: null | (() => mixed) = null; - - componentDidMount(): void { - this.props.reset(); - - const formatValue = genFormatTokenAmount(this.props.getTokenInfo); - if (this.props.uriParams) { - // assert not null - const uriParams = this.props.uriParams; - - // note: assume these are validated externally - this.props.updateAmount(uriParams.amount.getDefaultEntry().amount); - this.props.updateReceiver(getAddressPayload(uriParams.address, this.props.selectedNetwork)); - this.props.resetUriParams(); - } - - /** - * Mobx-react-form doesn't allow the value field to be updated based on a computed variable - * so instead we register a reaction to update it - */ - this.amountFieldReactionDisposer = reaction( - () => [this.props.shouldSendAll, this.props.totalInput], - () => { - if (!this.props.totalInput || !this.props.fee) { - return; - } - const totalInput = this.props.totalInput; - const fee = this.props.fee; - if (!this.props.shouldSendAll) { - return; - } - - // once sendAll is triggered, set the amount field to the total input - const adjustedInput = totalInput.joinSubtractCopy(fee); - const relatedEntry = this.getTokenEntry(adjustedInput); - this.form.$('amount').set('value', formatValue(relatedEntry)); - } - ); - } - - getTokenEntry: MultiToken => TokenEntry = tokens => { - return this.props.selectedToken == null - ? tokens.getDefaultEntry() - : tokens.values.find(entry => entry.identifier === this.props.selectedToken?.Identifier) ?? - tokens.getDefaultEntry(); - }; - - componentWillUnmount(): void { - this.props.reset(); - // dispose reaction - if (this.amountFieldReactionDisposer != null) { - this.amountFieldReactionDisposer(); - } - } - - // FORM VALIDATION - form: ReactToolboxMobxForm = new ReactToolboxMobxForm( - { - fields: { - receiver: { - label: this.context.intl.formatMessage(messages.receiverLabel), - placeholder: '', - value: this.props.uriParams ? this.props.uriParams.address : '', - validators: [ - ({ field }) => { - const receiverValue = field.value; - if (receiverValue === '') { - this.props.updateReceiver(); - return [false, this.context.intl.formatMessage(globalMessages.fieldIsRequired)]; - } - const updateReceiver = (isValid: boolean) => { - if (isValid) { - this.props.updateReceiver( - getAddressPayload(receiverValue, this.props.selectedNetwork) - ); - } else { - this.props.updateReceiver(); - } - }; - - const isValid = isValidReceiveAddress(receiverValue, this.props.selectedNetwork); - if (isValid === true) { - updateReceiver(true); - return [isValid]; - } - updateReceiver(isValid[0]); - return [isValid[0], this.context.intl.formatMessage(isValid[1])]; - }, - ], - }, - amount: { - label: this.context.intl.formatMessage(globalMessages.amountLabel), - placeholder: '', - value: (() => { - const formatValue = genFormatTokenAmount(this.props.getTokenInfo); - return this.props.uriParams - ? formatValue(this.props.uriParams.amount.getDefaultEntry()) - : null; - })(), - validators: [ - async ({ field }) => { - if (this.props.shouldSendAll) { - // sendall doesn't depend on the amount so always succeed - return true; - } - const amountValue: string = field.value; - if (amountValue === '') { - this.props.updateAmount(); - return [false, this.context.intl.formatMessage(globalMessages.fieldIsRequired)]; - } - const formattedAmount = new BigNumber( - formattedAmountToNaturalUnits(amountValue, this.getNumDecimals()) - ); - const isValidAmount = await this.props.validateAmount( - formattedAmount, - this.props.selectedToken ?? this.props.defaultToken - ); - if (isValidAmount[0]) { - this.props.updateAmount(formattedAmount); - } else { - this.props.updateAmount(); - } - return isValidAmount; - }, - ], - }, - selectedToken: { - label: this.context.intl.formatMessage(globalMessages.assetSelect), - value: - this.props.selectedToken?.TokenId ?? - this.props.getTokenInfo({ - identifier: this.props.defaultToken.Identifier, - networkId: this.props.defaultToken.NetworkId, - }).TokenId, - }, - selectedAmount: { - label: this.context.intl.formatMessage(messages.selectedAmountLable), - value: this.props.shouldSendAll - ? this.props.selectedToken?.TokenId ?? - this.props.getTokenInfo({ - identifier: this.props.defaultToken.Identifier, - networkId: this.props.defaultToken.NetworkId, - }).TokenId - : CUSTOM_AMOUNT, - }, - memo: { - label: this.context.intl.formatMessage(memoMessages.memoLabel), - placeholder: this.context.intl.formatMessage(memoMessages.optionalMemo), - value: '', - validators: [ - ({ field }) => { - const memoContent = field.value; - const isValid = isValidMemoOptional(memoContent); - if (isValid) { - this.props.updateMemo(memoContent); - } - return [ - isValid, - this.context.intl.formatMessage(messages.memoInvalidOptional, { - maxMemo: MAX_MEMO_SIZE, - }), - ]; - }, - ], - }, - }, - }, - { - options: { - // if fields are pre-populated by URI, validate them right away - showErrorsOnInit: this.props.uriParams, - validateOnBlur: false, - validateOnChange: true, - validationDebounceWait: config.forms.FORM_VALIDATION_DEBOUNCE_WAIT, - }, - plugins: { - vjf: vjf(), - }, - } - ); - - getNumDecimals(): number { - const info = - this.props.selectedToken ?? - this.props.getTokenInfo({ - identifier: this.props.defaultToken.Identifier, - networkId: this.props.defaultToken.NetworkId, - }); - return info.Metadata.numberOfDecimals; - } - - render(): Node { - const { form } = this; - const { intl } = this.context; - const { memo } = this.form.values(); - const { hasAnyPending, showMemo, onAddMemo } = this.props; - - const amountField = form.$('amount'); - const receiverField = form.$('receiver'); - const memoField = form.$('memo'); - const amountFieldProps = amountField.bind(); - - const transactionFee = - this.props.fee ?? - new MultiToken([], { - defaultIdentifier: this.props.defaultToken.Identifier, - defaultNetworkId: this.props.defaultToken.NetworkId, - }); - - const totalAmount = - this.props.totalInput ?? - new MultiToken( - [ - { - identifier: (this.props.selectedToken ?? this.props.defaultToken).Identifier, - networkId: (this.props.selectedToken ?? this.props.defaultToken).NetworkId, - amount: formattedAmountToBigNumber(amountFieldProps.value).shiftedBy( - (this.props.selectedToken ?? this.props.defaultToken).Metadata.numberOfDecimals - ), - }, - ], - { - defaultIdentifier: this.props.defaultToken.Identifier, - defaultNetworkId: this.props.defaultToken.NetworkId, - } - ); - - const pendingTxWarningComponent = ( -
- {intl.formatMessage(globalMessages.sendingIsDisabled)} -
- ); - - let transactionFeeError = null; - if (this.props.isCalculatingFee) { - transactionFeeError = this.context.intl.formatMessage(messages.calculatingFee); - } - if (this.props.error) { - transactionFeeError = this.context.intl.formatMessage( - this.props.error, - this.props.error.values - ); - } - - const formatValue = genFormatTokenAmount(this.props.getTokenInfo); - const tokenOptions = (() => { - if (this.props.spendableBalance == null) return []; - const { spendableBalance } = this.props; - return [ - // make sure default token is always first in the list - spendableBalance.getDefaultEntry(), - ...spendableBalance.nonDefaultEntries(), - ] - .map(entry => ({ - entry, - info: this.props.getTokenInfo(entry), - })) - .map(token => { - const amount = genFormatTokenAmount(this.props.getTokenInfo)(token.entry); - return { - value: token.info.TokenId, - info: token.info, - label: truncateToken( - getTokenStrictName(token.info).name ?? getTokenIdentifierIfExists(token.info) ?? '-' - ), - id: getTokenIdentifierIfExists(token.info) ?? '-', - amount, - }; - }); - })(); - - const tokenId = - this.props.selectedToken?.TokenId ?? - this.props.getTokenInfo({ - identifier: this.props.defaultToken.Identifier, - networkId: this.props.defaultToken.NetworkId, - }).TokenId; - - const sendAmountOptions = (() => { - return [ - { - id: 'custom-amount', - label: intl.formatMessage(messages.customAmount), - value: CUSTOM_AMOUNT, - }, - ...tokenOptions - .filter(t => t.value === tokenId) - .map(token => { - let label = intl.formatMessage( - token.info.IsNFT ? messages.dropdownSendNFTLabel : messages.dropdownAmountLabel, - { - currency: truncateToken(token.label), - } - ); - - const defaultTokenName = truncateToken(getTokenName(this.props.defaultToken)); - if (token.label === defaultTokenName) { - label += intl.formatMessage(messages.allTokens); - } - return { - label, - value: token.value, - id: 'send-all', - }; - }), - ]; - })(); - const tokenListClasses = classnames([ - styles.tokenList, - { - [styles.show]: this.props.shouldSendAll && this.form.$('selectedToken').value === tokenId, - }, - ]); - - return ( -
- {hasAnyPending && pendingTxWarningComponent} - - - {tokenOptions.length > 1 && ( - - )} - -
- -
- -
- -
- - - -
-

{intl.formatMessage(messages.willSendAll)}

- {tokenOptions.map(token => ( -
- {token.amount} {token.label} -
- ))} -
- - {showMemo ? ( -
- -
- ) : ( -
- -
- )} - - {this._makeInvokeConfirmationButton()} -
-
- ); - } - - _makeInvokeConfirmationButton(): Node { - const { intl } = this.context; - const { memo, amount } = this.form.values(); - - const { hasAnyPending } = this.props; - - const disabledCondition = - !this.props.fee || hasAnyPending || !isValidMemoOptional(memo) || !amount; - - return ( - - ); - } -} diff --git a/packages/yoroi-extension/app/components/wallet/send/WalletSendForm.scss b/packages/yoroi-extension/app/components/wallet/send/WalletSendForm.scss deleted file mode 100644 index 756c704403..0000000000 --- a/packages/yoroi-extension/app/components/wallet/send/WalletSendForm.scss +++ /dev/null @@ -1,105 +0,0 @@ -.component { - padding-top: 40px; - padding-right: 20px; - padding-bottom: 20px; - padding-left: 20px; - - .warningBox { - margin-bottom: 30px; - } - - .receiverInput { - position: relative; - - :global { - .SimpleInput_input { - font-family: 'RobotoMono'; - font-weight: 300; - letter-spacing: 0; - } - } - } - - .amountInput { - position: relative; - margin-bottom: 10px; - } - - .checkbox { - font-family: 'RobotoMono'; - font-weight: 300; - width: fit-content; - } - - .memoActionItemBlock { - letter-spacing: 0.5px; - margin: 15px 0; - line-height: 20px; - vertical-align: top; - white-space: nowrap; - - * { - vertical-align: middle; - } - - button { - cursor: pointer; - } - - .addMemoIcon { - cursor: pointer; - display: inline-flex; - object-fit: contain; - & > svg { - height: 30px; - width: 30px; - } - } - } - - - .actionLabel { - color: var(--yoroi-palette-gray-800); - font-weight: 300; - font-size: 16px; - padding-left: 17px; - } - - .tokenList { - max-height: 0px; - height: 0px; - overflow: hidden; - transition: all .5s cubic-bezier(0,1,0,1); - - h1 { - margin-bottom: 10px; - font-size: 13px; - font-weight: 500; - color: #cccdcf; - } - - p { - color: var(--yoroi-palette-secondary-200); - font-weight: 500; - } - } - - .show { - height: auto; - max-height: 9999px; - transition: all .5s cubic-bezier(0,1,0,1); - } - -} - -:global(.YoroiRevamp) .component { - border-radius: 8px; -} - -:global(.YoroiModern) .component { - padding: 30px; - - .receiverInput { - letter-spacing: 0; - } -} diff --git a/packages/yoroi-extension/app/components/wallet/summary/WalletSummary.js b/packages/yoroi-extension/app/components/wallet/summary/WalletSummary.js deleted file mode 100644 index 50e50be726..0000000000 --- a/packages/yoroi-extension/app/components/wallet/summary/WalletSummary.js +++ /dev/null @@ -1,251 +0,0 @@ -// @flow -import { Component } from 'react'; -import type { Node } from 'react'; -import { observer } from 'mobx-react'; -import classnames from 'classnames'; -import { defineMessages, intlShape } from 'react-intl'; -import { ReactComponent as ExportTxToFileSvg } from '../../../assets/images/transaction/export-tx-to-file.inline.svg'; -import BorderedBox from '../../widgets/BorderedBox'; -import type { UnconfirmedAmount } from '../../../types/unconfirmedAmount.types'; -import globalMessages from '../../../i18n/global-messages'; -import styles from './WalletSummary.scss'; -import type { UnitOfAccountSettingType } from '../../../types/unitOfAccountType'; -import { formatValue } from '../../../utils/unit-of-account'; -import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; -import { splitAmount, truncateToken } from '../../../utils/formatters'; -import { MultiToken } from '../../../api/common/lib/MultiToken'; -import { hiddenAmount } from '../../../utils/strings'; -import type { TokenLookupKey } from '../../../api/common/lib/MultiToken'; -import { getTokenName } from '../../../stores/stateless/tokenHelpers'; -import type { TokenRow } from '../../../api/ada/lib/storage/database/primitives/tables'; -import BigNumber from 'bignumber.js'; - -const messages = defineMessages({ - pendingOutgoingConfirmationLabel: { - id: 'wallet.summary.page.pendingOutgoingConfirmationLabel', - defaultMessage: '!!!Outgoing pending confirmation', - }, - pendingIncomingConfirmationLabel: { - id: 'wallet.summary.page.pendingIncomingConfirmationLabel', - defaultMessage: '!!!Incoming pending confirmation', - }, - numOfTxsLabel: { - id: 'wallet.summary.page.transactionsLabel', - defaultMessage: '!!!Number of transactions', - }, - exportIconTooltip: { - id: 'wallet.transaction.export.exportIcon.tooltip', - defaultMessage: '!!!Export', - }, - dateSection: { - id: 'wallet.summary.page.dateTime', - defaultMessage: '!!!Date/time', - }, - typeSection: { - id: 'wallet.summary.page.type', - defaultMessage: '!!!Transaction type', - }, - statusSection: { - id: 'wallet.summary.page.status', - defaultMessage: '!!!Status', - }, -}); - -type Props = {| - +shouldHideBalance: boolean, - +pendingAmount: UnconfirmedAmount, - +isLoadingTransactions: boolean, - +openExportTxToFileDialog: void => void, - +unitOfAccountSetting: UnitOfAccountSettingType, - +getTokenInfo: ($ReadOnly>) => $ReadOnly, - +getHistoricalPrice: (from: string, to: string, timestamp: number) => ?string, -|}; - -@observer -export default class WalletSummary extends Component { - static contextTypes: {| intl: $npm$ReactIntl$IntlFormat |} = { - intl: intlShape.isRequired, - }; - - renderAmountDisplay: ({| - shouldHideBalance: boolean, - amount: MultiToken, - |}) => Node = request => { - const defaultEntry = request.amount.getDefaultEntry(); - const tokenInfo = this.props.getTokenInfo(defaultEntry); - - let balanceDisplay; - if (request.shouldHideBalance) { - balanceDisplay = {hiddenAmount}; - } else { - const shiftedAmount = defaultEntry.amount.shiftedBy(-tokenInfo.Metadata.numberOfDecimals); - const [beforeDecimalRewards, afterDecimalRewards] = splitAmount( - shiftedAmount, - tokenInfo.Metadata.numberOfDecimals - ); - - balanceDisplay = ( - <> - {beforeDecimalRewards} - {afterDecimalRewards} - - ); - } - - return ( - <> - {balanceDisplay} {truncateToken(getTokenName(tokenInfo))} - - ); - }; - - renderPendingAmount( - timestampedAmount: Array<{| amount: MultiToken, timestamp: number |}>, - label: string - ): Node { - if (!timestampedAmount.length) { - return null; - } - - const { - getHistoricalPrice, - unitOfAccountSetting, - shouldHideBalance, - getTokenInfo, - } = this.props; - - let pendingAmount = null; - if (false /* temporarily disabled */ && unitOfAccountSetting.enabled) { - const { currency } = unitOfAccountSetting; - if (!currency) { - throw new Error(`unexpected unit of account ${String(currency)}`); - } - if (shouldHideBalance) { - pendingAmount = ( - <> - {hiddenAmount} -   - {currency} - - ); - } else { - let totalFiatAmount = new BigNumber('0'); - for (const { amount, timestamp } of timestampedAmount) { - const tokenEntry = amount.getDefaultEntry(); - const tokenInfo = getTokenInfo(tokenEntry); - const ticker = tokenInfo.Metadata.ticker; - if (ticker == null) { - throw new Error('unexpected main token type'); - } - - const price = getHistoricalPrice(ticker, currency, timestamp); - if (price == null) { - totalFiatAmount = null; - break; - } - totalFiatAmount = totalFiatAmount.plus( - tokenEntry.amount - .shiftedBy(-tokenInfo.Metadata.numberOfDecimals) - .multipliedBy(String(price)) - ); - } - if (totalFiatAmount) { - const [beforeDecimal, afterDecimal] = formatValue(totalFiatAmount).split('.'); - - pendingAmount = ( - <> - {beforeDecimal} - {afterDecimal && .{afterDecimal}} -   - {currency} - - ); - } - } - } - - if (!pendingAmount) { - pendingAmount = this.renderAmountDisplay({ - shouldHideBalance, - amount: timestampedAmount - .map(({ amount }) => amount) - .reduce((accuAmount, curAmount) => accuAmount.joinAddCopy(curAmount)), - }); - } - - return ( -
- {label}:  - {pendingAmount} -
- ); - } - - render(): Node { - const { - pendingAmount, - isLoadingTransactions, - openExportTxToFileDialog, - } = this.props; - const { intl } = this.context; - - const content = ( -
-
-
- - {!isLoadingTransactions && ( - <> - {(pendingAmount.incoming.length > 0 || pendingAmount.outgoing.length > 0) && ( -
- {this.renderPendingAmount( - pendingAmount.incoming, - intl.formatMessage(messages.pendingIncomingConfirmationLabel) - )} - {this.renderPendingAmount( - pendingAmount.outgoing, - intl.formatMessage(messages.pendingOutgoingConfirmationLabel) - )} -
- )} - - )} -
-
-
- {!isLoadingTransactions ? ( - - - - ) : null} -
-
-
- {intl.formatMessage(messages.dateSection)} -
-
- {intl.formatMessage(messages.typeSection)} -
-
- {intl.formatMessage(messages.statusSection)} -
-
- {intl.formatMessage(globalMessages.feeLabel)} -
-
- {intl.formatMessage(globalMessages.amountLabel)} -
-
-
- ); - - return
{content}
; - } -} diff --git a/packages/yoroi-extension/app/containers/ExchangeEndPage.js b/packages/yoroi-extension/app/containers/ExchangeEndPage.js index 56b25a029b..5319af33cb 100644 --- a/packages/yoroi-extension/app/containers/ExchangeEndPage.js +++ b/packages/yoroi-extension/app/containers/ExchangeEndPage.js @@ -1,27 +1,18 @@ // @flow -import type { Node, ComponentType } from 'react'; +import type { 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 { Component } from 'react'; import { observer } from 'mobx-react'; -import { intlShape } from 'react-intl'; import { ROUTES } from '../routes-config'; import TopBarLayout from '../components/layout/TopBarLayout'; import BannerContainer from './banners/BannerContainer'; import SidebarContainer from './SidebarContainer'; -import { withLayout } from '../styles/context/layout'; -import type { LayoutComponentMap } from '../styles/context/layout'; import ExchangeEndPageContent from '../components/buySell/ExchangeEndPage'; -type InjectedLayoutProps = {| - +selectedLayout: string, - +renderLayoutComponent: LayoutComponentMap => Node, -|}; - -type Props = {| ...StoresAndActionsProps, ...InjectedLayoutProps |}; - @observer -class ExchangeEndPage extends Component { +export default class ExchangeEndPage extends Component { static contextTypes: {| intl: $npm$ReactIntl$IntlFormat |} = { intl: intlShape.isRequired, }; @@ -29,10 +20,10 @@ class ExchangeEndPage extends Component { render(): Node { const { actions, stores } = this.props; - const content = ( + return ( } - sidebar={} + banner={} + sidebar={} showInContainer showAsCard > @@ -41,12 +32,5 @@ class ExchangeEndPage extends Component { /> ); - - return this.props.renderLayoutComponent({ - CLASSIC: content, - REVAMP: content, - }); } } - -export default (withLayout(ExchangeEndPage): ComponentType); diff --git a/packages/yoroi-extension/app/containers/SidebarContainer.js b/packages/yoroi-extension/app/containers/SidebarContainer.js index 5fd830a663..ebadc7390b 100644 --- a/packages/yoroi-extension/app/containers/SidebarContainer.js +++ b/packages/yoroi-extension/app/containers/SidebarContainer.js @@ -1,32 +1,20 @@ // @flow -import type { ComponentType, Node } from 'react'; +import type { Node } from 'react'; import { Component } from 'react'; import { observer } from 'mobx-react'; -import Sidebar from '../components/topbar/Sidebar'; import type { StoresAndActionsProps } from '../types/injectedProps.types'; -import { allCategories, allCategoriesRevamp } from '../stores/stateless/sidebarCategories'; import type { SidebarCategoryRevamp } from '../stores/stateless/sidebarCategories'; +import { allCategoriesRevamp } from '../stores/stateless/sidebarCategories'; import SidebarRevamp from '../components/topbar/SidebarRevamp'; -import { withLayout } from '../styles/context/layout'; -import type { LayoutComponentMap } from '../styles/context/layout'; import { ROUTES } from '../routes-config'; import { runInAction } from 'mobx'; -type Props = {| - ...StoresAndActionsProps, -|}; -type InjectedLayoutProps = {| - +selectedLayout: string, - +renderLayoutComponent: LayoutComponentMap => Node, -|}; -type AllProps = {| ...Props, ...InjectedLayoutProps |}; - type State = {| featureFlags: { [string]: boolean }, |}; @observer -class SidebarContainer extends Component { +export default class SidebarContainer extends Component { state: State = { featureFlags: {}, @@ -64,29 +52,7 @@ class SidebarContainer extends Component { render(): Node { const { stores, actions } = this.props; - const { profile } = stores; - - const SidebarComponent = ( - { - actions.router.goToRoute.trigger({ - route: category.route, - }); - }} - isActiveCategory={category => stores.app.currentRoute.startsWith(category.route)} - categories={allCategories.filter(category => - category.isVisible({ - hasAnyWallets: stores.wallets.hasAnyWallets === true, - selected: stores.wallets.selected, - currentRoute: stores.app.currentRoute, - }) - )} - onToggleSidebar={this.toggleSidebar} - isSidebarExpanded={profile.isSidebarExpanded} - /> - ); - - const SidebarRevampComponent = ( + return ( { actions.router.goToRoute.trigger({ @@ -111,11 +77,5 @@ class SidebarContainer extends Component { )} /> ); - - return this.props.renderLayoutComponent({ - CLASSIC: SidebarComponent, - REVAMP: SidebarRevampComponent, - }); } } -export default (withLayout(SidebarContainer): ComponentType); diff --git a/packages/yoroi-extension/app/containers/wallet/WalletSendPage.js b/packages/yoroi-extension/app/containers/wallet/WalletSendPage.js index b4c1900d67..c171dcf15c 100644 --- a/packages/yoroi-extension/app/containers/wallet/WalletSendPage.js +++ b/packages/yoroi-extension/app/containers/wallet/WalletSendPage.js @@ -1,5 +1,5 @@ // @flow -import type { ComponentType, Node } from 'react'; +import type { Node } from 'react'; import { Component } from 'react'; import { observer } from 'mobx-react'; import { action, observable, runInAction } from 'mobx'; @@ -8,7 +8,6 @@ import { defineMessages, intlShape } from 'react-intl'; import { ROUTES } from '../../routes-config'; import type { StoresAndActionsProps } from '../../types/injectedProps.types'; -import WalletSendFormClassic from '../../components/wallet/send/WalletSendForm'; import WalletSendFormRevamp from '../../components/wallet/send/WalletSendFormRevamp'; // Web Wallet Confirmation @@ -16,14 +15,11 @@ import WalletSendConfirmationDialogContainer from './dialogs/WalletSendConfirmat import WalletSendConfirmationDialog from '../../components/wallet/send/WalletSendConfirmationDialog'; import MemoNoExternalStorageDialog from '../../components/wallet/memos/MemoNoExternalStorageDialog'; import { HaskellShelleyTxSignRequest } from '../../api/ada/transactions/shelley/HaskellShelleyTxSignRequest'; -import { validateAmount } from '../../utils/validations'; import { addressToDisplayString } from '../../api/ada/lib/storage/bridge/utils'; import type { TokenRow } from '../../api/ada/lib/storage/database/primitives/tables'; import { genLookupOrFail } from '../../stores/stateless/tokenHelpers'; import BigNumber from 'bignumber.js'; import TransactionSuccessDialog from '../../components/wallet/send/TransactionSuccessDialog'; -import type { LayoutComponentMap } from '../../styles/context/layout'; -import { withLayout } from '../../styles/context/layout'; // Hardware Wallet Confirmation import HWSendConfirmationDialog from '../../components/wallet/send/HWSendConfirmationDialog'; @@ -54,17 +50,8 @@ const messages = defineMessages({ }, }); -type Props = {| - ...StoresAndActionsProps, -|}; -type InjectedLayoutProps = {| - +renderLayoutComponent: LayoutComponentMap => Node, - +selectedLayout: string, -|}; -type AllProps = {| ...Props, ...InjectedLayoutProps |}; - @observer -class WalletSendPage extends Component { +export default class WalletSendPage extends Component { static contextTypes: {| intl: $npm$ReactIntl$IntlFormat |} = { intl: intlShape.isRequired, }; @@ -160,127 +147,73 @@ class WalletSendPage extends Component { actions.dialogs.closeActiveDialog.trigger(); } - const targetDialog = selected.type === 'mnemonic' - ? WalletSendConfirmationDialog - : HWSendConfirmationDialog; - - const onSubmit = () => { - actions.dialogs.push.trigger({ - dialog: targetDialog, - }); - txBuilderActions.updateTentativeTx.trigger(); - }; - const defaultToken = this.props.stores.tokenInfoStore.getDefaultTokenInfo( selected.networkId ); const network = getNetworkById(selected.networkId); - if (this.props.selectedLayout === 'REVAMP') { - const addressStore = this.props.stores.substores.ada.addresses; - const resolveDomainAddressFunc = addressStore.domainResolverSupported() - ? addressStore.resolveDomainAddress.bind(addressStore) - : null; - return ( - <> - txBuilderActions.updateReceiver.trigger(addr)} - updateAmount={(value: ?BigNumber) => txBuilderActions.updateAmount.trigger(value)} - updateSendAllStatus={txBuilderActions.updateSendAllStatus.trigger} - fee={transactionBuilderStore.fee} - isCalculatingFee={transactionBuilderStore.createUnsignedTx.isExecuting} - reset={txBuilderActions.reset.trigger} - error={transactionBuilderStore.createUnsignedTx.error} - // Min ADA for all tokens that is already included in the tx - minAda={transactionBuilderStore.minAda} - uriParams={this.props.stores.loading.uriParams} - resetUriParams={this.props.stores.loading.resetUriParams} - memo={transactionBuilderStore.memo} - showMemo={this.showMemo} - updateMemo={(content: void | string) => txBuilderActions.updateMemo.trigger(content)} - onAddMemo={() => - this.showMemoDialog({ - dialog: MemoNoExternalStorageDialog, - continuation: this.toggleShowMemo, - })} - spendableBalance={this.props.stores.transactions.balance} - onAddToken={txBuilderActions.addToken.trigger} - onRemoveTokens={txBuilderActions.removeTokens.trigger} - plannedTxInfoMap={transactionBuilderStore.plannedTxInfoMap} - isDefaultIncluded={transactionBuilderStore.isDefaultIncluded} - openDialog={this.openDialog} - closeDialog={this.props.actions.dialogs.closeActiveDialog.trigger} - isOpen={uiDialogs.isOpen} - openTransactionSuccessDialog={this.openTransactionSuccessDialog.bind(this)} - unitOfAccountSetting={this.props.stores.profile.unitOfAccount} - getCurrentPrice={this.props.stores.coinPriceStore.getCurrentPrice} - calculateMaxAmount={txBuilderActions.calculateMaxAmount.trigger} - maxSendableAmount={transactionBuilderStore.maxSendableAmount} - signRequest={transactionBuilderStore.tentativeTx} - staleTx={transactionBuilderStore.txMismatch} - sendMoneyRequest={this.props.stores.wallets.sendMoneyRequest} - 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} - /> - {this.renderDialog()} - - ); - } - + const addressStore = this.props.stores.substores.ada.addresses; + const resolveDomainAddressFunc = addressStore.domainResolverSupported() + ? addressStore.resolveDomainAddress.bind(addressStore) + : null; return ( <> - - validateAmount( - amount, - transactionBuilderStore.selectedToken ?? defaultToken, - transactionBuilderStore.minAda.getDefault(), - this.context.intl - ) - } + selectedWallet={selected} + selectedExplorer={this.props.stores.explorers.selectedExplorer} + selectedToken={transactionBuilderStore.selectedToken} defaultToken={defaultToken} getTokenInfo={genLookupOrFail(this.props.stores.tokenInfoStore.tokenInfo)} - onSubmit={onSubmit} + onSubmit={txBuilderActions.updateTentativeTx.trigger} totalInput={transactionBuilderStore.totalInput} hasAnyPending={hasAnyPending} + shouldSendAll={transactionBuilderStore.shouldSendAll} updateReceiver={(addr: void | string) => txBuilderActions.updateReceiver.trigger(addr)} updateAmount={(value: ?BigNumber) => txBuilderActions.updateAmount.trigger(value)} - updateMemo={(content: void | string) => txBuilderActions.updateMemo.trigger(content)} - shouldSendAll={transactionBuilderStore.shouldSendAll} updateSendAllStatus={txBuilderActions.updateSendAllStatus.trigger} fee={transactionBuilderStore.fee} isCalculatingFee={transactionBuilderStore.createUnsignedTx.isExecuting} reset={txBuilderActions.reset.trigger} error={transactionBuilderStore.createUnsignedTx.error} + // Min ADA for all tokens that is already included in the tx + minAda={transactionBuilderStore.minAda} uriParams={this.props.stores.loading.uriParams} resetUriParams={this.props.stores.loading.resetUriParams} + memo={transactionBuilderStore.memo} showMemo={this.showMemo} - onAddMemo={() => this.showMemoDialog({ - dialog: MemoNoExternalStorageDialog, - continuation: this.toggleShowMemo, - })} + updateMemo={(content: void | string) => txBuilderActions.updateMemo.trigger(content)} + onAddMemo={() => + this.showMemoDialog({ + dialog: MemoNoExternalStorageDialog, + continuation: this.toggleShowMemo, + })} spendableBalance={this.props.stores.transactions.balance} onAddToken={txBuilderActions.addToken.trigger} - selectedToken={transactionBuilderStore.selectedToken} + onRemoveTokens={txBuilderActions.removeTokens.trigger} + plannedTxInfoMap={transactionBuilderStore.plannedTxInfoMap} + isDefaultIncluded={transactionBuilderStore.isDefaultIncluded} + openDialog={this.openDialog} + closeDialog={this.props.actions.dialogs.closeActiveDialog.trigger} + isOpen={uiDialogs.isOpen} + openTransactionSuccessDialog={this.openTransactionSuccessDialog.bind(this)} + unitOfAccountSetting={this.props.stores.profile.unitOfAccount} + getCurrentPrice={this.props.stores.coinPriceStore.getCurrentPrice} + calculateMaxAmount={txBuilderActions.calculateMaxAmount.trigger} + maxSendableAmount={transactionBuilderStore.maxSendableAmount} + signRequest={transactionBuilderStore.tentativeTx} + staleTx={transactionBuilderStore.txMismatch} + sendMoneyRequest={this.props.stores.wallets.sendMoneyRequest} + 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} /> {this.renderDialog()} @@ -589,5 +522,3 @@ class WalletSendPage extends Component { ); }; } - -export default (withLayout(WalletSendPage): ComponentType); diff --git a/packages/yoroi-extension/app/containers/wallet/WalletSummaryPage.js b/packages/yoroi-extension/app/containers/wallet/WalletSummaryPage.js index 07b6444986..d001397981 100644 --- a/packages/yoroi-extension/app/containers/wallet/WalletSummaryPage.js +++ b/packages/yoroi-extension/app/containers/wallet/WalletSummaryPage.js @@ -1,20 +1,16 @@ // @flow -import type { ComponentType, Node } from 'react'; +import type { Node } from 'react'; import { Component } from 'react'; import { observer } from 'mobx-react'; import { observable, runInAction } from 'mobx'; import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; -import { FormattedHTMLMessage, intlShape } from 'react-intl'; +import { intlShape } from 'react-intl'; import { ROUTES } from '../../routes-config'; -import type { Notification } from '../../types/notification.types'; -import NotificationMessage from '../../components/widgets/NotificationMessage'; import Dialog from '../../components/widgets/Dialog'; import LoadingSpinner from '../../components/widgets/LoadingSpinner'; import globalMessages from '../../i18n/global-messages'; -import { ReactComponent as successIcon } from '../../assets/images/success-small.inline.svg'; import type { StoresAndActionsProps } from '../../types/injectedProps.types'; import WalletTransactionsListRevamp from '../../components/wallet/transactions/WalletTransactionsListRevamp'; -import WalletSummary from '../../components/wallet/summary/WalletSummary'; import VerticalFlexContainer from '../../components/layout/VerticalFlexContainer'; import ExportTransactionDialog from '../../components/wallet/export/ExportTransactionDialog'; import AddMemoDialog from '../../components/wallet/memos/AddMemoDialog'; @@ -26,8 +22,6 @@ import config from '../../config'; import { genAddressLookup } from '../../stores/stateless/addressStores'; import { addressToDisplayString } from '../../api/ada/lib/storage/bridge/utils'; import { genLookupOrFail, genLookupOrNull } from '../../stores/stateless/tokenHelpers'; -import type { LayoutComponentMap } from '../../styles/context/layout'; -import { withLayout } from '../../styles/context/layout'; import WalletSummaryRevamp from '../../components/wallet/summary/WalletSummaryRevamp'; import BuySellDialog from '../../components/buySell/BuySellDialog'; import WalletEmptyBanner from './WalletEmptyBanner'; @@ -35,21 +29,8 @@ import { Box } from '@mui/material'; import { getNetworkById } from '../../api/ada/lib/storage/database/prepackaged/networks'; import { noop } from '../../coreUtils'; -type Props = StoresAndActionsProps; -type InjectedLayoutProps = {| - +renderLayoutComponent: LayoutComponentMap => Node, - +selectedLayout: string, -|}; -type AllProps = {| ...Props, ...InjectedLayoutProps |}; - -const targetNotificationIds = [ - globalMessages.walletCreatedNotificationMessage.id, - globalMessages.walletRestoredNotificationMessage.id, - globalMessages.integratedNotificationMessage.id, -]; - @observer -class WalletSummaryPage extends Component { +export default class WalletSummaryPage extends Component { static contextTypes: {| intl: $npm$ReactIntl$IntlFormat |} = { intl: intlShape.isRequired, }; @@ -164,8 +145,6 @@ class WalletSummaryPage extends Component { } } - const notification = this._getThisPageActiveNotification(); - let exportDialog = ( @@ -192,109 +171,7 @@ class WalletSummaryPage extends Component { ); } - const walletSummaryPageClassic = ( - - - {!!notification && ( - - )} - - - - {walletTransactions} - - {uiDialogs.isOpen(ExportTransactionDialog) ? exportDialog : null} - - {uiDialogs.isOpen(AddMemoDialog) ? ( - { - if (memos.selectedTransaction == null) throw new Error('no selected transaction. Should never happen'); - return memos.selectedTransaction; - })()} - error={memos.error} - onCancel={actions.memos.closeMemoDialog.trigger} - onSubmit={values => { - return actions.memos.saveTxMemo.trigger(values); - }} - plateTextPart={selected.plate.TextPart} - /> - ) : null} - - {uiDialogs.isOpen(MemoNoExternalStorageDialog) ? ( - { - actions.memos.closeMemoDialog.trigger(); - actions.router.goToRoute.trigger({ route: ROUTES.SETTINGS.EXTERNAL_STORAGE }); - }} - onAcknowledge={() => { - this.props.stores.uiDialogs.getParam<(void) => void>('continuation')?.(); - }} - /> - ) : null} - - {uiDialogs.isOpen(EditMemoDialog) ? ( - { - 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); - if (memo == null) throw new Error('Should never happen'); - return memo; - })()} - error={memos.error} - onCancel={actions.memos.closeMemoDialog.trigger} - onClickDelete={this.openDeleteMemoDialog} - onSubmit={values => { - return actions.memos.updateTxMemo.trigger(values); - }} - plateTextPart={selected.plate.TextPart} - /> - ) : null} - - {uiDialogs.isOpen(DeleteMemoDialog) ? ( - { - if (memos.selectedTransaction == null) throw new Error('no selected transaction. Should never happen'); - return memos.selectedTransaction; - })()} - error={memos.error} - onCancel={() => { - actions.memos.closeMemoDialog.trigger(); - }} - onClose={actions.memos.closeMemoDialog.trigger} - onDelete={txHash => { - return actions.memos.deleteTxMemo.trigger({ - publicDeriverId: selected.publicDeriverId, - plateTextPart: selected.plate.TextPart, - txHash, - }); - }} - /> - ) : null} - - ); - - const walletSummaryPageRevamp = ( + return ( { getHistoricalPrice={this.props.stores.coinPriceStore.getHistoricalPrice} shouldShowEmptyBanner={!isLoading && !hasAny} emptyBannerComponent={ - this.props.actions.dialogs.open.trigger({ dialog: BuySellDialog })} /> + this.props.actions.dialogs.open.trigger({ dialog: BuySellDialog })}/> } /> @@ -391,25 +269,8 @@ class WalletSummaryPage extends Component { ) : null} ); - - return this.props.renderLayoutComponent({ - CLASSIC: walletSummaryPageClassic, - REVAMP: walletSummaryPageRevamp, - }); } - _getThisPageActiveNotification: void => ?Notification = () => { - let notification = null; - - const { mostRecentActiveNotification } = this.props.stores.uiNotifications; - const activeNotificationId = mostRecentActiveNotification ? mostRecentActiveNotification.id : ''; - if (targetNotificationIds.includes(activeNotificationId)) { - notification = mostRecentActiveNotification; - } - - return notification; - }; - openExportTransactionDialog: void => void = () => { const { actions } = this.props; actions.dialogs.push.trigger({ dialog: ExportTransactionDialog }); @@ -442,4 +303,3 @@ class WalletSummaryPage extends Component { || delegation.hasRewardHistory(publicDeriverId); }; } -export default (withLayout(WalletSummaryPage): ComponentType); diff --git a/packages/yoroi-extension/app/containers/wallet/staking/SeizaFetcher.js b/packages/yoroi-extension/app/containers/wallet/staking/SeizaFetcher.js index 2c7c68eaf7..cfe25a2634 100644 --- a/packages/yoroi-extension/app/containers/wallet/staking/SeizaFetcher.js +++ b/packages/yoroi-extension/app/containers/wallet/staking/SeizaFetcher.js @@ -1,7 +1,7 @@ // @flow import { Component } from 'react'; -import type { Node, ComponentType } from 'react'; +import type { Node } from 'react'; import { action, observable } from 'mobx'; import { intlShape } from 'react-intl'; import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; @@ -9,8 +9,6 @@ import environment from '../../../environment'; import VerticallyCenteredLayout from '../../../components/layout/VerticallyCenteredLayout'; import LoadingSpinner from '../../../components/widgets/LoadingSpinner'; import { observer } from 'mobx-react'; -import { withLayout } from '../../../styles/context/layout'; -import type { Layouts } from '../../../styles/context/layout'; import { Box, useTheme } from '@mui/material'; export type SocialLinks = {| @@ -47,14 +45,8 @@ type Props = {| setFirstPool?: PoolData => void, |}; -type InjectedProps = {| - +selectedLayout: Layouts, -|}; - -type AllProps = {| ...Props, ...InjectedProps |}; - @observer -class SeizaFetcher extends Component { +export default class SeizaFetcher extends Component { static defaultProps: {| children: void |} = { children: undefined, }; @@ -114,7 +106,7 @@ class SeizaFetcher extends Component { this.iframe = frame; }; - constructor(props: AllProps) { + constructor(props: Props) { super(props); window.addEventListener('message', this.messageHandler, false); } @@ -185,7 +177,7 @@ class SeizaFetcher extends Component { finalURL += totalAda == null ? '' : `&totalAda=${totalAda}`; // adds selected layout to customize revamp design - finalURL += `&layout=${this.props.selectedLayout}`; + finalURL += `&layout=REVAMP`; finalURL += `&bias=${bias}`; return finalURL; @@ -200,7 +192,6 @@ class SeizaFetcher extends Component { this.frameHeight = Math.max(window.innerHeight - this.iframe.getBoundingClientRect().top - 30, 0); }; } -export default (withLayout(SeizaFetcher): ComponentType); const SeizaFetcherComp = ({ setFrame, stakingUrl, iframe, frameHeight }) => { const { name } = useTheme(); diff --git a/packages/yoroi-extension/app/stores/stateless/sidebarCategories.js b/packages/yoroi-extension/app/stores/stateless/sidebarCategories.js index 25390a4785..61f11e21c3 100644 --- a/packages/yoroi-extension/app/stores/stateless/sidebarCategories.js +++ b/packages/yoroi-extension/app/stores/stateless/sidebarCategories.js @@ -31,6 +31,7 @@ export type SidebarCategory = {| |}) => boolean, |}; +// export const allCategories: Array = []; function registerCategory(category: SidebarCategory): SidebarCategory { allCategories.push(category); diff --git a/packages/yoroi-extension/app/styles/context/layout.js b/packages/yoroi-extension/app/styles/context/layout.js index 4d4a9e717f..17de64aad2 100644 --- a/packages/yoroi-extension/app/styles/context/layout.js +++ b/packages/yoroi-extension/app/styles/context/layout.js @@ -10,7 +10,6 @@ export type LayoutComponentMap = {| |}; export type InjectedLayoutProps = {| - +selectedLayout: Layouts, +isRevampLayout: boolean, +renderLayoutComponent: (layoutMap: LayoutComponentMap) => Node, |}; @@ -21,7 +20,6 @@ const LayoutProvider = (props: Object): Node => { return ( disabling legacy UI From a0471ad652e631c21a7a69f620b20eed6767fed9 Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Sun, 13 Oct 2024 18:10:17 +0300 Subject: [PATCH 19/76] removed legacy prop `currentTheme` --- packages/yoroi-extension/app/App.js | 2 +- packages/yoroi-extension/app/Routes.js | 3 +- .../app/components/layout/TopBarLayout.js | 62 +++-------------- .../components/wallet/add/AddAnotherWallet.js | 55 ---------------- .../wallet/add/AddAnotherWallet.scss | 32 --------- .../app/containers/ExchangeEndPage.js | 1 - .../app/containers/settings/Settings.js | 2 - .../app/containers/swap/SwapPageContainer.js | 1 - .../app/containers/wallet/AddWalletPage.js | 66 ++----------------- .../app/containers/wallet/AssetsWrapper.js | 1 - .../app/containers/wallet/Wallet.js | 2 - .../containers/wallet/staking/StakingPage.js | 1 - .../containers/wallet/voting/VotingPage.js | 1 - .../app/styles/context/layout.js | 2 - .../app/styles/context/mode.js | 13 ++-- 15 files changed, 24 insertions(+), 220 deletions(-) delete mode 100644 packages/yoroi-extension/app/components/wallet/add/AddAnotherWallet.js delete mode 100644 packages/yoroi-extension/app/components/wallet/add/AddAnotherWallet.scss diff --git a/packages/yoroi-extension/app/App.js b/packages/yoroi-extension/app/App.js index a365eeb3e4..24b542d1b3 100644 --- a/packages/yoroi-extension/app/App.js +++ b/packages/yoroi-extension/app/App.js @@ -90,7 +90,7 @@ class App extends Component { return (
- + {globalStyles(muiTheme)} diff --git a/packages/yoroi-extension/app/Routes.js b/packages/yoroi-extension/app/Routes.js index 18b96f082c..4c8f3046bc 100644 --- a/packages/yoroi-extension/app/Routes.js +++ b/packages/yoroi-extension/app/Routes.js @@ -7,7 +7,7 @@ import type { ConfigType } from '../config/config-types'; import type { ActionsMap } from './actions/index'; import ConnectedWebsitesPage, { ConnectedWebsitesPagePromise } from './containers/dapp-connector/ConnectedWebsitesContainer'; import Transfer, { WalletTransferPagePromise } from './containers/transfer/Transfer'; -import AddWalletPage, { AddAnotherWalletPromise } from './containers/wallet/AddWalletPage'; +import AddWalletPage from './containers/wallet/AddWalletPage'; import StakingPage, { StakingPageContentPromise } from './containers/wallet/staking/StakingPage'; import VotingPage, { VotingPageContentPromise } from './containers/wallet/voting/VotingPage'; import { ROUTES } from './routes-config'; @@ -149,7 +149,6 @@ const ExchangeEndPagePromise = () => import('./containers/ExchangeEndPage'); const ExchangeEndPage = React.lazy(ExchangeEndPagePromise); export const LazyLoadPromises: Array<() => any> = [ - AddAnotherWalletPromise, StakingPageContentPromise, CreateWalletPagePromise, RestoreWalletPagePromise, diff --git a/packages/yoroi-extension/app/components/layout/TopBarLayout.js b/packages/yoroi-extension/app/components/layout/TopBarLayout.js index c436fe9446..04a3beeeee 100644 --- a/packages/yoroi-extension/app/components/layout/TopBarLayout.js +++ b/packages/yoroi-extension/app/components/layout/TopBarLayout.js @@ -2,8 +2,6 @@ import { Box } from '@mui/system'; import { observer } from 'mobx-react'; import type { Node, ComponentType } from 'react'; -import { withLayout } from '../../styles/context/layout'; -import { THEMES } from '../../styles/themes'; import styles from './TopBarLayout.scss'; type Props = {| @@ -15,15 +13,10 @@ type Props = {| +notification?: ?Node, +languageSelectionBackground?: boolean, +showInContainer?: boolean, - +showAsCard?: boolean, - +asModern?: boolean, +withPadding?: boolean, // default: true +bgcolor?: string, |}; -type InjectedProps = {| isRevampLayout: boolean, currentTheme: string |}; - -type AllProps = {| ...Props, ...InjectedProps |}; /** Adds a top bar above the wrapped node */ function TopBarLayout({ banner, @@ -34,16 +27,9 @@ function TopBarLayout({ notification, languageSelectionBackground, showInContainer, - showAsCard, - currentTheme, - isRevampLayout, - asModern, withPadding, bgcolor, -}: AllProps) { - const isModern = currentTheme === THEMES.YOROI_MODERN; - const isRevamp = isRevampLayout && asModern !== true && !isModern; - +}: Props) { const getContentUnderBanner: void => Node = () => { const topbarComponent = {topbar}; const navbarComponent = {navbar}; @@ -61,8 +47,8 @@ function TopBarLayout({ height: '7px', display: 'block', }, - boxShadow: !isRevamp && showAsCard === true && '0 2px 12px 0 rgba(0, 0, 0, 0.06)', - borderRadius: !isRevamp && showAsCard === true && '8px', + boxShadow: false, + borderRadius: false, ...(showInContainer === true && { bgcolor: 'ds.bg_color_max', width: '100%', @@ -72,10 +58,10 @@ function TopBarLayout({ flex: '0 1 auto', height: '100%', }), - overflow: isRevamp ? 'auto' : 'unset', + overflow: 'auto', }} > - {isRevamp ? ( + {( - ) : ( - - {children} - )} ); if (showInContainer === true) { - const boxProperties = { - height: '100%', - minHeight: '200px', - backgroundColor: isRevamp ? 'ds.bg_color_max' : 'var(--yoroi-palette-gray-50)', - maxWidth: '1295px', - paddingLeft: '40px', - paddingRight: '40px', - width: '100%', - marginLeft: 'auto', - marginRight: 'auto', - display: 'flex', - flexDirection: 'column', - maxHeight: 'calc(100vh - 110px)', - overflow: isRevamp ? 'unset' : 'hidden', - pb: isRevamp ? '0px' : '100px', - }; - - return isRevamp ? ( + return ( {content} - ) : ( - {content} ); } return content; @@ -164,7 +122,7 @@ function TopBarLayout({ {banner} @@ -202,7 +160,7 @@ function TopBarLayout({ ); } -export default (withLayout(observer(TopBarLayout)): ComponentType); +export default (observer(TopBarLayout): ComponentType); TopBarLayout.defaultProps = { banner: undefined, @@ -213,8 +171,6 @@ TopBarLayout.defaultProps = { notification: undefined, languageSelectionBackground: false, showInContainer: false, - showAsCard: false, - asModern: false, withPadding: true, bgcolor: undefined, }; diff --git a/packages/yoroi-extension/app/components/wallet/add/AddAnotherWallet.js b/packages/yoroi-extension/app/components/wallet/add/AddAnotherWallet.js deleted file mode 100644 index eaf6bfddb3..0000000000 --- a/packages/yoroi-extension/app/components/wallet/add/AddAnotherWallet.js +++ /dev/null @@ -1,55 +0,0 @@ -// @flow -import { Component } from 'react'; -import type { Node } from 'react'; -import { observer } from 'mobx-react'; -import classnames from 'classnames'; - -import MainCards from './MainCards'; -import { ReactComponent as LogoYoroiIcon } from '../../../assets/images/yoroi-logo-white.inline.svg'; -import { ReactComponent as NightlyLogo } from '../../../assets/images/yoroi-logo-nightly.inline.svg'; - -import styles from './AddAnotherWallet.scss'; - -import environment from '../../../environment'; - -type Props = {| - +onCreate: void => void, - +onRestore: void => void, - +onHardwareConnect: void => void, -|}; - -@observer -export default class AddAnotherWallet extends Component { - - getLogo: void => string = () => { - if (environment.isNightly()) { - return NightlyLogo; - } - return LogoYoroiIcon; - } - - render(): Node { - const LogoIcon = this.getLogo(); - const iconClass = classnames( - styles.heroLogo, - ); - return ( -
-
-
-
- -
-
- -
-
-
-
- ); - } -} diff --git a/packages/yoroi-extension/app/components/wallet/add/AddAnotherWallet.scss b/packages/yoroi-extension/app/components/wallet/add/AddAnotherWallet.scss deleted file mode 100644 index d303064bca..0000000000 --- a/packages/yoroi-extension/app/components/wallet/add/AddAnotherWallet.scss +++ /dev/null @@ -1,32 +0,0 @@ -.component { - height: 100%; - overflow: auto; - - .hero { - min-height: 100%; - max-width: 1366px; - margin: 0 auto; - padding: 20px 15px; - display: flex; - align-items: center; - } - - .heroInner { - display: flex; - position: relative; - z-index: 1; - justify-content: space-between; - width: 100%; - - flex-direction: column; - align-items: center; - } - - .heroLogo { - display: block; - position: relative; - top: 50%; - margin: auto auto; - margin-bottom: 24px; - } -} diff --git a/packages/yoroi-extension/app/containers/ExchangeEndPage.js b/packages/yoroi-extension/app/containers/ExchangeEndPage.js index 5319af33cb..df00ffe134 100644 --- a/packages/yoroi-extension/app/containers/ExchangeEndPage.js +++ b/packages/yoroi-extension/app/containers/ExchangeEndPage.js @@ -25,7 +25,6 @@ export default class ExchangeEndPage extends Component { banner={} sidebar={} showInContainer - showAsCard > actions.router.goToRoute.trigger({ route: ROUTES.WALLETS.TRANSACTIONS })} diff --git a/packages/yoroi-extension/app/containers/settings/Settings.js b/packages/yoroi-extension/app/containers/settings/Settings.js index 09bab315cd..602c1373aa 100644 --- a/packages/yoroi-extension/app/containers/settings/Settings.js +++ b/packages/yoroi-extension/app/containers/settings/Settings.js @@ -74,7 +74,6 @@ class Settings extends Component { /> } showInContainer - showAsCard > {children != null ? children : null} @@ -96,7 +95,6 @@ class Settings extends Component { /> } showInContainer - showAsCard > {children} diff --git a/packages/yoroi-extension/app/containers/swap/SwapPageContainer.js b/packages/yoroi-extension/app/containers/swap/SwapPageContainer.js index 777a82e203..d7c893dbe7 100644 --- a/packages/yoroi-extension/app/containers/swap/SwapPageContainer.js +++ b/packages/yoroi-extension/app/containers/swap/SwapPageContainer.js @@ -73,7 +73,6 @@ class SwapPageContainer extends Component { /> } showInContainer - showAsCard withPadding={false} > diff --git a/packages/yoroi-extension/app/containers/wallet/AddWalletPage.js b/packages/yoroi-extension/app/containers/wallet/AddWalletPage.js index 65f7d745e0..34011f52d0 100644 --- a/packages/yoroi-extension/app/containers/wallet/AddWalletPage.js +++ b/packages/yoroi-extension/app/containers/wallet/AddWalletPage.js @@ -1,20 +1,18 @@ // @flow -import type { Node, ComponentType } from 'react'; +import type { ComponentType, Node } from 'react'; +import { Component } from 'react'; import type { StoresAndActionsProps } from '../../types/injectedProps.types'; import type { RestoreModeType } from '../../actions/common/wallet-restore-actions'; import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; +import { intlShape } from 'react-intl'; import type { LayoutComponentMap } from '../../styles/context/layout'; -import { Component, lazy } from 'react'; +import { withLayout } from '../../styles/context/layout'; import { observer } from 'mobx-react'; -import { intlShape } from 'react-intl'; import { ROUTES } from '../../routes-config'; import { networks } from '../../api/ada/lib/storage/database/prepackaged/networks'; -import { withLayout } from '../../styles/context/layout'; import { Box } from '@mui/material'; -import globalMessages from '../../i18n/global-messages'; import TopBarLayout from '../../components/layout/TopBarLayout'; import BannerContainer from '../banners/BannerContainer'; -import WalletAdd from '../../components/wallet/WalletAdd'; import WalletCreateDialogContainer from './dialogs/WalletCreateDialogContainer'; import WalletCreateDialog from '../../components/wallet/WalletCreateDialog'; import WalletBackupDialogContainer from './dialogs/WalletBackupDialogContainer'; @@ -28,14 +26,8 @@ import WalletConnectHWOptionDialog from '../../components/wallet/add/option-dial import WalletTrezorConnectDialogContainer from './dialogs/WalletTrezorConnectDialogContainer'; import WalletLedgerConnectDialogContainer from './dialogs/WalletLedgerConnectDialogContainer'; import SidebarContainer from '../SidebarContainer'; -import NavBar from '../../components/topbar/NavBar'; -import NavBarTitle from '../../components/topbar/NavBarTitle'; import AddWalletPageRevamp from './AddWalletPageRevamp'; -export const AddAnotherWalletPromise: void => Promise = () => - import('../../components/wallet/add/AddAnotherWallet'); -const AddAnotherWallet = lazy(AddAnotherWalletPromise); - type Props = StoresAndActionsProps; type InjectedLayoutProps = {| +renderLayoutComponent: LayoutComponentMap => Node |}; type AllProps = {| ...Props, ...InjectedLayoutProps |}; @@ -184,46 +176,7 @@ class AddWalletPage extends Component { ); } - let addWalletPageClassic = ( - } - sidebar={} - navbar={ - - } - /> - } - showInContainer - > - this.openDialogWrapper(WalletConnectHWOptionDialog)} - onCreate={() => this.openDialogWrapper(WalletCreateDialog)} - onRestore={() => this.openDialogWrapper(WalletRestoreOptionDialog)} - /> - {activeDialog} - - ); - const { hasAnyWallets } = this.props.stores.wallets; - if (!hasAnyWallets) { - addWalletPageClassic = ( - } - asModern - > - this.openDialogWrapper(WalletConnectHWOptionDialog)} - onCreate={() => this.openDialogWrapper(WalletCreateDialog)} - onRestore={() => this.openDialogWrapper(WalletRestoreOptionDialog)} - onSettings={this._goToSettingsRoot} - /> - {activeDialog} - - ); - } - const goToRoute = this.props.actions.router.goToRoute; const addWalletPageComponent = ( <> @@ -238,23 +191,18 @@ class AddWalletPage extends Component { ); - const addWalletPageRevamp = !hasAnyWallets ? ( + return !hasAnyWallets ? ( {addWalletPageComponent} ) : ( } - sidebar={} + banner={} + sidebar={} > {addWalletPageComponent} ); - - return this.props.renderLayoutComponent({ - CLASSIC: addWalletPageClassic, - REVAMP: addWalletPageRevamp, - }); } _goToSettingsRoot: () => void = () => { diff --git a/packages/yoroi-extension/app/containers/wallet/AssetsWrapper.js b/packages/yoroi-extension/app/containers/wallet/AssetsWrapper.js index 2b5621d6e6..8cb34b6c16 100644 --- a/packages/yoroi-extension/app/containers/wallet/AssetsWrapper.js +++ b/packages/yoroi-extension/app/containers/wallet/AssetsWrapper.js @@ -45,7 +45,6 @@ export default class AssetsWrapper extends Component { /> } showInContainer - showAsCard > {this.props.children} diff --git a/packages/yoroi-extension/app/containers/wallet/Wallet.js b/packages/yoroi-extension/app/containers/wallet/Wallet.js index 90a7c9cdbe..3c54c1b0ed 100644 --- a/packages/yoroi-extension/app/containers/wallet/Wallet.js +++ b/packages/yoroi-extension/app/containers/wallet/Wallet.js @@ -94,7 +94,6 @@ export default class Wallet extends Component<{| ...Props, ...StoresAndActionsPr banner={} navbar={} showInContainer - showAsCard > @@ -150,7 +149,6 @@ export default class Wallet extends Component<{| ...Props, ...StoresAndActionsPr /> } showInContainer - showAsCard > {warning} {isInitialSyncing ? ( diff --git a/packages/yoroi-extension/app/containers/wallet/staking/StakingPage.js b/packages/yoroi-extension/app/containers/wallet/staking/StakingPage.js index 8c4bc93961..c0ccfbda48 100644 --- a/packages/yoroi-extension/app/containers/wallet/staking/StakingPage.js +++ b/packages/yoroi-extension/app/containers/wallet/staking/StakingPage.js @@ -52,7 +52,6 @@ class StakingPage extends Component { /> } showInContainer - showAsCard > diff --git a/packages/yoroi-extension/app/containers/wallet/voting/VotingPage.js b/packages/yoroi-extension/app/containers/wallet/voting/VotingPage.js index e221f06880..8da142709e 100644 --- a/packages/yoroi-extension/app/containers/wallet/voting/VotingPage.js +++ b/packages/yoroi-extension/app/containers/wallet/voting/VotingPage.js @@ -51,7 +51,6 @@ class VotingPage extends Component { /> } showInContainer - showAsCard > {content} diff --git a/packages/yoroi-extension/app/styles/context/layout.js b/packages/yoroi-extension/app/styles/context/layout.js index 17de64aad2..44e9c4cb3d 100644 --- a/packages/yoroi-extension/app/styles/context/layout.js +++ b/packages/yoroi-extension/app/styles/context/layout.js @@ -1,7 +1,6 @@ // @flow import type { Node } from 'react'; import React from 'react'; -import { THEMES } from '../themes'; export type Layouts = 'CLASSIC' | 'REVAMP'; // disabling legacy UI @@ -20,7 +19,6 @@ const LayoutProvider = (props: Object): Node => { return ( disabling legacy UI renderLayoutComponent: (layoutMap: LayoutComponentMap = {}) => { diff --git a/packages/yoroi-extension/app/styles/context/mode.js b/packages/yoroi-extension/app/styles/context/mode.js index e0a942a437..baa779d475 100644 --- a/packages/yoroi-extension/app/styles/context/mode.js +++ b/packages/yoroi-extension/app/styles/context/mode.js @@ -3,9 +3,9 @@ import type { Node } from 'react'; import { ThemeProvider } from '@mui/material/styles'; import { baseLightTheme } from '../themes/light-theme-mui'; import { baseDarkTheme } from '../themes/dark-theme-mui'; -import { MuiThemes, THEMES } from '../themes'; import LocalStorageApi from '../../api/localStorage/index'; import React, { useEffect } from 'react'; +import { noop } from '../../coreUtils'; export type Modes = 'light' | 'dark'; @@ -15,12 +15,12 @@ function getDesignTokens(mode: string): Object { return mode === 'light' ? baseLightTheme : baseDarkTheme; } -function ColorModeProvider({ children, currentTheme }: any): Node { +function ColorModeProvider({ children }: any): Node { const [mode, setMode] = React.useState('light'); const localStorageApi = new LocalStorageApi(); useEffect(() => { - getCurrentThemeFromStorage(); + noop(getCurrentThemeFromStorage()); }, []); const colorMode = React.useMemo( @@ -35,15 +35,14 @@ function ColorModeProvider({ children, currentTheme }: any): Node { const getCurrentThemeFromStorage = async () => { const currentThemeMode = await localStorageApi.getUserThemeMode(); if (currentThemeMode) { - setMode(currentThemeMode === 'light' ? 'light' : 'dark'); + setMode(currentThemeMode === 'dark' ? 'dark' : 'light'); } }; // Update the theme only if the mode changes const theme = React.useMemo(() => { - if (currentTheme === THEMES.YOROI_BASE) return getDesignTokens(mode); - return MuiThemes[currentTheme]; - }, [mode, currentTheme]); + return getDesignTokens(mode); + }, [mode]); return ( From 5989f8fd8d6d703c4023aa2ab0af7a0adeebb3f8 Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Sun, 13 Oct 2024 18:56:29 +0300 Subject: [PATCH 20/76] removed legacy prop `isRevampLayout` usages --- .../ConnectedWebsitesPage.js | 89 +-------- .../ConnectedWebsites/WalletRow.js | 182 ------------------ .../complexity-level/ComplexityLevelForm.js | 54 ++---- .../components/profile/nightly/NightlyForm.js | 66 +------ .../categories/ExternalStorageSettings.js | 12 +- .../settings/categories/SupportSettings.js | 33 ++-- .../settings/categories/TermsOfUseSettings.js | 20 +- .../AboutYoroiSettingsBlock.js | 100 +--------- .../general-setting/ExplorerSettings.js | 20 +- .../general-setting/GeneralSettings.js | 26 +-- .../general-setting/UnitOfAccountSettings.js | 48 ++--- .../general-setting/UriSettingsBlock.js | 29 ++- .../containers/profile/ComplexityLevelPage.js | 1 - .../categories/ComplexityLevelSettingsPage.js | 1 - 14 files changed, 91 insertions(+), 590 deletions(-) delete mode 100644 packages/yoroi-extension/app/components/dapp-connector/ConnectedWebsites/WalletRow.js diff --git a/packages/yoroi-extension/app/components/dapp-connector/ConnectedWebsites/ConnectedWebsitesPage.js b/packages/yoroi-extension/app/components/dapp-connector/ConnectedWebsites/ConnectedWebsitesPage.js index bed03e58d8..464980cc92 100644 --- a/packages/yoroi-extension/app/components/dapp-connector/ConnectedWebsites/ConnectedWebsitesPage.js +++ b/packages/yoroi-extension/app/components/dapp-connector/ConnectedWebsites/ConnectedWebsitesPage.js @@ -1,5 +1,5 @@ // @flow -import type { ComponentType, Node } from 'react'; +import type { Node } from 'react'; import { Component } from 'react'; import type { WhitelistEntry } from '../../../../chrome/extension/connector/types'; import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; @@ -7,12 +7,8 @@ import { defineMessages, intlShape } from 'react-intl'; import type { TokenRow } from '../../../api/ada/lib/storage/database/primitives/tables'; import type { TokenLookupKey } from '../../../api/common/lib/MultiToken'; import { observer } from 'mobx-react'; -import { ReactComponent as NoDappsFoundImg } from '../../../assets/images/dapp-connector/no-dapps-connected.inline.svg'; import { ReactComponent as NoDappsConnected } from '../../../assets/images/revamp/no-dapps-connected.inline.svg'; import { connectorMessages } from '../../../i18n/global-messages'; -import { withLayout } from '../../../styles/context/layout'; -import styles from './ConnectedWebsitesPage.scss'; -import WalletRow from './WalletRow'; import WalletRowRevamp from './WalletRowRevamp'; import { Box, Typography } from '@mui/material'; import type { WalletState } from '../../../../chrome/extension/background/types'; @@ -26,10 +22,6 @@ type Props = {| +shouldHideBalance: boolean, |}; -type InjectedProps = {| isRevampLayout: boolean |}; - -type AllProps = {| ...Props, ...InjectedProps |}; - const messages = defineMessages({ connectedWallets: { id: 'connector.connect.connectedWallets', @@ -58,12 +50,12 @@ const messages = defineMessages({ }); @observer -class ConnectedWebsitesPage extends Component { +export default class ConnectedWebsitesPage extends Component { static contextTypes: {| intl: $npm$ReactIntl$IntlFormat |} = { intl: intlShape.isRequired, }; - renderRevamp(): Node { + render(): Node { const { intl } = this.context; const genNoResult = () => ( @@ -151,79 +143,4 @@ class ConnectedWebsitesPage extends Component { ); } - - render(): Node { - const { isRevampLayout } = this.props; - - if (isRevampLayout) return this.renderRevamp(); - - const { intl } = this.context; - const genNoResult = () => ( -
-
- -

{intl.formatMessage(messages.noWebsitesConnected)}

-
{intl.formatMessage(connectorMessages.messageReadOnly)}
-
-
- ); - - const { whitelistEntries, wallets } = this.props; - if ( - whitelistEntries == null || - whitelistEntries.length === 0 || - wallets == null || - wallets.length === 0 - ) { - return genNoResult(); - } - - const cardanoNodes = whitelistEntries - .map(({ url, publicDeriverId, image }) => { - const wallet = wallets.find( - cacheEntry => cacheEntry.publicDeriverId === publicDeriverId - ); - if (wallet == null) { - return null; - } - - return ( - - ); - }) - .filter(x => x != null); - - return ( -
-
-
-
{intl.formatMessage(messages.walletsLabel)}
-
{intl.formatMessage(messages.dappsLabel)}
-
-
- {cardanoNodes.length > 0 && ( -
-

{intl.formatMessage(messages.cardanoLabel)}

- {cardanoNodes} -
- )} -
-
-
- ); - } } - -export default (withLayout(ConnectedWebsitesPage): ComponentType); diff --git a/packages/yoroi-extension/app/components/dapp-connector/ConnectedWebsites/WalletRow.js b/packages/yoroi-extension/app/components/dapp-connector/ConnectedWebsites/WalletRow.js deleted file mode 100644 index 711bc010b7..0000000000 --- a/packages/yoroi-extension/app/components/dapp-connector/ConnectedWebsites/WalletRow.js +++ /dev/null @@ -1,182 +0,0 @@ -// @flow - -import { Component } from 'react'; -import type { Node } from 'react'; -import styles from './WalletRow.scss'; -import type { MultiToken, TokenLookupKey } from '../../../api/common/lib/MultiToken'; -import type { TokenRow } from '../../../api/ada/lib/storage/database/primitives/tables'; -import { getTokenName } from '../../../stores/stateless/tokenHelpers'; -import { hiddenAmount } from '../../../utils/strings'; -import { ReactComponent as DeleteIcon } from '../../../assets/images/dapp-connector/delete.inline.svg'; -import { ReactComponent as NoDappImage } from '../../../assets/images/dapp-connector/no-dapp.inline.svg'; -import WalletType from '../../widgets/WalletType'; -import NavPlate from '../../topbar/NavPlate'; -import { intlShape, defineMessages } from 'react-intl'; -import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; -import type { WalletChecksum } from '@emurgo/cip4-js'; -import { splitAmount, truncateToken } from '../../../utils/formatters'; -import { Tooltip, Typography } from '@mui/material'; -import type { WalletType as WalletT } from '../../../../chrome/extension/background/types'; - -const messages = defineMessages({ - active: { - id: 'connector.connect.connectedWallets.active', - defaultMessage: '!!!Active', - }, -}); - -type Props = {| - +url: ?string, - +isActiveSite: boolean, - +shouldHideBalance: boolean, - +onRemoveWallet: ({| url: ?string |}) => void, - +getTokenInfo: ($ReadOnly>) => $ReadOnly, - +walletName: string, - +websiteIcon: string, - +balance: MultiToken | null, - +plate: WalletChecksum, - +walletType: WalletT, -|}; - -type State = {| - showDeleteIcon: boolean, -|}; - -export default class WalletRow extends Component { - static contextTypes: {| intl: $npm$ReactIntl$IntlFormat |} = { - intl: intlShape.isRequired, - }; - - state: State = { - showDeleteIcon: false, - }; - - showDeleteIcon: void => void = () => { - this.setState({ showDeleteIcon: true }); - }; - - hideDeleteIcon: void => void = () => { - this.setState({ showDeleteIcon: false }); - }; - - renderAmountDisplay: ({| - shouldHideBalance: boolean, - amount: ?MultiToken, - |}) => Node = request => { - if (request.amount == null) { - return
; - } - - const defaultEntry = request.amount.getDefaultEntry(); - const tokenInfo = this.props.getTokenInfo(defaultEntry); - const shiftedAmount = defaultEntry.amount.shiftedBy(-tokenInfo.Metadata.numberOfDecimals); - - let balanceDisplay; - if (request.shouldHideBalance) { - balanceDisplay = {hiddenAmount}; - } else { - const [beforeDecimalRewards, afterDecimalRewards] = splitAmount( - shiftedAmount, - tokenInfo.Metadata.numberOfDecimals - ); - - balanceDisplay = ( - <> - {beforeDecimalRewards} - {afterDecimalRewards} - - ); - } - - return ( - <> - {balanceDisplay} {truncateToken(getTokenName(tokenInfo))} - - ); - }; - - render(): Node { - const { - isActiveSite, - url, - plate, - onRemoveWallet, - balance, - shouldHideBalance, - walletName, - websiteIcon, - walletType, - } = this.props; - const { showDeleteIcon } = this.state; - const { intl } = this.context; - - return ( -
-
-
- {walletName} - - {' '} - · - -
-
-
-
-
- -
-
- {this.renderAmountDisplay({ - shouldHideBalance, - amount: balance, - })} -
-
-
-
-
- {websiteIcon ? {url} : } -
-
- {url}} - > - - {url} - - - {isActiveSite && ( -
{intl.formatMessage(messages.active)}
- )} -
-
-
- {showDeleteIcon && ( - - )} -
-
-
-
- ); - } -} diff --git a/packages/yoroi-extension/app/components/profile/complexity-level/ComplexityLevelForm.js b/packages/yoroi-extension/app/components/profile/complexity-level/ComplexityLevelForm.js index 3484721f7e..89c4fe29c7 100644 --- a/packages/yoroi-extension/app/components/profile/complexity-level/ComplexityLevelForm.js +++ b/packages/yoroi-extension/app/components/profile/complexity-level/ComplexityLevelForm.js @@ -1,17 +1,14 @@ // @flow import { Component } from 'react'; -import type { Node, ComponentType } from 'react'; +import type { Node } from 'react'; import { intlShape, defineMessages, FormattedHTMLMessage } from 'react-intl'; import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; import styles from './ComplexityLevelForm.scss'; -import classnames from 'classnames'; import { ReactComponent as BeginnerLevel } from '../../../assets/images/complexity-level/beginner-level.inline.svg'; import { ReactComponent as AdvancedLevel } from '../../../assets/images/complexity-level/advanced-level.inline.svg'; import LocalizableError from '../../../i18n/LocalizableError'; -import { LoadingButton } from '@mui/lab'; import { ComplexityLevels } from '../../../types/complexityLevelType'; import type { ComplexityLevelType } from '../../../types/complexityLevelType'; -import { withLayout } from '../../../styles/context/layout'; import { Box, Typography } from '@mui/material'; import { settingsMenuMessages } from '../../settings/menu/SettingsMenu'; @@ -55,14 +52,11 @@ const messages = defineMessages({ type Props = {| +complexityLevel: ?ComplexityLevelType, +onSubmit: ComplexityLevelType => PossiblyAsync, - +isSubmitting: boolean, +error?: ?LocalizableError, +baseTheme?: string, |}; -type InjectedProps = {| +isRevampLayout: boolean |}; - -class ComplexityLevel extends Component { +export default class ComplexityLevel extends Component { static defaultProps: {| error: void |} = { error: undefined, }; @@ -73,7 +67,7 @@ class ComplexityLevel extends Component { render(): Node { const { intl } = this.context; - const { complexityLevel, isSubmitting, isRevampLayout, baseTheme } = this.props; + const { complexityLevel, baseTheme } = this.props; const levels = [ { @@ -92,17 +86,15 @@ class ComplexityLevel extends Component { return ( - {isRevampLayout && ( - - {intl.formatMessage(settingsMenuMessages.levelOfComplexity)} - - )} + + {intl.formatMessage(settingsMenuMessages.levelOfComplexity)} + {intl.formatMessage(messages.subtitle)} @@ -116,7 +108,7 @@ class ComplexityLevel extends Component { sx={{ textAlign: 'center', '& strong': { - color: isRevampLayout ? 'primary.500' : 'var(--yoroi-comp-button-secondary-text)', + color: 'primary.500', fontWeight: 500, textTransform: 'uppercase', }, @@ -133,7 +125,7 @@ class ComplexityLevel extends Component { )} - {isRevampLayout ? ( + {( { ? theme.palette.gradients.green : theme.palette.gradients_2 : baseTheme === 'light-theme' - ? 'linear-gradient( 0deg, var(--yoroi-palette-common-white), var(--yoroi-palette-common-white)), linear-gradient(180deg, #e4e8f7 0%, #c6f7f7 100%)' - : theme.palette.ds.bg_gradient_3, + ? 'linear-gradient( 0deg, var(--yoroi-palette-common-white), var(--yoroi-palette-common-white)), linear-gradient(180deg, #e4e8f7 0%, #c6f7f7 100%)' + : theme.palette.ds.bg_gradient_3, backgroundClip: 'content-box, border-box', backgroundOrigin: 'border-box', borderRadius: '8px', @@ -209,32 +201,8 @@ class ComplexityLevel extends Component { ); })} - ) : ( -
- {levels.map(level => ( -
-
{level.image}
-
-
-

{level.name}

-
{level.description}
-
- this.props.onSubmit(level.key)} - > - {intl.formatMessage(messages.labelChoose)} - -
-
- ))} -
)}
); } } - -export default (withLayout(ComplexityLevel): ComponentType); diff --git a/packages/yoroi-extension/app/components/profile/nightly/NightlyForm.js b/packages/yoroi-extension/app/components/profile/nightly/NightlyForm.js index 51d5e8eeaf..3196bdc709 100644 --- a/packages/yoroi-extension/app/components/profile/nightly/NightlyForm.js +++ b/packages/yoroi-extension/app/components/profile/nightly/NightlyForm.js @@ -1,17 +1,13 @@ // @flow +import type { Node } from 'react'; import { Component } from 'react'; -import type { ComponentType, Node } from 'react'; import { observer } from 'mobx-react'; import { Box, Button, Typography } from '@mui/material'; import CheckboxLabel from '../../common/CheckboxLabel'; -import { defineMessages, intlShape, FormattedHTMLMessage } from 'react-intl'; -import styles from './NightlyForm.scss'; +import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; +import { defineMessages, FormattedHTMLMessage, intlShape } from 'react-intl'; import globalMessages from '../../../i18n/global-messages'; -import { ReactComponent as NightlyIcon } from '../../../assets/images/yoroi-nightly-icon.inline.svg'; import { ReactComponent as NightlyIconRevamp } from '../../../assets/images/yoroi-nightly-icon-dark.inline.svg'; -import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; -import { withLayout } from '../../../styles/context/layout'; -import type { InjectedLayoutProps } from '../../../styles/context/layout'; const messages = defineMessages({ nightlySlogan: { @@ -63,7 +59,7 @@ type State = {| |}; @observer -class NightlyForm extends Component { +export default class NightlyForm extends Component { static contextTypes: {| intl: $npm$ReactIntl$IntlFormat |} = { intl: intlShape.isRequired, }; @@ -78,50 +74,9 @@ class NightlyForm extends Component { render(): Node { const { intl } = this.context; - const { onSubmit, isRevampLayout, renderLayoutComponent } = this.props; - - const classicLayout = ( -
-
-
- -
-
- -
-
-
{intl.formatMessage(messages.warningHeader)}
-
    -
  • {intl.formatMessage(messages.warning1)}
  • -
  • {intl.formatMessage(messages.warning2)}
  • -
-
-
{intl.formatMessage(messages.recommendationHeader)}
-
    -
  • {intl.formatMessage(messages.recommendation1)}
  • -
  • {intl.formatMessage(messages.recommendation2)}
  • -
-
-
- -
- -
-
- ); + const { onSubmit } = this.props; - const revampLayout = ( + return ( { mb: '24px', }} > - + {intl.formatMessage(globalMessages.yoroiNightly)} @@ -226,12 +181,5 @@ class NightlyForm extends Component { ); - - return renderLayoutComponent({ - CLASSIC: classicLayout, - REVAMP: revampLayout, - }); } } - -export default (withLayout(NightlyForm): ComponentType); diff --git a/packages/yoroi-extension/app/components/settings/categories/ExternalStorageSettings.js b/packages/yoroi-extension/app/components/settings/categories/ExternalStorageSettings.js index d1d297df2c..3db902ee72 100644 --- a/packages/yoroi-extension/app/components/settings/categories/ExternalStorageSettings.js +++ b/packages/yoroi-extension/app/components/settings/categories/ExternalStorageSettings.js @@ -1,6 +1,6 @@ // @flow import { Component } from 'react'; -import type { Node, ComponentType } from 'react'; +import type { Node } from 'react'; import { observer } from 'mobx-react'; import { defineMessages, intlShape } from 'react-intl'; import { Button, Typography } from '@mui/material'; @@ -8,7 +8,6 @@ import type { SelectedExternalStorageProvider } from '../../../domain/ExternalSt import type { ProvidersType } from '../../../api/externalStorage/index'; import styles from './ExternalStorageSettings.scss'; import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; -import { withLayout } from '../../../styles/context/layout'; const messages = defineMessages({ sectionTitle: { @@ -36,10 +35,8 @@ type Props = {| selectedExternalStorage: ?SelectedExternalStorageProvider, |}; -type InjectedProps = {| +isRevampLayout: boolean |}; - @observer -class ExternalStorageSettings extends Component { +export default class ExternalStorageSettings extends Component { static contextTypes: {| intl: $npm$ReactIntl$IntlFormat |} = { intl: intlShape.isRequired, }; @@ -47,7 +44,6 @@ class ExternalStorageSettings extends Component { render(): Node { const { onConnect, onDisconnect, externalStorageProviders, selectedExternalStorage } = this.props; const { intl } = this.context; - const { isRevampLayout } = this.props; const providersButtons = []; for (const provider of Object.keys(externalStorageProviders)) { @@ -57,7 +53,7 @@ class ExternalStorageSettings extends Component { providersButtons.push(
); - - return renderLayoutComponent({ - CLASSIC: classicLayout, - REVAMP: revampLayout, - }); } } @@ -329,5 +241,3 @@ function LabelWithValue({ LabelWithValue.defaultProps = { url: undefined, }; - -export default (withLayout(AboutYoroiSettingsBlock): ComponentType); diff --git a/packages/yoroi-extension/app/components/settings/categories/general-setting/ExplorerSettings.js b/packages/yoroi-extension/app/components/settings/categories/general-setting/ExplorerSettings.js index e80dc0d9ec..f900350088 100644 --- a/packages/yoroi-extension/app/components/settings/categories/general-setting/ExplorerSettings.js +++ b/packages/yoroi-extension/app/components/settings/categories/general-setting/ExplorerSettings.js @@ -1,6 +1,6 @@ // @flow import { Component } from 'react'; -import type { Node, ComponentType } from 'react'; +import type { Node } from 'react'; import { observer } from 'mobx-react'; import classNames from 'classnames'; import Select from '../../../common/Select'; @@ -13,8 +13,6 @@ import globalMessages from '../../../../i18n/global-messages'; import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; import type { ExplorerRow } from '../../../../api/ada/lib/storage/database/explorers/tables'; import { SelectedExplorer } from '../../../../domain/SelectedExplorer'; -import { withLayout } from '../../../../styles/context/layout'; -import type { InjectedLayoutProps } from '../../../../styles/context/layout'; type Props = {| +explorers: $ReadOnlyArray<$ReadOnly>, @@ -34,7 +32,7 @@ const messages = defineMessages({ }); @observer -class ExplorerSettings extends Component { +export default class ExplorerSettings extends Component { static defaultProps: {| error: void |} = { error: undefined, }; @@ -57,7 +55,7 @@ class ExplorerSettings extends Component { }); render(): Node { - const { isSubmitting, error, isRevampLayout } = this.props; + const { isSubmitting, error } = this.props; const { intl } = this.context; const { form } = this; const explorerId = form.$('explorerId'); @@ -72,12 +70,10 @@ class ExplorerSettings extends Component { return (
- {isRevampLayout && ( - - {intl.formatMessage(messages.title)} - - )} - + + {intl.formatMessage(messages.title)} + + { ); } } - -export default (withLayout(GeneralSettings): ComponentType); diff --git a/packages/yoroi-extension/app/components/settings/categories/general-setting/UnitOfAccountSettings.js b/packages/yoroi-extension/app/components/settings/categories/general-setting/UnitOfAccountSettings.js index a81a458dc3..cd8f628695 100644 --- a/packages/yoroi-extension/app/components/settings/categories/general-setting/UnitOfAccountSettings.js +++ b/packages/yoroi-extension/app/components/settings/categories/general-setting/UnitOfAccountSettings.js @@ -1,6 +1,6 @@ // @flow import { Component } from 'react'; -import type { Node, ComponentType } from 'react'; +import type { Node } from 'react'; import { observer } from 'mobx-react'; import classNames from 'classnames'; import Select from '../../../common/Select'; @@ -15,8 +15,6 @@ import VerticalFlexContainer from '../../../layout/VerticalFlexContainer'; import LoadingSpinner from '../../../widgets/LoadingSpinner'; import globalMessages from '../../../../i18n/global-messages'; import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; -import { withLayout } from '../../../../styles/context/layout'; -import type { InjectedLayoutProps } from '../../../../styles/context/layout'; const messages = defineMessages({ unitOfAccountTitle: { @@ -63,7 +61,7 @@ type Props = {| |}; @observer -class UnitOfAccountSettings extends Component { +export default class UnitOfAccountSettings extends Component { static defaultProps: {| error: void |} = { error: undefined, }; @@ -75,15 +73,13 @@ class UnitOfAccountSettings extends Component { form: ReactToolboxMobxForm = new ReactToolboxMobxForm({ fields: { coinPriceCurrencyId: { - label: this.context.intl.formatMessage( - this.props.isRevampLayout ? messages.revampInputLabel : messages.label - ), + label: this.context.intl.formatMessage(messages.revampInputLabel), }, }, }); render(): Node { - const { currencies, error, currentValue, lastUpdatedTimestamp, isRevampLayout } = this.props; + const { currencies, error, currentValue, lastUpdatedTimestamp } = this.props; const { intl } = this.context; const { form } = this; const coinPriceCurrencyId = form.$('coinPriceCurrencyId'); @@ -143,39 +139,27 @@ class UnitOfAccountSettings extends Component { {dialog} {intl.formatMessage(messages.unitOfAccountTitle)} - {!isRevampLayout && ( - <> - - - - - - - - - )} - - {isRevampLayout && ( + {( <> @@ -228,5 +212,3 @@ class UnitOfAccountSettings extends Component { ); } } - -export default (withLayout(UnitOfAccountSettings): ComponentType); diff --git a/packages/yoroi-extension/app/components/settings/categories/general-setting/UriSettingsBlock.js b/packages/yoroi-extension/app/components/settings/categories/general-setting/UriSettingsBlock.js index 5448000d0b..cb771da6a3 100644 --- a/packages/yoroi-extension/app/components/settings/categories/general-setting/UriSettingsBlock.js +++ b/packages/yoroi-extension/app/components/settings/categories/general-setting/UriSettingsBlock.js @@ -1,22 +1,20 @@ // @flow import { Component } from 'react'; -import type { Node, ComponentType } from 'react'; +import type { Node } from 'react'; import { observer } from 'mobx-react'; import { Box, Button, Typography } from '@mui/material'; import { intlShape } from 'react-intl'; import globalMessages from '../../../../i18n/global-messages'; import { observable, runInAction } from 'mobx'; import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; -import { withLayout } from '../../../../styles/context/layout'; type Props = {| +registerUriScheme: void => void, +isFirefox: boolean, |}; -type InjectedProps = {| +isRevampLayout: boolean |}; @observer -class UriSettingsBlock extends Component { +export default class UriSettingsBlock extends Component { @observable hasPressed: boolean = false; static contextTypes: {| intl: $npm$ReactIntl$IntlFormat |} = { @@ -25,7 +23,6 @@ class UriSettingsBlock extends Component { render(): Node { const { intl } = this.context; - const { isRevampLayout } = this.props; // On firefox since there is no prompt, // We need to give the user feedback that they pressed the button @@ -35,22 +32,22 @@ class UriSettingsBlock extends Component { - + {intl.formatMessage(globalMessages.uriSchemeLabel)} - - {intl.formatMessage(isRevampLayout ? globalMessages.uriExplanationRevamp : globalMessages.uriExplanation)} + + {intl.formatMessage(globalMessages.uriExplanationRevamp)} -
-
- - ); - } - - render(): Node { - return this.props.isRevampLayout ? this.renderRevampLayout() : this.renderLayout(); - } } - -export default (withLayout(Voting): ComponentType); diff --git a/packages/yoroi-extension/app/components/widgets/DialogCloseButton.js b/packages/yoroi-extension/app/components/widgets/DialogCloseButton.js index e86c0a4d7f..de59811ca9 100644 --- a/packages/yoroi-extension/app/components/widgets/DialogCloseButton.js +++ b/packages/yoroi-extension/app/components/widgets/DialogCloseButton.js @@ -1,31 +1,25 @@ // @flow +import type { Node } from 'react'; import { Component } from 'react'; -import type { ComponentType, Node } from 'react'; import { observer } from 'mobx-react'; - -import { ReactComponent as CloseCross } from '../../assets/images/cross-dark.inline.svg'; import { ReactComponent as CloseCrossRevamp } from '../../assets/images/cross-dark-revamp.inline.svg'; import { IconButton, styled } from '@mui/material'; -import { withLayout } from '../../styles/context/layout'; -import type { InjectedLayoutProps } from '../../styles/context/layout'; type Props = {| +onClose?: void => PossiblyAsync, +icon?: ?string, - +isRevampLayout?: boolean, |}; @observer -class DialogCloseButton extends Component { +export default class DialogCloseButton extends Component { static defaultProps: {| icon: null, onClose: void |} = { onClose: undefined, icon: null, }; render(): Node { - const { onClose, icon, isRevampLayout } = this.props; - const defaultIcon = isRevampLayout ? CloseCrossRevamp : CloseCross; - const Svg = icon != null && icon !== '' ? icon : defaultIcon; + const { onClose, icon } = this.props; + const Svg = icon != null && icon !== '' ? icon : CloseCrossRevamp; return ( @@ -43,5 +37,3 @@ const SIconBtn = styled(IconButton)(({ theme, active }) => ({ }, }, })); - -export default (withLayout(DialogCloseButton): ComponentType); diff --git a/packages/yoroi-extension/app/containers/wallet/SupportedAddressDomainsBanner.js b/packages/yoroi-extension/app/containers/wallet/SupportedAddressDomainsBanner.js index f9eb01903e..91b6ed24e5 100644 --- a/packages/yoroi-extension/app/containers/wallet/SupportedAddressDomainsBanner.js +++ b/packages/yoroi-extension/app/containers/wallet/SupportedAddressDomainsBanner.js @@ -51,7 +51,7 @@ function SupportedAddressDomainsBanner({ onClose, intl }: Props & Intl): Node { > } + closeButton={} sx={{ right: '4px', top: '4px', From a8c100a982541f55c7699e208ad6e5521ce790ba Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Sun, 13 Oct 2024 20:14:46 +0300 Subject: [PATCH 22/76] removed legacy prop `isRevampLayout` usages --- .../images/social/revamp/discord.inline.svg | 1 - .../images/social/revamp/facebook.inline.svg | 1 - .../images/social/revamp/github.inline.svg | 1 - .../images/social/revamp/personal.inline.svg | 1 - .../images/social/revamp/telegram.inline.svg | 1 - .../images/social/revamp/twitch.inline.svg | 1 - .../images/social/revamp/twitter.inline.svg | 1 - .../images/social/revamp/youtube.inline.svg | 1 - .../wallet/settings/ExportWallet.js | 37 ++--- .../wallet/settings/RemoveWallet.js | 37 ++--- .../components/wallet/settings/ResyncBlock.js | 35 ++-- .../wallet/settings/WalletNameSetting.js | 21 +-- .../wallet/staking/DelegationTxDialog.js | 153 +++++------------- .../dashboard-revamp/StakePool/StakePool.js | 64 ++++---- 14 files changed, 120 insertions(+), 235 deletions(-) delete mode 100644 packages/yoroi-extension/app/assets/images/social/revamp/discord.inline.svg delete mode 100644 packages/yoroi-extension/app/assets/images/social/revamp/facebook.inline.svg delete mode 100644 packages/yoroi-extension/app/assets/images/social/revamp/github.inline.svg delete mode 100644 packages/yoroi-extension/app/assets/images/social/revamp/personal.inline.svg delete mode 100644 packages/yoroi-extension/app/assets/images/social/revamp/telegram.inline.svg delete mode 100644 packages/yoroi-extension/app/assets/images/social/revamp/twitch.inline.svg delete mode 100644 packages/yoroi-extension/app/assets/images/social/revamp/twitter.inline.svg delete mode 100644 packages/yoroi-extension/app/assets/images/social/revamp/youtube.inline.svg diff --git a/packages/yoroi-extension/app/assets/images/social/revamp/discord.inline.svg b/packages/yoroi-extension/app/assets/images/social/revamp/discord.inline.svg deleted file mode 100644 index de241a8adc..0000000000 --- a/packages/yoroi-extension/app/assets/images/social/revamp/discord.inline.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/packages/yoroi-extension/app/assets/images/social/revamp/facebook.inline.svg b/packages/yoroi-extension/app/assets/images/social/revamp/facebook.inline.svg deleted file mode 100644 index f6fd20492d..0000000000 --- a/packages/yoroi-extension/app/assets/images/social/revamp/facebook.inline.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/packages/yoroi-extension/app/assets/images/social/revamp/github.inline.svg b/packages/yoroi-extension/app/assets/images/social/revamp/github.inline.svg deleted file mode 100644 index 59264e3b86..0000000000 --- a/packages/yoroi-extension/app/assets/images/social/revamp/github.inline.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/packages/yoroi-extension/app/assets/images/social/revamp/personal.inline.svg b/packages/yoroi-extension/app/assets/images/social/revamp/personal.inline.svg deleted file mode 100644 index e1682cefb7..0000000000 --- a/packages/yoroi-extension/app/assets/images/social/revamp/personal.inline.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/packages/yoroi-extension/app/assets/images/social/revamp/telegram.inline.svg b/packages/yoroi-extension/app/assets/images/social/revamp/telegram.inline.svg deleted file mode 100644 index 5060bf9fa4..0000000000 --- a/packages/yoroi-extension/app/assets/images/social/revamp/telegram.inline.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/packages/yoroi-extension/app/assets/images/social/revamp/twitch.inline.svg b/packages/yoroi-extension/app/assets/images/social/revamp/twitch.inline.svg deleted file mode 100644 index 64b05a04e8..0000000000 --- a/packages/yoroi-extension/app/assets/images/social/revamp/twitch.inline.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/packages/yoroi-extension/app/assets/images/social/revamp/twitter.inline.svg b/packages/yoroi-extension/app/assets/images/social/revamp/twitter.inline.svg deleted file mode 100644 index c4143b923c..0000000000 --- a/packages/yoroi-extension/app/assets/images/social/revamp/twitter.inline.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/packages/yoroi-extension/app/assets/images/social/revamp/youtube.inline.svg b/packages/yoroi-extension/app/assets/images/social/revamp/youtube.inline.svg deleted file mode 100644 index ef9863bf2d..0000000000 --- a/packages/yoroi-extension/app/assets/images/social/revamp/youtube.inline.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/packages/yoroi-extension/app/components/wallet/settings/ExportWallet.js b/packages/yoroi-extension/app/components/wallet/settings/ExportWallet.js index e82fd3fa33..67cbe2323f 100644 --- a/packages/yoroi-extension/app/components/wallet/settings/ExportWallet.js +++ b/packages/yoroi-extension/app/components/wallet/settings/ExportWallet.js @@ -1,12 +1,11 @@ // @flow +import type { Node } from 'react'; import { Component } from 'react'; -import type { Node, ComponentType } from 'react'; +import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; import { defineMessages, intlShape } from 'react-intl'; import globalMessages from '../../../i18n/global-messages'; import { observer } from 'mobx-react'; import { Box, Button, Typography } from '@mui/material'; -import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; -import { withLayout } from '../../../styles/context/layout'; export const messages: * = defineMessages({ titleLabel: { @@ -23,33 +22,31 @@ type Props = {| +openDialog: void => void, |}; -type InjectedProps = {| +isRevampLayout: boolean |}; - @observer -class ExportWallet extends Component { +export default class ExportWallet extends Component { static contextTypes: {| intl: $npm$ReactIntl$IntlFormat |} = { intl: intlShape.isRequired, }; render(): Node { const { intl } = this.context; - const { isRevampLayout, openDialog } = this.props; + const { openDialog } = this.props; return ( {intl.formatMessage(messages.titleLabel)} @@ -57,21 +54,21 @@ class ExportWallet extends Component { {intl.formatMessage(messages.exportExplanation)}
); - const confirmButtonClasses = classnames(['confirmButton', this.props.isSubmitting ? styles.submitButtonSpinning : null]); - const formatValue = genFormatTokenAmount(this.props.getTokenInfo); const decimalPlaces = this.props.getTokenInfo(this.props.amountToDelegate.getDefaultEntry()).Metadata.numberOfDecimals; const delegatingValue = new BigNumber(this.props.amountToDelegate.getDefaultEntry().amount).shiftedBy(-decimalPlaces); - const classicLayout = ( - {} // noop - : this.props.onCancel, - }, - { - label: intl.formatMessage(globalMessages.delegateLabel), - onClick: this.submit.bind(this), - primary: true, - className: confirmButtonClasses, - isSubmitting: this.props.isSubmitting, - disabled: this.props.isSubmitting, - }, - ]} - closeOnOverlayClick={false} - onClose={!this.props.isSubmitting ? this.props.onCancel : null} - className={styles.dialog} - closeButton={} - > - {this.props.staleTx && staleTxWarning} -
    -
  • {intl.formatMessage(messages.explanationLine1)}
  • -
  • {intl.formatMessage(messages.explanationLine2)}
  • -
  • {intl.formatMessage(messages.explanationLine3)}
  • -
-
-
{intl.formatMessage(messages.stakePoolName)}
-
{this.props.poolName ?? intl.formatMessage(globalMessages.unknownPoolLabel)}
-
-
-
{intl.formatMessage(globalMessages.stakePoolHash)}
-
- - {this.props.poolHash} - -
-
- -
- -
-
{spendingPasswordForm}
-
-
{intl.formatMessage(messages.approximateLabel)}
-
- {this.props.approximateReward.amount - .shiftedBy(-this.props.approximateReward.token.Metadata.numberOfDecimals) - .toFormat(this.props.approximateReward.token.Metadata.numberOfDecimals)} -   - {truncateToken(getTokenName(this.props.approximateReward.token))} -
-
- {this.props.error ? ( -
{intl.formatMessage(this.props.error, this.props.error.values)}
- ) : null} -
- ); - const avatarSource = toSvg(this.props.poolHash, 36, { padding: 0 }); const avatarGenerated = `data:image/svg+xml;utf8,${encodeURIComponent(avatarSource)}`; const tokenTicker = getTokenName(this.props.getTokenInfo(this.props.amountToDelegate.getDefaultEntry())); - const revampLayout = ( + return ( { ]} closeOnOverlayClick={false} onClose={!this.props.isSubmitting ? this.props.onCancel : null} - closeButton={} + closeButton={} > {this.props.staleTx && staleTxWarning} { borderRadius: '8px', }} > - + - + {intl.formatMessage(messages.delegationTips)} @@ -305,10 +217,19 @@ class DelegationTxDialog extends Component { {intl.formatMessage(globalMessages.stakePoolChecksumAndName)} - + @@ -326,7 +247,12 @@ class DelegationTxDialog extends Component { div > p': { p: '2px 3px' }, px: '2px', ml: '-3px', mt: '-2px' }} + sx={{ + '& > div > p': { p: '2px 3px' }, + px: '2px', + ml: '-3px', + mt: '-2px' + }} > { placement="top" > - + @@ -391,7 +317,7 @@ class DelegationTxDialog extends Component { } > - + @@ -430,12 +356,5 @@ class DelegationTxDialog extends Component { ) : null} ); - - return this.props.renderLayoutComponent({ - CLASSIC: classicLayout, - REVAMP: revampLayout, - }); } } - -export default (withLayout(DelegationTxDialog): ComponentType); diff --git a/packages/yoroi-extension/app/components/wallet/staking/dashboard-revamp/StakePool/StakePool.js b/packages/yoroi-extension/app/components/wallet/staking/dashboard-revamp/StakePool/StakePool.js index dc04bd2970..4870e63b93 100644 --- a/packages/yoroi-extension/app/components/wallet/staking/dashboard-revamp/StakePool/StakePool.js +++ b/packages/yoroi-extension/app/components/wallet/staking/dashboard-revamp/StakePool/StakePool.js @@ -1,29 +1,28 @@ // @flow -import type { ComponentType, Node } from 'react'; -import { ReactComponent as TwitterIcon } from '../../../../../assets/images/social/revamp/twitter.inline.svg'; -import { ReactComponent as TwitterIconRevamp } from '../../../../../assets/images/social/revamp/twitter-24x24.inline.svg'; -import { ReactComponent as TelegramIcon } from '../../../../../assets/images/social/revamp/telegram.inline.svg'; -import { ReactComponent as TelegramIconRevamp } from '../../../../../assets/images/social/revamp/telegram-24x24.inline.svg'; -import { ReactComponent as FbIcon } from '../../../../../assets/images/social/revamp/facebook.inline.svg'; +import type { Node } from 'react'; +import { + ReactComponent as TwitterIconRevamp +} from '../../../../../assets/images/social/revamp/twitter-24x24.inline.svg'; +import { + ReactComponent as TelegramIconRevamp +} from '../../../../../assets/images/social/revamp/telegram-24x24.inline.svg'; import { ReactComponent as FbIconRevamp } from '../../../../../assets/images/social/revamp/facebook-24x24.inline.svg'; -import { ReactComponent as YoutubeIcon } from '../../../../../assets/images/social/revamp/youtube.inline.svg'; -import { ReactComponent as YoutubeIconRevamp } from '../../../../../assets/images/social/revamp/youtube-24x24.inline.svg'; -import { ReactComponent as TwitchIcon } from '../../../../../assets/images/social/revamp/twitch.inline.svg'; +import { + ReactComponent as YoutubeIconRevamp +} from '../../../../../assets/images/social/revamp/youtube-24x24.inline.svg'; import { ReactComponent as TwitchIconRevamp } from '../../../../../assets/images/social/revamp/twitch-24x24.inline.svg'; -import { ReactComponent as DiscordIcon } from '../../../../../assets/images/social/revamp/discord.inline.svg'; -import { ReactComponent as DiscordIconRevamp } from '../../../../../assets/images/social/revamp/discord-24x24.inline.svg'; -import { ReactComponent as GithubIcon } from '../../../../../assets/images/social/revamp/github.inline.svg'; +import { + ReactComponent as DiscordIconRevamp +} from '../../../../../assets/images/social/revamp/discord-24x24.inline.svg'; import { ReactComponent as GithubIconRevamp } from '../../../../../assets/images/social/revamp/github-24x24.inline.svg'; -import { ReactComponent as PersonalIcon } from '../../../../../assets/images/social/revamp/personal.inline.svg'; -import { ReactComponent as PersonalIconRevamp } from '../../../../../assets/images/social/revamp/personal-site-24x24.inline.svg'; +import { + ReactComponent as PersonalIconRevamp +} from '../../../../../assets/images/social/revamp/personal-site-24x24.inline.svg'; import { List, StyledLink } from './StakePool.styles'; -import { Tooltip, Typography, styled } from '@mui/material'; +import { styled, Tooltip, Typography } from '@mui/material'; import { Box } from '@mui/system'; -import { ReactComponent as QuestionMarkIcon } from '../../../../../assets/images/question-mark.inline.svg'; import { ReactComponent as InfoIconRevamp } from '../../../../../assets/images/info-icon-revamp.inline.svg'; import type { SocialLinks } from '../../../../../containers/wallet/staking/SeizaFetcher'; -import { withLayout } from '../../../../../styles/context/layout'; -import type { InjectedLayoutProps } from '../../../../../styles/context/layout'; // eslint-disable-next-line react/require-default-props type Props = {| socialLinks?: SocialLinks, websiteUrl?: string, +color: string |}; @@ -43,7 +42,7 @@ const SocialExternalLink = ({ href, children }: {| href: string, children: Node ); -const StakingPoolSocialMedia = ({ socialLinks, websiteUrl, color, isRevampLayout }: Props & InjectedLayoutProps): Node => { +export const SocialMediaStakePool = ({ socialLinks, websiteUrl, color }: Props): Node => { const twitter = socialLinks?.tw; const telegram = socialLinks?.tg; const facebook = socialLinks?.fb; @@ -56,53 +55,52 @@ const StakingPoolSocialMedia = ({ socialLinks, websiteUrl, color, isRevampLayout {twitter != null ? ( - {isRevampLayout ? : } + ) : null} {telegram != null ? ( - {isRevampLayout ? : } + ) : null} {facebook != null ? ( - {isRevampLayout ? : } + ) : null} {youtube != null ? ( - {isRevampLayout ? : } + ) : null} {twitch != null ? ( - {isRevampLayout ? : } + ) : null} {discord != null ? ( - {isRevampLayout ? : } + ) : null} {github != null ? ( - {isRevampLayout ? : } + ) : null} {websiteUrl != null ? ( - {isRevampLayout ? : } + ) : null} ); }; -export const SocialMediaStakePool = (withLayout(StakingPoolSocialMedia): ComponentType); - type HelperTooltipProps = {| +message: string | Node, +placement?: string, |}; -const HelperTooltipComp = ({ message, isRevampLayout, placement }: HelperTooltipProps & InjectedLayoutProps): Node => { + +export const HelperTooltip = ({ message, placement }: HelperTooltipProps): Node => { return ( - {isRevampLayout ? : } + ); }; -HelperTooltipComp.defaultProps = { +HelperTooltip.defaultProps = { placement: 'right', }; -export const HelperTooltip = (withLayout(HelperTooltipComp): ComponentType); - const IconWrapper = styled(Box)(({ theme }) => ({ '& svg': { '& path': { From 5577e9c9ea7332d8b91c738b1f6859e9936a0230 Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Sun, 13 Oct 2024 20:34:36 +0300 Subject: [PATCH 23/76] removed legacy prop `isRevampLayout` --- .../app/components/wallet/WalletReceive.js | 331 ------------------ .../app/components/wallet/WalletReceive.scss | 204 ----------- .../wallet/receive/StandardHeader.js | 130 ------- .../wallet/voting/ConfirmPinDialog.js | 22 +- .../wallet/voting/GeneratePinDialog.js | 37 +- .../wallet/voting/RegisterDialog.js | 25 +- .../wallet/voting/VotingRegTxDialog.js | 9 +- .../app/components/widgets/Accordion.js | 12 +- .../app/components/widgets/Dialog.js | 29 +- .../widgets/forms/SpendingPasswordInput.js | 13 +- .../components/connect/ConnectPage.js | 17 +- .../containers/wallet/WalletReceivePage.js | 27 +- .../dialogs/voting/RegisterDialogContainer.js | 15 +- .../voting/TransactionDialogContainer.js | 13 +- .../VotingRegistrationDialogContainer.js | 15 +- .../app/styles/context/layout.js | 2 - 16 files changed, 72 insertions(+), 829 deletions(-) delete mode 100644 packages/yoroi-extension/app/components/wallet/WalletReceive.js delete mode 100644 packages/yoroi-extension/app/components/wallet/WalletReceive.scss delete mode 100644 packages/yoroi-extension/app/components/wallet/receive/StandardHeader.js diff --git a/packages/yoroi-extension/app/components/wallet/WalletReceive.js b/packages/yoroi-extension/app/components/wallet/WalletReceive.js deleted file mode 100644 index c5989e4dc6..0000000000 --- a/packages/yoroi-extension/app/components/wallet/WalletReceive.js +++ /dev/null @@ -1,331 +0,0 @@ -// @flow -import { Component } from 'react'; -import type { Node } from 'react'; -import { observer } from 'mobx-react'; -import { defineMessages, intlShape, } from 'react-intl'; -import classnames from 'classnames'; -import { ReactComponent as VerifyIcon } from '../../assets/images/verify-icon.inline.svg'; -import { ReactComponent as GenerateURIIcon } from '../../assets/images/generate-uri.inline.svg'; -import styles from './WalletReceive.scss'; -import CopyableAddress from '../widgets/CopyableAddress'; -import RawHash from '../widgets/hashWrappers/RawHash'; -import ExplorableHashContainer from '../../containers/widgets/ExplorableHashContainer'; -import { SelectedExplorer } from '../../domain/SelectedExplorer'; -import type { AddressFilterKind, StandardAddress } from '../../types/AddressFilterTypes'; -import { addressFilter, AddressFilter, } from '../../types/AddressFilterTypes'; -import environment from '../../environment'; -import type { Notification } from '../../types/notification.types'; -import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; -import { truncateAddressShort, splitAmount, truncateToken } from '../../utils/formatters'; -import type { UnitOfAccountSettingType } from '../../types/unitOfAccountType'; -import { ReactComponent as NoTransactionModernSvg } from '../../assets/images/transaction/no-transactions-yet.modern.inline.svg'; -import { ReactComponent as AddLabelIcon } from '../../assets/images/add-label.inline.svg'; -import { ReactComponent as EditLabelIcon } from '../../assets/images/edit.inline.svg'; -import { hiddenAmount } from '../../utils/strings'; -import type { - TokenEntry, TokenLookupKey, -} from '../../api/common/lib/MultiToken'; -import { getTokenName } from '../../stores/stateless/tokenHelpers'; -import type { TokenRow } from '../../api/ada/lib/storage/database/primitives/tables'; -import { CoreAddressTypes } from '../../api/ada/lib/storage/database/primitives/enums'; - -const messages = defineMessages({ - generatedAddressesSectionTitle: { - id: 'wallet.receive.page.generatedAddressesSectionTitle', - defaultMessage: '!!!Generated addresses', - }, - copyAddressLabel: { - id: 'wallet.receive.page.copyAddressLabel', - defaultMessage: '!!!Copy address', - }, - verifyAddressLabel: { - id: 'wallet.receive.page.verifyAddressLabel', - defaultMessage: '!!!Verify address', - }, - generateURLLabel: { - id: 'wallet.receive.page.generateURLLabel', - defaultMessage: '!!!Generate URL', - }, - outputAmountUTXO: { - id: 'wallet.receive.page.outputAmountUTXO', - defaultMessage: '!!!Balance (UTXO sum)', - }, - noResultsFoundLabel: { - id: 'wallet.receive.page.noResultsFoundLabel', - defaultMessage: '!!!No results found.', - }, - notFoundAnyAddresses: { - id: 'wallet.receive.page.notFoundAnyAddresses', - defaultMessage: '!!!No wallet addresses have been used yet.', - }, - label: { - id: 'wallet.receive.page.label', - defaultMessage: '!!!Label ', - }, -}); - -type Props = {| - +hierarchy: {| - path: Array, - filter: AddressFilterKind, - |}, - +header: Node, - +selectedExplorer: SelectedExplorer, - +walletAddresses: $ReadOnlyArray<$ReadOnly>, - +onCopyAddressTooltip: (string, string) => void, - +notification: ?Notification, - +onVerifyAddress: $ReadOnly => Promise, - +onGeneratePaymentURI: void | (string => void), - +shouldHideBalance: boolean, - +unitOfAccountSetting: UnitOfAccountSettingType, - +getTokenInfo: $ReadOnly> => $ReadOnly, - +addressBook: boolean, -|}; - -@observer -export default class WalletReceive extends Component { - static contextTypes: {|intl: $npm$ReactIntl$IntlFormat|} = { - intl: intlShape.isRequired, - }; - - getAmount: TokenEntry => ?Node = tokenEntry => { - if (this.props.shouldHideBalance) { - return ({hiddenAmount}); - } - const tokenInfo = this.props.getTokenInfo(tokenEntry); - - const shiftedAmount = tokenEntry.amount - .shiftedBy(-tokenInfo.Metadata.numberOfDecimals); - - const [beforeDecimalRewards, afterDecimalRewards] = splitAmount( - shiftedAmount, - tokenInfo.Metadata.numberOfDecimals - ); - // recall: can't be negative in this situation - const adjustedBefore = '+' + beforeDecimalRewards; - - return ( - <> - {adjustedBefore} - {afterDecimalRewards} - {' '} - {truncateToken(getTokenName(tokenInfo))} - - ); - } - - getValueBlock: void => {| - header: ?Node, - body: $ReadOnly => ?Node, - |} = () => { - if (this.props.addressBook) { - return { header: undefined, body: () => undefined }; - } - const { intl } = this.context; - - const header = (

{intl.formatMessage(messages.outputAmountUTXO)}

); - const body = address => ( -
- {address.values != null - ? ( -
- {this.getAmount(address.values.getDefaultEntry())} -
- ) - : '-' - } -
- ); - return { header, body }; - } - - getLabelBlock: void => {| - header: ?Node, - body: $ReadOnly => ?Node, - |} = () => { - if (environment.isProduction()) { - return { header: undefined, body: () => undefined }; - } - const { intl } = this.context; - - const header = (

{intl.formatMessage(messages.label)}

); - const body = address => ( -
- { - address.label != null ? -
- - {address.label} -
- : -
- -
- } -
- ); - return { header, body }; - } - - getHierarchy: void => Node = () => { - const { intl } = this.context; - const hierarchy = this.props.hierarchy.path.join(' > '); - - const filter = this.props.hierarchy.filter === AddressFilter.None - ? null - : ( - - [{intl.formatMessage(addressFilter[this.props.hierarchy.filter])}] - - ); - return ( -
- {hierarchy} {filter} -
- ); - }; - - render(): Node { - const { - walletAddresses, - onVerifyAddress, onGeneratePaymentURI, - onCopyAddressTooltip, notification, - } = this.props; - const { intl } = this.context; - const valueBlock = this.getValueBlock(); - const labelBlock = this.getLabelBlock(); - const walletReceiveContent = ( -
- {/* Header Addresses */} -
-

{intl.formatMessage(messages.generatedAddressesSectionTitle)}

- {labelBlock.header} - {valueBlock.header} - {onGeneratePaymentURI != null && ( -

{intl.formatMessage(messages.generateURLLabel)}

- )} -

{intl.formatMessage(messages.verifyAddressLabel)}

-
- - {/* Content Addresses */} - {walletAddresses.map((address, index) => { - const addressClasses = classnames([ - 'generatedAddress-' + (index + 1), - styles.walletAddress, - styles.generatedAddressesGrid, - address.isUsed === true ? styles.usedWalletAddress : null, - ]); - const notificationElementId = `address-${index}-copyNotification`; - return ( -
- {/* Address Id */} - onCopyAddressTooltip(address.address, notificationElementId) - } - notification={notification} - placementTooltip="bottom-start" - > - - - - {truncateAddressShort(address.address)} - - - - - {/* Label for Address Book */} - {labelBlock.body(address)} - {/* Address balance block start */} - {valueBlock.body(address)} - {/* Generate payment URL for Address action */} - {onGeneratePaymentURI != null && ( -
- -
- )} - {/* Verify Address action */} -
- -
- {/* Action block end */} -
- ); - })} -
- ); - - if (walletAddresses === undefined || walletAddresses.length === 0) { - return ( -
- {this.getHierarchy()} - {this.props.header} -
- -

{intl.formatMessage(messages.noResultsFoundLabel)}

-
{intl.formatMessage(messages.notFoundAnyAddresses)}
-
-
- ); - } - - return ( -
- {this.getHierarchy()} - {this.props.header} - {walletReceiveContent} -
- ); - } -} diff --git a/packages/yoroi-extension/app/components/wallet/WalletReceive.scss b/packages/yoroi-extension/app/components/wallet/WalletReceive.scss deleted file mode 100644 index e0f574602a..0000000000 --- a/packages/yoroi-extension/app/components/wallet/WalletReceive.scss +++ /dev/null @@ -1,204 +0,0 @@ -.component { - flex: 1; - overflow-x: hidden; - overflow-y: overlay; - padding: 40px 24px; - - .hierarchy { - margin-bottom: 24px; - font-weight: 400; - font-size: 20px; - padding-bottom: 5px; - border-bottom: 1px solid var(--yoroi-palette-gray-200); - - .filter { - font-size: 14px; - margin-left: 14px; - } - } - - &::-webkit-scrollbar-button { - height: 7px; - display: block; - } - - .notFound { - padding-top: 2rem; - text-align: center; - color: var(--yoroi-palette-gray-600); - svg { - max-width: 140px; - max-height: 140px; - } - h1 { - margin-bottom: 20px; - font-size: 1.2rem; - font-weight: 500; - } - p { - margin: 1rem 0; - font-size: 0.9rem; - } - } - - .generatedAddresses { - color: var(--yoroi-palette-gray-900); - font-weight: 400; - font-size: 14px; - line-height: 22px; - - .generatedAddressesGrid { - display: flex; - text-align: right; - align-items: center; - - & > *:first-child { - text-align: left; - flex: 1.5; - } - & > * { - flex: 1; - margin-left: 10px; - } - } - h2 { - font-size: 14px; - font-weight: 400; - margin-bottom: 10px; - line-height: 22px; - font-weight: lighter; - color: var(--yoroi-palette-gray-600); - } - .labelHeader { - text-align: left; - } - .walletAddress { - display: flex; - padding: 8.5px 0; - word-break: break-all; - - & + .walletAddress { - border-top: 1px solid var(--yoroi-palette-gray-200); - } - - .addressActions { - .addressActionItemBlock { - cursor: pointer; - letter-spacing: 0.5px; - text-align: right; - line-height: 20px; - vertical-align: top; - white-space: nowrap; - - * { - vertical-align: middle; - } - - span { - color: var(--yoroi-palette-gray-800); - font-weight: 400; - font-size: 14px; - margin-left: 6px; - } - } - - .verifyActionBlock, - .generateURLActionBlock { - button { - cursor: pointer; - } - } - - .generateURLActionBlock { - margin-left: unset; - } - } - .labelAddress { - font-weight: 400; - text-align: left; - font-size: 12px; - display: flex; - align-items: center; - .labelText { - position: relative; - - background: var(--yoroi-palette-gray-200); - color: var(--yoroi-palette-gray-600); - padding: 2px 6px; - height: 27px; - &:after { - content: ' '; - display: block; - width: 0; - height: 0; - border-top: 13px solid transparent; - border-bottom: 14px solid transparent; - border-left: 14px solid var(--yoroi-palette-gray-200); - position: absolute; - top: 50%; - margin-top: -14px; - right: -14px; - z-index: 2; - } - } - button { - margin: 0; - margin-right: 8px; - } - } - } - } -} - -:global(.YoroiModern), :global(.YoroiRevamp) { - .component { - .generatedAddresses { - .walletAddress { - padding: 12px 0; - } - } - } -} - -.addressHash { - font-size: 14px; - line-height: 22px; - font-family: 'RobotoMono'; - font-weight: 400; - color: var(--yoroi-palette-gray-900); -} - -.addressHashUsed { - color: var(--yoroi-palette-gray-600); -} - -.verifyIcon, -.copyIcon, -.generateURIIcon, -.labelAddressIcon { - cursor: pointer; - object-fit: contain; - display: inline-flex; - margin-left: 5px; - width: 32px; - height: 32px; - border-radius: 50%; - transition: background-color 0.3s; - & > svg { - display: block; - margin: auto; - height: 20px; - width: 20px; - path { - fill: var(--yoroi-palette-gray-900); - } - } - &:hover { - background-color: var(--yoroi-palette-gray-50); - } -} -.generateURIIcon { - & > svg path:first-child { - fill: unset; - } -} diff --git a/packages/yoroi-extension/app/components/wallet/receive/StandardHeader.js b/packages/yoroi-extension/app/components/wallet/receive/StandardHeader.js deleted file mode 100644 index 4c7cbb70aa..0000000000 --- a/packages/yoroi-extension/app/components/wallet/receive/StandardHeader.js +++ /dev/null @@ -1,130 +0,0 @@ -// @flow -import { Component } from 'react'; -import type { Node } from 'react'; -import { observer } from 'mobx-react'; -import { defineMessages, intlShape, FormattedHTMLMessage } from 'react-intl'; -import classnames from 'classnames'; -import { LoadingButton } from '@mui/lab'; -import LocalizableError from '../../../i18n/LocalizableError'; -import styles from './StandardHeader.scss'; -import CopyableAddress from '../../widgets/CopyableAddress'; -import QrCodeWrapper from '../../widgets/QrCodeWrapper'; -import RawHash from '../../widgets/hashWrappers/RawHash'; -import ExplorableHashContainer from '../../../containers/widgets/ExplorableHashContainer'; -import { SelectedExplorer } from '../../../domain/SelectedExplorer'; -import type { Notification } from '../../../types/notification.types'; -import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; -import { truncateAddress } from '../../../utils/formatters'; - -const messages = defineMessages({ - walletAddressLabel: { - id: 'wallet.receive.page.walletAddressLabel', - defaultMessage: '!!!Your wallet address', - }, - walletReceiveInstructions: { - id: 'wallet.receive.page.walletReceiveInstructions', - defaultMessage: - '!!!Share this wallet address to receive payments. To protect your privacy, new addresses are generated automatically once you use them.', - }, - generateNewAddressButtonLabel: { - id: 'wallet.receive.page.generateNewAddressButtonLabel', - defaultMessage: '!!!Generate new address', - }, -}); - -type Props = {| - +walletAddress: string, - +selectedExplorer: SelectedExplorer, - +isWalletAddressUsed: boolean, - +onGenerateAddress: void => Promise, - +onCopyAddressTooltip: (string, string) => void, - +notification: ?Notification, - +isSubmitting: boolean, - +error?: ?LocalizableError, - +isFilterActive: boolean, -|}; - -@observer -export default class StandardHeader extends Component { - static defaultProps: {| error: void |} = { - error: undefined, - }; - - static contextTypes: {| intl: $npm$ReactIntl$IntlFormat |} = { - intl: intlShape.isRequired, - }; - - submit: void => Promise = async () => { - await this.props.onGenerateAddress(); - }; - - render(): Node { - const { - walletAddress, - isSubmitting, - error, - isWalletAddressUsed, - onCopyAddressTooltip, - notification, - } = this.props; - const { intl } = this.context; - const mainAddressNotificationId = 'mainAddress-copyNotification'; - - const generateAddressForm = ( - - {intl.formatMessage(messages.generateNewAddressButtonLabel)} - - ); - - const copyableHashClass = classnames([styles.copyableHash]); - - const walletHeader = ( -
-
-
{intl.formatMessage(messages.walletAddressLabel)}
- onCopyAddressTooltip(walletAddress, mainAddressNotificationId)} - notification={notification} - placementTooltip="bottom-start" - > - - - {truncateAddress(walletAddress)} - - - -
-
- -
- {generateAddressForm} - {error ? ( -
{intl.formatMessage(error)}
- ) : ( -
 
- )} -
-
- -
-
- ); - - return walletHeader; - } -} diff --git a/packages/yoroi-extension/app/components/wallet/voting/ConfirmPinDialog.js b/packages/yoroi-extension/app/components/wallet/voting/ConfirmPinDialog.js index fb289ca3cd..c68c658c63 100644 --- a/packages/yoroi-extension/app/components/wallet/voting/ConfirmPinDialog.js +++ b/packages/yoroi-extension/app/components/wallet/voting/ConfirmPinDialog.js @@ -12,7 +12,6 @@ import globalMessages from '../../../i18n/global-messages'; import Dialog from '../../widgets/Dialog'; import DialogCloseButton from '../../widgets/DialogCloseButton'; import DialogBackButton from '../../widgets/DialogBackButton'; -import ProgressStepBlock from './ProgressStepBlock'; import { ProgressInfo } from '../../../stores/ada/VotingStore'; import PinInput from '../../widgets/forms/PinInput'; @@ -38,7 +37,6 @@ type Props = {| +cancel: void => void, +pinValidation: string => boolean, +isProcessing: boolean, - +isRevamp: boolean, |}; @observer @@ -84,14 +82,18 @@ export default class ConfirmPinDialog extends Component { backButton={} onClose={cancel} > - {this.props.isRevamp ? ( + {( <> ({ message: step.message, stepId: String(step.step) }))} + steps={stepsList.map(step => ({ + message: step.message, + stepId: String(step.step) + }))} setCurrentStep={() => goBack()} /> - { - ) : ( - <> - -
- -
- )}
void, +onBack: void => void, +pin: Array, - +isRevamp: boolean, |}; @observer @@ -46,7 +44,7 @@ export default class GeneratePinDialog extends Component { render(): Node { const { intl } = this.context; - const { stepsList, progressInfo, next, cancel, pin, isRevamp } = this.props; + const { stepsList, progressInfo, next, cancel, pin } = this.props; const dialogActions = [ { @@ -60,7 +58,7 @@ export default class GeneratePinDialog extends Component {
{pin.map((value, index) => { // eslint-disable-next-line react/no-array-index-key - return isRevamp ? ( + return ( { {value} - ) : ( -
- {value} -
); })}
@@ -97,25 +91,28 @@ export default class GeneratePinDialog extends Component { backButton={} onClose={cancel} > - {this.props.isRevamp ? ( + {( <> ({ message: step.message, stepId: String(step.step) }))} - setCurrentStep={() => {}} + steps={stepsList.map(step => ({ + message: step.message, + stepId: String(step.step) + }))} + setCurrentStep={() => { + }} /> - + - ) : ( - <> - - -
- -
- )} {pinCards} diff --git a/packages/yoroi-extension/app/components/wallet/voting/RegisterDialog.js b/packages/yoroi-extension/app/components/wallet/voting/RegisterDialog.js index f479408fc8..c8a64bd1e3 100644 --- a/packages/yoroi-extension/app/components/wallet/voting/RegisterDialog.js +++ b/packages/yoroi-extension/app/components/wallet/voting/RegisterDialog.js @@ -13,7 +13,6 @@ import globalMessages from '../../../i18n/global-messages'; import Dialog from '../../widgets/Dialog'; import DialogCloseButton from '../../widgets/DialogCloseButton'; import SpendingPasswordInput from '../../widgets/forms/SpendingPasswordInput'; -import ProgressStepBlock from './ProgressStepBlock'; import styles from './RegisterDialog.scss'; import { Typography } from '@mui/material'; import Stepper from '../../common/stepper/Stepper'; @@ -32,7 +31,6 @@ type Props = {| +submit: string => PossiblyAsync, +cancel: void => void, +isProcessing: boolean, - +isRevamp: boolean, |}; @observer @@ -69,14 +67,19 @@ export default class RegisterDialog extends Component { closeButton={} onClose={cancel} > - {this.props.isRevamp ? ( + {( <> ({ message: step.message, stepId: String(step.step) }))} - setCurrentStep={() => {}} + steps={stepsList.map(step => ({ + message: step.message, + stepId: String(step.step) + }))} + setCurrentStep={() => { + }} /> - { {intl.formatMessage(messages.line1)} - ) : ( - <> - -
- {intl.formatMessage(messages.line1)} -
- )}
>) => $ReadOnly, +walletType: WalletType, - +isRevamp: boolean, |}; @observer @@ -179,7 +177,7 @@ export default class VotingRegTxDialog extends Component { closeButton={} backButton={} > - {this.props.isRevamp ? ( + {( ({ @@ -188,11 +186,6 @@ export default class VotingRegTxDialog extends Component { }))} setCurrentStep={() => {}} /> - ) : ( - )} {this.props.staleTx && staleTxWarning} diff --git a/packages/yoroi-extension/app/components/widgets/Accordion.js b/packages/yoroi-extension/app/components/widgets/Accordion.js index bc8bd3283e..ae8cd27ff9 100644 --- a/packages/yoroi-extension/app/components/widgets/Accordion.js +++ b/packages/yoroi-extension/app/components/widgets/Accordion.js @@ -1,13 +1,11 @@ // @flow +import type { Node } from 'react'; import { Component } from 'react'; -import type { ComponentType, Node } from 'react'; import { observer } from 'mobx-react'; import classnames from 'classnames'; import { ReactComponent as ArrowDownSVG } from '../../assets/images/expand-arrow-grey.inline.svg'; import styles from './Accordion.scss'; -import { withLayout } from '../../styles/context/layout'; -import type { InjectedLayoutProps } from '../../styles/context/layout'; type Props = {| +header: Node, @@ -23,7 +21,7 @@ type State = {| |}; @observer -class Accordion extends Component { +export default class Accordion extends Component { state: State = { isToggle: true, }; @@ -33,13 +31,13 @@ class Accordion extends Component { }; render(): Node { - const { header, children, style, isRevampLayout } = this.props; + const { header, children, style } = this.props; const { isToggle } = this.state; const activeButtonClasses = classnames([ styles.accordionTitle, isToggle && styles.activeArrow, - isRevampLayout && styles.revamp, + styles.revamp, this.props.activeHeader && styles.activeHead, ]); @@ -69,5 +67,3 @@ class Accordion extends Component { ); } } - -export default (withLayout(Accordion): ComponentType); diff --git a/packages/yoroi-extension/app/components/widgets/Dialog.js b/packages/yoroi-extension/app/components/widgets/Dialog.js index fcc549947d..7db58f2783 100644 --- a/packages/yoroi-extension/app/components/widgets/Dialog.js +++ b/packages/yoroi-extension/app/components/widgets/Dialog.js @@ -1,12 +1,11 @@ /* eslint-disable no-nested-ternary */ // @flow -import type { Node, Element, ComponentType } from 'react'; +import type { ComponentType, Element, Node } from 'react'; import React, { forwardRef, useEffect, useState } from 'react'; import { map } from 'lodash'; -import { Modal, Typography, Button } from '@mui/material'; +import { Button, Modal, Typography } from '@mui/material'; import { Box, styled } from '@mui/system'; import { LoadingButton } from '@mui/lab'; -import { withLayout } from '../../styles/context/layout'; import { observer } from 'mobx-react'; import { ReactComponent as CrossIcon } from '../../assets/images/revamp/icons/cross.inline.svg'; @@ -39,16 +38,13 @@ export type Props = {| +styleContentOverride?: { ... }, +onClose?: ?(void) => PossiblyAsync, +closeOnOverlayClick?: boolean, - +isRevampLayout?: boolean, id?: string, +styleFlags?: StyleFlag, +forceBottomDivider?: boolean, +contentHeader?: Node, |}; -type InjectedProps = {| isRevampLayout: boolean |}; - -function Dialog(props: Props & InjectedProps): Node { +function Dialog(props: Props): Node { const { title, children, @@ -60,7 +56,6 @@ function Dialog(props: Props & InjectedProps): Node { withCloseButton, backButton, scrollableContentClass, - isRevampLayout, id, styleFlags, forceBottomDivider, @@ -108,7 +103,7 @@ function Dialog(props: Props & InjectedProps): Node { } } sx={{ - bgcolor: isRevampLayout ? 'ds.special_web_overlay' : 'var(--yoroi-comp-dialog-overlay-background-color)', + bgcolor: 'ds.special_web_overlay', display: 'flex', justifyContent: 'center', alignItems: 'center', @@ -169,7 +164,7 @@ function Dialog(props: Props & InjectedProps): Node { // $FlowIgnore id={action.id ?? id + '-' + buttonLabel + '-button'} key={i} - {...getBtnVariant(action.danger, action.primary, isRevampLayout)} + {...getBtnVariant(action.danger, action.primary)} loading={action.isSubmitting} onClick={action.onClick} disabled={action.disabled === true || action.isSubmitting === true} @@ -314,24 +309,22 @@ const ModalFooter = styled(StyledBox)(({ theme, hasDivider }) => ({ function getBtnVariant( danger?: boolean, primary?: boolean, - isRevampLayout?: boolean ): {| variant: 'contained' | 'outlined' | 'danger' | 'primary' | 'secondary', color?: 'primary' | 'secondary' | 'error', |} { - if (danger && isRevampLayout) return { variant: 'contained', color: 'error' }; - - if (isRevampLayout && primary) { + if (danger) { + return { variant: 'contained', color: 'error' }; + } + if (primary) { return { variant: 'primary' }; } - - if (isRevampLayout && !primary) { + if (!primary) { return { variant: 'secondary' }; } - if (danger === true) return { variant: 'danger' }; if (primary === true) return { variant: 'primary' }; return { variant: 'secondary' }; } -export default (withLayout(observer(Dialog)): ComponentType); +export default (observer(Dialog): ComponentType); diff --git a/packages/yoroi-extension/app/components/widgets/forms/SpendingPasswordInput.js b/packages/yoroi-extension/app/components/widgets/forms/SpendingPasswordInput.js index 6f7840c2c3..a80005d444 100644 --- a/packages/yoroi-extension/app/components/widgets/forms/SpendingPasswordInput.js +++ b/packages/yoroi-extension/app/components/widgets/forms/SpendingPasswordInput.js @@ -1,5 +1,5 @@ // @flow -import type { Node, ComponentType } from 'react'; +import type { Node } from 'react'; import { Component } from 'react'; import { observer } from 'mobx-react'; import { intlShape } from 'react-intl'; @@ -7,8 +7,6 @@ import ReactToolboxMobxForm from '../../../utils/ReactToolboxMobxForm'; import globalMessages from '../../../i18n/global-messages'; import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; import PasswordInput from './PasswordInput'; -import { withLayout } from '../../../styles/context/layout'; -import type { InjectedLayoutProps } from '../../../styles/context/layout'; type Props = {| +setForm: ReactToolboxMobxForm => void, @@ -17,7 +15,7 @@ type Props = {| |}; @observer -class SpendingPasswordInput extends Component { +export default class SpendingPasswordInput extends Component { static defaultProps: {| initValues: void |} = { initValues: undefined, }; @@ -28,7 +26,6 @@ class SpendingPasswordInput extends Component { render(): Node { const { intl } = this.context; - const { isRevampLayout } = this.props; return ( { passwordMatches={_password => true} fieldName="walletPassword" validCheck={_password => true} - placeholder={intl.formatMessage( - isRevampLayout ? globalMessages.passwordLabel : globalMessages.walletPasswordLabel - )} + placeholder={intl.formatMessage(globalMessages.passwordLabel)} allowEmptyInput={false} initValues={this.props.initValues} /> ); } } - -export default (withLayout(SpendingPasswordInput): ComponentType); diff --git a/packages/yoroi-extension/app/connector/components/connect/ConnectPage.js b/packages/yoroi-extension/app/connector/components/connect/ConnectPage.js index 6f2c922b45..090dd697e0 100644 --- a/packages/yoroi-extension/app/connector/components/connect/ConnectPage.js +++ b/packages/yoroi-extension/app/connector/components/connect/ConnectPage.js @@ -1,13 +1,13 @@ // @flow +import type { Node } from 'react'; /* eslint-disable no-nested-ternary */ import { Component } from 'react'; -import type { Node, ComponentType } from 'react'; import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; +import { defineMessages, intlShape } from 'react-intl'; import type { TokenLookupKey } from '../../../api/common/lib/MultiToken'; import type { TokenRow } from '../../../api/ada/lib/storage/database/primitives/tables'; import type { WalletChecksum } from '@emurgo/cip4-js'; import type { UnitOfAccountSettingType } from '../../../types/unitOfAccountType'; -import { intlShape, defineMessages } from 'react-intl'; import classNames from 'classnames'; import styles from './ConnectPage.scss'; import { Button, Stack, styled, Typography } from '@mui/material'; @@ -29,7 +29,6 @@ import { ReactComponent as NoWalletImage } from '../../assets/images/no-websites import { ReactComponent as NoDappIcon } from '../../../assets/images/dapp-connector/no-dapp.inline.svg'; import { ReactComponent as IconEyeOpen } from '../../../assets/images/my-wallets/icon_eye_open.inline.svg'; import { ReactComponent as IconEyeClosed } from '../../../assets/images/my-wallets/icon_eye_closed.inline.svg'; -import { withLayout } from '../../../styles/context/layout'; import AmountDisplay from '../../../components/common/AmountDisplay'; import type { WalletState } from '../../../../chrome/extension/background/types'; @@ -99,10 +98,8 @@ type Props = {| +onUpdateHideBalance: void => Promise, |}; -type InjectedProps = {| +isRevampLayout: boolean |}; - @observer -class ConnectPage extends Component { +export default class ConnectPage extends Component { static contextTypes: {| intl: $npm$ReactIntl$IntlFormat |} = { intl: intlShape.isRequired, }; @@ -186,9 +183,9 @@ class ConnectPage extends Component { shouldHideBalance, isAppAuth, onUpdateHideBalance, - isRevampLayout, selectedWallet, } = this.props; + const isNightly = environment.isNightly(); const componentClasses = classNames([styles.component, isNightly && styles.isNightly]); @@ -231,7 +228,7 @@ class ConnectPage extends Component { {!isSelectWalletHardware && (
- ); - - const revampLayout = ( - + return ( +
{this.context.intl.formatMessage(globalMessages.languageSelectLabelShort)} @@ -211,7 +133,7 @@ class LanguageSelectionForm extends Component {languageOptions.map(option => ( - + ))} @@ -287,37 +209,16 @@ class LanguageSelectionForm extends Component ); - - return renderLayoutComponent({ - CLASSIC: classicLayout, - REVAMP: revampLayout, - }); } renderMarkdown(markdown: string): Node { const { intl } = this.context; - const { renderLayoutComponent } = this.props; - const classicLayout = ( - <> -
-
-
- -
-
-
- - - ); - - const revampLayout = ( + return ( <>
- +
@@ -328,18 +229,13 @@ class LanguageSelectionForm extends Component} + startIcon={} onClick={this.onClickBack} > {intl.formatMessage(globalMessages.backButtonLabel)} ); - - return renderLayoutComponent({ - CLASSIC: classicLayout, - REVAMP: revampLayout, - }); } render(): Node { @@ -353,5 +249,3 @@ class LanguageSelectionForm extends Component); diff --git a/packages/yoroi-extension/app/components/profile/terms-of-use/TermsOfUseForm.js b/packages/yoroi-extension/app/components/profile/terms-of-use/TermsOfUseForm.js index 8c2c982df9..04a4600e82 100644 --- a/packages/yoroi-extension/app/components/profile/terms-of-use/TermsOfUseForm.js +++ b/packages/yoroi-extension/app/components/profile/terms-of-use/TermsOfUseForm.js @@ -1,18 +1,16 @@ // @flow +import type { Node } from 'react'; import { Component } from 'react'; -import type { Node, ComponentType } from 'react'; import { observer } from 'mobx-react'; import { LoadingButton } from '@mui/lab'; import { Box, Button, Checkbox, FormControlLabel, Typography } from '@mui/material'; -import { defineMessages, intlShape, FormattedHTMLMessage } from 'react-intl'; +import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; +import { defineMessages, FormattedHTMLMessage, intlShape } from 'react-intl'; import LocalizableError from '../../../i18n/LocalizableError'; import styles from './TermsOfUseForm.scss'; import globalMessages from '../../../i18n/global-messages'; -import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; import ReactMarkdown from 'react-markdown'; import tosStyles from './TermsOfUseText.scss'; -import { withLayout } from '../../../styles/context/layout'; -import type { InjectedLayoutProps } from '../../../styles/context/layout'; import { ReactComponent as BackIcon } from '../../../assets/images/assets-page/backarrow.inline.svg'; const messages = defineMessages({ @@ -41,7 +39,7 @@ type State = {| |}; @observer -class TermsOfUseForm extends Component { +export default class TermsOfUseForm extends Component { static defaultProps: {| error: void |} = { error: undefined, }; @@ -78,51 +76,9 @@ class TermsOfUseForm extends Component { renderForm(): Node { const { intl } = this.context; - const { isSubmitting, error, renderLayoutComponent } = this.props; + const { isSubmitting, error } = this.props; const { areTermsOfUseAccepted } = this.state; - - const classicLayout = ( -
-
-
{intl.formatMessage(messages.updateTitle)}
-
{intl.formatMessage(messages.updateText)}
- -
- - - - } - control={ - - } - sx={{ margin: '0px' }} - /> -
- -
- - {intl.formatMessage(globalMessages.continue)} - -
- - {error &&
{intl.formatMessage(error, error.values)}
} -
-
- ); - - const revampLayout = ( + return ( { ); - - return renderLayoutComponent({ - CLASSIC: classicLayout, - REVAMP: revampLayout, - }); } renderMarkdown(markdown: string): Node { const { intl } = this.context; - const { renderLayoutComponent } = this.props; - - const classicLayout = ( - <> -
-
-
- -
-
-
-
- -
- - ); - const revampLayout = ( + return ( <>
- +
@@ -237,17 +170,13 @@ class TermsOfUseForm extends Component { top: '24px', left: '24px', }} - startIcon={} + startIcon={} onClick={this.onClickBack} > {intl.formatMessage(globalMessages.backButtonLabel)} ); - return renderLayoutComponent({ - CLASSIC: classicLayout, - REVAMP: revampLayout, - }); } render(): Node { @@ -261,5 +190,3 @@ class TermsOfUseForm extends Component { return this.renderMarkdown(this.props.localizedPrivacyNotice); } } - -export default (withLayout(TermsOfUseForm): ComponentType); diff --git a/packages/yoroi-extension/app/components/topbar/BuySellAdaButton.js b/packages/yoroi-extension/app/components/topbar/BuySellAdaButton.js index c399c4eb33..a9d9707212 100644 --- a/packages/yoroi-extension/app/components/topbar/BuySellAdaButton.js +++ b/packages/yoroi-extension/app/components/topbar/BuySellAdaButton.js @@ -1,51 +1,36 @@ // @flow +import type { Node } from 'react'; import { Component } from 'react'; -import type { Node, ComponentType } from 'react'; import { observer } from 'mobx-react'; import { Button } from '@mui/material'; import globalMessages from '../../i18n/global-messages'; import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; import { intlShape } from 'react-intl'; -import { withLayout } from '../../styles/context/layout'; -import type { LayoutComponentMap } from '../../styles/context/layout'; import environment from '../../environment'; type Props = {| +onBuySellClick: void => void, |}; -type InjectedProps = {| - +renderLayoutComponent: LayoutComponentMap => Node, -|}; - const buttonText = (environment.isDev() || environment.isNightly()) ? globalMessages.buySellAda : globalMessages.buyAda; @observer -class BuySellAdaButton extends Component { +export default class BuySellAdaButton extends Component { static contextTypes: {| intl: $npm$ReactIntl$IntlFormat |} = { intl: intlShape.isRequired, }; render(): Node { const { intl } = this.context; - - const BuyAdaButtonClassic = ( - - ); - - const BuyAdaButtonRevamp = ( + return ( ); - - return this.props.renderLayoutComponent({ - CLASSIC: BuyAdaButtonClassic, - REVAMP: BuyAdaButtonRevamp, - }); } } - -export default (withLayout(BuySellAdaButton): ComponentType); diff --git a/packages/yoroi-extension/app/components/topbar/NavBarTitle.js b/packages/yoroi-extension/app/components/topbar/NavBarTitle.js index 0cee2bd99c..2cea214c03 100644 --- a/packages/yoroi-extension/app/components/topbar/NavBarTitle.js +++ b/packages/yoroi-extension/app/components/topbar/NavBarTitle.js @@ -1,35 +1,22 @@ // @flow import { Box } from '@mui/material'; import { observer } from 'mobx-react'; -import type { Node, ComponentType } from 'react'; -import type { LayoutComponentMap } from '../../styles/context/layout'; +import type { Node } from 'react'; import { Component } from 'react'; -import { withLayout } from '../../styles/context/layout'; import styles from './NavBarTitle.scss'; type Props = {| +title: string, |}; -type InjectedProps = {| - +renderLayoutComponent: LayoutComponentMap => Node, -|}; @observer -class NavBarTitle extends Component { +export default class NavBarTitle extends Component { render(): Node { - const { renderLayoutComponent, title } = this.props; - - const navbarTitleClassic =
{title}
; - const navbarTitleRevamp = ( + const { title } = this.props; + return ( {title} ); - - return renderLayoutComponent({ - CLASSIC: navbarTitleClassic, - REVAMP: navbarTitleRevamp, - }); } } -export default (withLayout(NavBarTitle): ComponentType); diff --git a/packages/yoroi-extension/app/components/wallet/layouts/FullscreenMessage.js b/packages/yoroi-extension/app/components/wallet/layouts/FullscreenMessage.js index 41b8ffde1c..97c3c037ae 100644 --- a/packages/yoroi-extension/app/components/wallet/layouts/FullscreenMessage.js +++ b/packages/yoroi-extension/app/components/wallet/layouts/FullscreenMessage.js @@ -1,12 +1,9 @@ // @flow -import type { Node, ComponentType } from 'react'; +import type { Node } from 'react'; import { Component } from 'react'; -import styles from './FullscreenMessage.scss'; import VerticallyCenteredLayout from '../../layout/VerticallyCenteredLayout'; import FullscreenLayout from '../../layout/FullscreenLayout'; import { observer } from 'mobx-react'; -import { withLayout } from '../../../styles/context/layout'; -import type { InjectedLayoutProps } from '../../../styles/context/layout'; import { Box, Stack, Typography } from '@mui/material'; type Props = {| @@ -16,26 +13,14 @@ type Props = {| |}; @observer -class FullscreenMessage extends Component { +export default class FullscreenMessage extends Component { static defaultProps: {| image: void |} = { image: undefined, }; render(): Node { - const { title, subtitle, image, renderLayoutComponent } = this.props; - const classicLayout = ( - - -
-
{title}
-
-
{subtitle}
-
-
-
- ); - - const revampLayout = ( + const { title, subtitle, image } = this.props; + return ( { ); - - return renderLayoutComponent({ - CLASSIC: classicLayout, - REVAMP: revampLayout, - }); } } - -export default (withLayout(FullscreenMessage): ComponentType); diff --git a/packages/yoroi-extension/app/components/wallet/layouts/FullscreenMessage.scss b/packages/yoroi-extension/app/components/wallet/layouts/FullscreenMessage.scss deleted file mode 100644 index d070260db8..0000000000 --- a/packages/yoroi-extension/app/components/wallet/layouts/FullscreenMessage.scss +++ /dev/null @@ -1,15 +0,0 @@ -.component { - text-align: center; - line-height: 22px; - color: var(--yoroi-palette-gray-900); - - .title { - font-weight: 500; - font-size: 18px; - } - - .subtitle { - font-weight: 400; - font-size: 14px; - } -} diff --git a/packages/yoroi-extension/app/components/wallet/layouts/ReceiveWithNavigation.js b/packages/yoroi-extension/app/components/wallet/layouts/ReceiveWithNavigation.js index 03e80220e9..bfd7b53213 100644 --- a/packages/yoroi-extension/app/components/wallet/layouts/ReceiveWithNavigation.js +++ b/packages/yoroi-extension/app/components/wallet/layouts/ReceiveWithNavigation.js @@ -1,11 +1,8 @@ // @flow -import type { Node, ComponentType } from 'react'; +import type { ComponentType, Node } from 'react'; import { observer } from 'mobx-react'; -import { useLayout } from '../../../styles/context/layout'; -import type { LayoutComponentMap } from '../../../styles/context/layout'; -import ReceiveNavigation from '../navigation/ReceiveNavigation'; import { Box } from '@mui/material'; -import type { AddressTypeName, AddressFilterKind } from '../../../types/AddressFilterTypes'; +import type { AddressFilterKind, AddressTypeName } from '../../../types/AddressFilterTypes'; import ReceiveNavigationRevamp from '../navigation/ReceiveNavigationRevamp'; export type Props = {| @@ -21,31 +18,8 @@ export type Props = {| ... }>, |}; -type InjectedProps = {| - +renderLayoutComponent: LayoutComponentMap => Node, -|}; -function ReceiveWithNavigation({ addressStores, setFilter, activeFilter, children }: Props & InjectedProps): Node { - const { renderLayoutComponent } = useLayout(); - - const classicReceiveNav = ( - - - - - - {children} - - - ); - - const revampReceiveNav = ( +function ReceiveWithNavigation({ addressStores, setFilter, activeFilter, children }: Props): Node { + return ( - - + + + + + {children} - {children} ); - return renderLayoutComponent({ CLASSIC: classicReceiveNav, REVAMP: revampReceiveNav }); } export default (observer(ReceiveWithNavigation): ComponentType); diff --git a/packages/yoroi-extension/app/components/wallet/navigation/ReceiveNavigation.js b/packages/yoroi-extension/app/components/wallet/navigation/ReceiveNavigation.js deleted file mode 100644 index de841e78fc..0000000000 --- a/packages/yoroi-extension/app/components/wallet/navigation/ReceiveNavigation.js +++ /dev/null @@ -1,170 +0,0 @@ -// @flow -import { Component } from 'react'; -import type { Node } from 'react'; -import { observer } from 'mobx-react'; -import { intlShape } from 'react-intl'; -import styles from './ReceiveNavigation.scss'; - -import { ReactComponent as AttentionIcon } from '../../../assets/images/attention-modern.inline.svg'; -import ReceiveNavButton from './ReceiveNavButton'; -import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; -import { - addressGroupName, - addressSubgroupName, - addressGroupsTooltip, - addressFilter, - AddressGroupTypes, - AddressSubgroup, -} from '../../../types/AddressFilterTypes'; -import Accordion from '../../widgets/Accordion'; -import { ReactComponent as InfoIcon } from '../../../assets/images/attention-big-light.inline.svg'; - -import type { AddressTypeName, AddressFilterKind } from '../../../types/AddressFilterTypes'; -import classNames from 'classnames'; -import { Tooltip, Typography } from '@mui/material'; - -type AddressStoreSubset = { - +isActiveStore: boolean, - +setAsActiveStore: void => void, - +name: AddressTypeName, - +validFilters: $ReadOnlyArray, - +wasExecuted: boolean, - ... -}; -export type Props = {| - +setFilter: AddressFilterKind => void, - +activeFilter: AddressFilterKind, - +addressStores: $ReadOnlyArray, -|}; - -@observer -export default class ReceiveNavigation extends Component { - static contextTypes: {| intl: $npm$ReactIntl$IntlFormat |} = { - intl: intlShape.isRequired, - }; - - genTooltip: AddressStoreSubset => Node = store => { - const { intl } = this.context; - return ( - - {intl.formatMessage(addressGroupsTooltip[store.name.group])} -
- } - > - - - - - ); - }; - - createAccordionForGroup: ($PropertyType) => Node = stores => { - const { intl } = this.context; - - if (stores.length === 1 && stores[0].name.subgroup === AddressSubgroup.all) { - const store = stores[0]; - return ( -
- -
- ); - } - - return ( - !store.wasExecuted) != null} - header={ -
- {intl.formatMessage(addressGroupName[stores[0].name.group])} - {this.genTooltip(stores[0])} -
- } - activeHeader={stores.some(address => address.isActiveStore)} - > - {stores.map(type => ( - - ))} -
- ); - }; - - createAccordions: void => Node = () => { - // we use an array instead of a map to maintain the order of stores - const groups: Array> = []; - - for (const store of this.props.addressStores) { - const existingGroup = groups.find( - // if any existing group shares the group name - group => group[0].name.group === store.name.group - ); - if (existingGroup == null) { - groups.push([store]); - continue; - } - existingGroup.push(store); - } - - return groups.map(group => ( -
- {this.createAccordionForGroup(group)} -
- )); - }; - - generateFilterSection: void => ?Node = () => { - const { intl } = this.context; - - const { activeFilter } = this.props; - - const activeStore = this.props.addressStores.find(store => store.isActiveStore); - if (activeStore == null) return undefined; - - return ( -
- {activeStore.validFilters.map(filter => ( - this.props.setFilter(filter)} - isToplevel - /> - ))} -
- ); - }; - - render(): Node { - return ( -
-
-
{this.createAccordions()}
- {/* Section filtered button */} - {this.generateFilterSection()} -
-
- ); - } -} diff --git a/packages/yoroi-extension/app/components/wallet/navigation/ReceiveNavigation.scss b/packages/yoroi-extension/app/components/wallet/navigation/ReceiveNavigation.scss deleted file mode 100644 index befafc4f26..0000000000 --- a/packages/yoroi-extension/app/components/wallet/navigation/ReceiveNavigation.scss +++ /dev/null @@ -1,48 +0,0 @@ -.wrapper { - padding-top: 37px; - box-shadow: 0 2px 4px 0 rgba(56, 57, 61, 0.2); - height: 100%; - // background-color: var(--yoroi-palette-gray-50); -} - -.content { - display: flex; - flex-direction: column; - justify-content: space-between; - min-width: 225px; - height: inherit; -} -.accordion { - &:not(:nth-child(1)) { - margin-top: 24px; - } -} -.accordions { - display: flex; - flex-direction: column; - justify-content: start; - overflow-y: overlay; - min-height: 80px; // always show at least ~2 elements - flex: 1; - padding-bottom: 10px; - .Tooltip { - position: absolute; // added here due of specificity - } -} -.filterSection { - padding-top: 20px; - padding-bottom: 40px; - height: 240px; - box-shadow: inset 0 -1px 12px 0 rgba(255, 255, 255, 0.5), inset 0 2px 4px 0 rgba(56, 57, 61, 0.2); - overflow: auto; -} -.infoIcon { - margin-left: 8px; - svg { - max-width: 12px; - max-height: 12px; - path { - fill: #8a92a3; - } - } -} diff --git a/packages/yoroi-extension/app/components/wallet/settings/SpendingPasswordSetting.js b/packages/yoroi-extension/app/components/wallet/settings/SpendingPasswordSetting.js index c50269eb99..1db1bb20bb 100644 --- a/packages/yoroi-extension/app/components/wallet/settings/SpendingPasswordSetting.js +++ b/packages/yoroi-extension/app/components/wallet/settings/SpendingPasswordSetting.js @@ -1,15 +1,10 @@ // @flow -import type { Node, ComponentType } from 'react'; +import type { Node } from 'react'; import { Component } from 'react'; import { observer } from 'mobx-react'; -import { defineMessages, intlShape } from 'react-intl'; -import moment from 'moment'; -import ReadOnlyInput from '../../widgets/forms/ReadOnlyInput'; -import globalMessages from '../../../i18n/global-messages'; // import styles from './SpendingPasswordSetting.scss'; import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; -import { withLayout } from '../../../styles/context/layout'; -import type { InjectedLayoutProps } from '../../../styles/context/layout'; +import { defineMessages, intlShape } from 'react-intl'; import { Box, Button, Typography } from '@mui/material'; const messages = defineMessages({ @@ -37,36 +32,18 @@ const messages = defineMessages({ }); type Props = {| - +walletPasswordUpdateDate: ?Date, +openDialog: void => void, |}; @observer -class SpendingPasswordSetting extends Component { +export default class SpendingPasswordSetting extends Component { static contextTypes: {| intl: $npm$ReactIntl$IntlFormat |} = { intl: intlShape.isRequired, }; render(): Node { const { intl } = this.context; - const { walletPasswordUpdateDate, renderLayoutComponent } = this.props; - const passwordMessage = - walletPasswordUpdateDate == null - ? intl.formatMessage(messages.unchangedPassword) - : intl.formatMessage(messages.passwordLastUpdated, { - lastUpdated: moment(walletPasswordUpdateDate).fromNow(), - }); - - const classicLayout = ( - - ); - - const revampLayout = ( + return ( {intl.formatMessage(messages.title)} @@ -87,12 +64,5 @@ class SpendingPasswordSetting extends Component { ); - - return renderLayoutComponent({ - CLASSIC: classicLayout, - REVAMP: revampLayout, - }); } } - -export default (withLayout(SpendingPasswordSetting): ComponentType); diff --git a/packages/yoroi-extension/app/components/widgets/forms/ReadOnlyInput.js b/packages/yoroi-extension/app/components/widgets/forms/ReadOnlyInput.js deleted file mode 100644 index c8d26a3c6c..0000000000 --- a/packages/yoroi-extension/app/components/widgets/forms/ReadOnlyInput.js +++ /dev/null @@ -1,61 +0,0 @@ -// @flow -import { Component } from 'react'; -import type { Node } from 'react'; -import { observer } from 'mobx-react'; -import classnames from 'classnames'; -import { intlShape } from 'react-intl'; -import TextField from '../../common/TextField'; -import { ReactComponent as EditSvg } from '../../../assets/images/edit.inline.svg'; -import styles from './ReadOnlyInput.scss'; -import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; - -type Props = {| - +label: string, - +value: string, - +isSet: boolean, - +onClick: void => void, -|}; - -@observer -export default class ReadOnlyInput extends Component { - - static contextTypes: {|intl: $npm$ReactIntl$IntlFormat|} = { - intl: intlShape.isRequired, - }; - - render(): Node { - const { - label, - value, - isSet, - onClick, - } = this.props; - - const mainClasses = classnames([ - styles.component, - isSet ? 'changeLabel' : 'createLabel', - ]); - - return ( -
- - - - - -
- ); - } - -} diff --git a/packages/yoroi-extension/app/containers/settings/categories/WalletSettingsPage.js b/packages/yoroi-extension/app/containers/settings/categories/WalletSettingsPage.js index 5142eed2c2..1dd865c5a7 100644 --- a/packages/yoroi-extension/app/containers/settings/categories/WalletSettingsPage.js +++ b/packages/yoroi-extension/app/containers/settings/categories/WalletSettingsPage.js @@ -50,11 +50,6 @@ export default class WalletSettingsPage extends Component {this.getDialog(selectedWallet.publicDeriverId)} @@ -88,7 +83,6 @@ export default class WalletSettingsPage extends Component )} , + // todo: pending removal signingKeyUpdateDate: ?string, stakingAddressing: Addressing, stakingAddress: string, From 6e20de2a41b1d380fe90204e3636d3163bfa54bb Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Sun, 13 Oct 2024 22:27:49 +0300 Subject: [PATCH 25/76] removed legacy `layout` --- packages/yoroi-extension/app/App.js | 21 ++--- .../app/UI/layout/GeneralPageLayout.js | 5 +- .../app/components/settings/SettingsLayout.js | 27 ------ .../wallet/receive/VerifyAddressDialog.js | 8 +- .../wallet/staking/DelegationSuccessDialog.js | 30 +------ .../widgets/DangerousActionDialog.js | 85 +++++++------------ .../widgets/forms/InlineEditingInput.js | 8 +- packages/yoroi-extension/app/connector/App.js | 19 ++--- .../ConnectedWebsitesContainer.js | 12 +-- .../containers/experimental/YoroiPalette.js | 12 +-- .../containers/experimental/yoroiThemes.js | 12 +-- .../app/containers/settings/Settings.js | 45 ++-------- .../categories/RemoveWalletDialogContainer.js | 48 +---------- .../app/containers/swap/SwapPageContainer.js | 14 +-- .../app/containers/transfer/Transfer.js | 11 +-- .../app/containers/wallet/AddWalletPage.js | 11 +-- .../app/containers/wallet/MyWalletsPage.js | 42 ++------- .../wallet/staking/CardanoStakingPage.js | 46 ++-------- .../wallet/staking/StakingPageContent.js | 12 +-- .../wallet/voting/RegistrationOver.js | 8 +- .../containers/wallet/voting/VotingPage.js | 32 ++----- .../app/styles/context/layout.js | 44 ---------- 22 files changed, 107 insertions(+), 445 deletions(-) delete mode 100644 packages/yoroi-extension/app/components/settings/SettingsLayout.js delete mode 100644 packages/yoroi-extension/app/styles/context/layout.js diff --git a/packages/yoroi-extension/app/App.js b/packages/yoroi-extension/app/App.js index 24b542d1b3..838d6a2c45 100644 --- a/packages/yoroi-extension/app/App.js +++ b/packages/yoroi-extension/app/App.js @@ -11,7 +11,6 @@ import { observable, autorun, runInAction } from 'mobx'; import { Routes } from './Routes'; import { locales, translations } from './i18n/translations'; import { Logger } from './utils/logging'; -import { LayoutProvider } from './styles/context/layout'; import { ColorModeProvider } from './styles/context/mode'; import { CssBaseline } from '@mui/material'; import { globalStyles } from './styles/globalStyles'; @@ -89,17 +88,15 @@ class App extends Component { return (
- - - - {globalStyles(muiTheme)} - - {/* Automatically pass a theme prop to all components in this subtree. */} - - {this.getContent()} - - - + + + {globalStyles(muiTheme)} + + {/* Automatically pass a theme prop to all components in this subtree. */} + + {this.getContent()} + +
); } diff --git a/packages/yoroi-extension/app/UI/layout/GeneralPageLayout.js b/packages/yoroi-extension/app/UI/layout/GeneralPageLayout.js index 6b95139445..91b47a74a6 100644 --- a/packages/yoroi-extension/app/UI/layout/GeneralPageLayout.js +++ b/packages/yoroi-extension/app/UI/layout/GeneralPageLayout.js @@ -4,13 +4,12 @@ import { intlShape } from 'react-intl'; import TopBarLayout from '../../components/layout/TopBarLayout'; import BannerContainer from '../../containers/banners/BannerContainer'; import SidebarContainer from '../../containers/SidebarContainer'; -import { withLayout } from '../../styles/context/layout'; import { ModalProvider } from '../components/modals/ModalContext'; import { ModalManager } from '../components/modals/ModalManager'; import { IntlProvider } from '../context/IntlProvider'; @observer -class GeneralPageLayout extends React.Component { +export default class GeneralPageLayout extends React.Component { static defaultProps = { children: undefined, }; @@ -36,5 +35,3 @@ class GeneralPageLayout extends React.Component { ); } } - -export default withLayout(GeneralPageLayout); diff --git a/packages/yoroi-extension/app/components/settings/SettingsLayout.js b/packages/yoroi-extension/app/components/settings/SettingsLayout.js deleted file mode 100644 index 53658f90ac..0000000000 --- a/packages/yoroi-extension/app/components/settings/SettingsLayout.js +++ /dev/null @@ -1,27 +0,0 @@ -// @flow -import { Component } from 'react'; -import type { Node } from 'react'; -import { observer } from 'mobx-react'; -import styles from './SettingsLayout.scss'; - -type Props = {| - +children: Node, - +menu: Node, -|}; - -@observer -export default class SettingsLayout extends Component { - render(): Node { - const { menu, children } = this.props; - return ( -
- {menu} -
-
- {children} -
-
-
- ); - } -} diff --git a/packages/yoroi-extension/app/components/wallet/receive/VerifyAddressDialog.js b/packages/yoroi-extension/app/components/wallet/receive/VerifyAddressDialog.js index 96c0843d39..1fead03f09 100644 --- a/packages/yoroi-extension/app/components/wallet/receive/VerifyAddressDialog.js +++ b/packages/yoroi-extension/app/components/wallet/receive/VerifyAddressDialog.js @@ -2,13 +2,12 @@ /* eslint react/jsx-one-expression-per-line: 0 */ // the   in the html breaks this -import type { Node, ComponentType } from 'react'; +import type { Node } from 'react'; import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; import type { Notification } from '../../../types/notification.types'; import type { StandardAddress } from '../../../types/AddressFilterTypes'; import type { Addressing } from '../../../api/ada/lib/storage/models/PublicDeriver/interfaces'; import type { ComplexityLevelType } from '../../../types/complexityLevelType'; -import type { InjectedLayoutProps } from '../../../styles/context/layout'; import { Component } from 'react'; import { observer } from 'mobx-react'; import { defineMessages, intlShape } from 'react-intl'; @@ -23,7 +22,6 @@ import { normalizeToAddress, } from '../../../api/ada/lib/storage/bridge/utils'; import { ComplexityLevels } from '../../../types/complexityLevelType'; -import { withLayout } from '../../../styles/context/layout'; import classnames from 'classnames'; import QrCodeWrapper from '../../widgets/QrCodeWrapper'; import Dialog from '../../widgets/Dialog'; @@ -62,7 +60,7 @@ type Props = {| |}; @observer -class VerifyAddressDialog extends Component { +export default class VerifyAddressDialog extends Component { static contextTypes: {| intl: $npm$ReactIntl$IntlFormat |} = { intl: intlShape.isRequired, }; @@ -281,5 +279,3 @@ class VerifyAddressDialog extends Component { ); }; } - -export default (withLayout(VerifyAddressDialog): ComponentType); diff --git a/packages/yoroi-extension/app/components/wallet/staking/DelegationSuccessDialog.js b/packages/yoroi-extension/app/components/wallet/staking/DelegationSuccessDialog.js index 0dd8ef6ee2..7be5481da7 100644 --- a/packages/yoroi-extension/app/components/wallet/staking/DelegationSuccessDialog.js +++ b/packages/yoroi-extension/app/components/wallet/staking/DelegationSuccessDialog.js @@ -1,13 +1,10 @@ // @flow -import type { Node, ComponentType } from 'react'; +import type { Node } from 'react'; import { Component } from 'react'; import { observer } from 'mobx-react'; -import { defineMessages, intlShape } from 'react-intl'; -import SuccessPage from '../../transfer/SuccessPage'; import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; -import { withLayout } from '../../../styles/context/layout'; -import type { InjectedLayoutProps } from '../../../styles/context/layout'; +import { defineMessages, intlShape } from 'react-intl'; import { SuccessPageRevamp } from '../../transfer/SuccessPageRevamp'; import globalMessages from '../../../i18n/global-messages'; @@ -41,26 +38,14 @@ type Props = {| |}; @observer -class DelegationSuccessDialog extends Component { +export default class DelegationSuccessDialog extends Component { static contextTypes: {| intl: $npm$ReactIntl$IntlFormat |} = { intl: intlShape.isRequired, }; render(): Node { const { intl } = this.context; - - const classicLayout = ( - - ); - - const revampLayout = ( + return ( { }} /> ); - - return this.props.renderLayoutComponent({ - CLASSIC: classicLayout, - REVAMP: revampLayout, - }); } } - -export default (withLayout(DelegationSuccessDialog): ComponentType); diff --git a/packages/yoroi-extension/app/components/widgets/DangerousActionDialog.js b/packages/yoroi-extension/app/components/widgets/DangerousActionDialog.js index 1c5dfc4a80..cdd90f9cd4 100644 --- a/packages/yoroi-extension/app/components/widgets/DangerousActionDialog.js +++ b/packages/yoroi-extension/app/components/widgets/DangerousActionDialog.js @@ -1,18 +1,15 @@ // @flow -import type { Node, ComponentType } from 'react'; -import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; -import type { InjectedLayoutProps } from '../../styles/context/layout'; +import type { Node } from 'react'; import { Component } from 'react'; -import { observer } from 'mobx-react'; +import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; import { intlShape } from 'react-intl'; -import { withLayout } from '../../styles/context/layout'; -import { Box, FormControlLabel, Checkbox as MuiCheckbox } from '@mui/material'; +import { observer } from 'mobx-react'; +import { Box, Checkbox as MuiCheckbox, FormControlLabel } from '@mui/material'; import classnames from 'classnames'; import DialogCloseButton from './DialogCloseButton'; import Dialog from './Dialog'; import globalMessages from '../../i18n/global-messages'; import LocalizableError from '../../i18n/LocalizableError'; -import CheckboxLabel from '../common/CheckboxLabel'; import styles from './DangerousActionDialog.scss'; type Props = {| @@ -38,14 +35,14 @@ type Props = {| |}; @observer -class DangerousActionDialog extends Component { +export default class DangerousActionDialog extends Component { static contextTypes: {| intl: $npm$ReactIntl$IntlFormat |} = { intl: intlShape.isRequired, }; render(): Node { const { intl } = this.context; - const { isSubmitting, error, renderLayoutComponent, id } = this.props; + const { isSubmitting, error, id } = this.props; const dialogClasses = classnames(['removeWalletDialog', styles.dialog]); @@ -68,48 +65,6 @@ class DangerousActionDialog extends Component { }, ]; - const classicLayout = ( -
- {this.props.children} -
- -
- - {error ?

{intl.formatMessage(error, error.values)}

: null} -
- ); - - const revampLayout = ( - - {this.props.children} - - - } - id={id + '-acknowledgeAction-checkbox'} - sx={{ marginLeft: '-0px' }} - /> - - {error ?

{intl.formatMessage(error, error.values)}

: null} -
- ); - - const content = renderLayoutComponent({ - CLASSIC: classicLayout, - REVAMP: revampLayout, - }); - return ( { closeButton={} id={id} > - {content} + {( + + {this.props.children} + + + } + id={id + '-acknowledgeAction-checkbox'} + sx={{ marginLeft: '-0px' }} + /> + + {error ?

{intl.formatMessage(error, error.values)}

: null} +
+ )}
); } } - -export default (withLayout(DangerousActionDialog): ComponentType); diff --git a/packages/yoroi-extension/app/components/widgets/forms/InlineEditingInput.js b/packages/yoroi-extension/app/components/widgets/forms/InlineEditingInput.js index 835d4ff03f..65c86c8145 100644 --- a/packages/yoroi-extension/app/components/widgets/forms/InlineEditingInput.js +++ b/packages/yoroi-extension/app/components/widgets/forms/InlineEditingInput.js @@ -1,6 +1,6 @@ // @flow import { Component } from 'react'; -import type { Node, ComponentType } from 'react'; +import type { Node } from 'react'; import { observer } from 'mobx-react'; import { defineMessages, intlShape } from 'react-intl'; import classnames from 'classnames'; @@ -10,8 +10,6 @@ import vjf from 'mobx-react-form/lib/validators/VJF'; import styles from './InlineEditingInput.scss'; import config from '../../../config'; import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; -import { withLayout } from '../../../styles/context/layout'; -import type { InjectedLayoutProps } from '../../../styles/context/layout'; const messages = defineMessages({ change: { @@ -48,7 +46,7 @@ type State = {| |}; @observer -class InlineEditingInput extends Component { +export default class InlineEditingInput extends Component { static defaultProps: {| className: void |} = { className: undefined, }; @@ -189,5 +187,3 @@ class InlineEditingInput extends Component { ); } } - -export default (withLayout(InlineEditingInput): ComponentType); diff --git a/packages/yoroi-extension/app/connector/App.js b/packages/yoroi-extension/app/connector/App.js index 1b0db8035f..013e96eb99 100644 --- a/packages/yoroi-extension/app/connector/App.js +++ b/packages/yoroi-extension/app/connector/App.js @@ -31,7 +31,6 @@ import { Logger } from '../utils/logging'; import { ThemeProvider } from '@mui/material/styles'; import { globalStyles } from '../styles/globalStyles'; import { CssBaseline } from '@mui/material'; -import { LayoutProvider } from '../styles/context/layout'; import { changeToplevelTheme, MuiThemes } from '../styles/themes'; // https://github.com/yahoo/react-intl/wiki#loading-locale-data @@ -110,16 +109,14 @@ class App extends Component { return (
- - - - {globalStyles(muiTheme)} - - - {this.getContent()} - - - + + + {globalStyles(muiTheme)} + + + {this.getContent()} + +
); } diff --git a/packages/yoroi-extension/app/containers/dapp-connector/ConnectedWebsitesContainer.js b/packages/yoroi-extension/app/containers/dapp-connector/ConnectedWebsitesContainer.js index e41d052d7c..3bd0b30103 100644 --- a/packages/yoroi-extension/app/containers/dapp-connector/ConnectedWebsitesContainer.js +++ b/packages/yoroi-extension/app/containers/dapp-connector/ConnectedWebsitesContainer.js @@ -1,5 +1,5 @@ // @flow -import type { Node, ComponentType } from 'react'; +import type { Node } from 'react'; import { Component, lazy, Suspense } from 'react'; import { observer } from 'mobx-react'; import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; @@ -7,8 +7,6 @@ import { intlShape } from 'react-intl'; import type { StoresAndActionsProps } from '../../types/injectedProps.types'; import TopBarLayout from '../../components/layout/TopBarLayout'; import BannerContainer from '../banners/BannerContainer'; -import { withLayout } from '../../styles/context/layout'; -import type { LayoutComponentMap } from '../../styles/context/layout'; import SidebarContainer from '../SidebarContainer'; import { genLookupOrFail } from '../../stores/stateless/tokenHelpers'; import FullscreenLayout from '../../components/layout/FullscreenLayout'; @@ -22,13 +20,8 @@ export const ConnectedWebsitesPagePromise: void => Promise = () => import('../../components/dapp-connector/ConnectedWebsites/ConnectedWebsitesPage'); const ConnectedWebsitesPage = lazy(ConnectedWebsitesPagePromise); -type Props = StoresAndActionsProps; - -type InjectedLayoutProps = {| +renderLayoutComponent: LayoutComponentMap => Node |}; -type AllProps = {| ...Props, ...InjectedLayoutProps |}; - @observer -class ConnectedWebsitesPageContainer extends Component { +export default class ConnectedWebsitesPageContainer extends Component { static contextTypes: {| intl: $npm$ReactIntl$IntlFormat |} = { intl: intlShape.isRequired, }; @@ -87,4 +80,3 @@ class ConnectedWebsitesPageContainer extends Component { ); } } -export default (withLayout(ConnectedWebsitesPageContainer): ComponentType); diff --git a/packages/yoroi-extension/app/containers/experimental/YoroiPalette.js b/packages/yoroi-extension/app/containers/experimental/YoroiPalette.js index 8922585f93..e0507d9e92 100644 --- a/packages/yoroi-extension/app/containers/experimental/YoroiPalette.js +++ b/packages/yoroi-extension/app/containers/experimental/YoroiPalette.js @@ -1,12 +1,10 @@ // @flow -import type { Node, ComponentType } from 'react' +import type { Node } from 'react' import { Component } from 'react' import { observer } from 'mobx-react' import type { StoresAndActionsProps } from '../../types/injectedProps.types' import TopBarLayout from '../../components/layout/TopBarLayout' import BannerContainer from '../banners/BannerContainer' -import { withLayout } from '../../styles/context/layout' -import type { LayoutComponentMap } from '../../styles/context/layout' import SidebarContainer from '../SidebarContainer' import FullscreenLayout from '../../components/layout/FullscreenLayout' import Navbar from '../../components/experimental/layout/Navbar' @@ -14,13 +12,8 @@ import YoroiPalettePage from '../../components/experimental/YoroiPalette/YoroiPa import environment from '../../environment' import { ROUTES } from '../../routes-config' -type Props = StoresAndActionsProps - -type InjectedLayoutProps = {| +renderLayoutComponent: LayoutComponentMap => Node |}; -type AllProps = {| ...Props, ...InjectedLayoutProps |}; - @observer -class YoroiPaletteContainer extends Component { +export default class YoroiPaletteContainer extends Component { componentDidMount() { if(!environment.isNightly() && !environment.isDev()) { @@ -48,4 +41,3 @@ class YoroiPaletteContainer extends Component { ); } } -export default (withLayout(YoroiPaletteContainer): ComponentType); \ No newline at end of file diff --git a/packages/yoroi-extension/app/containers/experimental/yoroiThemes.js b/packages/yoroi-extension/app/containers/experimental/yoroiThemes.js index 918464a2d0..cb3db2dc5a 100644 --- a/packages/yoroi-extension/app/containers/experimental/yoroiThemes.js +++ b/packages/yoroi-extension/app/containers/experimental/yoroiThemes.js @@ -1,12 +1,10 @@ // @flow -import type { Node, ComponentType } from 'react' +import type { Node } from 'react' import { Component } from 'react' import { observer } from 'mobx-react' import type { StoresAndActionsProps } from '../../types/injectedProps.types' import TopBarLayout from '../../components/layout/TopBarLayout' import BannerContainer from '../banners/BannerContainer' -import { withLayout } from '../../styles/context/layout' -import type { LayoutComponentMap } from '../../styles/context/layout' import SidebarContainer from '../SidebarContainer' import FullscreenLayout from '../../components/layout/FullscreenLayout' import Navbar from '../../components/experimental/layout/Navbar' @@ -14,13 +12,8 @@ import YoroiThemesPage from '../../components/experimental/YoroiTheme/YoroiTheme import environment from '../../environment' import { ROUTES } from '../../routes-config' -type Props = StoresAndActionsProps - -type InjectedLayoutProps = {| +renderLayoutComponent: LayoutComponentMap => Node |}; -type AllProps = {| ...Props, ...InjectedLayoutProps |}; - @observer -class YoroiThemesContainer extends Component { +export default class YoroiThemesContainer extends Component { componentDidMount() { if(!environment.isNightly() && !environment.isDev()) { @@ -48,4 +41,3 @@ class YoroiThemesContainer extends Component { ); } } -export default (withLayout(YoroiThemesContainer): ComponentType); \ No newline at end of file diff --git a/packages/yoroi-extension/app/containers/settings/Settings.js b/packages/yoroi-extension/app/containers/settings/Settings.js index 602c1373aa..5233653833 100644 --- a/packages/yoroi-extension/app/containers/settings/Settings.js +++ b/packages/yoroi-extension/app/containers/settings/Settings.js @@ -1,11 +1,10 @@ // @flow +import type { Node } from 'react'; import { Component } from 'react'; -import type { Node, ComponentType } from 'react'; import { observer } from 'mobx-react'; +import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; import { intlShape } from 'react-intl'; import globalMessages from '../../i18n/global-messages'; -import SettingsLayout from '../../components/settings/SettingsLayout'; -import NavBarContainer from '../NavBarContainer'; import SettingsMenu from '../../components/settings/menu/SettingsMenu'; import BannerContainer from '../banners/BannerContainer'; import { buildRoute } from '../../utils/routing'; @@ -14,22 +13,15 @@ import type { StoresAndActionsProps } from '../../types/injectedProps.types'; import TopBarLayout from '../../components/layout/TopBarLayout'; import SidebarContainer from '../SidebarContainer'; import NavBarTitle from '../../components/topbar/NavBarTitle'; -import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; -import { withLayout } from '../../styles/context/layout'; -import type { LayoutComponentMap } from '../../styles/context/layout'; import NavBarContainerRevamp from '../NavBarContainerRevamp'; type Props = {| - ...StoresAndActionsProps, +children?: Node, |}; -type InjectedLayoutProps = {| - +renderLayoutComponent: LayoutComponentMap => Node, -|}; -type AllProps = {| ...Props, ...InjectedLayoutProps |}; +type AllProps = {| ...Props, ...StoresAndActionsProps |}; @observer -class Settings extends Component { +export default class Settings extends Component { static defaultProps: {| children: void |} = { children: undefined, }; @@ -58,29 +50,9 @@ class Settings extends Component { /> ); - const SettingsLayoutClassic = ( - } - sidebar={sidebarContainer} - navbar={ - - } - /> - } - showInContainer - > - {children != null ? children : null} - - ); - const SettingsLayoutRevamp = ( + return ( } + banner={} sidebar={sidebarContainer} navbar={ { {children} ); - return this.props.renderLayoutComponent({ - CLASSIC: SettingsLayoutClassic, - REVAMP: SettingsLayoutRevamp, - }); } } -export default (withLayout(Settings): ComponentType); diff --git a/packages/yoroi-extension/app/containers/settings/categories/RemoveWalletDialogContainer.js b/packages/yoroi-extension/app/containers/settings/categories/RemoveWalletDialogContainer.js index c8a69e9659..d7aa3cf7d8 100644 --- a/packages/yoroi-extension/app/containers/settings/categories/RemoveWalletDialogContainer.js +++ b/packages/yoroi-extension/app/containers/settings/categories/RemoveWalletDialogContainer.js @@ -1,5 +1,5 @@ // @flow -import type { ComponentType, Node } from 'react'; +import type { Node } from 'react'; import { Component } from 'react'; import { action, observable } from 'mobx'; import { observer } from 'mobx-react'; @@ -11,17 +11,11 @@ import { messages } from '../../../components/wallet/settings/RemoveWallet'; import type { StoresAndActionsProps } from '../../../types/injectedProps.types'; import DangerousActionDialog from '../../../components/widgets/DangerousActionDialog'; -import type { LayoutComponentMap } from '../../../styles/context/layout'; -import { withLayout } from '../../../styles/context/layout'; type Props = {| - ...StoresAndActionsProps, publicDeriverId: number, |}; -type InjectedLayoutProps = {| - +renderLayoutComponent: LayoutComponentMap => Node, -|}; -type AllProps = {| ...Props, ...InjectedLayoutProps |}; +type AllProps = {| ...Props, ...StoresAndActionsProps |}; const dialogMessages = defineMessages({ warning2: { @@ -37,7 +31,7 @@ const dialogMessages = defineMessages({ }); @observer -class RemoveWalletDialogContainer extends Component { +export default class RemoveWalletDialogContainer extends Component { static contextTypes: {| intl: $npm$ReactIntl$IntlFormat |} = { intl: intlShape.isRequired, }; @@ -76,35 +70,7 @@ class RemoveWalletDialogContainer extends Component { render(): Node { const { intl } = this.context; const settingsStore = this.props.stores.walletSettings; - const settingsActions = this.props.actions.walletSettings; - - const DangerousActionDialogClassic = ( - { - settingsActions.removeWallet.trigger({ - publicDeriverId: this.props.publicDeriverId, - }); - }, - }} - secondaryButton={{ - onClick: this.props.actions.dialogs.closeActiveDialog.trigger, - }} - id="removeWalletDialog" - > -

{intl.formatMessage(messages.removeExplanation)}

-

{intl.formatMessage(dialogMessages.warning2)}

-
- ); - const DangerousActionDialogRevamp = ( + return ( {

{intl.formatMessage(dialogMessages.warning2)}

); - - return this.props.renderLayoutComponent({ - CLASSIC: DangerousActionDialogClassic, - REVAMP: DangerousActionDialogRevamp, - }); } } -export default (withLayout(RemoveWalletDialogContainer): ComponentType); diff --git a/packages/yoroi-extension/app/containers/swap/SwapPageContainer.js b/packages/yoroi-extension/app/containers/swap/SwapPageContainer.js index d7c893dbe7..8cb0a729c6 100644 --- a/packages/yoroi-extension/app/containers/swap/SwapPageContainer.js +++ b/packages/yoroi-extension/app/containers/swap/SwapPageContainer.js @@ -1,13 +1,11 @@ // @flow -import type { Node, ComponentType } from 'react'; +import type { Node } from 'react'; import type { StoresAndActionsProps } from '../../types/injectedProps.types'; import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; -import type { LayoutComponentMap } from '../../styles/context/layout'; import { Component } from 'react'; import { observer } from 'mobx-react'; import { intlShape } from 'react-intl'; import { buildRoute } from '../../utils/routing'; -import { withLayout } from '../../styles/context/layout'; import globalMessages from '../../i18n/global-messages'; import SwapMenu from '../../components/swap/SwapMenu'; import BannerContainer from '../banners/BannerContainer'; @@ -18,18 +16,13 @@ import NavBarContainerRevamp from '../NavBarContainerRevamp'; import { SwapFormProvider } from './context/swap-form'; type Props = {| - ...StoresAndActionsProps, +children?: Node, |}; -type InjectedLayoutProps = {| - +renderLayoutComponent: LayoutComponentMap => Node, -|}; - -type AllProps = {| ...Props, ...InjectedLayoutProps |}; +type AllProps = {| ...Props, ...StoresAndActionsProps |}; @observer -class SwapPageContainer extends Component { +export default class SwapPageContainer extends Component { static defaultProps: {| children: void |} = { children: undefined, }; @@ -82,4 +75,3 @@ class SwapPageContainer extends Component { ); } } -export default (withLayout(SwapPageContainer): ComponentType); diff --git a/packages/yoroi-extension/app/containers/transfer/Transfer.js b/packages/yoroi-extension/app/containers/transfer/Transfer.js index e5a91205a4..90d4b86513 100644 --- a/packages/yoroi-extension/app/containers/transfer/Transfer.js +++ b/packages/yoroi-extension/app/containers/transfer/Transfer.js @@ -1,5 +1,5 @@ // @flow -import type { ComponentType, Node } from 'react'; +import type { Node } from 'react'; import { Component, lazy, Suspense } from 'react'; import { observer } from 'mobx-react'; import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; @@ -15,22 +15,18 @@ import NavBarTitle from '../../components/topbar/NavBarTitle'; import NavBarContainer from '../NavBarContainer'; import globalMessages from '../../i18n/global-messages'; import HorizontalLine from '../../components/widgets/HorizontalLine'; -import type { LayoutComponentMap } from '../../styles/context/layout'; -import { withLayout } from '../../styles/context/layout'; export const WalletTransferPagePromise: void => Promise = () => import('./WalletTransferPage'); const WalletTransferPage = lazy(WalletTransferPagePromise); type Props = {| - ...StoresAndActionsProps, +children?: Node, |}; -type InjectedLayoutProps = {| +renderLayoutComponent: LayoutComponentMap => Node |}; -type AllProps = {| ...Props, ...InjectedLayoutProps |}; +type AllProps = {| ...Props, ...StoresAndActionsProps |}; @observer -class Transfer extends Component { +export default class Transfer extends Component { static contextTypes: {| intl: $npm$ReactIntl$IntlFormat |} = { intl: intlShape.isRequired, }; @@ -89,4 +85,3 @@ class Transfer extends Component { ); }; } -export default (withLayout(Transfer): ComponentType); diff --git a/packages/yoroi-extension/app/containers/wallet/AddWalletPage.js b/packages/yoroi-extension/app/containers/wallet/AddWalletPage.js index 34011f52d0..ebb7d0ed13 100644 --- a/packages/yoroi-extension/app/containers/wallet/AddWalletPage.js +++ b/packages/yoroi-extension/app/containers/wallet/AddWalletPage.js @@ -1,12 +1,10 @@ // @flow -import type { ComponentType, Node } from 'react'; +import type { Node } from 'react'; import { Component } from 'react'; import type { StoresAndActionsProps } from '../../types/injectedProps.types'; import type { RestoreModeType } from '../../actions/common/wallet-restore-actions'; import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; import { intlShape } from 'react-intl'; -import type { LayoutComponentMap } from '../../styles/context/layout'; -import { withLayout } from '../../styles/context/layout'; import { observer } from 'mobx-react'; import { ROUTES } from '../../routes-config'; import { networks } from '../../api/ada/lib/storage/database/prepackaged/networks'; @@ -28,12 +26,8 @@ import WalletLedgerConnectDialogContainer from './dialogs/WalletLedgerConnectDia import SidebarContainer from '../SidebarContainer'; import AddWalletPageRevamp from './AddWalletPageRevamp'; -type Props = StoresAndActionsProps; -type InjectedLayoutProps = {| +renderLayoutComponent: LayoutComponentMap => Node |}; -type AllProps = {| ...Props, ...InjectedLayoutProps |}; - @observer -class AddWalletPage extends Component { +export default class AddWalletPage extends Component { static contextTypes: {| intl: $npm$ReactIntl$IntlFormat |} = { intl: intlShape.isRequired, }; @@ -211,4 +205,3 @@ class AddWalletPage extends Component { }); }; } -export default (withLayout(AddWalletPage): ComponentType); diff --git a/packages/yoroi-extension/app/containers/wallet/MyWalletsPage.js b/packages/yoroi-extension/app/containers/wallet/MyWalletsPage.js index 890fa482d9..b5af0d101a 100644 --- a/packages/yoroi-extension/app/containers/wallet/MyWalletsPage.js +++ b/packages/yoroi-extension/app/containers/wallet/MyWalletsPage.js @@ -1,14 +1,12 @@ // @flow -import type { Node, ComponentType } from 'react'; +import type { 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 { 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'; @@ -19,25 +17,16 @@ import WalletSubRow from '../../components/wallet/my-wallets/WalletSubRow'; import NavPlate from '../../components/topbar/NavPlate'; import SidebarContainer from '../SidebarContainer'; import BannerContainer from '../banners/BannerContainer'; -import NavBar from '../../components/topbar/NavBar'; import NavBarTitle from '../../components/topbar/NavBarTitle'; import WalletSync from '../../components/wallet/my-wallets/WalletSync'; import moment from 'moment'; -import NavBarAddButton from '../../components/topbar/NavBarAddButton'; -import BuySellAdaButton from '../../components/topbar/BuySellAdaButton'; import globalMessages from '../../i18n/global-messages'; -import BuySellDialog from '../../components/buySell/BuySellDialog'; 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 |}; - @observer -class MyWalletsPage extends Component { +export default class MyWalletsPage extends Component { static contextTypes: {| intl: $npm$ReactIntl$IntlFormat |} = { intl: intlShape.isRequired, }; @@ -79,21 +68,6 @@ class MyWalletsPage extends Component { const sidebarContainer = ; const { wallets } = this.props.stores.wallets; const navbarTitle = ; - const navbarElementClassic = ( - - this.props.actions.router.goToRoute.trigger({ route: ROUTES.WALLETS.ADD }) - } - /> - } - buyButton={ - this.openDialogWrapper(BuySellDialog)} /> - } - /> - ); const navbarElementRevamp = ( { /> ); - const navbarElement = this.props.renderLayoutComponent({ - CLASSIC: navbarElementClassic, - REVAMP: navbarElementRevamp, - }); - const walletsList = {wallets.map(wallet => this.generateRow(wallet))}; return ( } sidebar={sidebarContainer} - navbar={navbarElement} + navbar={navbarElementRevamp} showInContainer > {walletsList} @@ -240,4 +209,3 @@ class MyWalletsPage extends Component { return walletSubRow; }; } -export default (withLayout(MyWalletsPage): ComponentType); diff --git a/packages/yoroi-extension/app/containers/wallet/staking/CardanoStakingPage.js b/packages/yoroi-extension/app/containers/wallet/staking/CardanoStakingPage.js index f9ac11fb30..4f5148faca 100644 --- a/packages/yoroi-extension/app/containers/wallet/staking/CardanoStakingPage.js +++ b/packages/yoroi-extension/app/containers/wallet/staking/CardanoStakingPage.js @@ -1,12 +1,12 @@ // @flow -import type { Node, ComponentType } from 'react'; +import type { Node } from 'react'; import { Component } from 'react'; import { observer } from 'mobx-react'; import { observable, runInAction } from 'mobx'; +import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; import { intlShape } from 'react-intl'; import type { StoresAndActionsProps } from '../../../types/injectedProps.types'; -import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; import DelegationSendForm from '../../../components/wallet/send/DelegationSendForm'; import LocalizableError from '../../../i18n/LocalizableError'; import Dialog from '../../../components/widgets/Dialog'; @@ -20,6 +20,7 @@ import DelegationSuccessDialog from '../../../components/wallet/staking/Delegati import type { PoolMeta, PoolTransition } from '../../../stores/toplevel/DelegationStore'; import DelegationTxDialog from '../../../components/wallet/staking/DelegationTxDialog'; import StakePool from '../../../components/wallet/staking/dashboard/StakePool'; +import type { PoolData } from './SeizaFetcher'; import SeizaFetcher from './SeizaFetcher'; import config from '../../../config'; import { handleExternalLinkClick } from '../../../utils/routing'; @@ -27,28 +28,23 @@ import { genLookupOrFail, getTokenName } from '../../../stores/stateless/tokenHe import { MultiToken } from '../../../api/common/lib/MultiToken'; import WalletDelegationBanner from '../WalletDelegationBanner'; import { truncateToken } from '../../../utils/formatters'; -import { withLayout } from '../../../styles/context/layout'; -import type { LayoutComponentMap } from '../../../styles/context/layout'; import { Box } from '@mui/system'; -import type { PoolData } from './SeizaFetcher'; -import { isTestnet, getNetworkById } from '../../../api/ada/lib/storage/database/prepackaged/networks'; +import { getNetworkById, isTestnet } from '../../../api/ada/lib/storage/database/prepackaged/networks'; type Props = {| - ...StoresAndActionsProps, urlTemplate: ?string, poolTransition: ?PoolTransition, |}; -type InjectedLayoutProps = {| - +renderLayoutComponent: LayoutComponentMap => Node, -|}; + +type AllProps = {| ...Props, ...StoresAndActionsProps |}; + type State = {| firstPool: PoolData | void, selectedPoolId: ?string, |}; -type AllProps = {| ...Props, ...InjectedLayoutProps |}; @observer -class CardanoStakingPage extends Component { +export default class CardanoStakingPage extends Component { static contextTypes: {| intl: $npm$ReactIntl$IntlFormat |} = { intl: intlShape.isRequired, }; @@ -108,24 +104,7 @@ class CardanoStakingPage extends Component { const isWalletWithNoFunds = balance != null && balance.getDefaultEntry().amount.isZero(); const poolList = delegatedPoolId != null && isStakeRegistered ? [delegatedPoolId] : []; - const classicCardanoStakingPage = ( -
- {this.getDialog()} - { - this.setState({ selectedPoolId: poolId }); - await this.props.stores.delegation.createDelegationTransaction(poolId); - }} - /> -
- ); - - const revampCardanoStakingPage = ( + return ( <> {!isCurrentlyDelegating ? ( { ); - - return this.props.renderLayoutComponent({ - CLASSIC: classicCardanoStakingPage, - REVAMP: revampCardanoStakingPage, - }); } return ( @@ -443,5 +417,3 @@ class CardanoStakingPage extends Component { return undefined; }; } - -export default (withLayout(CardanoStakingPage): ComponentType); diff --git a/packages/yoroi-extension/app/containers/wallet/staking/StakingPageContent.js b/packages/yoroi-extension/app/containers/wallet/staking/StakingPageContent.js index 3d01c04fe5..3fb06fb31e 100644 --- a/packages/yoroi-extension/app/containers/wallet/staking/StakingPageContent.js +++ b/packages/yoroi-extension/app/containers/wallet/staking/StakingPageContent.js @@ -1,11 +1,10 @@ // @flow import { observer } from 'mobx-react'; import moment from 'moment'; -import type { ComponentType, Node } from 'react'; +import type { Node } from 'react'; import { Component } from 'react'; import { intlShape } from 'react-intl'; import type { ConfigType } from '../../../../config/config-types'; -import { withLayout } from '../../../styles/context/layout'; import type { TokenEntry } from '../../../api/common/lib/MultiToken'; import { Box, styled } from '@mui/system'; import BuySellDialog from '../../../components/buySell/BuySellDialog'; @@ -27,7 +26,6 @@ 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'; @@ -35,13 +33,8 @@ import { MultiToken } from '../../../api/common/lib/MultiToken'; // populated by ConfigWebpackPlugin declare var CONFIG: ConfigType; -type InjectedLayoutProps = {| - +renderLayoutComponent: LayoutComponentMap => Node, -|}; - -type AllProps = {| ...StoresAndActionsProps, ...InjectedLayoutProps |}; @observer -class StakingPageContent extends Component { +export default class StakingPageContent extends Component { static contextTypes: {| intl: $npm$ReactIntl$IntlFormat |} = { intl: intlShape.isRequired, }; @@ -365,7 +358,6 @@ class StakingPageContent extends Component { ); } } -export default (withLayout(StakingPageContent): ComponentType); const WrapperCards = styled(Box)({ display: 'flex', diff --git a/packages/yoroi-extension/app/containers/wallet/voting/RegistrationOver.js b/packages/yoroi-extension/app/containers/wallet/voting/RegistrationOver.js index 203a1f5f94..11db24b197 100644 --- a/packages/yoroi-extension/app/containers/wallet/voting/RegistrationOver.js +++ b/packages/yoroi-extension/app/containers/wallet/voting/RegistrationOver.js @@ -1,11 +1,9 @@ // @flow -import type { Node, ComponentType } from 'react'; +import type { Node } from 'react'; import { Component } from 'react'; import FullscreenMessage from '../../../components/wallet/layouts/FullscreenMessage'; import { ReactComponent as RegistrationNotAvailable } from '../../../assets/images/revamp/registration-is-not-available.inline.svg'; import { observer } from 'mobx-react'; -import { withLayout } from '../../../styles/context/layout'; -import type { InjectedLayoutProps } from '../../../styles/context/layout'; type Props = {| title: string | Node, @@ -13,7 +11,7 @@ type Props = {| |}; @observer -class RegistrationOver extends Component { +export default class RegistrationOver extends Component { render(): Node { return ( { ); } } - -export default (withLayout(RegistrationOver): ComponentType); diff --git a/packages/yoroi-extension/app/containers/wallet/voting/VotingPage.js b/packages/yoroi-extension/app/containers/wallet/voting/VotingPage.js index 8da142709e..444af49b15 100644 --- a/packages/yoroi-extension/app/containers/wallet/voting/VotingPage.js +++ b/packages/yoroi-extension/app/containers/wallet/voting/VotingPage.js @@ -1,9 +1,9 @@ // @flow -import { lazy, Component, Suspense } from 'react'; -import type { Node, ComponentType } from 'react'; +import type { Node } from 'react'; +import { Component, lazy, Suspense } from 'react'; import { observer } from 'mobx-react'; -import { intlShape } from 'react-intl'; import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; +import { intlShape } from 'react-intl'; import type { StoresAndActionsProps } from '../../../types/injectedProps.types'; import TopBarLayout from '../../../components/layout/TopBarLayout'; import BannerContainer from '../../banners/BannerContainer'; @@ -11,22 +11,13 @@ import SidebarContainer from '../../SidebarContainer'; import NavBarContainerRevamp from '../../NavBarContainerRevamp'; import NavBarTitle from '../../../components/topbar/NavBarTitle'; import globalMessages from '../../../i18n/global-messages'; -import { withLayout } from '../../../styles/context/layout'; -import type { LayoutComponentMap } from '../../../styles/context/layout'; // $FlowFixMe[signature-verification-failure] export const VotingPageContentPromise = () => import('./VotingPageContent'); const VotingPageContent = lazy(VotingPageContentPromise); -type Props = StoresAndActionsProps; -type InjectedLayoutProps = {| +renderLayoutComponent: LayoutComponentMap => Node |}; -type AllProps = {| - ...Props, - ...InjectedLayoutProps, -|}; - @observer -class VotingPage extends Component { +export default class VotingPage extends Component { static contextTypes: {| intl: $npm$ReactIntl$IntlFormat |} = { intl: intlShape.isRequired }; render(): Node { @@ -39,15 +30,15 @@ class VotingPage extends Component { ); - const revampLayout = ( + return ( } - sidebar={} + banner={} + sidebar={} navbar={ } + title={} /> } showInContainer @@ -55,12 +46,5 @@ class VotingPage extends Component { {content} ); - - return this.props.renderLayoutComponent({ - CLASSIC: content, - REVAMP: revampLayout, - }); } } - -export default (withLayout(VotingPage): ComponentType); diff --git a/packages/yoroi-extension/app/styles/context/layout.js b/packages/yoroi-extension/app/styles/context/layout.js deleted file mode 100644 index 3613b8cd1d..0000000000 --- a/packages/yoroi-extension/app/styles/context/layout.js +++ /dev/null @@ -1,44 +0,0 @@ -// @flow -import type { Node } from 'react'; -import React from 'react'; - -export type Layouts = 'CLASSIC' | 'REVAMP'; -// disabling legacy UI -export type LayoutComponentMap = {| - [key: Layouts]: Node, -|}; - -export type InjectedLayoutProps = {| - +renderLayoutComponent: (layoutMap: LayoutComponentMap) => Node, -|}; - -const LayoutContext = React.createContext(); - -const LayoutProvider = (props: Object): Node => { - return ( - disabling legacy UI - renderLayoutComponent: (layoutMap: LayoutComponentMap = {}) => { - return layoutMap.REVAMP; - }, - }} - {...props} - /> - ); -}; - -function useLayout(): Object { - const context = React.useContext(LayoutContext); - if (!context) { - throw new Error('useLayout must be used within a LayoutProvider'); - } - return context; -} - -const withLayout = (WrappedComponent: Function): Function => props => { - const layoutProps = useLayout(); - return ; -}; - -export { LayoutProvider, useLayout, withLayout }; From 4707fd20068c5fc789f2754940eb66540676037c Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Sun, 13 Oct 2024 22:38:45 +0300 Subject: [PATCH 26/76] removed legacy sidebar categories --- .../images/sidebar/my_wallets.inline.svg | 1 - .../sidebar/transfer_wallets.inline.svg | 1 - .../top-bar/back-arrow-white.inline.svg | 3 - .../app/stores/stateless/sidebarCategories.js | 71 ------------------- 4 files changed, 76 deletions(-) delete mode 100644 packages/yoroi-extension/app/assets/images/sidebar/my_wallets.inline.svg delete mode 100644 packages/yoroi-extension/app/assets/images/sidebar/transfer_wallets.inline.svg delete mode 100644 packages/yoroi-extension/app/assets/images/top-bar/back-arrow-white.inline.svg diff --git a/packages/yoroi-extension/app/assets/images/sidebar/my_wallets.inline.svg b/packages/yoroi-extension/app/assets/images/sidebar/my_wallets.inline.svg deleted file mode 100644 index 904bbf0b17..0000000000 --- a/packages/yoroi-extension/app/assets/images/sidebar/my_wallets.inline.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/packages/yoroi-extension/app/assets/images/sidebar/transfer_wallets.inline.svg b/packages/yoroi-extension/app/assets/images/sidebar/transfer_wallets.inline.svg deleted file mode 100644 index 91ecf1089f..0000000000 --- a/packages/yoroi-extension/app/assets/images/sidebar/transfer_wallets.inline.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/packages/yoroi-extension/app/assets/images/top-bar/back-arrow-white.inline.svg b/packages/yoroi-extension/app/assets/images/top-bar/back-arrow-white.inline.svg deleted file mode 100644 index 90c40efc2b..0000000000 --- a/packages/yoroi-extension/app/assets/images/top-bar/back-arrow-white.inline.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/packages/yoroi-extension/app/stores/stateless/sidebarCategories.js b/packages/yoroi-extension/app/stores/stateless/sidebarCategories.js index 61f11e21c3..04b74eef05 100644 --- a/packages/yoroi-extension/app/stores/stateless/sidebarCategories.js +++ b/packages/yoroi-extension/app/stores/stateless/sidebarCategories.js @@ -1,7 +1,6 @@ // @flow import type { MessageDescriptor } from 'react-intl'; import { ReactComponent as dappConnectorIcon } from '../../assets/images/dapp-connector/dapp-connector.inline.svg'; -import { ReactComponent as walletsIcon } from '../../assets/images/sidebar/my_wallets.inline.svg'; import { ReactComponent as assetsIcon } from '../../assets/images/sidebar/revamp/assets.inline.svg'; import { ReactComponent as governanceIcon } from '../../assets/images/sidebar/revamp/governance.inline.svg'; import { ReactComponent as nftsIcon } from '../../assets/images/sidebar/revamp/nfts.inline.svg'; @@ -11,81 +10,11 @@ import { ReactComponent as stakingIcon } from '../../assets/images/sidebar/revam import { ReactComponent as swapIcon } from '../../assets/images/sidebar/revamp/swap.inline.svg'; import { ReactComponent as votingIcon } from '../../assets/images/sidebar/revamp/voting.inline.svg'; import { ReactComponent as walletIcon } from '../../assets/images/sidebar/revamp/wallet.inline.svg'; -import { ReactComponent as transferIcon } from '../../assets/images/sidebar/transfer_wallets.inline.svg'; -import { ReactComponent as settingsIcon } from '../../assets/images/sidebar/wallet-settings-2-ic.inline.svg'; -import { ReactComponent as goBackIcon } from '../../assets/images/top-bar/back-arrow-white.inline.svg'; import environment from '../../environment'; import globalMessages, { connectorMessages } from '../../i18n/global-messages'; import { ROUTES } from '../../routes-config'; import type { WalletState } from '../../../chrome/extension/background/types'; -export type SidebarCategory = {| - +className: string, - +route: string, - +icon: string, - +label?: MessageDescriptor, - +isVisible: ({| - hasAnyWallets: boolean, - selected: ?{ publicDeriverId: number, ... }, - currentRoute: string, - |}) => boolean, -|}; - -// -export const allCategories: Array = []; -function registerCategory(category: SidebarCategory): SidebarCategory { - allCategories.push(category); - return category; -} - -export const MY_WALLETS: SidebarCategory = registerCategory({ - className: 'wallets', - route: ROUTES.MY_WALLETS, - icon: walletsIcon, - label: globalMessages.sidebarWallets, - isVisible: request => request.hasAnyWallets && request.selected == null, -}); - -export const WALLETS_ROOT: SidebarCategory = registerCategory({ - className: 'wallets', - route: ROUTES.WALLETS.ROOT, - icon: walletsIcon, - label: globalMessages.sidebarWallets, - isVisible: request => request.hasAnyWallets && request.selected != null, -}); - -export const BACK_TO_ADD: SidebarCategory = registerCategory({ - className: 'go-back', - route: ROUTES.WALLETS.ADD, - icon: goBackIcon, - label: globalMessages.goBack, - isVisible: request => !request.hasAnyWallets, -}); - -export const SETTINGS: SidebarCategory = registerCategory({ - className: 'settings', - route: ROUTES.SETTINGS.ROOT, - icon: settingsIcon, - label: globalMessages.sidebarSettings, - isVisible: r => r.selected != null, -}); - -export const TRANSFER_PAGE: SidebarCategory = registerCategory({ - className: 'wallet-transfer', - route: ROUTES.TRANSFER.ROOT, - icon: transferIcon, - label: globalMessages.sidebarTransfer, - isVisible: r => r.selected != null, -}); - -export const CONNECTED_WEBSITES: SidebarCategory = registerCategory({ - className: 'dapp-connector', - route: ROUTES.DAPP_CONNECTOR.CONNECTED_WEBSITES, - icon: dappConnectorIcon, - label: connectorMessages.dappConnector, - isVisible: _request => !environment.isLight, -}); - type isVisibleFunc = ({| hasAnyWallets: boolean, selected: ?WalletState, From 330c980142caf06731dfbe61d201b44045b26cec Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Sun, 13 Oct 2024 23:31:19 +0300 Subject: [PATCH 27/76] deleting unused files --- .../app/assets/images/add-label.inline.svg | 11 -- .../add-wallet-bg-modern.inline.svg | 61 ------ .../add-wallet/connect-hw-classic.inline.svg | 55 ------ .../add-wallet/connect-hw-modern.inline.svg | 1 - .../restore-wallet-classic.inline.svg | 76 ------- .../restore-wallet-modern.inline.svg | 1 - .../app/assets/images/cross-dark.inline.svg | 10 - .../images/dapp-connector/delete.inline.svg | 10 - .../no-dapps-connected.inline.svg | 48 ----- .../app/assets/images/generate-uri.inline.svg | 3 - .../hardware-wallet/trezor/check.inline.svg | 30 --- .../trezor/connect-error.inline.svg | 40 ---- .../hardware-wallet/trezor/connect-load.gif | Bin 11628 -> 0 bytes .../trezor/save-error.inline.svg | 60 ------ .../trezor/save-load.inline.svg | 66 ------- .../assets/images/question-mark.inline.svg | 1 - .../images/sidebar/open-sidebar.inline.svg | 1 - .../sidebar/yoroi-logo-expanded.inline.svg | 1 - .../images/sidebar/yoroi-logo.inline.svg | 1 - .../assets/images/success-small.inline.svg | 1 - .../transaction/export-tx-to-file.inline.svg | 17 -- .../images/uri/about-url-classic.inline.svg | 59 ------ .../app/assets/images/verify-icon.inline.svg | 11 -- .../images/wallet-nav/back-arrow.inline.svg | 11 -- .../app/assets/images/widget/cross.inline.svg | 13 -- .../app/assets/images/widget/tick.inline.svg | 15 -- .../yoroi-logo-nightly-white.inline.svg | 187 ------------------ .../assets/images/yoroi-logo-white.inline.svg | 76 ------- .../images/yoroi-nightly-icon.inline.svg | 139 ------------- .../ConnectedWebsitesPage.scss | 91 --------- .../profile/nightly/NightlyForm.scss | 44 ----- .../components/settings/SettingsLayout.scss | 22 --- .../components/settings/_settingsConfig.scss | 5 - .../app/components/topbar/NavBarBack.js | 33 ---- .../app/components/topbar/NavBarBack.scss | 19 -- .../app/components/topbar/SideBarCategory.js | 62 ------ .../components/topbar/SideBarCategory.scss | 40 ---- .../app/components/wallet/WalletAdd.js | 84 -------- .../app/components/wallet/WalletAdd.scss | 162 --------------- .../app/components/wallet/add/MainCards.js | 125 ------------ .../app/components/wallet/add/MainCards.scss | 64 ------ .../wallet/layouts/WalletWithNavigation.js | 35 ---- .../wallet/layouts/WalletWithNavigation.scss | 22 --- .../wallet/navigation/ReceiveNavButton.js | 72 ------- .../wallet/navigation/ReceiveNavButton.scss | 62 ------ .../wallet/navigation/WalletNavButton.js | 45 ----- .../wallet/navigation/WalletNavButton.scss | 73 ------- .../wallet/navigation/WalletNavigation.js | 56 ------ .../wallet/navigation/WalletNavigation.scss | 8 - .../syncingOverlay/WalletSyncingOverlay.js | 73 ------- .../syncingOverlay/WalletSyncingOverlay.scss | 30 --- .../components/widgets/NotificationMessage.js | 42 ---- .../widgets/NotificationMessage.scss | 33 ---- .../widgets/OneSideBarDecoration.js | 23 --- .../widgets/OneSideBarDecoration.scss | 14 -- .../app/components/widgets/WalletType.js | 33 ---- .../widgets/forms/ReadOnlyInput.scss | 38 ---- .../widgets/tokenOption/TokenOptionRow.js | 54 ----- 58 files changed, 2469 deletions(-) delete mode 100644 packages/yoroi-extension/app/assets/images/add-label.inline.svg delete mode 100644 packages/yoroi-extension/app/assets/images/add-wallet/add-wallet-bg-modern.inline.svg delete mode 100644 packages/yoroi-extension/app/assets/images/add-wallet/connect-hw-classic.inline.svg delete mode 100644 packages/yoroi-extension/app/assets/images/add-wallet/connect-hw-modern.inline.svg delete mode 100644 packages/yoroi-extension/app/assets/images/add-wallet/restore-wallet-classic.inline.svg delete mode 100644 packages/yoroi-extension/app/assets/images/add-wallet/restore-wallet-modern.inline.svg delete mode 100644 packages/yoroi-extension/app/assets/images/cross-dark.inline.svg delete mode 100644 packages/yoroi-extension/app/assets/images/dapp-connector/delete.inline.svg delete mode 100644 packages/yoroi-extension/app/assets/images/dapp-connector/no-dapps-connected.inline.svg delete mode 100644 packages/yoroi-extension/app/assets/images/generate-uri.inline.svg delete mode 100644 packages/yoroi-extension/app/assets/images/hardware-wallet/trezor/check.inline.svg delete mode 100644 packages/yoroi-extension/app/assets/images/hardware-wallet/trezor/connect-error.inline.svg delete mode 100644 packages/yoroi-extension/app/assets/images/hardware-wallet/trezor/connect-load.gif delete mode 100644 packages/yoroi-extension/app/assets/images/hardware-wallet/trezor/save-error.inline.svg delete mode 100644 packages/yoroi-extension/app/assets/images/hardware-wallet/trezor/save-load.inline.svg delete mode 100644 packages/yoroi-extension/app/assets/images/question-mark.inline.svg delete mode 100644 packages/yoroi-extension/app/assets/images/sidebar/open-sidebar.inline.svg delete mode 100644 packages/yoroi-extension/app/assets/images/sidebar/yoroi-logo-expanded.inline.svg delete mode 100644 packages/yoroi-extension/app/assets/images/sidebar/yoroi-logo.inline.svg delete mode 100644 packages/yoroi-extension/app/assets/images/success-small.inline.svg delete mode 100644 packages/yoroi-extension/app/assets/images/transaction/export-tx-to-file.inline.svg delete mode 100644 packages/yoroi-extension/app/assets/images/uri/about-url-classic.inline.svg delete mode 100644 packages/yoroi-extension/app/assets/images/verify-icon.inline.svg delete mode 100644 packages/yoroi-extension/app/assets/images/wallet-nav/back-arrow.inline.svg delete mode 100644 packages/yoroi-extension/app/assets/images/widget/cross.inline.svg delete mode 100644 packages/yoroi-extension/app/assets/images/widget/tick.inline.svg delete mode 100644 packages/yoroi-extension/app/assets/images/yoroi-logo-nightly-white.inline.svg delete mode 100644 packages/yoroi-extension/app/assets/images/yoroi-logo-white.inline.svg delete mode 100644 packages/yoroi-extension/app/assets/images/yoroi-nightly-icon.inline.svg delete mode 100644 packages/yoroi-extension/app/components/dapp-connector/ConnectedWebsites/ConnectedWebsitesPage.scss delete mode 100644 packages/yoroi-extension/app/components/profile/nightly/NightlyForm.scss delete mode 100644 packages/yoroi-extension/app/components/settings/SettingsLayout.scss delete mode 100644 packages/yoroi-extension/app/components/settings/_settingsConfig.scss delete mode 100644 packages/yoroi-extension/app/components/topbar/NavBarBack.js delete mode 100644 packages/yoroi-extension/app/components/topbar/NavBarBack.scss delete mode 100644 packages/yoroi-extension/app/components/topbar/SideBarCategory.js delete mode 100644 packages/yoroi-extension/app/components/topbar/SideBarCategory.scss delete mode 100644 packages/yoroi-extension/app/components/wallet/WalletAdd.js delete mode 100644 packages/yoroi-extension/app/components/wallet/WalletAdd.scss delete mode 100644 packages/yoroi-extension/app/components/wallet/add/MainCards.js delete mode 100644 packages/yoroi-extension/app/components/wallet/add/MainCards.scss delete mode 100644 packages/yoroi-extension/app/components/wallet/layouts/WalletWithNavigation.js delete mode 100644 packages/yoroi-extension/app/components/wallet/layouts/WalletWithNavigation.scss delete mode 100644 packages/yoroi-extension/app/components/wallet/navigation/ReceiveNavButton.js delete mode 100644 packages/yoroi-extension/app/components/wallet/navigation/ReceiveNavButton.scss delete mode 100644 packages/yoroi-extension/app/components/wallet/navigation/WalletNavButton.js delete mode 100644 packages/yoroi-extension/app/components/wallet/navigation/WalletNavButton.scss delete mode 100644 packages/yoroi-extension/app/components/wallet/navigation/WalletNavigation.js delete mode 100644 packages/yoroi-extension/app/components/wallet/navigation/WalletNavigation.scss delete mode 100644 packages/yoroi-extension/app/components/wallet/syncingOverlay/WalletSyncingOverlay.js delete mode 100644 packages/yoroi-extension/app/components/wallet/syncingOverlay/WalletSyncingOverlay.scss delete mode 100644 packages/yoroi-extension/app/components/widgets/NotificationMessage.js delete mode 100644 packages/yoroi-extension/app/components/widgets/NotificationMessage.scss delete mode 100644 packages/yoroi-extension/app/components/widgets/OneSideBarDecoration.js delete mode 100644 packages/yoroi-extension/app/components/widgets/OneSideBarDecoration.scss delete mode 100644 packages/yoroi-extension/app/components/widgets/WalletType.js delete mode 100644 packages/yoroi-extension/app/components/widgets/forms/ReadOnlyInput.scss delete mode 100644 packages/yoroi-extension/app/components/widgets/tokenOption/TokenOptionRow.js diff --git a/packages/yoroi-extension/app/assets/images/add-label.inline.svg b/packages/yoroi-extension/app/assets/images/add-label.inline.svg deleted file mode 100644 index f8e8ae55e1..0000000000 --- a/packages/yoroi-extension/app/assets/images/add-label.inline.svg +++ /dev/null @@ -1,11 +0,0 @@ - - - - icon/label - Created with Sketch. - - - - - - \ No newline at end of file diff --git a/packages/yoroi-extension/app/assets/images/add-wallet/add-wallet-bg-modern.inline.svg b/packages/yoroi-extension/app/assets/images/add-wallet/add-wallet-bg-modern.inline.svg deleted file mode 100644 index afa7fbabbf..0000000000 --- a/packages/yoroi-extension/app/assets/images/add-wallet/add-wallet-bg-modern.inline.svg +++ /dev/null @@ -1,61 +0,0 @@ - - - - -add wallet_bg - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/packages/yoroi-extension/app/assets/images/add-wallet/connect-hw-classic.inline.svg b/packages/yoroi-extension/app/assets/images/add-wallet/connect-hw-classic.inline.svg deleted file mode 100644 index bf03fc227c..0000000000 --- a/packages/yoroi-extension/app/assets/images/add-wallet/connect-hw-classic.inline.svg +++ /dev/null @@ -1,55 +0,0 @@ - - - - hardware_wallet.inline - Created with Sketch. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/packages/yoroi-extension/app/assets/images/add-wallet/connect-hw-modern.inline.svg b/packages/yoroi-extension/app/assets/images/add-wallet/connect-hw-modern.inline.svg deleted file mode 100644 index eddc9a80fb..0000000000 --- a/packages/yoroi-extension/app/assets/images/add-wallet/connect-hw-modern.inline.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/packages/yoroi-extension/app/assets/images/add-wallet/restore-wallet-classic.inline.svg b/packages/yoroi-extension/app/assets/images/add-wallet/restore-wallet-classic.inline.svg deleted file mode 100644 index d10eb9d418..0000000000 --- a/packages/yoroi-extension/app/assets/images/add-wallet/restore-wallet-classic.inline.svg +++ /dev/null @@ -1,76 +0,0 @@ - - - - restore_wallet.inline - Created with Sketch. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/packages/yoroi-extension/app/assets/images/add-wallet/restore-wallet-modern.inline.svg b/packages/yoroi-extension/app/assets/images/add-wallet/restore-wallet-modern.inline.svg deleted file mode 100644 index 44e803a777..0000000000 --- a/packages/yoroi-extension/app/assets/images/add-wallet/restore-wallet-modern.inline.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/packages/yoroi-extension/app/assets/images/cross-dark.inline.svg b/packages/yoroi-extension/app/assets/images/cross-dark.inline.svg deleted file mode 100644 index a3871260e5..0000000000 --- a/packages/yoroi-extension/app/assets/images/cross-dark.inline.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - close - Created with Sketch. - - - - - \ No newline at end of file diff --git a/packages/yoroi-extension/app/assets/images/dapp-connector/delete.inline.svg b/packages/yoroi-extension/app/assets/images/dapp-connector/delete.inline.svg deleted file mode 100644 index e66c61d793..0000000000 --- a/packages/yoroi-extension/app/assets/images/dapp-connector/delete.inline.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - icon/delete - - - - - - - \ No newline at end of file diff --git a/packages/yoroi-extension/app/assets/images/dapp-connector/no-dapps-connected.inline.svg b/packages/yoroi-extension/app/assets/images/dapp-connector/no-dapps-connected.inline.svg deleted file mode 100644 index ec19d5888f..0000000000 --- a/packages/yoroi-extension/app/assets/images/dapp-connector/no-dapps-connected.inline.svg +++ /dev/null @@ -1,48 +0,0 @@ - - - - v - Created with Sketch. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/packages/yoroi-extension/app/assets/images/generate-uri.inline.svg b/packages/yoroi-extension/app/assets/images/generate-uri.inline.svg deleted file mode 100644 index eee391c3e1..0000000000 --- a/packages/yoroi-extension/app/assets/images/generate-uri.inline.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/packages/yoroi-extension/app/assets/images/hardware-wallet/trezor/check.inline.svg b/packages/yoroi-extension/app/assets/images/hardware-wallet/trezor/check.inline.svg deleted file mode 100644 index b4d1899bb6..0000000000 --- a/packages/yoroi-extension/app/assets/images/hardware-wallet/trezor/check.inline.svg +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/packages/yoroi-extension/app/assets/images/hardware-wallet/trezor/connect-error.inline.svg b/packages/yoroi-extension/app/assets/images/hardware-wallet/trezor/connect-error.inline.svg deleted file mode 100644 index fbf3f139e6..0000000000 --- a/packages/yoroi-extension/app/assets/images/hardware-wallet/trezor/connect-error.inline.svg +++ /dev/null @@ -1,40 +0,0 @@ - - - - connect-error.inline - Created with Sketch. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/packages/yoroi-extension/app/assets/images/hardware-wallet/trezor/connect-load.gif b/packages/yoroi-extension/app/assets/images/hardware-wallet/trezor/connect-load.gif deleted file mode 100644 index 93e8c965287f5253e30ec7a8885540cc79aba499..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 11628 zcmdsdcQo8x_wS6+Mjb6WqeW-bAc)?}AZn0NgD4XuK@gqjLI}}`sEL*YL9`@Fh=eH7 zMmG$`5G|NH$@4z%``q<=@BR0#b!W|5bLM>a+55B0Ip4F^XY1rh5CnNFE9`5JFx3SUgj)vM=%+ezM z^mOyb#JA6%_fWG>5)*nlIu=n&+bhen!vmJaM$6)D-m0l&k%X^W$UZ8+JFXt=}{>TEk6`4-ODER-plR zo}{Mi&i_D-4xgT!gx$TnIXmrYZ+FAO{0N5|>S$Y^8voexdUfL4!sw8lxtaZSi?+8d z9W5;fJ3Da^5ACm;R~P12mX^W9il+L)b2 zEubQT?ys+J*qED#1O^~IZmo=uTARUfxS#0h?|XX(9j|I}xC89o!S3$<(%6^nx#_9N zsh!>Z{N{qeAb{Q6!eX}f z&{N+xroW@nJDZ!>l@;{r+Sb+#w!Xc(x{2Pz?&A)&Fu0YK4fON`8ohh8x3{}{kPz_@huh!ZKfrEnZLhA}w6Q+H z;Wp=fpr^*S=ccx|u{bQDp!T+ACehR5+p|-vD{JfP+sFF{nAu4;2m52(-i_-P_7>*H z`};q!SO?4NzkdFF5Ew{M_Pnrgvj4;8kMGON>uV^~`Oy)Epm25?Gc$E@eB^S&&c*)5 z`s5f6vz3{gj6XlOHG^+Xe>c=n-(Fig#_gXFzWX>QTbsJ#!n4y;{K?7g?%vB6FK)ZK z+;(ve4GcIsI=Xe!vEtd&O+pl=#@!tq2oMM*%7dpg(Y|h>sSekcmVkkP004k6Wn&D7 zYB>cu5q_1g1tFbWZo36So!xGE`l|5mzI)FL^>kI?wU#r686!2_JUsP6{M{@0x z+;&lP<-Mi~RSr@L@8#GukJsVkB&IZ2qjI7~_jrl2G(1^w5Dmtf7` z)m_P4OXpv<2>(=gJpu!fN|KWI@86fWFC*dSe@jwIQBhG6CM_u~El!XS4+!=RbP5vp z4dDA*gO*!>i@zr_(9_Qs`dg!uv)|o76?0pWlA{kq!tncl!^F|0*4DJs9aGY3>%_ch}#=jUdkV_hLfq{_lqV7Iby_w;b}W zzxN+MU0o#Iyxn}Dt){>HzR+syGt-fzSpp&nQ+i#=4*LwbEt@QtOt&*m{n^T~l|8+k< z@4rh0?%@~c7vSNCglcO3E)4~!kg=1Cr|<7c;osT(7hX4i&wFmJI{tn>&_C%=^87C- z!6p(bYvM&@<56?O)Za z?j88Ak+$yVG6oKwee2Kfys|$=`+P?MaaRGx}?p0hG-j{?w|K8bdzJ%@UPuRCW{Kfg%uhWy`qr;yE`?x*q?#?!5YZJY(zP7ru zytIf~n4g=S`9V0BC%%u5efv84Wn}pC(BMG-r;i`{dV9LN-gkDiziVr4dHd#db5mnO z{i~OCwKdgMl`krumzR~66c-g1*Iaf%hThQyPK3BEsp%b3#la4Zs7$2nQkH_Z^Qlu75!D-N3`L#?hQ^aAgxoYeMyv(4$;C1!)8k;7sxxv>pldllHiJXRS zYNwk##;P5L-qg*!MJ^8(7`}Zu_bzCEb8hJEtA+OwAWANymioos1O`#Z&n*qhpVIjZ z3yoSESBIX;+@Am3+O+ty;w=-IP9c-7fsDwh)19Q>D(*qytUl4bnWc#{=Kg?Lhw!^wN-6iI~_ z?yFo<k?fEtoRa4+vguS9KImLoRv}_jRZ*Q#U0r{Ozw1ezGVZli*Roc<^|JkN zQ}op*a{7P{E++~(~D$EbNoFTjH3>z7Z^crjc*e^UOJ0l}PF+@MGjh?+rT99H<2c`|gOuxD0H z4`R8}i~GX=>x@RuJ*Yv4ap_=LX4EK+BbLjST*^C0cExSF7;^REQQ5H*1-fAp zq4DKU(L&16CVDVa$a(;Y@{N(C7txC*c2%QgP%dT{fpJMF1BkC`b+b}n$Uve;U6pt&p$`R2}1ms#DpT)PI*$f?m>aS;6NCjSBi+X*$E83j-seq@40Ls5cO&(o*mPb z;uZ6X{r;#XYu_TVU;+raMh>JNT#qE<2T};zJO9k@|5%`w5peQUgQ&tud*y2{<>i{5 zt4769UZ_&`7G&2|xXm@WH+$&@!F((E2vXteF2q{)@p5`8@KXY{=w2vkzxrb1Q|iZ(Uo$pUCO2ikC2!c z7`ZE=MoSFuCP$V;5sj)Bc-8CDE9T&beNGt!=j?5NkisL39AWf3LPZ+PcAcbD=|PLX zh$O1_C`4Omo)zZLv*8EKGKjCcoe1>;B2YlmN?bADMx255;5T12+0cHF6S>%F%iEt# zWeQ;fx`y(jMESizXUp80@m}q>l$VRCDuuvar>~!_9aM=-qea1|V^}FQE}P+MtGCsb z0Xn=@RyHC!0bqm5yr2B$oVKPl6v?s&OLfSU8vDhzNLhPGt@G+Fox8ykosaqJE>q^4 zrU<5SjFyl~=+!zi4^8oI5K(KLRh#GjkbQCbvyl_%-9M3-WElitCkn9Xt|+EafPo$d zJr|ojw6pr$X2q9B!g|a44owIi`IWV0xX$hwXOfMXui<>k`?hH6 z?TgQ>8^=D#-fFvI+ryTrSUvwIm#2!pO}rU#V-0*RYP(5eT{dm}O6$!#d#t=qdzZMM zBhP(@pFfVEm~G!%x$N^#y6?B`Z{G;pHAF-%{y0CfS-9^&58%g$SZmsi5 z+n(`u@Cn-@%`cap`PJRnff}cd$FEzsQeg=U-istIEL}8loVU&Lorzwx^qgC=MjIL} zu*x)i6p34$Z=P&kWkY}!C30mXAdys*lYM>XcW%1VMX@5f=xs(Cv)_JRm3VM6grEt? zk%C1#ekSU_!q7;y;O^>GpN97|+)yX(1T0g(m6v3E3e2#xgx)w_`s{IeD8&;2a!>$z z>c1&cD6J<}(L)el_oy%MOwO^z0OF!HVk)i-qfH*1juq3quGCDSawU&a&H)4#_cksq zrAU#{kZUlK3QOM-14dG)X|j0$%(y70KCx>XN*;cuwF`D(d8GHIF=rU#e)ZS%XsUd3 zyi~HEtfu=Susg+yIvbS9$np_HN~zpM18ym%v8>b}DuBld1$F@yiv^@4^`iY}`MTsu z?%fRKDRi0QCDl}m=pr-0MzNov$W2>%m{S3C94MAg5L)_{VK2G$o!ckHI`sU-Bup67 zk~u7ZNfjB(-_lLhfe!!zBNlD2p7bSO^aQF@7piruOXI! z-(c^KSx}L503Mtv+=Kt@MJy2^^&3K(rPdFeg||r7hZWT5+aWQGZH1odsA#7C(S%CD z@bF85xS1$ajI;x!b*4-+(70_yL2kCtpQRi}Y zI=Q~g%&DM;m-c@6;H4OsYx_|T$>VeY`{?6IDv~&5WjHm976RZV6wT0LdMZTrOKdWS z{D*G9oOOhN44Dvwcu6;W^##-VTifL8r1}UTJvO|FUunf1ghY`!B1pfjhkR#d1}Xs0 z)gnlPq8cqp7OfwgMFdeNFwuHQo1jP?5ws$@hR^w^>AQ&U!b$IcdU#?Lg1>c%&n8MJ zD8`^HimWS2;yB8RF52rmtuLHZ9ZpOfK}=t-;E0VTWr;$X#avE^AvwMx+8<$Z9MgIw zF8&hrVKG_FI_a6 z!h#a6;iHL8FWof+&k>li1 zy}5zPvWSO89>fK1(Zn!4GNikV8?IZnm4qzWK_ zhzOD%xYT34NBk^tGvvB+$0??PT=-T2a%;51!g#UtU8e8y_RKK z#rPp2)0~x;BR$K2HPZ$xZ`b-nzX4c_dvaU?eOQv>hQ4y^QMRrWWp-CKPa~*WKAWC3 z2P&5n=*eh+dJ^Ob&4OlIwPuB%$jGujHH;*VRpjvnvmjfas)L@U>NCDW=45z6Ls(g! zc;*H(X36E|YL*b&kLI4Sw>IvU)1~Oe5pgYftW? z>AcqIoOf0B9q4E3KtL61{zf-&Qi|ne>$8-qd_DDNBeq=7uFP+?`JVDAgXT#Fwgu?wgpR`i~tDL>Ht@Qe*V@;K@RJ)-C#!c;>X>s1@Te^uh50Rs&Zvu zMeC1Ph(z*;?TTLr7fpi;C^id@74w3HvS7$d6o(ddft)(j>)F7zHEyk6f-c7KP0mrM9wbcS>VVN=2%lisi+e z>X*~nJ!OFuTrnsy94wdEEZ6>8cJrhxSt`mTLdUXN798~4Mv3wAV7A&fmdQzSsZpRW zEX**Eb`%Cs#wNOnFjfjbG23MEe@hfN3KEKtj#8?Ov8#*=sZ7YLjQSDci-(aQ;og^m zU#NU7Qk*8{9(;k~q4G3sSB(A~kAeRKuPk4^CNx z>A9jJNHmJ6D<(4Le`NH)K^lm(#Yk`tMV&ew(ZzsZHXAFaG?yII2dDJv!0y$cJXH@b zmkgq8gN?CWttJsyo2JgauPF0#`jskA-BV|DK2|s{;)HfaIYT10->D61QBwkbIj>l+;t4?3ovb-YRf7pj4S*gH7!A2?aMfLu2^*R~qQ8h{Cu zotT-7}?_GFEXprx<)88L$5z(u?XUqX`0;CTC(&12&iy;SgXO~5Ja5mAhu%i6KFRBl`E4ss1FL_L=fG<0y)pRJ+c8OqeK)4vJ(Uu z#VFBFRJRDm2@IFMi|DfCcU4(O#!LAW%#ii3QWrlMNPw ztc!cK>d6MX`W&4=`Y>raBsDEBhz3D+lS39%PomxR;f56LBougyLmF8R=tDuL5M*jD z)ZVpB-01)>zzgUYkpvV(;|vf7$WqjQvc>a|h?SAXhW1}8BTGzXx`pi%X!=O)+^@zr zkm=3zq+R+c2Q-gkpa3(FZ6sYn1ugq5oo_#Au{R)+If!o<6dfCU$-z_~I*`^r@b+x* zg|c*`7HC4AciOQ0x7<u$Is`B294$FD(_{p7^>;EDY821$)wF?38qxYGEK=*-?I3QFL;9S5M z4Hy7nzp3VTM3IK0$O};vohVWo6piY_neqH-7$e;U3OIrSg;T`U zFLKN;a=rvYxt4fUm-tPV;*m>2g-gPYOJeg&(49rt&LWE{>Jrxio$8|G*LfT#Ilc}h zMYAmMa!Dh6DG9z(H%gI&Truce(cK|8xmba7t(vQ@UN>1a>RizeU(t44(R{fi;0R>G zE_1v@0Y;X8&dn>#(`}yQ9Oa0P7+FuRU(clhTZFIQP+egv2Kv*iv4>Ms zsIHOiEcg^IcwRsvQM4;_Yc&^hq$7)Lor`6TK#d(V5q71c6aBy!op3>(Ho8#;qj-kI z3>Fdz*Mmno!NO4RH`VQNiS5sYL`CV_KRUN(=eK7^Fk@WX-+i}-cQBt*F&n9vfsu_& zM|5sFxQk}BV+XBKxCJZRM5$~oQ*YJzLS8w}dtc1?IHKPAlC!C93Wu+Uc49;3*LN?l z@g^90JZ6N3;?gc=d1U)Z{T|0nFe_@06@ugC#zEk?%MWpt={S-1II%A{K|Bru!%5?5 zft>I6<{Y=bgzqu#V(3jV@fTQZCz|TZ`u&$nWsaMq4=G5v$i3$e*5-DX<_?Tau_Th~ zV83-uT8!GlzRLUkOMZLf;gr?I6mOA~a()yQYB5(AfC`j_?Irh-I=vc4_D0p-K3H;D4ZNIo4oQcQSUjz5i9CYoh zYx%7Uhaa%{ZW2piPr2qjRp%Q`upFsat<;~C@6l?el=gV?+Aa!3{LgXK!|KsJkA+`? zw3PMf$IoGBy?#e`caMM&z{~oxA#REh{8Kg4zTQOLdeRSn&4#Qs#e`K!s4vbp#qcLZCQw&YI(i6drXyIzk< zQj3IKcHQ{0sF^?~U{Y@LbxAv!RnB*1>g%#@I*)cLzwNgb{VZWiE7yMP2g7I*Q&uI* z?zIxlR;0v|aF-x|ak@11u-4E9UwN91IEet|xP`5mKvk*TfR})Ut+6_4kZEG_`t!bQ zddoN7V$B|)S~vE=?HlHIR(;EEOzzB)P;PE^+_v6Xc9{9PYi-S9$zD-o?#;@|cF*9dFdIOdh)~8)hU5 zu&f%F))xrgG;?MRx$_}tA?Mgucv$Guftz{T@Py%-)OLitoW*% zN{m$Gh0Nev0NarMtIkKdI_F z!75v!t*2*E;GriWdGjYW#q97w(fBL-h~l>oIUj62s0hC|Q*u8%eU);7GkDoJDG0=m z08+EG048c5QYz10I1{Pd5l#(ZC`X)&1*ucH!?YP!ibd8vFgpGp@u2+~psd04^bvQAw`DmWqRPHA36KrU|W}fqI#Z5Bo#1KJh z@wAuUT`DEm$n~;C?vSgyOu>nfhmJ+wSh>4gU9hn?ySv4+nHBdd9Vf=fIE(yc{#%N} z!6tzf3^#zlKYS6zZ@y?0SO9X>z13e8CC zD1K;Z&B8ShtGHvkba4a^1E;?SJZqP?7bu@Fuz}zmiO-f`Sh-!&WukhO!frg^M6$cD z?0gdv8y&cGje%%cXzWg`kS6bgtN|oK@X_~&C#2rOQNuKSuNdlBJ?>0wYLVQ2-!{&d zBQ)3chc7yEX7ALh-9AV0`jG|nsZw>l(~f$tu4vakhjS`?KlJo2tS|Y5`_{uelJG-j z$UohA_WzSR=YU+mGC+oq9XugB|BcPdfVN7l^w+U8@$!94{F}{tltmK()_j!wR4l6p zwsfcQ51W_WzVt~aGF)vrv|mvB#cwum{_~{9m-pd##^%Zw&A-_^+RFfn1L096TLPPR zn}KGs>3lO6`kT#*y_1E;Cce4JNyuQw+)z#}71_PV<0N^0UD>>045C(v!zPo__I2Wg zM$;9Mm(r;HE#a+Ax6*TDm{&Frn$TlZnwqgx&9a-5^(2nI8%hK=kL>pHUu<4iG$pr5 zsPnU>{uBC){C34@S_zhWu=Vy+V`pwsv02{kw)>eEq^s*58OWjd;DxcIgHN63_L18& zHASXUs=to#m|taIxJ$#&PJap_G!KCu3lZd(D^XEY1U4@kq9e2z!)WEP7|Y^bxfsWB zZ-c<*(Uj{YoOi1^-#PZY=X|$@u6*vAVy%LGGQM389*DQ+DMKn!%gLm)aqdQ*;b+KEJ0jt9=d4%gu3R-6Hpc$6pZsb7s>JfDwLI@P=(T6a zkHYKuffJtV1wm_7FY;j!K)ed56|Sez2mR>gr>#~s3e^IHRQeo3q!Kg-A$zN36~byU zjua%s|19NPLMdM&B&TlEJO6J8#xaxy94bzzkuZz^KwH!}(&!*9W z0_`$UesG%7%Wp$HR$tXvb8>Vfa#G$~o@%-nJk&Il7n^zI`+@X-z@j6-asv$1vB<0y zbw`teQ*9SP$t+UjbgHhzAJvk=&w07}rcBecQ=mU1IE4Lw6U@eM^n=qAhE^zz~r)lWx&;RF91twTl0nD7S6R2%<-U%uZ{^RZs z8qu7e&yQg!9`)PwXVimVdzP|k>&_l=R7IouGldLkv)&KK z5I~^M$%z5@f5!e8Pzs>_b1Fsy&QGEj)gtqvz25X6^NcRU)131f#OzmTY0Wa3#bQ>!)zHv|dMibpvc`EY%)Wk6$ zpMZ;l0Qk}WYh0Z_*AIOh9{w{y$ABCHI(7oObbxvUd1kDUdbH~Wd3#_C8G9InFR?XX zpy(RA{;B6I%VOU9;7NYh*-E+*B4=*;$^l(-7fNR7^5*=iHKX`k{-mkCRNbW-c$s!Emt`K~y7>#^TdGe&F87b}a-UIcC!`3BsKU;+GfH%Zbx6F#x`bRCwskmt zmhD1CuSm?b1<3V$*xG&hA>yAQ{0;K=w(de}a-6ajR6ys`zuH0E41~}5tMB}?9mKT2+314f ze{Tn2rFO*t2<;$cq;~eonsUw=HHhAqpA8y{3Lo0LsA7&RYiHiFG*zc~T=IzzC%oQ$ zDBr%i8SlTY)b~KXZoW4ZFS0XJ@nJDKo^s&>rJ~=`ho`;t4Tn<**LT69%N_Zxvg5Q8 zO8BvvZVr#ZLh)yX4o{}yfg##QGrT~b^w9?0F|M6JIL)Ve>t(|2VE#RAc!cOD_Q;l> zos;#ehJ|lwlebWFJ2V+3?iK1JUN1vwzjS)3{fXT_LL~ZEh`_|^gkvT0zje%LwD&cX z>87#$-7&*=US&VvFEIG0V@C07rm?@M|K>RB$F*xuU>rhl&FjOLSg)OZwg25Qlf+WW zg@{S7R?|@~y*M~3>D5pu%2FkC%wWDf`E$40x=9D}d|o;0#W&DHKG~N?=$MhzX$DcS zNPp#tC)GY#5h=KD9OV#;yad@dY;AOljqqVqV_DZ+Y9(wQaASQeC2NjFjr==l_0CHn z5D^bE)4glL=Ummc!|$#PPf%}79U8Z{j6FfJO~^=1w(PG<{=Sh3C}gM%7T;drGLHjY zO=Diev)4Z-Kic0AaBkxJYIk~sWnlB5Ybc63J|6q><-GnT=Aq-NU~#~&y-)CK7v}*w z5!AU?P|;yb3B{2Nyeu-%PDG0Q#}bvc9jT-%0;wux>4cy$8@GkxhS%5ep@GEV|PV*x(Nt+ zITddoZLE4(M*z0viO z%hZoSSrYW8-O33%BIxogD=+l(r|#A0iu`+<=oiItBAb=v* - - - Group 9 Copy 2 - Created with Sketch. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/packages/yoroi-extension/app/assets/images/hardware-wallet/trezor/save-load.inline.svg b/packages/yoroi-extension/app/assets/images/hardware-wallet/trezor/save-load.inline.svg deleted file mode 100644 index 18fda8e491..0000000000 --- a/packages/yoroi-extension/app/assets/images/hardware-wallet/trezor/save-load.inline.svg +++ /dev/null @@ -1,66 +0,0 @@ - - - - save.inline - Created with Sketch. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/packages/yoroi-extension/app/assets/images/question-mark.inline.svg b/packages/yoroi-extension/app/assets/images/question-mark.inline.svg deleted file mode 100644 index 9806c07e0c..0000000000 --- a/packages/yoroi-extension/app/assets/images/question-mark.inline.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/packages/yoroi-extension/app/assets/images/sidebar/open-sidebar.inline.svg b/packages/yoroi-extension/app/assets/images/sidebar/open-sidebar.inline.svg deleted file mode 100644 index 3a67705315..0000000000 --- a/packages/yoroi-extension/app/assets/images/sidebar/open-sidebar.inline.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/packages/yoroi-extension/app/assets/images/sidebar/yoroi-logo-expanded.inline.svg b/packages/yoroi-extension/app/assets/images/sidebar/yoroi-logo-expanded.inline.svg deleted file mode 100644 index 561ef95b88..0000000000 --- a/packages/yoroi-extension/app/assets/images/sidebar/yoroi-logo-expanded.inline.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/packages/yoroi-extension/app/assets/images/sidebar/yoroi-logo.inline.svg b/packages/yoroi-extension/app/assets/images/sidebar/yoroi-logo.inline.svg deleted file mode 100644 index d479106fbe..0000000000 --- a/packages/yoroi-extension/app/assets/images/sidebar/yoroi-logo.inline.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/packages/yoroi-extension/app/assets/images/success-small.inline.svg b/packages/yoroi-extension/app/assets/images/success-small.inline.svg deleted file mode 100644 index b8d76a069d..0000000000 --- a/packages/yoroi-extension/app/assets/images/success-small.inline.svg +++ /dev/null @@ -1 +0,0 @@ -C1A491E1-87A9-4229-AF18-5B141E6D99B6 \ No newline at end of file diff --git a/packages/yoroi-extension/app/assets/images/transaction/export-tx-to-file.inline.svg b/packages/yoroi-extension/app/assets/images/transaction/export-tx-to-file.inline.svg deleted file mode 100644 index 19dff8a1dd..0000000000 --- a/packages/yoroi-extension/app/assets/images/transaction/export-tx-to-file.inline.svg +++ /dev/null @@ -1,17 +0,0 @@ - - - - export.inline copy - Created with Sketch. - - - - - - - - - - - - \ No newline at end of file diff --git a/packages/yoroi-extension/app/assets/images/uri/about-url-classic.inline.svg b/packages/yoroi-extension/app/assets/images/uri/about-url-classic.inline.svg deleted file mode 100644 index 895130a540..0000000000 --- a/packages/yoroi-extension/app/assets/images/uri/about-url-classic.inline.svg +++ /dev/null @@ -1,59 +0,0 @@ - - - - picture/about-url.inline - Created with Sketch. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/packages/yoroi-extension/app/assets/images/verify-icon.inline.svg b/packages/yoroi-extension/app/assets/images/verify-icon.inline.svg deleted file mode 100644 index eaffcaa010..0000000000 --- a/packages/yoroi-extension/app/assets/images/verify-icon.inline.svg +++ /dev/null @@ -1,11 +0,0 @@ - - - - icon/verify - Created with Sketch. - - - - - - \ No newline at end of file diff --git a/packages/yoroi-extension/app/assets/images/wallet-nav/back-arrow.inline.svg b/packages/yoroi-extension/app/assets/images/wallet-nav/back-arrow.inline.svg deleted file mode 100644 index af0beccc38..0000000000 --- a/packages/yoroi-extension/app/assets/images/wallet-nav/back-arrow.inline.svg +++ /dev/null @@ -1,11 +0,0 @@ - - - - Artboard - Created with Sketch. - - - - - - \ No newline at end of file diff --git a/packages/yoroi-extension/app/assets/images/widget/cross.inline.svg b/packages/yoroi-extension/app/assets/images/widget/cross.inline.svg deleted file mode 100644 index c4915c5799..0000000000 --- a/packages/yoroi-extension/app/assets/images/widget/cross.inline.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - - Shape Copy - Created with Sketch. - - - - - - - - \ No newline at end of file diff --git a/packages/yoroi-extension/app/assets/images/widget/tick.inline.svg b/packages/yoroi-extension/app/assets/images/widget/tick.inline.svg deleted file mode 100644 index 9e392c1010..0000000000 --- a/packages/yoroi-extension/app/assets/images/widget/tick.inline.svg +++ /dev/null @@ -1,15 +0,0 @@ - - - - Shape - Created with Sketch. - - - - - - - - - - \ No newline at end of file diff --git a/packages/yoroi-extension/app/assets/images/yoroi-logo-nightly-white.inline.svg b/packages/yoroi-extension/app/assets/images/yoroi-logo-nightly-white.inline.svg deleted file mode 100644 index 08f3d1e1e3..0000000000 --- a/packages/yoroi-extension/app/assets/images/yoroi-logo-nightly-white.inline.svg +++ /dev/null @@ -1,187 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/packages/yoroi-extension/app/assets/images/yoroi-logo-white.inline.svg b/packages/yoroi-extension/app/assets/images/yoroi-logo-white.inline.svg deleted file mode 100644 index 3c941929b5..0000000000 --- a/packages/yoroi-extension/app/assets/images/yoroi-logo-white.inline.svg +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/packages/yoroi-extension/app/assets/images/yoroi-nightly-icon.inline.svg b/packages/yoroi-extension/app/assets/images/yoroi-nightly-icon.inline.svg deleted file mode 100644 index c53a77e1c0..0000000000 --- a/packages/yoroi-extension/app/assets/images/yoroi-nightly-icon.inline.svg +++ /dev/null @@ -1,139 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/packages/yoroi-extension/app/components/dapp-connector/ConnectedWebsites/ConnectedWebsitesPage.scss b/packages/yoroi-extension/app/components/dapp-connector/ConnectedWebsites/ConnectedWebsitesPage.scss deleted file mode 100644 index 9112ef4189..0000000000 --- a/packages/yoroi-extension/app/components/dapp-connector/ConnectedWebsites/ConnectedWebsitesPage.scss +++ /dev/null @@ -1,91 +0,0 @@ -.component { - height: 100%; - width: 100%; - background-color: #fff; - display: flex; - justify-content: center; - - .container { - width: 750px; - height: 500px; - overflow-y: scroll; - background-color: white; - border: 1px solid #dce0e9; - border-radius: 8px; - -ms-overflow-style: none; - scrollbar-width: none; - } - - .container::-webkit-scrollbar { - display: none; - } - - .header { - display: grid; - grid-template-columns: 1fr 1fr; - box-shadow: 0 2px 4px 0 rgba(56, 57, 61, 0.2); - - & > p { - padding-left: 40px; - padding-top: 28px; - color: #000; - font-family: Rubik; - font-size: 14px; - letter-spacing: 0; - line-height: 22px; - padding-bottom: 16px; - } - } - .chain { - padding: 0px 24px; - & > h1 { - margin-top: 8px; - margin-bottom: 8px; - margin-left: 14px; - color: #a7afc0; - font-family: Rubik; - font-size: 14px; - letter-spacing: 0; - line-height: 22px; - } - } - - .line { - position: relative; - width: 100%; - - &::after { - content: ''; - left: 50%; - position: absolute; - width: 95%; - height: 1px; - background-color: #dce0e9; - transform: translateX(-50%); - } - } - .chain:first-child { - padding-top: 20px; - } -} - -.noDappsFound { - width: 100%; - height: 100%; - padding-bottom: 20px; - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - color: var(--yoroi-palette-gray-600); - text-align: center; - svg { - margin-bottom: 24px; - } - h3 { - font-size: 26px; - font-weight: 500; - margin-bottom: 20px; - line-height: 35px; - } -} diff --git a/packages/yoroi-extension/app/components/profile/nightly/NightlyForm.scss b/packages/yoroi-extension/app/components/profile/nightly/NightlyForm.scss deleted file mode 100644 index 3ce34db0bc..0000000000 --- a/packages/yoroi-extension/app/components/profile/nightly/NightlyForm.scss +++ /dev/null @@ -1,44 +0,0 @@ -@import '../../../themes/mixins/unordered-list'; - -.component { - @include unordered-list; - display: flex; - height: 100%; - justify-content: center; - - .centeredBox { - width: 480px; - } - - .logo { - margin-top: 40px; - margin-bottom: 40px; - & > svg { - display: block; - margin: auto; - width: 145px; - height: 135px; - } - } - - .content { - color: var(--yoroi-palette-gray-800); - font-weight: 400; - font-size: 14px; - line-height: 24px; - - .header { - font-size: 16px; - line-height: 32px; - } - - ul { - margin-top: 4px; - } - } - - .checkbox { - margin-top: 40px; - margin-bottom: 40px; - } -} diff --git a/packages/yoroi-extension/app/components/settings/SettingsLayout.scss b/packages/yoroi-extension/app/components/settings/SettingsLayout.scss deleted file mode 100644 index 5afd88030a..0000000000 --- a/packages/yoroi-extension/app/components/settings/SettingsLayout.scss +++ /dev/null @@ -1,22 +0,0 @@ -@import './settingsConfig'; - -.component { - background-color: var(--yoroi-palette-common-white); - display: flex; - flex-direction: column; - height: 100%; - - .settingsPaneWrapper { - flex: 1; - overflow-x: hidden; - overflow-y: overlay; - } - - .settingsPane { - min-height: 100%; - padding: 32px 24px; - background-color: var(--yoroi-palette-common-white); - border: 1px solid #ffffff; - overflow: visible; - } -} diff --git a/packages/yoroi-extension/app/components/settings/_settingsConfig.scss b/packages/yoroi-extension/app/components/settings/_settingsConfig.scss deleted file mode 100644 index c327311fc3..0000000000 --- a/packages/yoroi-extension/app/components/settings/_settingsConfig.scss +++ /dev/null @@ -1,5 +0,0 @@ -@mixin borderAndBackground { - background-color: var(--yoroi-palette-common-white); - border-radius: 4px; - border: solid 1px var(--yoroi-palette-common-white); -} diff --git a/packages/yoroi-extension/app/components/topbar/NavBarBack.js b/packages/yoroi-extension/app/components/topbar/NavBarBack.js deleted file mode 100644 index e2e1c83fe7..0000000000 --- a/packages/yoroi-extension/app/components/topbar/NavBarBack.js +++ /dev/null @@ -1,33 +0,0 @@ -// @flow -import { Component } from 'react'; -import type { Node } from 'react'; -import { observer } from 'mobx-react'; -import styles from './NavBarBack.scss'; -import { ReactComponent as BackIcon } from '../../assets/images/wallet-nav/back-arrow.inline.svg'; - -type Props = {| - +title: string, - +onBackClick: string => void, - +route: string, -|}; - -@observer -export default class NavBarBack extends Component { - - render(): Node { - const { title, onBackClick, route } = this.props; - - return ( - - ); - } -} diff --git a/packages/yoroi-extension/app/components/topbar/NavBarBack.scss b/packages/yoroi-extension/app/components/topbar/NavBarBack.scss deleted file mode 100644 index 01485c88a8..0000000000 --- a/packages/yoroi-extension/app/components/topbar/NavBarBack.scss +++ /dev/null @@ -1,19 +0,0 @@ -.backButton { - font-size: 14px; - line-height: 22px; - font-weight: 400; - background-color: transparent; - color: var(--yoroi-palette-gray-600); - height: 100%; - display: block; - - &:hover { - cursor: pointer; - } -} - -.backIcon { - width: 12px; - height: 12px; - margin-right: 16px; -} diff --git a/packages/yoroi-extension/app/components/topbar/SideBarCategory.js b/packages/yoroi-extension/app/components/topbar/SideBarCategory.js deleted file mode 100644 index aa729202bf..0000000000 --- a/packages/yoroi-extension/app/components/topbar/SideBarCategory.js +++ /dev/null @@ -1,62 +0,0 @@ -// @flow -import { Component } from 'react'; -import type { Node } from 'react'; -import type { MessageDescriptor, $npm$ReactIntl$IntlFormat } from 'react-intl'; -import { intlShape } from 'react-intl'; -import { observer } from 'mobx-react'; -import classNames from 'classnames'; -import styles from './SideBarCategory.scss'; - -type Props = {| - +icon: string, - +active: boolean, - +onClick: void => void, - +showLabel?: boolean, - +label: ?MessageDescriptor, -|}; - -@observer -export default class SideBarCategory extends Component { - static defaultProps: {|showLabel: boolean|} = { - showLabel: false, - }; - - static contextTypes: {|intl: $npm$ReactIntl$IntlFormat|} = { - intl: intlShape.isRequired, - }; - - render(): Node { - - const { intl } = this.context; - - const { - icon, - active, - onClick, - label, - showLabel - } = this.props; - - const componentStyles = classNames([ - styles.component, - active ? styles.active : null, - ]); - - const SvgElem = icon; - - return ( - - ); - } - -} diff --git a/packages/yoroi-extension/app/components/topbar/SideBarCategory.scss b/packages/yoroi-extension/app/components/topbar/SideBarCategory.scss deleted file mode 100644 index 92297d9856..0000000000 --- a/packages/yoroi-extension/app/components/topbar/SideBarCategory.scss +++ /dev/null @@ -1,40 +0,0 @@ -.component { - padding: 20px 24px; - height: 67px; - width: 100%; - display: flex; - align-items: center; - & svg > path { - fill: var(--yoroi-sidebar-text); - } - &:hover { - & svg > path { - fill: var(--yoroi-palette-secondary-300); - } - } - &.active:hover { - cursor: default !important; - } - &.active { - background-color: var(--yoroi-sidebar-end); - & svg > path { - fill: var(--yoroi-palette-secondary-300); - } - } -} - -.icon { - & > svg { - max-width: 24px; - max-height: 24px; - } -} - -.label { - display: block; - color: var(--yoroi-sidebar-text); - font-weight: 400; - font-size: 0.875rem; - line-height: 22px; - margin-left: 16px; -} diff --git a/packages/yoroi-extension/app/components/wallet/WalletAdd.js b/packages/yoroi-extension/app/components/wallet/WalletAdd.js deleted file mode 100644 index ebb14d247a..0000000000 --- a/packages/yoroi-extension/app/components/wallet/WalletAdd.js +++ /dev/null @@ -1,84 +0,0 @@ -// @flow -import { Component } from 'react'; -import type { Node } from 'react'; -import { observer } from 'mobx-react'; -import { defineMessages, intlShape, FormattedHTMLMessage } from 'react-intl'; - -import MainCards from './add/MainCards'; -import { ReactComponent as LogoYoroiIcon } from '../../assets/images/yoroi-logo-white.inline.svg'; -import { ReactComponent as SettingsIcon } from '../../assets/images/sidebar/wallet-settings-2-ic.inline.svg'; -import { ReactComponent as NightlyLogo } from '../../assets/images/yoroi-logo-nightly-white.inline.svg'; -import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; -import styles from './WalletAdd.scss'; - -import environment from '../../environment'; - -const messages = defineMessages({ - title: { - id: 'wallet.add.page.title', - defaultMessage: '!!!Your gateway to the financial world', - }, - subTitle: { - id: 'wallet.add.page.subtitle.label', - defaultMessage: '!!!Yoroi light wallet for Cardano', - }, -}); - -type Props = {| - +onCreate: void => void, - +onRestore: void => void, - +onHardwareConnect: void => void, - +onSettings: void => void, -|}; - -@observer -export default class WalletAdd extends Component { - static contextTypes: {|intl: $npm$ReactIntl$IntlFormat|} = { - intl: intlShape.isRequired, - }; - - getLogo: void => string = () => { - if (environment.isNightly()) { - return NightlyLogo; - } - return LogoYoroiIcon; - } - - render(): Node { - const { intl } = this.context; - const { onSettings } = this.props; - const LogoIcon = this.getLogo(); - - return ( -
- {/* Setting button */} -
-
- -
- -
- {/* Left block */} -
- -

- -

-

{intl.formatMessage(messages.subTitle)}

-
- {/* Right block */} -
- -
-
-
-
- ); - } -} diff --git a/packages/yoroi-extension/app/components/wallet/WalletAdd.scss b/packages/yoroi-extension/app/components/wallet/WalletAdd.scss deleted file mode 100644 index cdb50c4c67..0000000000 --- a/packages/yoroi-extension/app/components/wallet/WalletAdd.scss +++ /dev/null @@ -1,162 +0,0 @@ -@import '../mixins/card-mixin.scss'; - -$linebreakWidth: 1540px; - -.component { - height: 100%; - overflow: auto; - - .hero { - min-height: 100%; - max-width: 1366px; - margin: 0 auto; - padding: 20px 15px; - display: flex; - align-items: center; - - @media screen and (max-width: $linebreakWidth) { - max-width: 992px; - } - } - - .heroInner { - display: flex; - position: relative; - z-index: 1; - justify-content: space-between; - width: 100%; - - @media screen and (max-width: $linebreakWidth) { - flex-direction: column; - padding: 0 15px; - } - } - - .heroLogo { - margin-bottom: 48px; - width: 156px; - height: 50px; - display: block; - } - - .heroTitle { - color: var(--yoroi-palette-gray-900); - - font-size: 54px; - letter-spacing: 0.5px; - line-height: 62px; - margin-bottom: 15px; - margin-right: 42px; - width: 432px; - } - - .heroSubTitle { - font-weight: 400; - font-size: 22px; - line-height: 27px; - - @media screen and (max-width: 1530px) { - margin-bottom: 30px; - } - } - - .heroCardsItem { - @include card-mixin; - - &.heroCardsItemLink { - flex: auto; - flex-direction: row; - align-items: center; - text-decoration: none; - padding: 24px 32px; - - .heroCardsItemLinkIcon { - margin-right: 30px; - } - } - } - - .settingsBar { - position: absolute; - right: 35px; - top: 16px; - z-index: 99; - display: flex; - align-items: center; - } - - .settingsBarLink { - display: block; - cursor: pointer; - - + .settingsBarLink { - margin-left: 50px; - } - } -} - -:global(.YoroiClassic) { - .component { - background-image: linear-gradient(to right, #f3f3f5 65%, var(--yoroi-palette-common-white) 65%); - - .heroCardsItemLink { - width: calc(250px * 2 + 15px); - height: auto; - } - - .heroLogo, - .heroCardsItemLinkIcon, - .settingsBarLink { - path { - fill: var(--yoroi-palette-secondary-300); - } - } - - .heroTitle { - color: var(--yoroi-palette-background-walletAdd-title); - } - - .heroSubTitle { - color: var(--yoroi-palette-background-walletAdd-subtitle); - } - } -} - -:global(.YoroiModern), :global(.YoroiRevamp) { - .component { - background-image: url(../../assets/images/add-wallet/add-wallet-bg-modern.inline.svg); - background-size: cover; - background-repeat: no-repeat; - background-position: center -13vw; - - @media screen and (max-width: $linebreakWidth) { - background-position: 0 0; - } - - .heroTitle { - color: var(--yoroi-palette-background-walletAdd-title); - } - - .heroSubTitle { - color: var(--yoroi-palette-background-walletAdd-subtitle); - } - - .heroCardsItemLink { - width: calc(250px * 2 + 15px); - height: auto; - } - - .heroLogo, - .settingsBarLink { - path { - fill: var(--yoroi-palette-common-white); - } - } - - .heroCardsItemLinkIcon { - path { - fill: var(--yoroi-palette-primary-300); - } - } - } -} diff --git a/packages/yoroi-extension/app/components/wallet/add/MainCards.js b/packages/yoroi-extension/app/components/wallet/add/MainCards.js deleted file mode 100644 index 9c753d22e9..0000000000 --- a/packages/yoroi-extension/app/components/wallet/add/MainCards.js +++ /dev/null @@ -1,125 +0,0 @@ -// @flow -import { Component } from 'react'; -import type { Node } from 'react'; -import { observer } from 'mobx-react'; -import { defineMessages, intlShape, FormattedHTMLMessage } from 'react-intl'; -import classnames from 'classnames'; -import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; -import globalMessages from '../../../i18n/global-messages'; - -import CustomTooltip from '../../widgets/CustomTooltip'; - -import styles from './MainCards.scss'; - -const messages = defineMessages({ - connectToHWTitle: { - id: 'wallet.add.page.hw.title', - defaultMessage: '!!!Connect to hardware wallet', - }, - connectToHWTooltip: { - id: 'wallet.add.page.hw.tooltip', - defaultMessage: '!!!Create or restore a Yoroi wallet
using a Ledger or Trezor hardware wallet.', - }, - createTooltip: { - id: 'wallet.add.page.create.tooltip', - defaultMessage: '!!!Generate a new 15-word recovery phrase
and create a Yoroi wallet.', - }, - restoreTitle: { - id: 'wallet.add.page.restore.title', - defaultMessage: '!!!Restore wallet', - }, - restoreTooltip: { - id: 'wallet.add.page.restore.tooltip', - defaultMessage: '!!!Enter a 15-word recovery phrase
to restore an already-existing Yoroi wallet,
or import an existing Yoroi paper wallet.', - }, - -}); - -type Props = {| - +onCreate: void => void, - +onRestore: void => void, - +onHardwareConnect: void => void, -|}; - -@observer -export default class MainCards extends Component { - static contextTypes: {|intl: $npm$ReactIntl$IntlFormat|} = { - intl: intlShape.isRequired, - }; - - render(): Node { - const { intl } = this.context; - const { - onCreate, - onRestore, - onHardwareConnect, - } = this.props; - - return ( -
- {/* Connect to hardware wallet */} - - {/* Create wallet */} - - {/* Restore wallet */} - -
- ); - } -} diff --git a/packages/yoroi-extension/app/components/wallet/add/MainCards.scss b/packages/yoroi-extension/app/components/wallet/add/MainCards.scss deleted file mode 100644 index 9cdcf985f9..0000000000 --- a/packages/yoroi-extension/app/components/wallet/add/MainCards.scss +++ /dev/null @@ -1,64 +0,0 @@ -@import '../../mixins/card-mixin.scss'; - -.heroCardsList { - display: flex; -} - -.heroCardsItem { - @include card-mixin; - - .heroCardsItemBg { - flex: 1 0 auto; - background-repeat: no-repeat; - background-position: center center; - background-size: contain; - } -} - -:global(.YoroiClassic) { - .heroCardsItemBg { - &.bgConnectHW { - background-image: url(../../../assets/images/add-wallet/connect-hw-classic.inline.svg); - } - - &.bgCreateWallet { - background-image: url(../../../assets/images/add-wallet/create-wallet-classic.inline.svg); - } - - &.bgRestoreWallet { - background-image: url(../../../assets/images/add-wallet/restore-wallet-classic.inline.svg); - } - } -} - -:global(.YoroiRevamp) { - .heroCardsItemBg { - &.bgConnectHW { - background-image: url(../../../assets/images/add-wallet/connect-hw-modern.inline.svg); - } - - &.bgCreateWallet { - background-image: url(../../../assets/images/add-wallet/create-wallet-modern.inline.svg); - } - - &.bgRestoreWallet { - background-image: url(../../../assets/images/add-wallet/restore-wallet-modern.inline.svg); - } - } -} - -:global(.YoroiModern), :global(.YoroiRevamp) { - .heroCardsItemBg { - &.bgConnectHW { - background-image: url(../../../assets/images/add-wallet/connect-hw-modern.inline.svg); - } - - &.bgCreateWallet { - background-image: url(../../../assets/images/add-wallet/create-wallet-modern.inline.svg); - } - - &.bgRestoreWallet { - background-image: url(../../../assets/images/add-wallet/restore-wallet-modern.inline.svg); - } - } -} diff --git a/packages/yoroi-extension/app/components/wallet/layouts/WalletWithNavigation.js b/packages/yoroi-extension/app/components/wallet/layouts/WalletWithNavigation.js deleted file mode 100644 index 53dfb3676f..0000000000 --- a/packages/yoroi-extension/app/components/wallet/layouts/WalletWithNavigation.js +++ /dev/null @@ -1,35 +0,0 @@ -// @flow -import { Component } from 'react'; -import type { Node } from 'react'; -import { observer } from 'mobx-react'; -import WalletNavigation from '../navigation/WalletNavigation'; -import type { Category } from '../navigation/WalletNavigation'; -import styles from './WalletWithNavigation.scss'; - -type Props = {| - +children?: Node, - +categories: Array, -|}; - -@observer -export default class WalletWithNavigation extends Component { - static defaultProps: {|children: void|} = { - children: undefined - }; - - render(): Node { - const { children, } = this.props; - return ( -
-
- -
-
- {children} -
-
- ); - } -} diff --git a/packages/yoroi-extension/app/components/wallet/layouts/WalletWithNavigation.scss b/packages/yoroi-extension/app/components/wallet/layouts/WalletWithNavigation.scss deleted file mode 100644 index 4dd7f279f6..0000000000 --- a/packages/yoroi-extension/app/components/wallet/layouts/WalletWithNavigation.scss +++ /dev/null @@ -1,22 +0,0 @@ -.component { - height: 100%; - display: flex; - flex-direction: column; -} - -.navigation { - height: var(--yoroi-navigation-tab-height); - flex-shrink: 0; -} - -.page { - height: 100%; - min-height: 200px; - overflow: auto; -} - -:global(.YoroiModern) { - .navigation { - height: var(--yoroi-navigation-tab-height); - } -} diff --git a/packages/yoroi-extension/app/components/wallet/navigation/ReceiveNavButton.js b/packages/yoroi-extension/app/components/wallet/navigation/ReceiveNavButton.js deleted file mode 100644 index 271922bfae..0000000000 --- a/packages/yoroi-extension/app/components/wallet/navigation/ReceiveNavButton.js +++ /dev/null @@ -1,72 +0,0 @@ -// @flow -import { Component } from 'react'; -import type { Node } from 'react'; -import { observer } from 'mobx-react'; -import classnames from 'classnames'; -import styles from './ReceiveNavButton.scss'; - -type Props = {| - +label: string, - +isActive: boolean, - +onClick: void => void, - +className?: string, - +icon?: string, - +isToplevel?: boolean, - +tooltip?: Node, -|}; - -@observer -export default class ReceiveNavButton extends Component { - static defaultProps: {| className: void, icon: void, isToplevel:void, tooltip: void |} = { - className: undefined, - icon: undefined, - isToplevel: undefined, - tooltip: undefined, - }; - - renderButton: void => Node = () => { - const buttonClass = classnames([ - styles.button, - this.props.isToplevel === true - ? styles.topLevel - : styles.notTopLevel, - ]); - - if (this.props.tooltip == null) { - return ( - - ); - } - return ( - - ); - } - - render(): Node { - const componentClasses = classnames([ - this.props.className, - styles.wrapper, - this.props.isActive && styles.active, - ]); - - const IconComponent = this.props.icon; - - return ( -
- {this.renderButton()} - {IconComponent != null && -
- -
- } -
- ); - } -} diff --git a/packages/yoroi-extension/app/components/wallet/navigation/ReceiveNavButton.scss b/packages/yoroi-extension/app/components/wallet/navigation/ReceiveNavButton.scss deleted file mode 100644 index 8beefdfa11..0000000000 --- a/packages/yoroi-extension/app/components/wallet/navigation/ReceiveNavButton.scss +++ /dev/null @@ -1,62 +0,0 @@ -// ========= LAYOUT ========= - -.wrapper { - display: flex; - font-weight: 300; - color: var(--yoroi-palette-gray-600); - font-size: 1rem; - &:hover { - cursor: pointer; - background: var(--yoroi-palette-common-white); - } -} - -.button { - display: inline-block; - padding: 7px; - border-bottom: 3px solid transparent; - width: 100%; - text-align: left; - color: var(--yoroi-palette-gray-600); -} - -.active { - background: var(--yoroi-palette-common-white); - color: var(--yoroi-palette-gray-600); - .label { - font-weight: 500; - } - .notTopLevel { - color: var(--yoroi-palette-gray-600); - } - .topLevel { - color: var(--yoroi-palette-secondary-300); - } -} -.notTopLevel { - padding-left: 40px; -} -.topLevel { - padding-left: 24px; -} - -.icon { - position: relative; - right: 24px; - top: 7px; - - & > svg { - max-height: 24px; - max-width: 24px; - - & > g { - fill: var(--yoroi-palette-gray-600); - } - } -} - -.label { - font-size: 1rem; - line-height: 22px; - font-weight: 400; -} diff --git a/packages/yoroi-extension/app/components/wallet/navigation/WalletNavButton.js b/packages/yoroi-extension/app/components/wallet/navigation/WalletNavButton.js deleted file mode 100644 index 3b6877dc6e..0000000000 --- a/packages/yoroi-extension/app/components/wallet/navigation/WalletNavButton.js +++ /dev/null @@ -1,45 +0,0 @@ -// @flow -import { Component } from 'react'; -import type { Node } from 'react'; -import { observer } from 'mobx-react'; -import classnames from 'classnames'; -import styles from './WalletNavButton.scss'; - -type Props = {| - +label: string, - +icon?: string, - +isActive: boolean, - +onClick: void => void, - +className?: string, -|}; - -@observer -export default class WalletNavButton extends Component { - static defaultProps: {|className: void, icon: void|} = { - className: undefined, - icon: undefined - }; - - render(): Node { - const { isActive, onClick, className, label, icon } = this.props; - - const IconComponent = icon; - - const componentClasses = classnames([ - className, - styles.button, - isActive && styles.active - ]); - - return ( - - ); - } -} diff --git a/packages/yoroi-extension/app/components/wallet/navigation/WalletNavButton.scss b/packages/yoroi-extension/app/components/wallet/navigation/WalletNavButton.scss deleted file mode 100644 index c2c500db59..0000000000 --- a/packages/yoroi-extension/app/components/wallet/navigation/WalletNavButton.scss +++ /dev/null @@ -1,73 +0,0 @@ -// ========= LAYOUT ========= - -.button { - width: 100%; - display: flex; - align-items: center; - justify-content: center; - height: var(--yoroi-navigation-tab-height); - color: var(--yoroi-palette-gray-400); - - &:hover { - background-color: var(--yoroi-palette-common-white); - cursor: pointer; - } -} - -.active { - background-color: var(--yoroi-palette-common-white); - - .label { - color: var(--yoroi-palette-secondary-300); - } - - &:hover { - cursor: default; - background-color: var(--yoroi-palette-common-white); - } - - .icon { - & > svg { - color: var(--yoroi-palette-secondary-300); - } - & > svg > path { - fill: var(--yoroi-palette-secondary-300); - } - } -} - -.label { - font-size: 18px; - font-weight: 400; - font-weight: 500; - letter-spacing: 0.4px; - display: block; - text-align: center; - line-height: 22px; - color: var(--yoroi-palette-gray-600); -} - -.icon { - margin-right: 10px; - - & > svg { - max-height: 24px; - max-width: 24px; - - & > path { - fill: var(--yoroi-palette-gray-600); - } - } - - @media (max-width: 950px) { - display: none; - } -} - -:global(.YoroiModern) { - .active { - .label { - color: var(--yoroi-palette-secondary-300); - } - } -} diff --git a/packages/yoroi-extension/app/components/wallet/navigation/WalletNavigation.js b/packages/yoroi-extension/app/components/wallet/navigation/WalletNavigation.js deleted file mode 100644 index 6b672aa7f2..0000000000 --- a/packages/yoroi-extension/app/components/wallet/navigation/WalletNavigation.js +++ /dev/null @@ -1,56 +0,0 @@ -// @flow -import { Component } from 'react'; -import type { Node } from 'react'; -import { observer } from 'mobx-react'; -import { intlShape } from 'react-intl'; -import styles from './WalletNavigation.scss'; -import WalletNavButton from './WalletNavButton'; - -import type { MessageDescriptor, $npm$ReactIntl$IntlFormat } from 'react-intl'; - -export type Category = {| - +className: string, - +icon?: string, - +label?: MessageDescriptor, - +isActive: boolean, - +onClick: void => void, -|}; - -type Props = {| - categories: Array, -|}; - -@observer -export default class WalletNavigation extends Component { - - static contextTypes: {|intl: $npm$ReactIntl$IntlFormat|} = { - intl: intlShape.isRequired, - }; - - renderCategory: Category => ?Node = (category) => { - const { intl } = this.context; - - return ( -
- -
- ); - } - - render(): Node { - return ( -
- {this.props.categories.map(category => this.renderCategory(category))} -
- ); - } -} diff --git a/packages/yoroi-extension/app/components/wallet/navigation/WalletNavigation.scss b/packages/yoroi-extension/app/components/wallet/navigation/WalletNavigation.scss deleted file mode 100644 index 444ffbd391..0000000000 --- a/packages/yoroi-extension/app/components/wallet/navigation/WalletNavigation.scss +++ /dev/null @@ -1,8 +0,0 @@ -.component { - display: flex; -} - -.navItem { - flex: 1; - background-color: var(--yoroi-palette-gray-50); -} diff --git a/packages/yoroi-extension/app/components/wallet/syncingOverlay/WalletSyncingOverlay.js b/packages/yoroi-extension/app/components/wallet/syncingOverlay/WalletSyncingOverlay.js deleted file mode 100644 index b60f2ba078..0000000000 --- a/packages/yoroi-extension/app/components/wallet/syncingOverlay/WalletSyncingOverlay.js +++ /dev/null @@ -1,73 +0,0 @@ -// @flow -import type { Node } from 'react'; -import { Component } from 'react'; -import { observer } from 'mobx-react'; -import { intlShape, defineMessages } from 'react-intl'; -import styles from './WalletSyncingOverlay.scss'; -import Dialog from '../../widgets/Dialog'; -import DialogCloseButton from '../../widgets/DialogCloseButton'; -import LoadingSpinner from '../../widgets/LoadingSpinner'; -import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; - -type Props = {| - +onClose: void => PossiblyAsync, -|}; - -const messages = defineMessages({ - title: { - id: 'wallet.syncingOverlay.title', - defaultMessage: '!!!Wallet Syncing', - }, - explanation: { - id: 'wallet.syncingOverlay.explanation', - defaultMessage: '!!!Please wait while we process wallet data. This may take some time.' - }, - returnBtnLabel: { - id: 'wallet.syncingOverlay.return', - defaultMessage: '!!!Return to my wallets' - } -}) -@observer -export default class WalletSyncingOverlay extends Component { - - static contextTypes: {|intl: $npm$ReactIntl$IntlFormat|} = { - intl: intlShape.isRequired - }; - - render(): Node { - const { intl } = this.context; - const actions = this.props.onClose == null - ? undefined - : [{ - label: intl.formatMessage(messages.returnBtnLabel), - onClick: this.props.onClose, - primary: true - }]; - - return ( - ) : undefined} - > -
-
-
-
- {intl.formatMessage(messages.title)} -
-
- {intl.formatMessage(messages.explanation)} -
-
- -
-
-
-
- ); - } -} diff --git a/packages/yoroi-extension/app/components/wallet/syncingOverlay/WalletSyncingOverlay.scss b/packages/yoroi-extension/app/components/wallet/syncingOverlay/WalletSyncingOverlay.scss deleted file mode 100644 index 6624a2544f..0000000000 --- a/packages/yoroi-extension/app/components/wallet/syncingOverlay/WalletSyncingOverlay.scss +++ /dev/null @@ -1,30 +0,0 @@ -.component { - display: flex; - align-items: center; - justify-content: center; - overflow: hidden; - .title { - color: var(--theme-default-main-color); - text-transform: uppercase; - height: 19px; - font-family: var(--font-semibold); - font-size: 16px; - font-weight: 500; - line-height: 19px; - text-align: center; - } - - .text { - color: var(--card-text-color); - font-family: var(--font-regular); - font-size: 14px; - line-height: 22px; - text-align: center; - margin-top: 10px; - } - - .spinnerSection { - margin-top: 34px; - } -} - \ No newline at end of file diff --git a/packages/yoroi-extension/app/components/widgets/NotificationMessage.js b/packages/yoroi-extension/app/components/widgets/NotificationMessage.js deleted file mode 100644 index db7b71529c..0000000000 --- a/packages/yoroi-extension/app/components/widgets/NotificationMessage.js +++ /dev/null @@ -1,42 +0,0 @@ -// @flow -import { Component } from 'react'; -import type { Node } from 'react'; -import { observer } from 'mobx-react'; -import classNames from 'classnames'; -import styles from './NotificationMessage.scss'; - -type Props = {| - +icon: string, - +show: boolean, - +children?: Node, -|}; - -@observer -export default class NotificationMessage extends Component { - static defaultProps: {|children: null|} = { - children: null - }; - - render(): Node { - const { icon, show, children } = this.props; - - const notificationMessageStyles = classNames([ - styles.component, - show ? styles.show : null, - ]); - - const SvgElem = icon; - return ( -
- - {icon && } - -
- {children} -
- -
- ); - } - -} diff --git a/packages/yoroi-extension/app/components/widgets/NotificationMessage.scss b/packages/yoroi-extension/app/components/widgets/NotificationMessage.scss deleted file mode 100644 index 04a861581e..0000000000 --- a/packages/yoroi-extension/app/components/widgets/NotificationMessage.scss +++ /dev/null @@ -1,33 +0,0 @@ -.component { - background-color: var(--yoroi-notification-message-background); - height: 0; - overflow: hidden; - position: absolute; - text-align: center; - transition: all 200ms linear; - width: 100%; -} - -.show { - height: 40px; - padding: 0; -} - -.icon { - display: inline-block; - vertical-align: top; - & > svg { - height: 40px; - width: 40px; - } -} - -.message { - color: var(--yoroi-palette-gray-50); - display: inline-block; - font-weight: 400; - font-size: 14px; - font-weight: 500; - letter-spacing: normal; - line-height: 40px; -} diff --git a/packages/yoroi-extension/app/components/widgets/OneSideBarDecoration.js b/packages/yoroi-extension/app/components/widgets/OneSideBarDecoration.js deleted file mode 100644 index cc36f3d054..0000000000 --- a/packages/yoroi-extension/app/components/widgets/OneSideBarDecoration.js +++ /dev/null @@ -1,23 +0,0 @@ -// @flow -import { Component } from 'react'; -import type { Node } from 'react'; -import { observer } from 'mobx-react'; -import styles from './OneSideBarDecoration.scss'; - -type Props = {| - +children?: Node, -|}; - -@observer -export default class OneSideBarDecoration extends Component { - static defaultProps: {|children: void|} = { - children: undefined - }; - - render(): Node { - const { children } = this.props; - return ( -
{children}
- ); - } -} diff --git a/packages/yoroi-extension/app/components/widgets/OneSideBarDecoration.scss b/packages/yoroi-extension/app/components/widgets/OneSideBarDecoration.scss deleted file mode 100644 index 00afb57caa..0000000000 --- a/packages/yoroi-extension/app/components/widgets/OneSideBarDecoration.scss +++ /dev/null @@ -1,14 +0,0 @@ -.separator { - display: flex; - align-items: center; - text-align: center; -} -.separator::after { - content: ''; - flex: 1; - border-bottom: 2px solid var(--yoroi-palette-gray-200); -} - -.separator::after { - margin-left: 8px; -} diff --git a/packages/yoroi-extension/app/components/widgets/WalletType.js b/packages/yoroi-extension/app/components/widgets/WalletType.js deleted file mode 100644 index 1a00afab90..0000000000 --- a/packages/yoroi-extension/app/components/widgets/WalletType.js +++ /dev/null @@ -1,33 +0,0 @@ -// @flow - -import { Component } from 'react'; -import type { Node } from 'react' -import globalMessages from '../../i18n/global-messages'; -import { intlShape } from 'react-intl'; -import type { $npm$ReactIntl$MessageDescriptor, $npm$ReactIntl$IntlFormat } from 'react-intl'; -import type { WalletType as WalletT } from '../../../chrome/extension/background/types'; - -type Props = {| - walletType: WalletT, -|} -export default class WalletType extends Component { - static contextTypes: {|intl: $npm$ReactIntl$IntlFormat|} = { - intl: intlShape.isRequired, - }; - - getType: WalletT => $Exact<$npm$ReactIntl$MessageDescriptor> = (walletType) => { - if (walletType === 'ledger') { - return globalMessages.ledgerWallet; - } - if (walletType === 'trezor') { - return globalMessages.trezorWallet; - } - return globalMessages.standardWallet; - } - - render(): Node { - const { intl } = this.context; - const typeText = intl.formatMessage(this.getType(this.props.walletType)); - return {typeText} - } -} diff --git a/packages/yoroi-extension/app/components/widgets/forms/ReadOnlyInput.scss b/packages/yoroi-extension/app/components/widgets/forms/ReadOnlyInput.scss deleted file mode 100644 index 9c28f95b49..0000000000 --- a/packages/yoroi-extension/app/components/widgets/forms/ReadOnlyInput.scss +++ /dev/null @@ -1,38 +0,0 @@ -.component { - margin-bottom: 32px; - position: relative; - - .button { - bottom: 44px; - color: var(--yoroi-palette-gray-800); - cursor: pointer; - font-weight: 300; - font-size: 16px; - line-height: 1.38; - opacity: 0.5; - position: absolute; - right: 22px; - text-transform: lowercase; - &:hover { - opacity: 1; - } - } -} - -:global(.YoroiModern), :global(.YoroiRevamp) { - .component { - .disabled { - background-color: transparent; - } - - .button { - bottom: 37px; - } - } -} - -:global(.YoroiClassic) .component { - .button { - bottom: 44px; - } -} diff --git a/packages/yoroi-extension/app/components/widgets/tokenOption/TokenOptionRow.js b/packages/yoroi-extension/app/components/widgets/tokenOption/TokenOptionRow.js deleted file mode 100644 index ab01a904cb..0000000000 --- a/packages/yoroi-extension/app/components/widgets/tokenOption/TokenOptionRow.js +++ /dev/null @@ -1,54 +0,0 @@ -// @flow -import { Component } from 'react'; -import type { Node } from 'react'; -import { observer } from 'mobx-react'; -import { Typography } from '@mui/material'; -import { Box } from '@mui/system'; - -type Props = {| - +displayName: string, - +id?: string, - +amount?: string, - nameOnly?: boolean | null, -|}; - -@observer -export default class TokenOptionRow extends Component { - static defaultProps: {| - id: void, - amount: void, - nameOnly: void, - |} = { - id: undefined, - amount: undefined, - nameOnly: undefined, - }; - render(): Node { - const notOnlyName = !this.props.nameOnly; - return ( - - - {this.props.displayName} - {notOnlyName && {this.props.amount}} - - - {notOnlyName && ( - - {this.props.id} - - )} - - - ); - } -} From 8d27ea21a26eeceb2165b6d8bea0e15760975f67 Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Sun, 13 Oct 2024 23:50:30 +0300 Subject: [PATCH 28/76] removed legacy themes --- packages/yoroi-extension/app/Routes.js | 18 --- .../experimental/YoroiPalette/YoroiPalette.js | 139 ----------------- .../YoroiPalette/YoroiPalette.scss | 101 ------------- .../YoroiTheme/YoroiThemesPage.js | 119 --------------- .../YoroiTheme/YoroiThemesPage.scss | 121 --------------- .../components/experimental/layout/Navbar.js | 45 ------ .../experimental/layout/Navbar.scss | 24 --- .../containers/experimental/YoroiPalette.js | 43 ------ .../containers/experimental/yoroiThemes.js | 43 ------ packages/yoroi-extension/app/routes-config.js | 5 - packages/yoroi-extension/app/styles/themes.js | 8 - .../app/styles/themes/legacy/classic-theme.js | 141 ------------------ .../app/styles/themes/legacy/common-theme.js | 61 -------- .../app/styles/themes/legacy/modern-theme.js | 141 ------------------ 14 files changed, 1009 deletions(-) delete mode 100644 packages/yoroi-extension/app/components/experimental/YoroiPalette/YoroiPalette.js delete mode 100644 packages/yoroi-extension/app/components/experimental/YoroiPalette/YoroiPalette.scss delete mode 100644 packages/yoroi-extension/app/components/experimental/YoroiTheme/YoroiThemesPage.js delete mode 100644 packages/yoroi-extension/app/components/experimental/YoroiTheme/YoroiThemesPage.scss delete mode 100644 packages/yoroi-extension/app/components/experimental/layout/Navbar.js delete mode 100644 packages/yoroi-extension/app/components/experimental/layout/Navbar.scss delete mode 100644 packages/yoroi-extension/app/containers/experimental/YoroiPalette.js delete mode 100644 packages/yoroi-extension/app/containers/experimental/yoroiThemes.js delete mode 100644 packages/yoroi-extension/app/styles/themes/legacy/classic-theme.js delete mode 100644 packages/yoroi-extension/app/styles/themes/legacy/common-theme.js delete mode 100644 packages/yoroi-extension/app/styles/themes/legacy/modern-theme.js diff --git a/packages/yoroi-extension/app/Routes.js b/packages/yoroi-extension/app/Routes.js index 4c8f3046bc..61cd88e7c7 100644 --- a/packages/yoroi-extension/app/Routes.js +++ b/packages/yoroi-extension/app/Routes.js @@ -133,12 +133,6 @@ const NFTsPageRevamp = React.lazy(NFTsPageRevampPromise); const NFTDetailPageRevampPromise = () => import('./containers/wallet/NFTDetailPageRevamp'); const NFTDetailPageRevamp = React.lazy(NFTDetailPageRevampPromise); -const YoroiPalettePagePromise = () => import('./containers/experimental/YoroiPalette'); -const YoroiPalettePage = React.lazy(YoroiPalettePagePromise); - -const YoroiThemesPagePromise = () => import('./containers/experimental/yoroiThemes'); -const YoroiThemesPage = React.lazy(YoroiThemesPagePromise); - // SWAP const SwapPagePromise = () => import('./containers/swap/asset-swap/SwapPage'); const SwapPage = React.lazy(SwapPagePromise); @@ -182,8 +176,6 @@ export const LazyLoadPromises: Array<() => any> = [ NFTsPageRevampPromise, NFTDetailPageRevampPromise, ConnectedWebsitesPagePromise, - YoroiPalettePagePromise, - YoroiThemesPagePromise, SwapPagePromise, SwapOrdersPagePromise, OptForAnalyticsPagePromise, @@ -266,16 +258,6 @@ export const Routes = (stores: StoresMap, actions: ActionsMap): Node => { path={ROUTES.DAPP_CONNECTOR.CONNECTED_WEBSITES} component={props => } /> - } - /> - } - /> wrapWallet({ ...props, stores, actions }, WalletsSubpages(stores, actions))} diff --git a/packages/yoroi-extension/app/components/experimental/YoroiPalette/YoroiPalette.js b/packages/yoroi-extension/app/components/experimental/YoroiPalette/YoroiPalette.js deleted file mode 100644 index 747497df42..0000000000 --- a/packages/yoroi-extension/app/components/experimental/YoroiPalette/YoroiPalette.js +++ /dev/null @@ -1,139 +0,0 @@ -// @flow -import { Component } from 'react'; -import { observer } from 'mobx-react'; -import styles from './YoroiPalette.scss'; -import type { Node } from 'react'; -import { classicTheme } from '../../../styles/themes/legacy/classic-theme'; -import { modernTheme } from '../../../styles/themes/legacy/modern-theme'; -import classNames from 'classnames'; -import { ReactComponent as ArrowDown } from '../../../assets/images/down-arrow.inline.svg'; -import { getMainYoroiPalette, formatPalette } from '../../../styles/globalStyles'; -import type { DesignToken } from '../../../styles/globalStyles'; - -/** - * @todos - * 1. Print transaction status - * 2. Print the actual theme object - */ -type Props = {||}; - -type Theme = 'classic' | 'modern'; - -type State = {| - currentTheme: Theme, -|}; - -const themes = { - classic: classicTheme, - modern: modernTheme, -}; - -@observer -export default class YoroiPalettePage extends Component { - state: State = { - currentTheme: 'classic', - }; - - switchTheme(theme: Theme): void { - this.setState({ currentTheme: theme }); - } - - render(): Node { - const { currentTheme } = this.state; - const palette = getMainYoroiPalette(themes[currentTheme]); - const { designTokens, nameToHex } = formatPalette(palette, themes[currentTheme]); - return ( -
-
- - -
- -
-

Design tokens

-
- {designTokens.map(color => ( -
    {this.renderRow(color).map(node => node)}
- ))} -
-
- -

Colors Direct Hex Colors

- {nameToHex.map(color => ( -
- -
{String(color.hex)}
-
{color.name}
-
- ))} -
- ); - } - - renderRow(color: DesignToken): Node[] { - const subRows = [ - { - text: color.hex, - classnames: [styles.flexWithMargin, styles.multiLayerColorHex], - }, - { - text: color.path.join('-'), - classnames: [styles.flexWithMargin, styles.designTokens], - }, - { - text: color.child, - classnames: [styles.flexWithMargin, styles.child], - }, - { - text: color.parent, - classnames: [styles.flexWithMargin, styles.parent], - }, - ]; - - const nodes = []; - - for (let i = 0; i < subRows.length; i++) { - const subRow = subRows[i]; - nodes.push( - <> -
  • -
    -
    {subRow.text}
    -
  • - {i < subRows.length - 1 && ( -
  • - -
  • - )} - - ); - } - - return nodes; - } -} diff --git a/packages/yoroi-extension/app/components/experimental/YoroiPalette/YoroiPalette.scss b/packages/yoroi-extension/app/components/experimental/YoroiPalette/YoroiPalette.scss deleted file mode 100644 index 2d3c518d5f..0000000000 --- a/packages/yoroi-extension/app/components/experimental/YoroiPalette/YoroiPalette.scss +++ /dev/null @@ -1,101 +0,0 @@ -.component { - padding: 20px 40px; - - .themes { - display: grid; - grid-template-columns: 1fr 1fr; - width: 400px; - gap: 10px; - margin-bottom: 20px; - button { - font-size: 16px; - font-weight: 400; - color: #333438; - padding: 10px 16px; - border-radius: 10px; - background-color: #F0F3F5; - } - .active { - background-color: #59B1F4; - color: #fff; - } - } - - .row { - max-width: 1000px; - display: grid; - grid-template-columns: 1fr 2fr 2fr; - align-items: center; - justify-content: flex-start; - gap: 10px; - margin-bottom: 10px; - - .colorBox { - margin-right: 20px; - width: 124px; - height: 40px; - box-shadow: 3px 6px 8px rgba(0, 0, 0, 0.1); - border-radius: 10px; - } - - .colorName { - font-weight: 500; - font-size: 16px; - } - } - - .multiLayer { - - h1 { - font-size: 32px; - line-height: 32px; - margin: 40px 0px; - } - .multiLayerRows { - display: grid; - grid-template-columns: repeat(2, 1fr); - gap: 20px; - .multiLayerRow { - background-color: var(--yoroi-palette-gray-50); - margin-bottom: 20px; - display: flex; - flex-direction: column; - align-items: flex-start; - justify-content: center; - padding: 20px 40px; - border-radius: 9px; - - .flexWithMargin { - display: flex; - align-items: center; - justify-content: flex-start; - font-family: Courier, monospace; - font-weight: 500; - color: var(--yoroi-palette-gray-900); - p { - margin-left: 10px; - } - } - - .arrowDown { - margin-bottom: 10px; - margin-top: 10px; - display: inline-block; - width: 100%; - padding-left: 30px; - - svg { - width: 35px; - height: 35px; - } - } - } - } - } - - .nameToHexHeader { - font-size: 32px; - line-height: 32px; - margin: 20px 0px; - } -} diff --git a/packages/yoroi-extension/app/components/experimental/YoroiTheme/YoroiThemesPage.js b/packages/yoroi-extension/app/components/experimental/YoroiTheme/YoroiThemesPage.js deleted file mode 100644 index 4394fc699f..0000000000 --- a/packages/yoroi-extension/app/components/experimental/YoroiTheme/YoroiThemesPage.js +++ /dev/null @@ -1,119 +0,0 @@ -// @flow -import { Component } from 'react'; -import { observer } from 'mobx-react'; -import styles from './YoroiThemesPage.scss' -import type { Node } from 'react'; -import { classicTheme } from '../../../styles/themes/legacy/classic-theme'; -import { modernTheme } from '../../../styles/themes/legacy/modern-theme'; -import classNames from 'classnames'; - -type Props = {||} -type Theme = 'classic' | 'modern' - -type State = {| - currentTheme: Theme -|} - -const themes = { - classic: classicTheme, - modern: modernTheme -} - -@observer -export default class YoroiThemesPage extends Component { - - state: State = { - currentTheme: 'classic', - } - - switchTheme(theme: Theme): void { - this.setState({ currentTheme: theme }) - } - - render(): Node { - const { currentTheme } = this.state - delete themes[currentTheme].components - return ( -
    -
    - - -
    -
    -

    Shadows

    -
    - {themes[currentTheme].shadows.map(shadow => ( -
    {shadow} -
    - ))} -
    -
    -
    -

    Typography

    -
    - {Object.entries(themes[currentTheme].typography).map(entry => { - if (typeof entry[1] === 'object') { - return ( -
    -
    {entry[0]}
    -
      - {Object.entries(Object(entry[1])).map(row => ( -
    • -
      {JSON.stringify(row[0])}
      -
      {JSON.stringify(row[1])}
      -
    • - ))} -
    -
    - ) - } - - return '' - })} -
    -
    - -
    -

    Show All ({currentTheme})

    -
    - - -
    -
    -
    {JSON.stringify(themes[currentTheme], null, 5)}
    -
    -
    -
    - ) - } -} \ No newline at end of file diff --git a/packages/yoroi-extension/app/components/experimental/YoroiTheme/YoroiThemesPage.scss b/packages/yoroi-extension/app/components/experimental/YoroiTheme/YoroiThemesPage.scss deleted file mode 100644 index a02c58c032..0000000000 --- a/packages/yoroi-extension/app/components/experimental/YoroiTheme/YoroiThemesPage.scss +++ /dev/null @@ -1,121 +0,0 @@ -.component { - padding: 20px 40px; - padding-bottom: 200px; - - .themes { - display: grid; - grid-template-columns: 1fr 1fr; - width: 400px; - gap: 10px; - margin-bottom: 20px; - button { - font-size: 16px; - font-weight: 400; - color: #333438; - padding: 10px 16px; - border-radius: 10px; - background-color: #F0F3F5; - } - .active { - background-color: #59B1F4; - color: #fff; - } - } - - .shadows { - margin-top: 20px; - - & h1 { - font-size: 32px; - color: var(--yoroi-palette-gray-900); - margin-bottom: 20px; - } - - .shadowsContainer { - display: grid; - grid-template-columns: 1fr 1fr; - gap: 40px; - - .shadow { - background-color: var(--yoroi-palette-gray-100); - width: 100%; - height: 200px; - border-radius: 15px; - display: flex; - align-items: center; - justify-content: center; - text-align: center; - line-height: 32px; - font-family: monospace; - padding: 10px; - } - } - } - - .typographyWrapper { - margin-top: 60px; - - & h1 { - font-size: 32px; - color: var(--yoroi-palette-gray-900); - margin-bottom: 20px; - } - - .typographyList { - .row { - margin-bottom: 30px; - font-family: 'RobotoMono'; - .rowKey { - font-size: 19px; - line-height: 20px; - font-weight: 500; - text-transform: uppercase; - } - - .subRow { - background-color: var(--yoroi-palette-gray-50); - padding: 20px 40px; - margin-top: 10px; - border-radius: 9px; - - .subRowItem { - display: grid; - grid-template-columns: 1fr 4fr; - align-items: center; - justify-content: flex-start; - line-height: 30px; - - .key { - color: var(--yoroi-palette-gray-600); - margin-right: 20px; - font-family: 'RobotoMono'; - } - } - } - } - } - } - - .jsonWrapper { - margin-top: 60px; - - & h1 { - font-size: 32px; - color: var(--yoroi-palette-gray-900); - margin-bottom: 20px; - } - - .json { - background-color: var(--yoroi-palette-gray-100); - padding: 30px 40px; - border-radius: 8px; - line-height: 25px; - letter-spacing: 2px; - font-family: 'RobotoMono'; - font-weight: 500; - color: var(--yoroi-palette-gray-600); - box-shadow: 0px 3px 5px -1px rgba(0,0,0,0.2),0px 5px 8px 0px rgba(0,0,0,0.14),0px 1px 14px 0px rgba(0,0,0,0.12); - } - } - -} \ No newline at end of file diff --git a/packages/yoroi-extension/app/components/experimental/layout/Navbar.js b/packages/yoroi-extension/app/components/experimental/layout/Navbar.js deleted file mode 100644 index 849606717d..0000000000 --- a/packages/yoroi-extension/app/components/experimental/layout/Navbar.js +++ /dev/null @@ -1,45 +0,0 @@ -// @flow -import { Component } from 'react'; -import { observer } from 'mobx-react'; -import styles from './Navbar.scss' -import type { Node } from 'react'; -import { ROUTES } from '../../../routes-config'; -import classNames from 'classnames'; - -type Props = {| - goToRoute: string => void, -|} - -const PAGES = [ - { - label: 'Yoroi Palette', - route: ROUTES.EXPERIMENTAL.YOROI_PALETTE - }, - { - label: 'Themes', - route: ROUTES.EXPERIMENTAL.THEMES - } -] -@observer -export default class Navbar extends Component { - - render(): Node { - return ( -
    - { - PAGES.map(page => ( - - )) - } -
    - ) - } -} \ No newline at end of file diff --git a/packages/yoroi-extension/app/components/experimental/layout/Navbar.scss b/packages/yoroi-extension/app/components/experimental/layout/Navbar.scss deleted file mode 100644 index 2a8a12232b..0000000000 --- a/packages/yoroi-extension/app/components/experimental/layout/Navbar.scss +++ /dev/null @@ -1,24 +0,0 @@ -.component { - background-color: var(--yoroi-palette-gray-100); - box-shadow: 0 2px 5px 3px rgba(0, 0, 0, 0.06); - - .tab { - color: #38393D; - font-family: Rubik; - font-size: 20px; - font-weight: 500; - letter-spacing: 0; - line-height: 28px; - padding: 20px 40px; - color: var(--yoroi-palette-gray-600); - - &:hover { - background-color: var(--yoroi-palette-common-white); - } - } - - .active { - background-color: white; - color: var(--yoroi-palette-secondary-300); - } -} \ No newline at end of file diff --git a/packages/yoroi-extension/app/containers/experimental/YoroiPalette.js b/packages/yoroi-extension/app/containers/experimental/YoroiPalette.js deleted file mode 100644 index e0507d9e92..0000000000 --- a/packages/yoroi-extension/app/containers/experimental/YoroiPalette.js +++ /dev/null @@ -1,43 +0,0 @@ -// @flow -import type { Node } from 'react' -import { Component } from 'react' -import { observer } from 'mobx-react' -import type { StoresAndActionsProps } from '../../types/injectedProps.types' -import TopBarLayout from '../../components/layout/TopBarLayout' -import BannerContainer from '../banners/BannerContainer' -import SidebarContainer from '../SidebarContainer' -import FullscreenLayout from '../../components/layout/FullscreenLayout' -import Navbar from '../../components/experimental/layout/Navbar' -import YoroiPalettePage from '../../components/experimental/YoroiPalette/YoroiPalette' -import environment from '../../environment' -import { ROUTES } from '../../routes-config' - -@observer -export default class YoroiPaletteContainer extends Component { - - componentDidMount() { - if(!environment.isNightly() && !environment.isDev()) { - this.props.actions.router.goToRoute.trigger({ route: ROUTES.MY_WALLETS }) - } - } - - render (): Node { - const { actions, stores } = this.props; - const sidebarContainer = - return ( - )} - sidebar={sidebarContainer} - navbar={ - ( this.props.actions.router.goToRoute.trigger({ route })} - />) - } - > - - - - - ); - } -} diff --git a/packages/yoroi-extension/app/containers/experimental/yoroiThemes.js b/packages/yoroi-extension/app/containers/experimental/yoroiThemes.js deleted file mode 100644 index cb3db2dc5a..0000000000 --- a/packages/yoroi-extension/app/containers/experimental/yoroiThemes.js +++ /dev/null @@ -1,43 +0,0 @@ -// @flow -import type { Node } from 'react' -import { Component } from 'react' -import { observer } from 'mobx-react' -import type { StoresAndActionsProps } from '../../types/injectedProps.types' -import TopBarLayout from '../../components/layout/TopBarLayout' -import BannerContainer from '../banners/BannerContainer' -import SidebarContainer from '../SidebarContainer' -import FullscreenLayout from '../../components/layout/FullscreenLayout' -import Navbar from '../../components/experimental/layout/Navbar' -import YoroiThemesPage from '../../components/experimental/YoroiTheme/YoroiThemesPage' -import environment from '../../environment' -import { ROUTES } from '../../routes-config' - -@observer -export default class YoroiThemesContainer extends Component { - - componentDidMount() { - if(!environment.isNightly() && !environment.isDev()) { - this.props.actions.router.goToRoute.trigger({ route: ROUTES.MY_WALLETS }) - } - } - - render (): Node { - const { actions, stores } = this.props; - const sidebarContainer = - return ( - )} - sidebar={sidebarContainer} - navbar={ - ( this.props.actions.router.goToRoute.trigger({ route })} - />) - } - > - - - - - ); - } -} diff --git a/packages/yoroi-extension/app/routes-config.js b/packages/yoroi-extension/app/routes-config.js index df36933045..cd69fc68d0 100644 --- a/packages/yoroi-extension/app/routes-config.js +++ b/packages/yoroi-extension/app/routes-config.js @@ -62,11 +62,6 @@ export const ROUTES = { DAPP_CONNECTOR: { CONNECTED_WEBSITES: '/connector/connected-websites', }, - EXPERIMENTAL: { - YOROI_PALETTE: '/experimental/yoroi-palette', - YOROI_COMPONENTS: '/experimental/components', - THEMES: '/experimental/themes', - }, // Revamp specific routes: REVAMP: { // `voting` is part of the sidebar diff --git a/packages/yoroi-extension/app/styles/themes.js b/packages/yoroi-extension/app/styles/themes.js index 09af4eb1ba..b0b11a564c 100644 --- a/packages/yoroi-extension/app/styles/themes.js +++ b/packages/yoroi-extension/app/styles/themes.js @@ -3,22 +3,14 @@ import { createTheme } from '@mui/material/styles'; import { deepmerge } from '@mui/utils'; import { baseLightTheme } from './themes/light-theme-mui'; -import { classicTheme } from './themes/legacy/classic-theme'; -import { modernTheme } from './themes/legacy/modern-theme'; - -// legacy themes export const THEMES = Object.freeze({ - YOROI_CLASSIC: 'YoroiClassic', - YOROI_MODERN: 'YoroiModern', YOROI_BASE: 'YoroiBase', }); export type Theme = $Values; // Old way export const baseTheme: Object = createTheme(deepmerge({ name: 'base' }, baseLightTheme)); export const MuiThemes: {| [Theme]: Object |} = Object.freeze({ - [THEMES.YOROI_CLASSIC]: classicTheme, - [THEMES.YOROI_MODERN]: modernTheme, [THEMES.YOROI_BASE]: baseTheme, }); diff --git a/packages/yoroi-extension/app/styles/themes/legacy/classic-theme.js b/packages/yoroi-extension/app/styles/themes/legacy/classic-theme.js deleted file mode 100644 index cef4c9a84d..0000000000 --- a/packages/yoroi-extension/app/styles/themes/legacy/classic-theme.js +++ /dev/null @@ -1,141 +0,0 @@ -// @flow -import { createTheme } from '@mui/material/styles'; -import { SFUIDisplayFonts, RobotoMonoFonts } from '../../fonts'; -import { - ClassicButton, - ClassicCheckbox, - ClassicInputLabel, - ClassicTextField, - ClassicOutlinedInput, - ClassicFormHelperText, - ClassicFormControl, - ClassicMenu, - ClassicMenuItem, - ClassicTabs, - ClassicTabPanel, - ClassicChip, - ClassicTooltip, - ClassicSelect, -} from '../../overrides/legacy'; -import { commonTheme } from './common-theme'; -import { deepmerge } from '@mui/utils'; - -const fontFamily = ['SFUIDisplay', 'sans-serif'].join(','); - -const theme = { - name: 'classic', - components: { - MuiCssBaseline: { - styleOverrides: ` - ${SFUIDisplayFonts} - ${RobotoMonoFonts} - `, - }, - MuiButton: ClassicButton, - MuiCheckbox: ClassicCheckbox, - MuiInputLabel: ClassicInputLabel, - MuiTextField: ClassicTextField, - MuiOutlinedInput: ClassicOutlinedInput, - MuiFormHelperText: ClassicFormHelperText, - MuiFormControl: ClassicFormControl, - MuiSelect: ClassicSelect, - MuiMenuItem: ClassicMenuItem, - MuiMenu: ClassicMenu, - MuiTabs: ClassicTabs, - MuiTabPanel: ClassicTabPanel, - MuiChip: ClassicChip, - MuiTooltip: ClassicTooltip, - }, - palette: { - /* `main` is added since MUI required it but we don't use it at all */ - primary: { - main: '#daa49a', - '50': '#F4FDFA', - '100': '#C9ECE5', - '200': '#EDB2A6', - '300': '#DAA49A', - contrastText: '#FFF', - }, - secondary: { - main: '#daa49a', - '50': '#F4FDFA', - '100': '#C9ECE5', - '200': '#EDB2A6', - '300': '#DAA49A', - contrastText: '#FFF', - }, - background: { - sidebar: { - start: '#373f52', - end: '#373f52', - text: '#FFFFFF', - }, - banner: { - warning: '#b54b4b', - }, - walletAdd: { - title: '#141415', - subtitle: '#888893', - }, - }, - }, - shape: { - borderRadius: 0, - }, - typography: { - fontFamily, - h1: { - fontWeight: 500, - fontSize: '1.875rem', - fontFamily, - }, - h2: { - fontWeight: 500, - fontSize: '1.75rem', - fontFamily, - }, - h3: { - fontWeight: 500, - fontSize: '1.5rem', - fontFamily, - }, - h4: { - fontWeight: 500, - fontSize: '1.25rem', - fontFamily, - }, - h5: { - fontWeight: 500, - fontSize: '1.125rem', - fontFamily, - }, - h6: { - fontWeight: 500, - fontSize: '1rem', - fontFamily, - textTransform: 'uppercase', - }, - h7: { - fontWeight: 500, - fontSize: '0.875rem', - fontFamily, - textTransform: 'uppercase', - }, - body1: { - fontWeight: 400, - fontSize: '1rem', - fontFamily, - }, - body2: { - fontWeight: 400, - fontSize: '0.875rem', - fontFamily, - }, - body3: { - fontWeight: 400, - fontSize: '0.75rem', - fontFamily, - }, - }, -}; -export const classicTheme: Object = createTheme(deepmerge(commonTheme, theme)); diff --git a/packages/yoroi-extension/app/styles/themes/legacy/common-theme.js b/packages/yoroi-extension/app/styles/themes/legacy/common-theme.js deleted file mode 100644 index 599e563c58..0000000000 --- a/packages/yoroi-extension/app/styles/themes/legacy/common-theme.js +++ /dev/null @@ -1,61 +0,0 @@ -// @flow -import { createTheme } from '@mui/material/styles'; - -/* Common settings for colors, typography, shapes */ -export const commonTheme: Object = createTheme({ - palette: { - error: { - main: '#FF1351', - '50': '#FFF3F5', - '100': '#FF1351', - '200': '#CD0E41', - }, - warning: { - main: '#f6a823', - }, - cyan: { - '50': '#F2F9FF', - '100': '#59B1F4', - }, - gray: { - min: '#ffffff', - '50': '#F0F3F5', - '100': '#EAEDF2', - '200': '#DCE0E9', - '300': '#C4CAD7', - '400': '#A7AFC0', - '500': '#8A92A3', - '600': '#6B7384', - '700': '#4A5065', - '800': '#383E54', - '900': '#242838', - max: '#000000', - }, - background: { - overlay: '#060d23cc', // dialogs, - }, - txStatus: { - pending: { - background: '#F0F3F5', - text: '#ADAEB6', - stripes: 'rgba(217, 221, 224, 0.6)', - }, - high: { - background: '#c9ede5', - text: '#17cfa7', - }, - failed: { - background: '#ff145380', - text: '#e6003d', - }, - medium: { - background: '#f5a5244d', - text: '#f5a524', - }, - low: { - background: '#ff145326', - text: '#FA5F88', - }, - }, - }, -}); diff --git a/packages/yoroi-extension/app/styles/themes/legacy/modern-theme.js b/packages/yoroi-extension/app/styles/themes/legacy/modern-theme.js deleted file mode 100644 index 72992058c2..0000000000 --- a/packages/yoroi-extension/app/styles/themes/legacy/modern-theme.js +++ /dev/null @@ -1,141 +0,0 @@ -// @flow -import { createTheme } from '@mui/material/styles'; -import { RubikFonts, RobotoMonoFonts } from '../../fonts'; -import { - ModernButton, - ModernCheckbox, - ModernTextField, - ModernOutlinedInput, - ModernFormHelperText, - ModernFormControl, - ModernMenu, - ModernMenuItem, - ModernTabs, - ModernTabPanel, - ModernChip, - ModernTooltip, - ModernInputLabel, - ModernSelect, -} from '../../overrides/legacy'; -import { commonTheme } from './common-theme'; -import { deepmerge } from '@mui/utils'; - -const fontFamily = ['Rubik', 'sans-serif'].join(','); - -const theme = { - name: 'modern', - components: { - MuiCssBaseline: { - styleOverrides: ` - ${RubikFonts} - ${RobotoMonoFonts} - `, - }, - MuiButton: ModernButton, - MuiCheckbox: ModernCheckbox, - MuiTextField: ModernTextField, - MuiOutlinedInput: ModernOutlinedInput, - MuiFormHelperText: ModernFormHelperText, - MuiFormControl: ModernFormControl, - MuiSelect: ModernSelect, - MuiInputLabel: ModernInputLabel, - MuiMenu: ModernMenu, - MuiMenuItem: ModernMenuItem, - MuiTabs: ModernTabs, - MuiTabPanel: ModernTabPanel, - MuiChip: ModernChip, - MuiTooltip: ModernTooltip, - }, - palette: { - /* `main` is added since MUI required it but we don't use it at all */ - primary: { - main: '#3154CB', - '50': '#F0F2FB', - '100': '#164FD6', - '200': '#3154CB', - '300': '#1A44B7', - contrastText: '#FFF', - }, - secondary: { - main: '#16E3BA', - '50': '#F4FDFA', // ? - '100': '#C9ECE5', // light - '200': '#16E3BA', // main - hover btn color - - '300': '#17D1AA', // dark - contrastText: '#FFF', - }, - background: { - sidebar: { - start: '#1e46bd', - end: '#4760ff', - text: '#FFFFFF', - }, - banner: { - warning: '#f5a623', - }, - walletAdd: { - title: '#ffffff', - subtitle: '#ffffff', - }, - }, - }, - shape: { - borderRadius: 8, - }, - typography: { - fontFamily, - h1: { - fontWeight: 500, - fontSize: '1.875rem', - fontFamily, - }, - h2: { - fontWeight: 500, - fontSize: '1.75rem', - fontFamily, - }, - h3: { - fontWeight: 500, - fontSize: '1.5rem', - fontFamily, - }, - h4: { - fontWeight: 500, - fontSize: '1.25rem', - fontFamily, - }, - h5: { - fontWeight: 500, - fontSize: '1.125rem', - fontFamily, - }, - h6: { - fontWeight: 500, - fontSize: '1rem', - fontFamily, - textTransform: 'uppercase', - }, - h7: { - fontWeight: 500, - fontSize: '0.875rem', - fontFamily, - textTransform: 'uppercase', - }, - body1: { - fontWeight: 400, - fontSize: '1rem', - fontFamily, - }, - body2: { - fontWeight: 400, - fontSize: '0.875rem', - fontFamily, - }, - body3: { - fontWeight: 400, - fontSize: '0.75rem', - fontFamily, - }, - }, -}; -export const modernTheme: Object = createTheme(deepmerge(commonTheme, theme)); From 62c49ebb80a00bb3143bb069f42ac40ac89feace Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Mon, 14 Oct 2024 00:24:31 +0300 Subject: [PATCH 29/76] post-merge fixes --- packages/yoroi-extension/app/containers/SidebarContainer.js | 2 +- .../containers/settings/categories/BlockchainSettingsPage.js | 3 ++- .../app/stores/ada/AdaDelegationTransactionStore.js | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/yoroi-extension/app/containers/SidebarContainer.js b/packages/yoroi-extension/app/containers/SidebarContainer.js index 541f8683d8..e9f99a9945 100644 --- a/packages/yoroi-extension/app/containers/SidebarContainer.js +++ b/packages/yoroi-extension/app/containers/SidebarContainer.js @@ -51,7 +51,7 @@ export default class SidebarContainer extends Component { diff --git a/packages/yoroi-extension/app/containers/settings/categories/BlockchainSettingsPage.js b/packages/yoroi-extension/app/containers/settings/categories/BlockchainSettingsPage.js index 24786d268d..268b977480 100644 --- a/packages/yoroi-extension/app/containers/settings/categories/BlockchainSettingsPage.js +++ b/packages/yoroi-extension/app/containers/settings/categories/BlockchainSettingsPage.js @@ -20,7 +20,8 @@ export default class BlockchainSettingsPage extends Component; diff --git a/packages/yoroi-extension/app/stores/ada/AdaDelegationTransactionStore.js b/packages/yoroi-extension/app/stores/ada/AdaDelegationTransactionStore.js index 4fa743ad2d..a14d39dcdd 100644 --- a/packages/yoroi-extension/app/stores/ada/AdaDelegationTransactionStore.js +++ b/packages/yoroi-extension/app/stores/ada/AdaDelegationTransactionStore.js @@ -189,7 +189,7 @@ export default class AdaDelegationTransactionStore extends Store Date: Mon, 14 Oct 2024 00:45:30 +0300 Subject: [PATCH 30/76] removed wallet actions --- packages/yoroi-extension/app/actions/index.js | 3 -- .../app/actions/wallet-actions.js | 20 ---------- .../wallet/restore/RestoreWalletPage.js | 4 +- .../app/connector/stores/index.js | 2 +- .../containers/transfer/TransferSendPage.js | 2 +- .../app/containers/wallet/MyWalletsPage.js | 2 +- .../app/containers/wallet/WalletSendPage.js | 38 +++++++++---------- .../dialogs/WalletRestoreDialogContainer.js | 2 +- .../WalletSendConfirmationDialogContainer.js | 15 +++----- .../wallet/staking/WithdrawRewardsDialog.js | 2 +- .../app/stores/ada/LedgerConnectStore.js | 2 +- .../app/stores/ada/TrezorConnectStore.js | 2 +- .../app/stores/ada/VotingStore.js | 9 ++--- .../stores/ada/send/AdaMnemonicSendStore.js | 10 +---- packages/yoroi-extension/app/stores/index.js | 2 +- .../app/stores/toplevel/AppStore.js | 15 ++++---- .../app/stores/toplevel/TokenInfoStore.js | 6 +-- .../stores/toplevel/WalletSettingsStore.js | 7 ++-- .../app/stores/toplevel/WalletStore.js | 16 ++++---- 19 files changed, 62 insertions(+), 97 deletions(-) delete mode 100644 packages/yoroi-extension/app/actions/wallet-actions.js diff --git a/packages/yoroi-extension/app/actions/index.js b/packages/yoroi-extension/app/actions/index.js index 3a519c6367..e8b707426b 100644 --- a/packages/yoroi-extension/app/actions/index.js +++ b/packages/yoroi-extension/app/actions/index.js @@ -4,7 +4,6 @@ import ProfileActions from './profile-actions'; import DialogsActions from './dialogs-actions'; import NotificationsActions from './notifications-actions'; import MemosActions from './memos-actions'; -import WalletActions from './wallet-actions'; import WalletRestoreActions from './common/wallet-restore-actions'; import YoroiTransferActions from './common/yoroi-transfer-actions'; import TxBuilderActions from './common/tx-builder-actions'; @@ -20,7 +19,6 @@ export type ActionsMap = {| notifications: NotificationsActions, yoroiTransfer: YoroiTransferActions, memos: MemosActions, - wallets: WalletActions, walletRestore: WalletRestoreActions, connector: ConnectorActionsMap, |}; @@ -34,7 +32,6 @@ const actionsMap: ActionsMap = Object.freeze({ notifications: new NotificationsActions(), yoroiTransfer: new YoroiTransferActions(), memos: new MemosActions(), - wallets: new WalletActions(), walletRestore: new WalletRestoreActions(), connector: new ConnectorActionsMap(), }); diff --git a/packages/yoroi-extension/app/actions/wallet-actions.js b/packages/yoroi-extension/app/actions/wallet-actions.js deleted file mode 100644 index a0cf88032c..0000000000 --- a/packages/yoroi-extension/app/actions/wallet-actions.js +++ /dev/null @@ -1,20 +0,0 @@ -// @flow -import { AsyncAction, Action } from './lib/Action'; -import type { ISignRequest } from '../api/common/lib/transactions/ISignRequest'; - -// ======= WALLET ACTIONS ======= - -export default class WalletsActions { - unselectWallet: Action = new Action(); - setActiveWallet: Action<{| publicDeriverId: number |}> = new Action(); - sendMoney: AsyncAction<{| - signRequest: ISignRequest, - password: string, - +wallet: { - publicDeriverId: number, - +plate: { TextPart: string, ... }, - ... - }, - onSuccess?: void => void, - |}> = 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 fdf74f57ea..5c4eb4fe10 100644 --- a/packages/yoroi-extension/app/components/wallet/restore/RestoreWalletPage.js +++ b/packages/yoroi-extension/app/components/wallet/restore/RestoreWalletPage.js @@ -63,7 +63,7 @@ type Props = {| function RestoreWalletPage(props: Props & Intl): Node { const { intl, stores, actions, restoreWallet, isDialogOpen, openDialog, closeDialog } = props; - const { profile, wallets: walletsActions } = actions; + const { profile } = actions; const { walletRestore, profile: profileData, @@ -179,7 +179,7 @@ function RestoreWalletPage(props: Props & Intl): Node { }} openDuplicatedWallet={lastDuplicatedWalletId => { resetRestoreWalletData(); - walletsActions.setActiveWallet.trigger({ publicDeriverId: lastDuplicatedWalletId }); + wallets.setActiveWallet({ publicDeriverId: lastDuplicatedWalletId }); handleGoToRoute({ route: ROUTES.WALLETS.TRANSACTIONS }); }} onSubmit={async enteredRecoveryPhrase => { diff --git a/packages/yoroi-extension/app/connector/stores/index.js b/packages/yoroi-extension/app/connector/stores/index.js index c3b20eeedd..bb20e57795 100644 --- a/packages/yoroi-extension/app/connector/stores/index.js +++ b/packages/yoroi-extension/app/connector/stores/index.js @@ -36,7 +36,7 @@ export type StoresMap = {| coinPriceStore: ConnectorCoinPriceStore, loading: ConnectorLoadingStore, connector: ConnectorStore, - tokenInfoStore: TokenInfoStore, + tokenInfoStore: TokenInfoStore, substores: {| ada: AdaStoresMap, |}, diff --git a/packages/yoroi-extension/app/containers/transfer/TransferSendPage.js b/packages/yoroi-extension/app/containers/transfer/TransferSendPage.js index ba0351fb6d..1c58d26236 100644 --- a/packages/yoroi-extension/app/containers/transfer/TransferSendPage.js +++ b/packages/yoroi-extension/app/containers/transfer/TransferSendPage.js @@ -101,7 +101,7 @@ export default class TransferSendPage extends Component<{| ...StoresAndActionsPr this.spendingPasswordForm.submit({ onSuccess: async (form) => { const { walletPassword } = form.values(); - await this.props.actions.wallets.sendMoney.trigger({ + await stores.substores.ada.mnemonicSend.sendMoney({ signRequest, password: walletPassword, wallet: selected, diff --git a/packages/yoroi-extension/app/containers/wallet/MyWalletsPage.js b/packages/yoroi-extension/app/containers/wallet/MyWalletsPage.js index 687c170e58..a6d4b5ea78 100644 --- a/packages/yoroi-extension/app/containers/wallet/MyWalletsPage.js +++ b/packages/yoroi-extension/app/containers/wallet/MyWalletsPage.js @@ -53,7 +53,7 @@ export default class MyWalletsPage extends Component { }; openToSettings: (number) => void = publicDeriverId => { - this.props.actions.wallets.setActiveWallet.trigger({ + this.props.stores.wallets.setActiveWallet({ publicDeriverId }); this.props.stores.app.goToRoute({ diff --git a/packages/yoroi-extension/app/containers/wallet/WalletSendPage.js b/packages/yoroi-extension/app/containers/wallet/WalletSendPage.js index 74b69d4f3a..775f075c8e 100644 --- a/packages/yoroi-extension/app/containers/wallet/WalletSendPage.js +++ b/packages/yoroi-extension/app/containers/wallet/WalletSendPage.js @@ -122,21 +122,21 @@ export default class WalletSendPage extends Component { } render(): Node { - const { selected } = this.props.stores.wallets; + const { actions, stores } = this.props; + const { selected } = stores.wallets; if (!selected) throw new Error(`Active wallet required for ${nameof(WalletSendPage)}.`); const { uiDialogs, transactionBuilderStore, protocolParameters, - } = this.props.stores; + } = stores; if (!protocolParameters.loadProtocolParametersRequest.wasExecuted) { return null; } - const { actions } = this.props; - const { hasAnyPending } = this.props.stores.transactions; + const { hasAnyPending } = stores.transactions; const { txBuilderActions } = this.props.actions; // disallow sending when pending tx exists @@ -148,12 +148,12 @@ export default class WalletSendPage extends Component { actions.dialogs.closeActiveDialog.trigger(); } - const defaultToken = this.props.stores.tokenInfoStore.getDefaultTokenInfo( + const defaultToken = stores.tokenInfoStore.getDefaultTokenInfo( selected.networkId ); const network = getNetworkById(selected.networkId); - const addressStore = this.props.stores.substores.ada.addresses; + const addressStore = stores.substores.ada.addresses; const resolveDomainAddressFunc = addressStore.domainResolverSupported() ? addressStore.resolveDomainAddress.bind(addressStore) : null; @@ -167,10 +167,10 @@ export default class WalletSendPage extends Component { }} selectedNetwork={network} selectedWallet={selected} - selectedExplorer={this.props.stores.explorers.selectedExplorer} + selectedExplorer={stores.explorers.selectedExplorer} selectedToken={transactionBuilderStore.selectedToken} defaultToken={defaultToken} - getTokenInfo={genLookupOrFail(this.props.stores.tokenInfoStore.tokenInfo)} + getTokenInfo={genLookupOrFail(stores.tokenInfoStore.tokenInfo)} onSubmit={txBuilderActions.updateTentativeTx.trigger} totalInput={transactionBuilderStore.totalInput} hasAnyPending={hasAnyPending} @@ -184,8 +184,8 @@ export default class WalletSendPage extends Component { error={transactionBuilderStore.createUnsignedTx.error} // Min ADA for all tokens that is already included in the tx minAda={transactionBuilderStore.minAda} - uriParams={this.props.stores.loading.uriParams} - resetUriParams={this.props.stores.loading.resetUriParams} + uriParams={stores.loading.uriParams} + resetUriParams={stores.loading.resetUriParams} memo={transactionBuilderStore.memo} showMemo={this.showMemo} updateMemo={(content: void | string) => txBuilderActions.updateMemo.trigger(content)} @@ -194,7 +194,7 @@ export default class WalletSendPage extends Component { dialog: MemoNoExternalStorageDialog, continuation: this.toggleShowMemo, })} - spendableBalance={this.props.stores.transactions.balance} + spendableBalance={stores.transactions.balance} onAddToken={txBuilderActions.addToken.trigger} onRemoveTokens={txBuilderActions.removeTokens.trigger} plannedTxInfoMap={transactionBuilderStore.plannedTxInfoMap} @@ -203,18 +203,18 @@ export default class WalletSendPage extends Component { closeDialog={this.props.actions.dialogs.closeActiveDialog.trigger} isOpen={uiDialogs.isOpen} openTransactionSuccessDialog={this.openTransactionSuccessDialog.bind(this)} - unitOfAccountSetting={this.props.stores.profile.unitOfAccount} - getCurrentPrice={this.props.stores.coinPriceStore.getCurrentPrice} + unitOfAccountSetting={stores.profile.unitOfAccount} + getCurrentPrice={stores.coinPriceStore.getCurrentPrice} calculateMaxAmount={txBuilderActions.calculateMaxAmount.trigger} maxSendableAmount={transactionBuilderStore.maxSendableAmount} signRequest={transactionBuilderStore.tentativeTx} staleTx={transactionBuilderStore.txMismatch} - sendMoneyRequest={this.props.stores.wallets.sendMoneyRequest} - 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.stores.substores.ada.ledgerSend} - trezorSend={this.props.stores.substores.ada.trezorSend} + sendMoneyRequest={stores.wallets.sendMoneyRequest} + sendMoney={stores.substores.ada.mnemonicSend.sendMoney} + ledgerSendError={stores.substores.ada.ledgerSend.error || null} + trezorSendError={stores.substores.ada.trezorSend.error || null} + ledgerSend={stores.substores.ada.ledgerSend} + trezorSend={stores.substores.ada.trezorSend} /> {this.renderDialog()} diff --git a/packages/yoroi-extension/app/containers/wallet/dialogs/WalletRestoreDialogContainer.js b/packages/yoroi-extension/app/containers/wallet/dialogs/WalletRestoreDialogContainer.js index e38fbd10a1..fe94825f5c 100644 --- a/packages/yoroi-extension/app/containers/wallet/dialogs/WalletRestoreDialogContainer.js +++ b/packages/yoroi-extension/app/containers/wallet/dialogs/WalletRestoreDialogContainer.js @@ -82,7 +82,7 @@ export default class WalletRestoreDialogContainer extends Component<{| ...Stores }; openToTransactions: (number) => void = publicDeriverId => { - this.props.actions.wallets.setActiveWallet.trigger({ + this.props.stores.wallets.setActiveWallet({ publicDeriverId, }); this.props.stores.app.goToRoute({ diff --git a/packages/yoroi-extension/app/containers/wallet/dialogs/WalletSendConfirmationDialogContainer.js b/packages/yoroi-extension/app/containers/wallet/dialogs/WalletSendConfirmationDialogContainer.js index 7ebe970c11..e4d85b14b5 100644 --- a/packages/yoroi-extension/app/containers/wallet/dialogs/WalletSendConfirmationDialogContainer.js +++ b/packages/yoroi-extension/app/containers/wallet/dialogs/WalletSendConfirmationDialogContainer.js @@ -14,17 +14,15 @@ import { getNetworkById } from '../../../api/ada/lib/storage/database/prepackage const MAX_VALUE_BYTES = 5000; const MAX_TX_BYTES = 16384; -type DialogProps = {| +type LocalProps = {| +signRequest: ISignRequest, +staleTx: boolean, +unitOfAccountSetting: UnitOfAccountSettingType, -|}; -type Props = {| - ...StoresAndActionsProps, - ...DialogProps, +openTransactionSuccessDialog: () => void, |}; +type Props = {| ...StoresAndActionsProps, ...LocalProps |}; + @observer export default class WalletSendConfirmationDialogContainer extends Component { @@ -44,7 +42,6 @@ export default class WalletSendConfirmationDialogContainer extends Component { throw new Error('No explorer for wallet network'); })() } - getTokenInfo={genLookupOrFail(this.props.stores.tokenInfoStore.tokenInfo)} - getCurrentPrice={this.props.stores.coinPriceStore.getCurrentPrice} + getTokenInfo={genLookupOrFail(stores.tokenInfoStore.tokenInfo)} + getCurrentPrice={stores.coinPriceStore.getCurrentPrice} amount={totalInput.joinSubtractCopy(fee)} receivers={receivers} totalAmount={totalInput} transactionFee={fee} transactionSize={showSize ? `${fullSize}/${MAX_TX_BYTES} (Biggest output: ${maxOutput}/${MAX_VALUE_BYTES})` : null} onSubmit={async ({ password }) => { - await sendMoney.trigger({ + await stores.substores.ada.mnemonicSend.sendMoney({ signRequest, password, wallet: publicDeriver, diff --git a/packages/yoroi-extension/app/containers/wallet/staking/WithdrawRewardsDialog.js b/packages/yoroi-extension/app/containers/wallet/staking/WithdrawRewardsDialog.js index c6c6f5e6c5..b4f36c36d9 100644 --- a/packages/yoroi-extension/app/containers/wallet/staking/WithdrawRewardsDialog.js +++ b/packages/yoroi-extension/app/containers/wallet/staking/WithdrawRewardsDialog.js @@ -102,7 +102,7 @@ export default class WithdrawRewardsDialog extends Component<{| ...StoresAndActi this.spendingPasswordForm.submit({ onSuccess: async form => { const { walletPassword } = form.values(); - await this.props.actions.wallets.sendMoney.trigger({ + await stores.substores.ada.mnemonicSend.sendMoney({ signRequest, password: walletPassword, wallet: selected, diff --git a/packages/yoroi-extension/app/stores/ada/LedgerConnectStore.js b/packages/yoroi-extension/app/stores/ada/LedgerConnectStore.js index 7b9f3e79d4..75164880ff 100644 --- a/packages/yoroi-extension/app/stores/ada/LedgerConnectStore.js +++ b/packages/yoroi-extension/app/stores/ada/LedgerConnectStore.js @@ -399,7 +399,7 @@ export default class LedgerConnectStore } await stores.wallets.addHwWallet(wallet); - this.actions.wallets.setActiveWallet.trigger({ publicDeriverId: wallet.publicDeriverId }); + stores.wallets.setActiveWallet({ publicDeriverId: wallet.publicDeriverId }); if (stores.substores.ada.yoroiTransfer.transferRequest.result == null) { stores.app.goToRoute({ 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 2641ecb4fb..e97b3ff2ac 100644 --- a/packages/yoroi-extension/app/stores/ada/TrezorConnectStore.js +++ b/packages/yoroi-extension/app/stores/ada/TrezorConnectStore.js @@ -354,7 +354,7 @@ export default class TrezorConnectStore const { stores } = this; await stores.wallets.addHwWallet(wallet); - this.actions.wallets.setActiveWallet.trigger({ publicDeriverId: wallet.publicDeriverId }); + stores.wallets.setActiveWallet({ publicDeriverId: wallet.publicDeriverId }); stores.app.goToRoute({ route: ROUTES.WALLETS.ROOT }); // show success notification diff --git a/packages/yoroi-extension/app/stores/ada/VotingStore.js b/packages/yoroi-extension/app/stores/ada/VotingStore.js index 95487a502d..e669e3d3b8 100644 --- a/packages/yoroi-extension/app/stores/ada/VotingStore.js +++ b/packages/yoroi-extension/app/stores/ada/VotingStore.js @@ -83,23 +83,22 @@ export default class VotingStore extends Store { setup(): void { super.setup(); this.reset({ justTransaction: false }); - this.actions.wallets.setActiveWallet.listen(() => {noop(this._updateCatalystRoundInfo())}); - noop(this._loadCatalystRoundInfo()); - noop(this._updateCatalystRoundInfo()); + noop(this.loadCatalystRoundInfo()); + noop(this.updateCatalystRoundInfo()); } get isActionProcessing(): boolean { return this.progressInfo.stepState === StepState.PROCESS; } - _loadCatalystRoundInfo: void => Promise = async () => { + loadCatalystRoundInfo: void => Promise = async () => { const data = await loadCatalystRoundInfo(); runInAction(() => { this.catalystRoundInfo = data; }); } - @action _updateCatalystRoundInfo: void => Promise = async () => { + @action updateCatalystRoundInfo: void => Promise = async () => { runInAction(() => { this.loadingCatalystRoundInfo = true }) diff --git a/packages/yoroi-extension/app/stores/ada/send/AdaMnemonicSendStore.js b/packages/yoroi-extension/app/stores/ada/send/AdaMnemonicSendStore.js index 75c8573cc1..595817ded6 100644 --- a/packages/yoroi-extension/app/stores/ada/send/AdaMnemonicSendStore.js +++ b/packages/yoroi-extension/app/stores/ada/send/AdaMnemonicSendStore.js @@ -14,14 +14,8 @@ import { signAndBroadcastTransaction } from '../../../api/thunk'; export default class AdaMnemonicSendStore extends Store { - setup(): void { - super.setup(); - const { wallets, } = this.actions; - wallets.sendMoney.listen(this._sendMoney); - } - /** Send money and then return to transaction screen */ - _sendMoney: {| + sendMoney: {| signRequest: ISignRequest, password: string, +wallet: { @@ -32,7 +26,7 @@ export default class AdaMnemonicSendStore extends Store { onSuccess?: void => void, |} => Promise = async (request) => { if (!(request.signRequest instanceof HaskellShelleyTxSignRequest)) { - throw new Error(`${nameof(this._sendMoney)} wrong tx sign request`); + throw new Error(`${nameof(this.sendMoney)} wrong tx sign request`); } const { stores } = this; diff --git a/packages/yoroi-extension/app/stores/index.js b/packages/yoroi-extension/app/stores/index.js index 7dad1c5bcc..3061016ff6 100644 --- a/packages/yoroi-extension/app/stores/index.js +++ b/packages/yoroi-extension/app/stores/index.js @@ -58,7 +58,7 @@ const storeClasses = Object.freeze({ export type StoresMap = {| stateFetchStore: StateFetchStore, coinPriceStore: CoinPriceStore, - tokenInfoStore: TokenInfoStore, + tokenInfoStore: TokenInfoStore, profile: ProfileStore, serverConnectionStore: ServerConnectionStore, app: AppStore, diff --git a/packages/yoroi-extension/app/stores/toplevel/AppStore.js b/packages/yoroi-extension/app/stores/toplevel/AppStore.js index 8173e89f34..06f970fc8d 100644 --- a/packages/yoroi-extension/app/stores/toplevel/AppStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/AppStore.js @@ -30,25 +30,26 @@ export default class AppStore extends Store { options ) => { const routePath = buildRoute(options.route, options.params); - const currentRoute = this.stores.router.location.pathname; + const { stores } = this; + const currentRoute = stores.router.location.pathname; if ( options.publicDeriverId !== undefined && - options.publicDeriverId !== this.stores.wallets.selected?.publicDeriverId + options.publicDeriverId !== stores.wallets.selected?.publicDeriverId ) { if (options.publicDeriverId == null) { - this.actions.wallets.unselectWallet.trigger(); + stores.wallets.unsetActiveWallet(); } else { - this.actions.wallets.setActiveWallet.trigger({ publicDeriverId: options.publicDeriverId }); + stores.wallets.setActiveWallet({ publicDeriverId: options.publicDeriverId }); } // we can't clear the browser history programmatically (requires root privilege) // so instead, we route the user to a page that blocks the back button - this.stores.router.push({ pathname: ROUTES.SWITCH }); + stores.router.push({ pathname: ROUTES.SWITCH }); // we need the timeout otherwise mobx will optimize out the fake path setTimeout(() => { - this.stores.router.push({ pathname: routePath }); + stores.router.push({ pathname: routePath }); }); } else if (currentRoute !== routePath) { - this.stores.router.push(routePath); + stores.router.push(routePath); } }; } diff --git a/packages/yoroi-extension/app/stores/toplevel/TokenInfoStore.js b/packages/yoroi-extension/app/stores/toplevel/TokenInfoStore.js index c95907e27c..0cb0217002 100644 --- a/packages/yoroi-extension/app/stores/toplevel/TokenInfoStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/TokenInfoStore.js @@ -11,7 +11,6 @@ import { defaultAssets } from '../../api/ada/lib/storage/database/prepackaged/ne import type { DefaultTokenEntry, } from '../../api/common/lib/MultiToken'; -import type WalletsActions from '../../actions/wallet-actions'; import type TransactionsStore from './TransactionsStore'; import type { IFetcher as IFetcherCardano } from '../../api/ada/lib/state-fetch/IFetcher.types'; import { getCardanoAssets } from '../../api/thunk'; @@ -40,9 +39,8 @@ export default class TokenInfoStore< ... }, ... - }, - ActionsMapType: { +wallets?: WalletsActions, ... }, -> extends Store { + } +> extends Store { @observable tokenInfo: TokenInfoMap; setup(): void { diff --git a/packages/yoroi-extension/app/stores/toplevel/WalletSettingsStore.js b/packages/yoroi-extension/app/stores/toplevel/WalletSettingsStore.js index 024aae0bfa..82af97df5b 100644 --- a/packages/yoroi-extension/app/stores/toplevel/WalletSettingsStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/WalletSettingsStore.js @@ -133,10 +133,11 @@ export default class WalletSettingsStore extends Store { publicDeriverId: number, |} => Promise = async (request) => { this.removeWalletRequest.reset(); - this.actions.wallets.unselectWallet.trigger(); // deselect before deleting + const { stores } = this; + stores.wallets.unsetActiveWallet(); // deselect before deleting // Remove this wallet from wallet sort list - const walletsNavigation = this.stores.profile.walletsNavigation + const walletsNavigation = stores.profile.walletsNavigation const newWalletsNavigation = { ...walletsNavigation, // $FlowFixMe[invalid-computed-prop] @@ -147,7 +148,7 @@ export default class WalletSettingsStore extends Store { // ==================== Disconnect related dApps ==================== await this.actions.connector.getConnectorWhitelist.trigger(); - const connectorWhitelist = this.stores.connector.currentConnectorWhitelist; + const connectorWhitelist = stores.connector.currentConnectorWhitelist; const connectedDapps = connectorWhitelist.filter( dapp => dapp.publicDeriverId === request.publicDeriverId ); diff --git a/packages/yoroi-extension/app/stores/toplevel/WalletStore.js b/packages/yoroi-extension/app/stores/toplevel/WalletStore.js index 0683063451..96d52b2dbd 100644 --- a/packages/yoroi-extension/app/stores/toplevel/WalletStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/WalletStore.js @@ -20,7 +20,7 @@ import { getWallets, subscribe, listenForWalletStateUpdate } from '../../api/thu import { FlagsApi } from '@emurgo/yoroi-lib/dist/flags'; import type { StorageAPI } from '@emurgo/yoroi-lib/dist/flags'; import { createFlagStorage, loadSubmittedTransactions } from '../../api/localStorage'; -import { forceNonNull, timeCached } from '../../coreUtils'; +import { forceNonNull, noop, timeCached } from '../../coreUtils'; import type { BestBlockResponse } from '../../api/ada/lib/state-fetch/types'; import TimeUtils from '../../api/ada/lib/storage/bridge/timeUtils'; import type { CardanoAddressedUtxo } from '../../api/ada/transactions/types'; @@ -79,10 +79,6 @@ export default class WalletStore extends Store { setup(): void { super.setup(); - const { wallets } = this.actions; - wallets.unselectWallet.listen(this._unsetActiveWallet); - wallets.setActiveWallet.listen(this._setActiveWallet); - this.flagStorage = createFlagStorage(); listenForWalletStateUpdate(async (params) => { @@ -182,7 +178,7 @@ export default class WalletStore extends Store { runInAction(() => { this.wallets.push(newWallet); - this._setActiveWallet({ + this.setActiveWallet({ publicDeriverId: newWallet.publicDeriverId, }); this.actions.dialogs.closeActiveDialog.trigger(); @@ -278,7 +274,7 @@ export default class WalletStore extends Store { // =================== ACTIVE WALLET ==================== // - @action _setActiveWallet: ({| publicDeriverId: number |}) => void = ({ publicDeriverId }) => { + @action setActiveWallet: ({| publicDeriverId: number |}) => void = ({ publicDeriverId }) => { const walletIndex = this.wallets.findIndex(wallet => wallet.publicDeriverId === publicDeriverId); if (walletIndex === -1) { throw new Error('unexpected missing wallet id'); @@ -290,7 +286,9 @@ export default class WalletStore extends Store { this.selectedWalletName = this.wallets[walletIndex].name; // Cache select wallet this.api.localStorage.setSelectedWalletId(publicDeriverId); - subscribe(publicDeriverId); + noop(subscribe(publicDeriverId)); + // Catalyst update // todo: maybe check if network changed + noop(this.stores.substores.ada.votingStore.updateCatalystRoundInfo()); }; getLastSelectedWallet: void => ?WalletState = () => { @@ -298,7 +296,7 @@ export default class WalletStore extends Store { return this.wallets.find(wallet => wallet.publicDeriverId === walletId); }; - @action _unsetActiveWallet: void => void = () => { + @action unsetActiveWallet: void => void = () => { this.actions.profile.setSelectedNetwork.trigger(undefined); this.selectedIndex = null; this.selectedWalletName = null; From c2de6412da2329776a7c2dc01643cb6d48febee9 Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Mon, 14 Oct 2024 01:00:22 +0300 Subject: [PATCH 31/76] removed profile actions --- packages/yoroi-extension/app/actions/index.js | 3 --- .../app/actions/profile-actions.js | 13 ------------- .../wallet/restore/RestoreWalletPage.js | 7 +++---- .../app/containers/NavBarContainerRevamp.js | 2 +- .../app/containers/SidebarContainer.js | 2 +- .../containers/profile/LanguageSelectionPage.js | 5 +++-- .../app/containers/profile/TermsOfUsePage.js | 13 +++++++------ .../app/containers/profile/UriPromptPage.js | 5 +++-- .../categories/RemoveWalletDialogContainer.js | 5 +++-- .../app/containers/wallet/AddWalletPage.js | 10 +++++----- .../wallet/CreateWalletPageContainer.js | 2 +- .../app/stores/base/BaseProfileStore.js | 2 +- .../app/stores/toplevel/ProfileStore.js | 15 +++++---------- .../app/stores/toplevel/WalletSettingsStore.js | 2 +- .../app/stores/toplevel/WalletStore.js | 4 ++-- 15 files changed, 36 insertions(+), 54 deletions(-) delete mode 100644 packages/yoroi-extension/app/actions/profile-actions.js diff --git a/packages/yoroi-extension/app/actions/index.js b/packages/yoroi-extension/app/actions/index.js index e8b707426b..af1f32e379 100644 --- a/packages/yoroi-extension/app/actions/index.js +++ b/packages/yoroi-extension/app/actions/index.js @@ -1,6 +1,5 @@ // @flow import WalletBackupActions from './wallet-backup-actions'; -import ProfileActions from './profile-actions'; import DialogsActions from './dialogs-actions'; import NotificationsActions from './notifications-actions'; import MemosActions from './memos-actions'; @@ -14,7 +13,6 @@ export type ActionsMap = {| txBuilderActions: TxBuilderActions, walletSettings: WalletSettingsActions, walletBackup: WalletBackupActions, - profile: ProfileActions, dialogs: DialogsActions, notifications: NotificationsActions, yoroiTransfer: YoroiTransferActions, @@ -27,7 +25,6 @@ const actionsMap: ActionsMap = Object.freeze({ txBuilderActions: new TxBuilderActions(), walletSettings: new WalletSettingsActions(), walletBackup: new WalletBackupActions(), - profile: new ProfileActions(), dialogs: new DialogsActions(), notifications: new NotificationsActions(), yoroiTransfer: new YoroiTransferActions(), diff --git a/packages/yoroi-extension/app/actions/profile-actions.js b/packages/yoroi-extension/app/actions/profile-actions.js deleted file mode 100644 index 625e7c4964..0000000000 --- a/packages/yoroi-extension/app/actions/profile-actions.js +++ /dev/null @@ -1,13 +0,0 @@ -// @flow -import { AsyncAction, Action } from './lib/Action'; -import type { NetworkRow } from '../api/ada/lib/storage/database/primitives/tables'; -import type { WalletsNavigation } from '../api/localStorage'; -// ======= PROFILE ACTIONS ======= - -export default class ProfileActions { - acceptTermsOfUse: AsyncAction = new AsyncAction(); - acceptUriScheme: AsyncAction = new AsyncAction(); - toggleSidebar: AsyncAction = new AsyncAction(); - updateSortedWalletList: AsyncAction = new AsyncAction(); - setSelectedNetwork: Action> = new Action(); -} diff --git a/packages/yoroi-extension/app/components/wallet/restore/RestoreWalletPage.js b/packages/yoroi-extension/app/components/wallet/restore/RestoreWalletPage.js index 5c4eb4fe10..5dbe188509 100644 --- a/packages/yoroi-extension/app/components/wallet/restore/RestoreWalletPage.js +++ b/packages/yoroi-extension/app/components/wallet/restore/RestoreWalletPage.js @@ -62,8 +62,7 @@ type Props = {| |}; function RestoreWalletPage(props: Props & Intl): Node { - const { intl, stores, actions, restoreWallet, isDialogOpen, openDialog, closeDialog } = props; - const { profile } = actions; + const { intl, stores, restoreWallet, isDialogOpen, openDialog, closeDialog } = props; const { walletRestore, profile: profileData, @@ -117,7 +116,7 @@ function RestoreWalletPage(props: Props & Intl): Node { component: ( { - profile.setSelectedNetwork.trigger(network); + stores.profile.setSelectedNetwork(network); setCurrentStep(RESTORE_WALLET_STEPS.SELECT_WALLET_TYPE); ampli.restoreWalletTypeStepViewed(); }} @@ -133,7 +132,7 @@ function RestoreWalletPage(props: Props & Intl): Node { onNext={mode => { resetRestoreWalletData(); if (!environment.isDev() && !environment.isNightly()) - profile.setSelectedNetwork.trigger(networks.CardanoMainnet); + stores.profile.setSelectedNetwork(networks.CardanoMainnet); runInAction(() => { setSelectedRestoreMode(mode); setCurrentStep(RESTORE_WALLET_STEPS.ENTER_RECOVERY_PHRASE); diff --git a/packages/yoroi-extension/app/containers/NavBarContainerRevamp.js b/packages/yoroi-extension/app/containers/NavBarContainerRevamp.js index 5254820a8f..1821ba9155 100644 --- a/packages/yoroi-extension/app/containers/NavBarContainerRevamp.js +++ b/packages/yoroi-extension/app/containers/NavBarContainerRevamp.js @@ -157,7 +157,7 @@ export default class NavBarContainerRevamp extends Component<{| ...StoresAndActi this.props.actions.dialogs.closeActiveDialog.trigger(); stores.app.goToRoute({ route: ROUTES.WALLETS.ADD }); }} - updateSortedWalletList={this.props.actions.profile.updateSortedWalletList.trigger} + updateSortedWalletList={stores.profile.updateSortedWalletList} walletsNavigation={stores.profile.walletsNavigation} unitOfAccountSetting={stores.profile.unitOfAccount} getCurrentPrice={stores.coinPriceStore.getCurrentPrice} diff --git a/packages/yoroi-extension/app/containers/SidebarContainer.js b/packages/yoroi-extension/app/containers/SidebarContainer.js index e9f99a9945..a19fe6497c 100644 --- a/packages/yoroi-extension/app/containers/SidebarContainer.js +++ b/packages/yoroi-extension/app/containers/SidebarContainer.js @@ -21,7 +21,7 @@ export default class SidebarContainer extends Component Promise = async () => { - await this.props.actions.profile.toggleSidebar.trigger(); + await this.props.stores.profile.toggleSidebar(); }; componentDidMount(): * { diff --git a/packages/yoroi-extension/app/containers/profile/LanguageSelectionPage.js b/packages/yoroi-extension/app/containers/profile/LanguageSelectionPage.js index 632776fa34..9955369211 100644 --- a/packages/yoroi-extension/app/containers/profile/LanguageSelectionPage.js +++ b/packages/yoroi-extension/app/containers/profile/LanguageSelectionPage.js @@ -39,8 +39,9 @@ export default class LanguageSelectionPage extends Component 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.stores.profile.acceptLocale(); + const { stores } = this.props; + await stores.profile.acceptTermsOfUse(); + await stores.profile.acceptLocale(); }; renderByron(props: StoresAndActionsProps): Node { diff --git a/packages/yoroi-extension/app/containers/profile/TermsOfUsePage.js b/packages/yoroi-extension/app/containers/profile/TermsOfUsePage.js index 251fe89ef8..28bce90da4 100644 --- a/packages/yoroi-extension/app/containers/profile/TermsOfUsePage.js +++ b/packages/yoroi-extension/app/containers/profile/TermsOfUsePage.js @@ -20,9 +20,10 @@ export default class TermsOfUsePage extends Component { }; render(): Node { - const { checkAdaServerStatus } = this.props.stores.serverConnectionStore; - const { selected } = this.props.stores.wallets; - const isWalletTestnet = Boolean(selected && selected.isTestnet); + const { stores } = this.props; + const { checkAdaServerStatus } = stores.serverConnectionStore; + const { selected } = stores.wallets; + const isWalletTestnet = Boolean(selected?.isTestnet); const displayedBanner = checkAdaServerStatus === ServerStatusErrors.Healthy ? @@ -37,9 +38,9 @@ export default class TermsOfUsePage extends Component { /> diff --git a/packages/yoroi-extension/app/containers/profile/UriPromptPage.js b/packages/yoroi-extension/app/containers/profile/UriPromptPage.js index 7e68d40a16..950f614d8a 100644 --- a/packages/yoroi-extension/app/containers/profile/UriPromptPage.js +++ b/packages/yoroi-extension/app/containers/profile/UriPromptPage.js @@ -18,6 +18,7 @@ import { ServerStatusErrors } from '../../types/serverStatusErrorType'; import registerProtocols from '../../uri-protocols'; import globalMessages from '../../i18n/global-messages'; import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; +import { noop } from '../../coreUtils'; @observer export default class UriPromptPage extends Component { @@ -37,7 +38,7 @@ export default class UriPromptPage extends Component { }; onSkip: void => void = () => { - this.props.actions.profile.acceptUriScheme.trigger() + noop(this.props.stores.profile.acceptUriScheme()); }; onBack: void => void = () => { @@ -56,7 +57,7 @@ export default class UriPromptPage extends Component { if (this.isAccepted) { return ; } diff --git a/packages/yoroi-extension/app/containers/settings/categories/RemoveWalletDialogContainer.js b/packages/yoroi-extension/app/containers/settings/categories/RemoveWalletDialogContainer.js index d7aa3cf7d8..271daff264 100644 --- a/packages/yoroi-extension/app/containers/settings/categories/RemoveWalletDialogContainer.js +++ b/packages/yoroi-extension/app/containers/settings/categories/RemoveWalletDialogContainer.js @@ -49,9 +49,10 @@ export default class RemoveWalletDialogContainer extends Component { }; removeWalletRevamp: void => Promise = async () => { + const { stores } = this.props; const settingsActions = this.props.actions.walletSettings; const selectedWalletId = this.props.publicDeriverId; - const walletsNavigation = this.props.stores.profile.walletsNavigation; + const walletsNavigation = stores.profile.walletsNavigation; const newWalletsNavigation = { ...walletsNavigation, @@ -60,7 +61,7 @@ export default class RemoveWalletDialogContainer extends Component { walletId => walletId !== selectedWalletId ), }; - await this.props.actions.profile.updateSortedWalletList.trigger(newWalletsNavigation); + await stores.profile.updateSortedWalletList(newWalletsNavigation); settingsActions.removeWallet.trigger({ publicDeriverId: this.props.publicDeriverId, diff --git a/packages/yoroi-extension/app/containers/wallet/AddWalletPage.js b/packages/yoroi-extension/app/containers/wallet/AddWalletPage.js index 7653705688..2709cc249d 100644 --- a/packages/yoroi-extension/app/containers/wallet/AddWalletPage.js +++ b/packages/yoroi-extension/app/containers/wallet/AddWalletPage.js @@ -44,7 +44,7 @@ export default class AddWalletPage extends Component { // this is because on close, asynchronous unmount actions get triggered // so there is no safe time at which we can un-select the API // so instead, the API gets reset before we start any dialog flow - this.props.actions.profile.setSelectedNetwork.trigger(undefined); + this.props.stores.profile.setSelectedNetwork(undefined); this.props.actions.dialogs.open.trigger({ dialog }); }; @@ -80,15 +80,15 @@ export default class AddWalletPage extends Component { activeDialog = ( actions.profile.setSelectedNetwork.trigger(networks.CardanoMainnet)} + onCardano={() => stores.profile.setSelectedNetwork(networks.CardanoMainnet)} onCardanoPreprodTestnet={() => - actions.profile.setSelectedNetwork.trigger(networks.CardanoPreprodTestnet) + stores.profile.setSelectedNetwork(networks.CardanoPreprodTestnet) } onCardanoPreviewTestnet={() => - actions.profile.setSelectedNetwork.trigger(networks.CardanoPreviewTestnet) + stores.profile.setSelectedNetwork(networks.CardanoPreviewTestnet) } onCardanoSanchoTestnet={() => - actions.profile.setSelectedNetwork.trigger(networks.CardanoSanchoTestnet) + stores.profile.setSelectedNetwork(networks.CardanoSanchoTestnet) } /> ); diff --git a/packages/yoroi-extension/app/containers/wallet/CreateWalletPageContainer.js b/packages/yoroi-extension/app/containers/wallet/CreateWalletPageContainer.js index ba5f7bb65e..02ee28eeb8 100644 --- a/packages/yoroi-extension/app/containers/wallet/CreateWalletPageContainer.js +++ b/packages/yoroi-extension/app/containers/wallet/CreateWalletPageContainer.js @@ -23,7 +23,7 @@ export default class CreateWalletPageContainer extends Component stores.substores.ada.wallets.createWallet(request)} - setSelectedNetwork={actions.profile.setSelectedNetwork.trigger} + setSelectedNetwork={stores.profile.setSelectedNetwork} selectedNetwork={stores.profile.selectedNetwork} openDialog={dialog => this.props.actions.dialogs.open.trigger({ dialog })} closeDialog={this.props.actions.dialogs.closeActiveDialog.trigger} diff --git a/packages/yoroi-extension/app/stores/base/BaseProfileStore.js b/packages/yoroi-extension/app/stores/base/BaseProfileStore.js index 701b4d7db8..18d4e7df77 100644 --- a/packages/yoroi-extension/app/stores/base/BaseProfileStore.js +++ b/packages/yoroi-extension/app/stores/base/BaseProfileStore.js @@ -328,7 +328,7 @@ export default class BaseProfileStore }); } - _acceptTermsOfUse: void => Promise = async () => { + acceptTermsOfUse: void => Promise = async () => { runInAction(() => { this._acceptedTosVersion.version = CURRENT_TOS_VERSION; }); diff --git a/packages/yoroi-extension/app/stores/toplevel/ProfileStore.js b/packages/yoroi-extension/app/stores/toplevel/ProfileStore.js index e42df986d7..c0fb8f3cb0 100644 --- a/packages/yoroi-extension/app/stores/toplevel/ProfileStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/ProfileStore.js @@ -155,16 +155,11 @@ export default class ProfileStore extends BaseProfileStore { setup(): void { super.setup(); - this.actions.profile.acceptTermsOfUse.listen(this._acceptTermsOfUse); - this.actions.profile.acceptUriScheme.listen(this._acceptUriScheme); - this.actions.profile.toggleSidebar.listen(this._toggleSidebar); - this.actions.profile.setSelectedNetwork.listen(this._setSelectedNetwork); this.registerReactions([ this._checkSetupSteps, ]); - this.actions.profile.updateSortedWalletList.listen(this._updateSortedWalletList); this._getUriSchemeAcceptance(); // eagerly cache - this._getSortedWalletList() + noop(this._getSortedWalletList()); } teardown(): void { @@ -184,7 +179,7 @@ export default class ProfileStore extends BaseProfileStore { return this.__selectedNetwork; } - @action _setSelectedNetwork: ($ReadOnly | void) => void = type => { + @action setSelectedNetwork: ($ReadOnly | void) => void = type => { this.__selectedNetwork = type; }; @@ -207,7 +202,7 @@ export default class ProfileStore extends BaseProfileStore { return this.getUriSchemeAcceptanceRequest.result === true; } - _acceptUriScheme: void => Promise = async () => { + acceptUriScheme: void => Promise = async () => { await this.setUriSchemeAcceptanceRequest.execute(); await this.getUriSchemeAcceptanceRequest.execute(); // eagerly cache }; @@ -226,7 +221,7 @@ export default class ProfileStore extends BaseProfileStore { return result === true; } - _toggleSidebar: void => Promise = async () => { + toggleSidebar: void => Promise = async () => { const isSidebarExpanded = this.isSidebarExpanded; await this.setToggleSidebarRequest.execute(isSidebarExpanded); await this.getToggleSidebarRequest.execute(); @@ -259,7 +254,7 @@ export default class ProfileStore extends BaseProfileStore { await this.getWalletsNavigationRequest.execute(); }; - _updateSortedWalletList: WalletsNavigation => Promise + updateSortedWalletList: WalletsNavigation => Promise = async (walletsNavigation) => { await this.setWalletsNavigationRequest.execute(walletsNavigation); await this.getWalletsNavigationRequest.execute(); diff --git a/packages/yoroi-extension/app/stores/toplevel/WalletSettingsStore.js b/packages/yoroi-extension/app/stores/toplevel/WalletSettingsStore.js index 82af97df5b..58fca43198 100644 --- a/packages/yoroi-extension/app/stores/toplevel/WalletSettingsStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/WalletSettingsStore.js @@ -144,7 +144,7 @@ export default class WalletSettingsStore extends Store { 'cardano': walletsNavigation.cardano.filter( walletId => walletId !== request.publicDeriverId) } - await this.actions.profile.updateSortedWalletList.trigger(newWalletsNavigation); + await stores.profile.updateSortedWalletList(newWalletsNavigation); // ==================== Disconnect related dApps ==================== await this.actions.connector.getConnectorWhitelist.trigger(); diff --git a/packages/yoroi-extension/app/stores/toplevel/WalletStore.js b/packages/yoroi-extension/app/stores/toplevel/WalletStore.js index 96d52b2dbd..9e48e8374a 100644 --- a/packages/yoroi-extension/app/stores/toplevel/WalletStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/WalletStore.js @@ -279,7 +279,7 @@ export default class WalletStore extends Store { if (walletIndex === -1) { throw new Error('unexpected missing wallet id'); } - this.actions.profile.setSelectedNetwork.trigger( + this.stores.profile.setSelectedNetwork( getNetworkById(this.wallets[walletIndex].networkId) ); this.selectedIndex = walletIndex; @@ -297,7 +297,7 @@ export default class WalletStore extends Store { }; @action unsetActiveWallet: void => void = () => { - this.actions.profile.setSelectedNetwork.trigger(undefined); + this.stores.profile.setSelectedNetwork(undefined); this.selectedIndex = null; this.selectedWalletName = null; }; From c2d1542ffca2a97b6ffa9a159d0ba68958bf2f2d Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Mon, 14 Oct 2024 09:19:32 +0300 Subject: [PATCH 32/76] removed notification actions --- packages/yoroi-extension/app/actions/index.js | 3 --- .../app/actions/notifications-actions.js | 12 ------------ .../app/connector/actions/index.js | 3 --- .../connector/containers/SignTxContainer.js | 3 +-- .../app/connector/stores/index.js | 2 +- .../app/containers/transfer/YoroiPlatePage.js | 3 +-- .../app/containers/wallet/WalletReceivePage.js | 8 ++++---- .../app/containers/wallet/WalletSummaryPage.js | 2 +- .../dialogs/WalletRestoreDialogContainer.js | 2 +- .../wallet/staking/CardanoStakingPage.js | 5 +++-- .../wallet/staking/StakingDashboardPage.js | 2 +- packages/yoroi-extension/app/stores/index.js | 2 +- .../stores/toplevel/UiNotificationsStore.js | 18 +++++------------- .../app/stores/toplevel/WalletStore.js | 8 ++++---- 14 files changed, 23 insertions(+), 50 deletions(-) delete mode 100644 packages/yoroi-extension/app/actions/notifications-actions.js diff --git a/packages/yoroi-extension/app/actions/index.js b/packages/yoroi-extension/app/actions/index.js index af1f32e379..ebb0463689 100644 --- a/packages/yoroi-extension/app/actions/index.js +++ b/packages/yoroi-extension/app/actions/index.js @@ -1,7 +1,6 @@ // @flow import WalletBackupActions from './wallet-backup-actions'; import DialogsActions from './dialogs-actions'; -import NotificationsActions from './notifications-actions'; import MemosActions from './memos-actions'; import WalletRestoreActions from './common/wallet-restore-actions'; import YoroiTransferActions from './common/yoroi-transfer-actions'; @@ -14,7 +13,6 @@ export type ActionsMap = {| walletSettings: WalletSettingsActions, walletBackup: WalletBackupActions, dialogs: DialogsActions, - notifications: NotificationsActions, yoroiTransfer: YoroiTransferActions, memos: MemosActions, walletRestore: WalletRestoreActions, @@ -26,7 +24,6 @@ const actionsMap: ActionsMap = Object.freeze({ walletSettings: new WalletSettingsActions(), walletBackup: new WalletBackupActions(), dialogs: new DialogsActions(), - notifications: new NotificationsActions(), yoroiTransfer: new YoroiTransferActions(), memos: new MemosActions(), walletRestore: new WalletRestoreActions(), diff --git a/packages/yoroi-extension/app/actions/notifications-actions.js b/packages/yoroi-extension/app/actions/notifications-actions.js deleted file mode 100644 index 48c6a50307..0000000000 --- a/packages/yoroi-extension/app/actions/notifications-actions.js +++ /dev/null @@ -1,12 +0,0 @@ -// @flow -import { Action } from './lib/Action'; -import type { Notification } from '../types/notification.types'; - -// ======= NOTIFICATIONS ACTIONS ======= - -export default class NotificationsActions { - open: Action = new Action(); - updateDataForActiveNotification: Action<{| data: Object, |}> = new Action(); - closeActiveNotification: Action<{| id: string |}>= new Action(); - resetActiveNotification: Action = new Action(); -} diff --git a/packages/yoroi-extension/app/connector/actions/index.js b/packages/yoroi-extension/app/connector/actions/index.js index 3e0e637553..659678eb81 100644 --- a/packages/yoroi-extension/app/connector/actions/index.js +++ b/packages/yoroi-extension/app/connector/actions/index.js @@ -1,18 +1,15 @@ // @flow import DialogsActions from '../../actions/dialogs-actions'; -import NotificationsActions from '../../actions/notifications-actions'; import ConnectorActions from './connector-actions'; export type ActionsMap = {| dialogs: DialogsActions, - notifications: NotificationsActions, connector: ConnectorActions, |}; const actionsMap: ActionsMap = Object.freeze({ connector: new ConnectorActions(), dialogs: new DialogsActions(), - notifications: new NotificationsActions(), }); export default actionsMap; diff --git a/packages/yoroi-extension/app/connector/containers/SignTxContainer.js b/packages/yoroi-extension/app/connector/containers/SignTxContainer.js index 9355a8ddba..04c74d8e53 100644 --- a/packages/yoroi-extension/app/connector/containers/SignTxContainer.js +++ b/packages/yoroi-extension/app/connector/containers/SignTxContainer.js @@ -82,7 +82,6 @@ export default class SignTxContainer extends Component< } render(): Node { - const actions = this.props.actions; const { uiNotifications } = this.props.stores; const { signingMessage, unrecoverableError } = this.props.stores.connector; @@ -110,7 +109,7 @@ export default class SignTxContainer extends Component< runInAction(() => { this.notificationElementId = elementId; }); - actions.notifications.open.trigger({ + uiNotifications.open({ id: elementId, duration: tooltipNotification.duration, message: tooltipNotification.message, diff --git a/packages/yoroi-extension/app/connector/stores/index.js b/packages/yoroi-extension/app/connector/stores/index.js index bb20e57795..d4f21c0e55 100644 --- a/packages/yoroi-extension/app/connector/stores/index.js +++ b/packages/yoroi-extension/app/connector/stores/index.js @@ -31,7 +31,7 @@ export type StoresMap = {| stateFetchStore: StateFetchStore, profile: ProfileStore, uiDialogs: UiDialogsStore<{||}, ActionsMap>, - uiNotifications: UiNotificationsStore<{||}, ActionsMap>, + uiNotifications: UiNotificationsStore<{||}>, explorers: ExplorerStore, coinPriceStore: ConnectorCoinPriceStore, loading: ConnectorLoadingStore, diff --git a/packages/yoroi-extension/app/containers/transfer/YoroiPlatePage.js b/packages/yoroi-extension/app/containers/transfer/YoroiPlatePage.js index 30e5c30c1a..5def137a50 100644 --- a/packages/yoroi-extension/app/containers/transfer/YoroiPlatePage.js +++ b/packages/yoroi-extension/app/containers/transfer/YoroiPlatePage.js @@ -47,7 +47,6 @@ export default class YoroiPlatePage extends Component { render(): null | Node { if (this.plates == null) return null; - const actions = this.props.actions; const { uiNotifications } = this.props.stores; const tooltipNotification = { @@ -65,7 +64,7 @@ export default class YoroiPlatePage extends Component { runInAction(() => { this.notificationElementId = elementId; }); - actions.notifications.open.trigger({ + uiNotifications.open({ id: elementId, duration: tooltipNotification.duration, message: tooltipNotification.message, diff --git a/packages/yoroi-extension/app/containers/wallet/WalletReceivePage.js b/packages/yoroi-extension/app/containers/wallet/WalletReceivePage.js index 337015dd04..3ea8d1ce27 100644 --- a/packages/yoroi-extension/app/containers/wallet/WalletReceivePage.js +++ b/packages/yoroi-extension/app/containers/wallet/WalletReceivePage.js @@ -76,7 +76,7 @@ export default class WalletReceivePage extends Component const publicDeriver = this.props.stores.wallets.selected; if (publicDeriver) { const notificationId = `${publicDeriver.publicDeriverId}-copyNotification`; - this.props.actions.notifications.closeActiveNotification.trigger({ id: notificationId }); + this.props.stores.uiNotifications.closeActiveNotification({ id: notificationId }); } }; @@ -115,7 +115,7 @@ export default class WalletReceivePage extends Component runInAction(() => { this.notificationElementId = elementId; }); - actions.notifications.open.trigger({ + uiNotifications.open({ id: elementId, duration: tooltipNotification.duration, message: tooltipNotification.message, @@ -300,7 +300,7 @@ export default class WalletReceivePage extends Component runInAction(() => { this.notificationElementId = elementId; }); - actions.notifications.open.trigger({ + uiNotifications.open({ id: elementId, duration: tooltipNotification.duration, message: tooltipNotification.message, @@ -330,7 +330,7 @@ export default class WalletReceivePage extends Component runInAction(() => { this.notificationElementId = elementId; }); - actions.notifications.open.trigger({ + uiNotifications.open({ id: elementId, duration: tooltipNotification.duration, message: tooltipNotification.message, diff --git a/packages/yoroi-extension/app/containers/wallet/WalletSummaryPage.js b/packages/yoroi-extension/app/containers/wallet/WalletSummaryPage.js index 6db178c745..f049b9ffd7 100644 --- a/packages/yoroi-extension/app/containers/wallet/WalletSummaryPage.js +++ b/packages/yoroi-extension/app/containers/wallet/WalletSummaryPage.js @@ -72,7 +72,7 @@ export default class WalletSummaryPage extends Component runInAction(() => { this.notificationElementId = elementId; }); - actions.notifications.open.trigger({ + uiNotifications.open({ id: elementId, duration: tooltipNotification.duration, message: tooltipNotification.message, diff --git a/packages/yoroi-extension/app/containers/wallet/dialogs/WalletRestoreDialogContainer.js b/packages/yoroi-extension/app/containers/wallet/dialogs/WalletRestoreDialogContainer.js index fe94825f5c..fef38acbc9 100644 --- a/packages/yoroi-extension/app/containers/wallet/dialogs/WalletRestoreDialogContainer.js +++ b/packages/yoroi-extension/app/containers/wallet/dialogs/WalletRestoreDialogContainer.js @@ -193,7 +193,7 @@ export default class WalletRestoreDialogContainer extends Component<{| ...Stores runInAction(() => { this.notificationElementId = elementId; }); - actions.notifications.open.trigger({ + uiNotifications.open({ id: elementId, duration: tooltipNotification.duration, message: tooltipNotification.message, diff --git a/packages/yoroi-extension/app/containers/wallet/staking/CardanoStakingPage.js b/packages/yoroi-extension/app/containers/wallet/staking/CardanoStakingPage.js index 2dd9971b57..425b9cdba8 100644 --- a/packages/yoroi-extension/app/containers/wallet/staking/CardanoStakingPage.js +++ b/packages/yoroi-extension/app/containers/wallet/staking/CardanoStakingPage.js @@ -236,11 +236,12 @@ export default class CardanoStakingPage extends Component { hash={selectedPoolInfo.poolId} moreInfo={moreInfo} onCopyAddressTooltip={(address, elementId) => { - if (!this.props.stores.uiNotifications.isOpen(elementId)) { + const { uiNotifications } = this.props.stores; + if (!uiNotifications.isOpen(elementId)) { runInAction(() => { this.notificationElementId = elementId; }); - this.props.actions.notifications.open.trigger({ + uiNotifications.open({ id: elementId, duration: tooltipNotification.duration, message: tooltipNotification.message, diff --git a/packages/yoroi-extension/app/containers/wallet/staking/StakingDashboardPage.js b/packages/yoroi-extension/app/containers/wallet/staking/StakingDashboardPage.js index b07c9b86e4..1cc9d69a02 100644 --- a/packages/yoroi-extension/app/containers/wallet/staking/StakingDashboardPage.js +++ b/packages/yoroi-extension/app/containers/wallet/staking/StakingDashboardPage.js @@ -190,7 +190,7 @@ export default class StakingDashboardPage extends Component { this.notificationElementId = elementId; }); - this.props.actions.notifications.open.trigger({ + uiNotifications.open({ id: elementId, duration: tooltipNotification.duration, message: tooltipNotification.message, diff --git a/packages/yoroi-extension/app/stores/index.js b/packages/yoroi-extension/app/stores/index.js index 3061016ff6..d4a484d3bb 100644 --- a/packages/yoroi-extension/app/stores/index.js +++ b/packages/yoroi-extension/app/stores/index.js @@ -65,7 +65,7 @@ export type StoresMap = {| memos: MemosStore, walletBackup: WalletBackupStore, uiDialogs: UiDialogsStore<{||}, ActionsMap>, - uiNotifications: UiNotificationsStore<{||}, ActionsMap>, + uiNotifications: UiNotificationsStore<{||}>, loading: LoadingStore, wallets: WalletStore, addresses: AddressesStore, diff --git a/packages/yoroi-extension/app/stores/toplevel/UiNotificationsStore.js b/packages/yoroi-extension/app/stores/toplevel/UiNotificationsStore.js index 983bf0753a..c4e2d0579b 100644 --- a/packages/yoroi-extension/app/stores/toplevel/UiNotificationsStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/UiNotificationsStore.js @@ -2,13 +2,11 @@ import { observable, action, computed } from 'mobx'; import Store from '../base/Store'; import type { Notification } from '../../types/notification.types'; -import NotificationsActions from '../../actions/notifications-actions'; /** Manage a list on ongoing notifications and closes them when they expire */ export default class UiNotificationsStore< TStores, - TActions: { notifications: NotificationsActions, ... }, -> extends Store +> extends Store { @observable activeNotifications: Array = []; @@ -19,12 +17,6 @@ export default class UiNotificationsStore< null; } - setup(): void { - super.setup(); - this.actions.notifications.open.listen(this._onOpen); - this.actions.notifications.closeActiveNotification.listen(this._onClose); - } - isOpen: string => boolean = ( id: string ): boolean => !!this._findNotificationById(id); @@ -46,7 +38,7 @@ export default class UiNotificationsStore< this.activeNotifications.find(notification => notification.id === id) ); - @action _onOpen: Notification => void = (newNotification) => { + @action open: Notification => void = (newNotification) => { const notification: Notification = { ...newNotification, secondsTimerInterval: newNotification.duration != null @@ -56,7 +48,7 @@ export default class UiNotificationsStore< if (this.isOpen(notification.id)) { // if notification is currently active close and reopen it - this._onClose({ id: notification.id }); + this.closeActiveNotification({ id: notification.id }); setTimeout(() => this._set(notification), 200); } else { this._set(notification); @@ -67,7 +59,7 @@ export default class UiNotificationsStore< this.activeNotifications.push(notification); }; - @action _onClose: {| id: string |} => void = ({ id }) => { + @action closeActiveNotification: {| id: string |} => void = ({ id }) => { const notification = this._findNotificationById(id); if (notification) { if (notification.secondsTimerInterval) clearInterval(notification.secondsTimerInterval); @@ -80,7 +72,7 @@ export default class UiNotificationsStore< const notification = this._findNotificationById(id); if (notification && notification.duration != null) { notification.duration -= 1; - if (notification.duration === 0) this._onClose({ id }); + if (notification.duration === 0) this.closeActiveNotification({ id }); } }; } diff --git a/packages/yoroi-extension/app/stores/toplevel/WalletStore.js b/packages/yoroi-extension/app/stores/toplevel/WalletStore.js index 9e48e8374a..779ba44196 100644 --- a/packages/yoroi-extension/app/stores/toplevel/WalletStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/WalletStore.js @@ -306,19 +306,19 @@ export default class WalletStore extends Store { // =================== NOTIFICATION ==================== // showLedgerWalletIntegratedNotification: void => void = (): void => { - this.actions.notifications.open.trigger(WalletCreationNotifications.LedgerNotification); + this.stores.uiNotifications.open(WalletCreationNotifications.LedgerNotification); }; showTrezorTWalletIntegratedNotification: void => void = (): void => { - this.actions.notifications.open.trigger(WalletCreationNotifications.TrezorTNotification); + this.stores.uiNotifications.open(WalletCreationNotifications.TrezorTNotification); }; showWalletCreatedNotification: void => void = (): void => { - this.actions.notifications.open.trigger(WalletCreationNotifications.WalletCreatedNotification); + this.stores.uiNotifications.open(WalletCreationNotifications.WalletCreatedNotification); }; showWalletRestoredNotification: void => void = (): void => { - this.actions.notifications.open.trigger(WalletCreationNotifications.WalletRestoredNotification); + this.stores.uiNotifications.open(WalletCreationNotifications.WalletRestoredNotification); }; @action From e4e952d9799b64b96ee6e192c9c1da23836a351c Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Mon, 14 Oct 2024 16:49:23 +0300 Subject: [PATCH 33/76] removed transfer actions --- .../actions/common/yoroi-transfer-actions.js | 25 -- packages/yoroi-extension/app/actions/index.js | 3 - .../containers/transfer/WalletTransferPage.js | 5 +- .../containers/transfer/YoroiTransferPage.js | 10 +- .../app/stores/ada/AdaWalletRestoreStore.js | 2 +- .../app/stores/toplevel/YoroiTransferStore.js | 242 ++++++++---------- 6 files changed, 120 insertions(+), 167 deletions(-) delete mode 100644 packages/yoroi-extension/app/actions/common/yoroi-transfer-actions.js diff --git a/packages/yoroi-extension/app/actions/common/yoroi-transfer-actions.js b/packages/yoroi-extension/app/actions/common/yoroi-transfer-actions.js deleted file mode 100644 index 884716e3d4..0000000000 --- a/packages/yoroi-extension/app/actions/common/yoroi-transfer-actions.js +++ /dev/null @@ -1,25 +0,0 @@ -// @flow -import { AsyncAction, Action } from '../lib/Action'; -import type { - Address, Addressing -} from '../../api/ada/lib/storage/models/PublicDeriver/interfaces'; -import type { NetworkRow } from '../../api/ada/lib/storage/database/primitives/tables'; - -export default class YoroiTransferActions { - startTransferFunds: Action = new Action(); - setupTransferFundsWithPaperMnemonic: Action<{| - recoveryPhrase: string, - paperPassword: string, - |}> = new Action(); - checkAddresses: AsyncAction<{| - getDestinationAddress: void => Promise<{| ...Address, ...InexactSubset |}>, - |}> = new AsyncAction(); - backToUninitialized: Action = new Action(); - transferFunds: AsyncAction<{| - next: void => Promise, - network: $ReadOnly, - getDestinationAddress: void => Promise<{| ...Address, ...InexactSubset |}>, - rebuildTx: boolean, - |}> = new AsyncAction(); - cancelTransferFunds: Action = new Action(); -} diff --git a/packages/yoroi-extension/app/actions/index.js b/packages/yoroi-extension/app/actions/index.js index ebb0463689..83f86c8e52 100644 --- a/packages/yoroi-extension/app/actions/index.js +++ b/packages/yoroi-extension/app/actions/index.js @@ -3,7 +3,6 @@ import WalletBackupActions from './wallet-backup-actions'; import DialogsActions from './dialogs-actions'; import MemosActions from './memos-actions'; import WalletRestoreActions from './common/wallet-restore-actions'; -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'; @@ -13,7 +12,6 @@ export type ActionsMap = {| walletSettings: WalletSettingsActions, walletBackup: WalletBackupActions, dialogs: DialogsActions, - yoroiTransfer: YoroiTransferActions, memos: MemosActions, walletRestore: WalletRestoreActions, connector: ConnectorActionsMap, @@ -24,7 +22,6 @@ const actionsMap: ActionsMap = Object.freeze({ walletSettings: new WalletSettingsActions(), walletBackup: new WalletBackupActions(), dialogs: new DialogsActions(), - yoroiTransfer: new YoroiTransferActions(), memos: new MemosActions(), walletRestore: new WalletRestoreActions(), connector: new ConnectorActionsMap(), diff --git a/packages/yoroi-extension/app/containers/transfer/WalletTransferPage.js b/packages/yoroi-extension/app/containers/transfer/WalletTransferPage.js index 8189738564..62e4935563 100644 --- a/packages/yoroi-extension/app/containers/transfer/WalletTransferPage.js +++ b/packages/yoroi-extension/app/containers/transfer/WalletTransferPage.js @@ -14,12 +14,11 @@ import { genLookupOrFail, getTokenName, } from '../../stores/stateless/tokenHelp import { truncateToken } from '../../utils/formatters'; type Props = {| - ...StoresAndActionsProps, publicDeriver: PublicDeriver<>, |}; @observer -export default class WalletTransferPage extends Component { +export default class WalletTransferPage extends Component<{| ...Props, ...StoresAndActionsProps |}> { static contextTypes: {|intl: $npm$ReactIntl$IntlFormat|} = { intl: intlShape.isRequired, }; @@ -30,7 +29,7 @@ export default class WalletTransferPage extends Component { // paper startTransferYoroiPaperFunds: void => void = () => { - this.props.actions.yoroiTransfer.startTransferFunds.trigger(); + this.props.stores.yoroiTransfer.startTransferFunds(); } render(): Node { diff --git a/packages/yoroi-extension/app/containers/transfer/YoroiTransferPage.js b/packages/yoroi-extension/app/containers/transfer/YoroiTransferPage.js index 952aa0a5cf..6a54a6595c 100644 --- a/packages/yoroi-extension/app/containers/transfer/YoroiTransferPage.js +++ b/packages/yoroi-extension/app/containers/transfer/YoroiTransferPage.js @@ -40,7 +40,7 @@ export default class YoroiTransferPage extends Component paperPassword: string, recoveryPhrase: string, |}) => void) = (payload) => { - this.props.actions.yoroiTransfer.setupTransferFundsWithPaperMnemonic.trigger({ + this.props.stores.yoroiTransfer.setupTransferFundsWithPaperMnemonic({ ...payload, }); }; @@ -52,7 +52,7 @@ export default class YoroiTransferPage extends Component if (publicDeriver == null) { throw new Error(`${nameof(this.checkAddresses)} no wallet selected`); } - await this.props.actions.yoroiTransfer.checkAddresses.trigger({ + await this.props.stores.yoroiTransfer.checkAddresses({ getDestinationAddress: yoroiTransfer.nextInternalAddress(publicDeriver), }); }; @@ -63,7 +63,7 @@ export default class YoroiTransferPage extends Component const { stores } = this.props; const { wallets: walletsStore, yoroiTransfer } = stores; const wallet = stores.wallets.selectedOrFail; - await this.props.actions.yoroiTransfer.transferFunds.trigger({ + await this.props.stores.yoroiTransfer.transferFunds({ network: getNetworkById(wallet.networkId), next: async () => { const preRefreshTime = new Date().getTime(); @@ -90,11 +90,11 @@ export default class YoroiTransferPage extends Component } backToUninitialized: (() => void) = () => { - this.props.actions.yoroiTransfer.backToUninitialized.trigger(); + this.props.stores.yoroiTransfer.backToUninitialized(); }; cancelTransferFunds: (() => void) = () => { - this.props.actions.yoroiTransfer.cancelTransferFunds.trigger(); + this.props.stores.yoroiTransfer.reset(); }; render(): null | Node { diff --git a/packages/yoroi-extension/app/stores/ada/AdaWalletRestoreStore.js b/packages/yoroi-extension/app/stores/ada/AdaWalletRestoreStore.js index f131a39097..795fbbfad9 100644 --- a/packages/yoroi-extension/app/stores/ada/AdaWalletRestoreStore.js +++ b/packages/yoroi-extension/app/stores/ada/AdaWalletRestoreStore.js @@ -34,7 +34,7 @@ export default class AdaWalletRestoreStore extends Store if (network == null) { throw new Error(`${nameof(this._transferFromLegacy)} no network selected`); } - await this.actions.yoroiTransfer.transferFunds.trigger({ + await this.stores.yoroiTransfer.transferFunds({ next: async () => { await this._restoreToDb(); }, diff --git a/packages/yoroi-extension/app/stores/toplevel/YoroiTransferStore.js b/packages/yoroi-extension/app/stores/toplevel/YoroiTransferStore.js index 79ed87e8c4..02dd82a525 100644 --- a/packages/yoroi-extension/app/stores/toplevel/YoroiTransferStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/YoroiTransferStore.js @@ -23,62 +23,38 @@ export default class YoroiTransferStore extends Store { @observable transferTx: ?TransferTx = null; @observable recoveryPhrase: string = ''; - // eslint-disable-next-line no-restricted-syntax - _asyncErrorWrapper: (( - func: (PT) => Promise - ) => (PT) => Promise) = ( - func: PT=>Promise - ): (PT => Promise) => (async (payload) => { - try { - return await func(payload); - } catch (error) { - Logger.error(`${nameof(YoroiTransferStore)} ${stringifyError(error)}`); - runInAction(() => { - this.status = TransferStatus.ERROR; - this.error = localizedError(error); - }); - throw error; - } - }); - // eslint-disable-next-line no-restricted-syntax - _errorWrapper: (( - func: (PT) => RT - ) => (PT) => RT) = ( - func: PT=>RT - ): (PT => RT) => ((payload) => { - try { - return func(payload); - } catch (error) { + _wrapError: (( + func: () => R + ) => R) = ( + func: () => R + ): R => { + const handleError = (error: Error) => { Logger.error(`${nameof(YoroiTransferStore)} ${stringifyError(error)}`); runInAction(() => { this.status = TransferStatus.ERROR; this.error = localizedError(error); }); throw error; + }; + try { + const r = func(); + if (r instanceof Promise) { + // $FlowIgnore[incompatible-return] + return r.catch(handleError); + } + return r; + } catch (error) { + handleError(error) + throw error; } - }); - - setup(): void { - super.setup(); - const actions = this.actions.yoroiTransfer; - actions.startTransferFunds.listen(this._startTransferFunds); - actions.setupTransferFundsWithPaperMnemonic.listen( - this._errorWrapper(this._setupTransferFundsWithPaperMnemonic) - ); - actions.checkAddresses.listen( - this._asyncErrorWrapper(this.checkAddresses) - ); - actions.backToUninitialized.listen(this._backToUninitialized); - actions.transferFunds.listen(this._asyncErrorWrapper(this._transferFunds)); - actions.cancelTransferFunds.listen(this.reset); - } + }; teardown(): void { super.teardown(); this.reset(); } - _startTransferFunds: void => void = () => { + startTransferFunds: void => void = () => { this._updateStatus(TransferStatus.GETTING_PAPER_MNEMONICS); } @@ -100,22 +76,24 @@ export default class YoroiTransferStore extends Store { } // paper - _setupTransferFundsWithPaperMnemonic: {| + setupTransferFundsWithPaperMnemonic: {| recoveryPhrase: string, paperPassword: string, |} => void = (payload) => { - const result = unscramblePaperAdaMnemonic( - payload.recoveryPhrase, - config.wallets.YOROI_PAPER_RECOVERY_PHRASE_WORD_COUNT, - payload.paperPassword - ); - const recoveryPhrase = result[0]; - if (recoveryPhrase == null) { - throw new Error(`${nameof(this._setupTransferFundsWithPaperMnemonic)} paper wallet failed`); - } - this.setupTransferFundsWithMnemonic({ - recoveryPhrase, - }); + this._wrapError(() => { + const result = unscramblePaperAdaMnemonic( + payload.recoveryPhrase, + config.wallets.YOROI_PAPER_RECOVERY_PHRASE_WORD_COUNT, + payload.paperPassword + ); + const recoveryPhrase = result[0]; + if (recoveryPhrase == null) { + throw new Error(`${nameof(this.setupTransferFundsWithPaperMnemonic)} paper wallet failed`); + } + this.setupTransferFundsWithMnemonic({ + recoveryPhrase, + }); + }) } setupTransferFundsWithMnemonic: {| @@ -151,20 +129,22 @@ export default class YoroiTransferStore extends Store { |} => Promise = async ( payload ): Promise => { - this._updateStatus(TransferStatus.CHECKING_ADDRESSES); - const transferTx = await this.generateTransferTx({ - recoveryPhrase: this.recoveryPhrase, - updateStatusCallback: () => this._updateStatus(TransferStatus.GENERATING_TX), - getDestinationAddress: payload.getDestinationAddress, - }); - runInAction(() => { - this.transferTx = transferTx; - }); + return this._wrapError>(async () => { + this._updateStatus(TransferStatus.CHECKING_ADDRESSES); + const transferTx = await this.generateTransferTx({ + recoveryPhrase: this.recoveryPhrase, + updateStatusCallback: () => this._updateStatus(TransferStatus.GENERATING_TX), + getDestinationAddress: payload.getDestinationAddress, + }); + runInAction(() => { + this.transferTx = transferTx; + }); - this._updateStatus(TransferStatus.READY_TO_TRANSFER); + this._updateStatus(TransferStatus.READY_TO_TRANSFER); + }); } - _backToUninitialized: void => void = () => { + backToUninitialized: void => void = () => { this._updateStatus(TransferStatus.UNINITIALIZED); } @@ -175,7 +155,7 @@ export default class YoroiTransferStore extends Store { } /** Broadcast the transfer transaction if one exists and proceed to continuation */ - _transferFunds: {| + transferFunds: {| next: void => Promise, network: $ReadOnly, getDestinationAddress: void => Promise<{| ...Address, ...InexactSubset |}>, @@ -188,74 +168,76 @@ export default class YoroiTransferStore extends Store { runInAction(() => { this.error = null; }); - const oldTx: TransferTx = (() => { - const tx = this.transferTx; - if (tx == null) { - throw new NoTransferTxError(); - } - return tx; - })(); + return this._wrapError>(async () => { + const oldTx: TransferTx = (() => { + const tx = this.transferTx; + if (tx == null) { + throw new NoTransferTxError(); + } + return tx; + })(); - const getTransferTx = async (): Promise => { - if (!payload.rebuildTx) { - return oldTx; - } - const newTx = await this.generateTransferTx({ - recoveryPhrase: this.recoveryPhrase, - updateStatusCallback: () => {}, - getDestinationAddress: payload.getDestinationAddress, - }); - if (this._isWalletChanged(oldTx, newTx)) { - this._handleWalletChanged(newTx); - } - return newTx; - }; + const getTransferTx = async (): Promise => { + if (!payload.rebuildTx) { + return oldTx; + } + const newTx = await this.generateTransferTx({ + recoveryPhrase: this.recoveryPhrase, + updateStatusCallback: () => {}, + getDestinationAddress: payload.getDestinationAddress, + }); + if (this._isWalletChanged(oldTx, newTx)) { + this._handleWalletChanged(newTx); + } + return newTx; + }; - const { next } = payload; + const { next } = payload; - try { - await this.stores.wallets.sendAndRefresh({ - publicDeriverId: undefined, - plateTextPart: undefined, - broadcastRequest: async () => { - const transferTx = await getTransferTx(); - if (transferTx.id == null || transferTx.encodedTx == null) { - throw new Error(`${nameof(YoroiTransferStore)} transaction not signed`); - } - const { id, encodedTx } = transferTx; - try { - const txId = await this.stores.substores.ada.stateFetchStore.fetcher.sendTx({ - network: payload.network, - id, - encodedTx, - }); - return txId; - } catch (error) { - if (error instanceof SendTransactionApiError) { - /* See if the error is due to wallet change since last recovery. - This should be very rare because the window is short. - */ - await getTransferTx(); // will update the tx if something changed + try { + await this.stores.wallets.sendAndRefresh({ + publicDeriverId: undefined, + plateTextPart: undefined, + broadcastRequest: async () => { + const transferTx = await getTransferTx(); + if (transferTx.id == null || transferTx.encodedTx == null) { + throw new Error(`${nameof(YoroiTransferStore)} transaction not signed`); } + const { id, encodedTx } = transferTx; + try { + const txId = await this.stores.substores.ada.stateFetchStore.fetcher.sendTx({ + network: payload.network, + id, + encodedTx, + }); + return txId; + } catch (error) { + if (error instanceof SendTransactionApiError) { + /* See if the error is due to wallet change since last recovery. + This should be very rare because the window is short. + */ + await getTransferTx(); // will update the tx if something changed + } - throw new TransferFundsError(); + throw new TransferFundsError(); + } + }, + refreshWallet: async () => { + const selected = this.stores.wallets.selected; + if (selected == null) return; + await this.stores.wallets.refreshWalletFromRemote(selected.publicDeriverId); } - }, - refreshWallet: async () => { - const selected = this.stores.wallets.selected; - if (selected == null) return; - await this.stores.wallets.refreshWalletFromRemote(selected.publicDeriverId); - } - }); - } catch (e) { - Logger.error(`${nameof(YoroiTransferStore)}::${nameof(this._transferFunds)} ${stringifyError(e)}`); - runInAction(() => { this.error = e; }); - } - if (this.error == null) { - this._updateStatus(TransferStatus.SUCCESS); - await next(); - this.reset(); - } + }); + } catch (e) { + Logger.error(`${nameof(YoroiTransferStore)}::${nameof(this.transferFunds)} ${stringifyError(e)}`); + runInAction(() => { this.error = e; }); + } + if (this.error == null) { + this._updateStatus(TransferStatus.SUCCESS); + await next(); + this.reset(); + } + }) } _isWalletChanged(transferTx1: TransferTx, transferTx2: TransferTx): boolean { From 57a5fd7e4f8347af9403e8fb547e64aab1b5b6bc Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Mon, 14 Oct 2024 17:37:22 +0300 Subject: [PATCH 34/76] removed wallet restore actions --- .../actions/common/wallet-restore-actions.js | 49 ---------- packages/yoroi-extension/app/actions/index.js | 3 - .../wallet/restore/LegacyExplanation.js | 91 ------------------- .../wallet/restore/LegacyExplanation.scss | 29 ------ .../wallet/restore/RestoreWalletPage.js | 2 +- .../steps/phrase/EnterRecoveryPhraseStep.js | 2 +- .../steps/type/SelectWalletTypeStep.js | 2 +- .../app/containers/wallet/AddWalletPage.js | 2 +- .../dialogs/WalletRestoreDialogContainer.js | 49 ++++------ .../wallet/restore/RestoreWalletPage.js | 2 +- .../app/stores/ada/AdaWalletRestoreStore.js | 23 ++--- .../app/stores/toplevel/WalletRestoreStore.js | 58 ++++++++---- 12 files changed, 73 insertions(+), 239 deletions(-) delete mode 100644 packages/yoroi-extension/app/actions/common/wallet-restore-actions.js delete mode 100644 packages/yoroi-extension/app/components/wallet/restore/LegacyExplanation.js delete mode 100644 packages/yoroi-extension/app/components/wallet/restore/LegacyExplanation.scss diff --git a/packages/yoroi-extension/app/actions/common/wallet-restore-actions.js b/packages/yoroi-extension/app/actions/common/wallet-restore-actions.js deleted file mode 100644 index b34b85c555..0000000000 --- a/packages/yoroi-extension/app/actions/common/wallet-restore-actions.js +++ /dev/null @@ -1,49 +0,0 @@ -// @flow - -import { AsyncAction, Action } from '../lib/Action'; -import config from '../../config'; - -export type WalletRestoreMeta = {| - recoveryPhrase: string, - walletName: string, - walletPassword: string, -|}; - -// BIP44 , PAPER -export type RestoreModeType = - | {| - type: 'bip44', - extra: void, - length: typeof config.wallets.WALLET_RECOVERY_PHRASE_WORD_COUNT, - |} - | {| - type: 'cip1852', - extra: void, - chain?: number, - length: - | typeof config.wallets.WALLET_RECOVERY_PHRASE_WORD_COUNT - | typeof config.wallets.DAEDALUS_SHELLEY_RECOVERY_PHRASE_WORD_COUNT, - |} - | {| - // note: we didn't allow paper wallet creation during the ITN - // but we did allow paper wallet restoration - type: 'bip44' | 'cip1852', - extra: 'paper', - length: typeof config.wallets.YOROI_PAPER_RECOVERY_PHRASE_WORD_COUNT, - chain?: number, - |} - | {| - type: 'bip44' | 'cip1852', - extra: 'ledger' | 'trezor', - |}; - -export default class WalletRestoreActions { - submitFields: AsyncAction = new AsyncAction(); - startRestore: AsyncAction = new AsyncAction(); - restoreWallet: AsyncAction = new AsyncAction(); - verifyMnemonic: AsyncAction = new AsyncAction(); - startCheck: AsyncAction = new AsyncAction(); - reset: Action = new Action(); - back: Action = new Action(); - transferFromLegacy: AsyncAction = new AsyncAction(); -} diff --git a/packages/yoroi-extension/app/actions/index.js b/packages/yoroi-extension/app/actions/index.js index 83f86c8e52..122941b0a9 100644 --- a/packages/yoroi-extension/app/actions/index.js +++ b/packages/yoroi-extension/app/actions/index.js @@ -2,7 +2,6 @@ import WalletBackupActions from './wallet-backup-actions'; import DialogsActions from './dialogs-actions'; import MemosActions from './memos-actions'; -import WalletRestoreActions from './common/wallet-restore-actions'; import TxBuilderActions from './common/tx-builder-actions'; import WalletSettingsActions from './common/wallet-settings-actions'; import ConnectorActionsMap from '../connector/actions/connector-actions'; @@ -13,7 +12,6 @@ export type ActionsMap = {| walletBackup: WalletBackupActions, dialogs: DialogsActions, memos: MemosActions, - walletRestore: WalletRestoreActions, connector: ConnectorActionsMap, |}; @@ -23,7 +21,6 @@ const actionsMap: ActionsMap = Object.freeze({ walletBackup: new WalletBackupActions(), dialogs: new DialogsActions(), memos: new MemosActions(), - walletRestore: new WalletRestoreActions(), connector: new ConnectorActionsMap(), }); diff --git a/packages/yoroi-extension/app/components/wallet/restore/LegacyExplanation.js b/packages/yoroi-extension/app/components/wallet/restore/LegacyExplanation.js deleted file mode 100644 index 1aa4629b5f..0000000000 --- a/packages/yoroi-extension/app/components/wallet/restore/LegacyExplanation.js +++ /dev/null @@ -1,91 +0,0 @@ -// @flow -import type { Node } from 'react'; -import { Component } from 'react'; -import { observer } from 'mobx-react'; -import classnames from 'classnames'; -import { defineMessages, intlShape } from 'react-intl'; -import Dialog from '../../widgets/Dialog'; -import DialogBackButton from '../../widgets/DialogBackButton'; -import DialogCloseButton from '../../widgets/DialogCloseButton'; -import WalletRecoveryInstructions from '../backup-recovery/WalletRecoveryInstructions'; -import globalMessages from '../../../i18n/global-messages'; -import styles from './LegacyExplanation.scss'; -import { ReactComponent as RecoveryWatchingSvg } from '../../../assets/images/recovery-watching.inline.svg'; -import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; - -const messages = defineMessages({ - legacyExplanation: { - id: 'wallet.backup.dialog.legacy.explanation', - defaultMessage: `!!!If you had any ADA in your wallet on November 29th, 2019 - you have to upgrade your wallet to a Shelley "reward wallet".` - }, - checkConfirm: { - id: 'wallet.backup.dialog.legacy.checkConfirm', - defaultMessage: `!!!Do you want to check if your wallet needs to be upgraded?` - }, -}); - -type Props = {| - +onBack: void => void, - +onClose: void => void, - +onSkip: void => PossiblyAsync, - +onCheck: void => PossiblyAsync, - +isSubmitting: boolean, -|}; - -@observer -export default class LegacyExplanation extends Component { - - static contextTypes: {|intl: $npm$ReactIntl$IntlFormat|} = { - intl: intlShape.isRequired, - }; - - render(): Node { - const { intl } = this.context; - const dialogClasses = classnames([ - styles.component, - 'LegacyExplanation', - ]); - - const actions = [ - { - label: intl.formatMessage(globalMessages.skipLabel), - className: classnames([this.props.isSubmitting ? styles.isSubmitting : null]), - onClick: this.props.onSkip, - primary: false, - isSubmitting: this.props.isSubmitting, - }, - { - label: intl.formatMessage(globalMessages.checkLabel), - onClick: this.props.onCheck, - primary: true, - disabled: this.props.isSubmitting, - } - ]; - - return ( - } - backButton={} - > - - - {intl.formatMessage(messages.legacyExplanation)} -
    -
    - {intl.formatMessage(messages.checkConfirm)} - - )} - /> -
    - ); - } - -} diff --git a/packages/yoroi-extension/app/components/wallet/restore/LegacyExplanation.scss b/packages/yoroi-extension/app/components/wallet/restore/LegacyExplanation.scss deleted file mode 100644 index ccf4c0658b..0000000000 --- a/packages/yoroi-extension/app/components/wallet/restore/LegacyExplanation.scss +++ /dev/null @@ -1,29 +0,0 @@ -@import '../../../themes/mixins/loading-spinner'; - -.component { - text-align: left; - - .checkbox { - margin-top: 20px; - - label { - font-size: 14px; - } - } - - .recoveryImage { - display: block; - width: 100%; - text-align: center; - margin: 23px 0 36px; - - svg { - width: 212px; - } - } -} - -.isSubmitting { - @include loading-spinner("../../../assets/images/spinner-dark.svg"); - opacity: 0.5; -} diff --git a/packages/yoroi-extension/app/components/wallet/restore/RestoreWalletPage.js b/packages/yoroi-extension/app/components/wallet/restore/RestoreWalletPage.js index 5dbe188509..eaadf8f0e6 100644 --- a/packages/yoroi-extension/app/components/wallet/restore/RestoreWalletPage.js +++ b/packages/yoroi-extension/app/components/wallet/restore/RestoreWalletPage.js @@ -19,11 +19,11 @@ import environment from '../../../environment'; import { useRestoreWallet } from './hooks'; import { ampli } from '../../../../ampli/index'; import { runInAction } from 'mobx'; -import type { RestoreModeType } from '../../../actions/common/wallet-restore-actions'; import { isWalletExist } from '../../../stores/toplevel/WalletRestoreStore'; import type { StoresMap } from '../../../stores'; import type { ActionsMap } from '../../../actions'; import { forceNonNull } from '../../../coreUtils'; +import type { RestoreModeType } from '../../../stores/toplevel/WalletRestoreStore'; const messages: * = defineMessages({ title: { diff --git a/packages/yoroi-extension/app/components/wallet/restore/steps/phrase/EnterRecoveryPhraseStep.js b/packages/yoroi-extension/app/components/wallet/restore/steps/phrase/EnterRecoveryPhraseStep.js index 8ba83e0c85..70572faf78 100644 --- a/packages/yoroi-extension/app/components/wallet/restore/steps/phrase/EnterRecoveryPhraseStep.js +++ b/packages/yoroi-extension/app/components/wallet/restore/steps/phrase/EnterRecoveryPhraseStep.js @@ -12,11 +12,11 @@ import globalMessages from '../../../../../i18n/global-messages'; import RestoreRecoveryPhraseForm from './RestoreRecoveryPhraseForm'; import DuplicatedWalletDialog from './DuplicatedWalletDialog'; import { TIPS_DIALOGS } from '../../../dialogs/constants'; -import type { RestoreModeType } from '../../../../../actions/common/wallet-restore-actions'; import { fail } from '../../../../../coreUtils'; import type { WalletChecksum } from '@emurgo/cip4-js'; import type { MultiToken } from '../../../../../api/common/lib/MultiToken'; import type { TokenInfoMap } from '../../../../../stores/toplevel/TokenInfoStore'; +import type { RestoreModeType } from '../../../../../stores/toplevel/WalletRestoreStore'; const messages = defineMessages({ description: { diff --git a/packages/yoroi-extension/app/components/wallet/restore/steps/type/SelectWalletTypeStep.js b/packages/yoroi-extension/app/components/wallet/restore/steps/type/SelectWalletTypeStep.js index 08460cb2a1..2d6f3a879f 100644 --- a/packages/yoroi-extension/app/components/wallet/restore/steps/type/SelectWalletTypeStep.js +++ b/packages/yoroi-extension/app/components/wallet/restore/steps/type/SelectWalletTypeStep.js @@ -1,7 +1,6 @@ // @flow import type { Node, ComponentType } from 'react'; import type { $npm$ReactIntl$IntlShape } from 'react-intl'; -import type { RestoreModeType } from '../../../../../actions/common/wallet-restore-actions'; import { defineMessages, injectIntl } from 'react-intl'; import { observer } from 'mobx-react'; import { Stack, Box } from '@mui/material'; @@ -11,6 +10,7 @@ import twentyfourImg from '../../../../../assets/images/add-wallet/restore/24-wo import AddWalletCard from '../../../add-wallet-revamp/AddWalletCard'; import styles from './SelectWalletTypeStep.scss'; import globalMessages from '../../../../../i18n/global-messages'; +import type { RestoreModeType } from '../../../../../stores/toplevel/WalletRestoreStore'; const messages: * = defineMessages({ fifteenWords: { diff --git a/packages/yoroi-extension/app/containers/wallet/AddWalletPage.js b/packages/yoroi-extension/app/containers/wallet/AddWalletPage.js index 2709cc249d..edb96dde8f 100644 --- a/packages/yoroi-extension/app/containers/wallet/AddWalletPage.js +++ b/packages/yoroi-extension/app/containers/wallet/AddWalletPage.js @@ -2,7 +2,6 @@ import type { Node } from 'react'; import { Component } from 'react'; import type { StoresAndActionsProps } from '../../types/injectedProps.types'; -import type { RestoreModeType } from '../../actions/common/wallet-restore-actions'; import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; import { intlShape } from 'react-intl'; import { observer } from 'mobx-react'; @@ -25,6 +24,7 @@ import WalletTrezorConnectDialogContainer from './dialogs/WalletTrezorConnectDia import WalletLedgerConnectDialogContainer from './dialogs/WalletLedgerConnectDialogContainer'; import SidebarContainer from '../SidebarContainer'; import AddWalletPageRevamp from './AddWalletPageRevamp'; +import type { RestoreModeType } from '../../stores/toplevel/WalletRestoreStore'; @observer export default class AddWalletPage extends Component { diff --git a/packages/yoroi-extension/app/containers/wallet/dialogs/WalletRestoreDialogContainer.js b/packages/yoroi-extension/app/containers/wallet/dialogs/WalletRestoreDialogContainer.js index fef38acbc9..8df150a521 100644 --- a/packages/yoroi-extension/app/containers/wallet/dialogs/WalletRestoreDialogContainer.js +++ b/packages/yoroi-extension/app/containers/wallet/dialogs/WalletRestoreDialogContainer.js @@ -8,11 +8,9 @@ import validWords from 'bip39/src/wordlists/english.json'; import WalletRestoreDialog from '../../../components/wallet/WalletRestoreDialog'; import WalletRestoreVerifyDialog from '../../../components/wallet/WalletRestoreVerifyDialog'; import TransferSummaryPage from '../../../components/transfer/TransferSummaryPage'; -import LegacyExplanation from '../../../components/wallet/restore/LegacyExplanation'; import type { StoresAndActionsProps } from '../../../types/injectedProps.types'; import globalMessages from '../../../i18n/global-messages'; import { CheckAddressesInUseApiError, NoInputsError } from '../../../api/common/errors'; -import type { RestoreModeType, } from '../../../actions/common/wallet-restore-actions'; import { RestoreSteps } from '../../../stores/toplevel/WalletRestoreStore'; import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; import { defineMessages, intlShape } from 'react-intl'; @@ -27,6 +25,7 @@ import WalletAlreadyExistDialog from '../../../components/wallet/WalletAlreadyEx import NavPlate from '../../../components/topbar/NavPlate'; import WalletDetails from '../../../components/wallet/my-wallets/WalletDetails'; import { ROUTES } from '../../../routes-config'; +import type { RestoreModeType } from '../../../stores/toplevel/WalletRestoreStore'; const messages = defineMessages({ walletUpgradeNoop: { @@ -63,11 +62,13 @@ export default class WalletRestoreDialogContainer extends Component<{| ...Stores }; componentDidMount() { - this.props.actions.walletRestore.reset.trigger(); + this.props.stores.walletRestore.reset(); + this.props.stores.substores.ada.walletRestore.reset(); } componentWillUnmount() { - this.props.actions.walletRestore.reset.trigger(); + this.props.stores.walletRestore.reset(); + this.props.stores.substores.ada.walletRestore.reset(); } onCancel: void => void = () => { @@ -91,11 +92,8 @@ export default class WalletRestoreDialogContainer extends Component<{| ...Stores }; render(): null | Node { - const walletRestoreActions = this.props.actions.walletRestore; - const actions = this.props.actions; - const { uiNotifications } = this.props.stores; - const { walletRestore } = this.props.stores; - const { wallets } = this.props.stores; + const { stores } = this.props; + const { uiNotifications, walletRestore, wallets } = stores; const { restoreRequest } = wallets; const mode = this.props.mode; @@ -116,7 +114,7 @@ export default class WalletRestoreDialogContainer extends Component<{| ...Stores mnemonicValidator={mnemonic => walletRestore.isValidMnemonic({ mnemonic, mode })} validWords={validWords} numberOfMnemonics={wordsCount} - onSubmit={meta => actions.walletRestore.submitFields.trigger(meta)} + onSubmit={meta => stores.walletRestore.submitWalletRestoringFields(meta)} onCancel={this.onCancel} onBack={this.props.onBack} error={restoreRequest.error} @@ -131,7 +129,7 @@ export default class WalletRestoreDialogContainer extends Component<{| ...Stores throw new Error(`${nameof(WalletRestoreDialogContainer)} no duplicated wallet`); } const balance = duplicatedWallet.balance; - const rewards = this.props.stores.delegation.getRewardBalanceOrZero( + const rewards = stores.delegation.getRewardBalanceOrZero( duplicatedWallet ); @@ -149,15 +147,15 @@ export default class WalletRestoreDialogContainer extends Component<{| ...Stores walletAmount={balance} rewards={rewards} onUpdateHideBalance={this.updateHideBalance} - shouldHideBalance={this.props.stores.profile.shouldHideBalance} - getTokenInfo={genLookupOrFail(this.props.stores.tokenInfoStore.tokenInfo)} + shouldHideBalance={stores.profile.shouldHideBalance} + getTokenInfo={genLookupOrFail(stores.tokenInfoStore.tokenInfo)} isRefreshing={false} /> } openWallet={() => { this.openToTransactions(duplicatedWallet.publicDeriverId); }} - onCancel={walletRestoreActions.back.trigger} + onCancel={walletRestore.back} /> ); } @@ -179,15 +177,15 @@ export default class WalletRestoreDialogContainer extends Component<{| ...Stores { throw new Error('No explorer for wallet network'); })() } - onNext={actions.walletRestore.verifyMnemonic.trigger} - onCancel={walletRestoreActions.back.trigger} + onNext={stores.walletRestore.verifyMnemonic} + onCancel={walletRestore.back} onCopyAddressTooltip={(address, elementId) => { if (!uiNotifications.isOpen(elementId)) { runInAction(() => { @@ -206,17 +204,6 @@ export default class WalletRestoreDialogContainer extends Component<{| ...Stores /> ); } - case RestoreSteps.LEGACY_EXPLANATION: { - return ( - - ); - } case RestoreSteps.TRANSFER_TX_GEN: { return this._transferDialogContent(); } @@ -228,7 +215,7 @@ export default class WalletRestoreDialogContainer extends Component<{| ...Stores _transferDialogContent(): null | Node { const { yoroiTransfer } = this.props.stores; - const walletRestoreActions = this.props.actions.walletRestore; + const walletRestore = this.props.stores.substores.ada.walletRestore; const { intl } = this.context; switch (yoroiTransfer.status) { @@ -259,7 +246,7 @@ export default class WalletRestoreDialogContainer extends Component<{| ...Stores getTokenInfo={genLookupOrFail(this.props.stores.tokenInfoStore.tokenInfo)} onSubmit={{ label: intl.formatMessage(globalMessages.nextButtonLabel), - trigger: walletRestoreActions.transferFromLegacy.trigger, + trigger: walletRestore.transferFromLegacy, }} isSubmitting={this.props.stores.wallets.sendMoneyRequest.isExecuting} onCancel={{ @@ -295,7 +282,7 @@ export default class WalletRestoreDialogContainer extends Component<{| ...Stores text={intl.formatMessage(messages.walletUpgradeNoop)} closeInfo={{ closeLabel: intl.formatMessage(globalMessages.continue), - onClose: walletRestoreActions.startRestore.trigger, + onClose: walletRestore.startWalletRestore, }} /> ); diff --git a/packages/yoroi-extension/app/containers/wallet/restore/RestoreWalletPage.js b/packages/yoroi-extension/app/containers/wallet/restore/RestoreWalletPage.js index 089327adc0..4f02983b8f 100644 --- a/packages/yoroi-extension/app/containers/wallet/restore/RestoreWalletPage.js +++ b/packages/yoroi-extension/app/containers/wallet/restore/RestoreWalletPage.js @@ -21,7 +21,7 @@ export default class RestoreWalletPage extends Component const restoreWalletPageComponent = ( this.props.actions.dialogs.open.trigger({ dialog })} diff --git a/packages/yoroi-extension/app/stores/ada/AdaWalletRestoreStore.js b/packages/yoroi-extension/app/stores/ada/AdaWalletRestoreStore.js index 795fbbfad9..799a8645f9 100644 --- a/packages/yoroi-extension/app/stores/ada/AdaWalletRestoreStore.js +++ b/packages/yoroi-extension/app/stores/ada/AdaWalletRestoreStore.js @@ -16,27 +16,22 @@ export default class AdaWalletRestoreStore extends Store setup(): void { super.setup(); this.reset(); - const actions = this.actions.walletRestore; - actions.transferFromLegacy.listen(this._transferFromLegacy); - actions.startRestore.listen(this._restoreToDb); - actions.restoreWallet.listen(this._restoreWallet); - actions.reset.listen(this.reset); } - _transferFromLegacy: void => Promise = async () => { + transferFromLegacy: void => Promise = async () => { const phrase = this.stores.walletRestore.recoveryResult?.phrase; if (phrase == null) { throw new Error( - `${nameof(this._transferFromLegacy)} no recovery phrase set. Should never happen` + `${nameof(this.transferFromLegacy)} no recovery phrase set. Should never happen` ); } const network = this.stores.profile.selectedNetwork; if (network == null) { - throw new Error(`${nameof(this._transferFromLegacy)} no network selected`); + throw new Error(`${nameof(this.transferFromLegacy)} no network selected`); } await this.stores.yoroiTransfer.transferFunds({ next: async () => { - await this._restoreToDb(); + await this.startWalletRestore(); }, network, getDestinationAddress: () => Promise.resolve(this._getFirstCip1852InternalAddr()), @@ -50,31 +45,31 @@ export default class AdaWalletRestoreStore extends Store throw new ApiMethodNotYetImplementedError(); }; - _restoreToDb: void => Promise = async () => { + startWalletRestore: void => Promise = async () => { if ( this.stores.walletRestore.recoveryResult == null || this.stores.walletRestore.walletRestoreMeta == null ) { throw new Error( `${nameof( - this._restoreToDb + this.startWalletRestore )} Cannot submit wallet restoration! No values are available in context!` ); } const { phrase } = this.stores.walletRestore.recoveryResult; const { walletName, walletPassword } = this.stores.walletRestore.walletRestoreMeta; - await this._restoreWallet({ walletName, walletPassword, recoveryPhrase: phrase }); + await this.restoreWallet({ walletName, walletPassword, recoveryPhrase: phrase }); }; - _restoreWallet: ({| + restoreWallet: ({| walletName: string, walletPassword: string, recoveryPhrase: string, |}) => Promise = async ({ walletName, walletPassword, recoveryPhrase }) => { const { selectedNetwork } = this.stores.profile; if (selectedNetwork == null) - throw new Error(`${nameof(this._restoreToDb)} no network selected`); + throw new Error(`${nameof(this.startWalletRestore)} no network selected`); const accountIndex = this.stores.walletRestore.selectedAccount; diff --git a/packages/yoroi-extension/app/stores/toplevel/WalletRestoreStore.js b/packages/yoroi-extension/app/stores/toplevel/WalletRestoreStore.js index 01cc088c61..4093570e6a 100644 --- a/packages/yoroi-extension/app/stores/toplevel/WalletRestoreStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/WalletRestoreStore.js @@ -3,7 +3,6 @@ import { action, observable, runInAction } from 'mobx'; import Store from '../base/Store'; -import type { RestoreModeType, WalletRestoreMeta, } from '../../actions/common/wallet-restore-actions'; import type { PlateResponse } from '../../api/ada/lib/cardanoCrypto/plate'; import { generateShelleyPlate } from '../../api/ada/lib/cardanoCrypto/plate'; import { CoinTypes, HARD_DERIVATION_START, WalletTypePurpose } from '../../config/numbersConfig'; @@ -19,6 +18,7 @@ import type { StoresMap } from '../index'; import AdaApi from '../../api/ada'; import type { WalletState } from '../../../chrome/extension/background/types'; import { bytesToHex } from '../../coreUtils'; +import config from '../../config'; const messages = defineMessages({ walletRestoreVerifyAccountIdLabel: { @@ -45,7 +45,6 @@ export const RestoreSteps = Object.freeze({ START: 0, WALLET_EXIST: 1, VERIFY_MNEMONIC: 2, - LEGACY_EXPLANATION: 3, TRANSFER_TX_GEN: 4, }); export type RestoreStepsType = $Values; @@ -85,6 +84,40 @@ export async function isWalletExist( } } +// BIP44 , PAPER +export type RestoreModeType = + | {| + type: 'bip44', + extra: void, + length: typeof config.wallets.WALLET_RECOVERY_PHRASE_WORD_COUNT, +|} + | {| + type: 'cip1852', + extra: void, + chain?: number, + length: + | typeof config.wallets.WALLET_RECOVERY_PHRASE_WORD_COUNT + | typeof config.wallets.DAEDALUS_SHELLEY_RECOVERY_PHRASE_WORD_COUNT, +|} + | {| + // note: we didn't allow paper wallet creation during the ITN + // but we did allow paper wallet restoration + type: 'bip44' | 'cip1852', + extra: 'paper', + length: typeof config.wallets.YOROI_PAPER_RECOVERY_PHRASE_WORD_COUNT, + chain?: number, +|} + | {| + type: 'bip44' | 'cip1852', + extra: 'ledger' | 'trezor', +|}; + +export type WalletRestoreMeta = {| + recoveryPhrase: string, + walletName: string, + walletPassword: string, +|}; + export default class AdaWalletRestoreStore extends Store { @observable selectedAccount: number = 0 + HARD_DERIVATION_START; @@ -103,31 +136,26 @@ export default class AdaWalletRestoreStore extends Store setup(): void { super.setup(); this.reset(); - const actions = this.actions.walletRestore; - actions.submitFields.listen(this._processRestoreMeta); - actions.verifyMnemonic.listen(this._verifyMnemonic); - actions.reset.listen(this.reset); - actions.back.listen(this._back); } @action - _verifyMnemonic: void => Promise = async () => { + verifyMnemonic: void => Promise = async () => { const { selectedNetwork } = this.stores.profile; if (selectedNetwork == null) - throw new Error(`${nameof(this._processRestoreMeta)} no network selected`); + throw new Error(`${nameof(this.submitWalletRestoringFields)} no network selected`); - await this.actions.walletRestore.startRestore.trigger(); + await this.stores.substores.ada.walletRestore.startWalletRestore(); }; @action - _processRestoreMeta: WalletRestoreMeta => Promise = async restoreMeta => { + submitWalletRestoringFields: WalletRestoreMeta => Promise = async restoreMeta => { this.walletRestoreMeta = restoreMeta; const resolvedRecoveryPhrase = restoreMeta.recoveryPhrase; const { selectedNetwork } = this.stores.profile; if (selectedNetwork == null) - throw new Error(`${nameof(this._processRestoreMeta)} no network selected`); + throw new Error(`${nameof(this.submitWalletRestoringFields)} no network selected`); const plates = generatePlates( resolvedRecoveryPhrase, @@ -164,14 +192,10 @@ export default class AdaWalletRestoreStore extends Store } @action - _back: void => void = () => { + back: void => void = () => { if (this.step === RestoreSteps.VERIFY_MNEMONIC || this.step === RestoreSteps.WALLET_EXIST) { this.recoveryResult = undefined; this.step = RestoreSteps.START; - return; - } - if (this.step === RestoreSteps.LEGACY_EXPLANATION) { - this.step = RestoreSteps.VERIFY_MNEMONIC; } }; From 85d2c79a1b4370e331f4c4d669dc1f251d4f2c8c Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Mon, 14 Oct 2024 18:40:30 +0300 Subject: [PATCH 35/76] removed memo actions --- packages/yoroi-extension/app/actions/index.js | 3 - .../app/actions/memos-actions.js | 20 --- .../categories/ExternalStorageSettingsPage.js | 2 +- .../settings/categories/OAuthDropboxPage.js | 5 +- .../app/containers/wallet/WalletSendPage.js | 8 +- .../containers/wallet/WalletSummaryPage.js | 22 +-- .../app/stores/toplevel/MemosStore.js | 141 ++---------------- .../app/stores/toplevel/WalletStore.js | 2 +- 8 files changed, 34 insertions(+), 169 deletions(-) delete mode 100644 packages/yoroi-extension/app/actions/memos-actions.js diff --git a/packages/yoroi-extension/app/actions/index.js b/packages/yoroi-extension/app/actions/index.js index 122941b0a9..58a3530eff 100644 --- a/packages/yoroi-extension/app/actions/index.js +++ b/packages/yoroi-extension/app/actions/index.js @@ -1,7 +1,6 @@ // @flow import WalletBackupActions from './wallet-backup-actions'; import DialogsActions from './dialogs-actions'; -import MemosActions from './memos-actions'; import TxBuilderActions from './common/tx-builder-actions'; import WalletSettingsActions from './common/wallet-settings-actions'; import ConnectorActionsMap from '../connector/actions/connector-actions'; @@ -11,7 +10,6 @@ export type ActionsMap = {| walletSettings: WalletSettingsActions, walletBackup: WalletBackupActions, dialogs: DialogsActions, - memos: MemosActions, connector: ConnectorActionsMap, |}; @@ -20,7 +18,6 @@ const actionsMap: ActionsMap = Object.freeze({ walletSettings: new WalletSettingsActions(), walletBackup: new WalletBackupActions(), dialogs: new DialogsActions(), - memos: new MemosActions(), connector: new ConnectorActionsMap(), }); diff --git a/packages/yoroi-extension/app/actions/memos-actions.js b/packages/yoroi-extension/app/actions/memos-actions.js deleted file mode 100644 index 81911c3c00..0000000000 --- a/packages/yoroi-extension/app/actions/memos-actions.js +++ /dev/null @@ -1,20 +0,0 @@ -// @flow -import { Action, AsyncAction } from './lib/Action'; -import type { SelectedExternalStorageProvider } from '../domain/ExternalStorage'; -import WalletTransaction from '../domain/WalletTransaction'; -import type { TxMemoTableUpsert, TxMemoPreLookupKey, TxMemoTablePreInsert } from '../api/ada/lib/storage/bridge/memos'; -import type { WalletState } from '../../chrome/extension/background/types'; - -// ======= MEMOS ACTIONS ======= - -export default class MemosActions { - updateExternalStorageProvider: AsyncAction = new AsyncAction(); - unsetExternalStorageProvider: AsyncAction = new AsyncAction(); - closeMemoDialog: Action = new Action(); - selectTransaction: Action<{| tx: WalletTransaction |}> = new Action(); - saveTxMemo: AsyncAction = new AsyncAction(); - updateTxMemo: AsyncAction = new AsyncAction(); - deleteTxMemo: AsyncAction = new AsyncAction(); - syncTxMemos: AsyncAction = new AsyncAction(); - downloadTxMemo: AsyncAction = new AsyncAction(); -} diff --git a/packages/yoroi-extension/app/containers/settings/categories/ExternalStorageSettingsPage.js b/packages/yoroi-extension/app/containers/settings/categories/ExternalStorageSettingsPage.js index 52985fabc6..24ca74133f 100644 --- a/packages/yoroi-extension/app/containers/settings/categories/ExternalStorageSettingsPage.js +++ b/packages/yoroi-extension/app/containers/settings/categories/ExternalStorageSettingsPage.js @@ -15,7 +15,7 @@ export default class ExternalStorageSettingsPage extends Component Promise = async () => { - await this.props.actions.memos.unsetExternalStorageProvider.trigger(); + await this.props.stores.memos.unsetExternalStorageProvider(); }; render(): Node { diff --git a/packages/yoroi-extension/app/containers/settings/categories/OAuthDropboxPage.js b/packages/yoroi-extension/app/containers/settings/categories/OAuthDropboxPage.js index dfd016ab8e..6998560079 100644 --- a/packages/yoroi-extension/app/containers/settings/categories/OAuthDropboxPage.js +++ b/packages/yoroi-extension/app/containers/settings/categories/OAuthDropboxPage.js @@ -7,7 +7,6 @@ import type { StoresAndActionsProps } from '../../../types/injectedProps.types'; import { ExternalStorageList } from '../../../domain/ExternalStorage'; type Props = {| - ...StoresAndActionsProps, match: {| params: {| token: string, @@ -19,10 +18,10 @@ type Props = {| |}; @observer -export default class OAuthDropboxPage extends Component { +export default class OAuthDropboxPage extends Component<{| ...Props, ...StoresAndActionsProps |}> { onLoad: string => Promise = async (token) => { - await this.props.actions.memos.updateExternalStorageProvider.trigger({ + await this.props.stores.memos.setExternalStorageProvider({ provider: ExternalStorageList.DROPBOX, token, }); diff --git a/packages/yoroi-extension/app/containers/wallet/WalletSendPage.js b/packages/yoroi-extension/app/containers/wallet/WalletSendPage.js index 775f075c8e..d6aba11a7c 100644 --- a/packages/yoroi-extension/app/containers/wallet/WalletSendPage.js +++ b/packages/yoroi-extension/app/containers/wallet/WalletSendPage.js @@ -91,7 +91,7 @@ export default class WalletSendPage extends Component { @action toggleShowMemo: void => void = () => { this.showMemo = !this.showMemo; - this.props.actions.memos.closeMemoDialog.trigger(); + this.props.stores.memos.closeMemoDialog(); }; openDialog: any => void = dialog => { @@ -407,12 +407,12 @@ export default class WalletSendPage extends Component { }; noCloudWarningDialog: void => Node = () => { - const { actions, stores } = this.props; + const { stores } = this.props; return ( { - actions.memos.closeMemoDialog.trigger(); + stores.memos.closeMemoDialog(); stores.app.goToRoute({ route: ROUTES.SETTINGS.EXTERNAL_STORAGE }); }} onAcknowledge={() => { diff --git a/packages/yoroi-extension/app/containers/wallet/WalletSummaryPage.js b/packages/yoroi-extension/app/containers/wallet/WalletSummaryPage.js index f049b9ffd7..b4f6658d80 100644 --- a/packages/yoroi-extension/app/containers/wallet/WalletSummaryPage.js +++ b/packages/yoroi-extension/app/containers/wallet/WalletSummaryPage.js @@ -105,7 +105,7 @@ export default class WalletSummaryPage extends Component this.showMemoDialog({ dialog: MemoNoExternalStorageDialog, continuation: () => { - actions.memos.selectTransaction.trigger({ tx: transaction }); + stores.memos.selectTransaction({ tx: transaction }); actions.dialogs.push.trigger({ dialog: AddMemoDialog }); }, }) @@ -114,7 +114,7 @@ export default class WalletSummaryPage extends Component this.showMemoDialog({ dialog: MemoNoExternalStorageDialog, continuation: () => { - actions.memos.selectTransaction.trigger({ tx: transaction }); + stores.memos.selectTransaction({ tx: transaction }); actions.dialogs.push.trigger({ dialog: EditMemoDialog }); }, }) @@ -203,9 +203,9 @@ export default class WalletSummaryPage extends Component return memos.selectedTransaction; })()} error={memos.error} - onCancel={actions.memos.closeMemoDialog.trigger} + onCancel={stores.memos.closeMemoDialog} onSubmit={values => { - return actions.memos.saveTxMemo.trigger(values); + return stores.memos.saveTxMemo(values); }} plateTextPart={selected.plate.TextPart} /> @@ -213,9 +213,9 @@ export default class WalletSummaryPage extends Component {uiDialogs.isOpen(MemoNoExternalStorageDialog) ? ( { - actions.memos.closeMemoDialog.trigger(); + stores.memos.closeMemoDialog(); stores.app.goToRoute({ route: ROUTES.SETTINGS.EXTERNAL_STORAGE }); }} onAcknowledge={() => { @@ -235,10 +235,10 @@ export default class WalletSummaryPage extends Component return memo; })()} error={memos.error} - onCancel={actions.memos.closeMemoDialog.trigger} + onCancel={stores.memos.closeMemoDialog} onClickDelete={this.openDeleteMemoDialog} onSubmit={values => { - return actions.memos.updateTxMemo.trigger(values); + return stores.memos.updateTxMemo(values); }} plateTextPart={selected.plate.TextPart} /> @@ -252,11 +252,11 @@ export default class WalletSummaryPage extends Component })()} error={memos.error} onCancel={() => { - actions.memos.closeMemoDialog.trigger(); + stores.memos.closeMemoDialog(); }} - onClose={actions.memos.closeMemoDialog.trigger} + onClose={stores.memos.closeMemoDialog} onDelete={txHash => { - return actions.memos.deleteTxMemo.trigger({ + return stores.memos.deleteTxMemo({ publicDeriverId: selected.publicDeriverId, plateTextPart: selected.plate.TextPart, txHash, diff --git a/packages/yoroi-extension/app/stores/toplevel/MemosStore.js b/packages/yoroi-extension/app/stores/toplevel/MemosStore.js index c3df2160bb..6dec7f0642 100644 --- a/packages/yoroi-extension/app/stores/toplevel/MemosStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/MemosStore.js @@ -10,15 +10,16 @@ import type { import type { TxMemoTableRow } from '../../api/ada/lib/storage/database/memos/tables'; import type { ProvidersType } from '../../api/externalStorage/index'; import type { - UploadExternalTxMemoFunc, DeleteExternalTxMemoFunc, - DownloadExternalTxMemoFunc, FetchFilenameExternalTxMemoFunc, - FetchFilenameExternalTxMemoResponse, FetchFolderExternalTxMemoFunc, + UploadExternalTxMemoFunc, + DeleteExternalTxMemoFunc, + DownloadExternalTxMemoFunc, + FetchFilenameExternalTxMemoFunc, + FetchFolderExternalTxMemoFunc, CreateFolderExternalTxMemoFunc } from '../../api/externalStorage/providers/IProvider.types'; import type { SelectedExternalStorageProvider } from '../../domain/ExternalStorage'; import type { ActionsMap } from '../../actions/index'; import type { StoresMap } from '../index'; -import type { WalletState } from '../../../chrome/extension/background/types'; import { getAllTxMemos, deleteTxMemo, @@ -81,15 +82,6 @@ export default class MemosStore extends Store { txMemoMap: Map = new Map(); setup(): void { - this.actions.memos.updateExternalStorageProvider.listen(this._setExternalStorageProvider); - this.actions.memos.unsetExternalStorageProvider.listen(this._unsetExternalStorageProvider); - this.actions.memos.closeMemoDialog.listen(this._closeMemoDialog); - this.actions.memos.selectTransaction.listen(this._selectTransaction); - this.actions.memos.saveTxMemo.listen(this._saveTxMemo); - this.actions.memos.updateTxMemo.listen(this._updateTxMemo); - this.actions.memos.deleteTxMemo.listen(this._deleteTxMemo); - this.actions.memos.syncTxMemos.listen(this._syncTxMemos); - this.actions.memos.downloadTxMemo.listen(this._downloadAndSaveTxMemo); this.api.externalStorage.setup(); this.registerReactions([ this._setSelectedProvider, @@ -137,14 +129,14 @@ export default class MemosStore extends Store { // ========== Selected External Storage ========== // - @action _setExternalStorageProvider: SelectedExternalStorageProvider => Promise = async ( + @action setExternalStorageProvider: SelectedExternalStorageProvider => Promise = async ( provider ) => { await this.setExternalStorageProviderRequest.execute(provider); await this.getExternalStorageProviderRequest.execute(); // eagerly cache }; - @action _unsetExternalStorageProvider: void => Promise = async () => { + @action unsetExternalStorageProvider: void => Promise = async () => { await this.unsetExternalStorageProviderRequest.execute(); await this.getExternalStorageProviderRequest.execute(); // eagerly cache // Revoke current token @@ -167,12 +159,12 @@ export default class MemosStore extends Store { ); } - @action _closeMemoDialog: void => void = () => { + @action closeMemoDialog: void => void = () => { this._setError(null); this.actions.dialogs.closeActiveDialog.trigger(); } - @action _selectTransaction: {| tx: WalletTransaction |} => void = (params) => { + @action selectTransaction: {| tx: WalletTransaction |} => void = (params) => { this.selectedTransaction = params.tx; } @@ -180,7 +172,7 @@ export default class MemosStore extends Store { this.error = error; } - @action _saveTxMemo: TxMemoTablePreInsert => Promise = async (request) => { + @action saveTxMemo: TxMemoTablePreInsert => Promise = async (request) => { const walletId = request.plateTextPart; const memo = { ...request.memo, @@ -197,10 +189,10 @@ export default class MemosStore extends Store { runInAction(() => { this.txMemoMap.get(walletId)?.set(request.memo.TransactionHash, savedMemo); }); - this._closeMemoDialog(); + this.closeMemoDialog(); }; - @action _updateTxMemo: TxMemoTableUpsert => Promise = async (request) => { + @action updateTxMemo: TxMemoTableUpsert => Promise = async (request) => { const walletId = request.plateTextPart; const memo = { ...request.memo, @@ -217,10 +209,10 @@ export default class MemosStore extends Store { runInAction(() => { this.txMemoMap.get(walletId)?.set(request.memo.TransactionHash, savedMemo); }); - this._closeMemoDialog(); + this.closeMemoDialog(); }; - @action _deleteTxMemo: TxMemoPreLookupKey => Promise = async (request) => { + @action deleteTxMemo: TxMemoPreLookupKey => Promise = async (request) => { const walletId = request.plateTextPart; const memoToDelete = { walletId, @@ -236,112 +228,9 @@ export default class MemosStore extends Store { runInAction(() => { this.txMemoMap.get(walletId)?.delete(request.txHash); }); - this._closeMemoDialog(); + this.closeMemoDialog(); }; - @action _downloadAndSaveTxMemo: TxMemoPreLookupKey => Promise = async ( - request - ) => { - if (this.hasSetSelectedExternalStorageProvider) { - const walletId = request.plateTextPart; - const memo = await this.downloadExternalTxMemoRequest.execute({ - walletId, - txHash: request.txHash, - }).promise; - if (memo == null) throw new Error('Should never happen'); - const memoRow = await upsertTxMemo({ - publicDeriverId: request.publicDeriverId, - memo: { - WalletId: walletId, - Content: memo.content, - TransactionHash: request.txHash, - LastUpdated: memo.lastUpdated - } - }); - - runInAction(() => { - this.txMemoMap.get(walletId)?.set(request.txHash, memoRow); - }); - } - }; - - @action _syncTxMemos: WalletState => Promise = async (publicDeriver) => { - if (this.hasSetSelectedExternalStorageProvider) { - // 1st check if root folder exists. If not, we create it - { - const rootFolderStatus = await this.fetchFolderExternalTxMemoRequest.execute({ - walletId: undefined - }).promise; - if (rootFolderStatus == null) return undefined; - if (rootFolderStatus === false) { - await this.createFolderExternalTxMemoRequest.execute({ walletId: undefined }); - } - } - - // 2nd check if wallet folder exists. If not, we create it - const walletId = publicDeriver.plate.TextPart; - { - // Check if wallet folder exists - const walletFolderStatus = await this.fetchFolderExternalTxMemoRequest.execute({ - walletId - }).promise; - if (walletFolderStatus == null) return undefined; - if (walletFolderStatus === false) { - await this.createFolderExternalTxMemoRequest.execute({ walletId }); - } - } - - // sync memos with remote - const memos = await this.fetchFilenamesExternalTxMemoRequest.execute({ walletId }).promise; - if (memos == null) return undefined; - await this._updateLocaleFromRemote({ - remoteResponse: memos, - publicDeriver, - }); - } - } - - _updateLocaleFromRemote: {| - remoteResponse: FetchFilenameExternalTxMemoResponse, - publicDeriver: WalletState, - |} => Promise = async (request) => { - const walletId = request.publicDeriver.plate.TextPart; - const txMemosForWallet = this.txMemoMap.get(walletId); - if (txMemosForWallet == null) return; // shouldn't happen - - for (const memo of request.remoteResponse) { - // check if memo already exists - const localMemo = txMemosForWallet.get(memo.tx); - if (localMemo != null) { - // delete local copy if file was deleted on external storage - if (memo.deleted === true) { - await deleteTxMemo({ - publicDeriverId: request.publicDeriver.publicDeriverId, - key: { - walletId, - txHash: memo.tx, - } - }); - } else if (localMemo.LastUpdated < memo.lastUpdated) { - // only update if the file is newer - await this._downloadAndSaveTxMemo({ - publicDeriverId: request.publicDeriver.publicDeriverId, - plateTextPart: request.publicDeriver.plate.TextPart, - txHash: memo.tx - }); - } - // our local version is more recent, so don't do anything - } else { - // save memo locally - await this._downloadAndSaveTxMemo({ - publicDeriverId: request.publicDeriver.publicDeriverId, - plateTextPart: request.publicDeriver.plate.TextPart, - txHash: memo.tx - }); - } - } - } - @computed get selectedProvider(): ?SelectedExternalStorageProvider { let { result } = this.getExternalStorageProviderRequest; if (result == null) { diff --git a/packages/yoroi-extension/app/stores/toplevel/WalletStore.js b/packages/yoroi-extension/app/stores/toplevel/WalletStore.js index 779ba44196..685dad9eeb 100644 --- a/packages/yoroi-extension/app/stores/toplevel/WalletStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/WalletStore.js @@ -379,7 +379,7 @@ export default class WalletStore extends Store { const memo = this.stores.transactionBuilderStore.memo; if (memo !== '' && memo !== undefined && request.plateTextPart) { try { - await this.actions.memos.saveTxMemo.trigger({ + await this.stores.memos.saveTxMemo({ publicDeriverId: request.publicDeriverId, plateTextPart: request.plateTextPart, memo: { From 5672d603fd3bc6b2747eb5af8e5c76deef899c05 Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Mon, 14 Oct 2024 19:00:47 +0300 Subject: [PATCH 36/76] removed wallet backup actions --- packages/yoroi-extension/app/actions/index.js | 3 -- .../app/actions/wallet-backup-actions.js | 24 ----------- .../dialogs/WalletBackupDialogContainer.js | 42 +++++++------------ .../app/stores/ada/AdaWalletsStore.js | 12 ++---- .../app/stores/toplevel/WalletBackupStore.js | 39 ++++++----------- 5 files changed, 30 insertions(+), 90 deletions(-) delete mode 100644 packages/yoroi-extension/app/actions/wallet-backup-actions.js diff --git a/packages/yoroi-extension/app/actions/index.js b/packages/yoroi-extension/app/actions/index.js index 58a3530eff..ad85c6715c 100644 --- a/packages/yoroi-extension/app/actions/index.js +++ b/packages/yoroi-extension/app/actions/index.js @@ -1,5 +1,4 @@ // @flow -import WalletBackupActions from './wallet-backup-actions'; import DialogsActions from './dialogs-actions'; import TxBuilderActions from './common/tx-builder-actions'; import WalletSettingsActions from './common/wallet-settings-actions'; @@ -8,7 +7,6 @@ import ConnectorActionsMap from '../connector/actions/connector-actions'; export type ActionsMap = {| txBuilderActions: TxBuilderActions, walletSettings: WalletSettingsActions, - walletBackup: WalletBackupActions, dialogs: DialogsActions, connector: ConnectorActionsMap, |}; @@ -16,7 +14,6 @@ export type ActionsMap = {| const actionsMap: ActionsMap = Object.freeze({ txBuilderActions: new TxBuilderActions(), walletSettings: new WalletSettingsActions(), - walletBackup: new WalletBackupActions(), dialogs: new DialogsActions(), connector: new ConnectorActionsMap(), }); diff --git a/packages/yoroi-extension/app/actions/wallet-backup-actions.js b/packages/yoroi-extension/app/actions/wallet-backup-actions.js deleted file mode 100644 index 09cc9ef833..0000000000 --- a/packages/yoroi-extension/app/actions/wallet-backup-actions.js +++ /dev/null @@ -1,24 +0,0 @@ -// @flow -import { AsyncAction, Action } from './lib/Action'; - -// ======= WALLET BACKUP ACTIONS ======= - -export default class WalletBackupActions { - startWalletBackup: Action = new Action(); - initiateWalletBackup: Action<{| - recoveryPhrase: Array, - name: string, - password: string, - |}> = new Action(); - continueToPrivacyWarning: Action = new Action(); - togglePrivacyNoticeForWalletBackup: Action = new Action(); - continueToRecoveryPhraseForWalletBackup: Action = new Action(); - addWordToWalletBackupVerification: Action<{| word: string, index: number |}> = new Action(); - clearEnteredRecoveryPhrase: Action = new Action(); - acceptWalletBackupTermDevice: Action = new Action(); - acceptWalletBackupTermRecovery: Action = new Action(); - restartWalletBackup: Action = new Action(); - cancelWalletBackup: Action = new Action(); - finishWalletBackup: AsyncAction = new AsyncAction(); - removeOneMnemonicWord: Action = new Action(); -} diff --git a/packages/yoroi-extension/app/containers/wallet/dialogs/WalletBackupDialogContainer.js b/packages/yoroi-extension/app/containers/wallet/dialogs/WalletBackupDialogContainer.js index 098f1c4081..b147f7f3e4 100644 --- a/packages/yoroi-extension/app/containers/wallet/dialogs/WalletBackupDialogContainer.js +++ b/packages/yoroi-extension/app/containers/wallet/dialogs/WalletBackupDialogContainer.js @@ -6,20 +6,19 @@ import WalletBackupDialog from '../../../components/wallet/WalletBackupDialog'; import type { StoresAndActionsProps } from '../../../types/injectedProps.types'; type Props = {| - ...StoresAndActionsProps, +onClose: void => void, |}; @observer -export default class WalletBackupDialogContainer extends Component { +export default class WalletBackupDialogContainer extends Component<{| ...Props, ...StoresAndActionsProps |}> { onCancelBackup: (() => void) = () => { this.props.onClose(); - this.props.actions.walletBackup.cancelWalletBackup.trigger(); + this.props.stores.walletBackup.cancelWalletBackup(); } render(): Node { - const { actions, stores } = this.props; + const { stores } = this.props; const { recoveryPhraseWords, enteredPhrase, @@ -31,19 +30,6 @@ export default class WalletBackupDialogContainer extends Component { isPrivacyNoticeAccepted, currentStep } = stores.walletBackup; - const { - startWalletBackup, - addWordToWalletBackupVerification, - clearEnteredRecoveryPhrase, - acceptWalletBackupTermDevice, - acceptWalletBackupTermRecovery, - restartWalletBackup, - finishWalletBackup, - removeOneMnemonicWord, - continueToPrivacyWarning, - togglePrivacyNoticeForWalletBackup, - continueToRecoveryPhraseForWalletBackup - } = actions.walletBackup; const { createWalletRequest } = stores.wallets; const hasWord = (enteredPhrase.length > 0); return ( @@ -55,12 +41,12 @@ export default class WalletBackupDialogContainer extends Component { canPhraseBeShown={isPrivacyNoticeAccepted && countdownRemaining === 0} isPrivacyNoticeAccepted={isPrivacyNoticeAccepted} countdownRemaining={countdownRemaining} - togglePrivacyNotice={togglePrivacyNoticeForWalletBackup.trigger} - onBack={continueToPrivacyWarning.trigger} - onContinue={continueToRecoveryPhraseForWalletBackup.trigger} + togglePrivacyNotice={stores.walletBackup.togglePrivacyNoticeForWalletBackup} + onBack={stores.walletBackup.continueToPrivacyWarning} + onContinue={stores.walletBackup.continueToRecoveryPhraseForWalletBackup} // Props for WalletRecoveryPhraseDisplayDialog recoveryPhrase={recoveryPhraseWords.reduce((phrase, { word }) => `${phrase} ${word}`, '')} - onStartWalletBackup={startWalletBackup.trigger} + onStartWalletBackup={stores.walletBackup.startWalletBackup} // Props for WalletRecoveryPhraseEntryDialog isTermDeviceAccepted={isTermDeviceAccepted} enteredPhrase={enteredPhrase} @@ -68,15 +54,15 @@ export default class WalletBackupDialogContainer extends Component { isTermRecoveryAccepted={isTermRecoveryAccepted} isValid={isRecoveryPhraseValid} isSubmitting={createWalletRequest.isExecuting} - onAcceptTermDevice={acceptWalletBackupTermDevice.trigger} - onAcceptTermRecovery={acceptWalletBackupTermRecovery.trigger} - onAddWord={addWordToWalletBackupVerification.trigger} - onClear={clearEnteredRecoveryPhrase.trigger} - onFinishBackup={finishWalletBackup.trigger} + onAcceptTermDevice={stores.walletBackup.acceptWalletBackupTermDevice} + onAcceptTermRecovery={stores.walletBackup.acceptWalletBackupTermRecovery} + onAddWord={stores.walletBackup.addWordToWalletBackupVerification} + onClear={stores.walletBackup.clearEnteredRecoveryPhrase} + onFinishBackup={stores.substores.ada.wallets.finishWalletBackup} removeWord={() => { - removeOneMnemonicWord.trigger(); + stores.walletBackup.removeOneMnemonicWord(); }} - onRestartBackup={restartWalletBackup.trigger} + onRestartBackup={stores.walletBackup.restartWalletBackup} recoveryPhraseSorted={recoveryPhraseSorted} /> ); diff --git a/packages/yoroi-extension/app/stores/ada/AdaWalletsStore.js b/packages/yoroi-extension/app/stores/ada/AdaWalletsStore.js index d179aee30d..f8baef3655 100644 --- a/packages/yoroi-extension/app/stores/ada/AdaWalletsStore.js +++ b/packages/yoroi-extension/app/stores/ada/AdaWalletsStore.js @@ -27,12 +27,6 @@ export default class AdaWalletsStore extends Store { this.api.ada.generateWalletRecoveryPhrase ); - setup(): void { - super.setup(); - const { walletBackup } = this.actions; - walletBackup.finishWalletBackup.listen(this._createInDb); - } - // =================== SEND MONEY ==================== // adaSendAndRefresh: ({| @@ -231,7 +225,7 @@ export default class AdaWalletsStore extends Store { if (recoveryPhrase == null) { throw new Error(`${nameof(this.startWalletCreation)} failed to generate recovery phrase`); } - this.actions.walletBackup.initiateWalletBackup.trigger({ + this.stores.walletBackup.initiateWalletBackup({ recoveryPhrase, name: params.name, password: params.password, @@ -249,7 +243,7 @@ export default class AdaWalletsStore extends Store { }; /** Create the wallet and go to wallet summary screen */ - _createInDb: void => Promise = async () => { + finishWalletBackup: void => Promise = async () => { await this.createWallet({ recoveryPhrase: this.stores.walletBackup.recoveryPhrase, walletPassword: this.stores.walletBackup.password, @@ -263,7 +257,7 @@ export default class AdaWalletsStore extends Store { walletName: string, |} => Promise = async (request) => { const { selectedNetwork } = this.stores.profile; - if (selectedNetwork == null) throw new Error(`${nameof(this._createInDb)} no network selected`); + if (selectedNetwork == null) throw new Error(`${nameof(this.finishWalletBackup)} no network selected`); await this.stores.wallets.createWalletRequest.execute(async () => { const wallet = await createWallet({ walletName: request.walletName, diff --git a/packages/yoroi-extension/app/stores/toplevel/WalletBackupStore.js b/packages/yoroi-extension/app/stores/toplevel/WalletBackupStore.js index dcb9b19348..d51840a3e5 100644 --- a/packages/yoroi-extension/app/stores/toplevel/WalletBackupStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/WalletBackupStore.js @@ -46,22 +46,9 @@ class WalletBackupStore extends Store { setup(): void { super.setup(); this._reset(); - const a = this.actions.walletBackup; - a.initiateWalletBackup.listen(this._initiateWalletBackup); - a.continueToPrivacyWarning.listen(this._continueToPrivacyWarning); - a.togglePrivacyNoticeForWalletBackup.listen(this._togglePrivacyNoticeForWalletBackup); - a.continueToRecoveryPhraseForWalletBackup.listen(this._continueToRecoveryPhraseForWalletBackup); - a.startWalletBackup.listen(this._startWalletBackup); - a.addWordToWalletBackupVerification.listen(this._addWordToWalletBackupVerification); - a.clearEnteredRecoveryPhrase.listen(this._clearEnteredRecoveryPhrase); - a.acceptWalletBackupTermDevice.listen(this._acceptWalletBackupTermDevice); - a.acceptWalletBackupTermRecovery.listen(this._acceptWalletBackupTermRecovery); - a.restartWalletBackup.listen(this._restartWalletBackup); - a.cancelWalletBackup.listen(this._cancelWalletBackup); - a.removeOneMnemonicWord.listen(this._removeOneWord); } - @action _initiateWalletBackup: {| + @action initiateWalletBackup: {| recoveryPhrase: Array, name: string, password: string, @@ -96,23 +83,23 @@ class WalletBackupStore extends Store { }); }; - @action _continueToPrivacyWarning: void => void = () => { + @action continueToPrivacyWarning: void => void = () => { this.currentStep = 'privacyWarning'; }; - @action _togglePrivacyNoticeForWalletBackup: void => void = () => { + @action togglePrivacyNoticeForWalletBackup: void => void = () => { this.isPrivacyNoticeAccepted = !this.isPrivacyNoticeAccepted; }; - @action _continueToRecoveryPhraseForWalletBackup: void => void = () => { + @action continueToRecoveryPhraseForWalletBackup: void => void = () => { this.currentStep = 'recoveryPhraseDisplay'; }; - @action _startWalletBackup: void => void = () => { + @action startWalletBackup: void => void = () => { this.currentStep = 'recoveryPhraseEntry'; }; - @action _addWordToWalletBackupVerification: {| + @action addWordToWalletBackupVerification: {| word: string, index: number |} => void = (params) => { @@ -122,14 +109,14 @@ class WalletBackupStore extends Store { if (pickedWord && pickedWord.word === word) pickedWord.isActive = false; }; - @action _clearEnteredRecoveryPhrase: void => void = () => { + @action clearEnteredRecoveryPhrase: void => void = () => { this.enteredPhrase = []; this.recoveryPhraseSorted = this.recoveryPhraseSorted.map( ({ word }) => ({ word, isActive: true }) ); }; - @action _removeOneWord: void => void = () => { + @action removeOneMnemonicWord: void => void = () => { if (!this.enteredPhrase) { return; } @@ -144,20 +131,20 @@ class WalletBackupStore extends Store { ); } - @action _acceptWalletBackupTermDevice: void => void = () => { + @action acceptWalletBackupTermDevice: void => void = () => { this.isTermDeviceAccepted = true; }; - @action _acceptWalletBackupTermRecovery: void => void = () => { + @action acceptWalletBackupTermRecovery: void => void = () => { this.isTermRecoveryAccepted = true; }; - @action _restartWalletBackup: void => void = () => { - this._clearEnteredRecoveryPhrase(); + @action restartWalletBackup: void => void = () => { + this.clearEnteredRecoveryPhrase(); this.currentStep = 'recoveryPhraseDisplay'; }; - @action _cancelWalletBackup: void => void = () => { + @action cancelWalletBackup: void => void = () => { this.teardown(); }; From 406c6ee5009fe50927164d7484b409900d84d7bc Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Mon, 14 Oct 2024 19:13:27 +0300 Subject: [PATCH 37/76] removed wallet settings actions --- .../actions/common/wallet-settings-actions.js | 27 ------------- packages/yoroi-extension/app/actions/index.js | 3 -- .../categories/RemoveWalletDialogContainer.js | 3 +- .../categories/ResyncWalletDialogContainer.js | 5 +-- .../settings/categories/WalletSettingsPage.js | 18 +++------ .../ChangeWalletPasswordDialogContainer.js | 10 ++--- .../stores/toplevel/WalletSettingsStore.js | 39 ++++--------------- 7 files changed, 20 insertions(+), 85 deletions(-) delete mode 100644 packages/yoroi-extension/app/actions/common/wallet-settings-actions.js diff --git a/packages/yoroi-extension/app/actions/common/wallet-settings-actions.js b/packages/yoroi-extension/app/actions/common/wallet-settings-actions.js deleted file mode 100644 index 71bcabb5e6..0000000000 --- a/packages/yoroi-extension/app/actions/common/wallet-settings-actions.js +++ /dev/null @@ -1,27 +0,0 @@ -// @flow -import { AsyncAction, Action } from '../lib/Action'; - -export default class WalletSettingsActions { - cancelEditingWalletField: Action = new Action(); - startEditingWalletField: Action<{| field: string |}> = new Action(); - stopEditingWalletField: Action = new Action(); - renamePublicDeriver: AsyncAction<{| - publicDeriverId: number, - newName: string, - |}> = new AsyncAction(); - renameConceptualWallet: AsyncAction<{| - conceptualWalletId: number, - newName: string, - |}> = new AsyncAction(); - updateSigningPassword: AsyncAction<{| - publicDeriverId: number, - oldPassword: string, - newPassword: string - |}> = new AsyncAction(); - resyncHistory: AsyncAction<{| - publicDeriverId: number, - |}> = new AsyncAction(); - removeWallet: AsyncAction<{| - publicDeriverId: number, - |}> = new AsyncAction(); -} diff --git a/packages/yoroi-extension/app/actions/index.js b/packages/yoroi-extension/app/actions/index.js index ad85c6715c..e02231b7c7 100644 --- a/packages/yoroi-extension/app/actions/index.js +++ b/packages/yoroi-extension/app/actions/index.js @@ -1,19 +1,16 @@ // @flow import DialogsActions from './dialogs-actions'; import TxBuilderActions from './common/tx-builder-actions'; -import WalletSettingsActions from './common/wallet-settings-actions'; import ConnectorActionsMap from '../connector/actions/connector-actions'; export type ActionsMap = {| txBuilderActions: TxBuilderActions, - walletSettings: WalletSettingsActions, dialogs: DialogsActions, connector: ConnectorActionsMap, |}; const actionsMap: ActionsMap = Object.freeze({ txBuilderActions: new TxBuilderActions(), - walletSettings: new WalletSettingsActions(), dialogs: new DialogsActions(), connector: new ConnectorActionsMap(), }); diff --git a/packages/yoroi-extension/app/containers/settings/categories/RemoveWalletDialogContainer.js b/packages/yoroi-extension/app/containers/settings/categories/RemoveWalletDialogContainer.js index 271daff264..599db98e09 100644 --- a/packages/yoroi-extension/app/containers/settings/categories/RemoveWalletDialogContainer.js +++ b/packages/yoroi-extension/app/containers/settings/categories/RemoveWalletDialogContainer.js @@ -50,7 +50,6 @@ export default class RemoveWalletDialogContainer extends Component { removeWalletRevamp: void => Promise = async () => { const { stores } = this.props; - const settingsActions = this.props.actions.walletSettings; const selectedWalletId = this.props.publicDeriverId; const walletsNavigation = stores.profile.walletsNavigation; @@ -63,7 +62,7 @@ export default class RemoveWalletDialogContainer extends Component { }; await stores.profile.updateSortedWalletList(newWalletsNavigation); - settingsActions.removeWallet.trigger({ + stores.walletSettings.removeWallet({ publicDeriverId: this.props.publicDeriverId, }); }; diff --git a/packages/yoroi-extension/app/containers/settings/categories/ResyncWalletDialogContainer.js b/packages/yoroi-extension/app/containers/settings/categories/ResyncWalletDialogContainer.js index 3411cf5887..7db544c9d2 100644 --- a/packages/yoroi-extension/app/containers/settings/categories/ResyncWalletDialogContainer.js +++ b/packages/yoroi-extension/app/containers/settings/categories/ResyncWalletDialogContainer.js @@ -11,7 +11,6 @@ import globalMessages from '../../../i18n/global-messages'; import DangerousActionDialog from '../../../components/widgets/DangerousActionDialog'; type Props = {| - ...StoresAndActionsProps, publicDeriverId: number, |}; @@ -24,7 +23,7 @@ const dialogMessages = defineMessages({ }); @observer -export default class ResyncWalletDialogContainer extends Component { +export default class ResyncWalletDialogContainer extends Component<{| ...Props, ...StoresAndActionsProps |}> { static contextTypes: {| intl: $npm$ReactIntl$IntlFormat |} = { intl: intlShape.isRequired, }; @@ -57,7 +56,7 @@ export default class ResyncWalletDialogContainer extends Component { label: intl.formatMessage(globalMessages.resyncButtonLabel), danger: false, onClick: async () => { - await this.props.actions.walletSettings.resyncHistory.trigger({ + await this.props.stores.walletSettings.resyncHistory({ publicDeriverId: this.props.publicDeriverId, }); this.props.actions.dialogs.closeActiveDialog.trigger(); diff --git a/packages/yoroi-extension/app/containers/settings/categories/WalletSettingsPage.js b/packages/yoroi-extension/app/containers/settings/categories/WalletSettingsPage.js index 1dd865c5a7..b858adb295 100644 --- a/packages/yoroi-extension/app/containers/settings/categories/WalletSettingsPage.js +++ b/packages/yoroi-extension/app/containers/settings/categories/WalletSettingsPage.js @@ -26,16 +26,10 @@ export default class WalletSettingsPage extends Component { if (field === 'name') { - await renameConceptualWallet.trigger({ + await stores.walletSettings.renameConceptualWallet({ conceptualWalletId: selectedWallet.conceptualWalletId, newName: value, }); } }} - onStartEditing={field => startEditingWalletField.trigger({ field })} - onStopEditing={() => stopEditingWalletField.trigger()} - onCancelEditing={() => cancelEditingWalletField.trigger()} + onStartEditing={field => stores.walletSettings.startEditingWalletField({ field })} + onStopEditing={() => stores.walletSettings.stopEditingWalletField()} + onCancelEditing={() => stores.walletSettings.cancelEditingWalletField()} activeField={walletFieldBeingEdited} nameValidator={name => isValidWalletName(name)} /> diff --git a/packages/yoroi-extension/app/containers/wallet/dialogs/ChangeWalletPasswordDialogContainer.js b/packages/yoroi-extension/app/containers/wallet/dialogs/ChangeWalletPasswordDialogContainer.js index 6cc443ce0e..14341eba69 100644 --- a/packages/yoroi-extension/app/containers/wallet/dialogs/ChangeWalletPasswordDialogContainer.js +++ b/packages/yoroi-extension/app/containers/wallet/dialogs/ChangeWalletPasswordDialogContainer.js @@ -6,17 +6,15 @@ import ChangeWalletPasswordDialog from '../../../components/wallet/settings/Chan import type { StoresAndActionsProps } from '../../../types/injectedProps.types'; type Props = {| - ...StoresAndActionsProps, publicDeriverId: number, |}; @observer -export default class ChangeWalletPasswordDialogContainer extends Component { +export default class ChangeWalletPasswordDialogContainer extends Component<{| ...Props, ...StoresAndActionsProps |}> { render(): Node { - const { actions } = this.props; - const { uiDialogs } = this.props.stores; - const { walletSettings } = this.props.stores; + const { actions, stores } = this.props; + const { uiDialogs, walletSettings } = stores; const { updateDataForActiveDialog } = actions.dialogs; const { changeSigningKeyRequest } = walletSettings; @@ -29,7 +27,7 @@ export default class ChangeWalletPasswordDialogContainer extends Component { const { oldPassword, newPassword } = values; - await actions.walletSettings.updateSigningPassword.trigger({ + await stores.walletSettings.updateSigningPassword({ publicDeriverId: this.props.publicDeriverId, oldPassword, newPassword diff --git a/packages/yoroi-extension/app/stores/toplevel/WalletSettingsStore.js b/packages/yoroi-extension/app/stores/toplevel/WalletSettingsStore.js index 58fca43198..2b4e5888f8 100644 --- a/packages/yoroi-extension/app/stores/toplevel/WalletSettingsStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/WalletSettingsStore.js @@ -10,7 +10,6 @@ import type { StoresMap } from '../index'; import { removeWalletFromDb, changeSigningKeyPassword, - renamePublicDeriver, renameConceptualWallet, resyncWallet, removeAllTransactions, @@ -48,38 +47,25 @@ export default class WalletSettingsStore extends Store { throw new Error(`${nameof(WalletSettingsStore)}::${nameof(this.getWalletWarnings)} no warning list found`); } - setup(): void { - super.setup(); - const a = this.actions.walletSettings; - a.startEditingWalletField.listen(this._startEditingWalletField); - a.stopEditingWalletField.listen(this._stopEditingWalletField); - a.cancelEditingWalletField.listen(this._cancelEditingWalletField); - a.renamePublicDeriver.listen(this._renamePublicDeriver); - a.renameConceptualWallet.listen(this._renameConceptualWallet); - a.updateSigningPassword.listen(this._changeSigningPassword); - a.resyncHistory.listen(this._resyncHistory); - a.removeWallet.listen(this._removeWallet); - } - - @action _startEditingWalletField: {| field: string |} => void = ( + @action startEditingWalletField: {| field: string |} => void = ( { field } ) => { this.walletFieldBeingEdited = field; }; - @action _stopEditingWalletField: void => void = () => { + @action stopEditingWalletField: void => void = () => { if (this.walletFieldBeingEdited != null) { this.lastUpdatedWalletField = this.walletFieldBeingEdited; } this.walletFieldBeingEdited = null; }; - @action _cancelEditingWalletField: void => void = () => { + @action cancelEditingWalletField: void => void = () => { this.lastUpdatedWalletField = null; this.walletFieldBeingEdited = null; }; - @action _changeSigningPassword: {| + @action updateSigningPassword: {| publicDeriverId: number, oldPassword: string, newPassword: string @@ -91,18 +77,7 @@ export default class WalletSettingsStore extends Store { this.changeSigningKeyRequest.reset(); }; - @action _renamePublicDeriver: {| - publicDeriverId: number, - newName: string - |} => Promise = async (request) => { - // update the meta-parameters in the internal wallet representation - await this.renameModelRequest.execute(async () => { - await renamePublicDeriver(request); - }); - //fixme: update memory directly? - }; - - _renameConceptualWallet: {| + renameConceptualWallet: {| conceptualWalletId: number, newName: string |} => Promise = async (request) => { @@ -113,7 +88,7 @@ export default class WalletSettingsStore extends Store { }); }; - @action _resyncHistory: {| + @action resyncHistory: {| publicDeriverId: number, |} => Promise = async (request) => { this.clearHistory.reset(); @@ -129,7 +104,7 @@ export default class WalletSettingsStore extends Store { }).promise; }; - @action _removeWallet: {| + @action removeWallet: {| publicDeriverId: number, |} => Promise = async (request) => { this.removeWalletRequest.reset(); From c1a8511d771fd585fb9c16fbb2563b7c719a1ded Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Mon, 14 Oct 2024 19:38:49 +0300 Subject: [PATCH 38/76] removed tx builder actions --- .../app/actions/common/tx-builder-actions.js | 29 -------- packages/yoroi-extension/app/actions/index.js | 3 - .../transfer/UnmangleTxDialogContainer.js | 8 +-- .../app/containers/wallet/WalletSendPage.js | 35 +++++---- .../toplevel/TransactionBuilderStore.js | 71 ++++++++----------- 5 files changed, 48 insertions(+), 98 deletions(-) delete mode 100644 packages/yoroi-extension/app/actions/common/tx-builder-actions.js diff --git a/packages/yoroi-extension/app/actions/common/tx-builder-actions.js b/packages/yoroi-extension/app/actions/common/tx-builder-actions.js deleted file mode 100644 index 547e2f1c7f..0000000000 --- a/packages/yoroi-extension/app/actions/common/tx-builder-actions.js +++ /dev/null @@ -1,29 +0,0 @@ -// @flow -import { Action, AsyncAction } from '../lib/Action'; -import type { - IGetAllUtxosResponse, -} from '../../api/ada/lib/storage/models/PublicDeriver/interfaces'; -import type { SetupSelfTxRequest } from '../../stores/toplevel/TransactionBuilderStore'; -import type { TransactionMetadata } from '../../api/ada/lib/storage/bridge/metadataUtils'; -import type { TokenRow, } from '../../api/ada/lib/storage/database/primitives/tables'; -import BigNumber from 'bignumber.js'; - -export default class TxBuilderActions { - updateReceiver: Action = new Action(); - updateAmount: Action = new Action(); - updateMemo: Action = new Action(); - addToken: Action<{| - token?: $ReadOnly, - shouldSendAll?: boolean, - shouldReset?: boolean, - |}> = new Action(); - calculateMaxAmount: AsyncAction = new AsyncAction(); - deselectToken: Action = new Action(); - removeTokens: Action>> = new Action(); - updateTentativeTx: Action = new Action(); - setFilter: Action<(ElementOf => boolean)> = new Action(); - updateMetadata: Action | void> = new Action(); - updateSendAllStatus: Action = new Action(); - initialize: AsyncAction = new AsyncAction(); - reset: Action = new Action(); -} diff --git a/packages/yoroi-extension/app/actions/index.js b/packages/yoroi-extension/app/actions/index.js index e02231b7c7..b4eeb0db93 100644 --- a/packages/yoroi-extension/app/actions/index.js +++ b/packages/yoroi-extension/app/actions/index.js @@ -1,16 +1,13 @@ // @flow import DialogsActions from './dialogs-actions'; -import TxBuilderActions from './common/tx-builder-actions'; import ConnectorActionsMap from '../connector/actions/connector-actions'; export type ActionsMap = {| - txBuilderActions: TxBuilderActions, dialogs: DialogsActions, connector: ConnectorActionsMap, |}; const actionsMap: ActionsMap = Object.freeze({ - txBuilderActions: new TxBuilderActions(), dialogs: new DialogsActions(), connector: new ConnectorActionsMap(), }); diff --git a/packages/yoroi-extension/app/containers/transfer/UnmangleTxDialogContainer.js b/packages/yoroi-extension/app/containers/transfer/UnmangleTxDialogContainer.js index 5806ec0c5d..6bbcd280c3 100644 --- a/packages/yoroi-extension/app/containers/transfer/UnmangleTxDialogContainer.js +++ b/packages/yoroi-extension/app/containers/transfer/UnmangleTxDialogContainer.js @@ -16,12 +16,11 @@ import { getNetworkById } from '../../api/ada/lib/storage/database/prepackaged/n declare var CONFIG: ConfigType; type Props = {| - ...StoresAndActionsProps, +onClose: void => void, |}; @observer -export default class UnmangleTxDialogContainer extends Component { +export default class UnmangleTxDialogContainer extends Component<{| ...Props, ...StoresAndActionsProps |}> { static contextTypes: {|intl: $npm$ReactIntl$IntlFormat|} = { intl: intlShape.isRequired, @@ -47,7 +46,8 @@ export default class UnmangleTxDialogContainer extends Component { selected.networkId, ); // note: don't await - this.props.actions.txBuilderActions.initialize.trigger({ + // noinspection JSIgnoredPromiseFromCall + this.props.stores.transactionBuilderStore.initializeTx({ publicDeriver: selected, /** * We filter to only UTXOs of mangled addresses @@ -76,7 +76,7 @@ export default class UnmangleTxDialogContainer extends Component { transactionRequest={{ error: txBuilder.setupSelfTx.error, result: txBuilder.tentativeTx, - reset: this.props.actions.txBuilderActions.reset.trigger, + reset: this.props.stores.transactionBuilderStore.reset, }} toTransferTx={tentativeTx => ({ recoveredBalance: tentativeTx.totalInput(), diff --git a/packages/yoroi-extension/app/containers/wallet/WalletSendPage.js b/packages/yoroi-extension/app/containers/wallet/WalletSendPage.js index d6aba11a7c..2736a5f685 100644 --- a/packages/yoroi-extension/app/containers/wallet/WalletSendPage.js +++ b/packages/yoroi-extension/app/containers/wallet/WalletSendPage.js @@ -137,7 +137,6 @@ export default class WalletSendPage extends Component { } const { hasAnyPending } = stores.transactions; - const { txBuilderActions } = this.props.actions; // disallow sending when pending tx exists if ( @@ -171,16 +170,16 @@ export default class WalletSendPage extends Component { selectedToken={transactionBuilderStore.selectedToken} defaultToken={defaultToken} getTokenInfo={genLookupOrFail(stores.tokenInfoStore.tokenInfo)} - onSubmit={txBuilderActions.updateTentativeTx.trigger} + onSubmit={transactionBuilderStore.updateTentativeTx} totalInput={transactionBuilderStore.totalInput} hasAnyPending={hasAnyPending} shouldSendAll={transactionBuilderStore.shouldSendAll} - updateReceiver={(addr: void | string) => txBuilderActions.updateReceiver.trigger(addr)} - updateAmount={(value: ?BigNumber) => txBuilderActions.updateAmount.trigger(value)} - updateSendAllStatus={txBuilderActions.updateSendAllStatus.trigger} + updateReceiver={(addr: void | string) => transactionBuilderStore.updateReceiver(addr)} + updateAmount={(value: ?BigNumber) => transactionBuilderStore.updateAmount(value)} + updateSendAllStatus={transactionBuilderStore.updateSendAllStatus} fee={transactionBuilderStore.fee} isCalculatingFee={transactionBuilderStore.createUnsignedTx.isExecuting} - reset={txBuilderActions.reset.trigger} + reset={transactionBuilderStore.reset} error={transactionBuilderStore.createUnsignedTx.error} // Min ADA for all tokens that is already included in the tx minAda={transactionBuilderStore.minAda} @@ -188,15 +187,15 @@ export default class WalletSendPage extends Component { resetUriParams={stores.loading.resetUriParams} memo={transactionBuilderStore.memo} showMemo={this.showMemo} - updateMemo={(content: void | string) => txBuilderActions.updateMemo.trigger(content)} + updateMemo={(content: void | string) => transactionBuilderStore.updateMemo(content)} onAddMemo={() => this.showMemoDialog({ dialog: MemoNoExternalStorageDialog, continuation: this.toggleShowMemo, })} spendableBalance={stores.transactions.balance} - onAddToken={txBuilderActions.addToken.trigger} - onRemoveTokens={txBuilderActions.removeTokens.trigger} + onAddToken={transactionBuilderStore.addToken} + onRemoveTokens={transactionBuilderStore.removeTokens} plannedTxInfoMap={transactionBuilderStore.plannedTxInfoMap} isDefaultIncluded={transactionBuilderStore.isDefaultIncluded} openDialog={this.openDialog} @@ -205,7 +204,7 @@ export default class WalletSendPage extends Component { openTransactionSuccessDialog={this.openTransactionSuccessDialog.bind(this)} unitOfAccountSetting={stores.profile.unitOfAccount} getCurrentPrice={stores.coinPriceStore.getCurrentPrice} - calculateMaxAmount={txBuilderActions.calculateMaxAmount.trigger} + calculateMaxAmount={transactionBuilderStore.calculateMaxAmount} maxSendableAmount={transactionBuilderStore.maxSendableAmount} signRequest={transactionBuilderStore.tentativeTx} staleTx={transactionBuilderStore.txMismatch} @@ -477,16 +476,15 @@ export default class WalletSendPage extends Component { if (!selected) throw new Error(`Active wallet required for ${nameof(AddNFTDialog)}.`); const { transactionBuilderStore } = this.props.stores; - const { txBuilderActions } = this.props.actions; return ( txBuilderActions.updateAmount.trigger(value)} - onAddToken={txBuilderActions.addToken.trigger} - onRemoveTokens={txBuilderActions.removeTokens.trigger} + updateAmount={(value: ?BigNumber) => transactionBuilderStore.updateAmount(value)} + onAddToken={transactionBuilderStore.addToken} + onRemoveTokens={transactionBuilderStore.removeTokens} selectedNetwork={getNetworkById(selected.networkId)} calculateMinAda={this.calculateMinAda} plannedTxInfoMap={transactionBuilderStore.plannedTxInfoMap} @@ -500,20 +498,19 @@ export default class WalletSendPage extends Component { if (!selected) throw new Error(`Active wallet required for ${nameof(AddTokenDialog)}.`); const { transactionBuilderStore } = this.props.stores; - const { txBuilderActions } = this.props.actions; return ( { - txBuilderActions.deselectToken.trigger(); + transactionBuilderStore.deselectToken(); this.props.actions.dialogs.closeActiveDialog.trigger(); }} spendableBalance={this.props.stores.transactions.balance} getTokenInfo={genLookupOrFail(this.props.stores.tokenInfoStore.tokenInfo)} - updateAmount={(value: ?BigNumber) => txBuilderActions.updateAmount.trigger(value)} + updateAmount={(value: ?BigNumber) => transactionBuilderStore.updateAmount(value)} calculateMinAda={this.calculateMinAda} - onAddToken={txBuilderActions.addToken.trigger} - onRemoveTokens={txBuilderActions.removeTokens.trigger} + onAddToken={transactionBuilderStore.addToken} + onRemoveTokens={transactionBuilderStore.removeTokens} shouldAddMoreTokens={this.shouldAddMoreTokens} plannedTxInfoMap={transactionBuilderStore.plannedTxInfoMap} selectedNetwork={getNetworkById(selected.networkId)} diff --git a/packages/yoroi-extension/app/stores/toplevel/TransactionBuilderStore.js b/packages/yoroi-extension/app/stores/toplevel/TransactionBuilderStore.js index fe8b8e85b3..c69b8777f1 100644 --- a/packages/yoroi-extension/app/stores/toplevel/TransactionBuilderStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/TransactionBuilderStore.js @@ -53,6 +53,10 @@ export default class TransactionBuilderStore extends Store; @observable filter: ElementOf => boolean; + + /** + * note: unused for now, as we don't provide an option to send custom meta + */ @observable metadata: Array | void; /** tracks mismatch between `plannedTx` and `tentativeTx` */ @@ -74,21 +78,7 @@ export default class TransactionBuilderStore extends Store Promise = async () => { + calculateMaxAmount: void => Promise = async () => { const publicDeriver = this.stores.wallets.selected; - if (!publicDeriver) throw new Error(`${nameof(this._maxSendableAmount)} requires wallet to be selected.`); + if (!publicDeriver) throw new Error(`${nameof(this.calculateMaxAmount)} requires wallet to be selected.`); const { timeToSlot } = this.stores.substores.ada.time.getTimeCalcRequests(publicDeriver).requests; @@ -367,29 +357,29 @@ export default class TransactionBuilderStore extends Store void = (status) => { - this._updateAmount(undefined, status || false); + updateSendAllStatus: (void | boolean) => void = (status) => { + this.updateAmount(undefined, status || false); } /** Should only set to valid address or undefined */ @action - _updateReceiver: (void | string) => void = (receiver) => { + updateReceiver: (void | string) => void = (receiver) => { this.receiver = receiver ?? null; } @action - _setFilter: (ElementOf => boolean) => void = (filter) => { + setFilter: (ElementOf => boolean) => void = (filter) => { this.filter = filter; } /** Should only set to valid amount or undefined */ @action - _updateAmount: ( + updateAmount: ( value: ?BigNumber, shouldSendAll?: boolean, ) => void = (value, shouldSendAll) => { const publicDeriver = this.stores.wallets.selected; - if (!publicDeriver) throw new Error(`${nameof(this._updateAmount)} requires wallet to be selected`); + if (!publicDeriver) throw new Error(`${nameof(this.updateAmount)} requires wallet to be selected`); const selectedToken = ( this.selectedToken ?? this.stores.tokenInfoStore.getDefaultTokenInfo(publicDeriver.networkId) ); @@ -410,23 +400,18 @@ export default class TransactionBuilderStore extends Store | void) => void = (metadata) => { - this.metadata = metadata; - } - - @action - _updateMemo: (void | string) => void = (content) => { + updateMemo: (void | string) => void = (content) => { this.memo = content; } @action - _addToken: ({| + addToken: ({| token: void | $ReadOnly, shouldSendAll: void | boolean, shouldReset?: boolean, |}) => void = ({ token, shouldReset, shouldSendAll }) => { const publicDeriver = this.stores.wallets.selected; - if (!publicDeriver) throw new Error(`${nameof(this._addToken)} requires wallet to be selected`); + if (!publicDeriver) throw new Error(`${nameof(this.addToken)} requires wallet to be selected`); const selectedToken = ( token ?? this.stores.tokenInfoStore.getDefaultTokenInfo(publicDeriver.networkId) @@ -452,10 +437,10 @@ export default class TransactionBuilderStore extends Store>) => void = (tokens) => { + removeTokens: (tokens: Array<$ReadOnly>) => void = (tokens) => { // Todo: Fix removing the default asset const publicDeriver = this.stores.wallets.selected; - if (!publicDeriver) throw new Error(`${nameof(this._removeTokens)} requires wallet to be selected`); + if (!publicDeriver) throw new Error(`${nameof(this.removeTokens)} requires wallet to be selected`); const tokenIds = new Set(); tokens.forEach(token => tokenIds.add(token.Identifier)) @@ -465,16 +450,16 @@ export default class TransactionBuilderStore extends Store void = () => { + deselectToken: void => void = () => { this.selectedToken = undefined; } @action - _updateTentativeTx: void => void = () => { + updateTentativeTx: void => void = () => { if (!this.plannedTx) { this.tentativeTx = null; return; @@ -483,12 +468,12 @@ export default class TransactionBuilderStore extends Store Promise = async (request) => { + initializeTx: SetupSelfTxRequest => Promise = async (request) => { await this.setupSelfTx.execute(request); } @action - _reset: void => void = () => { + reset: void => void = () => { this.plannedTxInfoMap = []; this.memo = undefined; this.selectedToken = undefined; @@ -541,16 +526,16 @@ export default class TransactionBuilderStore extends Store => { - this._setFilter(request.filter); + this.setFilter(request.filter); const nextUnusedInternal = request.publicDeriver.receiveAddress; - this._updateReceiver(nextUnusedInternal.addr.Hash); + this.updateReceiver(nextUnusedInternal.addr.Hash); // Todo: update shouldSendAll if (this.shouldSendAll === false) { - this._updateSendAllStatus(true); + this.updateSendAllStatus(true); } await this._updateTxBuilder(); this._updatePlannedTx(); - this._updateTentativeTx(); + this.updateTentativeTx(); } } From 581404fd6af0b4714955aa919b8077273b01eb0b Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Mon, 14 Oct 2024 22:48:46 +0300 Subject: [PATCH 39/76] removed some connector actions --- .../connector/actions/connector-actions.js | 8 +-- .../connector/containers/ConnectContainer.js | 12 ++-- .../connector/containers/SignTxContainer.js | 10 ++-- .../app/connector/stores/ConnectorStore.js | 59 +++++++------------ .../ConnectedWebsitesContainer.js | 4 +- .../app/stores/toplevel/DappConnectorStore.js | 20 +++---- .../stores/toplevel/WalletSettingsStore.js | 2 +- 7 files changed, 48 insertions(+), 67 deletions(-) diff --git a/packages/yoroi-extension/app/connector/actions/connector-actions.js b/packages/yoroi-extension/app/connector/actions/connector-actions.js index a165eb34b3..983bb98af5 100644 --- a/packages/yoroi-extension/app/connector/actions/connector-actions.js +++ b/packages/yoroi-extension/app/connector/actions/connector-actions.js @@ -1,19 +1,13 @@ // @flow -import { AsyncAction, Action } from '../../actions/lib/Action'; +import { AsyncAction } from '../../actions/lib/Action'; import type { WhitelistEntry } from '../../../chrome/extension/connector/types'; // ======= CONNECTOR ACTIONS ======= export default class ConnectorActions { - refreshActiveSites: AsyncAction = new AsyncAction(); - refreshWallets: AsyncAction = new AsyncAction(); - closeWindow: Action = new Action(); - getConnectorWhitelist: AsyncAction = new AsyncAction(); updateConnectorWhitelist: AsyncAction<{| whitelist: Array, |}> = new AsyncAction(); removeWalletFromWhitelist: AsyncAction<{| url: string, |}> = new AsyncAction(); - confirmSignInTx: AsyncAction = new AsyncAction(); - cancelSignInTx: Action = new Action(); } diff --git a/packages/yoroi-extension/app/connector/containers/ConnectContainer.js b/packages/yoroi-extension/app/connector/containers/ConnectContainer.js index e02ea3e114..5e0fb18fa2 100644 --- a/packages/yoroi-extension/app/connector/containers/ConnectContainer.js +++ b/packages/yoroi-extension/app/connector/containers/ConnectContainer.js @@ -58,7 +58,8 @@ export default class ConnectContainer extends Component< // eslint-disable-next-line camelcase UNSAFE_componentWillMount() { - this.props.actions.connector.refreshWallets.trigger(); + // noinspection JSIgnoredPromiseFromCall + this.props.stores.connector.refreshWallets(); window.addEventListener('beforeunload', this.onUnload); window.addEventListener('unload', this.onUnload); } @@ -68,7 +69,8 @@ export default class ConnectContainer extends Component< checksum: ?WalletChecksum, password: ?string ) => Promise = async (deriver, _checksum, password) => { - const chromeMessage = this.props.stores.connector.connectingMessage; + const { stores } = this.props; + const chromeMessage = stores.connector.connectingMessage; if (chromeMessage == null) { throw new Error( `${nameof(chromeMessage)} connecting to a wallet but no connect message found` @@ -91,7 +93,7 @@ export default class ConnectContainer extends Component< } const { publicDeriverId } = deriver; - const result = this.props.stores.connector.currentConnectorWhitelist; + const result = stores.connector.currentConnectorWhitelist; // Removing any previous whitelisted connections for the same url const whitelist = (result.length ? [...result] : []).filter( @@ -118,7 +120,7 @@ export default class ConnectContainer extends Component< // if we close the window immediately, the previous message may not be able to // to reach the service worker - setTimeout(() => { connector.closeWindow.trigger(); }, 100); + setTimeout(() => { stores.connector.closeWindow(); }, 100); }; onSelectWallet: (deriver: WalletState, checksum: ?WalletChecksum) => void = ( @@ -153,7 +155,7 @@ export default class ConnectContainer extends Component< tabId: chromeMessage?.tabId, }); - this.props.actions.connector.closeWindow.trigger(); + this.props.stores.connector.closeWindow(); }; hidePasswordForm: void => void = () => { diff --git a/packages/yoroi-extension/app/connector/containers/SignTxContainer.js b/packages/yoroi-extension/app/connector/containers/SignTxContainer.js index 04c74d8e53..48680585af 100644 --- a/packages/yoroi-extension/app/connector/containers/SignTxContainer.js +++ b/packages/yoroi-extension/app/connector/containers/SignTxContainer.js @@ -26,11 +26,12 @@ export default class SignTxContainer extends Component< onUnload: (SyntheticEvent<>) => void = ev => { ev.preventDefault(); - this.props.actions.connector.cancelSignInTx.trigger(); + this.props.stores.connector.cancelSignInTx(); }; componentDidMount() { - this.props.actions.connector.refreshWallets.trigger(); + // noinspection JSIgnoredPromiseFromCall + this.props.stores.connector.refreshWallets(); window.addEventListener('beforeunload', this.onUnload); window.addEventListener('unload', this.onUnload); } @@ -54,12 +55,13 @@ export default class SignTxContainer extends Component< window.removeEventListener('beforeunload', this.onUnload); window.removeEventListener('unload', this.onUnload); - await this.props.actions.connector.confirmSignInTx.trigger(password); + await this.props.stores.connector.confirmSignInTx(password); }; + onCancel: () => void = () => { window.removeEventListener('beforeunload', this.onUnload); window.removeEventListener('unload', this.onUnload); - this.props.actions.connector.cancelSignInTx.trigger(); + this.props.stores.connector.cancelSignInTx(); setTimeout(() => { window.close(); }, 100); }; diff --git a/packages/yoroi-extension/app/connector/stores/ConnectorStore.js b/packages/yoroi-extension/app/connector/stores/ConnectorStore.js index b5fb9e2bff..2f1d94ceac 100644 --- a/packages/yoroi-extension/app/connector/stores/ConnectorStore.js +++ b/packages/yoroi-extension/app/connector/stores/ConnectorStore.js @@ -1,7 +1,6 @@ /* eslint-disable promise/always-return */ // @flow import type { - ConnectedSites, ConnectingMessage, SigningMessage, WhitelistEntry, @@ -65,7 +64,6 @@ import { iterateLenGet, hexToBytes, noop, purify } from '../../coreUtils'; import { broadcastTransaction, connectWindowRetrieveData, - getConnectedSites, getProtocolParameters, getWallets, removeWalletFromWhiteList, @@ -125,10 +123,6 @@ export default class ConnectorStore extends Store { ({ whitelist }) => this.api.localStorage.setWhitelist(whitelist) ); - @observable getConnectedSites: Request = new Request< - typeof getConnectedSites - >(getConnectedSites); - @observable signingMessage: ?SigningMessage = null; @observable adaTransaction: ?CardanoConnectorSignRequest = null; @@ -146,17 +140,12 @@ export default class ConnectorStore extends Store { // the tx is not supported. @observable isHwWalletErrorRecoverable: ?boolean = null; + isSignInExecuted: boolean = false; + setup(): void { super.setup(); this.actions.connector.updateConnectorWhitelist.listen(this._updateConnectorWhitelist); this.actions.connector.removeWalletFromWhitelist.listen(this._removeWalletFromWhitelist); - this.actions.connector.confirmSignInTx.listen(async (password) => { - await this._confirmSignInTx(password); - }); - this.actions.connector.cancelSignInTx.listen(this._cancelSignInTx); - this.actions.connector.refreshActiveSites.listen(this._refreshActiveSites); - this.actions.connector.refreshWallets.listen(this._getWallets); - this.actions.connector.closeWindow.listen(this._closeWindow); this._getConnectorWhitelist(); this._getConnectingMsg(); this._getSigningMsg(); @@ -169,7 +158,7 @@ export default class ConnectorStore extends Store { // ========== general ========== // @action - _closeWindow() { + closeWindow() { window.close(); } @@ -212,7 +201,7 @@ export default class ConnectorStore extends Store { }; @action - _confirmSignInTx: string => Promise = async password => { + confirmSignInTx: string => Promise = async password => { runInAction(() => { this.submissionError = null; }); @@ -221,7 +210,7 @@ export default class ConnectorStore extends Store { if (signingMessage == null) { throw new Error( - `${nameof(this._confirmSignInTx)} confirming a tx but no signing message set` + `${nameof(this.confirmSignInTx)} confirming a tx but no signing message set` ); } @@ -359,15 +348,24 @@ export default class ConnectorStore extends Store { throw new Error(`unkown sign data type ${signingMessage.sign.type}`); } - this.actions.connector.cancelSignInTx.remove(this._cancelSignInTx); + runInAction(() => { + this.isSignInExecuted = true; + }); + await ampli.dappPopupSignTransactionSubmitted(); - this._closeWindow(); + this.closeWindow(); }; + @action - _cancelSignInTx: void => void = () => { + cancelSignInTx: void => void = () => { + if (this.isSignInExecuted) { + // Ignore call to cancel in case sign was already executed + // This is needed to handle page unload after signing + return; + } if (this.signingMessage == null) { throw new Error( - `${nameof(this._confirmSignInTx)} confirming a tx but no signing message set` + `${nameof(this.confirmSignInTx)} confirming a tx but no signing message set` ); } const { signingMessage } = this; @@ -379,7 +377,7 @@ export default class ConnectorStore extends Store { // ========== wallets info ========== // @action - _getWallets: void => Promise = async () => { + refreshWallets: void => Promise = async () => { runInAction(() => { this.loadingWallets = LoadingWalletStates.PENDING; this.errorWallets = ''; @@ -476,7 +474,7 @@ export default class ConnectorStore extends Store { uid: signingMessage.sign.uid, tabId: signingMessage.tabId, }); - this._closeWindow(); + this.closeWindow(); return; } @@ -546,7 +544,7 @@ export default class ConnectorStore extends Store { uid: signingMessage.sign.uid, tabId: signingMessage.tabId, }); - this._closeWindow(); + this.closeWindow(); return; } if (foreignUtxo.spendingTxHash != null) { @@ -556,7 +554,7 @@ export default class ConnectorStore extends Store { uid: signingMessage.sign.uid, tabId: signingMessage.tabId, }); - this._closeWindow(); + this.closeWindow(); return; } const value = multiTokenFromRemote(foreignUtxo.output, defaultToken.NetworkId); @@ -984,19 +982,6 @@ export default class ConnectorStore extends Store { await removeWalletFromWhiteList({ url: request.url }); }; - _refreshActiveSites: void => Promise = async () => { - await this.getConnectedSites.execute(); - }; - - // ========== active websites ========== // - @computed get activeSites(): ConnectedSites { - let { result } = this.getConnectedSites; - if (result == null) { - result = this.getConnectedSites.execute().result; - } - return result ?? { sites: [] }; - } - @computed get connectedWallet(): ?WalletState { const { signingMessage } = this; if (signingMessage == null) { diff --git a/packages/yoroi-extension/app/containers/dapp-connector/ConnectedWebsitesContainer.js b/packages/yoroi-extension/app/containers/dapp-connector/ConnectedWebsitesContainer.js index cc729e4d8a..c3e9472b45 100644 --- a/packages/yoroi-extension/app/containers/dapp-connector/ConnectedWebsitesContainer.js +++ b/packages/yoroi-extension/app/containers/dapp-connector/ConnectedWebsitesContainer.js @@ -33,8 +33,8 @@ export default class ConnectedWebsitesPageContainer extends Component void = ({ url }) => { diff --git a/packages/yoroi-extension/app/stores/toplevel/DappConnectorStore.js b/packages/yoroi-extension/app/stores/toplevel/DappConnectorStore.js index df370e2a15..c5cd4c16b6 100644 --- a/packages/yoroi-extension/app/stores/toplevel/DappConnectorStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/DappConnectorStore.js @@ -24,7 +24,7 @@ type SetWhitelistFunc = {| export default class ConnectorStore extends Store { @observable connectingMessage: ?ConnectingMessage = null; @observable whiteList: Array = []; - @observable getConnectorWhitelist: Request< + @observable getConnectorWhitelistRequest: Request< GetWhitelistFunc > = new Request( this.api.localStorage.getWhitelist @@ -42,11 +42,9 @@ export default class ConnectorStore extends Store { setup(): void { super.setup(); - this.actions.connector.getConnectorWhitelist.listen(this._getConnectorWhitelist); this.actions.connector.updateConnectorWhitelist.listen(this._updateConnectorWhitelist); this.actions.connector.removeWalletFromWhitelist.listen(this._removeWalletFromWhitelist); - this.actions.connector.refreshActiveSites.listen(this._refreshActiveSites); - this._getConnectorWhitelist(); + this.getConnectorWhitelist(); noop(this.currentConnectorWhitelist); } @@ -56,20 +54,20 @@ export default class ConnectorStore extends Store { // ========== whitelist ========== // @computed get currentConnectorWhitelist(): Array { - let { result } = this.getConnectorWhitelist; + let { result } = this.getConnectorWhitelistRequest; if (result == null) { - result = this.getConnectorWhitelist.execute().result; + result = this.getConnectorWhitelistRequest.execute().result; } return result ?? []; } - _getConnectorWhitelist: void => Promise = async () => { - await this.getConnectorWhitelist.execute(); + getConnectorWhitelist: void => Promise = async () => { + await this.getConnectorWhitelistRequest.execute(); }; _updateConnectorWhitelist: ({| whitelist: Array |}) => Promise = async ({ whitelist, }) => { await this.setConnectorWhitelist.execute({ whitelist }); - await this.getConnectorWhitelist.execute(); + await this.getConnectorWhitelistRequest.execute(); }; _removeWalletFromWhitelist: ( request: {| url: string |} @@ -80,11 +78,11 @@ export default class ConnectorStore extends Store { await this.setConnectorWhitelist.execute({ whitelist: filter, }); - await this.getConnectorWhitelist.execute(); + await this.getConnectorWhitelistRequest.execute(); await removeWalletFromWhiteList({ url: request.url }); }; - _refreshActiveSites: void => Promise = async () => { + refreshActiveSites: void => Promise = async () => { await this.getConnectedSites.execute(); } diff --git a/packages/yoroi-extension/app/stores/toplevel/WalletSettingsStore.js b/packages/yoroi-extension/app/stores/toplevel/WalletSettingsStore.js index 2b4e5888f8..6152cf7987 100644 --- a/packages/yoroi-extension/app/stores/toplevel/WalletSettingsStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/WalletSettingsStore.js @@ -122,7 +122,7 @@ export default class WalletSettingsStore extends Store { await stores.profile.updateSortedWalletList(newWalletsNavigation); // ==================== Disconnect related dApps ==================== - await this.actions.connector.getConnectorWhitelist.trigger(); + await this.stores.connector.getConnectorWhitelist(); const connectorWhitelist = stores.connector.currentConnectorWhitelist; const connectedDapps = connectorWhitelist.filter( dapp => dapp.publicDeriverId === request.publicDeriverId From 6ba54d39b83fca120def3c66895294d6b15d2acc Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Mon, 14 Oct 2024 23:27:39 +0300 Subject: [PATCH 40/76] removed some connector actions --- .../app/connector/actions/connector-actions.js | 4 ---- .../app/connector/containers/ConnectContainer.js | 3 +-- .../yoroi-extension/app/connector/stores/ConnectorStore.js | 3 +-- .../app/stores/toplevel/DappConnectorStore.js | 7 ------- 4 files changed, 2 insertions(+), 15 deletions(-) diff --git a/packages/yoroi-extension/app/connector/actions/connector-actions.js b/packages/yoroi-extension/app/connector/actions/connector-actions.js index 983bb98af5..3df574a4f9 100644 --- a/packages/yoroi-extension/app/connector/actions/connector-actions.js +++ b/packages/yoroi-extension/app/connector/actions/connector-actions.js @@ -1,12 +1,8 @@ // @flow import { AsyncAction } from '../../actions/lib/Action'; -import type { WhitelistEntry } from '../../../chrome/extension/connector/types'; // ======= CONNECTOR ACTIONS ======= export default class ConnectorActions { - updateConnectorWhitelist: AsyncAction<{| - whitelist: Array, - |}> = new AsyncAction(); removeWalletFromWhitelist: AsyncAction<{| url: string, |}> = new AsyncAction(); diff --git a/packages/yoroi-extension/app/connector/containers/ConnectContainer.js b/packages/yoroi-extension/app/connector/containers/ConnectContainer.js index 5e0fb18fa2..eda2225409 100644 --- a/packages/yoroi-extension/app/connector/containers/ConnectContainer.js +++ b/packages/yoroi-extension/app/connector/containers/ConnectContainer.js @@ -76,7 +76,6 @@ export default class ConnectContainer extends Component< `${nameof(chromeMessage)} connecting to a wallet but no connect message found` ); } - const connector = this.props.actions.connector; const url = chromeMessage.url; const appAuthID = chromeMessage.appAuthID; @@ -107,7 +106,7 @@ export default class ConnectContainer extends Component< auth: authEntry, image: chromeMessage.imgBase64Url, }); - await connector.updateConnectorWhitelist.trigger({ whitelist }); + await stores.connector.updateConnectorWhitelist({ whitelist }); await ampli.dappPopupConnectWalletPasswordPageViewed(); diff --git a/packages/yoroi-extension/app/connector/stores/ConnectorStore.js b/packages/yoroi-extension/app/connector/stores/ConnectorStore.js index 2f1d94ceac..5a71ebd67a 100644 --- a/packages/yoroi-extension/app/connector/stores/ConnectorStore.js +++ b/packages/yoroi-extension/app/connector/stores/ConnectorStore.js @@ -144,7 +144,6 @@ export default class ConnectorStore extends Store { setup(): void { super.setup(); - this.actions.connector.updateConnectorWhitelist.listen(this._updateConnectorWhitelist); this.actions.connector.removeWalletFromWhitelist.listen(this._removeWalletFromWhitelist); this._getConnectorWhitelist(); this._getConnectingMsg(); @@ -963,7 +962,7 @@ export default class ConnectorStore extends Store { _getConnectorWhitelist: void => Promise = async () => { await this.getConnectorWhitelist.execute(); }; - _updateConnectorWhitelist: ({| whitelist: Array |}) => Promise = async ({ + updateConnectorWhitelist: ({| whitelist: Array |}) => Promise = async ({ whitelist, }) => { await this.setConnectorWhitelist.execute({ whitelist }); diff --git a/packages/yoroi-extension/app/stores/toplevel/DappConnectorStore.js b/packages/yoroi-extension/app/stores/toplevel/DappConnectorStore.js index c5cd4c16b6..4013bc091a 100644 --- a/packages/yoroi-extension/app/stores/toplevel/DappConnectorStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/DappConnectorStore.js @@ -42,7 +42,6 @@ export default class ConnectorStore extends Store { setup(): void { super.setup(); - this.actions.connector.updateConnectorWhitelist.listen(this._updateConnectorWhitelist); this.actions.connector.removeWalletFromWhitelist.listen(this._removeWalletFromWhitelist); this.getConnectorWhitelist(); noop(this.currentConnectorWhitelist); @@ -63,12 +62,6 @@ export default class ConnectorStore extends Store { getConnectorWhitelist: void => Promise = async () => { await this.getConnectorWhitelistRequest.execute(); }; - _updateConnectorWhitelist: ({| whitelist: Array |}) => Promise = async ({ - whitelist, - }) => { - await this.setConnectorWhitelist.execute({ whitelist }); - await this.getConnectorWhitelistRequest.execute(); - }; _removeWalletFromWhitelist: ( request: {| url: string |} ) => Promise = async request => { From 9f124548b52c56869846c43f4e2d5ae3acf346ab Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Mon, 14 Oct 2024 23:35:16 +0300 Subject: [PATCH 41/76] removed connector actions --- packages/yoroi-extension/app/actions/index.js | 3 --- .../app/connector/actions/connector-actions.js | 9 --------- .../app/connector/actions/index.js | 3 --- .../app/connector/stores/ConnectorStore.js | 17 +++-------------- .../ConnectedWebsitesContainer.js | 3 ++- .../app/stores/toplevel/DappConnectorStore.js | 5 ++--- .../app/stores/toplevel/WalletSettingsStore.js | 2 +- 7 files changed, 8 insertions(+), 34 deletions(-) delete mode 100644 packages/yoroi-extension/app/connector/actions/connector-actions.js diff --git a/packages/yoroi-extension/app/actions/index.js b/packages/yoroi-extension/app/actions/index.js index b4eeb0db93..28ca07a05b 100644 --- a/packages/yoroi-extension/app/actions/index.js +++ b/packages/yoroi-extension/app/actions/index.js @@ -1,15 +1,12 @@ // @flow import DialogsActions from './dialogs-actions'; -import ConnectorActionsMap from '../connector/actions/connector-actions'; export type ActionsMap = {| dialogs: DialogsActions, - connector: ConnectorActionsMap, |}; const actionsMap: ActionsMap = Object.freeze({ dialogs: new DialogsActions(), - connector: new ConnectorActionsMap(), }); export default actionsMap; diff --git a/packages/yoroi-extension/app/connector/actions/connector-actions.js b/packages/yoroi-extension/app/connector/actions/connector-actions.js deleted file mode 100644 index 3df574a4f9..0000000000 --- a/packages/yoroi-extension/app/connector/actions/connector-actions.js +++ /dev/null @@ -1,9 +0,0 @@ -// @flow -import { AsyncAction } from '../../actions/lib/Action'; -// ======= CONNECTOR ACTIONS ======= - -export default class ConnectorActions { - removeWalletFromWhitelist: AsyncAction<{| - url: string, - |}> = new AsyncAction(); -} diff --git a/packages/yoroi-extension/app/connector/actions/index.js b/packages/yoroi-extension/app/connector/actions/index.js index 659678eb81..a9ef504718 100644 --- a/packages/yoroi-extension/app/connector/actions/index.js +++ b/packages/yoroi-extension/app/connector/actions/index.js @@ -1,14 +1,11 @@ // @flow import DialogsActions from '../../actions/dialogs-actions'; -import ConnectorActions from './connector-actions'; export type ActionsMap = {| dialogs: DialogsActions, - connector: ConnectorActions, |}; const actionsMap: ActionsMap = Object.freeze({ - connector: new ConnectorActions(), dialogs: new DialogsActions(), }); diff --git a/packages/yoroi-extension/app/connector/stores/ConnectorStore.js b/packages/yoroi-extension/app/connector/stores/ConnectorStore.js index 5a71ebd67a..6c5c07dad8 100644 --- a/packages/yoroi-extension/app/connector/stores/ConnectorStore.js +++ b/packages/yoroi-extension/app/connector/stores/ConnectorStore.js @@ -66,7 +66,6 @@ import { connectWindowRetrieveData, getProtocolParameters, getWallets, - removeWalletFromWhiteList, signAndBroadcastTransaction, signFail, signWindowRetrieveData, @@ -144,9 +143,11 @@ export default class ConnectorStore extends Store { setup(): void { super.setup(); - this.actions.connector.removeWalletFromWhitelist.listen(this._removeWalletFromWhitelist); + // noinspection JSIgnoredPromiseFromCall this._getConnectorWhitelist(); + // noinspection JSIgnoredPromiseFromCall this._getConnectingMsg(); + // noinspection JSIgnoredPromiseFromCall this._getSigningMsg(); noop(this.currentConnectorWhitelist); } @@ -968,18 +969,6 @@ export default class ConnectorStore extends Store { await this.setConnectorWhitelist.execute({ whitelist }); await this.getConnectorWhitelist.execute(); }; - _removeWalletFromWhitelist: (request: {| - url: string, - |}) => Promise = async request => { - const filter = this.currentConnectorWhitelist.filter( - e => e.url !== request.url - ); - await this.setConnectorWhitelist.execute({ - whitelist: filter, - }); - await this.getConnectorWhitelist.execute(); - await removeWalletFromWhiteList({ url: request.url }); - }; @computed get connectedWallet(): ?WalletState { const { signingMessage } = this; diff --git a/packages/yoroi-extension/app/containers/dapp-connector/ConnectedWebsitesContainer.js b/packages/yoroi-extension/app/containers/dapp-connector/ConnectedWebsitesContainer.js index c3e9472b45..4dc700329d 100644 --- a/packages/yoroi-extension/app/containers/dapp-connector/ConnectedWebsitesContainer.js +++ b/packages/yoroi-extension/app/containers/dapp-connector/ConnectedWebsitesContainer.js @@ -41,7 +41,8 @@ export default class ConnectedWebsitesPageContainer extends Component { setup(): void { super.setup(); - this.actions.connector.removeWalletFromWhitelist.listen(this._removeWalletFromWhitelist); - this.getConnectorWhitelist(); + noop(this.getConnectorWhitelist()); noop(this.currentConnectorWhitelist); } @@ -62,7 +61,7 @@ export default class ConnectorStore extends Store { getConnectorWhitelist: void => Promise = async () => { await this.getConnectorWhitelistRequest.execute(); }; - _removeWalletFromWhitelist: ( + removeWalletFromWhitelist1: ( request: {| url: string |} ) => Promise = async request => { const filter = this.currentConnectorWhitelist.filter( diff --git a/packages/yoroi-extension/app/stores/toplevel/WalletSettingsStore.js b/packages/yoroi-extension/app/stores/toplevel/WalletSettingsStore.js index 6152cf7987..a58dffd140 100644 --- a/packages/yoroi-extension/app/stores/toplevel/WalletSettingsStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/WalletSettingsStore.js @@ -129,7 +129,7 @@ export default class WalletSettingsStore extends Store { ); for (const dapp of connectedDapps) { - await this.actions.connector.removeWalletFromWhitelist.trigger({ + await this.stores.connector.removeWalletFromWhitelist1({ url: dapp.url, }); } From 15c7a6ac82df4ccc437cc59cf9caab0d80e59502 Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Mon, 14 Oct 2024 23:46:27 +0300 Subject: [PATCH 42/76] removed some dialog actions --- .../app/actions/dialogs-actions.js | 4 ---- .../app/containers/wallet/AddWalletPage.js | 14 +++++++------- .../app/containers/wallet/WalletSendPage.js | 6 +++--- .../app/containers/wallet/WalletSummaryPage.js | 16 ++++++++-------- .../ChangeWalletPasswordDialogContainer.js | 3 +-- .../app/stores/toplevel/UiDialogsStore.js | 18 +++++++----------- 6 files changed, 26 insertions(+), 35 deletions(-) diff --git a/packages/yoroi-extension/app/actions/dialogs-actions.js b/packages/yoroi-extension/app/actions/dialogs-actions.js index 6f9d505590..3200b15893 100644 --- a/packages/yoroi-extension/app/actions/dialogs-actions.js +++ b/packages/yoroi-extension/app/actions/dialogs-actions.js @@ -5,9 +5,5 @@ import { Action } from './lib/Action'; export default class DialogsActions { open: Action<{| dialog: Function, params?: Object |}> = new Action(); - push: Action<{| dialog: Function, params?: Object |}> = new Action(); - pop: Action = new Action(); - updateDataForActiveDialog: Action<{| [key: string]: any, |}> = new Action(); closeActiveDialog: Action = new Action(); - resetActiveDialog: Action = new Action(); } diff --git a/packages/yoroi-extension/app/containers/wallet/AddWalletPage.js b/packages/yoroi-extension/app/containers/wallet/AddWalletPage.js index edb96dde8f..ded81bb02b 100644 --- a/packages/yoroi-extension/app/containers/wallet/AddWalletPage.js +++ b/packages/yoroi-extension/app/containers/wallet/AddWalletPage.js @@ -58,7 +58,7 @@ export default class AddWalletPage extends Component { if (selectedNetwork === undefined) { throw new Error(`${nameof(AddWalletPage)} no API selected`); } - actions.dialogs.push.trigger({ + stores.uiDialogs.push({ dialog: WalletTrezorConnectDialogContainer, }); // @@ -68,7 +68,7 @@ export default class AddWalletPage extends Component { if (selectedNetwork === undefined) { throw new Error(`${nameof(AddWalletPage)} no API selected`); } - actions.dialogs.push.trigger({ + stores.uiDialogs.push({ dialog: WalletLedgerConnectDialogContainer, }); // @@ -116,13 +116,13 @@ export default class AddWalletPage extends Component { { - return actions.dialogs.push.trigger({ + return stores.uiDialogs.push({ dialog: WalletRestoreDialogContainer, params: { restoreType: { type: 'cip1852', extra: undefined, length: 15 } }, }); }} onRestore24={() => { - actions.dialogs.push.trigger({ + stores.uiDialogs.push({ dialog: WalletRestoreDialogContainer, params: { restoreType: { type: 'cip1852', extra: undefined, length: 24 } }, }); @@ -138,7 +138,7 @@ export default class AddWalletPage extends Component { actions={actions} stores={stores} onClose={this.onClose} - onBack={() => actions.dialogs.pop.trigger()} + onBack={() => stores.uiDialogs.pop()} mode={mode} /> ); @@ -156,7 +156,7 @@ export default class AddWalletPage extends Component { actions={actions} stores={stores} onClose={this.onClose} - onBack={() => actions.dialogs.pop.trigger()} + onBack={() => stores.uiDialogs.pop()} /> ); } else if (uiDialogs.isOpen(WalletLedgerConnectDialogContainer)) { @@ -165,7 +165,7 @@ export default class AddWalletPage extends Component { actions={actions} stores={stores} onClose={this.onClose} - onBack={() => actions.dialogs.pop.trigger()} + onBack={() => stores.uiDialogs.pop()} /> ); } diff --git a/packages/yoroi-extension/app/containers/wallet/WalletSendPage.js b/packages/yoroi-extension/app/containers/wallet/WalletSendPage.js index 2736a5f685..d104ae1d44 100644 --- a/packages/yoroi-extension/app/containers/wallet/WalletSendPage.js +++ b/packages/yoroi-extension/app/containers/wallet/WalletSendPage.js @@ -71,7 +71,7 @@ export default class WalletSendPage extends Component { }; openTransactionSuccessDialog: void => void = () => { - this.props.actions.dialogs.push.trigger({ + this.props.stores.uiDialogs.push({ dialog: TransactionSuccessDialog, }); }; @@ -96,7 +96,7 @@ export default class WalletSendPage extends Component { openDialog: any => void = dialog => { this.props.actions.dialogs.closeActiveDialog.trigger(); - this.props.actions.dialogs.push.trigger({ + this.props.stores.uiDialogs.push({ dialog, }); }; @@ -397,7 +397,7 @@ export default class WalletSendPage extends Component { return request.continuation(); } - this.props.actions.dialogs.push.trigger({ + this.props.stores.uiDialogs.push({ dialog: request.dialog, params: { continuation: request.continuation, diff --git a/packages/yoroi-extension/app/containers/wallet/WalletSummaryPage.js b/packages/yoroi-extension/app/containers/wallet/WalletSummaryPage.js index b4f6658d80..cd8484ba23 100644 --- a/packages/yoroi-extension/app/containers/wallet/WalletSummaryPage.js +++ b/packages/yoroi-extension/app/containers/wallet/WalletSummaryPage.js @@ -38,7 +38,7 @@ export default class WalletSummaryPage extends Component render(): Node { const { intl } = this.context; - const { actions, stores } = this.props; + const { stores } = this.props; const { hasAny, hasMoreToLoad, @@ -106,7 +106,7 @@ export default class WalletSummaryPage extends Component dialog: MemoNoExternalStorageDialog, continuation: () => { stores.memos.selectTransaction({ tx: transaction }); - actions.dialogs.push.trigger({ dialog: AddMemoDialog }); + stores.uiDialogs.push({ dialog: AddMemoDialog }); }, }) } @@ -115,7 +115,7 @@ export default class WalletSummaryPage extends Component dialog: MemoNoExternalStorageDialog, continuation: () => { stores.memos.selectTransaction({ tx: transaction }); - actions.dialogs.push.trigger({ dialog: EditMemoDialog }); + stores.uiDialogs.push({ dialog: EditMemoDialog }); }, }) } @@ -269,8 +269,8 @@ export default class WalletSummaryPage extends Component } openExportTransactionDialog: void => void = () => { - const { actions } = this.props; - actions.dialogs.push.trigger({ dialog: ExportTransactionDialog }); + const { stores } = this.props; + stores.uiDialogs.push({ dialog: ExportTransactionDialog }); }; showMemoDialog: ({| @@ -281,7 +281,7 @@ export default class WalletSummaryPage extends Component return request.continuation(); } - this.props.actions.dialogs.push.trigger({ + this.props.stores.uiDialogs.push({ dialog: request.dialog, params: { continuation: request.continuation, @@ -290,8 +290,8 @@ export default class WalletSummaryPage extends Component }; openDeleteMemoDialog: void => void = () => { - const { actions } = this.props; - actions.dialogs.push.trigger({ dialog: DeleteMemoDialog }); + const { stores } = this.props; + stores.uiDialogs.push({ dialog: DeleteMemoDialog }); }; readyToExportHistory: (number) => boolean = publicDeriverId => { diff --git a/packages/yoroi-extension/app/containers/wallet/dialogs/ChangeWalletPasswordDialogContainer.js b/packages/yoroi-extension/app/containers/wallet/dialogs/ChangeWalletPasswordDialogContainer.js index 14341eba69..62e95c3cea 100644 --- a/packages/yoroi-extension/app/containers/wallet/dialogs/ChangeWalletPasswordDialogContainer.js +++ b/packages/yoroi-extension/app/containers/wallet/dialogs/ChangeWalletPasswordDialogContainer.js @@ -15,7 +15,6 @@ export default class ChangeWalletPasswordDialogContainer extends Component<{| .. render(): Node { const { actions, stores } = this.props; const { uiDialogs, walletSettings } = stores; - const { updateDataForActiveDialog } = actions.dialogs; const { changeSigningKeyRequest } = walletSettings; return ( @@ -41,7 +40,7 @@ export default class ChangeWalletPasswordDialogContainer extends Component<{| .. changeSigningKeyRequest.reset(); }} onDataChange={data => { - updateDataForActiveDialog.trigger(data); + stores.uiDialogs.updateDataForActiveDialog(data); }} isSubmitting={changeSigningKeyRequest.isExecuting} error={changeSigningKeyRequest.error} diff --git a/packages/yoroi-extension/app/stores/toplevel/UiDialogsStore.js b/packages/yoroi-extension/app/stores/toplevel/UiDialogsStore.js index 13f9f20a49..7fe21dbb6d 100644 --- a/packages/yoroi-extension/app/stores/toplevel/UiDialogsStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/UiDialogsStore.js @@ -38,11 +38,7 @@ export default class UiDialogsStore< setup(): void { super.setup(); this.actions.dialogs.open.listen(this._onOpen); - this.actions.dialogs.push.listen(this._onPush); - this.actions.dialogs.pop.listen(this._onPop); this.actions.dialogs.closeActiveDialog.listen(this._onClose); - this.actions.dialogs.resetActiveDialog.listen(this._reset); - this.actions.dialogs.updateDataForActiveDialog.listen(this._onUpdateDataForActiveDialog); } @computed @@ -70,7 +66,7 @@ export default class UiDialogsStore< this.dialogList[this.dialogList.length - 1]?.dataForActiveDialog.get(key) ); - @action _onPush: {| dialog : any, params?: {...} |} => void = ({ dialog, params }) => { + @action push: {| dialog : any, params?: {...} |} => void = ({ dialog, params }) => { const prevEntry = this.dialogList[this.dialogList.length - 1]; const newMap = observable.map(); @@ -82,28 +78,28 @@ export default class UiDialogsStore< dataForActiveDialog: observable.map(), }); }; - @action _onPop: void => void = () => { + @action pop: void => void = () => { this.dialogList.pop(); } @action _onOpen: {| dialog : any, params?: {...} |} => void = ({ dialog, params }) => { - this._reset(); - this._onPush({ + this.reset(); + this.push({ dialog, params, }); }; @action _onClose: void => void = () => { - this._reset(); + this.reset(); }; - @action _onUpdateDataForActiveDialog: {| [key: string]: any, |} => void = (data) => { + @action updateDataForActiveDialog: {| [key: string]: any, |} => void = (data) => { if (this.dialogList.length === 0) return; // $FlowExpectedError[prop-missing] this is a mobx property -- not part of es6 this.dialogList[this.dialogList.length - 1].dataForActiveDialog.merge(data); }; - @action _reset: void => void = () => { + @action reset: void => void = () => { this.dialogList.splice(0); // remove all elements. Need this to trigger mobx reaction }; From 9ce1e261220d20971480b76f990afab57a84e133 Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Tue, 15 Oct 2024 00:00:38 +0300 Subject: [PATCH 43/76] removed some dialog actions --- packages/yoroi-extension/app/Routes.js | 4 ++-- .../app/actions/dialogs-actions.js | 1 - .../app/containers/NavBarContainer.js | 2 +- .../app/containers/NavBarContainerRevamp.js | 4 ++-- .../settings/categories/SupportSettingsPage.js | 2 +- .../settings/categories/WalletSettingsPage.js | 10 +++++----- .../app/containers/wallet/AddWalletPage.js | 2 +- .../wallet/CreateWalletPageContainer.js | 2 +- .../app/containers/wallet/MyWalletsPage.js | 2 +- .../app/containers/wallet/Wallet.js | 2 +- .../app/containers/wallet/WalletReceivePage.js | 16 ++++++++-------- .../app/containers/wallet/WalletSummaryPage.js | 2 +- .../wallet/restore/RestoreWalletPage.js | 2 +- .../wallet/staking/StakingDashboardPage.js | 8 ++++---- .../wallet/staking/StakingPageContent.js | 18 +++++++++--------- .../wallet/voting/VotingPageContent.js | 2 +- .../ada/AdaDelegationTransactionStore.js | 2 +- .../app/stores/toplevel/UiDialogsStore.js | 3 +-- .../app/stores/toplevel/WalletBackupStore.js | 2 +- 19 files changed, 42 insertions(+), 44 deletions(-) diff --git a/packages/yoroi-extension/app/Routes.js b/packages/yoroi-extension/app/Routes.js index 41505b4da2..33cb7906bb 100644 --- a/packages/yoroi-extension/app/Routes.js +++ b/packages/yoroi-extension/app/Routes.js @@ -538,7 +538,7 @@ export function wrapReceive(receiveProps: StoresAndActionsProps, children: Node) // NEW UI - TODO: to be refactred export function wrapGovernance(governanceProps: StoresAndActionsProps, children: Node): Node { - const { stores, actions } = governanceProps; + const { stores } = governanceProps; const currentWalletInfo = createCurrrentWalletInfo(stores); const { delegationTransaction } = stores.substores.ada; const delegationTxResult = delegationTransaction.createDelegationTx.result; @@ -551,7 +551,7 @@ export function wrapGovernance(governanceProps: StoresAndActionsProps, children: txDelegationResult={delegationTxResult} txDelegationError={delegationTxError} tokenInfo={stores.tokenInfoStore.tokenInfo} - triggerBuySellAdaDialog={() => actions.dialogs.open.trigger({ dialog: BuySellDialog })} + triggerBuySellAdaDialog={() => stores.uiDialogs.open({ dialog: BuySellDialog })} > {children}; diff --git a/packages/yoroi-extension/app/actions/dialogs-actions.js b/packages/yoroi-extension/app/actions/dialogs-actions.js index 3200b15893..3c936c5d25 100644 --- a/packages/yoroi-extension/app/actions/dialogs-actions.js +++ b/packages/yoroi-extension/app/actions/dialogs-actions.js @@ -4,6 +4,5 @@ import { Action } from './lib/Action'; // ======= DIALOGS ACTIONS ======= export default class DialogsActions { - open: Action<{| dialog: Function, params?: Object |}> = new Action(); closeActiveDialog: Action = new Action(); } diff --git a/packages/yoroi-extension/app/containers/NavBarContainer.js b/packages/yoroi-extension/app/containers/NavBarContainer.js index 9348fa0250..5083b84163 100644 --- a/packages/yoroi-extension/app/containers/NavBarContainer.js +++ b/packages/yoroi-extension/app/containers/NavBarContainer.js @@ -41,7 +41,7 @@ export default class NavBarContainer extends Component<{| ...StoresAndActionsPro openDialogWrapper: any => void = dialog => { this.props.stores.app.goToRoute({ route: ROUTES.MY_WALLETS }); - this.props.actions.dialogs.open.trigger({ dialog }); + this.props.stores.uiDialogs.open({ dialog }); }; render(): Node { diff --git a/packages/yoroi-extension/app/containers/NavBarContainerRevamp.js b/packages/yoroi-extension/app/containers/NavBarContainerRevamp.js index 1821ba9155..e83a3ce6a1 100644 --- a/packages/yoroi-extension/app/containers/NavBarContainerRevamp.js +++ b/packages/yoroi-extension/app/containers/NavBarContainerRevamp.js @@ -89,7 +89,7 @@ export default class NavBarContainerRevamp extends Component<{| ...StoresAndActi getCurrentPrice={this.props.stores.coinPriceStore.getCurrentPrice} openWalletInfoDialog={() => { ampli.allWalletsPageViewed(); - this.props.actions.dialogs.open.trigger({ dialog: WalletListDialog }); + this.props.stores.uiDialogs.open({ dialog: WalletListDialog }); }} /> ); @@ -103,7 +103,7 @@ export default class NavBarContainerRevamp extends Component<{| ...StoresAndActi menu={this.props.menu} walletDetails={selected !== null ? : null} buyButton={ - this.props.actions.dialogs.open.trigger({ dialog: BuySellDialog })} /> + this.props.stores.uiDialogs.open({ dialog: BuySellDialog })} /> } pageBanner={pageBanner} /> diff --git a/packages/yoroi-extension/app/containers/settings/categories/SupportSettingsPage.js b/packages/yoroi-extension/app/containers/settings/categories/SupportSettingsPage.js index e0f6b21dac..ecb6d5b40b 100644 --- a/packages/yoroi-extension/app/containers/settings/categories/SupportSettingsPage.js +++ b/packages/yoroi-extension/app/containers/settings/categories/SupportSettingsPage.js @@ -35,7 +35,7 @@ export default class SupportSettingsPage extends Component prompt if they want to include it in the logs - this.props.actions.dialogs.open.trigger({ dialog: IncludePublicKeyDialog }); + this.props.stores.uiDialogs.open({ dialog: IncludePublicKeyDialog }); }; getDialog: void => Node = () => { diff --git a/packages/yoroi-extension/app/containers/settings/categories/WalletSettingsPage.js b/packages/yoroi-extension/app/containers/settings/categories/WalletSettingsPage.js index b858adb295..2871cf1a60 100644 --- a/packages/yoroi-extension/app/containers/settings/categories/WalletSettingsPage.js +++ b/packages/yoroi-extension/app/containers/settings/categories/WalletSettingsPage.js @@ -27,7 +27,7 @@ export default class WalletSettingsPage extends Component - actions.dialogs.open.trigger({ + stores.uiDialogs.open({ dialog: ChangeWalletPasswordDialogContainer, }) } @@ -81,20 +81,20 @@ export default class WalletSettingsPage extends Component - actions.dialogs.open.trigger({ + stores.uiDialogs.open({ dialog: ResyncWalletDialogContainer, }) } /> actions.dialogs.open.trigger({ + openDialog={() => stores.uiDialogs.open({ dialog: ExportWalletDialogContainer, })} /> - actions.dialogs.open.trigger({ + stores.uiDialogs.open({ dialog: RemoveWalletDialogContainer, }) } diff --git a/packages/yoroi-extension/app/containers/wallet/AddWalletPage.js b/packages/yoroi-extension/app/containers/wallet/AddWalletPage.js index ded81bb02b..62573d8c1c 100644 --- a/packages/yoroi-extension/app/containers/wallet/AddWalletPage.js +++ b/packages/yoroi-extension/app/containers/wallet/AddWalletPage.js @@ -46,7 +46,7 @@ export default class AddWalletPage extends Component { // so instead, the API gets reset before we start any dialog flow this.props.stores.profile.setSelectedNetwork(undefined); - this.props.actions.dialogs.open.trigger({ dialog }); + this.props.stores.uiDialogs.open({ dialog }); }; render(): Node { diff --git a/packages/yoroi-extension/app/containers/wallet/CreateWalletPageContainer.js b/packages/yoroi-extension/app/containers/wallet/CreateWalletPageContainer.js index 02ee28eeb8..40baef8f26 100644 --- a/packages/yoroi-extension/app/containers/wallet/CreateWalletPageContainer.js +++ b/packages/yoroi-extension/app/containers/wallet/CreateWalletPageContainer.js @@ -25,7 +25,7 @@ export default class CreateWalletPageContainer extends Component stores.substores.ada.wallets.createWallet(request)} setSelectedNetwork={stores.profile.setSelectedNetwork} selectedNetwork={stores.profile.selectedNetwork} - openDialog={dialog => this.props.actions.dialogs.open.trigger({ dialog })} + openDialog={dialog => this.props.stores.uiDialogs.open({ dialog })} closeDialog={this.props.actions.dialogs.closeActiveDialog.trigger} isDialogOpen={stores.uiDialogs.isOpen} goToRoute={route => stores.app.goToRoute({ route })} diff --git a/packages/yoroi-extension/app/containers/wallet/MyWalletsPage.js b/packages/yoroi-extension/app/containers/wallet/MyWalletsPage.js index a6d4b5ea78..b9e3494761 100644 --- a/packages/yoroi-extension/app/containers/wallet/MyWalletsPage.js +++ b/packages/yoroi-extension/app/containers/wallet/MyWalletsPage.js @@ -36,7 +36,7 @@ export default class MyWalletsPage extends Component { }; openDialogWrapper: any => void = dialog => { - this.props.actions.dialogs.open.trigger({ dialog }); + this.props.stores.uiDialogs.open({ dialog }); }; updateHideBalance: void => Promise = async () => { diff --git a/packages/yoroi-extension/app/containers/wallet/Wallet.js b/packages/yoroi-extension/app/containers/wallet/Wallet.js index 68fea54c36..b363343cc9 100644 --- a/packages/yoroi-extension/app/containers/wallet/Wallet.js +++ b/packages/yoroi-extension/app/containers/wallet/Wallet.js @@ -33,7 +33,7 @@ export default class Wallet extends Component<{| ...Props, ...StoresAndActionsPr componentDidMount() { if (!this.props.stores.profile.isRevampAnnounced) - this.props.actions.dialogs.open.trigger({ dialog: RevampAnnouncementDialog }); + this.props.stores.uiDialogs.open({ dialog: RevampAnnouncementDialog }); } checkRoute(): void | string { diff --git a/packages/yoroi-extension/app/containers/wallet/WalletReceivePage.js b/packages/yoroi-extension/app/containers/wallet/WalletReceivePage.js index 3ea8d1ce27..322762cf26 100644 --- a/packages/yoroi-extension/app/containers/wallet/WalletReceivePage.js +++ b/packages/yoroi-extension/app/containers/wallet/WalletReceivePage.js @@ -60,7 +60,7 @@ export default class WalletReceivePage extends Component 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({ + this.props.stores.uiDialogs.open({ dialog: LoadingSpinner, }); await stores.addresses.createAddress(publicDeriver); @@ -174,7 +174,7 @@ export default class WalletReceivePage extends Component - this.props.actions.dialogs.open.trigger({ + this.props.stores.uiDialogs.open({ dialog: UnmangleTxDialogContainer, }) } @@ -371,21 +371,21 @@ export default class WalletReceivePage extends Component }; openVerifyAddressDialog: void => void = (): void => { - const { actions } = this.props; - actions.dialogs.open.trigger({ dialog: VerifyAddressDialog }); + const { stores } = this.props; + stores.uiDialogs.open({ dialog: VerifyAddressDialog }); }; openURIGenerateDialog: (address: string, amount?: string) => void = (address, amount) => { - const { actions } = this.props; - actions.dialogs.open.trigger({ + const { stores } = this.props; + stores.uiDialogs.open({ dialog: URIGenerateDialog, params: { address, amount }, }); }; generateURI: (string, BigNumber) => void = (address, amount) => { - const { actions } = this.props; - actions.dialogs.open.trigger({ + const { stores } = this.props; + stores.uiDialogs.open({ dialog: URIDisplayDialog, params: { address, amount: amount.toString() }, }); diff --git a/packages/yoroi-extension/app/containers/wallet/WalletSummaryPage.js b/packages/yoroi-extension/app/containers/wallet/WalletSummaryPage.js index cd8484ba23..375c573cd5 100644 --- a/packages/yoroi-extension/app/containers/wallet/WalletSummaryPage.js +++ b/packages/yoroi-extension/app/containers/wallet/WalletSummaryPage.js @@ -187,7 +187,7 @@ export default class WalletSummaryPage extends Component shouldShowEmptyBanner={!isLoading && !hasAny} emptyBannerComponent={ this.props.actions.dialogs.open.trigger({ dialog: BuySellDialog })}/> + onBuySellClick={() => this.props.stores.uiDialogs.open({ dialog: BuySellDialog })}/> } /> diff --git a/packages/yoroi-extension/app/containers/wallet/restore/RestoreWalletPage.js b/packages/yoroi-extension/app/containers/wallet/restore/RestoreWalletPage.js index 4f02983b8f..0b810d1450 100644 --- a/packages/yoroi-extension/app/containers/wallet/restore/RestoreWalletPage.js +++ b/packages/yoroi-extension/app/containers/wallet/restore/RestoreWalletPage.js @@ -24,7 +24,7 @@ export default class RestoreWalletPage extends Component restoreWallet={stores.substores.ada.walletRestore.restoreWallet} stores={stores} actions={actions} - openDialog={dialog => this.props.actions.dialogs.open.trigger({ dialog })} + openDialog={dialog => this.props.stores.uiDialogs.open({ dialog })} closeDialog={this.props.actions.dialogs.closeActiveDialog.trigger} isDialogOpen={stores.uiDialogs.isOpen} /> diff --git a/packages/yoroi-extension/app/containers/wallet/staking/StakingDashboardPage.js b/packages/yoroi-extension/app/containers/wallet/staking/StakingDashboardPage.js index 1cc9d69a02..160a111bb7 100644 --- a/packages/yoroi-extension/app/containers/wallet/staking/StakingDashboardPage.js +++ b/packages/yoroi-extension/app/containers/wallet/staking/StakingDashboardPage.js @@ -240,7 +240,7 @@ export default class StakingDashboardPage extends Component { // 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 }); + this.props.stores.uiDialogs.open({ dialog: WithdrawalTxDialogContainer }); }} /> ); @@ -300,20 +300,20 @@ export default class StakingDashboardPage extends Component - this.props.actions.dialogs.open.trigger({ + this.props.stores.uiDialogs.open({ dialog: UnmangleTxDialogContainer, }) } totalSum={balance == null ? undefined : balance.joinAddCopy(rewardBalance)} totalRewards={showRewardAmount ? rewardBalance : undefined} openLearnMore={() => - this.props.actions.dialogs.open.trigger({ + this.props.stores.uiDialogs.open({ dialog: LessThanExpectedDialog, }) } withdrawRewards={ stakeRegistered ? () => { - this.props.actions.dialogs.open.trigger({ dialog: DeregisterDialogContainer }); + this.props.stores.uiDialogs.open({ dialog: DeregisterDialogContainer }); } : undefined } unitOfAccount={_entry => { diff --git a/packages/yoroi-extension/app/containers/wallet/staking/StakingPageContent.js b/packages/yoroi-extension/app/containers/wallet/staking/StakingPageContent.js index 635365312e..73c77294db 100644 --- a/packages/yoroi-extension/app/containers/wallet/staking/StakingPageContent.js +++ b/packages/yoroi-extension/app/containers/wallet/staking/StakingPageContent.js @@ -68,11 +68,11 @@ export default class StakingPageContent extends Component }; createWithdrawalTx: (shouldDeregister: boolean) => void = shouldDeregister => { - const { actions, stores } = this.props; + const { 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({ + stores.uiDialogs.open({ dialog: WithdrawRewardsDialog, }); }; @@ -204,21 +204,21 @@ export default class StakingPageContent extends Component return ( {isWalletWithNoFunds ? ( - this.props.actions.dialogs.open.trigger({ dialog: BuySellDialog })} /> + this.props.stores.uiDialogs.open({ dialog: BuySellDialog })} /> ) : null} {currentlyDelegating ? ( - actions.dialogs.open.trigger({ + stores.uiDialogs.open({ dialog: OverviewModal, }) } withdrawRewards={ isParticipatingToGovernance === false ? async () => { - this.props.actions.dialogs.open.trigger({ + this.props.stores.uiDialogs.open({ dialog: GovernanceParticipateDialog, }); } @@ -246,7 +246,7 @@ export default class StakingPageContent extends Component defaultTokenId: wallet.defaultTokenId, })} onOpenRewardList={() => - actions.dialogs.open.trigger({ + stores.uiDialogs.open({ dialog: RewardHistoryDialog, }) } @@ -275,13 +275,13 @@ export default class StakingPageContent extends Component withdrawRewards={ isParticipatingToGovernance === false ? () => { - this.props.actions.dialogs.open.trigger({ + this.props.stores.uiDialogs.open({ dialog: GovernanceParticipateDialog, }); } : isStakeRegistered ? () => { - this.props.actions.dialogs.open.trigger({ + this.props.stores.uiDialogs.open({ dialog: GovernanceParticipateDialog, }); } @@ -297,7 +297,7 @@ export default class StakingPageContent extends Component onNext={() => { // 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({ + this.props.stores.uiDialogs.open({ // dialog: WithdrawalTxDialogContainer, dialog: WithdrawRewardsDialog, }); diff --git a/packages/yoroi-extension/app/containers/wallet/voting/VotingPageContent.js b/packages/yoroi-extension/app/containers/wallet/voting/VotingPageContent.js index 1a3235a488..966e060c0b 100644 --- a/packages/yoroi-extension/app/containers/wallet/voting/VotingPageContent.js +++ b/packages/yoroi-extension/app/containers/wallet/voting/VotingPageContent.js @@ -65,7 +65,7 @@ class VotingPageContent extends Component { }; start: void => void = () => { - this.props.actions.dialogs.open.trigger({ dialog: VotingRegistrationDialogContainer }); + this.props.stores.uiDialogs.open({ dialog: VotingRegistrationDialogContainer }); }; render(): Node { diff --git a/packages/yoroi-extension/app/stores/ada/AdaDelegationTransactionStore.js b/packages/yoroi-extension/app/stores/ada/AdaDelegationTransactionStore.js index a14d39dcdd..5d0c80e61c 100644 --- a/packages/yoroi-extension/app/stores/ada/AdaDelegationTransactionStore.js +++ b/packages/yoroi-extension/app/stores/ada/AdaDelegationTransactionStore.js @@ -179,7 +179,7 @@ export default class AdaDelegationTransactionStore extends Store void = () => { diff --git a/packages/yoroi-extension/app/stores/toplevel/UiDialogsStore.js b/packages/yoroi-extension/app/stores/toplevel/UiDialogsStore.js index 7fe21dbb6d..89db5fa43c 100644 --- a/packages/yoroi-extension/app/stores/toplevel/UiDialogsStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/UiDialogsStore.js @@ -37,7 +37,6 @@ export default class UiDialogsStore< setup(): void { super.setup(); - this.actions.dialogs.open.listen(this._onOpen); this.actions.dialogs.closeActiveDialog.listen(this._onClose); } @@ -81,7 +80,7 @@ export default class UiDialogsStore< @action pop: void => void = () => { this.dialogList.pop(); } - @action _onOpen: {| dialog : any, params?: {...} |} => void = ({ dialog, params }) => { + @action open: {| dialog : any, params?: {...} |} => void = ({ dialog, params }) => { this.reset(); this.push({ dialog, diff --git a/packages/yoroi-extension/app/stores/toplevel/WalletBackupStore.js b/packages/yoroi-extension/app/stores/toplevel/WalletBackupStore.js index d51840a3e5..120f2bc7cc 100644 --- a/packages/yoroi-extension/app/stores/toplevel/WalletBackupStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/WalletBackupStore.js @@ -78,7 +78,7 @@ class WalletBackupStore extends Store { clearInterval(this.countdownTimerInterval); } }, 1000); - this.actions.dialogs.open.trigger({ + this.stores.uiDialogs.open({ dialog: WalletBackupDialog, }); }; From 3336ff0937b44337a44139e24facf6329cc639db Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Tue, 15 Oct 2024 10:12:51 +0300 Subject: [PATCH 44/76] removed dialog actions --- .../yoroi-extension/app/actions/dialogs-actions.js | 8 -------- packages/yoroi-extension/app/actions/index.js | 3 --- .../yoroi-extension/app/connector/actions/index.js | 3 --- .../yoroi-extension/app/connector/stores/index.js | 2 +- .../app/containers/NavBarContainerRevamp.js | 6 +++--- .../categories/ExportWalletDialogContainer.js | 2 +- .../settings/categories/IncludePublicKeyDialog.js | 9 ++++----- .../categories/RemoveWalletDialogContainer.js | 4 ++-- .../categories/ResyncWalletDialogContainer.js | 6 +++--- .../transfer/DeregisterDialogContainer.js | 4 ++-- .../app/containers/transfer/WalletTransferPage.js | 2 +- .../app/containers/uri/URILandingPage.js | 2 +- .../app/containers/wallet/AddWalletPage.js | 2 +- .../containers/wallet/CreateWalletPageContainer.js | 2 +- .../app/containers/wallet/MyWalletsPage.js | 2 +- .../app/containers/wallet/Wallet.js | 2 +- .../app/containers/wallet/WalletReceivePage.js | 8 ++++---- .../app/containers/wallet/WalletSendPage.js | 14 +++++++------- .../dialogs/ChangeWalletPasswordDialogContainer.js | 4 ++-- .../WalletSendConfirmationDialogContainer.js | 4 ++-- .../containers/wallet/restore/RestoreWalletPage.js | 2 +- .../wallet/staking/StakingDashboardPage.js | 6 +++--- .../wallet/staking/StakingPageContent.js | 6 +++--- .../containers/wallet/voting/VotingPageContent.js | 2 +- .../stores/ada/AdaDelegationTransactionStore.js | 2 +- .../app/stores/ada/HWVerifyAddressStore.js | 2 +- .../app/stores/ada/LedgerConnectStore.js | 4 ++-- .../app/stores/ada/TrezorConnectStore.js | 2 +- .../yoroi-extension/app/stores/ada/VotingStore.js | 2 +- .../app/stores/ada/send/AdaMnemonicSendStore.js | 2 +- .../app/stores/ada/send/LedgerSendStore.js | 4 ++-- .../app/stores/ada/send/TrezorSendStore.js | 4 ++-- packages/yoroi-extension/app/stores/index.js | 2 +- .../app/stores/toplevel/MemosStore.js | 2 +- .../app/stores/toplevel/TransactionsStore.js | 4 ++-- .../app/stores/toplevel/UiDialogsStore.js | 11 ++--------- .../app/stores/toplevel/WalletSettingsStore.js | 2 +- .../app/stores/toplevel/WalletStore.js | 2 +- 38 files changed, 64 insertions(+), 86 deletions(-) delete mode 100644 packages/yoroi-extension/app/actions/dialogs-actions.js diff --git a/packages/yoroi-extension/app/actions/dialogs-actions.js b/packages/yoroi-extension/app/actions/dialogs-actions.js deleted file mode 100644 index 3c936c5d25..0000000000 --- a/packages/yoroi-extension/app/actions/dialogs-actions.js +++ /dev/null @@ -1,8 +0,0 @@ -// @flow -import { Action } from './lib/Action'; - -// ======= DIALOGS ACTIONS ======= - -export default class DialogsActions { - closeActiveDialog: Action = new Action(); -} diff --git a/packages/yoroi-extension/app/actions/index.js b/packages/yoroi-extension/app/actions/index.js index 28ca07a05b..420a567ffd 100644 --- a/packages/yoroi-extension/app/actions/index.js +++ b/packages/yoroi-extension/app/actions/index.js @@ -1,12 +1,9 @@ // @flow -import DialogsActions from './dialogs-actions'; export type ActionsMap = {| - dialogs: DialogsActions, |}; const actionsMap: ActionsMap = Object.freeze({ - dialogs: new DialogsActions(), }); export default actionsMap; diff --git a/packages/yoroi-extension/app/connector/actions/index.js b/packages/yoroi-extension/app/connector/actions/index.js index a9ef504718..420a567ffd 100644 --- a/packages/yoroi-extension/app/connector/actions/index.js +++ b/packages/yoroi-extension/app/connector/actions/index.js @@ -1,12 +1,9 @@ // @flow -import DialogsActions from '../../actions/dialogs-actions'; export type ActionsMap = {| - dialogs: DialogsActions, |}; const actionsMap: ActionsMap = Object.freeze({ - dialogs: new DialogsActions(), }); export default actionsMap; diff --git a/packages/yoroi-extension/app/connector/stores/index.js b/packages/yoroi-extension/app/connector/stores/index.js index d4f21c0e55..089a95852e 100644 --- a/packages/yoroi-extension/app/connector/stores/index.js +++ b/packages/yoroi-extension/app/connector/stores/index.js @@ -30,7 +30,7 @@ const storeClasses = Object.freeze({ export type StoresMap = {| stateFetchStore: StateFetchStore, profile: ProfileStore, - uiDialogs: UiDialogsStore<{||}, ActionsMap>, + uiDialogs: UiDialogsStore<{||}>, uiNotifications: UiNotificationsStore<{||}>, explorers: ExplorerStore, coinPriceStore: ConnectorCoinPriceStore, diff --git a/packages/yoroi-extension/app/containers/NavBarContainerRevamp.js b/packages/yoroi-extension/app/containers/NavBarContainerRevamp.js index e83a3ce6a1..cb0325d4ee 100644 --- a/packages/yoroi-extension/app/containers/NavBarContainerRevamp.js +++ b/packages/yoroi-extension/app/containers/NavBarContainerRevamp.js @@ -147,14 +147,14 @@ export default class NavBarContainerRevamp extends Component<{| ...StoresAndActi selectedWalletId={selected?.publicDeriverId} close={() => { this.checkAndResetGovRoutes(); - this.props.actions.dialogs.closeActiveDialog.trigger(); + this.props.stores.uiDialogs.closeActiveDialog(); }} shouldHideBalance={stores.profile.shouldHideBalance} onUpdateHideBalance={this.updateHideBalance} getTokenInfo={getTokenInfo} walletAmount={selected?.balance} onAddWallet={() => { - this.props.actions.dialogs.closeActiveDialog.trigger(); + this.props.stores.uiDialogs.closeActiveDialog(); stores.app.goToRoute({ route: ROUTES.WALLETS.ADD }); }} updateSortedWalletList={stores.profile.updateSortedWalletList} @@ -179,7 +179,7 @@ export default class NavBarContainerRevamp extends Component<{| ...StoresAndActi return ( stores.app.goToRoute({ route: ROUTES.EXCHANGE_END }) } diff --git a/packages/yoroi-extension/app/containers/settings/categories/ExportWalletDialogContainer.js b/packages/yoroi-extension/app/containers/settings/categories/ExportWalletDialogContainer.js index 3977260d93..71abd39c5a 100644 --- a/packages/yoroi-extension/app/containers/settings/categories/ExportWalletDialogContainer.js +++ b/packages/yoroi-extension/app/containers/settings/categories/ExportWalletDialogContainer.js @@ -26,7 +26,7 @@ export default class ExportWalletDialogContainer extends Component { } return ( diff --git a/packages/yoroi-extension/app/containers/settings/categories/IncludePublicKeyDialog.js b/packages/yoroi-extension/app/containers/settings/categories/IncludePublicKeyDialog.js index f92299e613..375974c2f8 100644 --- a/packages/yoroi-extension/app/containers/settings/categories/IncludePublicKeyDialog.js +++ b/packages/yoroi-extension/app/containers/settings/categories/IncludePublicKeyDialog.js @@ -12,7 +12,6 @@ import type { StoresAndActionsProps } from '../../../types/injectedProps.types'; import DangerousActionDialog from '../../../components/widgets/DangerousActionDialog'; type Props = {| - ...StoresAndActionsProps, +downloadIncludingKey: void => void, +downloadExcludingKey: void => void, |}; @@ -33,7 +32,7 @@ const dialogMessages = defineMessages({ }); @observer -export default class IncludePublicKeyDialog extends Component { +export default class IncludePublicKeyDialog extends Component<{| ...Props, ...StoresAndActionsProps |}> { static contextTypes: {|intl: $npm$ReactIntl$IntlFormat|} = { intl: intlShape.isRequired, }; @@ -56,19 +55,19 @@ export default class IncludePublicKeyDialog extends Component { toggleCheck={this.toggleCheck} isSubmitting={false} error={undefined} - onCancel={this.props.actions.dialogs.closeActiveDialog.trigger} + onCancel={this.props.stores.uiDialogs.closeActiveDialog} primaryButton={{ label: intl.formatMessage(dialogMessages.withKey), onClick: () => { this.props.downloadIncludingKey(); - this.props.actions.dialogs.closeActiveDialog.trigger(); + this.props.stores.uiDialogs.closeActiveDialog(); } }} secondaryButton={{ label: intl.formatMessage(dialogMessages.withoutKey), onClick: () => { this.props.downloadExcludingKey(); - this.props.actions.dialogs.closeActiveDialog.trigger(); + this.props.stores.uiDialogs.closeActiveDialog(); } }} id="includePublicKeyDialog" diff --git a/packages/yoroi-extension/app/containers/settings/categories/RemoveWalletDialogContainer.js b/packages/yoroi-extension/app/containers/settings/categories/RemoveWalletDialogContainer.js index 599db98e09..ff30a1992e 100644 --- a/packages/yoroi-extension/app/containers/settings/categories/RemoveWalletDialogContainer.js +++ b/packages/yoroi-extension/app/containers/settings/categories/RemoveWalletDialogContainer.js @@ -78,13 +78,13 @@ export default class RemoveWalletDialogContainer extends Component { toggleCheck={this.toggleCheck} isSubmitting={settingsStore.removeWalletRequest.isExecuting} error={settingsStore.removeWalletRequest.error} - onCancel={this.props.actions.dialogs.closeActiveDialog.trigger} + onCancel={this.props.stores.uiDialogs.closeActiveDialog} primaryButton={{ label: intl.formatMessage(globalMessages.remove), onClick: this.removeWalletRevamp, }} secondaryButton={{ - onClick: this.props.actions.dialogs.closeActiveDialog.trigger, + onClick: this.props.stores.uiDialogs.closeActiveDialog, }} id="removeWalletDialog" > diff --git a/packages/yoroi-extension/app/containers/settings/categories/ResyncWalletDialogContainer.js b/packages/yoroi-extension/app/containers/settings/categories/ResyncWalletDialogContainer.js index 7db544c9d2..9a26f8dfd0 100644 --- a/packages/yoroi-extension/app/containers/settings/categories/ResyncWalletDialogContainer.js +++ b/packages/yoroi-extension/app/containers/settings/categories/ResyncWalletDialogContainer.js @@ -59,12 +59,12 @@ export default class ResyncWalletDialogContainer extends Component<{| ...Props, await this.props.stores.walletSettings.resyncHistory({ publicDeriverId: this.props.publicDeriverId, }); - this.props.actions.dialogs.closeActiveDialog.trigger(); + this.props.stores.uiDialogs.closeActiveDialog(); }, }} - onCancel={this.props.actions.dialogs.closeActiveDialog.trigger} + onCancel={this.props.stores.uiDialogs.closeActiveDialog} secondaryButton={{ - onClick: this.props.actions.dialogs.closeActiveDialog.trigger, + onClick: this.props.stores.uiDialogs.closeActiveDialog, }} id="resyncWalletDialog" > diff --git a/packages/yoroi-extension/app/containers/transfer/DeregisterDialogContainer.js b/packages/yoroi-extension/app/containers/transfer/DeregisterDialogContainer.js index 61eda18144..3777d958f4 100644 --- a/packages/yoroi-extension/app/containers/transfer/DeregisterDialogContainer.js +++ b/packages/yoroi-extension/app/containers/transfer/DeregisterDialogContainer.js @@ -85,7 +85,7 @@ export default class DeregisterDialogContainer extends Component<{| ...StoresAnd render(): Node { const { intl } = this.context; - const { actions, stores } = this.props; + const { stores } = this.props; return ( { diff --git a/packages/yoroi-extension/app/containers/transfer/WalletTransferPage.js b/packages/yoroi-extension/app/containers/transfer/WalletTransferPage.js index 62e4935563..77352f0398 100644 --- a/packages/yoroi-extension/app/containers/transfer/WalletTransferPage.js +++ b/packages/yoroi-extension/app/containers/transfer/WalletTransferPage.js @@ -24,7 +24,7 @@ export default class WalletTransferPage extends Component<{| ...Props, ...Stores }; onClose: void => void = () => { - this.props.actions.dialogs.closeActiveDialog.trigger(); + this.props.stores.uiDialogs.closeActiveDialog(); }; // paper diff --git a/packages/yoroi-extension/app/containers/uri/URILandingPage.js b/packages/yoroi-extension/app/containers/uri/URILandingPage.js index 40cb0b590b..c647a214a5 100644 --- a/packages/yoroi-extension/app/containers/uri/URILandingPage.js +++ b/packages/yoroi-extension/app/containers/uri/URILandingPage.js @@ -12,7 +12,7 @@ import { getNetworkById } from '../../api/ada/lib/storage/database/prepackaged/n export default class URILandingPage extends Component { onClose: void => void = () => { const { stores } = this.props; - this.props.actions.dialogs.closeActiveDialog.trigger(); + this.props.stores.uiDialogs.closeActiveDialog(); stores.app.goToRoute({ route: ROUTES.WALLETS.ROOT }); stores.loading.resetUriParams(); }; diff --git a/packages/yoroi-extension/app/containers/wallet/AddWalletPage.js b/packages/yoroi-extension/app/containers/wallet/AddWalletPage.js index 62573d8c1c..b91a30e266 100644 --- a/packages/yoroi-extension/app/containers/wallet/AddWalletPage.js +++ b/packages/yoroi-extension/app/containers/wallet/AddWalletPage.js @@ -36,7 +36,7 @@ export default class AddWalletPage extends Component { if (!this.props.stores.wallets.hasAnyWallets) { this.props.stores.app.goToRoute({ route: ROUTES.WALLETS.ADD }); } - this.props.actions.dialogs.closeActiveDialog.trigger(); + this.props.stores.uiDialogs.closeActiveDialog(); }; openDialogWrapper: any => void = dialog => { diff --git a/packages/yoroi-extension/app/containers/wallet/CreateWalletPageContainer.js b/packages/yoroi-extension/app/containers/wallet/CreateWalletPageContainer.js index 40baef8f26..052c741f42 100644 --- a/packages/yoroi-extension/app/containers/wallet/CreateWalletPageContainer.js +++ b/packages/yoroi-extension/app/containers/wallet/CreateWalletPageContainer.js @@ -26,7 +26,7 @@ export default class CreateWalletPageContainer extends Component this.props.stores.uiDialogs.open({ dialog })} - closeDialog={this.props.actions.dialogs.closeActiveDialog.trigger} + closeDialog={this.props.stores.uiDialogs.closeActiveDialog} isDialogOpen={stores.uiDialogs.isOpen} goToRoute={route => stores.app.goToRoute({ route })} /> diff --git a/packages/yoroi-extension/app/containers/wallet/MyWalletsPage.js b/packages/yoroi-extension/app/containers/wallet/MyWalletsPage.js index b9e3494761..b49d0c16d4 100644 --- a/packages/yoroi-extension/app/containers/wallet/MyWalletsPage.js +++ b/packages/yoroi-extension/app/containers/wallet/MyWalletsPage.js @@ -32,7 +32,7 @@ export default class MyWalletsPage extends Component { }; onClose: void => void = () => { - this.props.actions.dialogs.closeActiveDialog.trigger(); + this.props.stores.uiDialogs.closeActiveDialog(); }; openDialogWrapper: any => void = dialog => { diff --git a/packages/yoroi-extension/app/containers/wallet/Wallet.js b/packages/yoroi-extension/app/containers/wallet/Wallet.js index b363343cc9..52f02b03da 100644 --- a/packages/yoroi-extension/app/containers/wallet/Wallet.js +++ b/packages/yoroi-extension/app/containers/wallet/Wallet.js @@ -209,7 +209,7 @@ export default class Wallet extends Component<{| ...Props, ...StoresAndActionsPr { stores.profile.markRevampAsAnnounced(); - this.props.actions.dialogs.closeActiveDialog.trigger(); + this.props.stores.uiDialogs.closeActiveDialog(); }} /> ); diff --git a/packages/yoroi-extension/app/containers/wallet/WalletReceivePage.js b/packages/yoroi-extension/app/containers/wallet/WalletReceivePage.js index 322762cf26..279f4e081f 100644 --- a/packages/yoroi-extension/app/containers/wallet/WalletReceivePage.js +++ b/packages/yoroi-extension/app/containers/wallet/WalletReceivePage.js @@ -64,7 +64,7 @@ export default class WalletReceivePage extends Component dialog: LoadingSpinner, }); await stores.addresses.createAddress(publicDeriver); - this.props.actions.dialogs.closeActiveDialog.trigger(); + this.props.stores.uiDialogs.closeActiveDialog(); } }; @@ -271,7 +271,7 @@ export default class WalletReceivePage extends Component if (val == null) return null; return new BigNumber(val); })()} - onClose={() => actions.dialogs.closeActiveDialog.trigger()} + onClose={() => stores.uiDialogs.closeActiveDialog()} onGenerate={(address, amount) => { this.generateURI(address, amount); }} @@ -293,7 +293,7 @@ export default class WalletReceivePage extends Component this.openURIGenerateDialog(paramAddress, paramAmount)} onCopyAddressTooltip={elementId => { if (!uiNotifications.isOpen(elementId)) { @@ -315,7 +315,7 @@ export default class WalletReceivePage extends Component this.props.actions.dialogs.closeActiveDialog.trigger()} + onClose={() => this.props.stores.uiDialogs.closeActiveDialog()} /> )} diff --git a/packages/yoroi-extension/app/containers/wallet/WalletSendPage.js b/packages/yoroi-extension/app/containers/wallet/WalletSendPage.js index d104ae1d44..4dc7dfd72b 100644 --- a/packages/yoroi-extension/app/containers/wallet/WalletSendPage.js +++ b/packages/yoroi-extension/app/containers/wallet/WalletSendPage.js @@ -65,7 +65,7 @@ export default class WalletSendPage extends Component { if (redirect) { window.document.location = redirect; } else { - this.props.actions.dialogs.closeActiveDialog.trigger(); + this.props.stores.uiDialogs.closeActiveDialog(); stores.app.goToRoute({ route: ROUTES.WALLETS.TRANSACTIONS }); } }; @@ -95,7 +95,7 @@ export default class WalletSendPage extends Component { }; openDialog: any => void = dialog => { - this.props.actions.dialogs.closeActiveDialog.trigger(); + this.props.stores.uiDialogs.closeActiveDialog(); this.props.stores.uiDialogs.push({ dialog, }); @@ -122,7 +122,7 @@ export default class WalletSendPage extends Component { } render(): Node { - const { actions, stores } = this.props; + const { stores } = this.props; const { selected } = stores.wallets; if (!selected) throw new Error(`Active wallet required for ${nameof(WalletSendPage)}.`); @@ -144,7 +144,7 @@ export default class WalletSendPage extends Component { uiDialogs.isOpen(WalletSendConfirmationDialog)) && hasAnyPending ) { - actions.dialogs.closeActiveDialog.trigger(); + stores.uiDialogs.closeActiveDialog(); } const defaultToken = stores.tokenInfoStore.getDefaultTokenInfo( @@ -199,7 +199,7 @@ export default class WalletSendPage extends Component { plannedTxInfoMap={transactionBuilderStore.plannedTxInfoMap} isDefaultIncluded={transactionBuilderStore.isDefaultIncluded} openDialog={this.openDialog} - closeDialog={this.props.actions.dialogs.closeActiveDialog.trigger} + closeDialog={this.props.stores.uiDialogs.closeActiveDialog} isOpen={uiDialogs.isOpen} openTransactionSuccessDialog={this.openTransactionSuccessDialog.bind(this)} unitOfAccountSetting={stores.profile.unitOfAccount} @@ -479,7 +479,7 @@ export default class WalletSendPage extends Component { return ( transactionBuilderStore.updateAmount(value)} @@ -503,7 +503,7 @@ export default class WalletSendPage extends Component { { transactionBuilderStore.deselectToken(); - this.props.actions.dialogs.closeActiveDialog.trigger(); + this.props.stores.uiDialogs.closeActiveDialog(); }} spendableBalance={this.props.stores.transactions.balance} getTokenInfo={genLookupOrFail(this.props.stores.tokenInfoStore.tokenInfo)} diff --git a/packages/yoroi-extension/app/containers/wallet/dialogs/ChangeWalletPasswordDialogContainer.js b/packages/yoroi-extension/app/containers/wallet/dialogs/ChangeWalletPasswordDialogContainer.js index 62e95c3cea..965a93b9c0 100644 --- a/packages/yoroi-extension/app/containers/wallet/dialogs/ChangeWalletPasswordDialogContainer.js +++ b/packages/yoroi-extension/app/containers/wallet/dialogs/ChangeWalletPasswordDialogContainer.js @@ -13,7 +13,7 @@ type Props = {| export default class ChangeWalletPasswordDialogContainer extends Component<{| ...Props, ...StoresAndActionsProps |}> { render(): Node { - const { actions, stores } = this.props; + const { stores } = this.props; const { uiDialogs, walletSettings } = stores; const { changeSigningKeyRequest } = walletSettings; @@ -33,7 +33,7 @@ export default class ChangeWalletPasswordDialogContainer extends Component<{| .. }); }} onCancel={() => { - actions.dialogs.closeActiveDialog.trigger(); + stores.uiDialogs.closeActiveDialog(); changeSigningKeyRequest.reset(); }} onPasswordSwitchToggle={() => { diff --git a/packages/yoroi-extension/app/containers/wallet/dialogs/WalletSendConfirmationDialogContainer.js b/packages/yoroi-extension/app/containers/wallet/dialogs/WalletSendConfirmationDialogContainer.js index e4d85b14b5..9a5aac9ed5 100644 --- a/packages/yoroi-extension/app/containers/wallet/dialogs/WalletSendConfirmationDialogContainer.js +++ b/packages/yoroi-extension/app/containers/wallet/dialogs/WalletSendConfirmationDialogContainer.js @@ -36,7 +36,7 @@ export default class WalletSendConfirmationDialogContainer extends Component { - actions.dialogs.closeActiveDialog.trigger(); + stores.uiDialogs.closeActiveDialog(); sendMoneyRequest.reset(); }} error={sendMoneyRequest.error} diff --git a/packages/yoroi-extension/app/containers/wallet/restore/RestoreWalletPage.js b/packages/yoroi-extension/app/containers/wallet/restore/RestoreWalletPage.js index 0b810d1450..4969660c6b 100644 --- a/packages/yoroi-extension/app/containers/wallet/restore/RestoreWalletPage.js +++ b/packages/yoroi-extension/app/containers/wallet/restore/RestoreWalletPage.js @@ -25,7 +25,7 @@ export default class RestoreWalletPage extends Component stores={stores} actions={actions} openDialog={dialog => this.props.stores.uiDialogs.open({ dialog })} - closeDialog={this.props.actions.dialogs.closeActiveDialog.trigger} + closeDialog={this.props.stores.uiDialogs.closeActiveDialog} isDialogOpen={stores.uiDialogs.isOpen} /> diff --git a/packages/yoroi-extension/app/containers/wallet/staking/StakingDashboardPage.js b/packages/yoroi-extension/app/containers/wallet/staking/StakingDashboardPage.js index 160a111bb7..7bafe21ba4 100644 --- a/packages/yoroi-extension/app/containers/wallet/staking/StakingDashboardPage.js +++ b/packages/yoroi-extension/app/containers/wallet/staking/StakingDashboardPage.js @@ -216,7 +216,7 @@ export default class StakingDashboardPage extends Component this.props.actions.dialogs.closeActiveDialog.trigger()} + close={() => this.props.stores.uiDialogs.closeActiveDialog()} /> ); } @@ -226,7 +226,7 @@ export default class StakingDashboardPage extends Component this.props.actions.dialogs.closeActiveDialog.trigger()} + onClose={() => this.props.stores.uiDialogs.closeActiveDialog()} /> ); } @@ -252,7 +252,7 @@ export default class StakingDashboardPage extends Component { stores.substores.ada.delegationTransaction.reset({ justTransaction: false }); - this.props.actions.dialogs.closeActiveDialog.trigger(); + this.props.stores.uiDialogs.closeActiveDialog(); }} /> ); diff --git a/packages/yoroi-extension/app/containers/wallet/staking/StakingPageContent.js b/packages/yoroi-extension/app/containers/wallet/staking/StakingPageContent.js index 73c77294db..00757ea520 100644 --- a/packages/yoroi-extension/app/containers/wallet/staking/StakingPageContent.js +++ b/packages/yoroi-extension/app/containers/wallet/staking/StakingPageContent.js @@ -40,7 +40,7 @@ export default class StakingPageContent extends Component }; onClose: void => void = () => { - this.props.actions.dialogs.closeActiveDialog.trigger(); + this.props.stores.uiDialogs.closeActiveDialog(); }; async componentDidMount() { @@ -316,7 +316,7 @@ export default class StakingPageContent extends Component stores={stores} onClose={() => { stores.substores.ada.delegationTransaction.reset({ justTransaction: false }); - this.props.actions.dialogs.closeActiveDialog.trigger(); + this.props.stores.uiDialogs.closeActiveDialog(); }} /> ) : null} @@ -326,7 +326,7 @@ export default class StakingPageContent extends Component stores={stores} onClose={() => { stores.substores.ada.delegationTransaction.reset({ justTransaction: false }); - this.props.actions.dialogs.closeActiveDialog.trigger(); + this.props.stores.uiDialogs.closeActiveDialog(); }} /> ) : null} diff --git a/packages/yoroi-extension/app/containers/wallet/voting/VotingPageContent.js b/packages/yoroi-extension/app/containers/wallet/voting/VotingPageContent.js index 966e060c0b..3316693a4e 100644 --- a/packages/yoroi-extension/app/containers/wallet/voting/VotingPageContent.js +++ b/packages/yoroi-extension/app/containers/wallet/voting/VotingPageContent.js @@ -61,7 +61,7 @@ class VotingPageContent extends Component { static contextTypes: {| intl: $npm$ReactIntl$IntlFormat |} = { intl: intlShape.isRequired }; onClose: void => void = () => { - this.props.actions.dialogs.closeActiveDialog.trigger(); + this.props.stores.uiDialogs.closeActiveDialog(); }; start: void => void = () => { diff --git a/packages/yoroi-extension/app/stores/ada/AdaDelegationTransactionStore.js b/packages/yoroi-extension/app/stores/ada/AdaDelegationTransactionStore.js index 5d0c80e61c..4151c28a0b 100644 --- a/packages/yoroi-extension/app/stores/ada/AdaDelegationTransactionStore.js +++ b/packages/yoroi-extension/app/stores/ada/AdaDelegationTransactionStore.js @@ -183,7 +183,7 @@ export default class AdaDelegationTransactionStore extends Store void = () => { - this.actions.dialogs.closeActiveDialog.trigger(); + this.stores.uiDialogs.closeActiveDialog(); this.goToDashboardRoute(); }; diff --git a/packages/yoroi-extension/app/stores/ada/HWVerifyAddressStore.js b/packages/yoroi-extension/app/stores/ada/HWVerifyAddressStore.js index d5f03a9a46..d03d2c134d 100644 --- a/packages/yoroi-extension/app/stores/ada/HWVerifyAddressStore.js +++ b/packages/yoroi-extension/app/stores/ada/HWVerifyAddressStore.js @@ -176,6 +176,6 @@ export default class HWVerifyAddressStore extends Store { this.selectedAddress = null; this._setError(null); this._setActionProcessing(false); - this.actions.dialogs.closeActiveDialog.trigger(); + this.stores.uiDialogs.closeActiveDialog(); } } diff --git a/packages/yoroi-extension/app/stores/ada/LedgerConnectStore.js b/packages/yoroi-extension/app/stores/ada/LedgerConnectStore.js index 75164880ff..0241ff89df 100644 --- a/packages/yoroi-extension/app/stores/ada/LedgerConnectStore.js +++ b/packages/yoroi-extension/app/stores/ada/LedgerConnectStore.js @@ -395,7 +395,7 @@ export default class LedgerConnectStore const { stores } = this; Logger.debug(`${nameof(LedgerConnectStore)}::${nameof(this._onSaveSuccess)} success`); if (stores.substores.ada.yoroiTransfer.transferRequest.result == null) { - this.actions.dialogs.closeActiveDialog.trigger(); + this.stores.uiDialogs.closeActiveDialog(); } await stores.wallets.addHwWallet(wallet); @@ -414,7 +414,7 @@ export default class LedgerConnectStore } finishTransfer: void => void = () => { - this.actions.dialogs.closeActiveDialog.trigger(); + this.stores.uiDialogs.closeActiveDialog(); this.stores.app.goToRoute({ route: ROUTES.WALLETS.ROOT }); // show success notification diff --git a/packages/yoroi-extension/app/stores/ada/TrezorConnectStore.js b/packages/yoroi-extension/app/stores/ada/TrezorConnectStore.js index e97b3ff2ac..bb72248b3d 100644 --- a/packages/yoroi-extension/app/stores/ada/TrezorConnectStore.js +++ b/packages/yoroi-extension/app/stores/ada/TrezorConnectStore.js @@ -350,7 +350,7 @@ export default class TrezorConnectStore _onSaveSuccess: (WalletState) => Promise = async (wallet) => { // close the active dialog Logger.debug(`${nameof(TrezorConnectStore)}::${nameof(this._onSaveSuccess)} success, closing dialog`); - this.actions.dialogs.closeActiveDialog.trigger(); + this.stores.uiDialogs.closeActiveDialog(); const { stores } = this; await stores.wallets.addHwWallet(wallet); diff --git a/packages/yoroi-extension/app/stores/ada/VotingStore.js b/packages/yoroi-extension/app/stores/ada/VotingStore.js index e669e3d3b8..68bef801e6 100644 --- a/packages/yoroi-extension/app/stores/ada/VotingStore.js +++ b/packages/yoroi-extension/app/stores/ada/VotingStore.js @@ -170,7 +170,7 @@ export default class VotingStore extends Store { @action finishQRCode: void => void = () => { - this.actions.dialogs.closeActiveDialog.trigger(); + this.stores.uiDialogs.closeActiveDialog(); this.stores.app.goToRoute({ route: ROUTES.WALLETS.TRANSACTIONS }); this.reset({ justTransaction: false }); } diff --git a/packages/yoroi-extension/app/stores/ada/send/AdaMnemonicSendStore.js b/packages/yoroi-extension/app/stores/ada/send/AdaMnemonicSendStore.js index 595817ded6..2785206a39 100644 --- a/packages/yoroi-extension/app/stores/ada/send/AdaMnemonicSendStore.js +++ b/packages/yoroi-extension/app/stores/ada/send/AdaMnemonicSendStore.js @@ -41,7 +41,7 @@ export default class AdaMnemonicSendStore extends Store { refreshWallet: () => stores.wallets.refreshWalletFromRemote(request.wallet.publicDeriverId), }); - this.actions.dialogs.closeActiveDialog.trigger(); + this.stores.uiDialogs.closeActiveDialog(); stores.wallets.sendMoneyRequest.reset(); if (request.onSuccess) { request.onSuccess(); diff --git a/packages/yoroi-extension/app/stores/ada/send/LedgerSendStore.js b/packages/yoroi-extension/app/stores/ada/send/LedgerSendStore.js index b5cfaa3973..fe69f7d39e 100644 --- a/packages/yoroi-extension/app/stores/ada/send/LedgerSendStore.js +++ b/packages/yoroi-extension/app/stores/ada/send/LedgerSendStore.js @@ -122,7 +122,7 @@ export default class LedgerSendStore extends Store { refreshWallet: () => stores.wallets.refreshWalletFromRemote(request.wallet.publicDeriverId), }); - this.actions.dialogs.closeActiveDialog.trigger(); + this.stores.uiDialogs.closeActiveDialog(); stores.wallets.sendMoneyRequest.reset(); if (request.onSuccess) { request.onSuccess(); @@ -429,7 +429,7 @@ export default class LedgerSendStore extends Store { cancel: void => void = () => { if (!this.isActionProcessing) { - this.actions.dialogs.closeActiveDialog.trigger(); + this.stores.uiDialogs.closeActiveDialog(); 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 f427ad76bb..fe81975c2c 100644 --- a/packages/yoroi-extension/app/stores/ada/send/TrezorSendStore.js +++ b/packages/yoroi-extension/app/stores/ada/send/TrezorSendStore.js @@ -83,7 +83,7 @@ export default class TrezorSendStore extends Store { refreshWallet: () => stores.wallets.refreshWalletFromRemote(request.wallet.publicDeriverId), }); - this.actions.dialogs.closeActiveDialog.trigger(); + this.stores.uiDialogs.closeActiveDialog(); stores.wallets.sendMoneyRequest.reset(); if (request.onSuccess) { request.onSuccess(); @@ -332,7 +332,7 @@ export default class TrezorSendStore extends Store { cancel: void => void = () => { if (!this.isActionProcessing) { - this.actions.dialogs.closeActiveDialog.trigger(); + this.stores.uiDialogs.closeActiveDialog(); this.reset(); } } diff --git a/packages/yoroi-extension/app/stores/index.js b/packages/yoroi-extension/app/stores/index.js index d4a484d3bb..b0a6675011 100644 --- a/packages/yoroi-extension/app/stores/index.js +++ b/packages/yoroi-extension/app/stores/index.js @@ -64,7 +64,7 @@ export type StoresMap = {| app: AppStore, memos: MemosStore, walletBackup: WalletBackupStore, - uiDialogs: UiDialogsStore<{||}, ActionsMap>, + uiDialogs: UiDialogsStore<{||}>, uiNotifications: UiNotificationsStore<{||}>, loading: LoadingStore, wallets: WalletStore, diff --git a/packages/yoroi-extension/app/stores/toplevel/MemosStore.js b/packages/yoroi-extension/app/stores/toplevel/MemosStore.js index 6dec7f0642..75d6262a3c 100644 --- a/packages/yoroi-extension/app/stores/toplevel/MemosStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/MemosStore.js @@ -161,7 +161,7 @@ export default class MemosStore extends Store { @action closeMemoDialog: void => void = () => { this._setError(null); - this.actions.dialogs.closeActiveDialog.trigger(); + this.stores.uiDialogs.closeActiveDialog(); } @action selectTransaction: {| tx: WalletTransaction |} => void = (params) => { diff --git a/packages/yoroi-extension/app/stores/toplevel/TransactionsStore.js b/packages/yoroi-extension/app/stores/toplevel/TransactionsStore.js index 942d9e63fb..d66589d037 100644 --- a/packages/yoroi-extension/app/stores/toplevel/TransactionsStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/TransactionsStore.js @@ -270,7 +270,7 @@ export default class TransactionsStore extends Store { setTimeout(async () => { await continuation(); this._setExporting(false); - this.actions.dialogs.closeActiveDialog.trigger(); + this.stores.uiDialogs.closeActiveDialog(); runInAction(() => { this.shouldIncludeTxIds = false; }); @@ -304,7 +304,7 @@ export default class TransactionsStore extends Store { @action closeExportTransactionDialog: void => void = () => { if (!this.isExporting) { - this.actions.dialogs.closeActiveDialog.trigger(); + this.stores.uiDialogs.closeActiveDialog(); this._setExporting(false); this._setExportError(null); } diff --git a/packages/yoroi-extension/app/stores/toplevel/UiDialogsStore.js b/packages/yoroi-extension/app/stores/toplevel/UiDialogsStore.js index 89db5fa43c..7ab8746d0e 100644 --- a/packages/yoroi-extension/app/stores/toplevel/UiDialogsStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/UiDialogsStore.js @@ -1,7 +1,6 @@ // @flow import { computed, observable, action, } from 'mobx'; import Store from '../base/Store'; -import DialogsActions from '../../actions/dialogs-actions'; type DialogEntry = {| dialog: any, @@ -29,17 +28,11 @@ type DialogEntry = {| */ export default class UiDialogsStore< TStores, - TActions: { dialogs: DialogsActions, ... }, -> extends Store +> extends Store { @observable dialogList: Array = []; - setup(): void { - super.setup(); - this.actions.dialogs.closeActiveDialog.listen(this._onClose); - } - @computed get hasOpen(): boolean { return this.dialogList.length > 0; @@ -88,7 +81,7 @@ export default class UiDialogsStore< }); }; - @action _onClose: void => void = () => { + @action closeActiveDialog: void => void = () => { this.reset(); }; diff --git a/packages/yoroi-extension/app/stores/toplevel/WalletSettingsStore.js b/packages/yoroi-extension/app/stores/toplevel/WalletSettingsStore.js index a58dffd140..ff2f5093d0 100644 --- a/packages/yoroi-extension/app/stores/toplevel/WalletSettingsStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/WalletSettingsStore.js @@ -73,7 +73,7 @@ export default class WalletSettingsStore extends Store { await this.changeSigningKeyRequest.execute(async () => { await changeSigningKeyPassword(request); }); - this.actions.dialogs.closeActiveDialog.trigger(); + this.stores.uiDialogs.closeActiveDialog(); this.changeSigningKeyRequest.reset(); }; diff --git a/packages/yoroi-extension/app/stores/toplevel/WalletStore.js b/packages/yoroi-extension/app/stores/toplevel/WalletStore.js index 685dad9eeb..8a8153ab9e 100644 --- a/packages/yoroi-extension/app/stores/toplevel/WalletStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/WalletStore.js @@ -181,7 +181,7 @@ export default class WalletStore extends Store { this.setActiveWallet({ publicDeriverId: newWallet.publicDeriverId, }); - this.actions.dialogs.closeActiveDialog.trigger(); + this.stores.uiDialogs.closeActiveDialog(); this.initialSyncingWalletIds.add(newWallet.publicDeriverId); this.stores.app.goToRoute({ route: ROUTES.WALLETS.ROOT }); }); From ffcc2d7502bd3c773fe13005263de8610368afa1 Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Tue, 15 Oct 2024 10:14:34 +0300 Subject: [PATCH 45/76] removed Action type --- .../yoroi-extension/app/actions/lib/Action.js | 54 ------------------- .../chrome/extension/connector/index.js | 2 - .../yoroi-extension/chrome/extension/index.js | 2 - 3 files changed, 58 deletions(-) delete mode 100644 packages/yoroi-extension/app/actions/lib/Action.js diff --git a/packages/yoroi-extension/app/actions/lib/Action.js b/packages/yoroi-extension/app/actions/lib/Action.js deleted file mode 100644 index dba26f5ed4..0000000000 --- a/packages/yoroi-extension/app/actions/lib/Action.js +++ /dev/null @@ -1,54 +0,0 @@ -// @flow -import { bindAll } from 'lodash'; - -/** - * Listener type as Function that takes specific params

    - */ -export type SyncListener

    = (params: P) => void; -export type AsyncListener

    = (params: P) => Promise; - -class BaseAction { - - /** - * Array of all defined actions in the system - * @type {[BaseAction]} - */ - static actions: BaseAction[] = []; - - static resetAllActions(): void { - Action.actions.forEach(action => action.removeAll()); - } - - listeners: ListenerType[] = []; - - constructor() { - bindAll(this, ['trigger']); - BaseAction.actions.push(this); - } - - listen(listener: ListenerType): void { - this.listeners.push(listener); - } - - remove(listener: ListenerType): void { - this.listeners.splice(this.listeners.indexOf(listener), 1); - } - - removeAll(): void { - this.listeners = []; - } -} - -export class Action extends BaseAction, Params> { - trigger(params: Params): void { - this.listeners.forEach(listener => listener(params)); - } -} - -export class AsyncAction extends BaseAction, Params> { - async trigger(params: Params): Promise { - for (const listener of this.listeners) { - await listener(params); - } - } -} diff --git a/packages/yoroi-extension/chrome/extension/connector/index.js b/packages/yoroi-extension/chrome/extension/connector/index.js index 3f9b45b0e3..29cddf2592 100644 --- a/packages/yoroi-extension/chrome/extension/connector/index.js +++ b/packages/yoroi-extension/chrome/extension/connector/index.js @@ -11,7 +11,6 @@ import createStores from '../../../app/connector/stores/index'; import { translations } from '../../../app/i18n/translations'; import actions from '../../../app/connector/actions/index'; // eslint-disable-next-line no-unused-vars -import { Action } from '../../../app/actions/lib/Action'; import App from '../../../app/connector/App'; import BigNumber from 'bignumber.js'; import { addCloseListener, TabIdKeys } from '../../../app/utils/tabManager'; @@ -39,7 +38,6 @@ const initializeDappConnector: void => Promise = async () => { translations, stores, reset: action(() => { - Action.resetAllActions(); createStores(api, actions); }), }; diff --git a/packages/yoroi-extension/chrome/extension/index.js b/packages/yoroi-extension/chrome/extension/index.js index 253da475cf..1e15943440 100644 --- a/packages/yoroi-extension/chrome/extension/index.js +++ b/packages/yoroi-extension/chrome/extension/index.js @@ -8,7 +8,6 @@ import { setupApi } from '../../app/api/index'; import createStores from '../../app/stores/index'; import { translations } from '../../app/i18n/translations'; import actions from '../../app/actions/index'; -import { Action } from '../../app/actions/lib/Action'; import App from '../../app/App'; import BigNumber from 'bignumber.js'; import { addCloseListener, TabIdKeys } from '../../app/utils/tabManager'; @@ -42,7 +41,6 @@ const initializeYoroi: void => Promise = async () => { translations, stores, reset: action(async () => { - Action.resetAllActions(); await createStores(api, actions, router); }) }; From b3d635d85a90e996f992555c730095a50c52a1cf Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Tue, 15 Oct 2024 19:47:57 +0300 Subject: [PATCH 46/76] renamed dialog prop `actions` into `dialogActions` --- .../app/components/buySell/BuySellDialog.js | 2 +- .../app/components/topbar/WalletListDialog.js | 2 +- .../app/components/transfer/BaseTransferPage.js | 2 +- .../app/components/transfer/ErrorPage.js | 2 +- .../app/components/transfer/SuccessPage.js | 2 +- .../app/components/transfer/SuccessPageRevamp.js | 2 +- .../app/components/transfer/TransferSummaryPage.js | 2 +- .../app/components/uri/URIGenerateDialog.js | 2 +- .../app/components/uri/URIInvalidDialog.js | 2 +- .../app/components/uri/URIVerifyDialog.js | 2 +- .../components/wallet/WalletAlreadyExistDialog.js | 2 +- .../app/components/wallet/WalletCreateDialog.js | 2 +- .../app/components/wallet/WalletRestoreDialog.js | 2 +- .../components/wallet/WalletRestoreVerifyDialog.js | 2 +- .../WalletBackupPrivacyWarningDialog.js | 2 +- .../WalletRecoveryPhraseDisplayDialog.js | 2 +- .../WalletRecoveryPhraseEntryDialog.js | 2 +- .../wallet/export/ExportTransactionDialog.js | 2 +- .../wallet/hwConnect/ledger/CheckDialog.js | 2 +- .../wallet/hwConnect/ledger/ConnectDialog.js | 2 +- .../components/wallet/hwConnect/ledger/SaveDialog.js | 2 +- .../wallet/hwConnect/trezor/CheckDialog.js | 2 +- .../wallet/hwConnect/trezor/ConnectDialog.js | 2 +- .../components/wallet/hwConnect/trezor/SaveDialog.js | 2 +- .../app/components/wallet/memos/AddMemoDialog.js | 2 +- .../app/components/wallet/memos/DeleteMemoDialog.js | 2 +- .../app/components/wallet/memos/EditMemoDialog.js | 2 +- .../wallet/memos/MemoNoExternalStorageDialog.js | 2 +- .../components/wallet/receive/VerifyAddressDialog.js | 2 +- .../wallet/send/HWSendConfirmationDialog.js | 2 +- .../wallet/send/TransactionSuccessDialog.js | 2 +- .../wallet/send/WalletSendConfirmationDialog.js | 2 +- .../wallet/send/WalletSendFormSteps/AddNFTDialog.js | 2 +- .../send/WalletSendFormSteps/AddTokenDialog.js | 2 +- .../wallet/settings/ChangeWalletPasswordDialog.js | 2 +- .../components/wallet/staking/DelegationTxDialog.js | 2 +- .../staking/dashboard-revamp/OverviewDialog.js | 2 +- .../app/components/wallet/voting/ConfirmPinDialog.js | 2 +- .../components/wallet/voting/GeneratePinDialog.js | 2 +- .../app/components/wallet/voting/QrCodeDialog.js | 2 +- .../app/components/wallet/voting/RegisterDialog.js | 2 +- .../components/wallet/voting/VotingRegTxDialog.js | 2 +- .../app/components/widgets/DangerousActionDialog.js | 2 +- .../yoroi-extension/app/components/widgets/Dialog.js | 12 ++++++------ .../wallet/dialogs/RevampAnnouncementDialog.js | 2 +- .../wallet/dialogs/voting/RegisterDialogContainer.js | 2 +- .../containers/wallet/staking/CardanoStakingPage.js | 2 +- .../wallet/staking/WithdrawRewardsDialog.js | 2 +- 48 files changed, 53 insertions(+), 53 deletions(-) diff --git a/packages/yoroi-extension/app/components/buySell/BuySellDialog.js b/packages/yoroi-extension/app/components/buySell/BuySellDialog.js index 4618144d79..4541e7b608 100644 --- a/packages/yoroi-extension/app/components/buySell/BuySellDialog.js +++ b/packages/yoroi-extension/app/components/buySell/BuySellDialog.js @@ -477,7 +477,7 @@ export default class BuySellDialog extends Component { onClose={props.onCancel} closeButton={} forceBottomDivider - actions={[ + dialogActions={[ { label: intl.formatMessage(messages.proceed), primary: true, diff --git a/packages/yoroi-extension/app/components/topbar/WalletListDialog.js b/packages/yoroi-extension/app/components/topbar/WalletListDialog.js index ad49c99685..e8d8399c08 100644 --- a/packages/yoroi-extension/app/components/topbar/WalletListDialog.js +++ b/packages/yoroi-extension/app/components/topbar/WalletListDialog.js @@ -186,7 +186,7 @@ export default class WalletListDialog extends Component { closeOnOverlayClick closeButton={} onClose={this.props.close} - actions={[ + dialogActions={[ { id: 'changeWalletDialog-addWallet-button', onClick: onAddWallet, diff --git a/packages/yoroi-extension/app/components/transfer/BaseTransferPage.js b/packages/yoroi-extension/app/components/transfer/BaseTransferPage.js index 7addab7f7d..7f33a01de3 100644 --- a/packages/yoroi-extension/app/components/transfer/BaseTransferPage.js +++ b/packages/yoroi-extension/app/components/transfer/BaseTransferPage.js @@ -56,7 +56,7 @@ export default class BaseTransferPage extends Component { return (

    { return ( } onClose={onCancel} diff --git a/packages/yoroi-extension/app/components/transfer/SuccessPage.js b/packages/yoroi-extension/app/components/transfer/SuccessPage.js index bf82becf49..8daa6f2ac0 100644 --- a/packages/yoroi-extension/app/components/transfer/SuccessPage.js +++ b/packages/yoroi-extension/app/components/transfer/SuccessPage.js @@ -43,7 +43,7 @@ export default class SuccessPage extends Component { return ( { return ( { } onClose={this.props.onCancel.trigger} closeOnOverlayClick={false} diff --git a/packages/yoroi-extension/app/components/uri/URIGenerateDialog.js b/packages/yoroi-extension/app/components/uri/URIGenerateDialog.js index 2e10baf771..ccc60f0f6d 100644 --- a/packages/yoroi-extension/app/components/uri/URIGenerateDialog.js +++ b/packages/yoroi-extension/app/components/uri/URIGenerateDialog.js @@ -132,7 +132,7 @@ export default class URIGenerateDialog extends Component { return ( } diff --git a/packages/yoroi-extension/app/components/uri/URIInvalidDialog.js b/packages/yoroi-extension/app/components/uri/URIInvalidDialog.js index 094943e248..56d0afc94d 100644 --- a/packages/yoroi-extension/app/components/uri/URIInvalidDialog.js +++ b/packages/yoroi-extension/app/components/uri/URIInvalidDialog.js @@ -71,7 +71,7 @@ export default class URIInvalidDialog extends Component { return ( { // TODO: in the future, we will need to confirm which wallet/account to use for this transaction return ( { return ( { } diff --git a/packages/yoroi-extension/app/components/wallet/WalletRestoreDialog.js b/packages/yoroi-extension/app/components/wallet/WalletRestoreDialog.js index 37aa12272b..5919a66d5c 100644 --- a/packages/yoroi-extension/app/components/wallet/WalletRestoreDialog.js +++ b/packages/yoroi-extension/app/components/wallet/WalletRestoreDialog.js @@ -281,7 +281,7 @@ export default class WalletRestoreDialog extends Component { } diff --git a/packages/yoroi-extension/app/components/wallet/WalletRestoreVerifyDialog.js b/packages/yoroi-extension/app/components/wallet/WalletRestoreVerifyDialog.js index 4241cae7c8..340da910f5 100644 --- a/packages/yoroi-extension/app/components/wallet/WalletRestoreVerifyDialog.js +++ b/packages/yoroi-extension/app/components/wallet/WalletRestoreVerifyDialog.js @@ -185,7 +185,7 @@ export default class WalletRestoreVerifyDialog extends Component { return ( { } diff --git a/packages/yoroi-extension/app/components/wallet/backup-recovery/WalletRecoveryPhraseDisplayDialog.js b/packages/yoroi-extension/app/components/wallet/backup-recovery/WalletRecoveryPhraseDisplayDialog.js index 5b319ec9ac..330f4782ac 100644 --- a/packages/yoroi-extension/app/components/wallet/backup-recovery/WalletRecoveryPhraseDisplayDialog.js +++ b/packages/yoroi-extension/app/components/wallet/backup-recovery/WalletRecoveryPhraseDisplayDialog.js @@ -60,7 +60,7 @@ export default class WalletRecoveryPhraseDisplayDialog extends Component } diff --git a/packages/yoroi-extension/app/components/wallet/backup-recovery/WalletRecoveryPhraseEntryDialog.js b/packages/yoroi-extension/app/components/wallet/backup-recovery/WalletRecoveryPhraseEntryDialog.js index d2be94c304..91c8509ae9 100644 --- a/packages/yoroi-extension/app/components/wallet/backup-recovery/WalletRecoveryPhraseEntryDialog.js +++ b/packages/yoroi-extension/app/components/wallet/backup-recovery/WalletRecoveryPhraseEntryDialog.js @@ -148,7 +148,7 @@ export default class WalletRecoveryPhraseEntryDialog extends Component { } diff --git a/packages/yoroi-extension/app/components/wallet/export/ExportTransactionDialog.js b/packages/yoroi-extension/app/components/wallet/export/ExportTransactionDialog.js index 04f016baaa..1169c1c680 100644 --- a/packages/yoroi-extension/app/components/wallet/export/ExportTransactionDialog.js +++ b/packages/yoroi-extension/app/components/wallet/export/ExportTransactionDialog.js @@ -99,7 +99,7 @@ export default class ExportTransactionDialog extends Component { } onClose={cancel} diff --git a/packages/yoroi-extension/app/components/wallet/hwConnect/ledger/CheckDialog.js b/packages/yoroi-extension/app/components/wallet/hwConnect/ledger/CheckDialog.js index 8c67980e79..bb68a87bf9 100644 --- a/packages/yoroi-extension/app/components/wallet/hwConnect/ledger/CheckDialog.js +++ b/packages/yoroi-extension/app/components/wallet/hwConnect/ledger/CheckDialog.js @@ -136,7 +136,7 @@ export default class CheckDialog extends Component { } backButton={} diff --git a/packages/yoroi-extension/app/components/wallet/hwConnect/ledger/ConnectDialog.js b/packages/yoroi-extension/app/components/wallet/hwConnect/ledger/ConnectDialog.js index 81c1bef606..fb89aeea23 100644 --- a/packages/yoroi-extension/app/components/wallet/hwConnect/ledger/ConnectDialog.js +++ b/packages/yoroi-extension/app/components/wallet/hwConnect/ledger/ConnectDialog.js @@ -125,7 +125,7 @@ export default class ConnectDialog extends Component { { } diff --git a/packages/yoroi-extension/app/components/wallet/hwConnect/trezor/CheckDialog.js b/packages/yoroi-extension/app/components/wallet/hwConnect/trezor/CheckDialog.js index e881533d5c..d58b68676f 100644 --- a/packages/yoroi-extension/app/components/wallet/hwConnect/trezor/CheckDialog.js +++ b/packages/yoroi-extension/app/components/wallet/hwConnect/trezor/CheckDialog.js @@ -120,7 +120,7 @@ export default class CheckDialog extends Component { } backButton={} diff --git a/packages/yoroi-extension/app/components/wallet/hwConnect/trezor/ConnectDialog.js b/packages/yoroi-extension/app/components/wallet/hwConnect/trezor/ConnectDialog.js index 3df70166a8..82bc337fb2 100644 --- a/packages/yoroi-extension/app/components/wallet/hwConnect/trezor/ConnectDialog.js +++ b/packages/yoroi-extension/app/components/wallet/hwConnect/trezor/ConnectDialog.js @@ -118,7 +118,7 @@ export default class ConnectDialog extends Component { { } diff --git a/packages/yoroi-extension/app/components/wallet/memos/AddMemoDialog.js b/packages/yoroi-extension/app/components/wallet/memos/AddMemoDialog.js index 7f9f96f3a2..ac4e4eb97b 100644 --- a/packages/yoroi-extension/app/components/wallet/memos/AddMemoDialog.js +++ b/packages/yoroi-extension/app/components/wallet/memos/AddMemoDialog.js @@ -129,7 +129,7 @@ export default class AddMemoDialog extends Component { } onClose={onCancel} diff --git a/packages/yoroi-extension/app/components/wallet/memos/DeleteMemoDialog.js b/packages/yoroi-extension/app/components/wallet/memos/DeleteMemoDialog.js index d0eb168793..85bf4cad8b 100644 --- a/packages/yoroi-extension/app/components/wallet/memos/DeleteMemoDialog.js +++ b/packages/yoroi-extension/app/components/wallet/memos/DeleteMemoDialog.js @@ -79,7 +79,7 @@ export default class DeleteMemoDialog extends Component { } onClose={onClose} diff --git a/packages/yoroi-extension/app/components/wallet/memos/EditMemoDialog.js b/packages/yoroi-extension/app/components/wallet/memos/EditMemoDialog.js index 519ac0e262..26445065b4 100644 --- a/packages/yoroi-extension/app/components/wallet/memos/EditMemoDialog.js +++ b/packages/yoroi-extension/app/components/wallet/memos/EditMemoDialog.js @@ -130,7 +130,7 @@ export default class EditMemoDialog extends Component { } onClose={onCancel} diff --git a/packages/yoroi-extension/app/components/wallet/memos/MemoNoExternalStorageDialog.js b/packages/yoroi-extension/app/components/wallet/memos/MemoNoExternalStorageDialog.js index 6a5c89845b..33b705e6d7 100644 --- a/packages/yoroi-extension/app/components/wallet/memos/MemoNoExternalStorageDialog.js +++ b/packages/yoroi-extension/app/components/wallet/memos/MemoNoExternalStorageDialog.js @@ -58,7 +58,7 @@ export default class MemoNoExternalStorageDialog extends Component { } onClose={onCancel} diff --git a/packages/yoroi-extension/app/components/wallet/receive/VerifyAddressDialog.js b/packages/yoroi-extension/app/components/wallet/receive/VerifyAddressDialog.js index 1fead03f09..c94a97e901 100644 --- a/packages/yoroi-extension/app/components/wallet/receive/VerifyAddressDialog.js +++ b/packages/yoroi-extension/app/components/wallet/receive/VerifyAddressDialog.js @@ -87,7 +87,7 @@ export default class VerifyAddressDialog extends Component { } onClose={this.props.cancel} diff --git a/packages/yoroi-extension/app/components/wallet/send/HWSendConfirmationDialog.js b/packages/yoroi-extension/app/components/wallet/send/HWSendConfirmationDialog.js index 6e1e49b1e1..1e6f49f842 100644 --- a/packages/yoroi-extension/app/components/wallet/send/HWSendConfirmationDialog.js +++ b/packages/yoroi-extension/app/components/wallet/send/HWSendConfirmationDialog.js @@ -223,7 +223,7 @@ export default class HWSendConfirmationDialog extends Component { return ( { return ( { return ( { onClose={onClose} withCloseButton scrollableContentClass={styles.nftsGrid} - actions={[ + dialogActions={[ { disabled: hasSelectedTokensIncluded.length === 0 || !shouldAddMore || currentNftsList.length === 0, onClick: this.onAddAll, diff --git a/packages/yoroi-extension/app/components/wallet/send/WalletSendFormSteps/AddTokenDialog.js b/packages/yoroi-extension/app/components/wallet/send/WalletSendFormSteps/AddTokenDialog.js index 542b522360..dbcfcf2829 100644 --- a/packages/yoroi-extension/app/components/wallet/send/WalletSendFormSteps/AddTokenDialog.js +++ b/packages/yoroi-extension/app/components/wallet/send/WalletSendFormSteps/AddTokenDialog.js @@ -314,7 +314,7 @@ export default class AddTokenDialog extends Component { return ( { return ( { return ( { return ( } onClose={onClose} diff --git a/packages/yoroi-extension/app/components/wallet/voting/ConfirmPinDialog.js b/packages/yoroi-extension/app/components/wallet/voting/ConfirmPinDialog.js index c68c658c63..e1698106f4 100644 --- a/packages/yoroi-extension/app/components/wallet/voting/ConfirmPinDialog.js +++ b/packages/yoroi-extension/app/components/wallet/voting/ConfirmPinDialog.js @@ -76,7 +76,7 @@ export default class ConfirmPinDialog extends Component { } backButton={} diff --git a/packages/yoroi-extension/app/components/wallet/voting/GeneratePinDialog.js b/packages/yoroi-extension/app/components/wallet/voting/GeneratePinDialog.js index ee19dcee33..db30114317 100644 --- a/packages/yoroi-extension/app/components/wallet/voting/GeneratePinDialog.js +++ b/packages/yoroi-extension/app/components/wallet/voting/GeneratePinDialog.js @@ -85,7 +85,7 @@ export default class GeneratePinDialog extends Component { } backButton={} diff --git a/packages/yoroi-extension/app/components/wallet/voting/QrCodeDialog.js b/packages/yoroi-extension/app/components/wallet/voting/QrCodeDialog.js index 997b757aca..28fd5397aa 100644 --- a/packages/yoroi-extension/app/components/wallet/voting/QrCodeDialog.js +++ b/packages/yoroi-extension/app/components/wallet/voting/QrCodeDialog.js @@ -78,7 +78,7 @@ export default class QrCodeDialog extends Component { } onClose={cancel} diff --git a/packages/yoroi-extension/app/components/wallet/voting/RegisterDialog.js b/packages/yoroi-extension/app/components/wallet/voting/RegisterDialog.js index c8a64bd1e3..3dc7d2ef94 100644 --- a/packages/yoroi-extension/app/components/wallet/voting/RegisterDialog.js +++ b/packages/yoroi-extension/app/components/wallet/voting/RegisterDialog.js @@ -62,7 +62,7 @@ export default class RegisterDialog extends Component { } onClose={cancel} diff --git a/packages/yoroi-extension/app/components/wallet/voting/VotingRegTxDialog.js b/packages/yoroi-extension/app/components/wallet/voting/VotingRegTxDialog.js index 86c812af76..cde303c3fc 100644 --- a/packages/yoroi-extension/app/components/wallet/voting/VotingRegTxDialog.js +++ b/packages/yoroi-extension/app/components/wallet/voting/VotingRegTxDialog.js @@ -170,7 +170,7 @@ export default class VotingRegTxDialog extends Component { return ( { return ( , + +dialogActions?: Array, +closeButton?: Element, +withCloseButton?: boolean, +backButton?: Node, @@ -48,7 +48,7 @@ function Dialog(props: Props): Node { const { title, children, - actions, + dialogActions, closeOnOverlayClick, onClose, className, @@ -84,11 +84,11 @@ function Dialog(props: Props): Node { }; }, [children]); - const hasActions = actions && actions.length > 0; + const hasActions = dialogActions && dialogActions.length > 0; const hasCloseButton = withCloseButton || closeButton; - const hasSubmitting = actions != null && actions.filter(action => action.isSubmitting === true).length > 0; + const hasSubmitting = dialogActions != null && dialogActions.filter(action => action.isSubmitting === true).length > 0; return ( - {map(actions, (action, i: number) => { + {map(dialogActions, (action, i: number) => { const buttonLabel = action.label.toLowerCase().replace(/ /gi, ''); return ( { className={styles.dialog} onClose={onClose} closeButton={} - actions={actions} + dialogActions={actions} > { closeOnOverlayClick={false} onClose={this.props.cancel} closeButton={} - actions={dialogBackButton} + dialogActions={dialogBackButton} > <> diff --git a/packages/yoroi-extension/app/containers/wallet/staking/CardanoStakingPage.js b/packages/yoroi-extension/app/containers/wallet/staking/CardanoStakingPage.js index 425b9cdba8..00ee96752a 100644 --- a/packages/yoroi-extension/app/containers/wallet/staking/CardanoStakingPage.js +++ b/packages/yoroi-extension/app/containers/wallet/staking/CardanoStakingPage.js @@ -284,7 +284,7 @@ export default class CardanoStakingPage extends Component { closeOnOverlayClick={false} onClose={this.cancel} closeButton={} - actions={dialogBackButton} + dialogActions={dialogBackButton} > <>
    diff --git a/packages/yoroi-extension/app/containers/wallet/staking/WithdrawRewardsDialog.js b/packages/yoroi-extension/app/containers/wallet/staking/WithdrawRewardsDialog.js index b4f36c36d9..17b179f51a 100644 --- a/packages/yoroi-extension/app/containers/wallet/staking/WithdrawRewardsDialog.js +++ b/packages/yoroi-extension/app/containers/wallet/staking/WithdrawRewardsDialog.js @@ -207,7 +207,7 @@ export default class WithdrawRewardsDialog extends Component<{| ...StoresAndActi return ( Date: Tue, 15 Oct 2024 20:10:11 +0300 Subject: [PATCH 47/76] removed ActionsMap type usage in stores --- .../yoroi-extension/app/connector/stores/ConnectorStore.js | 3 +-- packages/yoroi-extension/app/connector/stores/ada/index.js | 2 +- packages/yoroi-extension/app/connector/stores/index.js | 2 +- .../app/connector/stores/toplevel/ConnectorLoadingStore.js | 3 +-- .../yoroi-extension/app/stores/ada/AdaAddressesStore.js | 3 +-- .../yoroi-extension/app/stores/ada/AdaDelegationStore.js | 3 +-- .../app/stores/ada/AdaDelegationTransactionStore.js | 3 +-- .../yoroi-extension/app/stores/ada/AdaStateFetchStore.js | 2 -- .../yoroi-extension/app/stores/ada/AdaTransactionsStore.js | 5 ++--- .../yoroi-extension/app/stores/ada/AdaWalletRestoreStore.js | 3 +-- packages/yoroi-extension/app/stores/ada/AdaWalletsStore.js | 3 +-- .../yoroi-extension/app/stores/ada/AdaYoroiTransferStore.js | 3 +-- .../yoroi-extension/app/stores/ada/HWVerifyAddressStore.js | 3 +-- .../yoroi-extension/app/stores/ada/LedgerConnectStore.js | 3 +-- packages/yoroi-extension/app/stores/ada/SwapStore.js | 3 +-- .../yoroi-extension/app/stores/ada/TrezorConnectStore.js | 3 +-- packages/yoroi-extension/app/stores/ada/VotingStore.js | 3 +-- packages/yoroi-extension/app/stores/ada/index.js | 2 +- .../app/stores/ada/send/AdaMnemonicSendStore.js | 3 +-- .../yoroi-extension/app/stores/ada/send/LedgerSendStore.js | 3 +-- .../yoroi-extension/app/stores/ada/send/TrezorSendStore.js | 3 +-- .../yoroi-extension/app/stores/base/BaseCardanoTimeStore.js | 3 +-- .../yoroi-extension/app/stores/base/BaseCoinPriceStore.js | 2 +- .../yoroi-extension/app/stores/base/BaseExplorerStore.js | 2 +- .../yoroi-extension/app/stores/base/BaseLoadingStore.js | 2 +- .../yoroi-extension/app/stores/base/BaseProfileStore.js | 2 +- .../yoroi-extension/app/stores/base/BaseStateFetchStore.js | 3 +-- packages/yoroi-extension/app/stores/base/Store.js | 6 +++--- packages/yoroi-extension/app/stores/index.js | 2 +- .../yoroi-extension/app/stores/toplevel/AddressesStore.js | 3 +-- packages/yoroi-extension/app/stores/toplevel/AppStore.js | 3 +-- .../app/stores/toplevel/DappConnectorStore.js | 3 +-- .../yoroi-extension/app/stores/toplevel/DelegationStore.js | 3 +-- .../yoroi-extension/app/stores/toplevel/LoadingStore.js | 3 +-- packages/yoroi-extension/app/stores/toplevel/MemosStore.js | 3 +-- .../app/stores/toplevel/ProtocolParametersStore.js | 2 +- .../app/stores/toplevel/ServerConnectionStore.js | 3 +-- .../yoroi-extension/app/stores/toplevel/StateFetchStore.js | 5 ++--- .../yoroi-extension/app/stores/toplevel/TokenInfoStore.js | 2 +- .../app/stores/toplevel/TransactionBuilderStore.js | 3 +-- .../app/stores/toplevel/TransactionsStore.js | 3 +-- .../yoroi-extension/app/stores/toplevel/UiDialogsStore.js | 2 +- .../app/stores/toplevel/UiNotificationsStore.js | 2 +- .../app/stores/toplevel/WalletBackupStore.js | 3 +-- .../app/stores/toplevel/WalletRestoreStore.js | 3 +-- .../app/stores/toplevel/WalletSettingsStore.js | 3 +-- packages/yoroi-extension/app/stores/toplevel/WalletStore.js | 3 +-- .../app/stores/toplevel/YoroiTransferStore.js | 3 +-- 48 files changed, 51 insertions(+), 87 deletions(-) diff --git a/packages/yoroi-extension/app/connector/stores/ConnectorStore.js b/packages/yoroi-extension/app/connector/stores/ConnectorStore.js index 6c5c07dad8..3c542d94ab 100644 --- a/packages/yoroi-extension/app/connector/stores/ConnectorStore.js +++ b/packages/yoroi-extension/app/connector/stores/ConnectorStore.js @@ -5,7 +5,6 @@ import type { SigningMessage, WhitelistEntry, } from '../../../chrome/extension/connector/types'; -import type { ActionsMap } from '../actions/index'; import type { StoresMap } from './index'; import type { Anchor, @@ -106,7 +105,7 @@ type SetWhitelistFunc = ({| whitelist: Array | void, |}) => Promise; -export default class ConnectorStore extends Store { +export default class ConnectorStore extends Store { @observable unrecoverableError: string | null = null; @observable connectingMessage: ?ConnectingMessage = null; @observable whiteList: Array = []; diff --git a/packages/yoroi-extension/app/connector/stores/ada/index.js b/packages/yoroi-extension/app/connector/stores/ada/index.js index c5faeedc82..5d84e0be3d 100644 --- a/packages/yoroi-extension/app/connector/stores/ada/index.js +++ b/packages/yoroi-extension/app/connector/stores/ada/index.js @@ -11,7 +11,7 @@ export const adaStoreClasses = Object.freeze({ }); export type AdaStoresMap = {| - stateFetchStore: AdaStateFetchStore, + stateFetchStore: AdaStateFetchStore, |}; const adaStores: WithNullableFields = observable({ diff --git a/packages/yoroi-extension/app/connector/stores/index.js b/packages/yoroi-extension/app/connector/stores/index.js index 089a95852e..82bd92463a 100644 --- a/packages/yoroi-extension/app/connector/stores/index.js +++ b/packages/yoroi-extension/app/connector/stores/index.js @@ -28,7 +28,7 @@ const storeClasses = Object.freeze({ }); export type StoresMap = {| - stateFetchStore: StateFetchStore, + stateFetchStore: StateFetchStore, profile: ProfileStore, uiDialogs: UiDialogsStore<{||}>, uiNotifications: UiNotificationsStore<{||}>, diff --git a/packages/yoroi-extension/app/connector/stores/toplevel/ConnectorLoadingStore.js b/packages/yoroi-extension/app/connector/stores/toplevel/ConnectorLoadingStore.js index 5827fb8848..6185aff515 100644 --- a/packages/yoroi-extension/app/connector/stores/toplevel/ConnectorLoadingStore.js +++ b/packages/yoroi-extension/app/connector/stores/toplevel/ConnectorLoadingStore.js @@ -1,12 +1,11 @@ // @flow import BaseLoadingStore from '../../../stores/base/BaseLoadingStore'; -import type { ActionsMap } from '../../actions/index'; import type { StoresMap } from '../index'; import { TabIdKeys, } from '../../../utils/tabManager'; -export default class ConnectorLoadingStore extends BaseLoadingStore { +export default class ConnectorLoadingStore extends BaseLoadingStore { async preLoadingScreenEnd(): Promise { await super.preLoadingScreenEnd(); diff --git a/packages/yoroi-extension/app/stores/ada/AdaAddressesStore.js b/packages/yoroi-extension/app/stores/ada/AdaAddressesStore.js index 5da7939315..cbec866735 100644 --- a/packages/yoroi-extension/app/stores/ada/AdaAddressesStore.js +++ b/packages/yoroi-extension/app/stores/ada/AdaAddressesStore.js @@ -9,7 +9,6 @@ import { import { filterAddressesByStakingKey, } from '../../api/ada/lib/storage/bridge/delegationUtils'; -import type { ActionsMap } from '../../actions/index'; import type { StoresMap } from '../index'; import { isResolvableDomain, resolverApiMaker } from '@yoroi/resolver'; import { Api, Resolver } from '@yoroi/types'; @@ -58,7 +57,7 @@ export function resolveAddressDomainNameServerName(nameServerTag: string): strin } } -export default class AdaAddressesStore extends Store { +export default class AdaAddressesStore extends Store { _domainResolverApi: ?{| getCardanoAddresses: ({| resolve: string |}) => Promise |} = null; diff --git a/packages/yoroi-extension/app/stores/ada/AdaDelegationStore.js b/packages/yoroi-extension/app/stores/ada/AdaDelegationStore.js index 9db9ebd0f3..14382596c9 100644 --- a/packages/yoroi-extension/app/stores/ada/AdaDelegationStore.js +++ b/packages/yoroi-extension/app/stores/ada/AdaDelegationStore.js @@ -13,7 +13,6 @@ import type { NetworkRow } from '../../api/ada/lib/storage/database/primitives/t import type { MangledAmountFunc } from '../stateless/mangledAddresses'; import { getUnmangleAmounts } from '../stateless/mangledAddresses'; import { MultiToken } from '../../api/common/lib/MultiToken'; -import type { ActionsMap } from '../../actions/index'; import type { StoresMap } from '../index'; import { PoolInfoApi } from '@emurgo/yoroi-lib'; import { entriesIntoMap, forceNonNull } from '../../coreUtils'; @@ -25,7 +24,7 @@ import type { RewardHistoryFunc, } from '../../api/ada/lib/storage/bridge/delegationUtils'; -export default class AdaDelegationStore extends Store { +export default class AdaDelegationStore extends Store { _recalculateDelegationInfoDisposer: Array<(void) => void> = []; @action addObservedWallet: ({ diff --git a/packages/yoroi-extension/app/stores/ada/AdaDelegationTransactionStore.js b/packages/yoroi-extension/app/stores/ada/AdaDelegationTransactionStore.js index 4151c28a0b..cca39cedb5 100644 --- a/packages/yoroi-extension/app/stores/ada/AdaDelegationTransactionStore.js +++ b/packages/yoroi-extension/app/stores/ada/AdaDelegationTransactionStore.js @@ -7,12 +7,11 @@ import LocalizedRequest from '../lib/LocalizedRequest'; import type { CreateDelegationTxFunc, CreateWithdrawalTxResponse } from '../../api/ada'; import { buildRoute } from '../../utils/routing'; import { ROUTES } from '../../routes-config'; -import type { ActionsMap } from '../../actions/index'; import type { StoresMap } from '../index'; import type { WalletState } from '../../../chrome/extension/background/types'; import { getProtocolParameters } from '../../api/thunk'; -export default class AdaDelegationTransactionStore extends Store { +export default class AdaDelegationTransactionStore extends Store { @observable createWithdrawalTx: LocalizedRequest> = new LocalizedRequest< DeferredCall >(request => request()); diff --git a/packages/yoroi-extension/app/stores/ada/AdaStateFetchStore.js b/packages/yoroi-extension/app/stores/ada/AdaStateFetchStore.js index 1b7493ca6c..b4de00d9dc 100644 --- a/packages/yoroi-extension/app/stores/ada/AdaStateFetchStore.js +++ b/packages/yoroi-extension/app/stores/ada/AdaStateFetchStore.js @@ -10,10 +10,8 @@ import environment from '../../environment'; export default class AdaStateFetchStore< TStores: RequiredStores, - TActions > extends BaseStateFetchStore< TStores, - TActions, IFetcher > { diff --git a/packages/yoroi-extension/app/stores/ada/AdaTransactionsStore.js b/packages/yoroi-extension/app/stores/ada/AdaTransactionsStore.js index fafd9d20d4..635f6fc611 100644 --- a/packages/yoroi-extension/app/stores/ada/AdaTransactionsStore.js +++ b/packages/yoroi-extension/app/stores/ada/AdaTransactionsStore.js @@ -1,9 +1,8 @@ // @flow import Store from '../base/Store'; -import type { ActionsMap } from '../../actions/index'; import type { StoresMap } from '../index'; -// todo: remove -export default class AdaTransactionsStore extends Store { +// +export default class AdaTransactionsStore extends Store { } diff --git a/packages/yoroi-extension/app/stores/ada/AdaWalletRestoreStore.js b/packages/yoroi-extension/app/stores/ada/AdaWalletRestoreStore.js index 799a8645f9..68b38728e3 100644 --- a/packages/yoroi-extension/app/stores/ada/AdaWalletRestoreStore.js +++ b/packages/yoroi-extension/app/stores/ada/AdaWalletRestoreStore.js @@ -8,11 +8,10 @@ import type { Address, Addressing, } from '../../api/ada/lib/storage/models/PublicDeriver/interfaces'; -import type { ActionsMap } from '../../actions/index'; import type { StoresMap } from '../index'; import { createWallet } from '../../api/thunk'; -export default class AdaWalletRestoreStore extends Store { +export default class AdaWalletRestoreStore extends Store { setup(): void { super.setup(); this.reset(); diff --git a/packages/yoroi-extension/app/stores/ada/AdaWalletsStore.js b/packages/yoroi-extension/app/stores/ada/AdaWalletsStore.js index f8baef3655..b144aa8576 100644 --- a/packages/yoroi-extension/app/stores/ada/AdaWalletsStore.js +++ b/packages/yoroi-extension/app/stores/ada/AdaWalletsStore.js @@ -5,7 +5,6 @@ import Store from '../base/Store'; import Request from '../lib/LocalizedRequest'; import type { GenerateWalletRecoveryPhraseFunc } from '../../api/ada/index'; import { HaskellShelleyTxSignRequest } from '../../api/ada/transactions/shelley/HaskellShelleyTxSignRequest'; -import type { ActionsMap } from '../../actions/index'; import type { StoresMap } from '../index'; import { HARD_DERIVATION_START } from '../../config/numbersConfig'; import { createWallet, signTransaction } from '../../api/thunk'; @@ -19,7 +18,7 @@ import type{ WalletState } from '../../../chrome/extension/background/types'; const MAX_PICKED_COLLATERAL_UTXO_ADA = 10_000_000; // 10 ADA -export default class AdaWalletsStore extends Store { +export default class AdaWalletsStore extends Store { // REQUESTS @observable diff --git a/packages/yoroi-extension/app/stores/ada/AdaYoroiTransferStore.js b/packages/yoroi-extension/app/stores/ada/AdaYoroiTransferStore.js index fb778b959e..2053be0d22 100644 --- a/packages/yoroi-extension/app/stores/ada/AdaYoroiTransferStore.js +++ b/packages/yoroi-extension/app/stores/ada/AdaYoroiTransferStore.js @@ -17,10 +17,9 @@ import { Bip44DerivationLevels, } from '../../api/ada/lib/storage/database/walle import { getCardanoHaskellBaseConfig } from '../../api/ada/lib/storage/database/prepackaged/networks'; import TimeUtils from '../../api/ada/lib/storage/bridge/timeUtils'; import type { Address, Addressing } from '../../api/ada/lib/storage/models/PublicDeriver/interfaces'; -import type { ActionsMap } from '../../actions/index'; import type { StoresMap } from '../index'; -export default class AdaYoroiTransferStore extends Store { +export default class AdaYoroiTransferStore extends Store { @observable restoreForTransferRequest: Request = new Request(this.api.ada.restoreWalletForTransfer); diff --git a/packages/yoroi-extension/app/stores/ada/HWVerifyAddressStore.js b/packages/yoroi-extension/app/stores/ada/HWVerifyAddressStore.js index d03d2c134d..e8be75fdf8 100644 --- a/packages/yoroi-extension/app/stores/ada/HWVerifyAddressStore.js +++ b/packages/yoroi-extension/app/stores/ada/HWVerifyAddressStore.js @@ -31,11 +31,10 @@ import { toTrezorAddressParameters } from '../../api/ada/transactions/shelley/tr import { toLedgerAddressParameters } from '../../api/ada/transactions/shelley/ledgerTx'; import type { StandardAddress } from '../../types/AddressFilterTypes'; import { genAddressingLookup } from '../stateless/addressStores'; -import type { ActionsMap } from '../../actions/index'; import type { StoresMap } from '../index'; import type { WalletState } from '../../../chrome/extension/background/types'; -export default class HWVerifyAddressStore extends Store { +export default class HWVerifyAddressStore extends Store { @observable isActionProcessing: boolean = false; @observable error: ?LocalizableError = null; @observable selectedAddress: ?$ReadOnly = null; diff --git a/packages/yoroi-extension/app/stores/ada/LedgerConnectStore.js b/packages/yoroi-extension/app/stores/ada/LedgerConnectStore.js index 0241ff89df..51cd84f75b 100644 --- a/packages/yoroi-extension/app/stores/ada/LedgerConnectStore.js +++ b/packages/yoroi-extension/app/stores/ada/LedgerConnectStore.js @@ -25,7 +25,6 @@ import { Bip44DerivationLevels, } from '../../api/ada/lib/storage/database/walle import { RustModule } from '../../api/ada/lib/cardanoCrypto/rustLoader'; import TimeUtils from '../../api/ada/lib/storage/bridge/timeUtils'; import { getCardanoHaskellBaseConfig } from '../../api/ada/lib/storage/database/prepackaged/networks'; -import type { ActionsMap } from '../../actions/index'; import type { StoresMap } from '../index'; import type { GetExtendedPublicKeyResponse, } from '@cardano-foundation/ledgerjs-hw-app-cardano'; import { createHardwareWallet, getProtocolParameters } from '../../api/thunk'; @@ -33,7 +32,7 @@ import type { CreateHardwareWalletRequest } from '../../api/thunk'; import type { WalletState } from '../../../chrome/extension/background/types'; export default class LedgerConnectStore - extends Store + extends Store implements HWConnectStoreTypes> { // =================== VIEW RELATED =================== // diff --git a/packages/yoroi-extension/app/stores/ada/SwapStore.js b/packages/yoroi-extension/app/stores/ada/SwapStore.js index 187d324fc6..6c77dbf1ef 100644 --- a/packages/yoroi-extension/app/stores/ada/SwapStore.js +++ b/packages/yoroi-extension/app/stores/ada/SwapStore.js @@ -1,7 +1,6 @@ // @flow import Store from '../base/Store'; -import type { ActionsMap } from '../../actions'; import type { StoresMap } from '../index'; import { action, computed, observable } from 'mobx'; import type { StorageField } from '../../api/localStorage'; @@ -38,7 +37,7 @@ const FRONTEND_FEE_ADDRESS_MAINNET = const FRONTEND_FEE_ADDRESS_PREPROD = 'addr_test1qrgpjmyy8zk9nuza24a0f4e7mgp9gd6h3uayp0rqnjnkl54v4dlyj0kwfs0x4e38a7047lymzp37tx0y42glslcdtzhqzp57km'; -export default class SwapStore extends Store { +export default class SwapStore extends Store { @observable orderStep: number = 0; swapDisclaimerAcceptanceFlag: StorageField = createStorageFlag( diff --git a/packages/yoroi-extension/app/stores/ada/TrezorConnectStore.js b/packages/yoroi-extension/app/stores/ada/TrezorConnectStore.js index bb72248b3d..b178f6bbae 100644 --- a/packages/yoroi-extension/app/stores/ada/TrezorConnectStore.js +++ b/packages/yoroi-extension/app/stores/ada/TrezorConnectStore.js @@ -17,7 +17,6 @@ import { StepState } from '../../components/widgets/ProgressSteps'; import { Logger, stringifyError } from '../../utils/logging'; import { CoinTypes, HARD_DERIVATION_START, WalletTypePurpose, } from '../../config/numbersConfig'; import { Bip44DerivationLevels, } from '../../api/ada/lib/storage/database/walletTypes/bip44/api/utils'; -import type { ActionsMap } from '../../actions/index'; import type { StoresMap } from '../index'; import { createHardwareWallet } from '../../api/thunk'; import type { CreateHardwareWalletRequest } from '../../api/thunk'; @@ -30,7 +29,7 @@ type TrezorConnectionResponse = {| export default class TrezorConnectStore - extends Store + extends Store implements HWConnectStoreTypes { // =================== VIEW RELATED =================== // diff --git a/packages/yoroi-extension/app/stores/ada/VotingStore.js b/packages/yoroi-extension/app/stores/ada/VotingStore.js index 68bef801e6..798bb81a6e 100644 --- a/packages/yoroi-extension/app/stores/ada/VotingStore.js +++ b/packages/yoroi-extension/app/stores/ada/VotingStore.js @@ -20,7 +20,6 @@ import { ROUTES } from '../../routes-config'; import { convertToLocalizableError } from '../../domain/LedgerLocalizedError'; import LocalizableError from '../../i18n/LocalizableError'; import cryptoRandomString from 'crypto-random-string'; -import type { ActionsMap } from '../../actions/index'; import type { StoresMap } from '../index'; import { generateRegistration } from '../../api/ada/lib/cardanoCrypto/catalyst'; import type { CatalystRoundInfoResponse } from '../../api/ada/lib/state-fetch/types' @@ -44,7 +43,7 @@ export interface ProgressInfo { stepState: StepStateEnum, } -export default class VotingStore extends Store { +export default class VotingStore extends Store { @observable progressInfo: ProgressInfo @observable encryptedKey: string | null = null; @observable catalystPrivateKey: RustModule.WalletV4.PrivateKey | void; diff --git a/packages/yoroi-extension/app/stores/ada/index.js b/packages/yoroi-extension/app/stores/ada/index.js index 5080949cff..7e7dec2321 100644 --- a/packages/yoroi-extension/app/stores/ada/index.js +++ b/packages/yoroi-extension/app/stores/ada/index.js @@ -54,7 +54,7 @@ export type AdaStoresMap = {| ledgerConnect: LedgerConnectStore, ledgerSend: LedgerSendStore, hwVerifyAddress: HWVerifyAddressStore, - stateFetchStore: AdaStateFetchStore, + stateFetchStore: AdaStateFetchStore, delegationTransaction: AdaDelegationTransactionStore, walletRestore: AdaWalletRestoreStore, delegation: AdaDelegationStore, diff --git a/packages/yoroi-extension/app/stores/ada/send/AdaMnemonicSendStore.js b/packages/yoroi-extension/app/stores/ada/send/AdaMnemonicSendStore.js index 2785206a39..47bc1cd043 100644 --- a/packages/yoroi-extension/app/stores/ada/send/AdaMnemonicSendStore.js +++ b/packages/yoroi-extension/app/stores/ada/send/AdaMnemonicSendStore.js @@ -8,11 +8,10 @@ import { } from '../../../utils/logging'; import { ROUTES } from '../../../routes-config'; import type { ISignRequest } from '../../../api/common/lib/transactions/ISignRequest'; -import type { ActionsMap } from '../../../actions/index'; import type { StoresMap } from '../../index'; import { signAndBroadcastTransaction } from '../../../api/thunk'; -export default class AdaMnemonicSendStore extends Store { +export default class AdaMnemonicSendStore extends Store { /** Send money and then return to transaction screen */ sendMoney: {| diff --git a/packages/yoroi-extension/app/stores/ada/send/LedgerSendStore.js b/packages/yoroi-extension/app/stores/ada/send/LedgerSendStore.js index fe69f7d39e..bee8f7deb9 100644 --- a/packages/yoroi-extension/app/stores/ada/send/LedgerSendStore.js +++ b/packages/yoroi-extension/app/stores/ada/send/LedgerSendStore.js @@ -23,7 +23,6 @@ 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 { genAddressingLookup } from '../../stateless/addressStores'; -import type { ActionsMap } from '../../../actions/index'; import type { StoresMap } from '../../index'; import { generateCip15RegistrationMetadata, @@ -40,7 +39,7 @@ export type SendUsingLedgerParams = {| |}; /** Note: Handles Ledger Signing */ -export default class LedgerSendStore extends Store { +export default class LedgerSendStore extends Store { // =================== VIEW RELATED =================== // // TODO: consider getting rid of both of these @observable isActionProcessing: boolean = false; diff --git a/packages/yoroi-extension/app/stores/ada/send/TrezorSendStore.js b/packages/yoroi-extension/app/stores/ada/send/TrezorSendStore.js index fe81975c2c..41facb88e6 100644 --- a/packages/yoroi-extension/app/stores/ada/send/TrezorSendStore.js +++ b/packages/yoroi-extension/app/stores/ada/send/TrezorSendStore.js @@ -9,7 +9,6 @@ import { convertToLocalizableError } from '../../../domain/TrezorLocalizedError' import LocalizableError from '../../../i18n/LocalizableError'; import { ROUTES } from '../../../routes-config'; import { HaskellShelleyTxSignRequest } from '../../../api/ada/transactions/shelley/HaskellShelleyTxSignRequest'; -import type { ActionsMap } from '../../../actions/index'; import type { StoresMap } from '../../index'; import { buildConnectorSignedTransaction, @@ -31,7 +30,7 @@ export type SendUsingTrezorParams = {| |}; /** Note: Handles Trezor Signing */ -export default class TrezorSendStore extends Store { +export default class TrezorSendStore extends Store { // =================== VIEW RELATED =================== // // TODO: consider getting rid of both of these @observable isActionProcessing: boolean = false; diff --git a/packages/yoroi-extension/app/stores/base/BaseCardanoTimeStore.js b/packages/yoroi-extension/app/stores/base/BaseCardanoTimeStore.js index e2a3ea0b08..2770e264ed 100644 --- a/packages/yoroi-extension/app/stores/base/BaseCardanoTimeStore.js +++ b/packages/yoroi-extension/app/stores/base/BaseCardanoTimeStore.js @@ -3,7 +3,6 @@ import { action, computed, observable, runInAction, } from 'mobx'; import { find } from 'lodash'; import Store from './Store'; -import type { ActionsMap } from '../../actions/index'; import type { StoresMap } from '../index'; import type { RelativeSlot } from '../../api/ada/lib/storage/bridge/timeUtils'; import TimeUtils from '../../api/ada/lib/storage/bridge/timeUtils'; @@ -40,7 +39,7 @@ export type CurrentTimeRequests = {| /** * Different wallets can be on different networks and therefore have different measures of time */ -export default class BaseCardanoTimeStore extends Store { +export default class BaseCardanoTimeStore extends Store { @observable time: Date = new Date(); diff --git a/packages/yoroi-extension/app/stores/base/BaseCoinPriceStore.js b/packages/yoroi-extension/app/stores/base/BaseCoinPriceStore.js index f4cc390b3e..a922d660e4 100644 --- a/packages/yoroi-extension/app/stores/base/BaseCoinPriceStore.js +++ b/packages/yoroi-extension/app/stores/base/BaseCoinPriceStore.js @@ -26,7 +26,7 @@ export default class BaseCoinPriceStore ..., } > - 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/BaseExplorerStore.js b/packages/yoroi-extension/app/stores/base/BaseExplorerStore.js index 3134b59df8..ef2cdc64da 100644 --- a/packages/yoroi-extension/app/stores/base/BaseExplorerStore.js +++ b/packages/yoroi-extension/app/stores/base/BaseExplorerStore.js @@ -16,7 +16,7 @@ export default class BaseExplorerStore TStores: { ..., } - > extends Store { + > extends Store { @observable getSelectedExplorerRequest: Request = new Request(getSelectedExplorer); diff --git a/packages/yoroi-extension/app/stores/base/BaseLoadingStore.js b/packages/yoroi-extension/app/stores/base/BaseLoadingStore.js index c7cd9e393d..baea1048bf 100644 --- a/packages/yoroi-extension/app/stores/base/BaseLoadingStore.js +++ b/packages/yoroi-extension/app/stores/base/BaseLoadingStore.js @@ -9,7 +9,7 @@ import { closeOtherInstances } from '../../utils/tabManager'; import { RustModule } from '../../api/ada/lib/cardanoCrypto/rustLoader'; /** Load dependencies before launching the app */ -export default class BaseLoadingStore extends Store { +export default class BaseLoadingStore extends Store { @observable error: ?LocalizableError = null; @observable _loading: boolean = true; diff --git a/packages/yoroi-extension/app/stores/base/BaseProfileStore.js b/packages/yoroi-extension/app/stores/base/BaseProfileStore.js index 18d4e7df77..1a1c481cb5 100644 --- a/packages/yoroi-extension/app/stores/base/BaseProfileStore.js +++ b/packages/yoroi-extension/app/stores/base/BaseProfileStore.js @@ -29,7 +29,7 @@ export default class BaseProfileStore ... } > - extends Store + extends Store { LANGUAGE_OPTIONS: Array = [ diff --git a/packages/yoroi-extension/app/stores/base/BaseStateFetchStore.js b/packages/yoroi-extension/app/stores/base/BaseStateFetchStore.js index 52a71f20d1..0f8793df01 100644 --- a/packages/yoroi-extension/app/stores/base/BaseStateFetchStore.js +++ b/packages/yoroi-extension/app/stores/base/BaseStateFetchStore.js @@ -12,9 +12,8 @@ export type RequiredStores = { export default class BaseStateFetchStore < TStores: RequiredStores, - TActions, IFetcher - > extends Store { + > extends Store { @observable fetcher: IFetcher; diff --git a/packages/yoroi-extension/app/stores/base/Store.js b/packages/yoroi-extension/app/stores/base/Store.js index 1a0ac2c08c..66c42802c1 100644 --- a/packages/yoroi-extension/app/stores/base/Store.js +++ b/packages/yoroi-extension/app/stores/base/Store.js @@ -3,15 +3,15 @@ import Reaction from '../lib/Reaction'; import type { Api } from '../../api/index'; // Base store class used by all stores in our application -export default class Store { +export default class Store { stores: TStores; api: Api; - actions: TActions; + actions: any; _reactions: Array = []; - constructor(stores: TStores, api: Api, actions: TActions) { + constructor(stores: TStores, api: Api, actions: any) { this.stores = stores; this.api = api; this.actions = actions; diff --git a/packages/yoroi-extension/app/stores/index.js b/packages/yoroi-extension/app/stores/index.js index b0a6675011..5394776360 100644 --- a/packages/yoroi-extension/app/stores/index.js +++ b/packages/yoroi-extension/app/stores/index.js @@ -56,7 +56,7 @@ const storeClasses = Object.freeze({ }); export type StoresMap = {| - stateFetchStore: StateFetchStore, + stateFetchStore: StateFetchStore, coinPriceStore: CoinPriceStore, tokenInfoStore: TokenInfoStore, profile: ProfileStore, diff --git a/packages/yoroi-extension/app/stores/toplevel/AddressesStore.js b/packages/yoroi-extension/app/stores/toplevel/AddressesStore.js index 273e2389c8..d9334d5712 100644 --- a/packages/yoroi-extension/app/stores/toplevel/AddressesStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/AddressesStore.js @@ -12,14 +12,13 @@ import { AddressTypeStore } from '../base/AddressSubgroupStore'; import type { CoreAddressT } from '../../api/ada/lib/storage/database/primitives/enums'; import type { IAddressTypeStore, IAddressTypeUiSubset } from '../stateless/addressStores'; import { allAddressSubgroups } from '../stateless/addressStores'; -import type { ActionsMap } from '../../actions/index'; import type { StoresMap } from '../index'; import { ChainDerivations } from '../../config/numbersConfig'; import { getNetworkById } from '../../api/ada/lib/storage/database/prepackaged/networks'; import { popAddress } from '../../api/thunk'; import type { WalletState } from '../../../chrome/extension/background/types'; -export default class AddressesStore extends Store { +export default class AddressesStore extends Store { // note: no need for this to be observable _addressSubgroupMap: Map, IAddressTypeStore> = new Map(); diff --git a/packages/yoroi-extension/app/stores/toplevel/AppStore.js b/packages/yoroi-extension/app/stores/toplevel/AppStore.js index 06f970fc8d..7cf884a083 100644 --- a/packages/yoroi-extension/app/stores/toplevel/AppStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/AppStore.js @@ -3,10 +3,9 @@ import { computed } from 'mobx'; import Store from '../base/Store'; import { buildRoute } from '../../utils/routing'; import { ROUTES } from '../../routes-config'; -import type { ActionsMap } from '../../actions/index'; import type { StoresMap } from '../index'; -export default class AppStore extends Store { +export default class AppStore extends Store { @computed get currentRoute(): string { return this.stores.router.location.pathname; diff --git a/packages/yoroi-extension/app/stores/toplevel/DappConnectorStore.js b/packages/yoroi-extension/app/stores/toplevel/DappConnectorStore.js index 6301ac65b1..26c11129c5 100644 --- a/packages/yoroi-extension/app/stores/toplevel/DappConnectorStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/DappConnectorStore.js @@ -8,7 +8,6 @@ import type { WhitelistEntry, ConnectedSites, } from '../../../chrome/extension/connector/types'; -import type { ActionsMap } from '../../actions/index'; import type { StoresMap } from '../index'; import { noop } from '../../coreUtils'; import { @@ -21,7 +20,7 @@ type SetWhitelistFunc = {| whitelist: Array | void, |} => Promise; -export default class ConnectorStore extends Store { +export default class ConnectorStore extends Store { @observable connectingMessage: ?ConnectingMessage = null; @observable whiteList: Array = []; @observable getConnectorWhitelistRequest: Request< diff --git a/packages/yoroi-extension/app/stores/toplevel/DelegationStore.js b/packages/yoroi-extension/app/stores/toplevel/DelegationStore.js index da09634cd4..6d77e8937c 100644 --- a/packages/yoroi-extension/app/stores/toplevel/DelegationStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/DelegationStore.js @@ -9,7 +9,6 @@ import CachedRequest from '../lib/LocalizedCachedRequest'; import LocalizableError from '../../i18n/LocalizableError'; import { PoolMissingApiError } from '../../api/common/errors'; import type { MangledAmountFunc, MangledAmountsResponse } from '../stateless/mangledAddresses'; -import type { ActionsMap } from '../../actions/index'; import type { StoresMap } from '../index'; import type { ExplorerPoolInfo as PoolInfo } from '@emurgo/yoroi-lib'; import { PoolInfoApi } from '@emurgo/yoroi-lib'; @@ -60,7 +59,7 @@ export type PoolTransition = {| export type PoolTransitionModal = {| show: 'open' | 'closed' | 'idle', shouldUpdatePool?: boolean |}; -export default class DelegationStore extends Store { +export default class DelegationStore extends Store { @observable delegationRequests: Array = []; @observable governanceStatus: any = null; diff --git a/packages/yoroi-extension/app/stores/toplevel/LoadingStore.js b/packages/yoroi-extension/app/stores/toplevel/LoadingStore.js index af07a097ef..8faab29781 100644 --- a/packages/yoroi-extension/app/stores/toplevel/LoadingStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/LoadingStore.js @@ -10,7 +10,6 @@ import type { UriParams } from '../../utils/URIHandling'; import { isWithinSupply } from '../../utils/validations'; import { networks, defaultAssets } from '../../api/ada/lib/storage/database/prepackaged/networks'; import { getDefaultEntryToken } from './TokenInfoStore'; -import type { ActionsMap } from '../../actions/index'; import type { StoresMap } from '../index'; import { TabIdKeys, @@ -22,7 +21,7 @@ type SellAdaParamsType = {| amount: string, |}; -export default class LoadingStore extends BaseLoadingStore { +export default class LoadingStore extends BaseLoadingStore { /** * null if app not opened from URI Scheme OR URI scheme was invalid */ diff --git a/packages/yoroi-extension/app/stores/toplevel/MemosStore.js b/packages/yoroi-extension/app/stores/toplevel/MemosStore.js index 75d6262a3c..0c3befc075 100644 --- a/packages/yoroi-extension/app/stores/toplevel/MemosStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/MemosStore.js @@ -18,7 +18,6 @@ import type { CreateFolderExternalTxMemoFunc } from '../../api/externalStorage/providers/IProvider.types'; import type { SelectedExternalStorageProvider } from '../../domain/ExternalStorage'; -import type { ActionsMap } from '../../actions/index'; import type { StoresMap } from '../index'; import { getAllTxMemos, @@ -28,7 +27,7 @@ import { export type MemosForWallet = Map>; -export default class MemosStore extends Store { +export default class MemosStore extends Store { @computed get providers(): { [key: string]: ProvidersType, ... } { return this.api.externalStorage.getProviders(); diff --git a/packages/yoroi-extension/app/stores/toplevel/ProtocolParametersStore.js b/packages/yoroi-extension/app/stores/toplevel/ProtocolParametersStore.js index 383b509e2f..b46358eeeb 100644 --- a/packages/yoroi-extension/app/stores/toplevel/ProtocolParametersStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/ProtocolParametersStore.js @@ -11,7 +11,7 @@ import { observable } from 'mobx'; export default class ProtocolParametersStore< StoresMapType: { ... }, // no dependency on other stores -> extends Store { +> extends Store { @observable loadProtocolParametersRequest: LocalizedRequest<() => Promise> = new LocalizedRequest(() => this.loadProtocolParameters()); diff --git a/packages/yoroi-extension/app/stores/toplevel/ServerConnectionStore.js b/packages/yoroi-extension/app/stores/toplevel/ServerConnectionStore.js index 5013e66182..d0430bfa2a 100644 --- a/packages/yoroi-extension/app/stores/toplevel/ServerConnectionStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/ServerConnectionStore.js @@ -4,13 +4,12 @@ import { observable, computed, runInAction } from 'mobx'; import Store from '../base/Store'; import type { ServerStatusErrorType } from '../../types/serverStatusErrorType'; import { ServerStatusErrors } from '../../types/serverStatusErrorType'; -import type { ActionsMap } from '../../actions/index'; import type { StoresMap } from '../index'; import { listenForServerStatusUpdate } from '../../api/thunk'; import type { ServerStatus } from '../../../chrome/extension/background/types'; import { networks } from '../../api/ada/lib/storage/database/prepackaged/networks'; -export default class ServerConnectionStore extends Store { +export default class ServerConnectionStore extends Store { @observable serverStatusByNetworkId: {| [networkId: number]: ServerStatus |} = {}; setup(): void { diff --git a/packages/yoroi-extension/app/stores/toplevel/StateFetchStore.js b/packages/yoroi-extension/app/stores/toplevel/StateFetchStore.js index 4069caec18..06ce0581a8 100644 --- a/packages/yoroi-extension/app/stores/toplevel/StateFetchStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/StateFetchStore.js @@ -14,9 +14,8 @@ export default class StateFetchStore< ... }, ... - }, - ActionsMapType -> extends Store { + } +> extends Store { @observable fetcher: IFetcher; diff --git a/packages/yoroi-extension/app/stores/toplevel/TokenInfoStore.js b/packages/yoroi-extension/app/stores/toplevel/TokenInfoStore.js index 0cb0217002..d433d73ea9 100644 --- a/packages/yoroi-extension/app/stores/toplevel/TokenInfoStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/TokenInfoStore.js @@ -40,7 +40,7 @@ export default class TokenInfoStore< }, ... } -> extends Store { +> extends Store { @observable tokenInfo: TokenInfoMap; setup(): void { diff --git a/packages/yoroi-extension/app/stores/toplevel/TransactionBuilderStore.js b/packages/yoroi-extension/app/stores/toplevel/TransactionBuilderStore.js index c69b8777f1..027f50af5e 100644 --- a/packages/yoroi-extension/app/stores/toplevel/TransactionBuilderStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/TransactionBuilderStore.js @@ -12,7 +12,6 @@ import type { TransactionMetadata } from '../../api/ada/lib/storage/bridge/metad import { MultiToken } from '../../api/common/lib/MultiToken'; import type { TokenRow, } from '../../api/ada/lib/storage/database/primitives/tables'; import { getDefaultEntryToken } from './TokenInfoStore'; -import type { ActionsMap } from '../../actions/index'; import type { StoresMap } from '../index'; import { maxSendableADA } from '../../api/ada/transactions/shelley/transactions'; import type { WalletState } from '../../../chrome/extension/background/types'; @@ -41,7 +40,7 @@ export type MaxSendableAmountRequest = * * These can be loosened later to create a manual UTXO selection feature */ -export default class TransactionBuilderStore extends Store { +export default class TransactionBuilderStore extends Store { /** Stores the tx information as the user is building it */ @observable plannedTxInfoMap: PlannedTxInfoMap= []; diff --git a/packages/yoroi-extension/app/stores/toplevel/TransactionsStore.js b/packages/yoroi-extension/app/stores/toplevel/TransactionsStore.js index d66589d037..b7fa9f59de 100644 --- a/packages/yoroi-extension/app/stores/toplevel/TransactionsStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/TransactionsStore.js @@ -16,7 +16,6 @@ import globalMessages from '../../i18n/global-messages'; 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, { Moment } from 'moment'; import { toRequestAddresses } from '../../api/ada/lib/storage/bridge/updateTransactions' @@ -48,7 +47,7 @@ export type TransactionRowsToExportRequest = {| endDate: typeof Moment, |}; -export default class TransactionsStore extends Store { +export default class TransactionsStore extends Store { /** Track transactions for a set of wallets */ @observable txHistoryStates: Array = []; diff --git a/packages/yoroi-extension/app/stores/toplevel/UiDialogsStore.js b/packages/yoroi-extension/app/stores/toplevel/UiDialogsStore.js index 7ab8746d0e..7c75fdcdcc 100644 --- a/packages/yoroi-extension/app/stores/toplevel/UiDialogsStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/UiDialogsStore.js @@ -28,7 +28,7 @@ type DialogEntry = {| */ export default class UiDialogsStore< TStores, -> extends Store +> extends Store { @observable dialogList: Array = []; diff --git a/packages/yoroi-extension/app/stores/toplevel/UiNotificationsStore.js b/packages/yoroi-extension/app/stores/toplevel/UiNotificationsStore.js index c4e2d0579b..db6cfb8ce2 100644 --- a/packages/yoroi-extension/app/stores/toplevel/UiNotificationsStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/UiNotificationsStore.js @@ -6,7 +6,7 @@ import type { Notification } from '../../types/notification.types'; /** Manage a list on ongoing notifications and closes them when they expire */ export default class UiNotificationsStore< TStores, -> extends Store +> extends Store { @observable activeNotifications: Array = []; diff --git a/packages/yoroi-extension/app/stores/toplevel/WalletBackupStore.js b/packages/yoroi-extension/app/stores/toplevel/WalletBackupStore.js index 120f2bc7cc..394ceaf747 100644 --- a/packages/yoroi-extension/app/stores/toplevel/WalletBackupStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/WalletBackupStore.js @@ -6,7 +6,6 @@ import WalletBackupDialog from '../../components/wallet/WalletBackupDialog'; import { HARD_DERIVATION_START, } from '../../config/numbersConfig'; -import type { ActionsMap } from '../../actions/index'; import type { StoresMap } from '../index'; export type WalletBackupSteps = 'privacyWarning' | 'recoveryPhraseDisplay' | 'recoveryPhraseEntry' | null; @@ -19,7 +18,7 @@ export type RecoveryPhraseSortedArray = Array<{| /** Pipeline for users to create their wallet and backing up their mnemonic somewhere safe */ export default -class WalletBackupStore extends Store { +class WalletBackupStore extends Store { @observable inProgress: boolean; @observable currentStep: WalletBackupSteps; diff --git a/packages/yoroi-extension/app/stores/toplevel/WalletRestoreStore.js b/packages/yoroi-extension/app/stores/toplevel/WalletRestoreStore.js index 4093570e6a..118fb90536 100644 --- a/packages/yoroi-extension/app/stores/toplevel/WalletRestoreStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/WalletRestoreStore.js @@ -13,7 +13,6 @@ import { import type { NetworkRow } from '../../api/ada/lib/storage/database/primitives/tables'; import type { $npm$ReactIntl$MessageDescriptor } from 'react-intl'; import { defineMessages } from 'react-intl'; -import type { ActionsMap } from '../../actions/index'; import type { StoresMap } from '../index'; import AdaApi from '../../api/ada'; import type { WalletState } from '../../../chrome/extension/background/types'; @@ -118,7 +117,7 @@ export type WalletRestoreMeta = {| walletPassword: string, |}; -export default class AdaWalletRestoreStore extends Store { +export default class AdaWalletRestoreStore extends Store { @observable selectedAccount: number = 0 + HARD_DERIVATION_START; @observable step: RestoreStepsType; diff --git a/packages/yoroi-extension/app/stores/toplevel/WalletSettingsStore.js b/packages/yoroi-extension/app/stores/toplevel/WalletSettingsStore.js index ff2f5093d0..4f4d6a5050 100644 --- a/packages/yoroi-extension/app/stores/toplevel/WalletSettingsStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/WalletSettingsStore.js @@ -5,7 +5,6 @@ import { find, } from 'lodash'; import Store from '../base/Store'; import type { RemoveAllTransactionsFunc } from '../../api/common'; import Request from '../lib/LocalizedRequest'; -import type { ActionsMap } from '../../actions/index'; import type { StoresMap } from '../index'; import { removeWalletFromDb, @@ -20,7 +19,7 @@ export type WarningList = {| dialogs: Array Node>, |}; -export default class WalletSettingsStore extends Store { +export default class WalletSettingsStore extends Store { @observable renameModelRequest: Request<(() => Promise) => Promise> = new Request(async (func) => { await func(); }); diff --git a/packages/yoroi-extension/app/stores/toplevel/WalletStore.js b/packages/yoroi-extension/app/stores/toplevel/WalletStore.js index 8a8153ab9e..5182dc4443 100644 --- a/packages/yoroi-extension/app/stores/toplevel/WalletStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/WalletStore.js @@ -12,7 +12,6 @@ import { Logger, stringifyError } from '../../utils/logging'; import type { WalletChecksum } from '@emurgo/cip4-js'; import { createDebugWalletDialog } from '../../containers/wallet/dialogs/DebugWalletDialogContainer'; import { createProblematicWalletDialog } from '../../containers/wallet/dialogs/ProblematicWalletDialogContainer'; -import type { ActionsMap } from '../../actions/index'; import type { StoresMap } from '../index'; import { getNetworkById, getCardanoHaskellBaseConfig } from '../../api/ada/lib/storage/database/prepackaged/networks'; import type { WalletState } from '../../../chrome/extension/background/types'; @@ -36,7 +35,7 @@ export type SendMoneyRequest = Request>; * The base wallet store that contains the shared logic * dealing with wallets / accounts. */ -export default class WalletStore extends Store { +export default class WalletStore extends Store { ON_VISIBLE_DEBOUNCE_WAIT: number = 1000; @observable initialSyncingWalletIds: Set = observable.set(); diff --git a/packages/yoroi-extension/app/stores/toplevel/YoroiTransferStore.js b/packages/yoroi-extension/app/stores/toplevel/YoroiTransferStore.js index 02dd82a525..aaed7def81 100644 --- a/packages/yoroi-extension/app/stores/toplevel/YoroiTransferStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/YoroiTransferStore.js @@ -12,11 +12,10 @@ import config from '../../config'; import { SendTransactionApiError } from '../../api/common/errors'; import type { Address, Addressing } from '../../api/ada/lib/storage/models/PublicDeriver/interfaces'; import type { NetworkRow } from '../../api/ada/lib/storage/database/primitives/tables'; -import type { ActionsMap } from '../../actions/index'; import type { StoresMap } from '../index'; import type { WalletState } from '../../../chrome/extension/background/types'; -export default class YoroiTransferStore extends Store { +export default class YoroiTransferStore extends Store { @observable status: TransferStatusT = TransferStatus.UNINITIALIZED; @observable error: ?LocalizableError = null; From 523985de5597886445965a5e09e9eb9e602087af Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Tue, 15 Oct 2024 20:20:59 +0300 Subject: [PATCH 48/76] removed passing actions to stores --- .../app/connector/stores/ada/index.js | 6 ++---- .../yoroi-extension/app/connector/stores/index.js | 8 +++----- packages/yoroi-extension/app/stores/ada/index.js | 6 ++---- .../app/stores/base/AddressSubgroupStore.js | 14 -------------- packages/yoroi-extension/app/stores/base/Store.js | 4 +--- packages/yoroi-extension/app/stores/index.js | 8 +++----- .../app/stores/stateless/addressStores.js | 2 -- .../app/stores/toplevel/AddressesStore.js | 1 - .../chrome/extension/connector/index.js | 5 ++--- packages/yoroi-extension/chrome/extension/index.js | 5 ++--- 10 files changed, 15 insertions(+), 44 deletions(-) diff --git a/packages/yoroi-extension/app/connector/stores/ada/index.js b/packages/yoroi-extension/app/connector/stores/ada/index.js index 5d84e0be3d..378a0fcb1d 100644 --- a/packages/yoroi-extension/app/connector/stores/ada/index.js +++ b/packages/yoroi-extension/app/connector/stores/ada/index.js @@ -2,7 +2,6 @@ import { observable, action } from 'mobx'; import AdaStateFetchStore from '../../../stores/ada/AdaStateFetchStore'; -import type { ActionsMap } from '../../actions/index'; import type { Api } from '../../../api/index'; import type { StoresMap } from '../index'; @@ -25,13 +24,12 @@ export default (action( ( stores: StoresMap, api: Api, - actions: ActionsMap, ): AdaStoresMap => { const storeNames: Array<$Keys> = Object.keys(adaStoreClasses); storeNames.forEach(name => { if (adaStores[name]) adaStores[name].teardown(); }); storeNames.forEach(name => { - adaStores[name] = ((new adaStoreClasses[name](stores, api, actions)): any); + adaStores[name] = ((new adaStoreClasses[name](stores, api)): any); }); return (adaStores: any); } -): (StoresMap, Api, ActionsMap) => AdaStoresMap); +): (StoresMap, Api) => AdaStoresMap); diff --git a/packages/yoroi-extension/app/connector/stores/index.js b/packages/yoroi-extension/app/connector/stores/index.js index 82bd92463a..898ff1d8a4 100644 --- a/packages/yoroi-extension/app/connector/stores/index.js +++ b/packages/yoroi-extension/app/connector/stores/index.js @@ -8,7 +8,6 @@ import ConnectorCoinPriceStore from './toplevel/ConnectorCoinPriceStore'; import TokenInfoStore from '../../stores/toplevel/TokenInfoStore'; import ConnectorStore from './ConnectorStore'; import ConnectorLoadingStore from './toplevel/ConnectorLoadingStore'; -import type { ActionsMap } from '../actions'; import type { AdaStoresMap } from './ada/index'; import setupAdaStores from './ada/index'; import StateFetchStore from '../../stores/toplevel/StateFetchStore'; @@ -71,14 +70,13 @@ function initializeSubstore( export default (action( ( api: Api, - actions: ActionsMap ): StoresMap => { const storeNames = Object.keys(storeClasses); storeNames.forEach(name => { if (stores[name]) stores[name].teardown(); }); storeNames.forEach(name => { - stores[name] = (new storeClasses[name](stores, api, actions): any); + stores[name] = (new storeClasses[name](stores, api): any); }); storeNames.forEach(name => { if (stores[name]) stores[name].initialize(); @@ -89,7 +87,7 @@ export default (action( * Because to make sure all substores are non-null we have to create the object * But we only want to actually initialize it if it is the currency in use */ stores.substores = { - ada: setupAdaStores((stores: any), api, actions), + ada: setupAdaStores((stores: any), api), }; const loadedStores: StoresMap = (stores: any); @@ -102,4 +100,4 @@ export default (action( return loadedStores; } -): (Api, ActionsMap) => StoresMap); +): (Api) => StoresMap); diff --git a/packages/yoroi-extension/app/stores/ada/index.js b/packages/yoroi-extension/app/stores/ada/index.js index 7e7dec2321..7a13797446 100644 --- a/packages/yoroi-extension/app/stores/ada/index.js +++ b/packages/yoroi-extension/app/stores/ada/index.js @@ -19,7 +19,6 @@ import AdaDelegationStore from './AdaDelegationStore'; import AdaMnemonicSendStore from './send/AdaMnemonicSendStore'; import VotingStore from './VotingStore'; import SwapStore from './SwapStore'; -import type { ActionsMap } from '../../actions/index'; import type { Api } from '../../api/index'; import type { StoresMap } from '../index'; import BaseCardanoTimeStore from '../base/BaseCardanoTimeStore'; @@ -91,13 +90,12 @@ export default (action( ( stores: StoresMap, api: Api, - actions: ActionsMap, ): AdaStoresMap => { const storeNames: Array<$Keys> = Object.keys(adaStoreClasses); storeNames.forEach(name => { if (adaStores[name]) adaStores[name].teardown(); }); storeNames.forEach(name => { - adaStores[name] = ((new adaStoreClasses[name](stores, api, actions)): any); + adaStores[name] = ((new adaStoreClasses[name](stores, api)): any); }); return (adaStores: any); } -): (StoresMap, Api, ActionsMap) => AdaStoresMap); +): (StoresMap, Api) => AdaStoresMap); diff --git a/packages/yoroi-extension/app/stores/base/AddressSubgroupStore.js b/packages/yoroi-extension/app/stores/base/AddressSubgroupStore.js index 6dcf98d570..2406252231 100644 --- a/packages/yoroi-extension/app/stores/base/AddressSubgroupStore.js +++ b/packages/yoroi-extension/app/stores/base/AddressSubgroupStore.js @@ -4,7 +4,6 @@ import { observable, computed, action } from 'mobx'; import CachedRequest from '../lib/LocalizedCachedRequest'; import { find } from 'lodash'; import type { StoresMap } from '../index'; -import type { ActionsMap } from '../../actions'; import type { StandardAddress, } from '../../types/AddressFilterTypes'; import { ChainDerivations } from '../../config/numbersConfig'; import { CoreAddressTypes } from '../../api/ada/lib/storage/database/primitives/enums'; @@ -23,15 +22,12 @@ export class AddressTypeStore { |}> = []; stores: StoresMap; - actions: ActionsMap; request: SubRequestType; constructor(data: {| stores: StoresMap, - actions: ActionsMap, request: SubRequestType, |}) { this.stores = data.stores; - this.actions = data.actions; this.request = data.request; } @@ -88,7 +84,6 @@ export class AddressBookSubgroup extends AddressTypeStore implements IAddressTyp constructor(data: SubgroupCtorData): IAddressTypeStore { super({ stores: data.stores, - actions: data.actions, request: (request) => data.stores.addresses._wrapForeign({ ...request, storeName: data.name, @@ -101,7 +96,6 @@ export class ByronAllAddressesSubgroup extends AddressTypeStore implements IAddr constructor(data: SubgroupCtorData): IAddressTypeStore { super({ stores: data.stores, - actions: data.actions, request: (request) => data.stores.addresses._wrapForAllAddresses({ ...request, storeName: data.name, @@ -115,7 +109,6 @@ export class ByronExternalAddressesSubgroup extends AddressTypeStore implements constructor(data: SubgroupCtorData): IAddressTypeStore { super({ stores: data.stores, - actions: data.actions, request: (request) => data.stores.addresses._createAddressIfNeeded({ publicDeriver: request.publicDeriver, genAddresses: () => data.stores.addresses._wrapForChainAddresses({ @@ -133,7 +126,6 @@ export class ByronInternalAddressesSubgroup extends AddressTypeStore implements constructor(data: SubgroupCtorData): IAddressTypeStore { super({ stores: data.stores, - actions: data.actions, request: (request) => data.stores.addresses._wrapForChainAddresses({ ...request, storeName: data.name, @@ -148,7 +140,6 @@ export class BaseExternalAddressesSubgroup extends AddressTypeStore implements I constructor(data: SubgroupCtorData): IAddressTypeStore { super({ stores: data.stores, - actions: data.actions, request: (request) => data.stores.addresses._createAddressIfNeeded({ publicDeriver: request.publicDeriver, genAddresses: () => data.stores.addresses._wrapForChainAddresses({ @@ -166,7 +157,6 @@ export class BaseInternalAddressesSubgroup extends AddressTypeStore implements I constructor(data: SubgroupCtorData): IAddressTypeStore { super({ stores: data.stores, - actions: data.actions, request: (request) => data.stores.addresses._createAddressIfNeeded({ publicDeriver: request.publicDeriver, genAddresses: () => data.stores.addresses._wrapForChainAddresses({ @@ -184,7 +174,6 @@ export class BaseMangledAddressesSubgroup extends AddressTypeStore implements IA constructor(data: SubgroupCtorData): IAddressTypeStore { super({ stores: data.stores, - actions: data.actions, request: (request) => data.stores.addresses._wrapForAllAddresses({ publicDeriver: request.publicDeriver, ...request, @@ -200,7 +189,6 @@ export class EnterpriseExternalAddressesSubgroup constructor(data: SubgroupCtorData): IAddressTypeStore { super({ stores: data.stores, - actions: data.actions, request: (request) => data.stores.addresses._createAddressIfNeeded({ publicDeriver: request.publicDeriver, genAddresses: () => data.stores.addresses._wrapForChainAddresses({ @@ -219,7 +207,6 @@ export class EnterpriseInternalAddressesSubgroup constructor(data: SubgroupCtorData): IAddressTypeStore { super({ stores: data.stores, - actions: data.actions, request: (request) => data.stores.addresses._createAddressIfNeeded({ publicDeriver: request.publicDeriver, genAddresses: () => data.stores.addresses._wrapForChainAddresses({ @@ -237,7 +224,6 @@ export class RewardAddressesSubgroup extends AddressTypeStore implements IAddres constructor(data: SubgroupCtorData): IAddressTypeStore { super({ stores: data.stores, - actions: data.actions, request: (request) => data.stores.addresses._wrapForAllAddresses({ publicDeriver: request.publicDeriver, ...request, diff --git a/packages/yoroi-extension/app/stores/base/Store.js b/packages/yoroi-extension/app/stores/base/Store.js index 66c42802c1..fe7bb39168 100644 --- a/packages/yoroi-extension/app/stores/base/Store.js +++ b/packages/yoroi-extension/app/stores/base/Store.js @@ -7,14 +7,12 @@ export default class Store { stores: TStores; api: Api; - actions: any; _reactions: Array = []; - constructor(stores: TStores, api: Api, actions: any) { + constructor(stores: TStores, api: Api) { this.stores = stores; this.api = api; - this.actions = actions; } /** Register a set of autoruns with the same lifetime as the store */ diff --git a/packages/yoroi-extension/app/stores/index.js b/packages/yoroi-extension/app/stores/index.js index 5394776360..66a0d5ddf7 100644 --- a/packages/yoroi-extension/app/stores/index.js +++ b/packages/yoroi-extension/app/stores/index.js @@ -18,7 +18,6 @@ import DelegationStore from './toplevel/DelegationStore'; import setupAdaStores from './ada/index'; import type { AdaStoresMap } from './ada/index'; import { RouterStore } from 'mobx-react-router'; -import type { ActionsMap } from '../actions/index'; import type { Api } from '../api/index'; import StateFetchStore from './toplevel/StateFetchStore'; import CoinPriceStore from './toplevel/CoinPriceStore'; @@ -131,7 +130,6 @@ function initializeSubstore( export default (action( async ( api: Api, - actions: ActionsMap, // $FlowFixMe[value-as-type] router: RouterStore ): Promise => { @@ -153,7 +151,7 @@ export default (action( storeNames.forEach(name => { // Careful: we pass incomplete `store` down to child components // Any toplevel store that accesses `store` in its constructor may crash - stores[name] = ((new storeClasses[name](stores, api, actions)): any); + stores[name] = ((new storeClasses[name](stores, api)): any); }); storeNames.forEach(name => { if (stores[name]) stores[name].initialize(); }); @@ -162,7 +160,7 @@ export default (action( * Because to make sure all substores are non-null we have to create the object * But we only want to actually initialize it if it is the currency in use */ stores.substores = { - ada: setupAdaStores((stores: any), api, actions), + ada: setupAdaStores((stores: any), api), }; const loadedStores: StoresMap = (stores: any); @@ -176,4 +174,4 @@ export default (action( return loadedStores; } // $FlowFixMe[value-as-type] -): (Api, ActionsMap, RouterStore) => StoresMap); +): (Api, RouterStore) => StoresMap); diff --git a/packages/yoroi-extension/app/stores/stateless/addressStores.js b/packages/yoroi-extension/app/stores/stateless/addressStores.js index 5285d0827d..630565d71d 100644 --- a/packages/yoroi-extension/app/stores/stateless/addressStores.js +++ b/packages/yoroi-extension/app/stores/stateless/addressStores.js @@ -25,7 +25,6 @@ import { addressGroupName, } from '../../types/AddressFilterTypes'; import type { StoresMap } from '../index'; -import type { ActionsMap } from '../../actions'; import { ROUTES } from '../../routes-config'; import { buildRoute } from '../../utils/routing'; import { getNetworkById } from '../../api/ada/lib/storage/database/prepackaged/networks'; @@ -39,7 +38,6 @@ import type { WalletState } from '../../../chrome/extension/background/types'; export type SubgroupCtorData = {| stores: StoresMap, - actions: ActionsMap, name: AddressTypeName, |} export interface IAddressTypeUiSubset { diff --git a/packages/yoroi-extension/app/stores/toplevel/AddressesStore.js b/packages/yoroi-extension/app/stores/toplevel/AddressesStore.js index d9334d5712..9b7a4e148e 100644 --- a/packages/yoroi-extension/app/stores/toplevel/AddressesStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/AddressesStore.js @@ -38,7 +38,6 @@ export default class AddressesStore extends Store { for (const store of allAddressSubgroups) { this._addressSubgroupMap.set(store.class, new store.class({ stores: this.stores, - actions: this.actions, name: store.name, })); } diff --git a/packages/yoroi-extension/chrome/extension/connector/index.js b/packages/yoroi-extension/chrome/extension/connector/index.js index 29cddf2592..0d642579fd 100644 --- a/packages/yoroi-extension/chrome/extension/connector/index.js +++ b/packages/yoroi-extension/chrome/extension/connector/index.js @@ -30,15 +30,14 @@ const initializeDappConnector: void => Promise = async () => { const router = new RouterStore(); const hashHistory = createHashHistory(); const history = syncHistoryWithStore(hashHistory, router); - const stores = createStores(api, actions); + const stores = createStores(api); window.yoroi = { api, - actions, translations, stores, reset: action(() => { - createStores(api, actions); + createStores(api); }), }; diff --git a/packages/yoroi-extension/chrome/extension/index.js b/packages/yoroi-extension/chrome/extension/index.js index 1e15943440..c545dd8b49 100644 --- a/packages/yoroi-extension/chrome/extension/index.js +++ b/packages/yoroi-extension/chrome/extension/index.js @@ -31,17 +31,16 @@ const initializeYoroi: void => Promise = async () => { const router = new RouterStore(); const hashHistory = createHashHistory(); const history = syncHistoryWithStore(hashHistory, router); - const stores = await createStores(api, actions, router); + const stores = await createStores(api, router); Logger.debug(`[yoroi] stores created`); window.yoroi = { api, - actions, translations, stores, reset: action(async () => { - await createStores(api, actions, router); + await createStores(api, router); }) }; From 033da61c9a86a9332968755570426ae42724a4b7 Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Tue, 15 Oct 2024 20:41:39 +0300 Subject: [PATCH 49/76] Renamed `StepController` property `actions` to `stepActions` --- .../components/wallet/create-wallet/AddWalletDetailsStep.js | 2 +- .../wallet/create-wallet/LearnAboutRecoveryPhrase.js | 4 ++-- .../wallet/create-wallet/SaveRecoveryPhraseStep.js | 2 +- .../components/wallet/create-wallet/SelectNetworkStep.js | 2 +- .../app/components/wallet/create-wallet/StepController.js | 6 +++--- .../wallet/create-wallet/VerifyRecoveryPhraseStep.js | 2 +- .../wallet/restore/steps/phrase/EnterRecoveryPhraseStep.js | 2 +- .../wallet/restore/steps/type/SelectWalletTypeStep.js | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/yoroi-extension/app/components/wallet/create-wallet/AddWalletDetailsStep.js b/packages/yoroi-extension/app/components/wallet/create-wallet/AddWalletDetailsStep.js index 9db496e052..a59d44d74e 100644 --- a/packages/yoroi-extension/app/components/wallet/create-wallet/AddWalletDetailsStep.js +++ b/packages/yoroi-extension/app/components/wallet/create-wallet/AddWalletDetailsStep.js @@ -227,7 +227,7 @@ export default class AddWalletDetailsStep extends Component { /> - {actions.map(({ type, label, disabled, onClick }, idx) => { + {stepActions.map(({ type, label, disabled, onClick }, idx) => { const isPrimary = type === 'primary'; return (
    - -
    + + + } + /> + + 2017-2020 + + + ); } } diff --git a/packages/yoroi-extension/app/components/transfer/cards/TransferCards.scss b/packages/yoroi-extension/app/components/transfer/cards/TransferCards.scss deleted file mode 100644 index 737783f665..0000000000 --- a/packages/yoroi-extension/app/components/transfer/cards/TransferCards.scss +++ /dev/null @@ -1,29 +0,0 @@ -@import '../../mixins/card-mixin.scss'; - -.heroCardsList { - display: flex; -} - -.heroCardsItem { - @include card-mixin; -} - -.heroCardsItemBg { - flex: 1 0 auto; - background-repeat: no-repeat; - background-position: top center; - background-size: contain; -} - -.heroCardsItemBg { - &.bgByronMainnet { - background-image: url(../../../assets/images/add-wallet/option-dialog/restore-paper-wallet-modern.inline.svg); - } -} - -.tooltipSize { - max-width: 500px; - overflow-wrap: break-word; - white-space: normal; -} - From 57a781ad0d107bf94aea8d45da06bde2c34af051 Mon Sep 17 00:00:00 2001 From: Denis Nebytov Date: Thu, 19 Dec 2024 20:05:25 +0300 Subject: [PATCH 57/76] updated transfer paper wallet workflow to dark theme --- .../app/components/common/Autocomplete.js | 50 ++++++-------- .../components/transfer/BaseTransferPage.js | 57 ++++++++-------- .../components/transfer/BaseTransferPage.scss | 31 --------- .../transfer/TransferSummaryPage.js | 34 ++++++---- .../transfer/TransferSummaryPage.scss | 1 - .../wallet/WalletRestoreVerifyDialog.js | 68 +++++++++---------- .../wallet/WalletRestoreVerifyDialog.scss | 13 ---- .../components/widgets/DialogTextBlock.scss | 19 ------ .../components/widgets/forms/MnemonicInput.js | 11 ++- .../components/widgets/forms/PasswordInput.js | 9 ++- 10 files changed, 119 insertions(+), 174 deletions(-) delete mode 100644 packages/yoroi-extension/app/components/transfer/BaseTransferPage.scss diff --git a/packages/yoroi-extension/app/components/common/Autocomplete.js b/packages/yoroi-extension/app/components/common/Autocomplete.js index 23ec71326f..6f4ad9ae41 100644 --- a/packages/yoroi-extension/app/components/common/Autocomplete.js +++ b/packages/yoroi-extension/app/components/common/Autocomplete.js @@ -7,9 +7,8 @@ import { useCombobox, useMultipleSelection } from 'downshift'; import { Input, Box, InputLabel, FormControl, FormHelperText, Chip, useTheme } from '@mui/material'; import { styled } from '@mui/system'; import { slice } from 'lodash'; -import { ReactComponent as SuccessIcon } from '../../assets/images/forms/done.inline.svg'; -import { ReactComponent as ErrorIcon } from '../../assets/images/forms/error.inline.svg'; -import { ReactComponent as CloseIcon } from '../../assets/images/close-chip.inline.svg'; +import { ReactComponent as SuccessIcon } from '../../assets/images/forms/done.inline.svg'; +import { ReactComponent as CloseIcon } from '../../assets/images/close-chip.inline.svg'; type Props = {| +options: Array, @@ -56,12 +55,7 @@ function Autocomplete({ : options; const sliceArrayItems = slice(filteredList, 0, maxVisibleOptions); - const { - getSelectedItemProps, - getDropdownProps, - addSelectedItem, - removeSelectedItem, - } = useMultipleSelection({ + const { getSelectedItemProps, getDropdownProps, addSelectedItem, removeSelectedItem } = useMultipleSelection({ onSelectedItemsChange: ({ selectedItems }) => { onChange(selectedItems); }, @@ -131,7 +125,11 @@ function Autocomplete({ {...(value.length || theme.name === 'classic' ? { shrink: true } : {})} htmlFor={id ?? 'autocomplete-combobox'} {...getLabelProps()} - sx={{ backgroundColor: 'var(--yoroi-palette-common-white)', padding: '0px 6px' }} + sx={{ + backgroundColor: 'ds.bg_color_contrast_high', + padding: '0px 6px', + color: isOpen ? 'ds.text_gray_medium' : 'ds.text_gray_low', + }} > {label} @@ -177,10 +175,7 @@ function Autocomplete({ })} /> - - {done === true ? : null} - {Boolean(error) === true ? : null} - + {done === true ? : null} {error} @@ -195,7 +190,9 @@ function Autocomplete({ {noResultsMessage} @@ -208,11 +205,10 @@ function Autocomplete({ key={`${item}${index}`} sx={{ padding: '14px 20px', - backgroundColor: - highlightedIndex === index - ? 'var(--yoroi-palette-gray-50)' - : 'var(--yoroi-palette-common-white)', + color: 'ds.text_gray_medium', + backgroundColor: highlightedIndex === index ? 'ds.bg_color_contrast_min' : 'ds.bg_color_contrast_high', cursor: 'pointer', + boxShadow: isOpen ? 'ds.light_shadow_dropdown_menu' : 'unset', }} {...getItemProps({ item, @@ -270,17 +266,9 @@ const ULList = styled(Box)({ const InputWrapper = styled(Box)( ({ theme, error, isOpen }) => ` width: 100%; - border: ${isOpen ? '2px' : '1px'} solid ${ - error - ? 'var(--yoroi-comp-input-error)' - : isOpen - ? 'var(--yoroi-comp-input-text-focus)' - : theme.name === 'classic' - ? '#c7ced6' - : 'var(--yoroi-comp-input-border)' - }; - border-radius: ${theme.name === 'classic' ? '0' : '8px'}; - background-color: ${theme.name === 'classic' ? '#f4f4f6' : 'var(--yoroi-palette-common-white)'}; + border: ${isOpen ? '2px' : '1px'} solid ${error ? theme.palette.ds.sys_magenta_500 : theme.palette.ds.primary_200}; + border-radius: 8px; + background-color: ${theme.palette.ds.bg_color_contrast_high}; min-height: ${theme.name === 'classic' ? '73px' : '140px'}; align-content: baseline; display: inline-flex; @@ -292,7 +280,7 @@ const InputWrapper = styled(Box)( cursor: text; & input { background-color: transparent; - color: ${theme.name === 'classic' ? 'var(--yoroi-comp-input-border)' : '#000000d9'}; + color: ${theme.palette.ds.text_gray_medium}; font-size: 1rem; padding: 4px 6px; letter-spacing: 0; diff --git a/packages/yoroi-extension/app/components/transfer/BaseTransferPage.js b/packages/yoroi-extension/app/components/transfer/BaseTransferPage.js index 7addab7f7d..c3b8e00794 100644 --- a/packages/yoroi-extension/app/components/transfer/BaseTransferPage.js +++ b/packages/yoroi-extension/app/components/transfer/BaseTransferPage.js @@ -7,9 +7,9 @@ import { intlShape } from 'react-intl'; import globalMessages from '../../i18n/global-messages'; import DialogBackButton from '../widgets/DialogBackButton'; import Dialog from '../widgets/Dialog'; -import styles from './BaseTransferPage.scss'; import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; import LocalizableError from '../../i18n/LocalizableError'; +import { Box, Typography } from '@mui/material'; type Props = {| +children: Node, @@ -22,21 +22,17 @@ type Props = {| @observer export default class BaseTransferPage extends Component { - - static defaultProps: {|error: void|} = { - error: undefined + static defaultProps: {| error: void |} = { + error: undefined, }; - static contextTypes: {|intl: $npm$ReactIntl$IntlFormat|} = { - intl: intlShape.isRequired + static contextTypes: {| intl: $npm$ReactIntl$IntlFormat |} = { + intl: intlShape.isRequired, }; render(): Node { const { intl } = this.context; - const { - onBack, - step0, - } = this.props; + const { onBack, step0 } = this.props; const actions = [ { @@ -59,28 +55,35 @@ export default class BaseTransferPage extends Component { actions={actions} closeOnOverlayClick={false} onClose={onBack} - className={styles.dialog} + className={undefined} backButton={} > -
    -
    -
    -
      -
      - {step0} -

      - {intl.formatMessage(globalMessages.step1)} -
      -
    -
    + + + + + {step0} + + + {intl.formatMessage(globalMessages.step1)} + + {this.props.children} {this.props.error && ( -
    - {intl.formatMessage(this.props.error, this.props.error.values)} -
    + + + {intl.formatMessage(this.props.error, this.props.error.values)} + + )} -
    -
    +
    + ); } diff --git a/packages/yoroi-extension/app/components/transfer/BaseTransferPage.scss b/packages/yoroi-extension/app/components/transfer/BaseTransferPage.scss deleted file mode 100644 index ba1a39770e..0000000000 --- a/packages/yoroi-extension/app/components/transfer/BaseTransferPage.scss +++ /dev/null @@ -1,31 +0,0 @@ -@import '../../themes/mixins/error-message'; - -.component { - .body { - color: var(--yoroi-palette-gray-900); - font-weight: 400; - font-size: 14px; - line-height: 19px; - - .text { - font-size: 15px; - margin-bottom: 0.3%; - word-break: break-word; - } - - .instructionsList { - list-style-type: disc; - list-style-position: inside; - margin-bottom: 10px; - } - } - - .error { - @include error-message; - font-size: 16px; - line-height: 22px; - margin-bottom: 12px; - word-break: break-word; - text-align: center; - } -} diff --git a/packages/yoroi-extension/app/components/transfer/TransferSummaryPage.js b/packages/yoroi-extension/app/components/transfer/TransferSummaryPage.js index 5265910771..ec94476460 100644 --- a/packages/yoroi-extension/app/components/transfer/TransferSummaryPage.js +++ b/packages/yoroi-extension/app/components/transfer/TransferSummaryPage.js @@ -26,6 +26,7 @@ import type { } from '../../api/common/lib/MultiToken'; import type { TokenRow } from '../../api/ada/lib/storage/database/primitives/tables'; import { getTokenName, genFormatTokenAmount } from '../../stores/stateless/tokenHelpers'; +import { Box, Typography, styled, useTheme } from '@mui/material'; const messages = defineMessages({ addressFromLabel: { @@ -50,6 +51,11 @@ const messages = defineMessages({ }, }); +const STypography = styled(Typography)(({ theme }) => ({ + color: theme.palette.ds.text_gray_medium, + fontWeight: 500, +})); + type Props = {| +dialogTitle: string, +selectedExplorer: SelectedExplorer, @@ -210,9 +216,9 @@ export default class TransferSummaryPage extends Component { return ( <>
    -
    + {intl.formatMessage(messages.addressFromLabel)} -
    + { transferTx.senders.map((sender, index) => { const addressesClasses = classnames([ @@ -243,9 +249,9 @@ export default class TransferSummaryPage extends Component { }
    -
    + {intl.formatMessage(globalMessages.walletSendConfirmationAddressToLabel)} -
    + { transferTx.receivers.map((receiver, index) => { const addressesClasses = classnames([ @@ -342,9 +348,9 @@ export default class TransferSummaryPage extends Component {
    -
    + {intl.formatMessage(messages.recoveredBalanceLabel)} -
    + {unitOfAccountSetting.enabled /* tmp */ && false ? ( <>
    @@ -370,9 +376,9 @@ export default class TransferSummaryPage extends Component {
    -
    + {intl.formatMessage(messages.transactionFeeLabel)} -
    + {unitOfAccountSetting.enabled /* tmp */ && false ? ( <>
    @@ -399,9 +405,9 @@ export default class TransferSummaryPage extends Component {
    -
    + {intl.formatMessage(globalMessages.finalBalanceLabel)} -
    + {unitOfAccountSetting.enabled /* tmp */ && false ? ( <>
    @@ -449,10 +455,10 @@ export default class TransferSummaryPage extends Component { _getTxIdNode: string => Node = (txId) => { const { intl } = this.context; return ( -
    -
    + + {intl.formatMessage(globalMessages.transactionId)} -
    + { {txId} -
    + ); } } diff --git a/packages/yoroi-extension/app/components/transfer/TransferSummaryPage.scss b/packages/yoroi-extension/app/components/transfer/TransferSummaryPage.scss index 2048d5491c..bd178c09ea 100644 --- a/packages/yoroi-extension/app/components/transfer/TransferSummaryPage.scss +++ b/packages/yoroi-extension/app/components/transfer/TransferSummaryPage.scss @@ -2,7 +2,6 @@ @import '../../themes/mixins/loading-spinner'; .body { - color: var(--yoroi-palette-gray-900); font-weight: 400; font-size: 14px; line-height: 19px; diff --git a/packages/yoroi-extension/app/components/wallet/WalletRestoreVerifyDialog.js b/packages/yoroi-extension/app/components/wallet/WalletRestoreVerifyDialog.js index 4241cae7c8..c762fa3391 100644 --- a/packages/yoroi-extension/app/components/wallet/WalletRestoreVerifyDialog.js +++ b/packages/yoroi-extension/app/components/wallet/WalletRestoreVerifyDialog.js @@ -21,6 +21,7 @@ import type { WalletChecksum } from '@emurgo/cip4-js'; import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; import { truncateAddress } from '../../utils/formatters'; import type { PlateWithMeta } from '../../stores/toplevel/WalletRestoreStore'; +import { Box, Typography } from '@mui/material'; const messages = defineMessages({ dialogTitleVerifyWalletRestoration: { @@ -70,13 +71,23 @@ export default class WalletRestoreVerifyDialog extends Component { generatePlate(title: string, plate: WalletChecksum): Node { return ( -
    -

    {title}

    -
    + + + {title} + + - {plate.TextPart} -
    -
    + + {plate.TextPart} + + + ); } @@ -88,7 +99,9 @@ export default class WalletRestoreVerifyDialog extends Component { ): Node { return ( <> -

    {title}

    + + {title} + {addresses.map((address, index) => { const notificationElementId = `${address}-${index}`; return ( @@ -119,14 +132,7 @@ export default class WalletRestoreVerifyDialog extends Component { render(): Node { const { intl } = this.context; - const { - error, - isSubmitting, - onCancel, - onNext, - onCopyAddressTooltip, - notification, - } = this.props; + const { error, isSubmitting, onCancel, onNext, onCopyAddressTooltip, notification } = this.props; const dialogClasses = classnames(['walletRestoreVerifyDialog', styles.dialog]); @@ -146,40 +152,34 @@ export default class WalletRestoreVerifyDialog extends Component { ]; const introMessage = ( -
    - {intl.formatMessage(messages.walletRestoreVerifyIntroLine1)} -
    + + + {intl.formatMessage(messages.walletRestoreVerifyIntroLine1)} +
    • - + - +
    • - + - +
    • - + - +
    -
    + ); - const plateElems = this.props.plates.map(plate => - this.generatePlate(intl.formatMessage(plate.checksumTitle), plate.plate) - ); + const plateElems = this.props.plates.map(plate => this.generatePlate(intl.formatMessage(plate.checksumTitle), plate.plate)); const addressElems = this.props.plates.map(plate => - this.generateAddresses( - intl.formatMessage(plate.addressMessage), - plate.addresses, - onCopyAddressTooltip, - notification - ) + this.generateAddresses(intl.formatMessage(plate.addressMessage), plate.addresses, onCopyAddressTooltip, notification) ); return ( diff --git a/packages/yoroi-extension/app/components/wallet/WalletRestoreVerifyDialog.scss b/packages/yoroi-extension/app/components/wallet/WalletRestoreVerifyDialog.scss index b33291dafc..f35657fd7e 100644 --- a/packages/yoroi-extension/app/components/wallet/WalletRestoreVerifyDialog.scss +++ b/packages/yoroi-extension/app/components/wallet/WalletRestoreVerifyDialog.scss @@ -34,19 +34,6 @@ margin-bottom: 6px; } -.plateRowDiv { - display: table; -} - -.plateIdSpan { - display: table-cell; - vertical-align: middle; - padding-left: 10px; - font-size: 35px; - font-weight: 500; - opacity: 0.7; -} - .error { @include error-message; margin-top: 30px; diff --git a/packages/yoroi-extension/app/components/widgets/DialogTextBlock.scss b/packages/yoroi-extension/app/components/widgets/DialogTextBlock.scss index 1a40b0899b..ba489aca2b 100644 --- a/packages/yoroi-extension/app/components/widgets/DialogTextBlock.scss +++ b/packages/yoroi-extension/app/components/widgets/DialogTextBlock.scss @@ -4,25 +4,6 @@ color: var(--yoroi-palette-gray-900); text-align: justify; padding: 10px 0 24px 0; - - h1 { - color: var(--yoroi-palette-gray-900); - font-weight: 500; - font-size: 14px; - margin-bottom: 11px; - } - - p { - font-weight: 400; - font-size: 12px; - letter-spacing: 0.5px; - line-height: 1.38; - margin-bottom: 11px; - } - - p em { - font-weight: bold; - } } .component-bottom { diff --git a/packages/yoroi-extension/app/components/widgets/forms/MnemonicInput.js b/packages/yoroi-extension/app/components/widgets/forms/MnemonicInput.js index 7e6916a433..b669d07cbb 100644 --- a/packages/yoroi-extension/app/components/widgets/forms/MnemonicInput.js +++ b/packages/yoroi-extension/app/components/widgets/forms/MnemonicInput.js @@ -86,7 +86,16 @@ export default class MnemonicInput extends Component { error={recoveryPhraseField.error} maxVisibleOptions={5} noResultsMessage={intl.formatMessage(globalMessages.recoveryPhraseNoResults)} - chipProps={{ sx: { bgcolor: ' #f0f3f5' } }} + chipProps={{ + sx: { + bgcolor: 'ds.primary_100', + color: 'ds.text_primary_medium', + ':hover': { + bgcolor: 'ds.primary_200', + color: 'ds.text_primary_max', + } + } + }} /> ); } diff --git a/packages/yoroi-extension/app/components/widgets/forms/PasswordInput.js b/packages/yoroi-extension/app/components/widgets/forms/PasswordInput.js index 374e1495e1..b4d5a520b2 100644 --- a/packages/yoroi-extension/app/components/widgets/forms/PasswordInput.js +++ b/packages/yoroi-extension/app/components/widgets/forms/PasswordInput.js @@ -9,6 +9,7 @@ import globalMessages from '../../../i18n/global-messages'; import config from '../../../config'; import TextField from '../../common/TextField'; import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; +import { Box, Typography } from '@mui/material'; type Props = {| +setForm: ReactToolboxMobxForm => void, @@ -93,8 +94,10 @@ export default class PasswordInput extends Component { const passwordField = form.$(this.props.fieldName); return ( -
    - {this.props.disclaimer} + + + {this.props.disclaimer} + { error={passwordField.error} done={this.props.done} /> -
    + ); } } From 7395525ae92ca8541777fa4b26855889e72a7e52 Mon Sep 17 00:00:00 2001 From: Denis Nebytov Date: Thu, 19 Dec 2024 20:10:42 +0300 Subject: [PATCH 58/76] lint fixes --- .../app/components/transfer/TransferSummaryPage.js | 2 +- .../app/components/transfer/cards/TransferCards.js | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/yoroi-extension/app/components/transfer/TransferSummaryPage.js b/packages/yoroi-extension/app/components/transfer/TransferSummaryPage.js index ec94476460..be3ed4c1f4 100644 --- a/packages/yoroi-extension/app/components/transfer/TransferSummaryPage.js +++ b/packages/yoroi-extension/app/components/transfer/TransferSummaryPage.js @@ -26,7 +26,7 @@ import type { } from '../../api/common/lib/MultiToken'; import type { TokenRow } from '../../api/ada/lib/storage/database/primitives/tables'; import { getTokenName, genFormatTokenAmount } from '../../stores/stateless/tokenHelpers'; -import { Box, Typography, styled, useTheme } from '@mui/material'; +import { Box, Typography, styled } from '@mui/material'; const messages = defineMessages({ addressFromLabel: { diff --git a/packages/yoroi-extension/app/components/transfer/cards/TransferCards.js b/packages/yoroi-extension/app/components/transfer/cards/TransferCards.js index ae8bb0fe13..5cdf3fe46f 100644 --- a/packages/yoroi-extension/app/components/transfer/cards/TransferCards.js +++ b/packages/yoroi-extension/app/components/transfer/cards/TransferCards.js @@ -3,12 +3,11 @@ import { Component } from 'react'; import type { Node } from 'react'; import { observer } from 'mobx-react'; import { defineMessages, intlShape } from 'react-intl'; -import classnames from 'classnames'; import globalMessages from '../../../i18n/global-messages'; import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; import CustomTooltip from '../../widgets/CustomTooltip'; -import { Box, Button, Typography, styled } from '@mui/material'; +import { Box, Typography, styled } from '@mui/material'; import PaperWalletLogo from '../../../assets/images/add-wallet/option-dialog/restore-paper-wallet-modern.inline.svg'; const messages = defineMessages({ @@ -27,8 +26,8 @@ const GradientBox = styled(Box)(({ theme }: any) => ({ const SBox = styled(Box)(({ theme }) => ({ '& svg': { - width: "20px", - height: "20px", + width: '20px', + height: '20px', '& g': { fill: theme.palette.ds.el_gray_medium, }, From d617b88f770bce4f30e387c7a738c2296c8cac1f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 20 Dec 2024 03:27:42 +0000 Subject: [PATCH 59/76] Bump chromedriver from 131.0.3 to 131.0.4 in /packages/e2e-tests Bumps [chromedriver](https://github.com/giggio/node-chromedriver) from 131.0.3 to 131.0.4. - [Commits](https://github.com/giggio/node-chromedriver/compare/131.0.3...131.0.4) --- updated-dependencies: - dependency-name: chromedriver dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- packages/e2e-tests/package-lock.json | 8 ++++---- packages/e2e-tests/package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/e2e-tests/package-lock.json b/packages/e2e-tests/package-lock.json index 68ae79d124..ed4a7e6219 100644 --- a/packages/e2e-tests/package-lock.json +++ b/packages/e2e-tests/package-lock.json @@ -41,7 +41,7 @@ "@emurgo/cardano-serialization-lib-nodejs": "^12.0.0-alpha.26", "bignumber.js": "^9.1.2", "chai": "^4.3.10", - "chromedriver": "131.0.3", + "chromedriver": "131.0.4", "cross-env": "^7.0.3", "json-server": "^0.17.4", "mocha": "^10.2.0", @@ -450,9 +450,9 @@ } }, "node_modules/chromedriver": { - "version": "131.0.3", - "resolved": "https://registry.npmjs.org/chromedriver/-/chromedriver-131.0.3.tgz", - "integrity": "sha512-DKHFt0ilcA/RJzY1ApBiJAil6fh08f9mXM8XbdDE1u+S1V5YVUNTUi4bOtJFZoAwS9nlV0H5W6InWrpXqSs2xg==", + "version": "131.0.4", + "resolved": "https://registry.npmjs.org/chromedriver/-/chromedriver-131.0.4.tgz", + "integrity": "sha512-JgIkept8YrnqT05ldLaOzxxEJDUV1t3PFIIMO/gQz9AbnpZx7Pl1zq6tQTTz2HoY5T2JKZ5kyiEWwc48g4fJ5w==", "dev": true, "hasInstallScript": true, "dependencies": { diff --git a/packages/e2e-tests/package.json b/packages/e2e-tests/package.json index 5d527c19f3..8eea930e5b 100644 --- a/packages/e2e-tests/package.json +++ b/packages/e2e-tests/package.json @@ -47,7 +47,7 @@ "@emurgo/cardano-serialization-lib-nodejs": "^12.0.0-alpha.26", "bignumber.js": "^9.1.2", "chai": "^4.3.10", - "chromedriver": "131.0.3", + "chromedriver": "131.0.4", "cross-env": "^7.0.3", "json-server": "^0.17.4", "mocha": "^10.2.0", From e4bf670584620fcb471aae7a512e4ce3ced6a209 Mon Sep 17 00:00:00 2001 From: Denis Nebytov Date: Fri, 20 Dec 2024 14:47:07 +0300 Subject: [PATCH 60/76] applied dark theme to the complexity cards --- .../complexity-level/ComplexityLevelForm.js | 145 ++++++------------ .../complexity-level/ComplexityLevelForm.scss | 97 ------------ 2 files changed, 50 insertions(+), 192 deletions(-) delete mode 100644 packages/yoroi-extension/app/components/profile/complexity-level/ComplexityLevelForm.scss diff --git a/packages/yoroi-extension/app/components/profile/complexity-level/ComplexityLevelForm.js b/packages/yoroi-extension/app/components/profile/complexity-level/ComplexityLevelForm.js index 3484721f7e..ecfb8ecc50 100644 --- a/packages/yoroi-extension/app/components/profile/complexity-level/ComplexityLevelForm.js +++ b/packages/yoroi-extension/app/components/profile/complexity-level/ComplexityLevelForm.js @@ -3,16 +3,13 @@ import { Component } from 'react'; import type { Node, ComponentType } from 'react'; import { intlShape, defineMessages, FormattedHTMLMessage } from 'react-intl'; import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; -import styles from './ComplexityLevelForm.scss'; -import classnames from 'classnames'; import { ReactComponent as BeginnerLevel } from '../../../assets/images/complexity-level/beginner-level.inline.svg'; import { ReactComponent as AdvancedLevel } from '../../../assets/images/complexity-level/advanced-level.inline.svg'; import LocalizableError from '../../../i18n/LocalizableError'; -import { LoadingButton } from '@mui/lab'; import { ComplexityLevels } from '../../../types/complexityLevelType'; import type { ComplexityLevelType } from '../../../types/complexityLevelType'; import { withLayout } from '../../../styles/context/layout'; -import { Box, Typography } from '@mui/material'; +import { Box, Typography, styled } from '@mui/material'; import { settingsMenuMessages } from '../../settings/menu/SettingsMenu'; const messages = defineMessages({ @@ -52,6 +49,35 @@ const messages = defineMessages({ defaultMessage: '!!!Choose', }, }); + +const GradientBox = styled(Box)(({ theme, isSelected }) => ({ + maxWidth: '294px', + maxHeight: '362px', + flex: 1, + display: 'flex', + flexDirection: 'column', + alignItems: 'center', + justifyContent: 'flex-start', + textAlign: 'center', + alignSelf: 'stretch', + padding: '16px', + cursor: isSelected ? 'not-allowed' : 'pointer', + backgroundImage: isSelected ? theme.palette.ds.bg_gradient_2 : 'unset', + outline: `solid 1px ${isSelected ? 'transparent' : theme.palette.ds.gray_200}`, + borderRadius: '8px', + '&:hover': { + backgroundImage: theme.palette.ds.bg_gradient_1, + outlineColor: 'transparent', + '&::before': { + opacity: 1, + }, + }, + '&::before': { + opacity: 0, + transition: 'opacity 300ms linear', + } +})); + type Props = {| +complexityLevel: ?ComplexityLevelType, +onSubmit: ComplexityLevelType => PossiblyAsync, @@ -73,7 +99,7 @@ class ComplexityLevel extends Component { render(): Node { const { intl } = this.context; - const { complexityLevel, isSubmitting, isRevampLayout, baseTheme } = this.props; + const { complexityLevel, isRevampLayout } = this.props; const levels = [ { @@ -91,9 +117,9 @@ class ComplexityLevel extends Component { ]; return ( - + {isRevampLayout && ( - + {intl.formatMessage(settingsMenuMessages.levelOfComplexity)} )} @@ -102,7 +128,7 @@ class ComplexityLevel extends Component { component="div" textAlign="center" variant="body1" - color={isRevampLayout ? 'grayscale.800' : 'var(--yoroi-palette-gray-600)'} + color="ds.text_gray_low" > {intl.formatMessage(messages.subtitle)} @@ -113,10 +139,11 @@ class ComplexityLevel extends Component { variant="body1" my="1rem" mx="auto" + color="ds.text_gray_medium" sx={{ textAlign: 'center', '& strong': { - color: isRevampLayout ? 'primary.500' : 'var(--yoroi-comp-button-secondary-text)', + color: 'ds.text_primary_medium', fontWeight: 500, textTransform: 'uppercase', }, @@ -133,105 +160,33 @@ class ComplexityLevel extends Component { )} - {isRevampLayout ? ( - - {levels.map(level => { + + + {levels.map(level => { const isSelected = level.key === complexityLevel; - return ( - - isSelected - ? baseTheme === 'light-theme' - ? theme.palette.gradients.green - : theme.palette.gradients_2 - : baseTheme === 'light-theme' - ? 'linear-gradient( 0deg, var(--yoroi-palette-common-white), var(--yoroi-palette-common-white)), linear-gradient(180deg, #e4e8f7 0%, #c6f7f7 100%)' - : theme.palette.ds.bg_gradient_3, - backgroundClip: 'content-box, border-box', - backgroundOrigin: 'border-box', - borderRadius: '8px', - alignSelf: 'stretch', - cursor: isSelected ? 'not-allowed' : 'pointer', - position: 'relative', - zIndex: 1, - '&::before': { - position: 'absolute', - content: '""', - top: '0px', - right: '0px', - left: '0px', - bottom: '0px', - background: theme => theme.palette.gradients['blue-green-bg'], - borderRadius: '8px', - zIndex: -1, - opacity: 0, - transition: 'opacity 300ms linear', - }, - '&:hover::before': { - opacity: 1, - }, - }} + isSelected={isSelected} onClick={() => this.props.onSubmit(level.key)} > - - {level.image} - - + + {level.image} + + {level.name} - + {level.description} - + ); - })} + }) + } - ) : ( -
    - {levels.map(level => ( -
    -
    {level.image}
    -
    -
    -

    {level.name}

    -
    {level.description}
    -
    - this.props.onSubmit(level.key)} - > - {intl.formatMessage(messages.labelChoose)} - -
    -
    - ))} -
    - )} +
    ); } diff --git a/packages/yoroi-extension/app/components/profile/complexity-level/ComplexityLevelForm.scss b/packages/yoroi-extension/app/components/profile/complexity-level/ComplexityLevelForm.scss deleted file mode 100644 index 3b563162fe..0000000000 --- a/packages/yoroi-extension/app/components/profile/complexity-level/ComplexityLevelForm.scss +++ /dev/null @@ -1,97 +0,0 @@ -@import '../../../themes/mixins/loading-spinner'; -@import '../../../themes/mixins/error-message'; - -.component { - max-width: 650px; - margin: 0 auto; - margin-top: 24px; - - .header { - color: var(--yoroi-palette-gray-600); - text-align: center; - margin-bottom: 50px; - font-size: 1.125rem; - font-weight: bold; - letter-spacing: 0; - line-height: 1.375rem; - } - - .description { - color: var(--yoroi-palette-gray-600); - font-size: 1rem; - line-height: 1.375rem; - text-align: center; - } - - .cardsWrapper { - margin: 30px auto; - display: flex; - & > div { - flex: 1; - } - } - - .card { - margin-right: 30px; - border-radius: 8px; - background-color: var(--yoroi-palette-common-white); - border: 1px solid #dce0e9; - overflow: hidden; - &:last-child { - margin-right: 0; - } - - .cardImage { - background-color: var(--yoroi-palette-gray-100); - height: 184px; - display: flex; - align-items: center; - justify-content: center; - } - - .simple { - background: #f1fdfa; - } - - .advanced { - background: #f3f5fd; - } - - .cardContent { - padding: 24px; - color: var(--yoroi-palette-gray-900); - display: flex; - flex-direction: column; - justify-content: space-between; - height: 300px; - h3 { - font-size: 1.5rem; - letter-spacing: 0; - line-height: 1.875rem; - text-align: center; - text-transform: capitalize; - margin-bottom: 16px; - } - p { - font-size: 0.75rem; - letter-spacing: 0; - line-height: 1.25rem; - } - } - - .error { - @include error-message; - text-align: center; - margin-bottom: 1rem; - } - } -} - -:global(.YoroiRevamp) .component { - min-width: 650px; - max-width: unset; - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; -} From d62e95e319282503450b0fea37a4b8a353f3d02e Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Fri, 20 Dec 2024 15:01:19 +0300 Subject: [PATCH 61/76] post-merge fixes --- packages/yoroi-extension/app/Routes.js | 2 +- .../connector/containers/SignTxContainer.js | 2 +- .../app/containers/NavBarContainerRevamp.js | 4 ++-- .../categories/GeneralSettingsPage.js | 1 + .../categories/SupportSettingsPage.js | 4 ++-- .../app/containers/transfer/Transfer.js | 2 -- .../containers/transfer/WalletTransferPage.js | 7 ------- .../ChangeWalletPasswordDialogContainer.js | 1 - .../wallet/staking/StakingPageContent.js | 2 +- .../app/stores/toplevel/ProfileStore.js | 2 +- .../app/stores/toplevel/TransactionsStore.js | 20 +++++++++---------- 11 files changed, 18 insertions(+), 29 deletions(-) diff --git a/packages/yoroi-extension/app/Routes.js b/packages/yoroi-extension/app/Routes.js index bfc34adf5e..0f2f5c2df4 100644 --- a/packages/yoroi-extension/app/Routes.js +++ b/packages/yoroi-extension/app/Routes.js @@ -566,7 +566,7 @@ export function wrapPortfolio(portfolioProps: StoresProps, children: Node): Node const currentWalletInfo = createCurrrentWalletInfo(portfolioProps.stores); const openDialogWrapper = (dialog): void => { - portfolioProps.actions.dialogs.open.trigger({ dialog }); + portfolioProps.stores.uiDialogs.open({ dialog }); }; return ( diff --git a/packages/yoroi-extension/app/connector/containers/SignTxContainer.js b/packages/yoroi-extension/app/connector/containers/SignTxContainer.js index 2544fbe348..13361ef835 100644 --- a/packages/yoroi-extension/app/connector/containers/SignTxContainer.js +++ b/packages/yoroi-extension/app/connector/containers/SignTxContainer.js @@ -52,7 +52,7 @@ export default class SignTxContainer extends Component< // will throw a WrongPasswordError if password is wrong await getPrivateStakingKey({ publicDeriverId: deriver.publicDeriverId, password }); } - await this.props.actions.connector.confirmSignInTx.trigger(password); + await this.props.stores.connector.confirmSignInTx(password); window.removeEventListener('beforeunload', this.onUnload); window.removeEventListener('unload', this.onUnload); window.close(); diff --git a/packages/yoroi-extension/app/containers/NavBarContainerRevamp.js b/packages/yoroi-extension/app/containers/NavBarContainerRevamp.js index 915c8da8a2..7a17236689 100644 --- a/packages/yoroi-extension/app/containers/NavBarContainerRevamp.js +++ b/packages/yoroi-extension/app/containers/NavBarContainerRevamp.js @@ -42,8 +42,8 @@ export default class NavBarContainerRevamp extends Component<{| ...StoresProps, }; addNewWallet: void => Promise = async () => { - this.props.actions.dialogs.closeActiveDialog.trigger(); - this.props.actions.router.goToRoute.trigger({ route: ROUTES.WALLETS.ADD }); + this.props.stores.uiDialogs.closeActiveDialog(); + this.props.stores.app.goToRoute({ route: ROUTES.WALLETS.ADD }); await localStorage.unsetPortfolioFiatPair(); }; diff --git a/packages/yoroi-extension/app/containers/settings/categories/GeneralSettingsPage.js b/packages/yoroi-extension/app/containers/settings/categories/GeneralSettingsPage.js index 600af9cfbc..f7c28dcad4 100644 --- a/packages/yoroi-extension/app/containers/settings/categories/GeneralSettingsPage.js +++ b/packages/yoroi-extension/app/containers/settings/categories/GeneralSettingsPage.js @@ -62,6 +62,7 @@ export default class GeneralSettingsPage extends Component { const unitOfAccount = value === 'ADA' ? unitOfAccountDisabledValue : { enabled: true, currency: value }; localStorageApi.unsetPortfolioFiatPair(); await this.props.stores.profile.updateUnitOfAccount(unitOfAccount); + await this.props.stores.transactions.updateUnitOfAccount(); }; render(): Node { diff --git a/packages/yoroi-extension/app/containers/settings/categories/SupportSettingsPage.js b/packages/yoroi-extension/app/containers/settings/categories/SupportSettingsPage.js index 81fa231d49..7b393a6e84 100644 --- a/packages/yoroi-extension/app/containers/settings/categories/SupportSettingsPage.js +++ b/packages/yoroi-extension/app/containers/settings/categories/SupportSettingsPage.js @@ -54,14 +54,14 @@ export default class SupportSettingsPage extends Component { }; render(): Node { - const { actions } = this.props; + const { stores } = this.props; return ( <> {this.getDialog()} actions.router.redirect.trigger({ route: ROUTES.TRANSFER.ROOT })} + onPaperWalletTransfer={() => stores.app.redirect({ route: ROUTES.TRANSFER.ROOT })} /> ); diff --git a/packages/yoroi-extension/app/containers/transfer/Transfer.js b/packages/yoroi-extension/app/containers/transfer/Transfer.js index 93dac12214..796ef72387 100644 --- a/packages/yoroi-extension/app/containers/transfer/Transfer.js +++ b/packages/yoroi-extension/app/containers/transfer/Transfer.js @@ -1,7 +1,6 @@ // @flow import type { Node } from 'react'; import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; -import type { StoresAndActionsProps } from '../../types/injectedProps.types'; import { Component, lazy, Suspense } from 'react'; import { observer } from 'mobx-react'; import { intlShape } from 'react-intl'; @@ -12,7 +11,6 @@ import NoWalletMessage from '../wallet/NoWalletMessage'; import NavBarTitle from '../../components/topbar/NavBarTitle'; import globalMessages from '../../i18n/global-messages'; import NavBarContainerRevamp from '../NavBarContainerRevamp'; -import HorizontalLine from '../../components/widgets/HorizontalLine'; import type { StoresProps } from '../../stores'; export const WalletTransferPagePromise: void => Promise = () => import('./WalletTransferPage'); diff --git a/packages/yoroi-extension/app/containers/transfer/WalletTransferPage.js b/packages/yoroi-extension/app/containers/transfer/WalletTransferPage.js index 2591114cc3..eff299243f 100644 --- a/packages/yoroi-extension/app/containers/transfer/WalletTransferPage.js +++ b/packages/yoroi-extension/app/containers/transfer/WalletTransferPage.js @@ -1,6 +1,5 @@ // @flow import type { Node } from 'react'; -import type { StoresAndActionsProps } from '../../types/injectedProps.types'; import { Component } from 'react'; import { observer } from 'mobx-react'; import { getTokenName } from '../../stores/stateless/tokenHelpers'; @@ -10,14 +9,8 @@ import { intlShape } from 'react-intl'; import TransferTypeSelect from '../../components/transfer/cards/TransferTypeSelect'; import YoroiTransferPage from './YoroiTransferPage'; -import { genLookupOrFail, getTokenName, } from '../../stores/stateless/tokenHelpers'; -import { truncateToken } from '../../utils/formatters'; import type { StoresProps } from '../../stores'; -type Props = {| - publicDeriver: PublicDeriver<>, -|}; - @observer export default class WalletTransferPage extends Component { static contextTypes: {|intl: $npm$ReactIntl$IntlFormat|} = { diff --git a/packages/yoroi-extension/app/containers/wallet/dialogs/ChangeWalletPasswordDialogContainer.js b/packages/yoroi-extension/app/containers/wallet/dialogs/ChangeWalletPasswordDialogContainer.js index 12bbb32e6b..8ee57457b3 100644 --- a/packages/yoroi-extension/app/containers/wallet/dialogs/ChangeWalletPasswordDialogContainer.js +++ b/packages/yoroi-extension/app/containers/wallet/dialogs/ChangeWalletPasswordDialogContainer.js @@ -15,7 +15,6 @@ export default class ChangeWalletPasswordDialogContainer extends Component<{| .. render(): Node { const { stores } = this.props; const { uiDialogs, walletSettings } = stores; - const { updateDataForActiveDialog } = actions.dialogs; const { changeSigningKeyRequest } = walletSettings; return ( diff --git a/packages/yoroi-extension/app/containers/wallet/staking/StakingPageContent.js b/packages/yoroi-extension/app/containers/wallet/staking/StakingPageContent.js index 55769634d7..9512e44579 100644 --- a/packages/yoroi-extension/app/containers/wallet/staking/StakingPageContent.js +++ b/packages/yoroi-extension/app/containers/wallet/staking/StakingPageContent.js @@ -216,7 +216,7 @@ export default class StakingPageContent extends Component { const handleRewardsWithdrawal = async () => { if (!isParticipatingToGovernance) { - this.props.actions.dialogs.open.trigger({ + this.props.stores.uiDialogs.open({ dialog: GovernanceParticipateDialog, }); return; diff --git a/packages/yoroi-extension/app/stores/toplevel/ProfileStore.js b/packages/yoroi-extension/app/stores/toplevel/ProfileStore.js index ec5778215b..e8b100f371 100644 --- a/packages/yoroi-extension/app/stores/toplevel/ProfileStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/ProfileStore.js @@ -29,7 +29,7 @@ export default class ProfileStore extends BaseProfileStore { if (this.stores.app.currentRoute === route) { return; } - this.actions.router.goToRoute.trigger({ route }); + this.stores.app.goToRoute({ route }); }, }; diff --git a/packages/yoroi-extension/app/stores/toplevel/TransactionsStore.js b/packages/yoroi-extension/app/stores/toplevel/TransactionsStore.js index 0c25b136ef..d5c3ad0b43 100644 --- a/packages/yoroi-extension/app/stores/toplevel/TransactionsStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/TransactionsStore.js @@ -73,17 +73,15 @@ export default class TransactionsStore extends Store { @observable exportError: ?LocalizableError; @observable shouldIncludeTxIds: boolean = false; - setup(): void { - this.actions.profile.updateUnitOfAccount.listen(async () => { - const publicDeriver = this.stores.wallets.selected; - if (!publicDeriver) { - return; - } - const timestamps = new Set(this.getTxHistoryState(publicDeriver.publicDeriverId).txs.map( - tx => tx.date.valueOf() - )); - await this._updateTransactionPriceData(publicDeriver, timestamps); - }); + @action updateUnitOfAccount: void => Promise = async () => { + const publicDeriver = this.stores.wallets.selected; + if (!publicDeriver) { + return; + } + const timestamps = new Set(this.getTxHistoryState(publicDeriver.publicDeriverId).txs.map( + tx => tx.date.valueOf() + )); + await this._updateTransactionPriceData(publicDeriver, timestamps); } /** Calculate information about transactions that are still realistically reversible */ From 00ec2e1d0995f32c4a1cfa08550a868506243010 Mon Sep 17 00:00:00 2001 From: Denis Nebytov Date: Fri, 20 Dec 2024 17:19:00 +0300 Subject: [PATCH 62/76] fixed remarks --- .../app/components/transfer/BaseTransferPage.js | 1 - .../app/components/transfer/cards/TransferTypeSelect.js | 6 +++++- packages/yoroi-extension/app/i18n/locales/en-US.json | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/yoroi-extension/app/components/transfer/BaseTransferPage.js b/packages/yoroi-extension/app/components/transfer/BaseTransferPage.js index c3b8e00794..c87f7f6aa7 100644 --- a/packages/yoroi-extension/app/components/transfer/BaseTransferPage.js +++ b/packages/yoroi-extension/app/components/transfer/BaseTransferPage.js @@ -55,7 +55,6 @@ export default class BaseTransferPage extends Component { actions={actions} closeOnOverlayClick={false} onClose={onBack} - className={undefined} backButton={} > diff --git a/packages/yoroi-extension/app/components/transfer/cards/TransferTypeSelect.js b/packages/yoroi-extension/app/components/transfer/cards/TransferTypeSelect.js index 170048e229..7813c07f4d 100644 --- a/packages/yoroi-extension/app/components/transfer/cards/TransferTypeSelect.js +++ b/packages/yoroi-extension/app/components/transfer/cards/TransferTypeSelect.js @@ -23,6 +23,10 @@ const messages = defineMessages({ id: 'wallet.transfer.subInstruction', defaultMessage: '!!!Learn more about Byron and Shelley eras and how to claim ADA on our', }, + faqAbbreviation: { + id: 'settings.support.faq.abbreviation', + defaultMessage: '!!!FAQ', + } }); @observer @@ -39,7 +43,7 @@ export default class TransferTypeSelect extends Component { onClick={event => handleExternalLinkClick(event)} id="settings:support-faq-link" > - FAQ + {intl.formatMessage(messages.faqAbbreviation)} ); diff --git a/packages/yoroi-extension/app/i18n/locales/en-US.json b/packages/yoroi-extension/app/i18n/locales/en-US.json index 501e9d078f..adfa645487 100644 --- a/packages/yoroi-extension/app/i18n/locales/en-US.json +++ b/packages/yoroi-extension/app/i18n/locales/en-US.json @@ -319,6 +319,7 @@ "settings.support.faq.faqLink": "FAQ on Yoroi website", "settings.support.faq.faqLinkURL": "https://yoroi-wallet.com/faq/", "settings.support.faq.title": "Frequently asked questions", + "settings.support.faq.abbreviation": "FAQ", "settings.support.logs.content": "If you want to inspect logs, you can {downloadLogsLink}. Logs do not contain sensitive information, and it would be helpful to attach them to problem reports to help the team investigate the issue you are experiencing.", "settings.support.logs.downloadLogsButtonLabel": "Download Logs", "settings.support.logs.downloadLogsLink": "download them here", From 28174150b2fb4ea9129fa0ce6f92d0347b771b74 Mon Sep 17 00:00:00 2001 From: Juliano Lazzarotto <30806844+stackchain@users.noreply.github.com> Date: Fri, 20 Dec 2024 19:56:40 +0000 Subject: [PATCH 63/76] New translations en-us.json (Hungarian) --- packages/yoroi-extension/app/i18n/locales/hu-HU.json | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/yoroi-extension/app/i18n/locales/hu-HU.json b/packages/yoroi-extension/app/i18n/locales/hu-HU.json index 163f6e5448..d1f3b1b82e 100644 --- a/packages/yoroi-extension/app/i18n/locales/hu-HU.json +++ b/packages/yoroi-extension/app/i18n/locales/hu-HU.json @@ -319,6 +319,7 @@ "settings.support.faq.faqLink": "FAQ on Yoroi website", "settings.support.faq.faqLinkURL": "https://yoroi-wallet.com/faq/", "settings.support.faq.title": "Frequently asked questions", + "settings.support.faq.abbreviation": "FAQ", "settings.support.logs.content": "If you want to inspect logs, you can {downloadLogsLink}. Logs do not contain sensitive information, and it would be helpful to attach them to problem reports to help the team investigate the issue you are experiencing.", "settings.support.logs.downloadLogsButtonLabel": "Download Logs", "settings.support.logs.downloadLogsLink": "download them here", From 8487cbb9fea678c19416443ec3b9dfb44354ee88 Mon Sep 17 00:00:00 2001 From: Juliano Lazzarotto <30806844+stackchain@users.noreply.github.com> Date: Fri, 20 Dec 2024 19:56:41 +0000 Subject: [PATCH 64/76] New translations en-us.json (Vietnamese) --- packages/yoroi-extension/app/i18n/locales/vi-VN.json | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/yoroi-extension/app/i18n/locales/vi-VN.json b/packages/yoroi-extension/app/i18n/locales/vi-VN.json index bc33f8700e..8bd145d6f7 100644 --- a/packages/yoroi-extension/app/i18n/locales/vi-VN.json +++ b/packages/yoroi-extension/app/i18n/locales/vi-VN.json @@ -319,6 +319,7 @@ "settings.support.faq.faqLink": "FAQ trên website Yoroi", "settings.support.faq.faqLinkURL": "https://yoroi-wallet.com/faq/", "settings.support.faq.title": "Các câu hỏi thường gặp", + "settings.support.faq.abbreviation": "FAQ", "settings.support.logs.content": "Nếu muốn kiểm tra nhật ký, bạn có thể {downloadLogsLink}. Nhật ký không chứa thông tin nhạy cảm và sẽ rất hữu ích nếu đính kèm chúng vào các báo cáo sự cố để giúp nhóm điều tra sự cố bạn đang gặp phải.", "settings.support.logs.downloadLogsButtonLabel": "Tải Logs", "settings.support.logs.downloadLogsLink": "tải giao diện ở đây", From 16f8fa32f382dbd73b6612f072d8205a985a8234 Mon Sep 17 00:00:00 2001 From: Juliano Lazzarotto <30806844+stackchain@users.noreply.github.com> Date: Sat, 21 Dec 2024 12:50:59 +0000 Subject: [PATCH 65/76] New translations en-us.md (ru-RU) --- .../app/i18n/locales/terms-of-use/ada/ru-RU.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/yoroi-extension/app/i18n/locales/terms-of-use/ada/ru-RU.md b/packages/yoroi-extension/app/i18n/locales/terms-of-use/ada/ru-RU.md index 1bcbe9b596..ca73617bce 100644 --- a/packages/yoroi-extension/app/i18n/locales/terms-of-use/ada/ru-RU.md +++ b/packages/yoroi-extension/app/i18n/locales/terms-of-use/ada/ru-RU.md @@ -66,12 +66,12 @@ **e. Язык.** Любой перевод настоящего Соглашения предназначен только в целях местных ссылок, и в случае возникновения каких-либо несоответствий между английской и любыми не английскими версиями, английская версия настоящего Соглашения имеет преимущественную силу и регулирует во всех отношениях. -## 12. Delegation and Staking +## 12. Делегирование и Стейкинг -12.1 **Rewards.** The amount of Rewards a User may earn from delegation depends on various factors including, but not limited to, user participation, stakepool profit margins and the volume of ada being delegated. It is possible that delegation generates no Reward for a User due to the above-mentioned factors. Rewards are earned as of the start of the 3rd epoch on the Cardano blockchain. +12.1 **Вознаграждения.** Размер вознаграждения, которое Пользователь может получить за делегирование, зависит от различных факторов, включая, но не ограничиваясь этим, участие пользователя, размер прибыли в пуле ставок и объем делегируемого ada. Возможно, что делегирование не приносит вознаграждения Пользователю из-за вышеупомянутых факторов. Вознаграждения начисляются с начала 3-й эпохи в блокчейне Cardano. -12.2 **Delegation.** Users may delegate their stake to one of the various stake pools of the Company or to a third party stake pool. User will have the sole right to determine the volume to be delegated to a stake pool and may increase or decrease its level of participation at any time. Any information Company shares regarding stakepools, including performance metrics and Rewards, will be for indicative purposes only and may not be accurate. Users may only delegate their stake to a stake pool if their ada is in an updated Daedalus or an updated Yoroi wallet at the time of the setup process. User does not acquire any automatic right to Rewards as a result of delegating its stake. +12.2 **Делегирование.** Пользователи могут делегировать свои ставки одному из различных пулов ставок Компании или стороннему пулу ставок. Пользователь будет иметь исключительное право определять объем средств, которые будут делегированы в пул ставок, и может в любое время увеличить или уменьшить уровень своего участия. Любая информация, предоставляемая Компанией в отношении пулов ставок, включая показатели эффективности и вознаграждения, предназначена только для ознакомительных целей и может быть неточной. Пользователи могут делегировать свою ставку в пул ставок только в том случае, если на момент настройки их ada находится в обновленном Daedalus или в обновленном кошельке Yoroi. Пользователь не получает никаких автоматических прав на получение вознаграждений в результате делегирования своей ставки. -12.3 **Company Stake-Pools.** The Company will operate various stake pools which will be visible in Yoroi. The cost and network and server requirements to reliably operate such stake pools shall be determined by the Company in its sole discretion. Company will communicate the percentage amount of Reward to be shared with Users through the User’s Yoroi wallet. Rewards will accrue at the end of each epoch and will automatically appear in the User’s Yoroi wallet. +12.3 **Пулы ставок Компании.** Компания будет использовать различные пулы ставок, которые будут отображаться в Yoroi. Стоимость, а также требования к сети и серверу для надежной работы таких пулов ставок определяются Компанией по ее собственному усмотрению. Компания сообщит процентную сумму вознаграждения, которая будет распределена между Пользователями через кошелек Пользователя Yoroi. Вознаграждения будут начисляться в конце каждой эпохи и автоматически отображаться в кошельке Пользователя Yoroi. -12.4 **Redeeming Rewards.** User shall be responsible for payment of all applicable taxes, if any, to which the Rewards might be subject and any and all other taxes which may apply to User once Rewards are redeemed. +12.4 **Погашение вознаграждений.** Пользователь несет ответственность за уплату всех применимых налогов, если таковые имеются, которыми могут облагаться Вознаграждения, и любых других налогов, которые могут взиматься с Пользователя после погашения Вознаграждений. From f73415ed51ef6995b47b71dabb6f2995da7fce02 Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Mon, 23 Dec 2024 13:51:43 +0300 Subject: [PATCH 66/76] post-merge fixes --- .../profile/complexity-level/ComplexityLevelForm.js | 11 ++++++++--- .../components/wallet/hwConnect/trezor/CheckDialog.js | 1 - 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/yoroi-extension/app/components/profile/complexity-level/ComplexityLevelForm.js b/packages/yoroi-extension/app/components/profile/complexity-level/ComplexityLevelForm.js index 2f9e5f217e..e767594eb3 100644 --- a/packages/yoroi-extension/app/components/profile/complexity-level/ComplexityLevelForm.js +++ b/packages/yoroi-extension/app/components/profile/complexity-level/ComplexityLevelForm.js @@ -3,7 +3,6 @@ import { Component } from 'react'; import type { Node } from 'react'; import { intlShape, defineMessages, FormattedHTMLMessage } from 'react-intl'; import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; -import styles from './ComplexityLevelForm.scss'; import { ReactComponent as BeginnerLevel } from '../../../assets/images/complexity-level/beginner-level.inline.svg'; import { ReactComponent as AdvancedLevel } from '../../../assets/images/complexity-level/advanced-level.inline.svg'; import LocalizableError from '../../../i18n/LocalizableError'; @@ -115,8 +114,14 @@ export default class ComplexityLevel extends Component { return ( - + {intl.formatMessage(settingsMenuMessages.levelOfComplexity)} diff --git a/packages/yoroi-extension/app/components/wallet/hwConnect/trezor/CheckDialog.js b/packages/yoroi-extension/app/components/wallet/hwConnect/trezor/CheckDialog.js index b84559a6f0..ed63617507 100644 --- a/packages/yoroi-extension/app/components/wallet/hwConnect/trezor/CheckDialog.js +++ b/packages/yoroi-extension/app/components/wallet/hwConnect/trezor/CheckDialog.js @@ -18,7 +18,6 @@ import HWErrorBlock from '../common/HWErrorBlock'; import { ReactComponent as ExternalLinkSVG } from '../../../../assets/images/link-external.inline.svg'; import { ReactComponent as AboutPrerequisiteIconSVG } from '../../../../assets/images/hardware-wallet/check-prerequisite-header-icon.inline.svg'; -import { ReactComponent as AboutPrerequisiteTrezorSVG } from '../../../../assets/images/hardware-wallet/trezor/check.inline.svg'; import { ReactComponent as AboutTrezorSvg } from '../../../../assets/images/hardware-wallet/trezor/check-modern.inline.svg'; import { ProgressInfo } from '../../../../types/HWConnectStoreTypes'; From 1dfb24a0be0102e607d5946aec786c00a46edfcd Mon Sep 17 00:00:00 2001 From: Denis Nebytov Date: Wed, 25 Dec 2024 18:25:19 +0300 Subject: [PATCH 67/76] fixed hiding balance --- .../app/containers/NavBarContainerRevamp.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/yoroi-extension/app/containers/NavBarContainerRevamp.js b/packages/yoroi-extension/app/containers/NavBarContainerRevamp.js index 7a17236689..49c8cd1f76 100644 --- a/packages/yoroi-extension/app/containers/NavBarContainerRevamp.js +++ b/packages/yoroi-extension/app/containers/NavBarContainerRevamp.js @@ -37,6 +37,10 @@ export default class NavBarContainerRevamp extends Component<{| ...StoresProps, menu: undefined, }; + isBalanceHidden: void => boolean = () => { + return this.props.stores.profile.shouldHideBalance; + }; + updateHideBalance: void => Promise = async () => { await this.props.stores.profile.updateHideBalance(); }; @@ -72,6 +76,7 @@ export default class NavBarContainerRevamp extends Component<{| ...StoresProps, const { stores, pageBanner, isErrorPage } = this.props; const { profile, wallets } = stores; const { selected, selectedWalletName } = wallets; + const shouldHideBalance = this.isBalanceHidden(); const DropdownHead = () => { if (!selected || !selectedWalletName) { @@ -86,7 +91,7 @@ export default class NavBarContainerRevamp extends Component<{| ...StoresProps, plate={plate} name={selectedWalletName} onUpdateHideBalance={this.updateHideBalance} - shouldHideBalance={profile.shouldHideBalance} + shouldHideBalance={shouldHideBalance} rewards={rewards} walletAmount={selected.balance} getTokenInfo={genLookupOrFail(this.props.stores.tokenInfoStore.tokenInfo)} @@ -156,7 +161,7 @@ export default class NavBarContainerRevamp extends Component<{| ...StoresProps, this.checkAndResetGovRoutes(); this.props.stores.uiDialogs.closeActiveDialog(); }} - shouldHideBalance={stores.profile.shouldHideBalance} + shouldHideBalance={this.isBalanceHidden()} onUpdateHideBalance={this.updateHideBalance} getTokenInfo={getTokenInfo} walletAmount={selected?.balance} From 5227b99b96a732e6316ff41c36852e19a80c7449 Mon Sep 17 00:00:00 2001 From: Denis Nebytov Date: Wed, 25 Dec 2024 18:34:48 +0300 Subject: [PATCH 68/76] one more update --- .../yoroi-extension/app/containers/NavBarContainerRevamp.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/yoroi-extension/app/containers/NavBarContainerRevamp.js b/packages/yoroi-extension/app/containers/NavBarContainerRevamp.js index 49c8cd1f76..ee420383b0 100644 --- a/packages/yoroi-extension/app/containers/NavBarContainerRevamp.js +++ b/packages/yoroi-extension/app/containers/NavBarContainerRevamp.js @@ -128,6 +128,7 @@ export default class NavBarContainerRevamp extends Component<{| ...StoresProps, const { stores } = this.props; const { selected, wallets } = stores.wallets; const getTokenInfo = genLookupOrFail(stores.tokenInfoStore.tokenInfo); + const shouldHideBalance = this.isBalanceHidden(); if (stores.uiDialogs.isOpen(WalletListDialog)) { const cardanoWallets = []; @@ -161,7 +162,7 @@ export default class NavBarContainerRevamp extends Component<{| ...StoresProps, this.checkAndResetGovRoutes(); this.props.stores.uiDialogs.closeActiveDialog(); }} - shouldHideBalance={this.isBalanceHidden()} + shouldHideBalance={shouldHideBalance} onUpdateHideBalance={this.updateHideBalance} getTokenInfo={getTokenInfo} walletAmount={selected?.balance} From c5f2c2aecf43fbcba529998bf43c25efd602c1c1 Mon Sep 17 00:00:00 2001 From: Denis Nebytov Date: Wed, 25 Dec 2024 18:57:57 +0300 Subject: [PATCH 69/76] simplified --- .../app/containers/NavBarContainerRevamp.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/yoroi-extension/app/containers/NavBarContainerRevamp.js b/packages/yoroi-extension/app/containers/NavBarContainerRevamp.js index ee420383b0..1620e603bc 100644 --- a/packages/yoroi-extension/app/containers/NavBarContainerRevamp.js +++ b/packages/yoroi-extension/app/containers/NavBarContainerRevamp.js @@ -37,10 +37,6 @@ export default class NavBarContainerRevamp extends Component<{| ...StoresProps, menu: undefined, }; - isBalanceHidden: void => boolean = () => { - return this.props.stores.profile.shouldHideBalance; - }; - updateHideBalance: void => Promise = async () => { await this.props.stores.profile.updateHideBalance(); }; @@ -76,7 +72,7 @@ export default class NavBarContainerRevamp extends Component<{| ...StoresProps, const { stores, pageBanner, isErrorPage } = this.props; const { profile, wallets } = stores; const { selected, selectedWalletName } = wallets; - const shouldHideBalance = this.isBalanceHidden(); + const shouldHideBalance = profile.shouldHideBalance; const DropdownHead = () => { if (!selected || !selectedWalletName) { @@ -128,7 +124,7 @@ export default class NavBarContainerRevamp extends Component<{| ...StoresProps, const { stores } = this.props; const { selected, wallets } = stores.wallets; const getTokenInfo = genLookupOrFail(stores.tokenInfoStore.tokenInfo); - const shouldHideBalance = this.isBalanceHidden(); + const shouldHideBalance = stores.profile.shouldHideBalance; if (stores.uiDialogs.isOpen(WalletListDialog)) { const cardanoWallets = []; From 769d5d39bc7a71b069b8c516189ecea80c15e270 Mon Sep 17 00:00:00 2001 From: Denis Nebytov Date: Thu, 26 Dec 2024 12:06:59 +0300 Subject: [PATCH 70/76] move test from the blacklist --- .../25_hideShowBalance.test.js | 27 +++++++------------ 1 file changed, 10 insertions(+), 17 deletions(-) rename packages/e2e-tests/test/{blacklist => }/25_hideShowBalance.test.js (81%) diff --git a/packages/e2e-tests/test/blacklist/25_hideShowBalance.test.js b/packages/e2e-tests/test/25_hideShowBalance.test.js similarity index 81% rename from packages/e2e-tests/test/blacklist/25_hideShowBalance.test.js rename to packages/e2e-tests/test/25_hideShowBalance.test.js index f30f069055..17f981fb37 100644 --- a/packages/e2e-tests/test/blacklist/25_hideShowBalance.test.js +++ b/packages/e2e-tests/test/25_hideShowBalance.test.js @@ -1,23 +1,22 @@ -import BasePage from '../../pages/basepage.js'; -import { customAfterEach } from '../../utils/customHooks.js'; -import TransactionsSubTab from '../../pages/wallet/walletTab/walletTransactions.page.js'; -import ReceiveSubTab from '../../pages/wallet/walletTab/receiveSubTab.page.js'; +import BasePage from '../pages/basepage.js'; +import { customAfterEach } from '../utils/customHooks.js'; +import TransactionsSubTab from '../pages/wallet/walletTab/walletTransactions.page.js'; +import ReceiveSubTab from '../pages/wallet/walletTab/receiveSubTab.page.js'; import { expect } from 'chai'; -import { getTestLogger } from '../../utils/utils.js'; -import { oneMinute } from '../../helpers/timeConstants.js'; -import driversPoolsManager from '../../utils/driversPool.js'; -import { prepareWallet } from '../../helpers/restoreWalletHelper.js'; -import { testWallet1 } from '../../utils/testWallets.js'; +import { getTestLogger } from '../utils/utils.js'; +import { oneMinute } from '../helpers/timeConstants.js'; +import driversPoolsManager from '../utils/driversPool.js'; +import { prepareWallet } from '../helpers/restoreWalletHelper.js'; +import { testWallet1 } from '../utils/testWallets.js'; -// Issue https://emurgo.atlassian.net/browse/YOEXT-1218 describe('Hide and show balance', function () { this.timeout(2 * oneMinute); let webdriver = null; let logger = null; before(async function () { - webdriver = await driversPoolsManager.getDriverFromPool(); logger = getTestLogger(this.test.parent.title); + webdriver = await driversPoolsManager.getDriverFromPool(); await prepareWallet(webdriver, logger, 'testWallet1', this); }); // check the default state. The balance should be displayed @@ -57,9 +56,6 @@ describe('Hide and show balance', function () { await receivePage.selectBaseExtHasBalanceAddrs(); const balanceExtAddrHidden = await receivePage.allAddressesBalancesHidden(); expect(balanceExtAddrHidden, 'Balances of external addresses are not hidden').to.be.true; - await receivePage.selectBaseInterHasBalanceAddrs(); - const balanceInterAddrHidden = await receivePage.allAddressesBalancesHidden(); - expect(balanceInterAddrHidden, 'Balances of internal addresses are not hidden').to.be.true; }); // add checking Staking page when testnetwork is added // click show balance @@ -96,9 +92,6 @@ describe('Hide and show balance', function () { await receivePage.selectBaseExtHasBalanceAddrs(); const balanceExtAddrHidden = await receivePage.allAddressesBalancesHidden(); expect(balanceExtAddrHidden, 'Balances of external addresses are hidden').to.be.false; - await receivePage.selectBaseInterHasBalanceAddrs(); - const balanceInterAddrHidden = await receivePage.allAddressesBalancesHidden(); - expect(balanceInterAddrHidden, 'Balances of internal addresses are hidden').to.be.false; }); // add checking Staking page when testnetwork is added From 9a733e134fd4929fb6c13d833ab71b9567de2c9b Mon Sep 17 00:00:00 2001 From: Denis Nebytov Date: Thu, 26 Dec 2024 12:07:18 +0300 Subject: [PATCH 71/76] added missed id --- .../app/components/topbar/NavWalletDetailsRevamp.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/yoroi-extension/app/components/topbar/NavWalletDetailsRevamp.js b/packages/yoroi-extension/app/components/topbar/NavWalletDetailsRevamp.js index 3ba5bda8c4..de2884bad5 100644 --- a/packages/yoroi-extension/app/components/topbar/NavWalletDetailsRevamp.js +++ b/packages/yoroi-extension/app/components/topbar/NavWalletDetailsRevamp.js @@ -157,6 +157,7 @@ export default class NavWalletDetailsRevamp extends Component { backgroundColor: 'ds.primary_500', }} color="primary" + id={amountDisplayId + "-showHideBalance-button"} > {shouldHideBalance ? ( From d80012ae83d76d15534598981c1f4e9651efbc6d Mon Sep 17 00:00:00 2001 From: Denis Nebytov Date: Thu, 26 Dec 2024 12:07:29 +0300 Subject: [PATCH 72/76] minor fix --- packages/e2e-tests/pages/walletCommonBase.page.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/e2e-tests/pages/walletCommonBase.page.js b/packages/e2e-tests/pages/walletCommonBase.page.js index 1f5b050724..a0d40746b1 100644 --- a/packages/e2e-tests/pages/walletCommonBase.page.js +++ b/packages/e2e-tests/pages/walletCommonBase.page.js @@ -326,7 +326,7 @@ class WalletCommonBase extends BasePage { this.walletBalanceTextLocator, async () => { const rawBalanceText = await this.getText(this.walletBalanceTextLocator); - const balanceStr = rawBalanceText.split(' ')[0]; + const balanceStr = rawBalanceText.split(' ')[0].trim(); return balanceStr === balanceReplacer; } ); @@ -335,7 +335,7 @@ class WalletCommonBase extends BasePage { this.walletFiatBalanceTextLocator, async () => { const rawFiatBalanceText = await this.getText(this.walletFiatBalanceTextLocator); - const fiatBalanceStr = rawFiatBalanceText.split(' ')[0]; + const fiatBalanceStr = rawFiatBalanceText.split(' ')[0].trim(); return fiatBalanceStr === balanceReplacer; } ); From 97a3ba187ed0f57b886bbe581614009e6d0c91fc Mon Sep 17 00:00:00 2001 From: Denis Nebytov Date: Thu, 26 Dec 2024 12:33:44 +0300 Subject: [PATCH 73/76] lint fix --- .../app/components/topbar/NavWalletDetailsRevamp.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/yoroi-extension/app/components/topbar/NavWalletDetailsRevamp.js b/packages/yoroi-extension/app/components/topbar/NavWalletDetailsRevamp.js index de2884bad5..7ac7c7bbbe 100644 --- a/packages/yoroi-extension/app/components/topbar/NavWalletDetailsRevamp.js +++ b/packages/yoroi-extension/app/components/topbar/NavWalletDetailsRevamp.js @@ -157,7 +157,7 @@ export default class NavWalletDetailsRevamp extends Component { backgroundColor: 'ds.primary_500', }} color="primary" - id={amountDisplayId + "-showHideBalance-button"} + id={amountDisplayId + '-showHideBalance-button'} > {shouldHideBalance ? ( From be995e5028e5fbd9daee4ee2bfbae8f0d8484f13 Mon Sep 17 00:00:00 2001 From: Denis Nebytov Date: Fri, 27 Dec 2024 20:01:32 +0300 Subject: [PATCH 74/76] new box shadow --- .../app/styles/themes/base-palettes/dark-palette.js | 3 ++- .../app/styles/themes/base-palettes/light-palette.js | 3 ++- packages/yoroi-extension/app/styles/themes/types.js | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/yoroi-extension/app/styles/themes/base-palettes/dark-palette.js b/packages/yoroi-extension/app/styles/themes/base-palettes/dark-palette.js index 48cace5cf1..b2def5b1e9 100644 --- a/packages/yoroi-extension/app/styles/themes/base-palettes/dark-palette.js +++ b/packages/yoroi-extension/app/styles/themes/base-palettes/dark-palette.js @@ -57,5 +57,6 @@ export const darkPalette = { bg_gradient_3: 'linear-gradient(23deg, #2E4BB0 15.04%, #2B3E7D 84.96%)', special_web_overlay: 'rgba(31, 35, 46, 0.80)', special_web_bg_sidebar: 'rgba(0, 0, 0, 0.16)', - light_shadow_dropdown_menu: `0px 4px 20px 0px #0000007A`, // dropdown shadow + light_shadow_dropdown_words: `0px 3px 10px rgba(24, 26, 30, 0.08)`, // dropdown shadow + light_shadow_dropdown_menu: `0px 4px 10px rgba(24, 26, 30, 0.16)`, }; diff --git a/packages/yoroi-extension/app/styles/themes/base-palettes/light-palette.js b/packages/yoroi-extension/app/styles/themes/base-palettes/light-palette.js index fa1374a815..894748f412 100644 --- a/packages/yoroi-extension/app/styles/themes/base-palettes/light-palette.js +++ b/packages/yoroi-extension/app/styles/themes/base-palettes/light-palette.js @@ -56,5 +56,6 @@ export const lightPalette = { bg_gradient_3: 'linear-gradient(30deg, #244ABF 0%, #4760FF 100%)', special_web_overlay: 'rgba(31, 35, 46, 0.80)', special_web_bg_sidebar: '#1F232ECC', - light_shadow_dropdown_menu: '0px 4px 10px 0px #181A1E29', + light_shadow_dropdown_words: `0px 3px 10px rgba(24, 26, 30, 0.08)`, + light_shadow_dropdown_menu: `0px 4px 10px rgba(24, 26, 30, 0.16)`, }; diff --git a/packages/yoroi-extension/app/styles/themes/types.js b/packages/yoroi-extension/app/styles/themes/types.js index 25cface58e..89f6167123 100644 --- a/packages/yoroi-extension/app/styles/themes/types.js +++ b/packages/yoroi-extension/app/styles/themes/types.js @@ -77,5 +77,6 @@ export type DSColorPalette = {| web_sidebar_item_active_bg: string, mobile_overlay: string, mobile_bg_blur: string, + light_shadow_dropdown_words: string, light_shadow_dropdown_menu: string, |}; From cc007a167c49b0605196c4cbde32788d76ccb02d Mon Sep 17 00:00:00 2001 From: Denis Nebytov Date: Fri, 27 Dec 2024 21:15:28 +0300 Subject: [PATCH 75/76] changed box shadow on Select component --- .../yoroi-extension/app/components/common/Select.js | 12 +++++++++--- .../general-setting/UnitOfAccountSettings.js | 8 +------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/yoroi-extension/app/components/common/Select.js b/packages/yoroi-extension/app/components/common/Select.js index 80514183af..2b66d41df0 100644 --- a/packages/yoroi-extension/app/components/common/Select.js +++ b/packages/yoroi-extension/app/components/common/Select.js @@ -16,6 +16,7 @@ type Props = {| labelProps?: Object, helperText?: string, options: Array, + maxHeight?: string, |}; function Select({ @@ -28,6 +29,7 @@ function Select({ shrink, disabled, labelProps, + maxHeight, ...props }: Props): Node { const theme = useTheme(); @@ -53,9 +55,6 @@ function Select({ onChange={e => onChange(e.target.value)} onClose={handleClose} onOpen={handleOpen} - sx={{ - boxShadow: open ? theme.palette.ds.light_shadow_dropdown_menu : 'unset', - }} MenuProps={{ anchorOrigin: { vertical: 'bottom', @@ -65,6 +64,13 @@ function Select({ vertical: 'top', horizontal: 'left', }, + sx: { + '& .MuiMenu-paper': { + maxHeight: maxHeight != null ? maxHeight : '500px', + borderRadius: '8px', + boxShadow: open ? theme.palette.ds.light_shadow_dropdown_menu : 'unset', + }, + }, ...(menuProps !== null && menuProps), }} {...props} diff --git a/packages/yoroi-extension/app/components/settings/categories/general-setting/UnitOfAccountSettings.js b/packages/yoroi-extension/app/components/settings/categories/general-setting/UnitOfAccountSettings.js index 89bb9aa2b2..19911a71bc 100644 --- a/packages/yoroi-extension/app/components/settings/categories/general-setting/UnitOfAccountSettings.js +++ b/packages/yoroi-extension/app/components/settings/categories/general-setting/UnitOfAccountSettings.js @@ -169,13 +169,7 @@ export default class UnitOfAccountSettings extends Component { {...coinPriceCurrencyId.bind()} onChange={this.props.onSelect} value={currentValue} - menuProps={{ - sx: { - '& .MuiMenu-paper': { - maxHeight: '280px', - }, - }, - }} + maxHeight='280px' renderValue={value => ( Date: Fri, 27 Dec 2024 21:29:31 +0300 Subject: [PATCH 76/76] applied different shadow on autoselect --- .../app/components/common/autocomplete/Autocomplete.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/yoroi-extension/app/components/common/autocomplete/Autocomplete.js b/packages/yoroi-extension/app/components/common/autocomplete/Autocomplete.js index f3bb9c9089..04f1203539 100644 --- a/packages/yoroi-extension/app/components/common/autocomplete/Autocomplete.js +++ b/packages/yoroi-extension/app/components/common/autocomplete/Autocomplete.js @@ -246,7 +246,7 @@ const ULList = styled(Box)(({ theme, isOpen }) => ({ outline: '0', transition: 'opacity .1s ease', borderRadius: 0, - boxShadow: isOpen ? theme.palette.ds.light_shadow_dropdown_menu : 'unset', + boxShadow: isOpen ? theme.palette.ds.light_shadow_dropdown_words : 'unset', })); const InputWrapper = styled(Box)(