Skip to content

Commit

Permalink
chore: lint project
Browse files Browse the repository at this point in the history
  • Loading branch information
envin3 committed Apr 4, 2024
1 parent 5cdda95 commit c1ed0f7
Show file tree
Hide file tree
Showing 66 changed files with 261 additions and 219 deletions.
22 changes: 12 additions & 10 deletions scripts/fetch-addresses-assets.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// NOTE: before run this scripts go to settings/swap-assets and change export default into module.exports =
const { constants, helpers } = require('ptokens-utils')
const { NodeSelector } = require('ptokens-node-selector')
const fs = require('fs')

const { NodeSelector } = require('ptokens-node-selector')
const { constants, helpers } = require('ptokens-utils')

const assets = require('../src/settings/swap-assets')

const start = async () => {
Expand All @@ -19,23 +21,23 @@ const start = async () => {
{
pToken: workingName,
blockchain: helpers.getBlockchainType(blockchain.toLowerCase()),
network
network,
},
helpers.getNativeBlockchainFromPtokenName(workingName)
)

return new Promise(_resolve =>
return new Promise((_resolve) =>
nodeSelector
.select({
timeout: 20 * 1000,
pToken: workingName.toLowerCase() === 'peth' ? 'pweth' : workingName.toLowerCase(),
nativeBlockchain,
nativeNetwork,
hostBlockchain,
hostNetwork
hostNetwork,
})
.then(_resolve)
.catch(_err => {
.catch((_err) => {
console.error(_err)
_resolve(null)
})
Expand All @@ -45,8 +47,8 @@ const start = async () => {

const pTokensAddresses = await Promise.all(
nodes.map(
_node =>
new Promise(_resolve =>
(_node) =>
new Promise((_resolve) =>
_node
? _node
.getInfo()
Expand All @@ -59,7 +61,7 @@ const start = async () => {
: null
)
})
.catch(_err => {
.catch((_err) => {
console.error(_err)
_resolve(null)
})
Expand All @@ -75,7 +77,7 @@ const start = async () => {

return {
address: nativeAddress ? nativeAddress : pTokensAddresses[_index],
..._asset
..._asset,
}
})

Expand Down
45 changes: 23 additions & 22 deletions scripts/redirect-old-links.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
const fs = require('fs');
const dirList = ['swap', 'migration', 'migration/a', 'migration/b', 'migration/c', 'migration/d', 'risks', 'nfts'];
const fs = require('fs')

const dirList = ['swap', 'migration', 'migration/a', 'migration/b', 'migration/c', 'migration/d', 'risks', 'nfts']
const basePath = './build'

for (let i = 0; i < dirList.length; i++) {
let dir = dirList[i]
let dirSub = dir
let path = basePath + '/' + dir
if (!fs.existsSync(path)){
fs.mkdirSync(path);
}
/*
* This script takes the current url and adds '/#/' before the directory name.
* Afterwords it redirects the browser to the new created URL.
* This allows to redirect old links of the type 'https://dapp/directory' to
* 'https://dapp/#/directory' for all the directories listed in `dirList`
*/
if (dir == 'migration/a') {
dirSub = 'migration/pBTC-v1-to-v2'
}
fs.writeFileSync(
`${path}/index.html`,
`<script>
let dir = dirList[i]
let dirSub = dir
let path = basePath + '/' + dir
if (!fs.existsSync(path)) {
fs.mkdirSync(path)
}
/*
* This script takes the current url and adds '/#/' before the directory name.
* Afterwords it redirects the browser to the new created URL.
* This allows to redirect old links of the type 'https://dapp/directory' to
* 'https://dapp/#/directory' for all the directories listed in `dirList`
*/
if (dir === 'migration/a') {
dirSub = 'migration/pBTC-v1-to-v2'
}
fs.writeFileSync(
`${path}/index.html`,
`<script>
window.location.replace(window.location.href.replace('/${dir}/','/#/${dirSub}'));
</script>
`,
{encoding:'utf8', flag:'w'}
);
{ encoding: 'utf8', flag: 'w' }
)
}
31 changes: 15 additions & 16 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
import React, { useEffect, useState } from 'react'
import PropTypes from 'prop-types'
import { Route, Switch, Redirect, useRouteMatch } from 'react-router-dom'
import queryString from 'query-string'
import React, { useEffect, useState } from 'react'
import { connect } from 'react-redux'
import { Route, Switch, Redirect, useRouteMatch } from 'react-router-dom'

import SwapController from './components/pages/swap/SwapController'
import { sendPageView, setPageLocation } from './ga4'
import SwapOldPntController from './components/pages/swapOldPnt/SwapOldPntController'
import { loadSwapData } from './store/swap/swap.actions'
import { loadMigrationData } from './store/migration/migration.actions'
import { loadSwapOldPntData } from './store/swap-old-pnt/swap-old-pnt.actions'
import { selectPage, setTheme } from './store/pages/pages.actions'
import history from './utils/history'
import MigrationController from './components/pages/migration/MigrationController'
import MigrationHomeController from './components/pages/migrationHome/MigrationHomeController'
import NftsController from './components/pages/nfts/NftsController'
import Risks from './components/pages/risks/Risks'
import MainWrapper from './components/atoms/mainWrapper/MainWrapper'
import Notifications from './components/molecules/notifications/Notifications'
import Popup from './components/molecules/popup/Popup'
Expand All @@ -24,6 +12,18 @@ import WarningPopup from './components/molecules/popup/Warning'
import SocialLinks from './components/molecules/socials/Socials'
import Version from './components/molecules/version/Version'
import HeaderController from './components/organisms/header/HeaderController'
import MigrationController from './components/pages/migration/MigrationController'
import MigrationHomeController from './components/pages/migrationHome/MigrationHomeController'
import NftsController from './components/pages/nfts/NftsController'
import Risks from './components/pages/risks/Risks'
import SwapController from './components/pages/swap/SwapController'
import SwapOldPntController from './components/pages/swapOldPnt/SwapOldPntController'
import { sendPageView, setPageLocation } from './ga4'
import { loadMigrationData } from './store/migration/migration.actions'
import { selectPage, setTheme } from './store/pages/pages.actions'
import { loadSwapData } from './store/swap/swap.actions'
import { loadSwapOldPntData } from './store/swap-old-pnt/swap-old-pnt.actions'
import history from './utils/history'

history.listen((location) => {
setPageLocation(location.pathname)
Expand Down Expand Up @@ -112,7 +112,7 @@ const App = ({ loading, setTheme, loadSwapData, loadSwapOldPntData, loadMigratio
<MainWrapper>
<Notifications />
<HeaderController />
<RedirectBanner/>
<RedirectBanner />
<WarningPopup show={showWarningPopup} onClose={() => setShowWarningPopup(false)} />
<Switch>
<Route exact path={'/swap'} render={() => <SwapController />} />
Expand All @@ -121,7 +121,6 @@ const App = ({ loading, setTheme, loadSwapData, loadSwapOldPntData, loadMigratio
path={'/nfts'}
render={() => (
<React.Fragment>
{/* <Loader loading={loading} /> */}
<NftsController />
</React.Fragment>
)}
Expand Down
3 changes: 2 additions & 1 deletion src/components/atoms/icon/Icon.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react'
import PropTypes from 'prop-types'
import React from 'react'
import styled, { css } from 'styled-components'

import getIconSource from './icon-importer'

const commonCss = css`
Expand Down
4 changes: 2 additions & 2 deletions src/components/atoms/icon/icon-importer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import close from './icons/close.svg?raw'
import copy from './icons/copy.svg?raw'
import descendant from './icons/descendant.svg?raw'
import downArrow from './icons/down-arrow.svg?raw'
import info from './icons/info.svg?raw'
import metamask from './icons/metamask.svg?raw'
import moon from './icons/moon.svg?raw'
import sort from './icons/sort.svg?raw'
import sun from './icons/sun.svg?raw'
import wallet from './icons/wallet.svg?raw'
import world from './icons/world.svg?raw'
import warning from './icons/warning.svg?raw'
import info from './icons/info.svg?raw'
import world from './icons/world.svg?raw'

const getIconSource = (icon) => {
switch (icon) {
Expand Down
14 changes: 0 additions & 14 deletions src/components/atoms/loader/Loader.jsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/components/atoms/switch/Switch.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useContext } from 'react'
import { ThemeContext } from 'styled-components'
import Switch from 'react-switch'
import { ThemeContext } from 'styled-components'

const CustomSwitch = ({ checked, onChange, ..._props }) => {
const theme = useContext(ThemeContext)
Expand Down
3 changes: 2 additions & 1 deletion src/components/molecules/banner/Banner.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useState } from 'react'
import styled from 'styled-components'
import { Row, Col, Container } from 'react-bootstrap'
import styled from 'styled-components'

import Icon from '../../atoms/icon/Icon'

const ContainerBanner = styled(Container)`
Expand Down
2 changes: 1 addition & 1 deletion src/components/molecules/modal/Modal.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import PropTypes from 'prop-types'
import React from 'react'
import { Modal } from 'react-bootstrap'
import styled from 'styled-components'
import PropTypes from 'prop-types'

const StyledModalTitle = styled(Modal.Title)`
color: ${({ theme }) => theme.text1};
Expand Down
4 changes: 2 additions & 2 deletions src/components/molecules/popup/AddressWarning.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import PropTypes from 'prop-types'
import styled from 'styled-components'
import React from 'react'
import { Modal } from 'react-bootstrap'
import styled from 'styled-components'

const StyledModalTitle = styled(Modal.Title)`
color: ${({ theme }) => theme.text1};
Expand Down
5 changes: 3 additions & 2 deletions src/components/molecules/popup/Popup.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React, { useState } from 'react'
import PropTypes from 'prop-types'
import styled, { keyframes } from 'styled-components'
import React, { useState } from 'react'
import { bounceInUp } from 'react-animations'
import { Card } from 'react-bootstrap'
import styled, { keyframes } from 'styled-components'

import Icon from '../../atoms/icon/Icon'

const StyledCard = styled(Card)`
Expand Down
1 change: 0 additions & 1 deletion src/components/molecules/popup/RedirectBanner.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import PropTypes from 'prop-types'
import React from 'react'
import { Alert, Row } from 'react-bootstrap'
import styled from 'styled-components'
Expand Down
4 changes: 2 additions & 2 deletions src/components/molecules/popup/TermsOfService.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import PropTypes from 'prop-types'
import styled from 'styled-components'
import React from 'react'
import { Modal } from 'react-bootstrap'
import styled from 'styled-components'

const StyledModalTitle = styled(Modal.Title)`
color: ${({ theme }) => theme.text1};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable import/first */
import { render, screen } from '@testing-library/react'
import { describe, expect, it, vi } from 'vitest'
import { describe, expect } from 'vitest'

import RedirectBanner from '../RedirectBanner'

Expand Down
4 changes: 2 additions & 2 deletions src/components/molecules/progress/Progress.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import PropTypes from 'prop-types'
import styled from 'styled-components'
import React from 'react'
import { ProgressBar, Step } from 'react-step-progress-bar'
import styled from 'styled-components'

const ContainerProgress = styled.div`
padding-left: 10px;
Expand Down
1 change: 1 addition & 0 deletions src/components/molecules/socials/Socials.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react'
import { FaTelegram, FaTwitter } from 'react-icons/fa'

import settings from '../../../settings'
import './styles.css'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React, { useEffect, useState } from 'react'
import PropTypes from 'prop-types'
import styled from 'styled-components'
import QRCode from 'qrcode.react'
import { blockchainSymbolToCoin } from '../../../utils/maps'
import React, { useEffect, useState } from 'react'
import ReactTooltip from 'react-tooltip'
import styled from 'styled-components'

import { blockchainSymbolToCoin } from '../../../utils/maps'
import { copyToClipboard } from '../../../utils/utils'
import Modal from '../../molecules/modal/Modal'

Expand Down
8 changes: 5 additions & 3 deletions src/components/organisms/header/HeaderController.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import PropTypes from 'prop-types'
import React from 'react'
import { connect } from 'react-redux'
import Header from './Header'
import PropTypes from 'prop-types'
import { connectWithWallet, disconnectFromWallet } from '../../../store/wallets/wallets.actions'

import { selectPage, setTheme } from '../../../store/pages/pages.actions'
import { loadSwapData } from '../../../store/swap/swap.actions'
import { connectWithWallet, disconnectFromWallet } from '../../../store/wallets/wallets.actions'

import Header from './Header'

const mapStateToProps = (_state) => {
return {
Expand Down
5 changes: 3 additions & 2 deletions src/components/organisms/infoModal/InfoModal.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React, { useEffect, useState } from 'react'
import PropTypes from 'prop-types'
import React, { useEffect, useState } from 'react'
import styled from 'styled-components'
import Modal from '../../molecules/modal/Modal'

import Icon from '../../atoms/icon/Icon'
import Modal from '../../molecules/modal/Modal'

const Message = styled.div`
margin-top: 30px;
Expand Down
7 changes: 4 additions & 3 deletions src/components/organisms/migrationInfo/MigrationInfo.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React from 'react'
import styled from 'styled-components'
import PropTypes from 'prop-types'
import React from 'react'
import { Row, Col, Container } from 'react-bootstrap'
import Switch from '../../atoms/switch/Switch'
import ReactTooltip from 'react-tooltip'
import styled from 'styled-components'

import { getMigrationFees } from '../../../utils/fee'
import Switch from '../../atoms/switch/Switch'

const ContainerInfo = styled(Container)`
background: ${({ theme }) => theme.secondary3Transparentized};
Expand Down
5 changes: 3 additions & 2 deletions src/components/organisms/moveModal/MoveModal.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import PropTypes from 'prop-types'
import React, { useCallback, useMemo, useState } from 'react'
import { Row, Col } from 'react-bootstrap'
import PropTypes from 'prop-types'
import styled from 'styled-components'

import { isValidAccountByBlockchain } from '../../../utils/account-validator'
import Modal from '../../molecules/modal/Modal'
import { blockchainSymbolToName } from '../../../utils/maps'
import Modal from '../../molecules/modal/Modal'

const ContainerRow = styled.div`
padding-top: 10px;
Expand Down
3 changes: 2 additions & 1 deletion src/components/organisms/nftCard/NftCard.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import PropTypes from 'prop-types'
import React, { useState } from 'react'
import { Card, Row, Col } from 'react-bootstrap'
import PropTypes from 'prop-types'
import styled from 'styled-components'

import MoveModal from '../moveModal/MoveModal'

const StyledCard = styled(Card)`
Expand Down
Loading

0 comments on commit c1ed0f7

Please sign in to comment.