Skip to content
This repository has been archived by the owner on Oct 10, 2023. It is now read-only.

Commit

Permalink
Re-structure sources used by main and renderer
Browse files Browse the repository at this point in the history
processes
  • Loading branch information
veado committed Jul 14, 2020
1 parent 2f1dc77 commit eaec775
Show file tree
Hide file tree
Showing 424 changed files with 70 additions and 62 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ yarn-error.log*
# compiled by tsc
/public/electron.js
# generated by open api
/src/types/generated
/src/renderer/types/generated
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
/node_modules
.editorconfig
README.md
src/serviceWorker.ts
src/renderer/serviceWorker.ts
/public/
2 changes: 1 addition & 1 deletion .storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
stories: ['../src/**/*.stories.(ts|tsx)'],
stories: ['../src/renderer/**/*.stories.(ts|tsx)'],
addons: [
'@storybook/preset-create-react-app',
'@storybook/addon-actions',
Expand Down
8 changes: 4 additions & 4 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { configure } from '@storybook/react'
import { withThemes } from '@react-theming/storybook-addon'
import { BrowserRouter as Router, Route } from 'react-router-dom'

import { AppProvider } from '../src/contexts/AppContext'
import { ThemeProvider } from '../src/contexts/ThemeContext'
import { I18nProvider } from '../src/contexts/I18nContext'
import { AppWrapper } from '../src/App.style'
import { AppProvider } from '../src/renderer/contexts/AppContext'
import { ThemeProvider } from '../src/renderer/contexts/ThemeContext'
import { I18nProvider } from '../src/renderer/contexts/I18nContext'
import { AppWrapper } from '../src/renderer/App.style'

const lightTheme = { name: 'Light', ...themes.light }
const darkTheme = { name: 'Dark', ...themes.dark }
Expand Down
3 changes: 3 additions & 0 deletions craco.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// const path = require('path')

const GitRevisionPlugin = require('git-revision-webpack-plugin')
const webpack = require('webpack')

Expand All @@ -8,6 +10,7 @@ module.exports = {
webpackConfig.target = 'electron-renderer'
// support hot reload of hooks
webpackConfig.resolve.alias['react-dom'] = '@hot-loader/react-dom'
console.log('webpackConfig 22', webpackConfig)
return webpackConfig
},
plugins: [
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@
"start:web": "craco start",
"dev": "concurrently --kill-others --success first \"yarn:dev:*\"",
"dev:app": "cross-env BROWSER=none yarn start:web",
"dev:electron": "wait-on http://localhost:3000 && nodemon -I --watch ./electron/ --exec electron ./public/dev.js",
"dev:electron": "wait-on http://localhost:3000 && nodemon -I --watch ./src/main/ --exec electron ./public/dev.js",
"build": "cross-env CI=false PUBLIC_URL=./ craco build",
"prebuild": "webpack --config webpack.electron.js --mode production",
"prebuild": "webpack --config webpack.main.js --mode production",
"test": "craco test",
"package": "yarn build && yarn package:electron",
"package:electron": "electron-builder build -c.extraMetadata.main=build/electron.js --config .electronbuildrc",
"package:ci": "yarn postinstall && yarn build && yarn package:electron --publish always",
"postinstall": "electron-builder install-app-deps",
"lint": "eslint \"{src,electron,e2e,}/**/*.{ts,tsx}\" --fix",
"lint": "eslint \"{src,e2e,}/**/*.{ts,tsx}\" --fix",
"eject": "craco eject",
"test:e2e": "yarn build && yarn test:cafe",
"test:cafe": "cross-env NODE_ENV=production testcafe electron:./ ./e2e/**/*.e2e.ts",
"generate:types": "yarn clean:types:midgard && yarn generate:types:midgard",
"generate:types:midgard": "openapi-generator generate -i https://midgard.bepswap.com/v1/swagger.json -g typescript-rxjs -o ./src/types/generated/midgard --reserved-words-mappings in=in",
"clean:types:midgard": "rm -rf ./src/types/generated/midgard",
"generate:types:midgard": "openapi-generator generate -i https://midgard.bepswap.com/v1/swagger.json -g typescript-rxjs -o ./src/renderer/types/generated/midgard --reserved-words-mappings in=in",
"clean:types:midgard": "rm -rf ./src/renderer/types/generated/midgard",
"storybook": "start-storybook -p 9009 -s public",
"build-storybook": "build-storybook -s public"
},
Expand Down
4 changes: 2 additions & 2 deletions public/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
*/

// import tsconfig
const config = require("../electron/tsconfig.json");
const config = require("../tsconfig.main.json");
// register the typescript compiler
require("ts-node").register(config);
// import the main process typescript code
require("../electron/electron");
require("../src/main/electron");
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// needed by CRA (can't be overridden by craco)
// see https://github.com/gsoft-inc/craco/issues/66#issuecomment-455202361
import './renderer/index'
4 changes: 2 additions & 2 deletions electron/electron.ts → src/main/electron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import log from 'electron-log'
import { warn } from 'electron-log'
import { fromEvent } from 'rxjs'

import { Locale } from '../src/shared/i18n/types'
import IPCMessages from '../src/shared/ipc/messages'
import { Locale } from '../shared/i18n/types'
import IPCMessages from '../shared/ipc/messages'
import { setMenu } from './menu'

export const IS_DEV = isDev && process.env.NODE_ENV !== 'production'
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion electron/i18n/index.ts → src/main/i18n/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createIntlCache } from 'react-intl'

import { Locale } from '../../src/shared/i18n/types'
import { Locale } from '../../shared/i18n/types'
import de from './de'
import en from './en'
import fr from './fr'
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion electron/menu/help.ts → src/main/menu/help.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { MenuItemConstructorOptions, shell } from 'electron'
import { IntlShape } from 'react-intl'

import { ExternalUrl } from '../../src/shared/const'
import { ExternalUrl } from '../../shared/const'

const menu = (intl: IntlShape): MenuItemConstructorOptions => ({
label: intl.formatMessage({ id: 'menu.help.title' }),
Expand Down
2 changes: 1 addition & 1 deletion electron/menu/index.ts → src/main/menu/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Menu } from 'electron'
import { createIntl } from 'react-intl'

import { Locale } from '../../src/shared/i18n/types'
import { Locale } from '../../shared/i18n/types'
import { getMessagesByLocale, cache } from '../i18n'
import appMenu from './app'
import editMenu from './edit'
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { Row, Col, Grid } from 'antd'
import { useIntl } from 'react-intl'
import { useHistory } from 'react-router-dom'

import { ExternalUrl } from '../../shared/const'
import { ReactComponent as TelegramIcon } from '../assets/svg/icon-telegram.svg'
import { ReactComponent as ThorChainIcon } from '../assets/svg/logo-thorchain.svg'
import * as playgroundRoutes from '../routes/playground'
import { ExternalUrl } from '../shared/const'
import { FooterContainer, FooterLink, FooterIconWrapper, FooterLinkWrapper } from './Footer.style'

const { shell } = window.require('electron')
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { storiesOf } from '@storybook/react'
import { assetAmount, assetToBase } from '@thorchain/asgardex-util'
import BigNumber from 'bignumber.js'

import { ASSETS_MAINNET } from '../../../mock/assets'
import { ASSETS_MAINNET } from '../../../../shared/mock/assets'
import { TxStatus, TxTypes } from '../../../types/asgardex'
import SwapModal from './SwapModal'
import { CalcResult } from './types'
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import React from 'react'
import { storiesOf } from '@storybook/react'
import { bn, assetAmount, assetToBase } from '@thorchain/asgardex-util'

import { ASSETS_MAINNET } from '../../../../../shared/mock/assets'
import { ONE_ASSET_BASE_AMOUNT } from '../../../../const'
import { ASSETS_MAINNET } from '../../../../mock/assets'
import AssetCard from './AssetCard'

storiesOf('Components/Assets/AssetCard', module).add('default', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react'
import { storiesOf } from '@storybook/react'
import { assetAmount, assetToBase } from '@thorchain/asgardex-util'

import { ASSETS_MAINNET } from '../../../../mock/assets'
import { ASSETS_MAINNET } from '../../../../../shared/mock/assets'
import AssetData from './AssetData'

const assetValue = assetToBase(assetAmount(2.49274))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react'
import { radios } from '@storybook/addon-knobs'
import { storiesOf } from '@storybook/react'

import { ASSETS_MAINNET } from '../../../../mock/assets'
import { ASSETS_MAINNET } from '../../../../../shared/mock/assets'
import AssetIcon from './AssetIcon'
import { Size } from './types'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import React from 'react'
import { storiesOf } from '@storybook/react'
import { bn } from '@thorchain/asgardex-util'

import { ASSETS_MAINNET } from '../../../../../shared/mock/assets'
import { ONE_ASSET_BASE_AMOUNT } from '../../../../const'
import { ASSETS_MAINNET } from '../../../../mock/assets'
import AssetMenu from './AssetMenu'

storiesOf('Components/Assets/AssetMenu', module).add('default', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react'
import { withKnobs, radios } from '@storybook/addon-knobs'
import { storiesOf } from '@storybook/react'

import { ASSETS_MAINNET } from '../../../../mock/assets'
import { ASSETS_MAINNET } from '../../../../../shared/mock/assets'
import { Size as CoinSize } from '../assetIcon/types'
import AssetPair from './AssetPair'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react'
import { radios, withKnobs } from '@storybook/addon-knobs'
import { storiesOf } from '@storybook/react'

import { ASSETS_MAINNET } from '../../../../mock/assets'
import { ASSETS_MAINNET } from '../../../../../shared/mock/assets'
import { Size } from '../assetIcon/types'
import AssetPairOverlapped from './AssetPairOverlapped'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import React from 'react'
import { storiesOf } from '@storybook/react'
import { bn } from '@thorchain/asgardex-util'

import { ASSETS_MAINNET } from '../../../../../shared/mock/assets'
import { ONE_ASSET_BASE_AMOUNT } from '../../../../const'
import { ASSETS_MAINNET } from '../../../../mock/assets'
import AssetSelect from './AssetSelect'

storiesOf('Components/Assets/AssetSelect', module).add('default', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react'

import { storiesOf } from '@storybook/react'

import { ASSETS_MAINNET } from '../../../mock/assets'
import { ASSETS_MAINNET } from '../../../../shared/mock/assets'
import Drag from './Drag'

storiesOf('Components/Drag', module).add('default', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import React from 'react'
import { storiesOf } from '@storybook/react'
import { assetAmount, assetToBase } from '@thorchain/asgardex-util'

import { ASSETS_MAINNET } from '../../../../shared/mock/assets'
import { ONE_ASSET_BASE_AMOUNT } from '../../../const'
import { ASSETS_MAINNET } from '../../../mock/assets'
import { AssetPair } from '../../../types/asgardex'
import AssetData from '../assets/assetData'
import FilterMenu from './FilterMenu'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react'
import { storiesOf } from '@storybook/react'
import BigNumber from 'bignumber.js'

import { ASSETS_MAINNET } from '../../../mock/assets'
import { ASSETS_MAINNET } from '../../../../shared/mock/assets'
import TokenDetailCard from './TokenDetailCard'

storiesOf('Components/TokenDetailCard', module).add('default', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'

import { storiesOf } from '@storybook/react'

import { ASSETS_MAINNET } from '../../mock/assets'
import { ASSETS_MAINNET } from '../../../shared/mock/assets'
import AccountSelector from './AccountSelector'

storiesOf('Wallet/AccountSelector', module).add('default', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import React, { useCallback } from 'react'
import { Asset } from '@thorchain/asgardex-util'
import { Menu, Dropdown } from 'antd'

import { Size as CoinSize } from '../../components/uielements/assets/assetIcon/types'
import Label from '../../components/uielements/label'
import AssetIcon from '../uielements/assets/assetIcon'
import { Size as CoinSize } from '../uielements/assets/assetIcon/types'
import Label from '../uielements/label'
import { StyledCard, AssetWrapper, AssetInfoWrapper, AssetTitle } from './AccountSelector.style'

type Props = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Card, Divider, Row, Col } from 'antd'
import styled from 'styled-components'
import { palette } from 'styled-theme'

import Label from '../../components/uielements/label'
import Label from '../uielements/label'

export const StyledCard = styled(Card)`
.ant-card-body {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { Row, Col, Grid } from 'antd'
import { useIntl } from 'react-intl'
import { useHistory } from 'react-router-dom'

import Button from '../../components/uielements/button'
import { ASSETS_TESTNET } from '../../mock/assets'
import { ASSETS_TESTNET } from '../../../shared/mock/assets'
import * as walletRoutes from '../../routes/wallet'
import { UserTransactionType } from '../../types/wallet'
import AssetIcon from '../uielements/assets/assetIcon'
import Button from '../uielements/button'
import {
StyledCard,
StyledMobileCard,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ import * as O from 'fp-ts/lib/Option'
import { useIntl } from 'react-intl'
import { useHistory } from 'react-router-dom'

import ErrorView from '../../components/shared/error/ErrorView'
import Label from '../../components/uielements/label'
import { RUNE_PRICE_POOL } from '../../const'
import * as walletRoutes from '../../routes/wallet'
import { BalancesRD } from '../../services/binance/types'
import { bncSymbolToAsset, bncSymbolToAssetString, getPoolPriceValue } from '../../services/binance/utils'
import { PoolDetails } from '../../services/midgard/types'
import { PricePool } from '../../views/pools/types'
import ErrorView from '../shared/error/ErrorView'
import AssetIcon from '../uielements/assets/assetIcon'
import Label from '../uielements/label'
import { TableWrapper } from './AssetsTable.style'

type Props = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { useBinanceContext } from '../../contexts/BinanceContext'
import { useWalletContext } from '../../contexts/WalletContext'
import * as walletRoutes from '../../routes/wallet'
import Button from '../uielements/button'
import { InputPassword, InputTextArea } from '../uielements/input/'
import { InputPassword, InputTextArea } from '../uielements/input'

const ImportPhrase: React.FC = (): JSX.Element => {
const history = useHistory()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Form, Button } from 'antd'
import { Rule } from 'antd/lib/form'
import { Store } from 'antd/lib/form/interface'

import { Input } from '../../components/uielements/input'
import { Input } from '../uielements/input'

type Props = {}
const NewMnemonicGenerate: React.FC<Props> = (_: Props): JSX.Element => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Grid, Row, Col } from 'antd'
import QRCode from 'qrcode'
import { useHistory } from 'react-router-dom'

import { ASSETS_MAINNET } from '../../mock/assets'
import { ASSETS_MAINNET } from '../../../shared/mock/assets'
import AccountSelector from './AccountSelector'
import {
StyledBackLabel,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Col, Form } from 'antd'
import styled from 'styled-components'
import { palette } from 'styled-theme'

import Label from '../../components/uielements/label'
import Label from '../uielements/label'

export const StyledCol = styled(Col)`
padding: 20px 30px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { Store } from 'antd/lib/form/interface'
import { useIntl } from 'react-intl'
import { useHistory } from 'react-router-dom'

import Button from '../../components/uielements/button'
import { Input } from '../../components/uielements/input'
import { ASSETS_MAINNET } from '../../mock/assets'
import { ASSETS_MAINNET } from '../../../shared/mock/assets'
import Button from '../uielements/button'
import { Input } from '../uielements/input'
import AccountSelector from './AccountSelector'
import {
StyledCol,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import { none, Option, some } from 'fp-ts/lib/Option'
import { useIntl } from 'react-intl'
import { useHistory, useLocation } from 'react-router-dom'

import { InputPassword } from '../../components/uielements/input'
import { IS_PRODUCTION } from '../../../shared/const'
import { useWalletContext } from '../../contexts/WalletContext'
import { envOrDefault } from '../../helpers/envHelper'
import { RedirectRouteState } from '../../routes/types'
import * as walletRoutes from '../../routes/wallet'
import { KeystoreState } from '../../services/wallet/types'
import { isLocked, hasImportedKeystore } from '../../services/wallet/util'
import { IS_PRODUCTION } from '../../shared/const'
import BackLink from '../uielements/backLink'
import { InputPassword } from '../uielements/input'
import * as Styled from './UnlockForm.style'

type Props = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Typography } from 'antd'
import styled from 'styled-components'
import { palette } from 'styled-theme'

import Table from '../../components/uielements/table'
import Table from '../uielements/table'

const { Text } = Typography

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PoolData, assetAmount, assetToBase } from '@thorchain/asgardex-util'
import { some } from 'fp-ts/lib/Option'

import { ASSETS_TESTNET } from '../mock/assets'
import { ASSETS_TESTNET } from '../../shared/mock/assets'
import { PoolDetails } from '../services/midgard/types'
import { toPoolData } from '../services/midgard/utils'
import { PoolDetailStatusEnum, PoolDetail } from '../types/generated/midgard'
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit eaec775

Please sign in to comment.