Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions packages/boba/gateway/src/actions/createAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ export function createAction (key, asyncAction) {
return false
}

if(response && typeof(response) === 'string' && response.includes('execution reverted: ERC20Permit')) {
if(response && typeof(response) === 'string' && response?.includes('execution reverted: ERC20Permit')) {
let errorMessage = JSON.parse(response)
dispatch({ type: `UI/ERROR/UPDATE`, payload: errorMessage.error.message })
dispatch({ type: `${key}/ERROR` })
Sentry.captureMessage(errorMessage.error.message);
return false
}

if(response && typeof(response) === 'string' && response.includes('Insufficient balance')) {
if(response && typeof(response) === 'string' && response?.includes('Insufficient balance')) {
//let errorMessage = JSON.parse(response)
dispatch({ type: `UI/ERROR/UPDATE`, payload: "Insufficient BOBA balance for emergency swap" })
dispatch({ type: `${key}/ERROR` })
Expand All @@ -59,24 +59,24 @@ export function createAction (key, asyncAction) {
errorMessage = 'MetaMask: Transaction was rejected by user - signature denied'
}
// No internet case - throw up a banner
else if(response.hasOwnProperty('reason') && response.reason.includes('could not detect network')) {
else if(response.hasOwnProperty('reason') && response?.reason?.includes('could not detect network')) {
console.log("Gateway error: No network")
errorMessage = 'Gateway: No internet'
}
// ethers error
else if(response.hasOwnProperty('reason') && response.reason.includes('missing revert data in call exception')) {
else if(response.hasOwnProperty('reason') && response.reason?.includes('missing revert data in call exception')) {
console.log("Slow network or rate throttling - code 1")
// intercept error
return false
}
// ethers error
else if(response.hasOwnProperty('reason') && response.reason.includes('resolver or addr is not configured for ENS name')) {
else if(response.hasOwnProperty('reason') && response.reason?.includes('resolver or addr is not configured for ENS name')) {
console.log("Slow network or rate throttling - code 2")
// intercept error
return false
}
// ethers error
else if(response.hasOwnProperty('reason') && response.reason.includes('missing response')) {
else if(response.hasOwnProperty('reason') && response.reason?.includes('missing response')) {
console.log("Slow network or rate throttling - code 3")
// intercept error
return false
Expand All @@ -92,7 +92,8 @@ export function createAction (key, asyncAction) {
return response || true

} catch (error) {
console.log("Unhandled error RAW:", {error, key, asyncAction})
console.log("Unhandled error RAW:", { error, key, asyncAction })

Sentry.captureException(error);
return false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,18 @@ function GasSwitcher() {
useEffect(() => {
if (baseEnabled) {
dispatch(fetchGas())
dispatch(fetchVerifierStatus())
if(networkService.networkGateway === NETWORK.ETHEREUM) {
dispatch(fetchVerifierStatus())
}
}
}, [ networkName, baseEnabled , dispatch])

useInterval(() => {
if (baseEnabled) {
dispatch(fetchGas())
dispatch(fetchVerifierStatus())
if(networkService.networkGateway === NETWORK.ETHEREUM) {
dispatch(fetchVerifierStatus())
}
}
}, GAS_POLL_INTERVAL)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import truncate from 'truncate-middle'

import { setEnableAccount, setWalletAddress } from 'actions/setupAction'

import { fetchTransactions, fetchBalances } from 'actions/networkAction'
import { fetchTransactions } from 'actions/networkAction'

import { closeModal, openModal } from 'actions/uiAction'
import Button from 'components/button/Button.js'
Expand Down Expand Up @@ -113,7 +113,6 @@ function LayerSwitcher({ visisble = true, isButton = false }) {
dispatch(setEnableAccount(true))
dispatch(setWalletAddress(networkService.account))
dispatch(fetchTransactions())
dispatch(fetchBalances())
return true
} else {
return false
Expand Down
13 changes: 7 additions & 6 deletions packages/boba/gateway/src/containers/devtools/TxBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const TxBuilder = () => {
const TxBuilderResult = useSelector(selectTxBuilder, shallowEqual)
const networkLayer = useSelector(selectLayer())

const blockExplorerUrl = networkService.networkConfig.L2.blockExplorer
const [ contractAddress, setContractAddress ] = useState('')
const [ contractABI, setContractABI ] = useState('')
const [ contractMethos, setContractMethods ] = useState([])
Expand Down Expand Up @@ -86,6 +85,12 @@ const TxBuilder = () => {
dispatch(resetTxBuilder())
}

const viewTx = (txResult) => {
const blockExplorerUrl = networkService.networkConfig['L2'].blockExplorer
const url = `${blockExplorerUrl}tx/${txResult.transactionHash}`
window.open(url, '_blank', 'noopener,noreferrer')
}

const submitTx = async (methodIndex) => {
const method = contractMethos[methodIndex]
const methodName = method.key
Expand Down Expand Up @@ -119,10 +124,6 @@ const TxBuilder = () => {
dispatch(submitTxBuilder(contract, methodIndex, methodName, inputs))
}

const openInNewTab = url => {
window.open(url, '_blank', 'noopener,noreferrer');
};

return (
<S.TxBuilderWrapper>
<Box>
Expand Down Expand Up @@ -209,7 +210,7 @@ const TxBuilder = () => {
<S.TxSuccessWrapper>
<Typography variant="body1" sx={{color: 'green', wordBreak: 'break-all', marginRight: '10px'}}>Succeeded!</Typography>
<Button
onClick={() => openInNewTab(`${blockExplorerUrl}tx/${TxResult.transactionHash}`)}
onClick={() => viewTx(TxResult)}
color='primary'
variant="outlined"
>
Expand Down
7 changes: 6 additions & 1 deletion packages/boba/gateway/src/containers/earn/Earn.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import PageTitle from 'components/pageTitle/PageTitle'
import networkService from 'services/networkService'

import * as S from './Earn.styles'
import { fetchBalances } from 'actions/networkAction';

function Earn() {
const [showMDO, setShowMDO] = useState(false)
Expand Down Expand Up @@ -67,7 +68,11 @@ function Earn() {
if (baseEnabled) {
dispatch(getEarnInfo())
}
}, [dispatch, baseEnabled])

if (accountEnabled) {
dispatch(fetchBalances())
}
}, [dispatch, baseEnabled, accountEnabled])

function getBalance(address, chain) {
if (typeof (layer1Balance) === 'undefined') return [ 0, 0 ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { useTheme } from '@emotion/react'

import { Box, Typography, useMediaQuery } from '@mui/material'

import { depositL1LPBatch, approveFastDepositBatch } from 'actions/networkAction'
import { depositL1LPBatch, approveFastDepositBatch, fetchBalances } from 'actions/networkAction'
import { utils } from 'ethers'

import { openModal, openError, setActiveHistoryTab } from 'actions/uiAction'
Expand Down Expand Up @@ -125,6 +125,8 @@ function InputStepBatch({ isBridge, handleClose }) {
useEffect(() => {
dispatch(fetchL2TotalFeeRate())
dispatch(fetchL1FeeBalance()) //ETH balance for paying gas
dispatch(fetchBalances())

return ()=>{
dispatch({type: 'BALANCE/L2/RESET'})
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@

import { Box, Typography, useMediaQuery, useTheme } from '@mui/material'
import { updateToken } from 'actions/bridgeAction'
import { fetchBalances } from 'actions/networkAction'
import { closeModal } from 'actions/uiAction'
import Modal from 'components/modal/Modal'
import { isEqual } from 'lodash'
import React from 'react'
import React, { useEffect } from 'react'
import { useDispatch, useSelector } from 'react-redux'
import { selectlayer1Balance, selectlayer2Balance } from 'selectors/balanceSelector'
import { selectLayer } from 'selectors/setupSelector'
Expand Down Expand Up @@ -34,6 +35,10 @@ function TokenPickerModal({ open, tokenIndex }) {
balances = l2Balance
}

useEffect(() => {
dispatch(fetchBalances())
}, [dispatch]);

const handleClose = () => {
dispatch(closeModal('tokenPicker'))
}
Expand Down
7 changes: 5 additions & 2 deletions packages/boba/gateway/src/containers/wallet/token/Token.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { selectNetwork } from 'selectors/networkSelector'
import { selectTokens } from 'selectors/tokenSelector'
import { selectTransactions } from 'selectors/transactionSelector'

import { fetchLookUpPrice } from 'actions/networkAction'
import { fetchBalances, fetchLookUpPrice } from 'actions/networkAction'
import { setActiveHistoryTab } from 'actions/uiAction'

import * as S from './Token.styles'
Expand Down Expand Up @@ -111,7 +111,10 @@ function TokenPage() {
if (wAddress.toLowerCase() === gasEstimateAccount.toLowerCase()) {
setDebug(true)
}
}, [accountEnabled])
if (accountEnabled) {
dispatch(fetchBalances())
}
}, [dispatch ,accountEnabled])

const getLookupPrice = useCallback(() => {
if (!accountEnabled) return
Expand Down
1 change: 0 additions & 1 deletion packages/boba/gateway/src/services/networkService.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ class NetworkService {
// if it's false which means boba is getting used as tokenfee which is default value.
feeChoice = !feeChoice;
}
console.log('Fee used as boba', feeChoice)
const bobaFee = {
priceRatio: priceRatio.toString(),
feeChoice
Expand Down