Skip to content

Commit

Permalink
refactor: popup module (#4925)
Browse files Browse the repository at this point in the history
* chore: refactor `popup` module

* chore: update docs

* empty

Co-authored-by: MarkNerdi <105642810+MarkNerdi@users.noreply.github.com>
  • Loading branch information
maxwellmattryan and MarkNerdi996 committed Oct 19, 2022
1 parent 5abe868 commit 5419f55
Show file tree
Hide file tree
Showing 91 changed files with 205 additions and 176 deletions.
34 changes: 20 additions & 14 deletions docs/specifications/modules.md
Expand Up @@ -12,20 +12,23 @@ Core modules contain the baseline logic and functionality to build and run the a

### Modules

- `account`: Manages the accounts of a profile
- `app`: Application configuration, setup, settings, etc.
- `error`: Generic code for building domain-specific errors
- `i18n`: Logic related to internationalization, languages, locales, etc.
- `network`: Client options and node configuration, protocol settings, etc.
- `nft`: Managing NFTs, e.g. claiming, burning, transferring
- `profile`: General application logic to support profiles
- `profile-manager`: Library-related logic for managing and interacting with profiles
- `router`: Manage application views and flows
- `token`: Deals with tokens, metadata, conversion rates, registry, etc.
- `utils`: Useful and generic functions, e.g. formatting strings, converting units
- `account` - Manages the accounts of a profile
- `app` - Application configuration, setup, settings, etc.
- `error` - Generic code for building domain-specific errors
- `i18n` - Logic related to internationalization, languages, locales, etc.
- `ledger` - Code related to Ledger Nano profiles and devices
- `network` - Client options and node configuration, protocol settings, etc.
- `nft` - Managing NFTs, e.g. claiming, burning, transferring
- `profile` - General application logic to support profiles
- `profile-manager` - Library-related logic for managing and interacting with profiles
- `router` - Manage application views and flows
- `stronghold` - Code for Stronghold operations, utils, constants, etc. for software profiles
- `token` - Deals with tokens, metadata, conversion rates, registry, etc.
- `utils` - Useful and generic functions, e.g. formatting strings, converting units

### Rules

- **MAY** import code from other core modules
- **MAY NOT** import code from context or auxiliary modules

## Contexts
Expand All @@ -35,15 +38,17 @@ Context modules contain the logic specific to an area of the application.
### Modules

- `collectibles` - managing or viewing an account's NFTs
- `developer` - using developer tools to make lives easier
- `onboarding` - creating or restoring a profile or initial app setup
- `settings` - changing configuration of the app, profile, network, etc.
- `staking` - staking tokens to receive more tokens
- `voting` - using tokens to cast votes for community proposals
- `wallet` - sending or receiving coins and tokens
- `governance` - using tokens to cast votes for community proposals
- `wallet` - sending or receiving coins and tokens, i.e. asset management

### Rules

_None_
- **MAY** import code from core and auxiliary modules
- **SHOULD NOT** import code from other context modules

## Auxiliary

Expand All @@ -59,3 +64,4 @@ Auxiliary modules are non-essential pieces of code that help support the applica
### Rules

- **MAY NOT** import code from context modules
- **SHOULD NOT** import code from other auxiliary modules
2 changes: 1 addition & 1 deletion packages/desktop/App.svelte
Expand Up @@ -16,7 +16,7 @@
import { Electron } from '@lib/electron'
import { addError } from '@core/error'
import { showAppNotification } from '@lib/notifications'
import { openPopup, popupState } from '@lib/popup'
import { openPopup, popupState } from '@auxiliary/popup'
import { Dashboard, LoginRouter, OnboardingRouter, Settings, Splash } from 'shared/routes'
import { onDestroy, onMount } from 'svelte'
import { getLocalisedMenuItems } from './lib/helpers'
Expand Down
2 changes: 1 addition & 1 deletion packages/mobile/App.svelte
Expand Up @@ -27,7 +27,7 @@
import { Electron } from 'shared/lib/electron'
import { addError } from '@core/error'
import { showAppNotification } from 'shared/lib/notifications'
import { openPopup } from 'shared/lib/popup'
import { openPopup } from '@auxiliary/popup'
import { DashboardRouter, LoginRouter, OnboardingRouter } from './routes'
import { onDestroy, onMount } from 'svelte'
import { get } from 'svelte/store'
Expand Down
2 changes: 1 addition & 1 deletion packages/mobile/routes/login/views/EnterPinView.svelte
Expand Up @@ -5,7 +5,7 @@
import { activeProfile, login, resetActiveProfile } from '@core/profile'
import { loginRouter } from '../../../lib/core/router'
import { Platform } from '@lib/platform'
import { openPopup, popupState } from '@lib/popup'
import { openPopup, popupState } from '@auxiliary/popup'
import { validatePinFormat } from '@lib/utils'
import { Icon, PinInput, Profile, Text, TextType } from 'shared/components'
import { onDestroy } from 'svelte'
Expand Down
4 changes: 2 additions & 2 deletions packages/mobile/routes/login/views/SelectProfileView.svelte
Expand Up @@ -11,7 +11,7 @@
shouldBeDeveloperProfile,
updateOnboardingProfile,
} from '@contexts/onboarding'
import { openPopup } from '@lib/popup'
import { openPopup } from '@auxiliary/popup'
$: dark = $appSettings.darkMode
Expand Down Expand Up @@ -59,7 +59,7 @@
</section>
<footer class="w-full pt-5">
<Button
classes="w-full text-blue-500 border border-solid
classes="w-full text-blue-500 border border-solid
{dark ? 'border-gray-700' : 'border-gray-300'}"
variant="none"
onClick={onAddProfileClick}
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/components/TitleBar.svelte
Expand Up @@ -3,7 +3,7 @@
import { activeProfile } from '@core/profile'
import { appSettings, PlatformOption, platform } from '@core/app'
import { Platform } from 'shared/lib/platform'
import { popupState } from 'shared/lib/popup'
import { popupState } from '@auxiliary/popup'
import tailwindConfig from 'shared/tailwind.config.js'
import { onDestroy, onMount } from 'svelte'
import resolveConfig from 'tailwindcss/resolveConfig'
Expand Down
@@ -1,6 +1,6 @@
<script lang="typescript">
import { localize } from '@core/i18n'
import { openPopup } from '@lib/popup'
import { openPopup } from '@auxiliary/popup'
import { OnboardingButton } from 'shared/components'
function handleCreateAlias(): void {
Expand Down
Expand Up @@ -2,7 +2,7 @@
import { exportStronghold } from '@contexts/settings'
import { localize } from '@core/i18n'
import { showAppNotification } from '@lib/notifications'
import { openPopup } from '@lib/popup'
import { openPopup } from '@auxiliary/popup'
import { Button, ButtonSize } from 'shared/components'
export let isBusy = false
Expand Down
@@ -1,7 +1,7 @@
<script lang="typescript">
import { localize } from '@core/i18n'
import { FAUCET_URLS, nodeInfo } from '@core/network'
import { openPopup } from '@lib/popup'
import { openPopup } from '@auxiliary/popup'
import { OnboardingButton } from 'shared/components'
import { activeProfile } from '@core/profile'
Expand Down
@@ -1,6 +1,6 @@
<script lang="typescript">
import { localize } from '@core/i18n'
import { closePopup, openPopup } from '@lib/popup'
import { closePopup, openPopup } from '@auxiliary/popup'
import { OnboardingButton } from 'shared/components'
import { selectedAccount } from '@core/account'
Expand Down
@@ -1,6 +1,6 @@
<script lang="typescript">
import { localize } from '@core/i18n'
import { openPopup } from '@lib/popup'
import { openPopup } from '@auxiliary/popup'
function handleReceiveClick(): void {
openPopup({
Expand Down
Expand Up @@ -2,7 +2,7 @@
import { localize } from '@core/i18n'
import { refreshAccountAssetsForActiveProfile } from '@core/wallet'
import { showAppNotification } from '@lib/notifications'
import { closePopup, openPopup } from '@lib/popup'
import { closePopup, openPopup } from '@auxiliary/popup'
import { OnboardingButton } from 'shared/components'
function refreshTokenMetadata(): void {
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/components/atoms/buttons/SendButton.svelte
Expand Up @@ -2,7 +2,7 @@
import { localize } from '@core/i18n'
import { resetLedgerPreparedOutput, resetShowInternalVerificationPopup } from '@core/ledger'
import { resetNewTransactionDetails, selectedSendOptionIndex } from '@core/wallet'
import { openPopup } from '@lib/popup'
import { openPopup } from '@auxiliary/popup'
import { appSettings } from '@core/app'
import { Text, FontWeight, TextType, Icon, Modal } from 'shared/components'
import { Icon as IconEnum } from '@auxiliary/icon'
Expand Down
@@ -1,6 +1,6 @@
<script lang="typescript">
import { localize } from '@core/i18n'
import { openPopup } from '@lib/popup'
import { openPopup } from '@auxiliary/popup'
import { OnboardingButton } from 'shared/components'
function handleClick(): void {
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/components/atoms/tiles/ActivityTile.svelte
Expand Up @@ -9,7 +9,7 @@
NotVerifiedStatus,
ActivityAsyncStatus,
} from '@core/wallet'
import { openPopup } from '@lib/popup'
import { openPopup } from '@auxiliary/popup'
import {
ClickableTile,
TransactionActivityTileContent,
Expand Down
Expand Up @@ -22,7 +22,7 @@
import { localize } from '@core/i18n'
import { showInternalVerificationPopup } from '@core/ledger'
import { checkActiveProfileAuth, isActiveLedgerProfile } from '@core/profile'
import { closePopup, openPopup } from '@lib/popup'
import { closePopup, openPopup } from '@auxiliary/popup'
export let activityId: string
export let data: ITransactionActivityData
Expand Down
Expand Up @@ -4,7 +4,7 @@
import { activeAccounts, visibleActiveAccounts } from '@core/profile'
import { deleteAccount } from '@core/profile-manager'
import { Icon } from '@lib/auxiliary/icon'
import { openPopup } from '@lib/popup'
import { openPopup } from '@auxiliary/popup'
import { HR, MenuItem, Modal, ToggleHiddenAccountMenuItem } from 'shared/components'
export let modal: Modal = undefined
Expand Down
Expand Up @@ -4,7 +4,7 @@
import { activeProfile, visibleActiveAccounts } from '@core/profile'
import { selectedAccount, sumBalanceForAccounts } from '@core/account'
import { formatTokenAmountBestMatch } from '@core/wallet'
import { openPopup } from '@lib/popup'
import { openPopup } from '@auxiliary/popup'
import { AccountSwitcherMenuItem } from 'shared/components/molecules'
import { HR, Icon, Modal, Text } from 'shared/components'
import { tick } from 'svelte'
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/components/modals/AssetActionsMenu.svelte
Expand Up @@ -11,7 +11,7 @@
VerifiedStatus,
} from '@core/wallet'
import { Icon } from '@lib/auxiliary/icon'
import { updatePopupProps } from '@lib/popup'
import { updatePopupProps } from '@auxiliary/popup'
import { HR, MenuItem, Modal } from 'shared/components'
export let modal: Modal = undefined
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/components/modals/NodeActionsMenu.svelte
Expand Up @@ -9,7 +9,7 @@
toggleDisabledNodeInClientOptions,
togglePrimaryNodeInClientOptions,
} from '@core/network'
import { closePopup, openPopup } from 'shared/lib/popup'
import { closePopup, openPopup } from '@auxiliary/popup'
import { activeProfile } from '@core/profile'
export let node: INode
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/components/modals/ProfileActions.svelte
Expand Up @@ -3,7 +3,7 @@
import { Button, DeveloperIndicatorPill, HR, Icon, Modal, Text, Toggle, ButtonSize } from 'shared/components'
import { localize } from '@core/i18n'
import { LedgerConnectionState, ledgerConnectionState } from '@core/ledger'
import { popupState, openPopup } from 'shared/lib/popup'
import { popupState, openPopup } from '@auxiliary/popup'
import { openSettings } from '@core/router'
import { diffDates, getBackupWarningColor, getInitials, isRecentDate } from 'shared/lib/helpers'
import { appVersionDetails } from '@core/app'
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/components/molecules/AssetList.svelte
Expand Up @@ -2,7 +2,7 @@
import { localize } from '@core/i18n'
import { assetFilter, IAccountAssets, IAsset } from '@core/wallet'
import { isVisibleAsset } from '@core/wallet/utils/isVisibleAsset'
import { openPopup } from '@lib/popup'
import { openPopup } from '@auxiliary/popup'
import VirtualList from '@sveltejs/svelte-virtual-list'
import { AssetTile, Text, Filter, TextType } from 'shared/components'
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/components/organisms/NodeListTable.svelte
Expand Up @@ -2,7 +2,7 @@
import { localize } from '@core/i18n'
import { getOfficialNodes, INode, isOfficialNetwork } from '@core/network'
import { activeProfile } from '@core/profile'
import { openPopup } from '@lib/popup'
import { openPopup } from '@auxiliary/popup'
import { Text, NodeActionsButton, Pill } from 'shared/components'
export let nodesContainer: HTMLElement = undefined
Expand Down
@@ -1,7 +1,7 @@
<script lang="typescript">
import { localize } from '@core/i18n'
import { Text, Button, AccountInput, FontWeight } from 'shared/components'
import { closePopup } from '@lib/popup'
import { closePopup } from '@auxiliary/popup'
import { IAccountState, setSelectedAccount } from '@core/account'
export let onCancel: () => void
Expand Down
Expand Up @@ -18,7 +18,7 @@
import { CurrencyTypes } from 'shared/lib/typings/currency'
import { setClipboard } from '@lib/utils'
import { truncateString } from '@lib/helpers'
import { closePopup, openPopup } from '@lib/popup'
import { closePopup, openPopup } from '@auxiliary/popup'
import { onMount } from 'svelte'
export let activityId: string
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/components/popups/AddNodePopup.svelte
Expand Up @@ -2,7 +2,7 @@
import { Text, NodeConfigurationForm, Button, HTMLButtonType } from 'shared/components'
import { localize } from '@core/i18n'
import { INode, addNodeToClientOptions, editNodeInClientOptions } from '@core/network'
import { closePopup } from '@lib/popup'
import { closePopup } from '@auxiliary/popup'
import { activeProfile } from '@core/profile'
import { showAppNotification } from '@lib/notifications'
Expand Down
Expand Up @@ -13,7 +13,7 @@
UNLOCK_CONDITION_GOVERNOR_ADDRESS,
UNLOCK_CONDITION_STATE_CONTROLLER_ADDRESS,
} from '@core/wallet'
import { closePopup } from '@lib/popup'
import { closePopup } from '@auxiliary/popup'
import { onMount } from 'svelte'
import { BASE_TOKEN } from '@core/network'
import { handleError } from '@core/error/handlers/handleError'
Expand Down
@@ -1,7 +1,7 @@
<script lang="typescript">
import { localize } from '@core/i18n'
import { Button, Logo, Text, ExportStrongholdButton, TextType } from 'shared/components'
import { closePopup } from 'shared/lib/popup'
import { closePopup } from '@auxiliary/popup'
const busy = false
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/components/popups/ConfirmationPopup.svelte
@@ -1,7 +1,7 @@
<script lang="typescript">
import { Button, Text, TextHint, FontWeight, TextType, ButtonVariant } from 'shared/components'
import { localize } from '@core/i18n'
import { closePopup } from '@lib/popup'
import { closePopup } from '@auxiliary/popup'
export let title: string
export let description: string = ''
Expand Down
Expand Up @@ -6,7 +6,7 @@
import { activeProfile } from '@core/profile'
import { isFunction } from '@core/utils'
import { Button, LedgerAnimation, Text, TextHint, FontWeight, TextType } from 'shared/components'
import { closePopup } from 'shared/lib/popup'
import { closePopup } from '@auxiliary/popup'
export let onCancel: () => void
export let onContinue: () => void
Expand Down
Expand Up @@ -2,7 +2,7 @@
import { Button, ColorPicker, Input, Text } from 'shared/components'
import { getTrimmedLength } from 'shared/lib/helpers'
import { localize } from '@core/i18n'
import { closePopup, updatePopupProps } from 'shared/lib/popup'
import { closePopup, updatePopupProps } from '@auxiliary/popup'
import { checkActiveProfileAuth } from '@core/profile'
import { getRandomAccountColor, tryCreateAdditionalAccount, validateAccountName } from '@core/account'
import { onMount } from 'svelte'
Expand Down
@@ -1,7 +1,7 @@
<script lang="typescript">
import { localize } from '@core/i18n'
import { Text, Button, TextHint, FontWeight } from 'shared/components'
import { closePopup } from '@lib/popup'
import { closePopup } from '@auxiliary/popup'
export let error: Error
</script>
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/components/popups/DeleteAccount.svelte
@@ -1,6 +1,6 @@
<script lang="typescript">
import { Button, PasswordInput, Text, Error, ButtonVariant, HTMLButtonType } from 'shared/components'
import { closePopup } from 'shared/lib/popup'
import { closePopup } from '@auxiliary/popup'
import { localize } from '@core/i18n'
import { setStrongholdPassword } from '@core/profile-manager'
import { isSoftwareProfile } from '@core/profile'
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/components/popups/DeleteProfile.svelte
Expand Up @@ -3,7 +3,7 @@
import { isSoftwareProfile } from '@core/profile'
import { localize } from '@core/i18n'
import { setStrongholdPassword } from '@core/profile-manager'
import { closePopup } from '@lib/popup'
import { closePopup } from '@auxiliary/popup'
import { deleteProfile } from '@contexts/settings'
let isBusy = false
Expand Down
Expand Up @@ -7,7 +7,7 @@
ledgerPreparedOutput,
resetLedgerPreparedOutput,
} from '@core/ledger'
import { closePopup } from '@lib/popup'
import { closePopup } from '@auxiliary/popup'
import { sendOutput } from '@core/wallet'
const STEPS = [1, 2, 3, 4]
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/components/popups/ErrorLog.svelte
Expand Up @@ -2,7 +2,7 @@
import { Button, Text } from 'shared/components'
import { errorLog } from '@core/error'
import { localize } from '@core/i18n'
import { closePopup } from '@lib/popup'
import { closePopup } from '@auxiliary/popup'
import { setClipboard } from '@lib/utils'
function handleClearClick(): () => void {
Expand Down
Expand Up @@ -7,7 +7,7 @@
import { Platform } from 'shared/lib/platform'
import { displayNotificationForLedgerProfile, ledgerNanoStatus } from '@core/ledger'
import { showAppNotification } from 'shared/lib/notifications'
import { closePopup } from 'shared/lib/popup'
import { closePopup } from '@auxiliary/popup'
import { activeProfile, isActiveLedgerProfile, isSoftwareProfile } from '@core/profile'
import { localize } from '@core/i18n'
import { setStrongholdPassword } from '@core/profile-manager'
Expand Down
Expand Up @@ -3,7 +3,7 @@
import { BaseError } from '@core/error'
import { localize } from '@core/i18n'
import { nodeInfo } from '@core/network'
import { closePopup } from '@lib/popup'
import { closePopup } from '@auxiliary/popup'
import { Button, Error, Text, FontWeight, TextType } from 'shared/components'
let isBusy = false
Expand Down

0 comments on commit 5419f55

Please sign in to comment.