From 7da22bfcad228ee2d728f4407594f4d03373c570 Mon Sep 17 00:00:00 2001 From: CAPtheorem <79423264+CAPtheorem@users.noreply.github.com> Date: Thu, 16 Sep 2021 11:05:25 -0700 Subject: [PATCH 01/24] minor gateway updates --- .../src/components/listNFTfactory/listNFTfactory.js | 2 +- packages/omgx/wallet-frontend/src/containers/nft/Nft.js | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/omgx/wallet-frontend/src/components/listNFTfactory/listNFTfactory.js b/packages/omgx/wallet-frontend/src/components/listNFTfactory/listNFTfactory.js index af523271c477..025b1a58d15f 100644 --- a/packages/omgx/wallet-frontend/src/components/listNFTfactory/listNFTfactory.js +++ b/packages/omgx/wallet-frontend/src/components/listNFTfactory/listNFTfactory.js @@ -149,7 +149,7 @@ class listNFTfactory extends React.Component { {this.setState({tokenURI: i.target.value})}} value={tokenURI} /> diff --git a/packages/omgx/wallet-frontend/src/containers/nft/Nft.js b/packages/omgx/wallet-frontend/src/containers/nft/Nft.js index 41de1cdff3f8..5ee8facc73d7 100644 --- a/packages/omgx/wallet-frontend/src/containers/nft/Nft.js +++ b/packages/omgx/wallet-frontend/src/containers/nft/Nft.js @@ -109,6 +109,8 @@ class Nft extends React.Component { const numberOfContracts = Object.keys(contracts).length const layer = networkService.L1orL2 + const mintDisabled = numberOfContracts > 0 ? false : true + if(layer === 'L1') { return
@@ -171,7 +173,12 @@ class Nft extends React.Component { sx={{mt: 1, mb: 5}} > - + From 9dfe8f8fcd4e4e9bdd5163f30e803b6f8f3bc8fd Mon Sep 17 00:00:00 2001 From: CAPtheorem <79423264+CAPtheorem@users.noreply.github.com> Date: Thu, 16 Sep 2021 11:27:35 -0700 Subject: [PATCH 02/24] gateway minor tweaks --- .../omgx/wallet-frontend/src/components/listNFT/listNFT.js | 4 ++-- .../src/components/listNFT/listNFT.module.scss | 2 +- packages/omgx/wallet-frontend/src/services/networkService.js | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/omgx/wallet-frontend/src/components/listNFT/listNFT.js b/packages/omgx/wallet-frontend/src/components/listNFT/listNFT.js index 309bcc5b9708..73bd9def8f7b 100644 --- a/packages/omgx/wallet-frontend/src/components/listNFT/listNFT.js +++ b/packages/omgx/wallet-frontend/src/components/listNFT/listNFT.js @@ -110,8 +110,8 @@ class listNFT extends React.Component {
- {name} - ({symbol}) + + {name} ({symbol}) {(attributes || []).map((attr, index) => { return ({attr.trait_type}: diff --git a/packages/omgx/wallet-frontend/src/components/listNFT/listNFT.module.scss b/packages/omgx/wallet-frontend/src/components/listNFT/listNFT.module.scss index e5fa83e72f28..8f00dc1abd8f 100644 --- a/packages/omgx/wallet-frontend/src/components/listNFT/listNFT.module.scss +++ b/packages/omgx/wallet-frontend/src/components/listNFT/listNFT.module.scss @@ -44,7 +44,7 @@ $dropDownHeight: 92px; } .muted { - color: $white700; + color: $white500; margin-left: 5px !important; font-weight: 600 !important; } \ No newline at end of file diff --git a/packages/omgx/wallet-frontend/src/services/networkService.js b/packages/omgx/wallet-frontend/src/services/networkService.js index 6ac9b3d33197..2ef0943bc55c 100644 --- a/packages/omgx/wallet-frontend/src/services/networkService.js +++ b/packages/omgx/wallet-frontend/src/services/networkService.js @@ -1101,10 +1101,10 @@ class NetworkService { const UUID = address.substring(1, 6) + '_' + tokenID.toString() + '_' + this.account.substring(1, 6) - const { url , attributes = []} = await getNftImageUrl(meta[1]); + const { url , attributes = []} = await getNftImageUrl(meta[1]) + // Uncomment Just to test locally // const { url , attributes = []} = await getNftImageUrl('https://boredapeyachtclub.com/api/mutants/111'); - // const { url , attributes = []} = await getNftImageUrl('ipfs://QmeSjSinHpPnmXmspMjwiXyN6zS4E9zccariGR3jxcaWtq/6190'); const NFT = { From 129b22c26ee8885757175eb9956d899cc36085bf Mon Sep 17 00:00:00 2001 From: cby3149 <46272347+cby3149@users.noreply.github.com> Date: Thu, 16 Sep 2021 11:40:19 -0700 Subject: [PATCH 03/24] Update addresses (#468) --- .../contracts/deployment/mainnet/addressess.json | 12 ++++++------ .../src/deployment/mainnet/addresses.json | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/omgx/contracts/deployment/mainnet/addressess.json b/packages/omgx/contracts/deployment/mainnet/addressess.json index 6657c710cbe6..8c75e9f37c6e 100644 --- a/packages/omgx/contracts/deployment/mainnet/addressess.json +++ b/packages/omgx/contracts/deployment/mainnet/addressess.json @@ -5,12 +5,12 @@ "L2": "0xeDB79B0FD84c81E870b2fCB1D3CcF366179bA6D2" } }, - "OVM_L1CrossDomainMessengerFast": "0x68ac1623ACf9eB9F88b65B5F229fE3e2c0d5789e", - "Proxy__OVM_L1CrossDomainMessengerFast": "0x841979bbC06Be7BFE28d9FadDac1A73e1Fb495C1", - "L2LiquidityPool": "0x9C133903F299f083F2ba4A7DAeb142643Fe1864D", - "L1LiquidityPool": "0x87b6C838486c836a1fb16716Df25D8E023fd541C", - "Proxy__L1LiquidityPool": "0x3256BD6Fc8b5fA48DB95914d0dF314465F3F7879", - "Proxy__L2LiquidityPool": "0x02fc14bC0dF6452FCC36496244eE2D043401582F", + "OVM_L1CrossDomainMessengerFast": "0xb7E757633857C2E6Ec7aab362c17E7a5913B4855", + "Proxy__OVM_L1CrossDomainMessengerFast": "0xD05b8fD53614e1569cAC01c6D8d41416d0a7257E", + "L2LiquidityPool": "0xB1a1B698E4c67c242441749C22575FA02B14D645", + "L1LiquidityPool": "0x3d95bE575576F813B9b18eE14ba041d3E013eC25", + "Proxy__L1LiquidityPool": "0x1A26ef6575B7BBB864d984D9255C069F6c361a14", + "Proxy__L2LiquidityPool": "0x3A92cA39476fF84Dc579C868D4D7dE125513B034", "L2ERC721": "0xe7dc303281a6B69D86578EB596741cA1B8EFcD93", "L2ERC721Reg": "0x967c403E64A316d0Cb04c97334F967a37d58d82f" } diff --git a/packages/omgx/wallet-frontend/src/deployment/mainnet/addresses.json b/packages/omgx/wallet-frontend/src/deployment/mainnet/addresses.json index 69637198458f..ecf9ec9cf7ca 100644 --- a/packages/omgx/wallet-frontend/src/deployment/mainnet/addresses.json +++ b/packages/omgx/wallet-frontend/src/deployment/mainnet/addresses.json @@ -57,12 +57,12 @@ "L2": "0xeDB79B0FD84c81E870b2fCB1D3CcF366179bA6D2" } }, - "L2LiquidityPool": "0x9C133903F299f083F2ba4A7DAeb142643Fe1864D", - "L1LiquidityPool": "0x87b6C838486c836a1fb16716Df25D8E023fd541C", - "Proxy__L1LiquidityPool": "0x3256BD6Fc8b5fA48DB95914d0dF314465F3F7879", - "Proxy__L2LiquidityPool": "0x02fc14bC0dF6452FCC36496244eE2D043401582F", - "OVM_L1CrossDomainMessengerFast": "0x68ac1623ACf9eB9F88b65B5F229fE3e2c0d5789e", - "Proxy__OVM_L1CrossDomainMessengerFast": "0x841979bbC06Be7BFE28d9FadDac1A73e1Fb495C1", + "L2LiquidityPool": "0xB1a1B698E4c67c242441749C22575FA02B14D645", + "L1LiquidityPool": "0x3d95bE575576F813B9b18eE14ba041d3E013eC25", + "Proxy__L1LiquidityPool": "0x1A26ef6575B7BBB864d984D9255C069F6c361a14", + "Proxy__L2LiquidityPool": "0x3A92cA39476fF84Dc579C868D4D7dE125513B034", + "OVM_L1CrossDomainMessengerFast": "0xb7E757633857C2E6Ec7aab362c17E7a5913B4855", + "Proxy__OVM_L1CrossDomainMessengerFast": "0xD05b8fD53614e1569cAC01c6D8d41416d0a7257E", "L2TokenPool": "0x82B178EE692572e21D73d5F1ebC1c7c438Fc52DD", "AtomicSwap": "0xfCc9525fDDbafbD3393821F7dAf96F68Bba93294", "L1Message": "0x1E7C2Ed00FaaFeD62afC9DD630ACB8C8c6C16D52", From 5ac2cce1b700a1debb393967b2d092f91c7b8b0f Mon Sep 17 00:00:00 2001 From: CAPtheorem <79423264+CAPtheorem@users.noreply.github.com> Date: Thu, 16 Sep 2021 20:43:49 -0700 Subject: [PATCH 04/24] Fix display bug for token with 6 decimals --- .../wallet-frontend/src/components/listAccount/listAccount.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/omgx/wallet-frontend/src/components/listAccount/listAccount.js b/packages/omgx/wallet-frontend/src/components/listAccount/listAccount.js index 08036cc79613..828697ec69bd 100644 --- a/packages/omgx/wallet-frontend/src/components/listAccount/listAccount.js +++ b/packages/omgx/wallet-frontend/src/components/listAccount/listAccount.js @@ -82,7 +82,7 @@ class ListAccount extends React.Component { - {`${logAmount(token.balance, 18, 2)}`} + {`${logAmount(token.balance, token.decimals, 2)}`} From 9eb8f8c24b25d02712fe96884a6bda6d84248016 Mon Sep 17 00:00:00 2001 From: CAPtheorem <79423264+CAPtheorem@users.noreply.github.com> Date: Fri, 17 Sep 2021 13:11:31 -0700 Subject: [PATCH 05/24] Add FAQ to gateway --- .../src/components/listFarm/listFarm.js | 12 ++- .../src/components/mainMenu/menuItems.js | 6 ++ .../mainMenu/menuItems/MenuItems.js | 13 +-- .../src/containers/help/Help.js | 86 +++++++++++++++++++ .../src/containers/help/Help.module.scss | 67 +++++++++++++++ .../src/containers/home/Home.js | 13 ++- .../src/deployment/mainnet/addresses.json | 2 +- 7 files changed, 188 insertions(+), 11 deletions(-) create mode 100644 packages/omgx/wallet-frontend/src/containers/help/Help.js create mode 100644 packages/omgx/wallet-frontend/src/containers/help/Help.module.scss diff --git a/packages/omgx/wallet-frontend/src/components/listFarm/listFarm.js b/packages/omgx/wallet-frontend/src/components/listFarm/listFarm.js index bd73a0cd87e8..5d75a6552bfb 100644 --- a/packages/omgx/wallet-frontend/src/components/listFarm/listFarm.js +++ b/packages/omgx/wallet-frontend/src/components/listFarm/listFarm.js @@ -168,12 +168,16 @@ class ListFarm extends React.Component { // networkService.L1OrL2 L1: || L2 const disabled = !L1orL2Pool.includes(networkService.L1orL2) const symbol = poolInfo.symbol - const name = poolInfo.name + let name = poolInfo.name const decimals = poolInfo.decimals - const logo = getCoinImage(symbol) + let logo = getCoinImage(symbol) + + //Deal with Token migration to REPv2 + if( symbol === 'REPv2' ) { + name = 'AUGUR (REPv2)' + logo = getCoinImage('REP') + } - //console.log('poolinfo',poolInfo) - if(!showAll) { if(!Number(logAmount(poolInfo.tokenBalance, decimals, 2))) { return null; diff --git a/packages/omgx/wallet-frontend/src/components/mainMenu/menuItems.js b/packages/omgx/wallet-frontend/src/components/mainMenu/menuItems.js index da40af548b98..21bc253459dd 100644 --- a/packages/omgx/wallet-frontend/src/components/mainMenu/menuItems.js +++ b/packages/omgx/wallet-frontend/src/components/mainMenu/menuItems.js @@ -29,4 +29,10 @@ export const menuItems = [ title: "DAO", url: "/dao" }, + { + key: 'Help', + icon: "HelpIcon", + title: "Help/FAQ", + url: "/help" + }, ] diff --git a/packages/omgx/wallet-frontend/src/components/mainMenu/menuItems/MenuItems.js b/packages/omgx/wallet-frontend/src/components/mainMenu/menuItems/MenuItems.js index 105dc29db243..9477134f88f4 100644 --- a/packages/omgx/wallet-frontend/src/components/mainMenu/menuItems/MenuItems.js +++ b/packages/omgx/wallet-frontend/src/components/mainMenu/menuItems/MenuItems.js @@ -8,9 +8,11 @@ import WalletIcon from 'components/icons/WalletIcon' import HistoryIcon from 'components/icons/HistoryIcon' import NFTIcon from 'components/icons/NFTIcon' import DAOIcon from 'components/icons/DAOIcon' -import { useDispatch, useSelector } from 'react-redux'; -import { selectModalState } from 'selectors/uiSelector'; -import { setPage } from 'actions/uiAction'; +import HelpIcon from 'components/icons/LearnIcon' + +import { useDispatch, useSelector } from 'react-redux' +import { selectModalState } from 'selectors/uiSelector' +import { setPage } from 'actions/uiAction' function MenuItems ({setOpen }) { @@ -19,14 +21,15 @@ function MenuItems ({setOpen }) { const isLight = theme.palette.mode === 'light' const colorIcon = theme.palette.common[isLight ? 'black' : 'white'] const pageDisplay = useSelector(selectModalState('page')) - const dispatch = useDispatch(); + const dispatch = useDispatch() const iconObj = { WalletIcon, EarnIcon, HistoryIcon, NFTIcon, - DAOIcon + DAOIcon, + HelpIcon } return ( diff --git a/packages/omgx/wallet-frontend/src/containers/help/Help.js b/packages/omgx/wallet-frontend/src/containers/help/Help.js new file mode 100644 index 000000000000..048a014e9851 --- /dev/null +++ b/packages/omgx/wallet-frontend/src/containers/help/Help.js @@ -0,0 +1,86 @@ +import React from 'react' +import { connect } from 'react-redux' + +import * as styles from './Help.module.scss' + +import { Grid, Typography } from '@material-ui/core' +import PageHeader from 'components/pageHeader/PageHeader' + +class Help extends React.Component { + + constructor(props) { + + super(props) + + this.state = { + } + + } + + componentDidMount() { + + } + + componentDidUpdate(prevState) { + + } + + render() { + + return ( + <> + + + + + Common Questions + + + + L1 to L2 Deposits not working
+ Please make sure that you are using a current version of MetaMask, for example, 10.1.0. +
+ + + Transactions failing silently?
+ Please use your browser's developer + console to see the error message and then please check the project's{' '} + GitHub issues list{' '} + to see if other people have had the same problem. If not, please file a new GitHub issue. +
+ + + DAO not active yet
+ The DAO is pending and is not yet live. + +
+ + + It would be really nice if...
+ We love hearing about new features that you would like. Please file suggestions, + prefaced with `Gateway Feature`, in our{' '} + GitHub issues list. + Expect a turnaround time of several days for us to be able to consider new UI/GateWay features. + Keep in mind that this is an opensource project, so help out, + {' '}git clone, + {' '}yarn, and + {' '}yarn start, + and then open a PR. +
+ +
+ + + ) + } +} + +const mapStateToProps = state => ({ + +}) + +export default connect(mapStateToProps)(Help) diff --git a/packages/omgx/wallet-frontend/src/containers/help/Help.module.scss b/packages/omgx/wallet-frontend/src/containers/help/Help.module.scss new file mode 100644 index 000000000000..56ef28ea26dc --- /dev/null +++ b/packages/omgx/wallet-frontend/src/containers/help/Help.module.scss @@ -0,0 +1,67 @@ +@import 'index.scss'; + +.container { + display: flex; + flex-direction: column; + padding: 10px; + padding-top: 0px; + + .header { + h2 { + margin-bottom: 0; + padding-left: 10px; + color: $white; + } + + display: flex; + flex-direction: row; + justify-content: space-between; + align-items: center; + } + + .content { + margin: 10px auto; + display: flex; + flex-direction: column; + width: 100%; + + .action { + display: flex; + flex-direction: row; + justify-content: space-around; + align-items: center; + + .transferContainer, .delegateContainer { + margin: auto; + border-radius: 12px; + padding: 20px; + display: flex; + flex-direction: column; + background: $background400; + max-width: 40%; + width: 40%; + min-width: 400px; + .info { + text-align: center; + .title { + font-size: 1.4em; + color: $white; + } + .subTitle { + font-size: 1.2em; + color: $white700; + margin: 10px; + } + .helpText { + font-size: 0.8em; + margin: 10px; + color: $white700; + margin: 10px; + } + } + } + + } + } + +} \ No newline at end of file diff --git a/packages/omgx/wallet-frontend/src/containers/home/Home.js b/packages/omgx/wallet-frontend/src/containers/home/Home.js index c48a59a30f4f..9011031325dd 100644 --- a/packages/omgx/wallet-frontend/src/containers/home/Home.js +++ b/packages/omgx/wallet-frontend/src/containers/home/Home.js @@ -49,12 +49,20 @@ import TransferDaoModal from 'containers/modals/dao/TransferDaoModal' import DelegateDaoModal from 'containers/modals/dao/DelegateDaoModal' import NewProposalModal from 'containers/modals/dao/NewProposalModal' -import { fetchDaoBalance, fetchDaoVotes, fetchDaoProposals, getProposalThreshold } from 'actions/daoAction' +import { + fetchDaoBalance, + fetchDaoVotes, + fetchDaoProposals, + getProposalThreshold +} from 'actions/daoAction' //Wallet Functions import Account from 'containers/account/Account' import Transactions from 'containers/transactions/History' +//Help page +import Help from 'containers/help/Help' + //NFT Example Page import NFT from 'containers/nft/Nft' @@ -204,6 +212,9 @@ function Home () { {pageDisplay === "DAO" && } + {pageDisplay === "Help" && + + } diff --git a/packages/omgx/wallet-frontend/src/deployment/mainnet/addresses.json b/packages/omgx/wallet-frontend/src/deployment/mainnet/addresses.json index ecf9ec9cf7ca..d0e2b94a82ad 100644 --- a/packages/omgx/wallet-frontend/src/deployment/mainnet/addresses.json +++ b/packages/omgx/wallet-frontend/src/deployment/mainnet/addresses.json @@ -24,7 +24,7 @@ "L1": "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599", "L2": "0xdc0486f8bf31DF57a952bcd3c1d3e166e3d9eC8b" }, - "REP": { + "REPV2": { "L1": "0x221657776846890989a759ba2973e427dff5c9bb", "L2": "0x8b5B1E971862015bc058234FC11ce6C4a4c536dD" }, From b8704a080202472c53bc37860b7ccc4aa55726ee Mon Sep 17 00:00:00 2001 From: CAPtheorem <79423264+CAPtheorem@users.noreply.github.com> Date: Fri, 17 Sep 2021 17:48:14 -0700 Subject: [PATCH 06/24] add FAQ, remove legacy gas picker, clarify REPv2 support (#471) --- .../src/actions/networkAction.js | 54 +------------ .../src/api/ethGasStationAxios.js | 9 --- .../src/components/gaspicker/GasPicker.js | 80 ------------------- .../components/gaspicker/GasPicker.styles.js | 15 ---- .../src/containers/account/Account.js | 12 +-- .../wallet-frontend/src/containers/dao/Dao.js | 2 +- .../modals/deposit/steps/InputStep.js | 16 +--- .../src/services/networkService.js | 47 ++--------- 8 files changed, 15 insertions(+), 220 deletions(-) delete mode 100644 packages/omgx/wallet-frontend/src/api/ethGasStationAxios.js delete mode 100644 packages/omgx/wallet-frontend/src/components/gaspicker/GasPicker.js delete mode 100644 packages/omgx/wallet-frontend/src/components/gaspicker/GasPicker.styles.js diff --git a/packages/omgx/wallet-frontend/src/actions/networkAction.js b/packages/omgx/wallet-frontend/src/actions/networkAction.js index 4f0cea4749d9..6eb0636d1ca3 100644 --- a/packages/omgx/wallet-frontend/src/actions/networkAction.js +++ b/packages/omgx/wallet-frontend/src/actions/networkAction.js @@ -67,16 +67,16 @@ export function depositL2LP(token, value) { } //DEPOSIT ETH -export function depositETHL2(value, gasLimit) { +export function depositETHL2(value) { return createAction('DEPOSIT/CREATE', () => - networkService.depositETHL2(value,gasLimit) + networkService.depositETHL2(value) ) } //DEPOSIT ERC20 -export function depositErc20(value, currency, gasPrice, currencyL2) { +export function depositErc20(value, currency, currencyL2) { return createAction('DEPOSIT/CREATE', () => - networkService.depositErc20(value, currency, gasPrice, currencyL2) + networkService.depositErc20(value, currency, currencyL2) ) } @@ -120,58 +120,12 @@ export function approveERC20_L1LP( ) } -// Never used? -// export function resetApprove( -// value, -// currency, -// approveContractAddress, -// contractABI -// ) { -// return createAction('APPROVE/RESET', () => -// networkService.resetApprove( -// value, -// currency, -// approveContractAddress, -// contractABI -// ) -// ) -// } - export function transfer(recipient, value, currency) { return createAction('TRANSFER/CREATE', () => networkService.transfer(recipient, value, currency) ) } -export function fetchGas (params) { - return createAction('GAS/GET', () => networkService.getGasPrice(params) - ) -} - -// export function fetchFees () { -// return async function (dispatch) { -// // only makes the call if fee fetch not successful before -// const state = store.getState(); -// if (Object.keys(state.fees).length) { -// return; -// } - -// dispatch({ type: 'FEE/GET/REQUEST' }); -// try { -// const fees = await networkService.fetchFees(); -// if (fees.length) { -// dispatch({ -// type: 'FEE/GET/SUCCESS', -// payload: fees -// }); -// } -// } catch (error) { -// console.warn('Couldnt fetch fees, retrying...'); -// return; -// } -// }; -// } - export function fetchLookUpPrice(params) { return createAction('PRICE/GET', () => networkService.fetchLookUpPrice(params)) diff --git a/packages/omgx/wallet-frontend/src/api/ethGasStationAxios.js b/packages/omgx/wallet-frontend/src/api/ethGasStationAxios.js deleted file mode 100644 index 017d64276cd6..000000000000 --- a/packages/omgx/wallet-frontend/src/api/ethGasStationAxios.js +++ /dev/null @@ -1,9 +0,0 @@ -import axios from 'axios' - -import { getBaseServices } from 'util/masterConfig' - -const _ethGasStationAxiosInstance = axios.create({ - baseURL: getBaseServices().ETH_GAS_STATION_URL, -}) - -export default _ethGasStationAxiosInstance diff --git a/packages/omgx/wallet-frontend/src/components/gaspicker/GasPicker.js b/packages/omgx/wallet-frontend/src/components/gaspicker/GasPicker.js deleted file mode 100644 index 1de3736281f2..000000000000 --- a/packages/omgx/wallet-frontend/src/components/gaspicker/GasPicker.js +++ /dev/null @@ -1,80 +0,0 @@ -/* -Copyright 2019-present OmiseGO Pte Ltd - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. */ - -import { Box, CardActionArea, Grid, Typography } from '@material-ui/core'; -import React, { useEffect } from 'react'; -import { useSelector } from 'react-redux'; - -import { selectGas } from 'selectors/gasSelector'; -import * as S from './GasPicker.styles' - -function GasPicker ({ selectedSpeed, setSelectedSpeed, setGasPrice }) { - const gas = useSelector(selectGas); - - useEffect(() => { - setGasPrice(gas[selectedSpeed]); - }, [ selectedSpeed, gas, setGasPrice ]); - - return ( - - - Gas Fee - - - - - - setSelectedSpeed('slow')}> - - Slow - {gas.slow / 1000000000} gwei - - - - - - - - setSelectedSpeed('normal')}> - - Normal - {gas.normal / 1000000000} gwei - - - - - - - - setSelectedSpeed('fast')}> - - Fast - {gas.fast / 1000000000} gwei - - - - - - - - ); -} - -export default React.memo(GasPicker); diff --git a/packages/omgx/wallet-frontend/src/components/gaspicker/GasPicker.styles.js b/packages/omgx/wallet-frontend/src/components/gaspicker/GasPicker.styles.js deleted file mode 100644 index 0724404e101e..000000000000 --- a/packages/omgx/wallet-frontend/src/components/gaspicker/GasPicker.styles.js +++ /dev/null @@ -1,15 +0,0 @@ -import { styled } from '@material-ui/system'; -import { Box, Card } from '@material-ui/core'; - -export const CardTag = styled(Card)` - border: ${(props) => props.selected ? '2px solid #F0A000' : '2px solid #3A3F51'}; - opacity: ${(props) => props.selected ? 1.0 : 0.4}; - background-color: ${(props) => props.theme.palette.background.secondary}; -`; - -export const WrapperItem = styled(Box)` - display: flex; - align-items: center; - justify-content: space-between; - padding: 18px 16px; -`; diff --git a/packages/omgx/wallet-frontend/src/containers/account/Account.js b/packages/omgx/wallet-frontend/src/containers/account/Account.js index 020db33a8974..49bb67a8f132 100644 --- a/packages/omgx/wallet-frontend/src/containers/account/Account.js +++ b/packages/omgx/wallet-frontend/src/containers/account/Account.js @@ -30,7 +30,7 @@ import * as S from './Account.styles' import { selectTokens } from 'selectors/tokenSelector' import PageHeader from 'components/pageHeader/PageHeader' import { Box, Grid, Tab, Tabs, Typography, useMediaQuery } from '@material-ui/core' -import { fetchGas, fetchLookUpPrice, fetchTransactions } from 'actions/networkAction' +import { fetchLookUpPrice, fetchTransactions } from 'actions/networkAction' import { selectNetwork } from 'selectors/setupSelector' import { useTheme } from '@emotion/react' import { tableHeadList } from './tableHeadList' @@ -104,17 +104,9 @@ function Account () { ...pendingL2 ] - const getGasPrice = useCallback(() => { - dispatch(fetchGas({ - network: network || 'local', - networkLayer - })) - }, [dispatch, network, networkLayer]) - useEffect(()=>{ getLookupPrice() - getGasPrice() - },[childBalance, rootBalance, getLookupPrice, getGasPrice]) + },[childBalance, rootBalance, getLookupPrice]) useInterval(() => { batch(() => { diff --git a/packages/omgx/wallet-frontend/src/containers/dao/Dao.js b/packages/omgx/wallet-frontend/src/containers/dao/Dao.js index bf8eab051cbd..287ba7ffb9e1 100644 --- a/packages/omgx/wallet-frontend/src/containers/dao/Dao.js +++ b/packages/omgx/wallet-frontend/src/containers/dao/Dao.js @@ -100,7 +100,7 @@ function DAO() {
{balance} Comp Wallet Balance - To transfer goveranance tokens to another wallet, select "Transfer". + To transfer governance tokens to another wallet, select "Transfer".
: <> - {`${name}`} Staked + {`${symbol}`} Staked {logAmount(userInfo.amount, decimals)}
} + ) } diff --git a/packages/omgx/wallet-frontend/src/components/listAccount/listAccount.js b/packages/omgx/wallet-frontend/src/components/listAccount/listAccount.js index 828697ec69bd..ba58b1efe1b0 100644 --- a/packages/omgx/wallet-frontend/src/components/listAccount/listAccount.js +++ b/packages/omgx/wallet-frontend/src/components/listAccount/listAccount.js @@ -62,7 +62,7 @@ class ListAccount extends React.Component { dropDownBox, networkLayer, disabled - } = this.state; + } = this.state const enabled = (networkLayer === chain) ? true : false const logo = getCoinImage(token.symbol) @@ -97,12 +97,12 @@ class ListAccount extends React.Component { > {chain === 'L1' && - Deposit + Bridge } {chain === 'L2' && - Transact + Bridge and Transfer } @@ -160,9 +160,10 @@ class ListAccount extends React.Component { color='neutral' variant="outlined" disabled={disabled} + tooltip="Classic Bridge to Boba L2. This option is always available but is generally more expensive than the swap-based system ('Fast Bridge')." fullWidth > - Deposit + Bridge } @@ -183,24 +185,27 @@ class ListAccount extends React.Component { onClick={()=>{this.handleModalClick('exitModal', token, false)}} variant="outlined" disabled={disabled} + tooltip="Classic Bridge to L1. This option is always available but has a 7 day delay before receiving your funds." fullWidth > - Standard Exit + Bridge to L1 diff --git a/packages/omgx/wallet-frontend/src/containers/modals/deposit/steps/InputStepFast.js b/packages/omgx/wallet-frontend/src/containers/modals/deposit/steps/InputStepFast.js index 6a143a91ca98..0b54074b66b9 100644 --- a/packages/omgx/wallet-frontend/src/containers/modals/deposit/steps/InputStepFast.js +++ b/packages/omgx/wallet-frontend/src/containers/modals/deposit/steps/InputStepFast.js @@ -68,7 +68,7 @@ function InputStepFast({ handleClose, token }) { if(token.symbol === 'ETH') { - console.log("ETH Fast swap on") + console.log("ETH Fast Bridge") if (valueIsValid) { res = await dispatch(depositL1LP(token.address, value, token.decimals)) @@ -76,7 +76,7 @@ function InputStepFast({ handleClose, token }) { dispatch(setActiveHistoryTab1('Deposits')) dispatch( openAlert( - `ETH was deposited into the L1LP. You will receive + `ETH was bridged into the L1LP. You will receive ${((Number(value) * (100 - Number(feeRate)))/100).toFixed(2)} oETH on L2` ) @@ -84,14 +84,14 @@ function InputStepFast({ handleClose, token }) { handleClose() return } else { - dispatch(openError('Failed to deposit ETH')) + dispatch(openError('Failed to bridge ETH')) return } } } //at this point we know it's not ETH - console.log("ERC20 Fast swap on") + console.log("ERC20 Fast Bridge") res = await dispatch( approveERC20( @@ -113,13 +113,13 @@ function InputStepFast({ handleClose, token }) { dispatch(setActiveHistoryTab1('Deposits')) dispatch( openAlert( - `${token.symbol} was deposited to the L1LP. You will receive + `${token.symbol} was bridged to the L1LP. You will receive ${receivableAmount(value)} ${token.symbol} on L2` ) ) handleClose() } else { - dispatch(openError('Failed to deposit ERC20')) + dispatch(openError('Failed to bridge ERC20')) } } @@ -152,10 +152,10 @@ function InputStepFast({ handleClose, token }) { let buttonLabel_1 = 'CANCEL' if( depositLoading || approvalLoading ) buttonLabel_1 = 'CLOSE WINDOW' - let buttonLabel_2 = 'Deposit' + let buttonLabel_2 = 'Bridge' if(depositLoading) { - buttonLabel_2 = "Depositing..." + buttonLabel_2 = "Bridging..." } else if (approvalLoading) { buttonLabel_2 = "Approving..." } @@ -167,13 +167,13 @@ function InputStepFast({ handleClose, token }) { <> - Fast Deposit + Fast Bridge {label} - The liquidity pool balance (of {LPBalance}) is too low to cover your fast deposit. Please - use the traditional deposit or reduce the amount. + The liquidity pool balance (of {LPBalance}) is too low to cover your fast bridge. Please + use the traditional bridge or reduce the amount. )} @@ -223,7 +223,7 @@ function InputStepFast({ handleClose, token }) { color='primary' variant="contained" loading={depositLoading || approvalLoading} - tooltip="Your deposit is still pending. Please wait for confirmation." + tooltip={depositLoading ? "Your bridge is still pending. Please wait for confirmation." : "Click here to bridge your funds to L2"} disabled={disabledSubmit} triggerTime={new Date()} size="large" diff --git a/packages/omgx/wallet-frontend/src/containers/modals/exit/steps/DoExitStep.js b/packages/omgx/wallet-frontend/src/containers/modals/exit/steps/DoExitStep.js index 3d30a61ceea5..09431f9acd4d 100644 --- a/packages/omgx/wallet-frontend/src/containers/modals/exit/steps/DoExitStep.js +++ b/packages/omgx/wallet-frontend/src/containers/modals/exit/steps/DoExitStep.js @@ -61,14 +61,14 @@ function DoExitStep({ handleClose, token }) { if (res) { dispatch( openAlert( - `${token.symbol} was exited to L1. You will receive + `${token.symbol} was bridged to L1. You will receive ${Number(value).toFixed(2)} ${currencyL1} on L1 in 7 days.` ) ) handleClose() } else { - dispatch(openError(`Failed to exit L2`)) + dispatch(openError(`Failed to bridge to L1`)) } } @@ -102,11 +102,11 @@ function DoExitStep({ handleClose, token }) { <> - Standard Exit ({`${token ? token.symbol : ''}`}) + Classic Bridge to L1 ({`${token ? token.symbol : ''}`}) - Exit + Bridge to L1 )} diff --git a/packages/omgx/wallet-frontend/src/containers/modals/exit/steps/DoExitStepFast.js b/packages/omgx/wallet-frontend/src/containers/modals/exit/steps/DoExitStepFast.js index d42e91aecc2d..9730a07aa135 100644 --- a/packages/omgx/wallet-frontend/src/containers/modals/exit/steps/DoExitStepFast.js +++ b/packages/omgx/wallet-frontend/src/containers/modals/exit/steps/DoExitStepFast.js @@ -87,7 +87,7 @@ function DoExitStepFast({ handleClose, token }) { You will receive ${receivableAmount(value)} ${currencyL1} on L1.`)) handleClose() } else { - dispatch(openError(`Failed to fast exit funds from L2`)); + dispatch(openError(`Failed to fast bridge funds to L1`)) } } @@ -128,13 +128,13 @@ function DoExitStepFast({ handleClose, token }) { <> - Fast Exit + Fast Bridge to L1 {feeLabel} - The liquidity pool balance (of {LPBalance}) is too low to cover your exit - please - use the traditional exit or reduce the amount to exit. + The liquidity pool balance (of {LPBalance}) is too low to cover your bridge - please + use the classic bridge or reduce the amount. )} @@ -196,13 +196,13 @@ function DoExitStepFast({ handleClose, token }) { color='primary' variant='contained' loading={exitLoading} - tooltip='Your exit is still pending. Please wait for confirmation.' + tooltip={exitLoading ? "Your bridge is still pending. Please wait for confirmation." : "Click here to bridge your funds to L1"} disabled={disabledSubmit} triggerTime={new Date()} fullWidth={isMobile} size='large' > - Exit L2 + Bridge to L2 diff --git a/packages/omgx/wallet-frontend/src/containers/modals/transfer/TransferModal.js b/packages/omgx/wallet-frontend/src/containers/modals/transfer/TransferModal.js index 2ceadc1ca618..364d6db86d81 100644 --- a/packages/omgx/wallet-frontend/src/containers/modals/transfer/TransferModal.js +++ b/packages/omgx/wallet-frontend/src/containers/modals/transfer/TransferModal.js @@ -21,11 +21,11 @@ import { transfer } from 'actions/networkAction'; import { closeModal, openAlert } from 'actions/uiAction'; import { selectLoading } from 'selectors/loadingSelector'; -import Button from 'components/button/Button'; -import Modal from 'components/modal/Modal'; +import Button from 'components/button/Button' +import Modal from 'components/modal/Modal' import { amountToUsd, logAmount } from 'util/amountConvert' -import networkService from 'services/networkService'; +import networkService from 'services/networkService' import Input from 'components/input/Input'; import { selectLookupPrice } from 'selectors/lookupSelector'; diff --git a/packages/omgx/wallet-frontend/src/containers/modals/wrongnetwork/WrongNetworkModal.js b/packages/omgx/wallet-frontend/src/containers/modals/wrongnetwork/WrongNetworkModal.js index 71e8341eb8d6..97479b90e5f7 100644 --- a/packages/omgx/wallet-frontend/src/containers/modals/wrongnetwork/WrongNetworkModal.js +++ b/packages/omgx/wallet-frontend/src/containers/modals/wrongnetwork/WrongNetworkModal.js @@ -15,7 +15,10 @@ limitations under the License. */ import React from 'react'; import { useDispatch } from 'react-redux' + +import Button from 'components/button/Button' import Modal from 'components/modal/Modal' + import { closeModal } from 'actions/uiAction' import ArrowUpwardIcon from '@material-ui/icons/ArrowUpward' @@ -26,8 +29,11 @@ import { ReactComponent as Fox } from './../../../images/icons/fox-icon.svg' import { ReactComponent as Account } from './../../../images/icons/mm-account.svg' import { getAllNetworks } from 'util/masterConfig' + import store from 'store' +import networkService from 'services/networkService' + import * as styles from './WrongNetworkModal.module.scss' import { useTheme } from '@emotion/react' @@ -37,6 +43,19 @@ function WrongNetworkModal ({ open, onClose }) { const nw = getAllNetworks() const masterConfig = store.getState().setup.masterConfig + const networkLayer = store.getState().setup.netLayer + + /* + This is fired if the internal setting of the gateway does not match the + MetaMask configuration. There are multiple networks (e.g. mainent and rinkeby), + and multiple layers, e.g. L1 and L2 + */ + + console.log("WNM masterConfig",masterConfig) + console.log("WNM networkLayer",networkLayer) + + //Next figure out the right labels and targets + const textLabel = nw[masterConfig].MM_Label const iconLabel = nw[masterConfig].MM_Label @@ -48,6 +67,11 @@ function WrongNetworkModal ({ open, onClose }) { dispatch(closeModal('wrongNetworkModal')) } + async function correctChain() { + console.log("Correcting the chain") + const res = await networkService.correctChain( networkLayer ) + } + return ( - Please Change Network + Incorrect Network - - To use "{textLabel}", please switch MetaMask to that network. + + To use {textLabel}, please change network. - + + + + Or, you can change manually, by going to MetaMask and + clicking in the top bar. + + +
@@ -74,8 +114,9 @@ function WrongNetworkModal ({ open, onClose }) {
+ ); } -export default React.memo(WrongNetworkModal); +export default React.memo(WrongNetworkModal) diff --git a/packages/omgx/wallet-frontend/src/containers/modals/wrongnetwork/WrongNetworkModal.module.scss b/packages/omgx/wallet-frontend/src/containers/modals/wrongnetwork/WrongNetworkModal.module.scss index 735d45a44b3e..f5f9fe0ce71c 100644 --- a/packages/omgx/wallet-frontend/src/containers/modals/wrongnetwork/WrongNetworkModal.module.scss +++ b/packages/omgx/wallet-frontend/src/containers/modals/wrongnetwork/WrongNetworkModal.module.scss @@ -3,8 +3,8 @@ .metamask { background: #F2F3F4; border: 1px solid #A9A9A9; - width: 350px; - height: 55px; + width: 300px; + height: 45px; border-radius: 2px; display: flex; flex-direction: row; diff --git a/packages/omgx/wallet-frontend/src/reducers/setupReducer.js b/packages/omgx/wallet-frontend/src/reducers/setupReducer.js index bc784ba7b5b3..8c6622d7d1ae 100644 --- a/packages/omgx/wallet-frontend/src/reducers/setupReducer.js +++ b/packages/omgx/wallet-frontend/src/reducers/setupReducer.js @@ -35,7 +35,7 @@ const initialState = { etherscan: '', minter: false, netLayer: netLayerCache ? netLayerCache : 'L1' -}; +} function setupReducer (state = initialState, action) { switch (action.type) { diff --git a/packages/omgx/wallet-frontend/src/services/networkService.js b/packages/omgx/wallet-frontend/src/services/networkService.js index bc7fa45c488f..00b2a05ee522 100644 --- a/packages/omgx/wallet-frontend/src/services/networkService.js +++ b/packages/omgx/wallet-frontend/src/services/networkService.js @@ -611,6 +611,114 @@ class NetworkService { } + /* Yes, this almost complete dupicates async switchChain( layer ) + but that's safest for now */ + async correctChain( targetLayer ) { + + const nw = getAllNetworks() + const masterConfig = store.getState().setup.masterConfig + + //the chainParams are only needed for the L2's + const chainParam = { + chainId: '0x' + nw[masterConfig].L2.chainId.toString(16), + chainName: nw[masterConfig].L2.name, + rpcUrls: [nw[masterConfig].L2.rpcUrl], + blockExplorerUrls: [nw[masterConfig].L2.blockExplorer.slice(0, -1)], + } + + // connect to the wallet + this.provider = new ethers.providers.Web3Provider(window.ethereum) + + /********************* Switch to Mainnet L2 ****************/ + if (masterConfig === 'mainnet' && targetLayer === 'L2') { + //ok, so then, we want to switch to 'mainnet' && 'L2' + try { + await this.provider.send('wallet_switchEthereumChain', [{ chainId: '0x120' }]) //ChainID 288 + } catch (error) { + // This error code indicates that the chain has not been added to MetaMask. + if (error.code === 4902) { + try { + await this.provider.send('wallet_addEthereumChain', [chainParam, this.account]) + } catch (addError) { + console.log("MetaMask - Error adding new RPC: ", addError) + // handle "add" error via alert message + } + } else { //some other error code + console.log("MetaMask - Switch Error: ", error.code) + } + } + } else if ( masterConfig === 'mainnet' && targetLayer === 'L1') { + //ok, so then, we want to switch to 'mainnet' && 'L1' - no need to add + //if(fail) since mainnet L1 is always there unless the planet + //has been vaporized by space aliens with a blaster ray + try { + await this.provider.send('wallet_switchEthereumChain',[{ chainId: '0x1' }]) //ChainID 1 + } catch (switchError) { + console.log("MetaMask - could not switch to Ethereum Mainchain. Needless to say, this should never happen.") + } + } else if (masterConfig === 'rinkeby' && targetLayer === 'L2') { + //ok, so then, we want to switch to 'rinkeby' && 'L2' + try { + await this.provider.send('wallet_switchEthereumChain', [{ chainId: '0x1C' }]) //ChainID 28 + } catch (error) { + if (error.code === 4902) { + try { + await this.provider.send('wallet_addEthereumChain', [chainParam, this.account]) + } catch (addError) { + console.log("MetaMask - Error adding new RPC: ", addError) + // handle "add" error via alert message + } + } else { //some other error code + console.log("MetaMask - Switch Error: ", error.code) + } + } + } else if (masterConfig === 'rinkeby_integration' && targetLayer === 'L2') { + //ok, so then, we want to switch to 'rinkeby_integration' && 'L2' + try { + await this.provider.send('wallet_switchEthereumChain', [{ chainId: '0x1D' }]) //ChainID 29 + } catch (error) { + if (error.code === 4902) { + try { + await this.provider.send('wallet_addEthereumChain', [chainParam, this.account]) + } catch (addError) { + console.log("MetaMask - Error adding new RPC: ", addError) + // handle "add" error via alert message + } + } else { //some other error code + console.log("MetaMask - Switch Error: ", error.code) + } + } + } else if ((masterConfig === 'rinkeby' || masterConfig === 'rinkeby_integration') && targetLayer === 'L1') { + try { + await this.provider.send('wallet_switchEthereumChain',[{ chainId: '0x4' }]) //ChainID 4 + } catch (switchError) { + console.log("MetaMask - could not switch to Rinkeby. Needless to say, this should never happen.") + } + } else if (masterConfig === 'local' && targetLayer === 'L2') { + //ok, so then, we want to switch to 'local' && 'L2' + try { + await this.provider.send('wallet_switchEthereumChain', [{ chainId: '0x7A6A' }]) //ChainID 31338 + } catch (error) { + if (error.code === 4902) { + try { + await this.provider.send('wallet_addEthereumChain', [chainParam, this.account]) + } catch (addError) { + console.log("MetaMask - Error adding new RPC: ", addError) + // handle "add" error via alert message + } + } else { //some other error code + console.log("MetaMask - Switch Error: ", error.code) + } + } + } else if (masterConfig === 'local' && targetLayer === 'L1') { + try { + await this.provider.send('wallet_switchEthereumChain',[{ chainId: '0x7A69' }]) //ChainID 31337 + } catch (switchError) { + console.log("MetaMask - could not switch to Local L1") + } + } + } + async switchChain( layer ) { if(this.L1orL2 === layer) { diff --git a/packages/omgx/wallet-frontend/src/util/masterConfig.js b/packages/omgx/wallet-frontend/src/util/masterConfig.js index 0942c6f82d35..4e5b4e7d9afd 100644 --- a/packages/omgx/wallet-frontend/src/util/masterConfig.js +++ b/packages/omgx/wallet-frontend/src/util/masterConfig.js @@ -23,7 +23,7 @@ NETWORKS = { addressUrl: `https://rinkeby.boba.network:8080/addresses.json`, addressOMGXUrl: `https://rinkeby.boba.network:8078/addresses.json`, OMGX_WATCHER_URL: `https://api-watcher.rinkeby.boba.network/`, - MM_Label: `Rinkeby Test Network`, + MM_Label: `Rinkeby`, L1: { name: "Rinkeby", chainId: 4, @@ -43,7 +43,7 @@ NETWORKS = { addressUrl: `https://mainnet.boba.network:8080/addresses.json`, addressOMGXUrl: `https://mainnet.boba.network:8078/addresses.json`, OMGX_WATCHER_URL: `https://api-watcher.mainnet.boba.network/`, - MM_Label: `Ethereum Mainnet`, + MM_Label: `Mainnet`, L1: { name: "Mainnet", chainId: 1, @@ -67,7 +67,7 @@ if (env === 'dev') { addressUrl: `http://${window.location.hostname}:8080/addresses.json`, addressOMGXUrl: `http://${window.location.hostname}:8078/addresses.json`, OMGX_WATCHER_URL: null, //Does not exist on local - MM_Label: `Local Network`, + MM_Label: `Local`, L1: { name: "Local L1", chainId: 31337, @@ -85,7 +85,7 @@ if (env === 'dev') { addressUrl: `https://rinkeby-integration.boba.network:8081/addresses.json`, addressOMGXUrl: `https://rinkeby-integration.boba.network:8081/omgx-addr.json`, OMGX_WATCHER_URL: `https://api-watcher.rinkeby-integration.boba.network/`, - MM_Label: `Rinkeby Int Test Network`, + MM_Label: `Rinkeby Int Test`, L1: { name: "Rinkeby", chainId: 4, From 1ea4dc7193e8cbd68098ccbee28cdd82b020357f Mon Sep 17 00:00:00 2001 From: Petar Denev Date: Sun, 19 Sep 2021 22:08:23 +0300 Subject: [PATCH 11/24] adding blockexplorer-blockscout and other changes to the dtl and l2geth services to actually allow the replicas to run fine (#475) Co-authored-by: CAPtheorem <79423264+CAPtheorem@users.noreply.github.com> --- .../blockexplorer-blockscout.yaml | 33 +++++-------------- ops_omgx/cloudformation/replica-l2.yaml | 3 +- .../blockexplorer-blockscout/entrypoint.sh | 5 +-- ops_omgx/docker/l2geth/geth.sh | 2 +- 4 files changed, 15 insertions(+), 28 deletions(-) diff --git a/ops_omgx/cloudformation/blockexplorer-blockscout.yaml b/ops_omgx/cloudformation/blockexplorer-blockscout.yaml index 0c548fcd21ed..b28d8aa8d58d 100644 --- a/ops_omgx/cloudformation/blockexplorer-blockscout.yaml +++ b/ops_omgx/cloudformation/blockexplorer-blockscout.yaml @@ -150,7 +150,7 @@ Resources: BlockscoutLBTargetGroup: Type: AWS::ElasticLoadBalancingV2::TargetGroup Properties: - Port: 80 + Port: 4000 Protocol: HTTP VpcId: Fn::ImportValue: !Sub "${InfrastructureStackName}:VpcId" @@ -158,7 +158,7 @@ Resources: - Key: deregistration_delay.timeout_seconds Value: 30 HealthCheckIntervalSeconds: 20 - HealthCheckPath: /health + HealthCheckPath: / HealthCheckProtocol: HTTP # TODO Implement proper healthcheck HealthCheckTimeoutSeconds: 5 HealthyThresholdCount: 2 @@ -213,6 +213,8 @@ Resources: Value: ETH - Name: NETWORK Value: Boba + - Name: PORT + Value: 4000 - Name: SUBNETWORK Value: Rinkeby - Name: MIX_ENV @@ -223,14 +225,14 @@ Resources: Value: /images/boba_logo.svg - Name: SUPPORTED_CHAINS Value: '[{"title":"Boba Mainnet","url":"https://blockexplorer.boba.network","hide_in_dropdown?": false},{"title":"Boba Rinkeby","url":"https://blockexplorer.rinkeby.boba.network","test_net?":true},{"title":"Boba Rinkeby Integration","url":"https://blockexplorer.rinkeby-integration.boba.network","test_net?":true,"hide_in_dropdown?": true}]' - - Name: ETHEREUM_JSONRPC_HTTP_URL + - Name: ETHEREUM_JSONRPC_TRACE_URL Value: !Sub - - "http://${EndpointAddress}:8545/rpc" + - "http://${EndpointAddress}:8545/" - EndpointAddress: Fn::ImportValue: !Sub "${InfrastructureStackName}:LoadBalancerReplica:DNSName" - Name: ETHEREUM_JSONRPC_WS_URL Value: !Sub - - "ws://${EndpointAddress}:8545/ws" + - "ws://${EndpointAddress}:8545/ws/" - EndpointAddress: Fn::ImportValue: !Sub "${InfrastructureStackName}:LoadBalancerReplica:DNSName" - Name: BLOCKSCOUT_VERSION @@ -243,23 +245,6 @@ Resources: com.datadoghq.ad.logs: '[{"source": "blockscout", "service": "blockscout"}]' Essential: true Memory: "512" - - Image: 942431445534.dkr.ecr.us-east-1.amazonaws.com/omgx/nginx-eth-proxy:blockscout - Name: nginx-blockscout - PortMappings: - - ContainerPort: 80 - HostPort: 0 - Command: - - "nginx-debug" - - "-g" - - "daemon off;" - DockerLabels: - com.datadoghq.ad.check_names: '["nginx-blockscout"]' - com.datadoghq.ad.init_configs: '[{}]' - com.datadoghq.ad.logs: '[{"source": "nginx-blockscout", "service": "nginx-blockscout"}]' - Essential: true - Memory: "128" - Links: - - blockscout NetworkMode: bridge TaskRoleArn: !GetAtt TaskRole.Arn Family: !Sub "blockscout-${EnvironmentName}" @@ -270,8 +255,8 @@ Resources: Cluster: Fn::ImportValue: !Sub "${InfrastructureStackName}:EcsClusterReplica" LoadBalancers: - - ContainerName: nginx-blockscout - ContainerPort: 80 + - ContainerName: blockscout + ContainerPort: 4000 TargetGroupArn: !Ref BlockscoutLBTargetGroup DesiredCount: !Ref ServiceCount LaunchType: EC2 diff --git a/ops_omgx/cloudformation/replica-l2.yaml b/ops_omgx/cloudformation/replica-l2.yaml index a7e5ee4fbee3..7177cd6d0c32 100644 --- a/ops_omgx/cloudformation/replica-l2.yaml +++ b/ops_omgx/cloudformation/replica-l2.yaml @@ -136,6 +136,7 @@ Resources: ContainerDefinitions: - Image: !Sub "${ECRRegistry}/${DockerPrefix}/${ReplicaL2Image}:${ImageTag}" Name: geth_l2 + Hostname: geth-l2 PortMappings: - ContainerPort: 8545 HostPort: 0 @@ -175,7 +176,7 @@ Resources: - EndpointAddress: Fn::ImportValue: !Sub "${InfrastructureStackName}:DomainName" - Name: RPC_ADDR - Value: "0.0.0.0" + Value: "geth-l2" - Name: ROLLUP_ENABLE_L2_GAS_POLLING Value: true - Name: ROLLUP_ENFORCE_FEES diff --git a/ops_omgx/docker/blockexplorer-blockscout/entrypoint.sh b/ops_omgx/docker/blockexplorer-blockscout/entrypoint.sh index a9ef144804dd..548501ee65c6 100644 --- a/ops_omgx/docker/blockexplorer-blockscout/entrypoint.sh +++ b/ops_omgx/docker/blockexplorer-blockscout/entrypoint.sh @@ -5,5 +5,6 @@ DATABASE_USER=`/opt/secret2env -name $SECRETNAME|grep -w postgres_user|sed 's/po DATABASE_PASS=`/opt/secret2env -name $SECRETNAME|grep -w postgres_pass|sed 's/postgres_pass=//g'` DATABASE_HOST=`/opt/secret2env -name $SECRETNAME|grep -w postgres_host|sed 's/postgres_host=//g'` export DATABASE_URL="postgresql://${DATABASE_USER}:${DATABASE_PASS}@${DATABASE_HOST}:5432/${DATABASE_NAME}?ssl=false" - -mix do ecto.create, ecto.migrate; mix phx.server +printenv +mix do ecto.create, ecto.migrate +mix phx.server \ No newline at end of file diff --git a/ops_omgx/docker/l2geth/geth.sh b/ops_omgx/docker/l2geth/geth.sh index f196abd97491..6625122f1e73 100644 --- a/ops_omgx/docker/l2geth/geth.sh +++ b/ops_omgx/docker/l2geth/geth.sh @@ -63,5 +63,5 @@ curl \ --retry $RETRIES \ --retry-delay 1 \ $ROLLUP_CLIENT_HTTP - +rm -rf /root/.ethereum/geth/LOCK exec geth --verbosity="$VERBOSITY" "$@" From 859f2fb2dda4c6713894fb6e3792fc77922e25f9 Mon Sep 17 00:00:00 2001 From: cby3149 <46272347+cby3149@users.noreply.github.com> Date: Sun, 19 Sep 2021 12:45:46 -0700 Subject: [PATCH 12/24] Add log and data storage for L2 revenue (#484) * Add log and data storage for L2 revenue * Fix the issue of loading L2ETHCollectFee Co-authored-by: CAPtheorem <79423264+CAPtheorem@users.noreply.github.com> --- packages/omgx/gas-price-oracle/src/service.ts | 71 +++++++++++++++++-- 1 file changed, 67 insertions(+), 4 deletions(-) diff --git a/packages/omgx/gas-price-oracle/src/service.ts b/packages/omgx/gas-price-oracle/src/service.ts index 551749e91ea1..3970f81d869e 100644 --- a/packages/omgx/gas-price-oracle/src/service.ts +++ b/packages/omgx/gas-price-oracle/src/service.ts @@ -53,6 +53,7 @@ export class GasPriceOracleService extends BaseService { OVM_oETH: Contract L1ETHBalance: BigNumber L1ETHCostFee: BigNumber + L2ETHVaultBalance: BigNumber L2ETHCollectFee: BigNumber lastQueriedL1Block: number lastQueriedL2Block: number @@ -99,6 +100,7 @@ export class GasPriceOracleService extends BaseService { this.state.L1ETHBalance = BigNumber.from('0') this.state.L1ETHCostFee = BigNumber.from('0') this.state.L2ETHCollectFee = BigNumber.from('0') + this.state.L2ETHVaultBalance = BigNumber.from('0') this.state.lastQueriedL1Block = await this.options.l1RpcProvider.getBlockNumber() this.state.lastQueriedL2Block = await this.options.l2RpcProvider.getBlockNumber() @@ -108,6 +110,7 @@ export class GasPriceOracleService extends BaseService { // Load history await this._loadL1ETHFee(); + await this._loadL2ETHCost(); } protected async _start(): Promise { @@ -120,7 +123,7 @@ export class GasPriceOracleService extends BaseService { } private async _loadL1ETHFee(): Promise { - const dumpsPath = path.resolve(__dirname, '../data/history.json') + const dumpsPath = path.resolve(__dirname, '../data/l1History.json') if (fs.existsSync(dumpsPath)) { this.logger.warn('Loading L1 cost history...') const historyJsonRaw = await fsPromise.readFile(dumpsPath) @@ -136,13 +139,43 @@ export class GasPriceOracleService extends BaseService { } } + private async _loadL2ETHCost(): Promise { + const vaultBalance = + BigNumber.from((await this.state.OVM_oETH.balanceOf(this.options.OVM_SequencerFeeVault)).toString()) + // load data + const dumpsPath = path.resolve(__dirname, '../data/l2History.json') + if (fs.existsSync(dumpsPath)) { + this.logger.warn('Loading L2 cost history...') + const historyJsonRaw = await fsPromise.readFile(dumpsPath) + const historyJSON = JSON.parse(historyJsonRaw.toString()) + if (historyJSON.L2ETHCollectFee) { + this.state.L2ETHCollectFee = BigNumber.from(historyJSON.L2ETHCollectFee) + } else { + this.logger.warn('Invalid L2 cost history!') + this.state.L2ETHCollectFee = vaultBalance + } + } else { + this.logger.warn('No L2 cost history Found!') + this.state.L2ETHCollectFee = vaultBalance + } + // adjust the L2ETHCollectFee if it is not correct + if (this.state.L2ETHCollectFee.lt(vaultBalance)) { + this.state.L2ETHCollectFee = vaultBalance + } + this.state.L2ETHVaultBalance = vaultBalance + this.logger.info('Loaded L2 Cost Data', { + L2ETHVaultBalance: this.state.L2ETHVaultBalance.toString(), + L2ETHCollectFee: this.state.L2ETHCollectFee.toString() + }) + } + private async _writeL1ETHFee(): Promise { const dumpsPath = path.resolve(__dirname, '../data') if (!fs.existsSync(dumpsPath)) { fs.mkdirSync(dumpsPath) } try { - const addrsPath = path.resolve(dumpsPath, 'history.json') + const addrsPath = path.resolve(dumpsPath, 'l1History.json') await fsPromise.writeFile(addrsPath, JSON.stringify({ L1ETHBalance: this.state.L1ETHBalance.toString(), L1ETHCostFee: this.state.L1ETHCostFee.toString() @@ -153,6 +186,22 @@ export class GasPriceOracleService extends BaseService { } } + private async _writeL2ETHCost(): Promise { + const dumpsPath = path.resolve(__dirname, '../data') + if (!fs.existsSync(dumpsPath)) { + fs.mkdirSync(dumpsPath) + } + try { + const addrsPath = path.resolve(dumpsPath, 'l2History.json') + await fsPromise.writeFile(addrsPath, JSON.stringify({ + L2ETHCollectFee: this.state.L2ETHCollectFee.toString() + })) + } catch (error) { + console.log(error) + this.logger.error("Failed to write L1 cost history!") + } + } + private async _getL1Balance(): Promise { const balances = await Promise.all([ this.options.l1RpcProvider.getBalance(this.options.sequencerAddress), @@ -188,6 +237,7 @@ export class GasPriceOracleService extends BaseService { data: { L1ETHBalance: this.state.L1ETHBalance.toString(), L1ETHCostFee: Number(utils.formatEther(this.state.L1ETHCostFee.toString()).slice(0, 8)), + L1ETHCostFee10X: Number(utils.formatEther(this.state.L1ETHCostFee.toString()).slice(0, 8)) * 10, latestQueriedL1Block: this.state.lastQueriedL1Block, } }) @@ -212,15 +262,28 @@ export class GasPriceOracleService extends BaseService { }, [BigNumber.from('0'), BigNumber.from('0')]) // Get L2 ETH Fee from contract - this.state.L2ETHCollectFee = BigNumber.from((await this.state.OVM_oETH.balanceOf(this.options.OVM_SequencerFeeVault)).toString()) + const L2ETHCollectFee = + BigNumber.from((await this.state.OVM_oETH.balanceOf(this.options.OVM_SequencerFeeVault)).toString()) + // The oETH in OVM_SequencerFeeVault is zero after withdrawing it + let L2ETHCollectFeeIncreased = BigNumber.from('0') + if (L2ETHCollectFee.lt(this.state.L2ETHCollectFee)) { + this.state.L2ETHVaultBalance = L2ETHCollectFee + } else { + L2ETHCollectFeeIncreased = L2ETHCollectFee.sub(this.state.L2ETHVaultBalance) + this.state.L2ETHVaultBalance = L2ETHCollectFee + } + this.state.L2ETHCollectFee = this.state.L2ETHCollectFee.add(L2ETHCollectFeeIncreased); this.state.lastQueriedL2Block = latestQueriedL2Block this.state.avgL2GasLimitPerBlock = collectGasLimitAndFee[0].div(numberOfBlocksInterval) this.state.numberOfBlocksInterval = numberOfBlocksInterval + await this._writeL2ETHCost() + this.logger.info("Got L2 Gas Cost", { network: "L2", data: { L2ETHCollectFee: Number(utils.formatEther(this.state.L2ETHCollectFee.toString()).slice(0, 8)), + L2ETHCollectFee10X: Number(utils.formatEther(this.state.L2ETHCollectFee.toString()).slice(0, 8)) * 10, lastQueriedL2Block: this.state.lastQueriedL2Block, avgL2GasUsagePerBlock: this.state.avgL2GasLimitPerBlock.toString(), numberOfBlocksInterval: this.state.numberOfBlocksInterval, @@ -258,4 +321,4 @@ export class GasPriceOracleService extends BaseService { this.logger.info("No need to update L2 gas price", { gasPrice: gasPriceInt, targetGasPrice }) } } -} \ No newline at end of file +} From ce9ba64b8b17785ec2a2af52d3a1bbbd56133593 Mon Sep 17 00:00:00 2001 From: cby3149 <46272347+cby3149@users.noreply.github.com> Date: Sun, 19 Sep 2021 21:33:34 -0700 Subject: [PATCH 13/24] Fix the decimal place of the balance data in the gas oracle's log (#486) * Add log and data storage for L2 revenue * Fix the issue of loading L2ETHCollectFee * Fix decimal place --- packages/omgx/gas-price-oracle/src/service.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/omgx/gas-price-oracle/src/service.ts b/packages/omgx/gas-price-oracle/src/service.ts index 3970f81d869e..2d13dda9659a 100644 --- a/packages/omgx/gas-price-oracle/src/service.ts +++ b/packages/omgx/gas-price-oracle/src/service.ts @@ -230,14 +230,14 @@ export class GasPriceOracleService extends BaseService { this.state.lastQueriedL1Block = await this.options.l2RpcProvider.getBlockNumber() // write history - this._writeL1ETHFee(); + this._writeL1ETHFee() this.logger.info("Got L1 ETH balances", { network: "L1", data: { L1ETHBalance: this.state.L1ETHBalance.toString(), - L1ETHCostFee: Number(utils.formatEther(this.state.L1ETHCostFee.toString()).slice(0, 8)), - L1ETHCostFee10X: Number(utils.formatEther(this.state.L1ETHCostFee.toString()).slice(0, 8)) * 10, + L1ETHCostFee: Number(utils.formatEther(this.state.L1ETHCostFee.toString())).toFixed(6), + L1ETHCostFee10X: (Number(utils.formatEther(this.state.L1ETHCostFee.toString())) * 10).toFixed(6), latestQueriedL1Block: this.state.lastQueriedL1Block, } }) @@ -282,8 +282,8 @@ export class GasPriceOracleService extends BaseService { this.logger.info("Got L2 Gas Cost", { network: "L2", data: { - L2ETHCollectFee: Number(utils.formatEther(this.state.L2ETHCollectFee.toString()).slice(0, 8)), - L2ETHCollectFee10X: Number(utils.formatEther(this.state.L2ETHCollectFee.toString()).slice(0, 8)) * 10, + L2ETHCollectFee: Number(utils.formatEther(this.state.L2ETHCollectFee.toString())).toFixed(6), + L2ETHCollectFee10X: (Number(utils.formatEther(this.state.L2ETHCollectFee.toString())) * 10).toFixed(6), lastQueriedL2Block: this.state.lastQueriedL2Block, avgL2GasUsagePerBlock: this.state.avgL2GasLimitPerBlock.toString(), numberOfBlocksInterval: this.state.numberOfBlocksInterval, From b661b74d794686f300e6f8d0f65d491d7bb0392c Mon Sep 17 00:00:00 2001 From: CAPtheorem <79423264+CAPtheorem@users.noreply.github.com> Date: Sun, 19 Sep 2021 21:33:51 -0700 Subject: [PATCH 14/24] More information for the users; fixed bug in withdrawal of staked amounts (#487) * wip * fix withdraw from LP pool balance bug - revert addition of Use All * assorted and sundry smoothing and more information for the user * Update networkService.js --- .../src/actions/tokenAction.js | 3 +- .../src/components/Icons/AlertIcon.js | 2 +- .../src/components/input/Input.js | 24 +++++---- .../src/components/listAccount/listAccount.js | 50 ++++++++++++++----- .../src/containers/account/Account.js | 39 ++++++++++++--- .../src/containers/account/Account.styles.js | 30 +++++++++++ .../src/containers/farm/Farm.js | 8 +-- .../modals/deposit/steps/InputStep.js | 14 +++--- .../modals/deposit/steps/InputStepFast.js | 20 +++----- .../modals/exit/steps/DoExitStep.js | 30 +++-------- .../modals/exit/steps/DoExitStepFast.js | 30 ++--------- .../modals/farm/FarmWithdrawModal.js | 44 ++++++++-------- .../modals/transfer/TransferModal.js | 4 +- .../src/containers/transactions/History.js | 7 ++- .../src/pages/history/index.js | 37 ++++++++------ .../wallet-frontend/src/pages/page.style.js | 4 -- .../src/reducers/tokenReducer.js | 6 +-- .../wallet-frontend/src/reducers/uiReducer.js | 2 +- .../src/services/networkService.js | 43 +++++++++------- .../wallet-frontend/src/util/amountConvert.js | 2 +- .../wallet-frontend/src/util/coinImage.js | 3 -- 21 files changed, 223 insertions(+), 179 deletions(-) diff --git a/packages/omgx/wallet-frontend/src/actions/tokenAction.js b/packages/omgx/wallet-frontend/src/actions/tokenAction.js index 05396b7decf7..6cd9d734cbb8 100644 --- a/packages/omgx/wallet-frontend/src/actions/tokenAction.js +++ b/packages/omgx/wallet-frontend/src/actions/tokenAction.js @@ -86,14 +86,13 @@ export async function addToken ( tokenContractAddressL1 ) { const decimals = _decimals ? Number(_decimals.toString()) : 'NOT ON ETHEREUM' const symbolL1 = _symbolL1 || 'NOT ON ETHEREUM' - let symbolL2 = _symbolL1 || 'NOT ON ETHEREUM' + const symbolL2 = _symbolL1 || 'NOT ON ETHEREUM' const name = _name || 'NOT ON ETHEREUM' //ETH is special as always let _tokenContractAddressL2 = null if(_tokenContractAddressL1 === ETHL1 ) { _tokenContractAddressL2 = ETHL2 - symbolL2 = 'oETH' } /********* DO WE HAVE L2 DATA?? *************/ diff --git a/packages/omgx/wallet-frontend/src/components/Icons/AlertIcon.js b/packages/omgx/wallet-frontend/src/components/Icons/AlertIcon.js index 11bd00f48114..d9091c20d49d 100644 --- a/packages/omgx/wallet-frontend/src/components/Icons/AlertIcon.js +++ b/packages/omgx/wallet-frontend/src/components/Icons/AlertIcon.js @@ -4,7 +4,7 @@ import { useTheme } from "@material-ui/core/styles"; function AlertIcon() { const theme = useTheme(); const isLight = theme.palette.mode === 'light'; - const color = theme.palette.common[isLight ? 'black' : 'white']; + const color = 'black';/*theme.palette.common[isLight ? 'black' : 'white'];*/ return ( @@ -96,10 +100,10 @@ function Input({ {unit && ( - Max Available: {Number(maxValue).toFixed(3)} + Max Amount: {Number(maxValue).toFixed(3)} - {/* maxValue && value !== maxValue && ( + {/*allowUseAll && maxValue && value !== maxValue && ( {value !== '' && underZero ? - The value must be greater than 0 + Value too small: the value must be greater than 0 : null } {value !== '' && overMax ? - Wallet balance exceeded: the value must be smaller than {Number(maxValue).toFixed(3)} + Value too large: the value must be smaller than {Number(maxValue).toFixed(3)} : null} ) } -export default React.memo(Input) +export default React.memo(Input) \ No newline at end of file diff --git a/packages/omgx/wallet-frontend/src/components/listAccount/listAccount.js b/packages/omgx/wallet-frontend/src/components/listAccount/listAccount.js index ba58b1efe1b0..af1c24a232e9 100644 --- a/packages/omgx/wallet-frontend/src/components/listAccount/listAccount.js +++ b/packages/omgx/wallet-frontend/src/components/listAccount/listAccount.js @@ -17,35 +17,56 @@ import { getCoinImage } from 'util/coinImage' class ListAccount extends React.Component { constructor(props) { + super(props) - const { token, chain, networkLayer, disabled } = this.props + + const { + token, + chain, + networkLayer, + disabled, + loading + } = this.props + this.state = { token, chain, dropDownBox: false, networkLayer, - disabled + disabled, + loading } + } componentDidUpdate(prevState) { - const { token, chain, networkLayer, disabled } = this.props; + const { + token, + chain, + networkLayer, + disabled, + loading + } = this.props if (!isEqual(prevState.token, token)) { - this.setState({ token }); + this.setState({ token }) } if (!isEqual(prevState.chain, chain)) { - this.setState({ chain }); + this.setState({ chain }) } if (!isEqual(prevState.networkLayer, networkLayer)) { - this.setState({ networkLayer }); + this.setState({ networkLayer }) } if (!isEqual(prevState.disabled, disabled)) { - this.setState({ disabled }); + this.setState({ disabled }) + } + + if (!isEqual(prevState.loading, loading)) { + this.setState({ loading }) } } @@ -61,12 +82,15 @@ class ListAccount extends React.Component { chain, dropDownBox, networkLayer, - disabled + disabled, + loading } = this.state const enabled = (networkLayer === chain) ? true : false const logo = getCoinImage(token.symbol) + //console.log("Acconut disabled:",disabled) + return ( <> @@ -102,7 +126,7 @@ class ListAccount extends React.Component { } {chain === 'L2' && - Bridge and Transfer + Bridge/Transfer } @@ -127,7 +151,7 @@ class ListAccount extends React.Component { }} > - You are on L2. To transact on L1, SWITCH LAYER to L1 + You are on L2. To use L1, click SWITCH LAYER @@ -144,7 +168,7 @@ class ListAccount extends React.Component { }} > - You are on L1. To transact on L2, SWITCH LAYER to L2 + You are on L1. To use L2, click SWITCH LAYER @@ -163,7 +187,7 @@ class ListAccount extends React.Component { tooltip="Classic Bridge to Boba L2. This option is always available but is generally more expensive than the swap-based system ('Fast Bridge')." fullWidth > - Bridge + Bridge to L2 } diff --git a/packages/omgx/wallet-frontend/src/containers/account/Account.js b/packages/omgx/wallet-frontend/src/containers/account/Account.js index 49bb67a8f132..bba7b8200060 100644 --- a/packages/omgx/wallet-frontend/src/containers/account/Account.js +++ b/packages/omgx/wallet-frontend/src/containers/account/Account.js @@ -27,7 +27,10 @@ import ListAccount from 'components/listAccount/listAccount' import networkService from 'services/networkService' import * as S from './Account.styles' + import { selectTokens } from 'selectors/tokenSelector' +import { selectLoading } from 'selectors/loadingSelector' + import PageHeader from 'components/pageHeader/PageHeader' import { Box, Grid, Tab, Tabs, Typography, useMediaQuery } from '@material-ui/core' import { fetchLookUpPrice, fetchTransactions } from 'actions/networkAction' @@ -41,12 +44,16 @@ import NetworkSwitcherIcon from 'components/icons/NetworkSwitcherIcon' import PendingTransaction from './PendingTransaction' import useInterval from 'util/useInterval' +import AlertIcon from 'components/icons/AlertIcon' + const POLL_INTERVAL = 2000; //milliseconds function Account () { const networkLayer = networkService.L1orL2 === 'L1' ? 'L1' : 'L2' + const dispatch = useDispatch() + const [activeTab, setActiveTab] = useState(networkLayer === 'L1' ? 0 : 1) const childBalance = useSelector(selectlayer2Balance, isEqual) @@ -56,6 +63,14 @@ function Account () { const network = useSelector(selectNetwork()) + const depositLoading = useSelector(selectLoading(['DEPOSIT/CREATE'])) + const exitLoading = useSelector(selectLoading(['EXIT/CREATE'])) + + const disabled = depositLoading || exitLoading + + //console.log("disabled:",disabled) + //console.log("loading:",loading) + const getLookupPrice = useCallback(()=>{ const symbolList = Object.values(tokenList).map((i)=> { if(i.symbolL1 === 'ETH') { @@ -67,7 +82,7 @@ function Account () { } }) dispatch(fetchLookUpPrice(symbolList)) - },[tokenList,dispatch]) + },[tokenList, dispatch]) const unorderedTransactions = useSelector(selectTransactions, isEqual) //console.log("Transactions:",unorderedTransactions) @@ -114,7 +129,6 @@ function Account () { }) }, POLL_INTERVAL * 2) - const disabled = false const theme = useTheme() const isMobile = useMediaQuery(theme.breakpoints.down('md')) @@ -224,18 +238,29 @@ function Account () { Please exercise caution when using Mainnet Beta. } - {/* - {balances['oETH'].amountShort} - oETH - */} Boba Drink - + + {disabled && + + + + + Balance altering transaction in progress - please be patient + + + + } + {pending.length > 0 && diff --git a/packages/omgx/wallet-frontend/src/containers/account/Account.styles.js b/packages/omgx/wallet-frontend/src/containers/account/Account.styles.js index 22e90f9b06a2..1ab5eb3557f5 100644 --- a/packages/omgx/wallet-frontend/src/containers/account/Account.styles.js +++ b/packages/omgx/wallet-frontend/src/containers/account/Account.styles.js @@ -94,3 +94,33 @@ export const ContentGlass = styled(Box)(({ theme }) => ({ right: '45px', }, })); + +export const LayerAlert = styled(Box)(({ theme }) => ({ + width: "100%", + display: 'flex', + justifyContent: 'space-between', + alignItems: 'center', + gap: '30px', + borderRadius: '8px', + margin: '20px 0px', + padding: '25px', + background: theme.palette.background.secondary, + [theme.breakpoints.up('md')]: { + padding: '25px 50px', + }, + +})); + +export const AlertText = styled(Typography)(({ theme }) => ({ + marginLeft: '10px', + flex: 4, + [theme.breakpoints.up('md')]: { + }, +})); + +export const AlertInfo = styled(Box)` + display: flex; + justify-content: space-around; + align-items: center; + flex: 1; +`; diff --git a/packages/omgx/wallet-frontend/src/containers/farm/Farm.js b/packages/omgx/wallet-frontend/src/containers/farm/Farm.js index 96425caf3aa9..05efec276512 100644 --- a/packages/omgx/wallet-frontend/src/containers/farm/Farm.js +++ b/packages/omgx/wallet-frontend/src/containers/farm/Farm.js @@ -69,7 +69,7 @@ class Farm extends React.Component { layer2, lpChoice: initialLayer, poolTab: initialViewLayer, - showMDO: false //MDO = my desposits only + showMDO: false //MDO = my deposits only } } @@ -183,7 +183,7 @@ class Farm extends React.Component { lpChoice, poolTab, showMDO - } = this.state; + } = this.state const { isMobile } = this.props @@ -193,7 +193,7 @@ class Farm extends React.Component { <> - { + {/* @@ -207,7 +207,7 @@ class Farm extends React.Component { - } + */} diff --git a/packages/omgx/wallet-frontend/src/containers/modals/deposit/steps/InputStep.js b/packages/omgx/wallet-frontend/src/containers/modals/deposit/steps/InputStep.js index e7739bda42ae..6bc7bfb88d2c 100644 --- a/packages/omgx/wallet-frontend/src/containers/modals/deposit/steps/InputStep.js +++ b/packages/omgx/wallet-frontend/src/containers/modals/deposit/steps/InputStep.js @@ -36,8 +36,8 @@ function InputStep({ handleClose, token }) { if (value > 0) { res = await dispatch(depositETHL2(value)) if (res) { - dispatch(setActiveHistoryTab1('Deposits')) - dispatch(openAlert('ETH bridge submitted')) + dispatch(setActiveHistoryTab1('L1->L2 Bridge')) + dispatch(openAlert('ETH bridge transaction submitted')) handleClose() } } @@ -47,8 +47,8 @@ function InputStep({ handleClose, token }) { depositErc20(powAmount(value, token.decimals), token.address, token.addressL2) ) if (res) { - dispatch(setActiveHistoryTab1('Deposits')) - dispatch(openAlert(`${token.symbol} bridge submitted`)) + dispatch(setActiveHistoryTab1('L1->L2 Bridge')) + dispatch(openAlert(`${token.symbol} bridge transaction submitted`)) handleClose() } else { dispatch(openError(`Failed to bridge ${token.symbol}`)) @@ -96,12 +96,12 @@ function InputStep({ handleClose, token }) { <> - `Classic Bridge ${token && token.symbol ? token.symbol : ''} to L1` + Classic Bridge {token && token.symbol ? token.symbol : ''} to L1 setAmount(i.target.value)} @@ -132,7 +132,7 @@ function InputStep({ handleClose, token }) { size="large" variant="contained" loading={depositLoading} - tooltip={depositLoading ? "Your bridge is still pending. Please wait for confirmation." : "Click here to bridge your funds to L2"} + tooltip={depositLoading ? "Your transaction is still pending. Please wait for confirmation." : "Click here to bridge your funds to L2"} disabled={disabledSubmit} triggerTime={new Date()} fullWidth={isMobile} diff --git a/packages/omgx/wallet-frontend/src/containers/modals/deposit/steps/InputStepFast.js b/packages/omgx/wallet-frontend/src/containers/modals/deposit/steps/InputStepFast.js index 0b54074b66b9..594e7f780078 100644 --- a/packages/omgx/wallet-frontend/src/containers/modals/deposit/steps/InputStepFast.js +++ b/packages/omgx/wallet-frontend/src/containers/modals/deposit/steps/InputStepFast.js @@ -73,12 +73,12 @@ function InputStepFast({ handleClose, token }) { if (valueIsValid) { res = await dispatch(depositL1LP(token.address, value, token.decimals)) if (res) { - dispatch(setActiveHistoryTab1('Deposits')) + dispatch(setActiveHistoryTab1('L1->L2 Bridge')) dispatch( openAlert( - `ETH was bridged into the L1LP. You will receive + `ETH was bridged. You will receive ${((Number(value) * (100 - Number(feeRate)))/100).toFixed(2)} - oETH on L2` + ETH on L2` ) ) handleClose() @@ -110,7 +110,7 @@ function InputStepFast({ handleClose, token }) { ) if (res) { - dispatch(setActiveHistoryTab1('Deposits')) + dispatch(setActiveHistoryTab1('L1->L2 Bridge')) dispatch( openAlert( `${token.symbol} was bridged to the L1LP. You will receive @@ -174,7 +174,7 @@ function InputStepFast({ handleClose, token }) { {setAmount(i.target.value)}} @@ -184,13 +184,7 @@ function InputStepFast({ handleClose, token }) { newStyle /> - {valueIsValid && token && token.symbol === 'ETH' && ( - - {value && `You will receive ${receivableAmount(value)} oETH ${!!amountToUsd(value, lookupPrice, token) ? `($${amountToUsd(value, lookupPrice, token).toFixed(2)})`: ''} on L2.`} - - )} - - {valueIsValid && token && token.symbol !== 'ETH' && ( + {valueIsValid && token && ( {value && `You will receive ${receivableAmount(value)} ${token.symbol} ${!!amountToUsd(value, lookupPrice, token) ? `($${amountToUsd(value, lookupPrice, token).toFixed(2)})`: ''} on L2.`} @@ -223,7 +217,7 @@ function InputStepFast({ handleClose, token }) { color='primary' variant="contained" loading={depositLoading || approvalLoading} - tooltip={depositLoading ? "Your bridge is still pending. Please wait for confirmation." : "Click here to bridge your funds to L2"} + tooltip={depositLoading ? "Your transaction is still pending. Please wait for confirmation." : "Click here to bridge your funds to L2"} disabled={disabledSubmit} triggerTime={new Date()} size="large" diff --git a/packages/omgx/wallet-frontend/src/containers/modals/exit/steps/DoExitStep.js b/packages/omgx/wallet-frontend/src/containers/modals/exit/steps/DoExitStep.js index 09431f9acd4d..af7208dfc807 100644 --- a/packages/omgx/wallet-frontend/src/containers/modals/exit/steps/DoExitStep.js +++ b/packages/omgx/wallet-frontend/src/containers/modals/exit/steps/DoExitStep.js @@ -52,17 +52,11 @@ function DoExitStep({ handleClose, token }) { let res = await dispatch(exitBOBA(token.address, value)) - //person will receive ETH on the L1, not oETH - let currencyL1 = token.symbol - - if (currencyL1 === 'oETH') - currencyL1 = 'ETH' - if (res) { dispatch( openAlert( `${token.symbol} was bridged to L1. You will receive - ${Number(value).toFixed(2)} ${currencyL1} + ${Number(value).toFixed(2)} ${token.symbol} on L1 in 7 days.` ) ) @@ -81,6 +75,7 @@ function DoExitStep({ handleClose, token }) { } else { setDisabledSubmit(true) } + setValue(value) } @@ -117,29 +112,18 @@ function DoExitStep({ handleClose, token }) { newStyle /> - {valueIsValid && token && token.symbol === 'oETH' && ( - - {value && - `You will receive ${Number(value).toFixed(2)} ETH - ${!!amountToUsd(value, lookupPrice, token) ? `($${amountToUsd(value, lookupPrice, token).toFixed(2)})`: ''} - on L1. - Your funds will be available on L1 in 7 days.`} - - )} - - {valueIsValid && token && token.symbol !== 'oETH' && ( + {valueIsValid && token && ( {value && `You will receive ${Number(value).toFixed(2)} ${token.symbol} - ${!!amountToUsd(value, lookupPrice, token) ? `($${amountToUsd(value, lookupPrice, token).toFixed(2)})`: ''} - on L1. - Your funds will be available on L1 in 7 days.`} + ${!!amountToUsd(value, lookupPrice, token) ? `($${amountToUsd(value, lookupPrice, token).toFixed(2)})`: ''} + on L1. Your funds will be available on L1 in 7 days.`} )} {exitLoading && ( - This window will automatically close when your transaction has been signed and submitted. + This window will close when your transaction has been signed and submitted. )} @@ -158,7 +142,7 @@ function DoExitStep({ handleClose, token }) { color="primary" variant="contained" loading={exitLoading} - tooltip={exitLoading ? "Your bridge is still pending. Please wait for confirmation." : "Click here to bridge your funds to L1"} + tooltip={exitLoading ? "Your transaction is still pending. Please wait for confirmation." : "Click here to bridge your funds to L1"} disabled={disabledSubmit} triggerTime={new Date()} fullWidth={isMobile} diff --git a/packages/omgx/wallet-frontend/src/containers/modals/exit/steps/DoExitStepFast.js b/packages/omgx/wallet-frontend/src/containers/modals/exit/steps/DoExitStepFast.js index 9730a07aa135..28850c18ba9f 100644 --- a/packages/omgx/wallet-frontend/src/containers/modals/exit/steps/DoExitStepFast.js +++ b/packages/omgx/wallet-frontend/src/containers/modals/exit/steps/DoExitStepFast.js @@ -75,16 +75,8 @@ function DoExitStepFast({ handleClose, token }) { ) ) - let currencyL1 = token.symbol - - //person will receive ETH on the L1, not oETH - if (currencyL1 === 'oETH') { - currencyL1 = 'ETH' - } - if (res) { - dispatch(openAlert(`${token.symbol} was deposited into the L2 liquidity pool. - You will receive ${receivableAmount(value)} ${currencyL1} on L1.`)) + dispatch(openAlert(`${token.symbol} was bridged. You will receive ${receivableAmount(value)} ${token.symbol} on L1.`)) handleClose() } else { dispatch(openError(`Failed to fast bridge funds to L1`)) @@ -135,7 +127,7 @@ function DoExitStepFast({ handleClose, token }) { {setAmount(i.target.value)}} @@ -145,19 +137,7 @@ function DoExitStepFast({ handleClose, token }) { variant="standard" /> - {valueIsValid && token && token.symbol === 'oETH' && ( - - {value && - `You will receive - ${receivableAmount(value)} - ETH - ${!!amountToUsd(value, lookupPrice, token) ? `($${amountToUsd(value, lookupPrice, token).toFixed(2)})`: ''} - on L1.` - } - - )} - - {valueIsValid && token && token.symbol !== 'oETH' && ( + {valueIsValid && token && ( {value && `You will receive @@ -196,13 +176,13 @@ function DoExitStepFast({ handleClose, token }) { color='primary' variant='contained' loading={exitLoading} - tooltip={exitLoading ? "Your bridge is still pending. Please wait for confirmation." : "Click here to bridge your funds to L1"} + tooltip={exitLoading ? "Your transaction is still pending. Please wait for confirmation." : "Click here to bridge your funds to L1"} disabled={disabledSubmit} triggerTime={new Date()} fullWidth={isMobile} size='large' > - Bridge to L2 + Bridge to L1 diff --git a/packages/omgx/wallet-frontend/src/containers/modals/farm/FarmWithdrawModal.js b/packages/omgx/wallet-frontend/src/containers/modals/farm/FarmWithdrawModal.js index 868a170f4872..4f880f7e97e3 100644 --- a/packages/omgx/wallet-frontend/src/containers/modals/farm/FarmWithdrawModal.js +++ b/packages/omgx/wallet-frontend/src/containers/modals/farm/FarmWithdrawModal.js @@ -17,28 +17,24 @@ import { WrapperActionsModal } from 'components/modal/Modal.styles'; class FarmWithdrawModal extends React.Component { constructor(props) { - super(props); + super(props) - const { open /*, balance*/ } = this.props; - const { withdrawToken, userInfo } = this.props.farm; + const { open } = this.props + const { withdrawToken, userInfo } = this.props.farm this.state = { open, withdrawToken, withdrawValue: '', - // balance userInfo, - //layer1Balance: balance.layer1, - //layer2Balance: balance.layer2, LPBalance: 0, - // loading loading: false, } } async componentDidUpdate(prevState) { - const { open /*, balance*/ } = this.props + const { open } = this.props const { withdrawToken, userInfo } = this.props.farm if (prevState.open !== open) { @@ -46,41 +42,45 @@ class FarmWithdrawModal extends React.Component { } if (!isEqual(prevState.farm.withdrawToken, withdrawToken)) { - let LPBalance = 0; + let LPBalance = 0 if (withdrawToken.L1orL2Pool === 'L1LP') { - LPBalance = await networkService.L1LPBalance(withdrawToken.currency); + LPBalance = await networkService.L1LPBalance(withdrawToken.currency, withdrawToken.decimals) } else { - LPBalance = await networkService.L2LPBalance(withdrawToken.currency); + LPBalance = await networkService.L2LPBalance(withdrawToken.currency, withdrawToken.decimals) } - this.setState({ withdrawToken, LPBalance }); + this.setState({ withdrawToken, LPBalance }) } if (!isEqual(prevState.farm.userInfo, userInfo)) { this.setState({ userInfo }); } - // if (!isEqual(prevState.balance, balance)) { - // this.setState({ - // layer1Balance: balance.layer1, - // layer2Balance: balance.layer2 - // }); - // } } getMaxTransferValue () { - const { userInfo, withdrawToken } = this.state + + const { userInfo, withdrawToken, LPBalance } = this.state + let transferingBalance = 0 if (typeof userInfo[withdrawToken.L1orL2Pool][withdrawToken.currency] !== 'undefined') { transferingBalance = userInfo[withdrawToken.L1orL2Pool][withdrawToken.currency].amount + transferingBalance = logAmount(transferingBalance, withdrawToken.decimals) } - return logAmount(transferingBalance, withdrawToken.decimals); + + //BUT, if the current balance is lower than what you staked, can only withdraw the balance + //console.log("LPBalance:",LPBalance) + if (LPBalance < transferingBalance) + transferingBalance = LPBalance + + return transferingBalance } handleClose() { - this.props.dispatch(closeModal("farmWithdrawModal")); + this.props.dispatch(closeModal("farmWithdrawModal")) } async handleConfirm() { + const { withdrawToken, withdrawValue } = this.state; this.setState({ loading: true }); @@ -90,7 +90,7 @@ class FarmWithdrawModal extends React.Component { withdrawValue, withdrawToken.L1orL2Pool, withdrawToken.decimals, - ); + ) if (withdrawLiquidityTX) { this.props.dispatch(openAlert("Your liquidity was withdrawn.")); this.props.dispatch(getFarmInfo()); diff --git a/packages/omgx/wallet-frontend/src/containers/modals/transfer/TransferModal.js b/packages/omgx/wallet-frontend/src/containers/modals/transfer/TransferModal.js index 364d6db86d81..689f2989f11b 100644 --- a/packages/omgx/wallet-frontend/src/containers/modals/transfer/TransferModal.js +++ b/packages/omgx/wallet-frontend/src/containers/modals/transfer/TransferModal.js @@ -131,7 +131,7 @@ function TransferModal ({ open, token, minHeight }) { {convertToUSD && ( - {`Transfer value in USD: $${amountToUsd(value, lookupPrice, token).toFixed(2)}`} + {`Value in USD: $${amountToUsd(value, lookupPrice, token).toFixed(2)}`} )} @@ -150,7 +150,7 @@ function TransferModal ({ open, token, minHeight }) { color='primary' variant="contained" loading={loading} - tooltip='Your transfer is still pending. Please wait for confirmation.' + tooltip={loading ? "Your transaction is still pending. Please wait for confirmation." : "Click here to bridge your funds to L1"} disabled={disabledTransfer} triggerTime={new Date()} fullWidth={isMobile} diff --git a/packages/omgx/wallet-frontend/src/containers/transactions/History.js b/packages/omgx/wallet-frontend/src/containers/transactions/History.js index bd6cd2a6e2b0..8b9a13969323 100644 --- a/packages/omgx/wallet-frontend/src/containers/transactions/History.js +++ b/packages/omgx/wallet-frontend/src/containers/transactions/History.js @@ -61,7 +61,6 @@ function History() { //sort transactions by timeStamp const orderedTransactions = orderBy(unorderedTransactions, i => i.timeStamp, 'desc') - //'desc' or 'asc' const transactions = orderedTransactions.filter((i) => { if (startDate && endDate) { @@ -129,7 +128,7 @@ function History() { {dispatch(setActiveHistoryTab1(tab))}} activeTab={activeTab1} - tabs={['All', 'Deposits', 'Exits']} + tabs={['All', 'L1->L2 Bridge', 'L2->L1 Bridge']} /> {activeTab1 === 'All' && ( @@ -139,14 +138,14 @@ function History() { /> )} - {activeTab1 === 'Deposits' && + {activeTab1 === 'L1->L2 Bridge' && } - {activeTab1 === 'Exits' && + {activeTab1 === 'L2->L1 Bridge' && L2 Bridge', 'L2->L1 Bridge'] const unorderedTransactions = useSelector(selectTransactions, isEqual); const orderedTransactions = orderBy(unorderedTransactions, i => i.timeStamp, 'desc'); @@ -69,13 +74,13 @@ function HistoryPage() { useInterval(() => { batch(() => { - dispatch(fetchTransactions()); - }); - }, POLL_INTERVAL * 2); + dispatch(fetchTransactions()) + }) + }, POLL_INTERVAL * 2) console.log(['transactions', transactions]); - const onTabChagne = (event, newValue) => { + const onTabChange = (event, newValue) => { console.log([event, newValue]); setSelectedTab(newValue); } @@ -89,7 +94,7 @@ function HistoryPage() { > @@ -126,13 +131,13 @@ function HistoryPage() { chainLink={chainLink} /> : null } - {tabList[selectedTab] === 'Deposits' ? + {tabList[selectedTab] === 'L1->L2 Bridge' ? : null } - {tabList[selectedTab] === 'Exits' ? + {tabList[selectedTab] === 'L2->L1 Bridge' ? props.open ? 'rotate(-90deg)' : 'rotate(90deg)'}; transition: all 200ms ease-in-out; diff --git a/packages/omgx/wallet-frontend/src/reducers/tokenReducer.js b/packages/omgx/wallet-frontend/src/reducers/tokenReducer.js index 8f77213bb96a..6cb75c16101d 100644 --- a/packages/omgx/wallet-frontend/src/reducers/tokenReducer.js +++ b/packages/omgx/wallet-frontend/src/reducers/tokenReducer.js @@ -22,9 +22,9 @@ const initialState = { addressL1: L1ETH, addressL2: L2ETH, symbolL1: 'ETH', - symbolL2: 'oETH', - decimals: 18, - name: 'Ethereum', + symbolL2: 'ETH', + decimals: 18, + name: 'Ethereum', redalert: false, }, } diff --git a/packages/omgx/wallet-frontend/src/reducers/uiReducer.js b/packages/omgx/wallet-frontend/src/reducers/uiReducer.js index 585632924ab0..8b7ccc933b67 100644 --- a/packages/omgx/wallet-frontend/src/reducers/uiReducer.js +++ b/packages/omgx/wallet-frontend/src/reducers/uiReducer.js @@ -41,7 +41,7 @@ const initialState = { alert: null, error: null, activeHistoryTab1: 'All', - activeHistoryTab2: 'Exits', + activeHistoryTab2: 'L2->L1 Bridge', }; function uiReducer (state = initialState, action) { diff --git a/packages/omgx/wallet-frontend/src/services/networkService.js b/packages/omgx/wallet-frontend/src/services/networkService.js index 00b2a05ee522..d41a5263abf2 100644 --- a/packages/omgx/wallet-frontend/src/services/networkService.js +++ b/packages/omgx/wallet-frontend/src/services/networkService.js @@ -1195,7 +1195,8 @@ class NetworkService { async getBalances() { try { - // Always check ETH and oETH + + // Always check ETH const layer1Balance = await this.L1Provider.getBalance(this.account) const layer2Balance = await this.L2Provider.getBalance(this.account) @@ -1215,7 +1216,7 @@ class NetworkService { address: this.L2_ETH_Address, addressL1: this.L1_ETH_Address, currency: this.L1_ETH_Address, - symbol: 'oETH', + symbol: 'ETH', decimals: 18, balance: new BN(layer2Balance.toString()), }, @@ -1590,7 +1591,7 @@ class NetworkService { async getL1LPInfo() { const tokenAddressList = Object.keys(this.addresses.TOKENS).reduce((acc, cur) => { - acc.push(this["L1_" + cur + "_Address"]); + acc.push(this["L1_" + cur + "_Address"].toLowerCase()); return acc; }, [this.L1_ETH_Address]); @@ -1624,19 +1625,19 @@ class NetworkService { } const poolTokenInfo = await L1LPContract.poolInfo(tokenAddress) const userTokenInfo = await L1LPContract.userInfo(tokenAddress, this.account) - return { tokenAddress, tokenBalance, tokenSymbol, tokenName, poolTokenInfo, userTokenInfo,decimals } + return { tokenAddress, tokenBalance, tokenSymbol, tokenName, poolTokenInfo, userTokenInfo, decimals } } tokenAddressList.forEach((tokenAddress) => L1LPInfoPromise.push(getL1LPInfoPromise(tokenAddress))) const L1LPInfo = await Promise.all(L1LPInfoPromise); L1LPInfo.forEach((token) => { - poolInfo[token.tokenAddress] = { + poolInfo[token.tokenAddress.toLowerCase()] = { symbol: token.tokenSymbol, name: token.tokenName, decimals: token.decimals, - l1TokenAddress: token.poolTokenInfo.l1TokenAddress, - l2TokenAddress: token.poolTokenInfo.l2TokenAddress, + l1TokenAddress: token.poolTokenInfo.l1TokenAddress.toLowerCase(), + l2TokenAddress: token.poolTokenInfo.l2TokenAddress.toLowerCase(), accUserReward: token.poolTokenInfo.accUserReward.toString(), accUserRewardPerShare: token.poolTokenInfo.accUserRewardPerShare.toString(), userDepositAmount: token.poolTokenInfo.userDepositAmount.toString(), @@ -1661,7 +1662,7 @@ class NetworkService { tokenBalance: token.tokenBalance.toString() } userInfo[token.tokenAddress] = { - l1TokenAddress: token.tokenAddress, + l1TokenAddress: token.tokenAddress.toLowerCase(), amount: token.userTokenInfo.amount.toString(), pendingReward: token.userTokenInfo.pendingReward.toString(), rewardDebt: token.userTokenInfo.rewardDebt.toString() @@ -1674,8 +1675,8 @@ class NetworkService { const tokenAddressList = Object.keys(this.addresses.TOKENS).reduce((acc, cur) => { acc.push({ - L1: this["L1_" + cur + "_Address"], - L2: this["L2_" + cur + "_Address"] + L1: this["L1_" + cur + "_Address"].toLowerCase(), + L2: this["L2_" + cur + "_Address"].toLowerCase() }); return acc; }, [{ @@ -1695,6 +1696,7 @@ class NetworkService { const L2LPInfoPromise = []; const getL2LPInfoPromise = async(tokenAddress, tokenAddressL1 ) => { + let tokenBalance let tokenSymbol let tokenName @@ -1702,9 +1704,9 @@ class NetworkService { if (tokenAddress === this.L2_ETH_Address) { tokenBalance = await this.L2Provider.getBalance(this.L2LPAddress) - tokenSymbol = 'oETH' + tokenSymbol = 'ETH' tokenName = 'Ethereum' - decimals = 18; + decimals = 18 } else { tokenBalance = await this.L2_TEST_Contract.attach(tokenAddress).connect(this.L2Provider).balanceOf(this.L2LPAddress) tokenSymbol = await this.L2_TEST_Contract.attach(tokenAddress).connect(this.L2Provider).symbol() @@ -1718,14 +1720,15 @@ class NetworkService { tokenAddressList.forEach(({L1, L2}) => L2LPInfoPromise.push(getL2LPInfoPromise(L2, L1))) - const L2LPInfo = await Promise.all(L2LPInfoPromise); + const L2LPInfo = await Promise.all(L2LPInfoPromise) + L2LPInfo.forEach((token) => { - poolInfo[token.tokenAddress] = { + poolInfo[token.tokenAddress.toLowerCase()] = { symbol: token.tokenSymbol, name: token.tokenName, decimals: token.decimals, - l1TokenAddress: token.poolTokenInfo.l1TokenAddress, - l2TokenAddress: token.poolTokenInfo.l2TokenAddress, + l1TokenAddress: token.poolTokenInfo.l1TokenAddress.toLowerCase(), + l2TokenAddress: token.poolTokenInfo.l2TokenAddress.toLowerCase(), accUserReward: token.poolTokenInfo.accUserReward.toString(), accUserRewardPerShare: token.poolTokenInfo.accUserRewardPerShare.toString(), userDepositAmount: token.poolTokenInfo.userDepositAmount.toString(), @@ -1749,8 +1752,8 @@ class NetworkService { ), // ( accUserReward - userDepositAmount ) / timeDuration tokenBalance: token.tokenBalance.toString() } - userInfo[token.tokenAddress] = { - l2TokenAddress: token.tokenAddress, + userInfo[token.tokenAddress.toLowerCase()] = { + l2TokenAddress: token.tokenAddress.toLowerCase(), amount: token.userTokenInfo.amount.toString(), pendingReward: token.userTokenInfo.pendingReward.toString(), rewardDebt: token.userTokenInfo.rewardDebt.toString() @@ -1878,8 +1881,10 @@ class NetworkService { /************ L1LP Pool size ***********/ /***************************************/ async L1LPBalance(tokenAddress, decimals) { + let balance let tokenAddressLC = tokenAddress.toLowerCase() + if ( tokenAddressLC === this.L2_ETH_Address || tokenAddressLC === this.L1_ETH_Address @@ -1903,8 +1908,10 @@ class NetworkService { /************ L2LP Pool size ***********/ /***************************************/ async L2LPBalance(tokenAddress, decimals) { + let balance let tokenAddressLC = tokenAddress.toLowerCase() + if ( tokenAddressLC === this.L2_ETH_Address || tokenAddressLC === this.L1_ETH_Address diff --git a/packages/omgx/wallet-frontend/src/util/amountConvert.js b/packages/omgx/wallet-frontend/src/util/amountConvert.js index db1af3c09d71..4c666faff62e 100644 --- a/packages/omgx/wallet-frontend/src/util/amountConvert.js +++ b/packages/omgx/wallet-frontend/src/util/amountConvert.js @@ -38,7 +38,7 @@ export function powAmount (amount, power) { } export function amountToUsd(amount, lookupPrice, token) { - if (['ETH', 'oETH'].includes(token.symbol) && !!lookupPrice['ethereum']) { + if (token.symbol === 'ETH' && !!lookupPrice['ethereum']) { return amount * lookupPrice['ethereum'].usd } else if (token.symbol === 'OMG' && !!lookupPrice['omisego']) { return amount * lookupPrice['omisego'].usd diff --git a/packages/omgx/wallet-frontend/src/util/coinImage.js b/packages/omgx/wallet-frontend/src/util/coinImage.js index 9e1fbbb380fd..de863675b9ca 100644 --- a/packages/omgx/wallet-frontend/src/util/coinImage.js +++ b/packages/omgx/wallet-frontend/src/util/coinImage.js @@ -57,9 +57,6 @@ export const getCoinImage = (symbol) => { case "ETH": logo = ethLogo; break; - case "oETH": - logo = ethLogo; - break; case "JLKN": logo = TESTLogo; break; From 97682bde73f3c12ae0a8bd0d4cc78c3ee672dd86 Mon Sep 17 00:00:00 2001 From: CAPtheorem <79423264+CAPtheorem@users.noreply.github.com> Date: Mon, 20 Sep 2021 07:13:54 -0700 Subject: [PATCH 15/24] Improved unit handling (#494) * rename functions to provide greater clarity on what functions expect * modal typo fix (L1->L2) --- .../modals/deposit/steps/InputStep.js | 4 +-- .../modals/farm/FarmDepositModal.js | 5 ++-- .../modals/farm/FarmWithdrawModal.js | 6 ++-- .../modals/transfer/TransferModal.js | 6 ++-- .../src/services/networkService.js | 28 +++++++++--------- .../wallet-frontend/src/util/amountConvert.js | 29 +++++++++++++++---- 6 files changed, 48 insertions(+), 30 deletions(-) diff --git a/packages/omgx/wallet-frontend/src/containers/modals/deposit/steps/InputStep.js b/packages/omgx/wallet-frontend/src/containers/modals/deposit/steps/InputStep.js index 6bc7bfb88d2c..96c0f76f8a45 100644 --- a/packages/omgx/wallet-frontend/src/containers/modals/deposit/steps/InputStep.js +++ b/packages/omgx/wallet-frontend/src/containers/modals/deposit/steps/InputStep.js @@ -96,11 +96,11 @@ function InputStep({ handleClose, token }) { <> - Classic Bridge {token && token.symbol ? token.symbol : ''} to L1 + Classic Bridge {token && token.symbol ? token.symbol : ''} to L2 BigNumber +*/ + +export function powAmount (amount, decimals) { + + const x = new BigNumber(amount) + const exp = new BigNumber(10).pow(decimals) + + const calculated = x.multipliedBy(exp) + return calculated.toFixed(0) +} + +/* more clearly named version of this */ +export function toWei_BN(amount, decimals) { + + const x = new BigNumber(amount) + const exp = new BigNumber(10).pow(decimals) - const calculated = x.multipliedBy(exp); - return calculated.toFixed(0); + const calculated = x.multipliedBy(exp) + return calculated.toFixed(0) } export function amountToUsd(amount, lookupPrice, token) { From 9673d4bd172871aaf656874e2783d3fc2f31fde7 Mon Sep 17 00:00:00 2001 From: cby3149 <46272347+cby3149@users.noreply.github.com> Date: Mon, 20 Sep 2021 16:34:52 -0700 Subject: [PATCH 16/24] Reduce the api call (#497) --- .../transaction-monitor/services/utilities/optimismEnv.js | 4 ++-- packages/omgx/gas-price-oracle/src/service.ts | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ops_omgx/monitor/transaction-monitor/services/utilities/optimismEnv.js b/ops_omgx/monitor/transaction-monitor/services/utilities/optimismEnv.js index 8f17cf486b52..7aeff0043966 100644 --- a/ops_omgx/monitor/transaction-monitor/services/utilities/optimismEnv.js +++ b/ops_omgx/monitor/transaction-monitor/services/utilities/optimismEnv.js @@ -67,8 +67,8 @@ const OVM_L2_CROSS_DOMAIN_MESSENGER = "0x420000000000000000000000000000000000000 class OptimismEnv { constructor() { - this.L1Provider = new ethers.providers.JsonRpcProvider(L1_NODE_WEB3_URL); - this.L2Provider = new ethers.providers.JsonRpcProvider(L2_NODE_WEB3_URL); + this.L1Provider = new ethers.providers.StaticJsonRpcProvider(L1_NODE_WEB3_URL); + this.L2Provider = new ethers.providers.StaticJsonRpcProvider(L2_NODE_WEB3_URL); this.MySQLHostURL = MYSQL_HOST_URL; this.MySQLPort = MYSQL_PORT; diff --git a/packages/omgx/gas-price-oracle/src/service.ts b/packages/omgx/gas-price-oracle/src/service.ts index 2d13dda9659a..befa38522bb0 100644 --- a/packages/omgx/gas-price-oracle/src/service.ts +++ b/packages/omgx/gas-price-oracle/src/service.ts @@ -236,8 +236,8 @@ export class GasPriceOracleService extends BaseService { network: "L1", data: { L1ETHBalance: this.state.L1ETHBalance.toString(), - L1ETHCostFee: Number(utils.formatEther(this.state.L1ETHCostFee.toString())).toFixed(6), - L1ETHCostFee10X: (Number(utils.formatEther(this.state.L1ETHCostFee.toString())) * 10).toFixed(6), + L1ETHCostFee: Number(Number(utils.formatEther(this.state.L1ETHCostFee.toString())).toFixed(6)), + L1ETHCostFee10X: Number((Number(utils.formatEther(this.state.L1ETHCostFee.toString())) * 10).toFixed(6)), latestQueriedL1Block: this.state.lastQueriedL1Block, } }) @@ -282,8 +282,8 @@ export class GasPriceOracleService extends BaseService { this.logger.info("Got L2 Gas Cost", { network: "L2", data: { - L2ETHCollectFee: Number(utils.formatEther(this.state.L2ETHCollectFee.toString())).toFixed(6), - L2ETHCollectFee10X: (Number(utils.formatEther(this.state.L2ETHCollectFee.toString())) * 10).toFixed(6), + L2ETHCollectFee: Number(Number(utils.formatEther(this.state.L2ETHCollectFee.toString())).toFixed(6)), + L2ETHCollectFee10X: Number((Number(utils.formatEther(this.state.L2ETHCollectFee.toString())) * 10).toFixed(6)), lastQueriedL2Block: this.state.lastQueriedL2Block, avgL2GasUsagePerBlock: this.state.avgL2GasLimitPerBlock.toString(), numberOfBlocksInterval: this.state.numberOfBlocksInterval, From 443349d33f286e87d5c1d2e8c8c63a7a67d2307b Mon Sep 17 00:00:00 2001 From: cby3149 <46272347+cby3149@users.noreply.github.com> Date: Mon, 20 Sep 2021 17:23:02 -0700 Subject: [PATCH 17/24] Increase the waiting time to 10 mins (#495) Co-authored-by: CAPtheorem <79423264+CAPtheorem@users.noreply.github.com> --- ops_omgx/api/watcher-api/watcher_getL2CrossDomainMessage.py | 4 ++-- ops_omgx/api/watcher-api/watcher_getL2Transactions.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ops_omgx/api/watcher-api/watcher_getL2CrossDomainMessage.py b/ops_omgx/api/watcher-api/watcher_getL2CrossDomainMessage.py index 1dc753065804..e6848378065c 100644 --- a/ops_omgx/api/watcher-api/watcher_getL2CrossDomainMessage.py +++ b/ops_omgx/api/watcher-api/watcher_getL2CrossDomainMessage.py @@ -60,8 +60,8 @@ def watcher_getL2CrossDomainMessage(event, context): crossDomainMessageSendTime = transactionDataRaw[8] fastRelay = transactionDataRaw[11] if fastRelay == True: - # Estimate time is 5 minutes - crossDomainMessageEstimateFinalizedTime = int(crossDomainMessageSendTime) + 60 * 5 + # Estimate time + crossDomainMessageEstimateFinalizedTime = int(crossDomainMessageSendTime) + int(config.get('ESTIMATE_FINIALIZED_TIME')) else: # Estimate time is 7 days crossDomainMessageEstimateFinalizedTime = int(crossDomainMessageSendTime) + 60 * 60 * 24 * 7 diff --git a/ops_omgx/api/watcher-api/watcher_getL2Transactions.py b/ops_omgx/api/watcher-api/watcher_getL2Transactions.py index 49810316c65a..2d35f7c4841a 100644 --- a/ops_omgx/api/watcher-api/watcher_getL2Transactions.py +++ b/ops_omgx/api/watcher-api/watcher_getL2Transactions.py @@ -64,8 +64,8 @@ def watcher_getL2Transactions(event, context): crossDomainMessageSendTime = transactionDataRaw[8] fastRelay = transactionDataRaw[11] if fastRelay == True: - # Estimate time is 5 minutes - crossDomainMessageEstimateFinalizedTime = int(crossDomainMessageSendTime) + 60 * 5 + # Estimate time + crossDomainMessageEstimateFinalizedTime = int(crossDomainMessageSendTime) + int(config.get('ESTIMATE_FINIALIZED_TIME')) else: # Estimate time is 7 days crossDomainMessageEstimateFinalizedTime = int(crossDomainMessageSendTime) + 60 * 60 * 24 * 7 From c12bb9a17efe1ddc2aa727d6e092a60afd4ad9ea Mon Sep 17 00:00:00 2001 From: cby3149 <46272347+cby3149@users.noreply.github.com> Date: Tue, 21 Sep 2021 13:35:56 -0700 Subject: [PATCH 18/24] Improve the way to query fast exit data (#507) --- .../monitor/transaction-monitor/services/database.service.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ops_omgx/monitor/transaction-monitor/services/database.service.js b/ops_omgx/monitor/transaction-monitor/services/database.service.js index 8bb8347580be..ecf55b35448f 100644 --- a/ops_omgx/monitor/transaction-monitor/services/database.service.js +++ b/ops_omgx/monitor/transaction-monitor/services/database.service.js @@ -237,7 +237,7 @@ class DatabaseService extends OptimismEnv{ const crossDomainMessage = await query(`SELECT * FROM receipt WHERE crossDomainMessage=${true} AND crossDomainMessageFinalize=${false} - AND UNIX_TIMESTAMP() > crossDomainMessageEstimateFinalizedTime + AND ((UNIX_TIMESTAMP() > crossDomainMessageEstimateFinalizedTime AND fastRelay is null) OR fastRelay=true) `); con.end(); return crossDomainMessage; @@ -257,7 +257,6 @@ class DatabaseService extends OptimismEnv{ on depositL2.hash = l1Bridge.hash WHERE crossDomainMessage=${true} AND depositL2.status='pending' - AND UNIX_TIMESTAMP() > crossDomainMessageEstimateFinalizedTime `); con.end(); return crossDomainMessage; From 03018ce2ccab484486d0bd7cdd9ec1ccdc0997fe Mon Sep 17 00:00:00 2001 From: CAPtheorem <79423264+CAPtheorem@users.noreply.github.com> Date: Tue, 21 Sep 2021 20:28:03 -0700 Subject: [PATCH 19/24] enables USE ALL for nonETH L2->L2 transfers and fix OMG bridges to deal with OMG token's violation of both ERC20 and EIP-20 (#496) * enables Use All for nonETH L2->L2 transfers * Update networkService.js * add support for USE ALL for L2->L1 ops * add support for USE ALL for non-ETH L1-L2 operations * clean up warnings / remove unused variables * Fix the value limit checking * Update Help.js * minor smoothing * improve Farm Withdraw and Deposit value checking and add support for USE ALL * Update listFarm.js * smoothing the farm max withdrawal * incorporate https://github.com/omgnetwork/optimism/pull/508/files * fix omg bridging --- .../src/actions/createAction.js | 2 + .../src/actions/networkAction.js | 6 +- .../src/components/Icons/AlertIcon.js | 2 +- .../src/components/input/Input.js | 14 +- .../src/components/listFarm/listFarm.js | 16 +- .../src/containers/account/Account.js | 10 +- .../containers/account/PendingTransaction.js | 11 +- .../src/containers/farm/Farm.js | 16 -- .../src/containers/help/Help.js | 5 + .../src/containers/home/Home.js | 18 +- .../modals/deposit/steps/InputStep.js | 91 ++++++-- .../modals/deposit/steps/InputStepFast.js | 110 ++++++--- .../modals/exit/steps/DoExitStep.js | 83 ++++--- .../modals/exit/steps/DoExitStepFast.js | 83 +++++-- .../modals/farm/FarmDepositModal.js | 34 ++- .../modals/farm/FarmWithdrawModal.js | 170 ++++++++++---- .../modals/transfer/TransferModal.js | 83 +++++-- .../src/deployment/contracts/OMG/OMG.json | 1 + .../wallet-frontend/src/services/OMG.json | 1 + .../src/services/networkService.js | 218 ++++++++++++------ .../wallet-frontend/src/util/amountConvert.js | 2 +- 21 files changed, 659 insertions(+), 317 deletions(-) create mode 100644 packages/omgx/wallet-frontend/src/deployment/contracts/OMG/OMG.json create mode 100644 packages/omgx/wallet-frontend/src/services/OMG.json diff --git a/packages/omgx/wallet-frontend/src/actions/createAction.js b/packages/omgx/wallet-frontend/src/actions/createAction.js index 5cc14fe93044..fbbd84b676c2 100644 --- a/packages/omgx/wallet-frontend/src/actions/createAction.js +++ b/packages/omgx/wallet-frontend/src/actions/createAction.js @@ -23,6 +23,8 @@ export function createAction (key, asyncAction) { //deal with metamask errors if(response && response.hasOwnProperty('message') && response.hasOwnProperty('code')) { dispatch({ type: `UI/ERROR/UPDATE`, payload: response.message }) + // cancel request loading state + dispatch({ type: `${key}/ERROR` }) return false } dispatch({ type: `${key}/SUCCESS`, payload: response }); diff --git a/packages/omgx/wallet-frontend/src/actions/networkAction.js b/packages/omgx/wallet-frontend/src/actions/networkAction.js index 6eb0636d1ca3..179fece3a9a9 100644 --- a/packages/omgx/wallet-frontend/src/actions/networkAction.js +++ b/packages/omgx/wallet-frontend/src/actions/networkAction.js @@ -68,13 +68,15 @@ export function depositL2LP(token, value) { //DEPOSIT ETH export function depositETHL2(value) { - return createAction('DEPOSIT/CREATE', () => - networkService.depositETHL2(value) + return createAction('DEPOSIT/CREATE', () => { + return networkService.depositETHL2(value) + } ) } //DEPOSIT ERC20 export function depositErc20(value, currency, currencyL2) { + console.log("Depositing ERC20") return createAction('DEPOSIT/CREATE', () => networkService.depositErc20(value, currency, currencyL2) ) diff --git a/packages/omgx/wallet-frontend/src/components/Icons/AlertIcon.js b/packages/omgx/wallet-frontend/src/components/Icons/AlertIcon.js index d9091c20d49d..11bd00f48114 100644 --- a/packages/omgx/wallet-frontend/src/components/Icons/AlertIcon.js +++ b/packages/omgx/wallet-frontend/src/components/Icons/AlertIcon.js @@ -4,7 +4,7 @@ import { useTheme } from "@material-ui/core/styles"; function AlertIcon() { const theme = useTheme(); const isLight = theme.palette.mode === 'light'; - const color = 'black';/*theme.palette.common[isLight ? 'black' : 'white'];*/ + const color = theme.palette.common[isLight ? 'black' : 'white']; return ( @@ -103,13 +105,13 @@ function Input({ Max Amount: {Number(maxValue).toFixed(3)} - {/*allowUseAll && maxValue && value !== maxValue && ( + {allowUseAll && ( - - )*/} + )} )} {paste && ( diff --git a/packages/omgx/wallet-frontend/src/components/listFarm/listFarm.js b/packages/omgx/wallet-frontend/src/components/listFarm/listFarm.js index 7a12ae3ffdcc..ee96c993e104 100644 --- a/packages/omgx/wallet-frontend/src/components/listFarm/listFarm.js +++ b/packages/omgx/wallet-frontend/src/components/listFarm/listFarm.js @@ -88,7 +88,7 @@ class ListFarm extends React.Component { handleWithdrawToken() { - const { poolInfo, L1orL2Pool, balance } = this.state; + const { poolInfo, L1orL2Pool, balance } = this.state this.props.dispatch(updateWithdrawToken({ symbol: poolInfo.symbol, @@ -151,6 +151,7 @@ class ListFarm extends React.Component { } = this.state; const pageLoading = Object.keys(poolInfo).length === 0; + const { isMobile } = this.props let userReward = 0; @@ -184,6 +185,11 @@ class ListFarm extends React.Component { } } + let enableReward = false + if( Number(logAmount(userReward, decimals, 3)) >= 0.001 ) { + enableReward = true + } + return ( {pageLoading ? ( @@ -203,9 +209,7 @@ class ListFarm extends React.Component { Earned ) : (null)} - {userReward ? - `${logAmount(userReward, decimals, 2)}` : `0` - } + {userReward ? `${logAmount(userReward, decimals, 3)}` : `0`} @@ -266,11 +270,11 @@ class ListFarm extends React.Component { {`${symbol}`} Earned - {logAmount(userReward, decimals, 2)} + {logAmount(userReward, decimals, 3)}
+ You are using Mainnet.
WARNING: the mainnet smart contracts are not fully audited and funds may be at risk.
- Please exercise caution when using Mainnet Beta. + Please exercise caution when using Mainnet. } @@ -247,15 +247,13 @@ function Account () { {disabled && - + - - Balance altering transaction in progress - please be patient + Note: Balance altering transaction in progress - please be patient diff --git a/packages/omgx/wallet-frontend/src/containers/account/PendingTransaction.js b/packages/omgx/wallet-frontend/src/containers/account/PendingTransaction.js index 8868367d1aae..8a76eb53abc3 100644 --- a/packages/omgx/wallet-frontend/src/containers/account/PendingTransaction.js +++ b/packages/omgx/wallet-frontend/src/containers/account/PendingTransaction.js @@ -130,7 +130,6 @@ function PendingTransaction() { //if totalNumberOfPages === 0, set to one so we don't get the strange "page 1 of 0" display if (totalNumberOfPages === 0) totalNumberOfPages = 1 - const currentNetwork = useSelector(selectNetwork()); const nw = getAllNetworks(); const theme = useTheme(); @@ -139,13 +138,7 @@ function PendingTransaction() { let network = nw[currentNetwork] let chain = item.chain === 'L1pending' ? 'L1' : item.chain; if (!!network && !!network[chain]) { - // network object should have L1 & L2 - // endpoint name is now network specific - `?network` no longer needed - //if (chain === 'L1') { - return `${network[chain].transaction}${item.hash}`; - //} else { - // return `${network[chain].transaction}${item.hash}?network=${currentNetwork[0].toUpperCase() + currentNetwork.slice(1)}`; - //} + return `${network[chain].transaction}${item.hash}`; } return ''; } @@ -221,7 +214,7 @@ function PendingTransaction() { component="p" > {'Started: '}{moment.unix(i.timeStamp).format('lll')}
- {'Completion estimated: '}{completionTime} + {'Completion after: '}{completionTime}
diff --git a/packages/omgx/wallet-frontend/src/containers/farm/Farm.js b/packages/omgx/wallet-frontend/src/containers/farm/Farm.js index 05efec276512..2a4d6f913fed 100644 --- a/packages/omgx/wallet-frontend/src/containers/farm/Farm.js +++ b/packages/omgx/wallet-frontend/src/containers/farm/Farm.js @@ -193,22 +193,6 @@ class Farm extends React.Component { <> - {/* - - - - - In preparation for Mainnet on Sept. 20, the LP pool contracts will be redeployed. If you have funds in the LP pools, - please withdraw those funds now. Your funds are safe, however - a separate page will be provided to withdraw funds from the - Mainnet Beta liquidity pools. - - - - */} - + + Ledger Hardware Wallet L1 to L2 Deposits not working
+ Please make sure that you are using a current firmware version for Ledger, for example, v2.0.0. +
+ L1 to L2 Deposits not working
Please make sure that you are using a current version of MetaMask, for example, 10.1.0. diff --git a/packages/omgx/wallet-frontend/src/containers/home/Home.js b/packages/omgx/wallet-frontend/src/containers/home/Home.js index 9011031325dd..96113c0dd506 100644 --- a/packages/omgx/wallet-frontend/src/containers/home/Home.js +++ b/packages/omgx/wallet-frontend/src/containers/home/Home.js @@ -149,17 +149,17 @@ function Home () { return ( <> - - - + {!!depositModalState && } + {!!transferModalState && } + {!!exitModalState && } - - - + {!!addTokenModalState && } + {!!farmDepositModalState && } + {!!farmWithdrawModalState && } - - - + {!!tranferBobaDaoModalState && } + {!!delegateBobaDaoModalState && } + {!!proposalBobaDaoModalState && } 0) { - res = await dispatch(depositETHL2(value)) - if (res) { - dispatch(setActiveHistoryTab1('L1->L2 Bridge')) - dispatch(openAlert('ETH bridge transaction submitted')) - handleClose() - } + //console.log("Bridging ETH to L2") + res = await dispatch( + depositETHL2(value_Wei_String) + ) + + if (res) { + dispatch(setActiveHistoryTab1('L1->L2 Bridge')) + dispatch(openAlert('ETH bridge transaction submitted')) + handleClose() + } else { + dispatch(openError(`Failed to bridge ETH`)) } + } else { - console.log("Bridging ERC20 to L2") + //console.log("Bridging ERC20 to L2") res = await dispatch( - depositErc20(powAmount(value, token.decimals), token.address, token.addressL2) + depositErc20(value_Wei_String, token.address, token.addressL2) ) if (res) { dispatch(setActiveHistoryTab1('L1->L2 Bridge')) @@ -56,15 +89,6 @@ function InputStep({ handleClose, token }) { } } - function setAmount(value) { - if (Number(value) > 0 && Number(value) < Number(logAmount(token.balance, token.decimals))) { - setDisabledSubmit(false) - } else { - setDisabledSubmit(true) - } - setValue(value) - } - const theme = useTheme() const isMobile = useMediaQuery(theme.breakpoints.down('md')) @@ -85,8 +109,8 @@ function InputStep({ handleClose, token }) { if( Object.keys(lookupPrice) && !!value && - value > 0 && - value <= logAmount(token.balance, token.decimals) && + new BN(value).gt(new BN(0.0)) && + new BN(value).lte(new BN(maxValue)) && !!amountToUsd(value, lookupPrice, token) ) { convertToUSD = true @@ -104,9 +128,17 @@ function InputStep({ handleClose, token }) { placeholder="0.0" value={value} type="number" - onChange={(i)=>setAmount(i.target.value)} + onChange={(i)=>{ + setAmount(i.target.value) + setValue_Wei_String(toWei_String(i.target.value, token.decimals)) + }} + onUseMax={(i)=>{//they want to use the maximum + setAmount(maxValue) //so the input value updates for the user - just for display purposes + setValue_Wei_String(token.balance.toString()) //this is the one that matters + }} + allowUseAll={true} unit={token.symbol} - maxValue={logAmount(token.balance, token.decimals)} + maxValue={maxValue} variant="standard" newStyle /> @@ -117,6 +149,15 @@ function InputStep({ handleClose, token }) {
)} + {!!token && token.symbol === 'OMG' && ( + + NOTE: The OMG Token was minted in 2017 and it does not conform to the ERC20 token standard. + In some cases, three interactions with MetaMask are needed. If you are bridging out of a + new wallet, it starts out with a 0 approval, and therefore, only two interactions with + MetaMask will be needed. + + )} +
+ {amountTx ? {amountTx} : null} diff --git a/packages/omgx/wallet-frontend/src/containers/account/Account.js b/packages/omgx/wallet-frontend/src/containers/account/Account.js index eb3b2808447e..b3d89bafaf4b 100644 --- a/packages/omgx/wallet-frontend/src/containers/account/Account.js +++ b/packages/omgx/wallet-frontend/src/containers/account/Account.js @@ -44,8 +44,6 @@ import NetworkSwitcherIcon from 'components/icons/NetworkSwitcherIcon' import PendingTransaction from './PendingTransaction' import useInterval from 'util/useInterval' -import AlertIcon from 'components/icons/AlertIcon' - const POLL_INTERVAL = 2000; //milliseconds function Account () { @@ -85,10 +83,8 @@ function Account () { },[tokenList, dispatch]) const unorderedTransactions = useSelector(selectTransactions, isEqual) - //console.log("Transactions:",unorderedTransactions) const orderedTransactions = orderBy(unorderedTransactions, i => i.timeStamp, 'desc') - //console.log("orderedTransactions:",orderedTransactions) const pendingL1 = orderedTransactions.filter((i) => { if (i.chain === 'L1pending' && //use the custom API watcher for fast data on pending L1->L2 TXs diff --git a/packages/omgx/wallet-frontend/src/containers/account/PendingTransaction.js b/packages/omgx/wallet-frontend/src/containers/account/PendingTransaction.js index 8a76eb53abc3..29bc130ee457 100644 --- a/packages/omgx/wallet-frontend/src/containers/account/PendingTransaction.js +++ b/packages/omgx/wallet-frontend/src/containers/account/PendingTransaction.js @@ -20,6 +20,9 @@ import { useSelector } from 'react-redux' import { isEqual, orderBy } from 'lodash' import { selectTransactions } from 'selectors/transactionSelector' import { selectNetwork } from 'selectors/setupSelector' +import { selectTokens } from 'selectors/tokenSelector' + +import { logAmount } from 'util/amountConvert' import { getAllNetworks } from 'util/masterConfig' import AlertIcon from 'components/icons/AlertIcon' @@ -33,7 +36,9 @@ function PendingTransaction() { const [page, setPage] = useState(1) const unorderedTransactions = useSelector(selectTransactions, isEqual) - + + const tokenList = useSelector(selectTokens) + const pending = unorderedTransactions.filter((i) => { if (i.crossDomainMessage && i.crossDomainMessage.crossDomainMessage === 1 && @@ -61,7 +66,7 @@ function PendingTransaction() { return false }) pendingExitsStage0 = pendingExitsStage0.map(v => ({ - ...v,label: 'L2->L1 Fast Exit',labelStatus: 'Step 0, No SR Hash yet, Pending', + ...v,label: 'Bridge to L1',labelStatus: 'Step 0, No SR Hash yet, Pending', completion: v.crossDomainMessage.crossDomainMessageEstimateFinalizedTime, }) ) @@ -72,7 +77,7 @@ function PendingTransaction() { return false }) pendingExitsStage1 = pendingExitsStage1.map(v => ({ - ...v, label: 'L2->L1 Fast Exit', labelStatus: 'Step 1, Have SR Hash, Pending', + ...v, label: 'Bridge to L1', labelStatus: 'Step 1, Have SR Hash, Pending', completion: v.crossDomainMessage.crossDomainMessageEstimateFinalizedTime, }) ) @@ -80,11 +85,11 @@ function PendingTransaction() { //Part 3 - exit that is not final, but we have a state root hash, and we ARE NOT using the fast message relayer //so this is a traditional exit let pendingExitsTrad = pendingL2.filter((i) => { - if (i.stateRoot.stateRootHash && !i.action.fast) return true + if (!i.action.fast) return true return false }) pendingExitsTrad = pendingExitsTrad.map(v => ({ - ...v,label: 'L2->L1 Trad Exit',labelStatus: 'In 7 day window', + ...v,label: 'Classical Bridge to L1',labelStatus: 'In 7 day window', completion: v.crossDomainMessage.crossDomainMessageEstimateFinalizedTime, }) ) @@ -95,19 +100,19 @@ function PendingTransaction() { return false }) pendingDepositsFast = pendingDepositsFast.map(v => ({ - ...v,label: 'L1->L2 Fast Deposit',labelStatus: 'Pending', + ...v,label: 'Bridge to L2',labelStatus: 'Pending', completion: v.crossDomainMessage.crossDomainMessageEstimateFinalizedTime, }) ) - //DEPOSIT Part 3 - deposit is not final, but we have a state root hash, and we ARE NOT using the fast message relayer + //DEPOSIT Part 3 - we ARE NOT using the fast message relayer //so this is a traditional deposit let pendingDepositsTrad = pendingL1.filter((i) => { if (!i.action.fast) return true return false }) pendingDepositsTrad = pendingDepositsTrad.map(v => ({ - ...v, label: 'L1->L2 Trad Deposit', labelStatus: 'Pending', + ...v, label: 'Classical Bridge to L2', labelStatus: 'Pending', completion: v.crossDomainMessage.crossDomainMessageEstimateFinalizedTime, }) ) @@ -194,6 +199,21 @@ function PendingTransaction() { let link = chainLink(i) + const chain = (i.chain === 'L1pending') ? 'L1' : i.chain + let amountTx = null; + + if (i.action) { + let token = tokenList[i.action.token.toLowerCase()]; + if (chain === 'L2') { + token = Object.values(tokenList).find(t => t.addressL2.toLowerCase() === i.action.token.toLowerCase()); + } + if (!!token) { + let amount = logAmount(i.action.amount, token.decimals, 3); + let symbol = token[`symbol${chain}`]; + amountTx = `${amount} ${symbol}`; + } + } + return - {i.label} + {i.label} @@ -241,6 +261,15 @@ function PendingTransaction() { + + + {amountTx} + + }) } diff --git a/packages/omgx/wallet-frontend/src/containers/help/Help.js b/packages/omgx/wallet-frontend/src/containers/help/Help.js index f9c1ffb616df..9c05c2e56a21 100644 --- a/packages/omgx/wallet-frontend/src/containers/help/Help.js +++ b/packages/omgx/wallet-frontend/src/containers/help/Help.js @@ -37,6 +37,14 @@ class Help extends React.Component { Common Questions
+ + + + MetaMask does not pop up
+ Some third party popup blockers, such as uBlock Origin, can interfere with MetaMask. + If MetaMask is not popping up, try disabling 3rd party popup blockers. +
+ Ledger Hardware Wallet L1 to L2 Deposits not working
Please make sure that you are using a current firmware version for Ledger, for example, v2.0.0. diff --git a/packages/omgx/wallet-frontend/src/containers/modals/deposit/steps/InputStep.js b/packages/omgx/wallet-frontend/src/containers/modals/deposit/steps/InputStep.js index 573e5f3eb1da..8784b0e7e0c2 100644 --- a/packages/omgx/wallet-frontend/src/containers/modals/deposit/steps/InputStep.js +++ b/packages/omgx/wallet-frontend/src/containers/modals/deposit/steps/InputStep.js @@ -67,7 +67,7 @@ function InputStep({ handleClose, token }) { ) if (res) { - dispatch(setActiveHistoryTab1('L1->L2 Bridge')) + dispatch(setActiveHistoryTab1('Bridge to L2')) dispatch(openAlert('ETH bridge transaction submitted')) handleClose() } else { @@ -80,7 +80,7 @@ function InputStep({ handleClose, token }) { depositErc20(value_Wei_String, token.address, token.addressL2) ) if (res) { - dispatch(setActiveHistoryTab1('L1->L2 Bridge')) + dispatch(setActiveHistoryTab1('Bridge to L2')) dispatch(openAlert(`${token.symbol} bridge transaction submitted`)) handleClose() } else { diff --git a/packages/omgx/wallet-frontend/src/containers/modals/deposit/steps/InputStepFast.js b/packages/omgx/wallet-frontend/src/containers/modals/deposit/steps/InputStepFast.js index 60896d2c8a62..c7152b05bd07 100644 --- a/packages/omgx/wallet-frontend/src/containers/modals/deposit/steps/InputStepFast.js +++ b/packages/omgx/wallet-frontend/src/containers/modals/deposit/steps/InputStepFast.js @@ -89,7 +89,7 @@ function InputStepFast({ handleClose, token }) { res = await dispatch(depositL1LP(token.address, value_Wei_String)) if (res) { - dispatch(setActiveHistoryTab1('L1->L2 Bridge')) + dispatch(setActiveHistoryTab1('Bridge to L2')) dispatch( openAlert( `ETH was bridged. You will receive @@ -126,7 +126,7 @@ function InputStepFast({ handleClose, token }) { ) if (res) { - dispatch(setActiveHistoryTab1('L1->L2 Bridge')) + dispatch(setActiveHistoryTab1('Bridge to L2')) dispatch( openAlert( `${token.symbol} was bridged to the L1LP. You will receive diff --git a/packages/omgx/wallet-frontend/src/containers/modals/wrongnetwork/WrongNetworkModal.js b/packages/omgx/wallet-frontend/src/containers/modals/wrongnetwork/WrongNetworkModal.js index 97479b90e5f7..e52c13fba3df 100644 --- a/packages/omgx/wallet-frontend/src/containers/modals/wrongnetwork/WrongNetworkModal.js +++ b/packages/omgx/wallet-frontend/src/containers/modals/wrongnetwork/WrongNetworkModal.js @@ -68,8 +68,7 @@ function WrongNetworkModal ({ open, onClose }) { } async function correctChain() { - console.log("Correcting the chain") - const res = await networkService.correctChain( networkLayer ) + await networkService.correctChain( networkLayer ) } return ( diff --git a/packages/omgx/wallet-frontend/src/containers/transactions/Deposits.js b/packages/omgx/wallet-frontend/src/containers/transactions/Deposits.js index 4025d38bf55a..1087b440964d 100644 --- a/packages/omgx/wallet-frontend/src/containers/transactions/Deposits.js +++ b/packages/omgx/wallet-frontend/src/containers/transactions/Deposits.js @@ -19,6 +19,9 @@ import { useSelector } from 'react-redux' import moment from 'moment' import { selectLoading } from 'selectors/loadingSelector' +import { selectTokens } from 'selectors/tokenSelector' + +import { logAmount } from 'util/amountConvert' import Pager from 'components/pager/Pager' import Transaction from 'components/transaction/Transaction' @@ -35,6 +38,7 @@ function Deposits({ searchHistory, transactions }) { const [page, setPage] = useState(1); const loading = useSelector(selectLoading(['TRANSACTION/GETALL'])); + const tokenList = useSelector(selectTokens); useEffect(() => { setPage(1); @@ -80,11 +84,27 @@ function Deposits({ searchHistory, transactions }) {
Loading deposits...
)} {paginatedDeposits.map((i, index) => { - const metaData = typeof (i.typeTX) === 'undefined' ? '' : i.typeTX + + if(i.depositL2 === false) return + + const typeTX = typeof(i.typeTX) === 'undefined' ? '' : i.typeTX + const activity = typeof(i.activity) === 'undefined' ? '' : ' (' + i.activity + ')' + let metaData = typeTX + ' ' + activity + const chain = (i.chain === 'L1pending') ? 'L1' : i.chain let details = null + let amountTx = null; + if (i.action && i.action.token) { + const token = tokenList[i.action.token.toLowerCase()]; + if (!!token) { + let amount = logAmount(i.action.amount, token.decimals, 3); + let symbol = token[`symbol${chain}`]; + amountTx = `${amount} ${symbol}`; + } + } + if( i.crossDomainMessage && i.crossDomainMessage.l2BlockHash ) { details = { blockHash: i.crossDomainMessage.l2BlockHash, @@ -101,11 +121,12 @@ function Deposits({ searchHistory, transactions }) { title={`Hash: ${i.hash}`} time={moment.unix(i.timeStamp).format('lll')} blockNumber={`Block ${i.blockNumber}`} - chain={`L1->L2 Deposit`} + chain={`Bridge to L2`} typeTX={`TX Type: ${metaData}`} detail={details} oriChain={chain} oriHash={i.hash} + amountTx={amountTx} /> ) })} diff --git a/packages/omgx/wallet-frontend/src/containers/transactions/Exits.js b/packages/omgx/wallet-frontend/src/containers/transactions/Exits.js index 06bc0b146720..6bc3f5298247 100644 --- a/packages/omgx/wallet-frontend/src/containers/transactions/Exits.js +++ b/packages/omgx/wallet-frontend/src/containers/transactions/Exits.js @@ -19,6 +19,10 @@ import moment from 'moment' import { useSelector } from 'react-redux' import { selectLoading } from 'selectors/loadingSelector' +import { selectTokens } from 'selectors/tokenSelector' + +import { logAmount } from 'util/amountConvert' + import Transaction from 'components/transaction/Transaction' import Pager from 'components/pager/Pager' @@ -36,23 +40,29 @@ function Exits({ searchHistory, transactions, chainLink }) { const [page, setPage] = useState(1); - const loading = useSelector(selectLoading(['EXIT/GETALL'])); + const loading = useSelector(selectLoading(['EXIT/GETALL'])) + + const tokenList = useSelector(selectTokens) const _exits = transactions.filter(i => { return i.hash.includes(searchHistory) && ( i.to !== null && ( i.to.toLowerCase() === networkService.L2LPAddress.toLowerCase() || - //i.to.toLowerCase() === networkService.L2_ETH_Address.toLowerCase() || i.to.toLowerCase() === networkService.L2StandardBridgeAddress.toLowerCase() ) ) }) const renderExits = _exits.map((i, index) => { + + //these are other types of transactions like approvals + if(i.exitL2 === false) return - const metaData = typeof (i.typeTX) === 'undefined' ? '' : i.typeTX const chain = (i.chain === 'L1pending') ? 'L1' : i.chain + const typeTX = typeof(i.typeTX) === 'undefined' ? '' : i.typeTX + const activity = typeof(i.activity) === 'undefined' ? '' : ' (' + i.activity + ')' + let metaData = typeTX + ' ' + activity let isExitable = false let details = null @@ -61,10 +71,20 @@ function Exits({ searchHistory, transactions, chainLink }) { const to = i.to.toLowerCase() + let amountTx = null; + + if (i.action && i.action.token) { + const token = Object.values(tokenList).find(t => t.addressL2.toLowerCase() === i.action.token.toLowerCase()); + if (!!token) { + let amount = logAmount(i.action.amount, token.decimals, 3); + let symbol = token[`symbol${chain}`]; + amountTx = `${amount} ${symbol}`; + } + } + //are we dealing with a traditional exit? if (to === networkService.L2StandardBridgeAddress.toLowerCase()) { - isExitable = moment().isAfter(moment.unix(i.crossDomainMessage.crossDomainMessageEstimateFinalizedTime)) if (isExitable) { @@ -92,7 +112,7 @@ function Exits({ searchHistory, transactions, chainLink }) { return ( ) }) diff --git a/packages/omgx/wallet-frontend/src/containers/transactions/History.js b/packages/omgx/wallet-frontend/src/containers/transactions/History.js index 8b9a13969323..09b0aa08ba5d 100644 --- a/packages/omgx/wallet-frontend/src/containers/transactions/History.js +++ b/packages/omgx/wallet-frontend/src/containers/transactions/History.js @@ -128,7 +128,7 @@ function History() { {dispatch(setActiveHistoryTab1(tab))}} activeTab={activeTab1} - tabs={['All', 'L1->L2 Bridge', 'L2->L1 Bridge']} + tabs={['All', 'Bridge to L2', 'Bridge to L1']} /> {activeTab1 === 'All' && ( @@ -138,14 +138,14 @@ function History() { /> )} - {activeTab1 === 'L1->L2 Bridge' && + {activeTab1 === 'Bridge to L2' && } - {activeTab1 === 'L2->L1 Bridge' && + {activeTab1 === 'Bridge to L1' && { setPage(1); @@ -72,10 +76,27 @@ function Transactions({ searchHistory, transactions }) {
Loading...
)} {paginatedTransactions.map((i, index) => { - const metaData = typeof (i.typeTX) === 'undefined' ? '' : i.typeTX + + const typeTX = typeof(i.typeTX) === 'undefined' ? '' : i.typeTX + const activity = typeof(i.activity) === 'undefined' ? '' : ' (' + i.activity + ')' + let metaData = typeTX + ' ' + activity + const time = moment.unix(i.timeStamp).format('lll') let details = null const chain = (i.chain === 'L1pending') ? 'L1' : i.chain + + let amountTx = null + if (i.action && i.action.token) { + let token = tokenList[i.action.token.toLowerCase()]; + if (chain === 'L2') { + token = Object.values(tokenList).find(t => t.addressL2.toLowerCase() === i.action.token.toLowerCase()); + } + if (!!token) { + let amount = logAmount(i.action.amount, token.decimals, 3); + let symbol = token[`symbol${chain}`]; + amountTx = `${amount} ${symbol}`; + } + } if( i.crossDomainMessage && i.crossDomainMessage.l1BlockHash ) { details = { @@ -108,6 +129,7 @@ function Transactions({ searchHistory, transactions }) { detail={details} oriChain={chain} oriHash={i.hash} + amountTx={amountTx} /> ) })} diff --git a/packages/omgx/wallet-frontend/src/pages/history/index.js b/packages/omgx/wallet-frontend/src/pages/history/index.js index 0cdd2e2d15d0..9390d31ad12b 100644 --- a/packages/omgx/wallet-frontend/src/pages/history/index.js +++ b/packages/omgx/wallet-frontend/src/pages/history/index.js @@ -47,7 +47,7 @@ function HistoryPage() { const [endDate, setEndDate] = useState(null) const [searchTerm, setSearchTerm] = useState('') - const tabList = ['All', 'L1->L2 Bridge', 'L2->L1 Bridge'] + const tabList = ['All', 'Bridge to L2', 'Bridge to L1'] const unorderedTransactions = useSelector(selectTransactions, isEqual); const orderedTransactions = orderBy(unorderedTransactions, i => i.timeStamp, 'desc'); @@ -131,13 +131,13 @@ function HistoryPage() { chainLink={chainLink} /> : null } - {tabList[selectedTab] === 'L1->L2 Bridge' ? + {tabList[selectedTab] === 'Bridge to L2' ? : null } - {tabList[selectedTab] === 'L2->L1 Bridge' ? + {tabList[selectedTab] === 'Bridge to L1' ? L1 Bridge', + activeHistoryTab2: 'Bridge to L1', }; function uiReducer (state = initialState, action) { diff --git a/packages/omgx/wallet-frontend/src/services/networkService.js b/packages/omgx/wallet-frontend/src/services/networkService.js index 2a7cd75799a2..aeaa93b403ce 100644 --- a/packages/omgx/wallet-frontend/src/services/networkService.js +++ b/packages/omgx/wallet-frontend/src/services/networkService.js @@ -70,7 +70,7 @@ import GovernorBravoDelegate from "../deployment/rinkeby/json/GovernorBravoDeleg import GovernorBravoDelegator from "../deployment/rinkeby/json/GovernorBravoDelegator.json" import Timelock from "../deployment/rinkeby/json/Timelock.json" -import { logAmount } from 'util/amountConvert' + import { accDiv, accMul } from 'util/calculation' import { getNftImageUrl } from 'util/nftImage' import { getAllNetworks } from 'util/masterConfig' @@ -936,17 +936,17 @@ class NetworkService { if (to === this.L2LPAddress.toLowerCase()) { //console.log("L2->L1 Swap Off") - return Object.assign({}, item, { typeTX: 'Fast Offramp' }) + return Object.assign({}, item, { typeTX: 'Fast Bridge to L1' }) } if (to === this.L1LPAddress.toLowerCase()) { //console.log("L1->L2 Swap On") - return Object.assign({}, item, { typeTX: 'Fast Onramp' }) + return Object.assign({}, item, { typeTX: 'Fast Bridge to L2' }) } if (to === this.L1StandardBridgeAddress.toLowerCase()) { //console.log("L1->L2 Traditional Deposit") - return Object.assign({}, item, { typeTX: 'Traditional' }) + return Object.assign({}, item, { typeTX: 'Classic Bridge to L2' }) } if (to === this.L1_TEST_Address.toLowerCase()) { @@ -956,7 +956,7 @@ class NetworkService { if (to === this.L2StandardBridgeAddress.toLowerCase()) { //console.log("L2 Standard Bridge") - return Object.assign({}, item, { typeTX: 'L2 Standard Bridge' }) + return Object.assign({}, item, { typeTX: 'Classic Bridge to L1' }) } if (to === this.L1Message.toLowerCase()) { @@ -999,7 +999,7 @@ class NetworkService { } } - return Object.assign({}, item, { typeTX: to }) + return Object.assign({}, item, { typeTX: 'Approval/Other (' + to + ')' }) }) //map @@ -1283,7 +1283,7 @@ class NetworkService { } //Move ETH from L1 to L2 using the standard deposit system - depositETHL2 = async (value = '1') => { + depositETHL2 = async (value_Wei_String) => { updateSignatureStatus_depositTRAD(false) @@ -1292,7 +1292,7 @@ class NetworkService { this.L2GasLimit, utils.formatBytes32String(new Date().getTime().toString()), { - value: parseEther(value) + value: value_Wei_String } ) From 86b0248a5e5748654505c8d19a08024d221e39c9 Mon Sep 17 00:00:00 2001 From: Sahil Kashetwar <86316370+sk-enya@users.noreply.github.com> Date: Fri, 24 Sep 2021 01:32:54 +0530 Subject: [PATCH 24/24] changes: (#527) - fix for date picker selection issue along with colors - fix for disable start date picker https://github.com/omgnetwork/optimism/issues/517 --- .../src/containers/transactions/Deposits.js | 4 +++- .../src/containers/transactions/Exits.js | 4 +++- .../src/containers/transactions/History.js | 16 +++++++++------- packages/omgx/wallet-frontend/src/index.scss | 11 +++++++++++ 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/packages/omgx/wallet-frontend/src/containers/transactions/Deposits.js b/packages/omgx/wallet-frontend/src/containers/transactions/Deposits.js index 1087b440964d..459e626414a7 100644 --- a/packages/omgx/wallet-frontend/src/containers/transactions/Deposits.js +++ b/packages/omgx/wallet-frontend/src/containers/transactions/Deposits.js @@ -85,7 +85,9 @@ function Deposits({ searchHistory, transactions }) { )} {paginatedDeposits.map((i, index) => { - if(i.depositL2 === false) return + if(i.depositL2 === false) { + return null + } const typeTX = typeof(i.typeTX) === 'undefined' ? '' : i.typeTX const activity = typeof(i.activity) === 'undefined' ? '' : ' (' + i.activity + ')' diff --git a/packages/omgx/wallet-frontend/src/containers/transactions/Exits.js b/packages/omgx/wallet-frontend/src/containers/transactions/Exits.js index 6bc3f5298247..921ae74ee5aa 100644 --- a/packages/omgx/wallet-frontend/src/containers/transactions/Exits.js +++ b/packages/omgx/wallet-frontend/src/containers/transactions/Exits.js @@ -56,7 +56,9 @@ function Exits({ searchHistory, transactions, chainLink }) { const renderExits = _exits.map((i, index) => { //these are other types of transactions like approvals - if(i.exitL2 === false) return + if(i.exitL2 === false) { + return null + } const chain = (i.chain === 'L1pending') ? 'L1' : i.chain diff --git a/packages/omgx/wallet-frontend/src/containers/transactions/History.js b/packages/omgx/wallet-frontend/src/containers/transactions/History.js index 09b0aa08ba5d..2d8320360446 100644 --- a/packages/omgx/wallet-frontend/src/containers/transactions/History.js +++ b/packages/omgx/wallet-frontend/src/containers/transactions/History.js @@ -50,8 +50,8 @@ function History() { const isMobile = useMediaQuery(theme.breakpoints.down('md')); const dispatch = useDispatch() - const [startDate, setStartDate] = useState(null) - const [endDate, setEndDate] = useState(null) + const [startDate, setStartDate] = useState(new Date()) + const [endDate, setEndDate] = useState(new Date()) const [searchHistory, setSearchHistory] = useState('') @@ -75,6 +75,9 @@ function History() { }); }, POLL_INTERVAL * 2); + console.log(startDate) + console.log(endDate) + return ( <> @@ -100,8 +103,8 @@ function History() { selected={startDate} onChange={(date) => setStartDate(date)} selectsStart - startDate={startDate} - endDate={endDate} + endDate={new Date(endDate)} + maxDate={new Date(endDate)} calendarClassName={theme.palette.mode} placeholderText={isMobile ? "From" : ""} popperClassName={styles.popperStyle} @@ -114,9 +117,8 @@ function History() { selected={endDate} onChange={(date) => setEndDate(date)} selectsEnd - startDate={startDate} - endDate={endDate} - minDate={startDate} + startDate={new Date(startDate)} + minDate={new Date(startDate)} calendarClassName={theme.palette.mode} placeholderText={isMobile ? "To" : ""} popperClassName={styles.popperStyle} diff --git a/packages/omgx/wallet-frontend/src/index.scss b/packages/omgx/wallet-frontend/src/index.scss index 23c8b84754f8..ffc4e741d335 100644 --- a/packages/omgx/wallet-frontend/src/index.scss +++ b/packages/omgx/wallet-frontend/src/index.scss @@ -233,6 +233,17 @@ $white500: rgba(255, 255, 255, 0.5); color: #FFFFFF !important; } + .react-datepicker__day--disabled { + opacity: 0.4 + } + .react-datepicker__day { + &:hover { + background-color: transparent; + color: #fff; + border-radius: 50%; + border: 0.2px solid #CCFF00; + } + } .react-datepicker__day--keyboard-selected, .react-datepicker__month-text--keyboard-selected, .react-datepicker__quarter-text--keyboard-selected,