Skip to content

Commit

Permalink
DAO-306: Src folder clean up (#1627)
Browse files Browse the repository at this point in the history
* added .vscode to gitignore

* moved utils file into separate folder

* changed import statements

* moved context into context folder

* adapted import paths

* DAO-306: minor doc update

Co-authored-by: yuetloo <[email protected]>
  • Loading branch information
WissenIstNacht and yuetloo authored Sep 14, 2021
1 parent 5bef06f commit f5f2268
Show file tree
Hide file tree
Showing 101 changed files with 149 additions and 144 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public/
# misc
.DS_Store
.cache
.vscode

npm-debug.log*
yarn-debug.log*
Expand Down
2 changes: 1 addition & 1 deletion docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ If you find an issue, or would like to add a feature, ask yourself these followi

## Starting frontend development

Refer to the [frontend development setup](./FRONTEND_SETUP.md) to set up everything you need to start local development on the Client or an app in `aragon-app`!
Refer to the [frontend development setup](./FRONTEND_SETUP.md) to set up everything you need to start local development on the Client or an app in [`aragon/aragon-apps`](https://github.com/aragon/aragon-apps)!

## Your own Aragon app

Expand Down
8 changes: 4 additions & 4 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import PropTypes from 'prop-types'
import { Spring, animated } from 'react-spring'
import { useTheme } from '@aragon/ui'
import { EthereumAddressType, ClientThemeType } from './prop-types'
import { useWallet } from './wallet'
import { useWallet } from './contexts/wallet'
import { useClientTheme } from './client-theme'
import { useRouting } from './routing'
import initWrapper, { pollConnectivity } from './aragonjs-wrapper'
import { Onboarding } from './onboarding'
import { getWeb3 } from './web3-utils'
import { getLocalStorageKey, log } from './utils'
import { getWeb3 } from './util/web3'
import { getLocalStorageKey, log } from './util/utils'
import { ActivityProvider } from './contexts/ActivityContext'
import { FavoriteDaosProvider } from './contexts/FavoriteDaosContext'
import { PermissionsProvider } from './contexts/PermissionsContext'
Expand All @@ -21,7 +21,7 @@ import CustomToast from './components/CustomToast/CustomToast'
import OrgView from './components/OrgView/OrgView'
import { identifyUser } from './analytics'
import { networkConfigs } from './network-config'
import { isKnownRepo } from './repo-utils'
import { isKnownRepo } from './util/repo'

import {
APPS_STATUS_ERROR,
Expand Down
2 changes: 1 addition & 1 deletion src/StoredList.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { identity, log } from './utils'
import { identity, log } from './util/utils'

class StoredList {
// name: the key used by StoredList to save the list in localStorage.
Expand Down
2 changes: 1 addition & 1 deletion src/Web3Provider.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getWeb3Provider } from './web3-utils'
import { getWeb3Provider } from './util/web3'

class Web3Provider {
getProvider(networkType) {
Expand Down
2 changes: 1 addition & 1 deletion src/app-locator.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { hash as namehash } from 'eth-ens-namehash'
import appIds from './known-app-ids'
import { appendTrailingSlash } from './utils'
import { appendTrailingSlash } from './util/utils'

// Known apps and their assigned ports
const DEFAULT_LOCAL_URLS = {
Expand Down
8 changes: 4 additions & 4 deletions src/apps/AppCenter/AppCenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import {
DaoAddressType,
RepoType,
} from '../../prop-types'
import { log, removeStartingSlash } from '../../utils'
import { repoBaseUrl } from '../../url-utils'
import { KERNEL_APP_BASE_NAMESPACE } from '../../aragonos-utils'
import { log, removeStartingSlash } from '../../util/utils'
import { repoBaseUrl } from '../../util/url'
import { KERNEL_APP_BASE_NAMESPACE } from '../../util/aragonos'
import InstalledApps from './InstalledApps/InstalledApps'
import DiscoverApps from './DiscoverApps/DiscoverApps'
import UpgradeAppPanel from './UpgradeAppPanel'
import EmptyBlock from './EmptyBlock'
import { useWallet } from '../../wallet'
import { useWallet } from '../../contexts/wallet'

function getLocation(localPath, extendedRepos) {
const defaultScreen = { screen: 'installed' }
Expand Down
2 changes: 1 addition & 1 deletion src/apps/AppCenter/DiscoverApps/discover-apps-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import redemptionsIcon from './icons/redemptions.svg'
import surveyIcon from './icons/survey.svg'
import timeLockIcon from './icons/time-lock.svg'
import tokenRequestIcon from './icons/token-request.svg'
import { shuffleArray } from '../../../utils'
import { shuffleArray } from '../../../util/utils'

export const appsInDevelopment = [
// Ready
Expand Down
4 changes: 2 additions & 2 deletions src/apps/AppCenter/InstalledApps/AppContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import LocalIdentityBadge from '../../../components/IdentityBadge/LocalIdentityB
import { RepoType } from '../../../prop-types'
import { useRepoDetails } from '../../../hooks'
import Screenshots from '../Screenshots'
import { sanitizeCodeRepositoryUrl } from '../../../url-utils'
import { useWallet } from '../../../wallet'
import { sanitizeCodeRepositoryUrl } from '../../../util/url'
import { useWallet } from '../../../contexts/wallet'

const AppContent = React.memo(
({ repo, repoVersions, onRequestUpgrade, onClose }) => {
Expand Down
2 changes: 1 addition & 1 deletion src/apps/AppCenter/InstalledApps/RepoVersions.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
useTheme,
} from '@aragon/ui'
import { RepoType } from '../../../prop-types'
import { dateFormat } from '../../../date-utils'
import { dateFormat } from '../../../util/date'

const { tr: AnimTr } = animated

Expand Down
2 changes: 1 addition & 1 deletion src/apps/AppCenter/Screenshots.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'
import PropTypes from 'prop-types'
import { Link, GU, RADIUS } from '@aragon/ui'
import { RepoType } from '../../prop-types'
import { imgSrcFromBase } from '../../utils'
import { imgSrcFromBase } from '../../util/utils'

const Screenshots = React.memo(function Screenshots({
screenshots,
Expand Down
2 changes: 1 addition & 1 deletion src/apps/AppCenter/UpgradeAppPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
} from '@aragon/ui'
import RepoBadge from '../../components/RepoBadge/RepoBadge'
import { RepoType } from '../../prop-types'
import { sanitizeCodeRepositoryUrl } from '../../url-utils'
import { sanitizeCodeRepositoryUrl } from '../../util/url'

class UpgradeAppPanel extends React.PureComponent {
static propTypes = {
Expand Down
2 changes: 1 addition & 1 deletion src/apps/Console/Console.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { buildCommand, parseCommand } from './console-utils'
import handlers from './handlers'
import IconPrompt from './IconPrompt'
import KEYCODES from '../../keycodes'
import { clamp } from '../../math-utils'
import { clamp } from '../../util/math'
import { AragonType, AppType } from '../../prop-types'
import { CONSOLE_COMMAND_HISTORY_KEY } from './useConsole'

Expand Down
2 changes: 1 addition & 1 deletion src/apps/Console/ConsoleFeedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
import styled from 'styled-components'
import { Link, textStyle, GU, LoadingRing } from '@aragon/ui'
import { AppType } from '../../prop-types'
import { shortenAddress } from '../../web3-utils'
import { shortenAddress } from '../../util/web3'

// Tuple of [display name, app name]
const INSTALLABLE_APPS = [
Expand Down
2 changes: 1 addition & 1 deletion src/apps/Console/console-utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { appendTrailingSlash } from '../../utils'
import { appendTrailingSlash } from '../../util/utils'

const SEPARATOR = '/'

Expand Down
4 changes: 2 additions & 2 deletions src/apps/GovernMigration/GovernMigration.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import {
toChecksumAddress,
isAddress,
isEmptyAddress,
} from '../../web3-utils'
} from '../../util/web3'
import styled from 'styled-components'
import { useWallet } from '../../wallet'
import { useWallet } from '../../contexts/wallet'
import AddressField from '../../components/AddressField/AddressField'
import { InvalidAddress, RequiredField } from '../../errors'
import { performTransactionPaths } from '../../aragonjs-wrapper'
Expand Down
4 changes: 2 additions & 2 deletions src/apps/Organization/Organization.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import {
import { AppType, DaoAddressType } from '../../prop-types'
import { useRouting, ARAGONID_ENS_DOMAIN } from '../../routing'
import airdrop, { testTokensEnabled } from '../../testnet/airdrop'
import { toChecksumAddress } from '../../web3-utils'
import { useWallet } from '../../wallet'
import { toChecksumAddress } from '../../util/web3'
import { useWallet } from '../../contexts/wallet'

const Organization = React.memo(function Organization({
apps,
Expand Down
2 changes: 1 addition & 1 deletion src/apps/Permissions/AssignPermissionPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Button, DropDown, Info, Field, SidePanel, GU } from '@aragon/ui'
import { ANY_ENTITY } from '../../permissions'
import { PermissionsConsumer } from '../../contexts/PermissionsContext'
import { AppType, AragonType } from '../../prop-types'
import { isAddress, isEmptyAddress } from '../../web3-utils'
import { isAddress, isEmptyAddress } from '../../util/web3'
import AppInstanceLabel from '../../components/AppInstanceLabel'
import EntitySelector from './EntitySelector'

Expand Down
2 changes: 1 addition & 1 deletion src/apps/Permissions/EntitySelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
import { DropDown, Field } from '@aragon/ui'
import { getAnyEntity } from '../../permissions'
import { AppType, AragonType } from '../../prop-types'
import { getEmptyAddress } from '../../web3-utils'
import { getEmptyAddress } from '../../util/web3'
import AppInstanceLabel from '../../components/AppInstanceLabel'
import LocalIdentitiesAutoComplete from '../../components/LocalIdentitiesAutoComplete/LocalIdentitiesAutoComplete'

Expand Down
2 changes: 1 addition & 1 deletion src/apps/Permissions/ManageRolePanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import { PermissionsConsumer } from '../../contexts/PermissionsContext'
import { ANY_ENTITY, isBurnEntity } from '../../permissions'
import { AppType, AragonType } from '../../prop-types'
import { isAddress, isEmptyAddress } from '../../web3-utils'
import { isAddress, isEmptyAddress } from '../../util/web3'
import LocalLabelAppBadge from '../../components/LocalLabelAppBadge/LocalLabelAppBadge'
import EntitySelector from './EntitySelector'
import PermissionsIdentityBadge from './PermissionsIdentityBadge'
Expand Down
4 changes: 2 additions & 2 deletions src/apps/Permissions/Permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import React, { useEffect, useCallback, useRef, useState } from 'react'
import PropTypes from 'prop-types'
import { AppType, AragonType } from '../../prop-types'
import { Button, GU, Header, IconPlus, useLayout } from '@aragon/ui'
import { removeStartingSlash } from '../../utils'
import { addressesEqual, isAddress } from '../../web3-utils'
import { removeStartingSlash } from '../../util/utils'
import { addressesEqual, isAddress } from '../../util/web3'
import { usePermissions } from '../../contexts/PermissionsContext'
import LocalLabelAppBadge from '../../components/LocalLabelAppBadge/LocalLabelAppBadge'
import AppPermissions from './AppPermissions'
Expand Down
8 changes: 4 additions & 4 deletions src/aragonjs-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ import { appOverrides, sortAppsPair } from './environment'
import { NoConnection, DAONotFound } from './errors'
import { getEthSubscriptionEventDelay, getIpfsGateway } from './local-settings'
import { workerFrameSandboxDisabled } from './security/configuration'
import { appBaseUrl } from './url-utils'
import { noop, removeStartingSlash, pollEvery } from './utils'
import { appBaseUrl } from './util/url'
import { noop, removeStartingSlash, pollEvery } from './util/utils'
import {
getGasPrice,
getWeb3,
isEmptyAddress,
isValidEnsName,
} from './web3-utils'
} from './util/web3'
import SandboxedWorker from './worker/SandboxedWorker'
import WorkerSubscriptionPool from './worker/WorkerSubscriptionPool'
import { getOrganizationByAddress } from './services/gql'
import { getNetworkConfig, getChainId } from './network-config'
import { KNOWN_CHAINS } from './wallet'
import { KNOWN_CHAINS } from './contexts/wallet'

const POLL_DELAY_CONNECTIVITY = 2000

Expand Down
2 changes: 1 addition & 1 deletion src/check-domain.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useState, useEffect, useMemo } from 'react'
import { isEnsDomainAvailable } from './aragonjs-wrapper'
import { useClientWeb3 } from './contexts/ClientWeb3Context'
import { useWallet } from './wallet'
import { useWallet } from './contexts/wallet'

const DOMAIN_CHECK = Symbol('DOMAIN_CHECK')
const DOMAIN_LOADING = Symbol('DOMAIN_LOADING')
Expand Down
2 changes: 1 addition & 1 deletion src/components/AccountModule/AccountModule.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { useWallet, WALLET_STATUS } from '../../wallet'
import { useWallet, WALLET_STATUS } from '../../contexts/wallet'
import { useLocalIdentity } from '../../hooks'
import {
useNetworkConnectionData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
} from '@aragon/ui'
import { EthereumAddressType, EthereumProviderType } from '../../prop-types'
import { useCopyToClipboard } from '../../copy-to-clipboard'
import { useWallet } from '../../wallet'
import { useWallet } from '../../contexts/wallet'
import {
useNetworkConnectionData,
useSyncState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'
import PropTypes from 'prop-types'
import { keyframes } from 'styled-components'
import { GU, useTheme, textStyle, Link } from '@aragon/ui'
import { useWallet } from '../../wallet'
import { useWallet } from '../../contexts/wallet'

import loadingRing from './assets/loading-ring.svg'

Expand Down
2 changes: 1 addition & 1 deletion src/components/AccountModule/AccountModuleErrorScreen.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useMemo, useRef } from 'react'
import PropTypes from 'prop-types'
import { GU, Link, textStyle, useTheme } from '@aragon/ui'
import { ChainUnsupportedError } from '../../wallet'
import { ChainUnsupportedError } from '../../contexts/wallet'
import { useNetworkConfig } from '../../network-config'
import connectionError from './assets/connection-error.png'

Expand Down
4 changes: 2 additions & 2 deletions src/components/AccountModule/ButtonAccount.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import {
useTheme,
useViewport,
} from '@aragon/ui'
import { shortenAddress, getEmptyAddress } from '../../web3-utils'
import { useWallet } from '../../wallet'
import { shortenAddress, getEmptyAddress } from '../../util/web3'
import { useWallet } from '../../contexts/wallet'

const ButtonAccount = React.forwardRef(function ButtonAccount(
{ connectionColor, connectionMessage, isWrongNetwork, label, onClick },
Expand Down
2 changes: 1 addition & 1 deletion src/components/AccountModule/WalletSyncedInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
STATUS_TOO_LITTLE_ETH,
STATUS_WALLET_CONNECTION_DROPPED,
} from './connection-statuses'
import { useWallet } from '../../wallet'
import { useWallet } from '../../contexts/wallet'
import { getNetworkName, isOnMainnet } from '../../network-config'

function WalletSyncedInfo({ header, info, status }) {
Expand Down
10 changes: 7 additions & 3 deletions src/components/AccountModule/connection-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ import {
MILD_PROVIDER_SYNC_DELAY,
OK_PROVIDER_SYNC_DELAY,
} from './utils'
import { pollEvery } from '../../utils'
import { useWallet, ChainUnsupportedError, WALLET_STATUS } from '../../wallet'
import { getWeb3, getLatestBlockTimestamp } from '../../web3-utils'
import { pollEvery } from '../../util/utils'
import {
useWallet,
ChainUnsupportedError,
WALLET_STATUS,
} from '../../contexts/wallet'
import { getWeb3, getLatestBlockTimestamp } from '../../util/web3'
import {
getNetworkSettings,
normalizeNetworkName,
Expand Down
4 changes: 2 additions & 2 deletions src/components/Activity/ActivityItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
useTheme,
} from '@aragon/ui'
import { ActivityContext } from '../../contexts/ActivityContext'
import { transformAddresses } from '../../web3-utils'
import { transformAddresses } from '../../util/web3'
import AppIcon from '../AppIcon/AppIcon'
import LocalIdentityBadge from '../IdentityBadge/LocalIdentityBadge'
import TimeTag from './TimeTag'
Expand All @@ -22,7 +22,7 @@ import {
ACTIVITY_STATUS_FAILED,
ACTIVITY_STATUS_TIMED_OUT,
} from '../../symbols'
import { useWallet } from '../../wallet'
import { useWallet } from '../../contexts/wallet'

const ActivityItem = ({ activity }) => {
const theme = useTheme()
Expand Down
2 changes: 1 addition & 1 deletion src/components/Activity/ActivityList.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import activityNoResults from '../../assets/activity-no-results.png'
import { ActivityContext } from '../../contexts/ActivityContext'
import { AppType } from '../../prop-types'
import { ACTIVITY_STATUS_PENDING } from '../../symbols'
import { addressesEqual } from '../../web3-utils'
import { addressesEqual } from '../../util/web3'
import ActivityItem from './ActivityItem'

// 8GU for top bar, 4GU for activity heading,
Expand Down
2 changes: 1 addition & 1 deletion src/components/Activity/TimeTag.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'
import PropTypes from 'prop-types'
import { GU, textStyle, useTheme } from '@aragon/ui'
import { useNow } from '../../hooks'
import { getRelativeTime } from '../../date-utils'
import { getRelativeTime } from '../../util/date'

function TimeTag({ date, label, ...props }) {
const theme = useTheme()
Expand Down
2 changes: 1 addition & 1 deletion src/components/Activity/TransactionProgress.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
import { ProgressBar, GU } from '@aragon/ui'
import { Transition, animated } from 'react-spring'
import { ActivityStatusType } from '../../prop-types'
import { norm } from '../../math-utils'
import { norm } from '../../util/math'
import { useNow } from '../../hooks'
import TimeTag from './TimeTag'
import {
Expand Down
2 changes: 1 addition & 1 deletion src/components/App/AppIFrame.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'
import PropTypes from 'prop-types'
import { AppType } from '../../prop-types'
import { appIframeSandbox } from '../../security/configuration'
import { noop } from '../../utils'
import { noop } from '../../util/utils'

class AppIFrame extends React.Component {
static propTypes = {
Expand Down
2 changes: 1 addition & 1 deletion src/components/AppCard/AppCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useCallback } from 'react'
import PropTypes from 'prop-types'
import { Card, Tag, textStyle, unselectable, GU } from '@aragon/ui'
import { AppType } from '../../prop-types'
import { shortenAddress } from '../../web3-utils'
import { shortenAddress } from '../../util/web3'
import AppIcon from '../AppIcon/AppIcon'

const AppCard = React.memo(function AppCard({ onOpen, app }) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/AppIcon/AppIcon.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect, useState } from 'react'
import PropTypes from 'prop-types'
import { useImageExists, RADIUS } from '@aragon/ui'
import { appIconUrl, legacyAppIconUrl } from '../../utils'
import { appIconUrl, legacyAppIconUrl } from '../../util/utils'

import iconSvgAcl from './assets/app-acl.svg'
import iconSvgApps from './assets/app-apps.svg'
Expand Down
2 changes: 1 addition & 1 deletion src/components/AppInstanceLabel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'
import PropTypes from 'prop-types'
import { Tag, GU, useViewport } from '@aragon/ui'
import { AppType, EthereumAddressType } from '../prop-types'
import { shortenAddress } from '../web3-utils'
import { shortenAddress } from '../util/web3'
import AppIcon from './AppIcon/AppIcon'

const AppInstanceLabel = React.memo(
Expand Down
Loading

0 comments on commit f5f2268

Please sign in to comment.