diff --git a/src/actions/balanceAction.js b/src/actions/balanceAction.js deleted file mode 100644 index cd0a0c04..00000000 --- a/src/actions/balanceAction.js +++ /dev/null @@ -1,91 +0,0 @@ -/* - Varna - A Privacy-Preserving Marketplace - Varna uses Fully Homomorphic Encryption to make markets fair. - Copyright (C) 2021 Enya Inc. Palo Alto, CA - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -import networkService from 'services/networkService' -import { createAction } from './createAction' - -export function fetchL1LPBalance(address) { - return createAction('FETCH/L1LP/BALANCE', () => networkService.L1LPBalance(address)) -} - -export function fetchL2LPBalance(address) { - return createAction('FETCH/L2LP/BALANCE', () => networkService.L2LPBalance(address)) -} - -export function fetchL1LPPending(address) { - return createAction('FETCH/L1LP/PENDING', () => networkService.L1LPPending(address)) -} - -export function fetchL2LPPending(address) { - return createAction('FETCH/L2LP/PENDING', () => networkService.L2LPPending(address)) -} - -export function fetchL1LPLiquidity(address) { - return createAction('FETCH/L1LP/LIQUIDITY', () => networkService.L1LPLiquidity(address)) -} - -export function fetchL2LPLiquidity(address) { - return createAction('FETCH/L2LP/LIQUIDITY', () => networkService.L2LPLiquidity(address)) -} - -export function fetchL1TotalFeeRate() { return createAction('FETCH/L1TOTALFEERATE', ()=>{return networkService.getL1TotalFeeRate()}) } -export function fetchL2TotalFeeRate() { return createAction('FETCH/L2TOTALFEERATE', ()=>{return networkService.getL2TotalFeeRate()}) } - -export function fetchL1FeeRateN(tokenAddress) { return createAction('FETCH/L1FEERATE', ()=>{return networkService.getL1UserRewardFeeRate(tokenAddress)}) } -export function fetchL2FeeRateN(tokenAddress) { return createAction('FETCH/L2FEERATE', ()=>{return networkService.getL2UserRewardFeeRate(tokenAddress)}) } - -export function fetchFastExitCost(address) { - return createAction('FETCH/FASTEXIT/COST', () => networkService.getFastExitCost(address)) -} - -export function fetchClassicExitCost(address) { - return createAction('FETCH/CLASSICEXIT/COST', () => networkService.getExitCost(address)) -} - -export function fetchFastDepositCost(address) { - return createAction('FETCH/FASTDEPOSIT/COST', () => networkService.getFastDepositCost(address)) -} - -export function fetchAltL1DepositFee() { - return createAction('FETCH/ALTL1DEPOSIT/COST', () => networkService.getAltL1DepositFee()) -} - -export function fetchFastDepositBatchCost(tokenList) { - return createAction('FETCH/FASTDEPOSIT/BATCH/COST', () => networkService.getFastDepositBatchCost(tokenList)) -} - -export function fetchL1FeeBalance() { - return createAction('FETCH/L1FEE/BALANCE', () => networkService.getL1FeeBalance()) -} - -export function fetchL2BalanceETH() { - return createAction('FETCH/L2ETH/BALANCE', () => networkService.getL2BalanceETH()) -} - -export function fetchL2BalanceBOBA() { - return createAction('FETCH/L2BOBA/BALANCE', () => networkService.getL2BalanceBOBA()) -} - -export function fetchUserAndL2LPBalanceBatch(tokenList) { - return createAction('FETCH/USER/L2LP/BALANCE/BATCH', () => networkService.getL2UserAndLPBalanceBatch(tokenList)) -} - -export function fetchExitFee() { - return createAction('FETCH/EXITFEE', () => networkService.getExitFeeFromBillingContract()) -} diff --git a/src/actions/balanceAction.ts b/src/actions/balanceAction.ts new file mode 100644 index 00000000..c305b066 --- /dev/null +++ b/src/actions/balanceAction.ts @@ -0,0 +1,90 @@ +/* + Varna - A Privacy-Preserving Marketplace + Varna uses Fully Homomorphic Encryption to make markets fair. + Copyright (C) 2021 Enya Inc. Palo Alto, CA + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +import networkService from 'services/networkService' +import { createAction } from './createAction' + +export const fetchL1LPBalance = (address: string) => + createAction('FETCH/L1LP/BALANCE', () => networkService.L1LPBalance(address)) + +export const fetchL2LPBalance = (address: string) => + createAction('FETCH/L2LP/BALANCE', () => networkService.L2LPBalance(address)) + +export const fetchL1LPPending = (address: string) => + createAction('FETCH/L1LP/PENDING', () => networkService.L1LPPending(address)) + +export const fetchL2LPPending = (address: string) => + createAction('FETCH/L2LP/PENDING', () => networkService.L2LPPending(address)) + +export const fetchL1LPLiquidity = (address: string) => + createAction('FETCH/L1LP/LIQUIDITY', () => + networkService.L1LPLiquidity(address) + ) + +export const fetchL2LPLiquidity = (address: string) => + createAction('FETCH/L2LP/LIQUIDITY', () => + networkService.L2LPLiquidity(address) + ) + +export const fetchL1TotalFeeRate = () => + createAction('FETCH/L1TOTALFEERATE', () => { + return networkService.getL1TotalFeeRate() + }) +export const fetchL2TotalFeeRate = () => + createAction('FETCH/L2TOTALFEERATE', () => { + return networkService.getL2TotalFeeRate() + }) + +export const fetchL1FeeRateN = (tokenAddress: string) => + createAction('FETCH/L1FEERATE', () => { + return networkService.getL1UserRewardFeeRate(tokenAddress) + }) +export const fetchL2FeeRateN = (tokenAddress: string) => + createAction('FETCH/L2FEERATE', () => { + return networkService.getL2UserRewardFeeRate(tokenAddress) + }) + +export const fetchFastExitCost = (address: string) => + createAction('FETCH/FASTEXIT/COST', () => + networkService.getFastExitCost(address) + ) + +export const fetchClassicExitCost = (address: string) => + createAction('FETCH/CLASSICEXIT/COST', () => + networkService.getExitCost(address) + ) + +export const fetchFastDepositCost = (address: string) => + createAction('FETCH/FASTDEPOSIT/COST', () => + networkService.getFastDepositCost(address) + ) + +export const fetchL1FeeBalance = () => + createAction('FETCH/L1FEE/BALANCE', () => networkService.getL1FeeBalance()) + +export const fetchL2BalanceETH = () => + createAction('FETCH/L2ETH/BALANCE', () => networkService.getL2BalanceETH()) + +export const fetchL2BalanceBOBA = () => + createAction('FETCH/L2BOBA/BALANCE', () => networkService.getL2BalanceBOBA()) + +export const fetchExitFee = () => + createAction('FETCH/EXITFEE', () => + networkService.getExitFeeFromBillingContract() + ) diff --git a/src/actions/bridgeAction.js b/src/actions/bridgeAction.js deleted file mode 100644 index 24b864cd..00000000 --- a/src/actions/bridgeAction.js +++ /dev/null @@ -1,123 +0,0 @@ -/* -Copyright 2021-present Boba Network. - -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 store from "store"; - -export function setToken(token) { - return function (dispatch) { - return dispatch({ type: 'BRIDGE/TOKEN/SELECT', payload: token }); - } -} - -export function resetToken() { - return function (dispatch) { - return dispatch({ type: 'BRIDGE/TOKEN/RESET' }); - } -} - -export function removeToken(tokenIndex) { - return function (dispatch) { - return dispatch({ type: 'BRIDGE/TOKEN/REMOVE', payload: tokenIndex }); - } -} - -export function setTokenAmount(payload) { - return function (dispatch) { - return dispatch({ type: 'BRIDGE/TOKEN/AMOUNT/CHANGE', payload }); - } -} - -export function updateToken(payload) { - return function (dispatch) { - return dispatch({ type: 'BRIDGE/TOKEN/UPDATE', payload }); - } -} - -export function setBridgeType(type) { - return function (dispatch) { - return dispatch({ type: 'BRIDGE/TYPE/SELECT', payload: type }); - } -} - -export function setMultiBridgeMode(mode) { - return function (dispatch) { - return dispatch({ type: 'BRIDGE/MODE/CHANGE', payload: mode }); - } -} - -export function setBridgeDestinationAddress(payload) { - return function (dispatch) { - return dispatch({type: 'BRIDGE/DESTINATION_ADDRESS/SET', payload }) - } -} - -export function resetBridgeDestinationAddress() { - return function(dispatch) { - return dispatch({type: 'BRIDGE/DESTINATION_ADDRESS/RESET'}); - } -} - -// updates value indicating wether the 'to address' field should be available -export function setBridgeDestinationAddressAvailable(payload) { - return function (dispatch) { - return dispatch({ type: 'BRIDGE/DESTINATION_ADDRESS_AVAILABLE/SET', payload }); - } -} - -export function setBridgeAlert(payload) { - return function (dispatch) { - return dispatch({ type: 'BRIDGE/ALERT/SET', payload }); - } -} - -export function clearBridgeAlert(payload) { - return function (dispatch) { - return dispatch({ type: 'BRIDGE/ALERT/CLEAR', payload }); - } -} - -export function purgeBridgeAlert(payload) { - return function (dispatch) { - return dispatch({ type: 'BRIDGE/ALERT/PURGE', payload }); - } -} - -export function setAmountToBridge(payload) { - return function (dispatch) { - return dispatch({ type: 'BRIDGE/AMOUNT/SET', payload }); - } -} - -export function resetBridgeAmount() { - return function (dispatch) { - return dispatch({ type: 'BRIDGE/AMOUNT/RESET'}); - } -} - -export function setTeleportationOfAssetSupported(payload) { - return function (dispatch) { - return dispatch({ type: 'BRIDGE/TELEPORTER/TOKEN_SUPPORTED', payload}) - } -} - -export function setTeleportationDestChainId(payload) { - return function (dispatch) { - return dispatch({ type: 'BRIDGE/TELEPORTER/DEST_CHAIN_ID', payload}) - } -} - -export function setFetchDepositTxBlock(payload) { - store.dispatch({ type: 'BRIDGE/DEPOSIT_TX/BLOCK', payload}) -} diff --git a/src/actions/bridgeAction.ts b/src/actions/bridgeAction.ts new file mode 100644 index 00000000..e92799e3 --- /dev/null +++ b/src/actions/bridgeAction.ts @@ -0,0 +1,82 @@ +/* +Copyright 2021-present Boba Network. + +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 store from 'store' +import { BigNumberish } from 'ethers' + +export interface IBridgeAltert { + meta: string + type: string + text: string +} + +export const resetToken = () => (dispatch) => + dispatch({ type: 'BRIDGE/TOKEN/RESET' }) + +export const updateToken = (payload?) => (dispatch) => + dispatch({ type: 'BRIDGE/TOKEN/UPDATE', payload }) + +export const setBridgeType = (type) => (dispatch) => + dispatch({ type: 'BRIDGE/TYPE/SELECT', payload: type }) + +export const setBridgeDestinationAddress = (payload: string) => (dispatch) => + dispatch({ + type: 'BRIDGE/DESTINATION_ADDRESS/SET', + payload, + }) + +export const resetBridgeDestinationAddress = () => (dispatch) => + dispatch({ type: 'BRIDGE/DESTINATION_ADDRESS/RESET' }) + +// updates value indicating wether the 'to address' field should be available +export const setBridgeDestinationAddressAvailable = + (payload: boolean) => (dispatch) => + dispatch({ + type: 'BRIDGE/DESTINATION_ADDRESS_AVAILABLE/SET', + payload, + }) + +export const setBridgeAlert = (payload: IBridgeAltert) => (dispatch) => + dispatch({ type: 'BRIDGE/ALERT/SET', payload }) + +export const clearBridgeAlert = (payload: { keys: string[] }) => (dispatch) => + dispatch({ type: 'BRIDGE/ALERT/CLEAR', payload }) + +export const purgeBridgeAlert = (payload?) => (dispatch) => + dispatch({ type: 'BRIDGE/ALERT/PURGE', payload }) + +export const setAmountToBridge = (payload?) => (dispatch) => + dispatch({ type: 'BRIDGE/AMOUNT/SET', payload }) + +export const resetBridgeAmount = () => (dispatch) => + dispatch({ type: 'BRIDGE/AMOUNT/RESET' }) + +export const setTeleportationOfAssetSupported = + (payload: boolean) => (dispatch) => + dispatch({ + type: 'BRIDGE/TELEPORTER/TOKEN_SUPPORTED', + payload, + }) + +export const setTeleportationDestChainId = + (payload: BigNumberish) => (dispatch) => + dispatch({ + type: 'BRIDGE/TELEPORTER/DEST_CHAIN_ID', + payload, + }) + +export const setFetchDepositTxBlock = (payload?) => { + store.dispatch({ type: 'BRIDGE/DEPOSIT_TX/BLOCK', payload }) +} diff --git a/src/actions/createAction.js b/src/actions/createAction.js deleted file mode 100644 index 6b99479d..00000000 --- a/src/actions/createAction.js +++ /dev/null @@ -1,104 +0,0 @@ -/* -Copyright 2021-present Boba Network. - -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 * as Sentry from '@sentry/react'; - -export function createAction (key, asyncAction) { - - return async function (dispatch) { - - dispatch({ type: `${key}/REQUEST` }) - - try { - const response = await asyncAction() - - if( response === false ) { - return false - } - - 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')) { - //let errorMessage = JSON.parse(response) - dispatch({ type: `UI/ERROR/UPDATE`, payload: "Insufficient BOBA balance for emergency swap" }) - dispatch({ type: `${key}/ERROR` }) - Sentry.captureMessage("Insufficient BOBA balance for emergency swap"); - return false - } - - //deal with metamask errors - they will have a 'code' field so we can detect those - if(response && response.hasOwnProperty('message') && response.hasOwnProperty('code')) { - Sentry.captureMessage(response.reason) - if(response.hasOwnProperty('reason')) console.log("Error reason:", response.reason) - - // the basic error message - let errorMessage = response.message - - // provide more information in special cases - // MetaMask user rejected sig - throw up a banner - if ((response.code === 4001 || - response.hasOwnProperty('reason')) - && response?.reason?.includes('user rejected transaction') - ) { - console.log("MetaMask: user denied signature") - 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')) { - 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')) { - 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')) { - 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')) { - console.log("Slow network or rate throttling - code 3") - // intercept error - return false - } - - dispatch({ type: `UI/ERROR/UPDATE`, payload: errorMessage }) - dispatch({ type: `${key}/ERROR` }) - - return false - } - - dispatch({ type: `${key}/SUCCESS`, payload: response }) - return response || true - - } catch (error) { - console.log("Unhandled error RAW:", { error, key, asyncAction }) - - Sentry.captureException(error); - return false - } - } -} diff --git a/src/actions/createAction.ts b/src/actions/createAction.ts new file mode 100644 index 00000000..9fe32ec6 --- /dev/null +++ b/src/actions/createAction.ts @@ -0,0 +1,135 @@ +/* +Copyright 2021-present Boba Network. + +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 * as Sentry from '@sentry/react' + +export const createAction = + (key: string, asyncAction: () => any) => async (dispatch) => { + dispatch({ type: `${key}/REQUEST` }) + + try { + const response = await asyncAction() + + if (response === false) { + return false + } + + if ( + response && + typeof response === 'string' && + response?.includes('execution reverted: ERC20Permit') + ) { + const 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') + ) { + //let errorMessage = JSON.parse(response) + dispatch({ + type: `UI/ERROR/UPDATE`, + payload: 'Insufficient BOBA balance for emergency swap', + }) + dispatch({ type: `${key}/ERROR` }) + Sentry.captureMessage('Insufficient BOBA balance for emergency swap') + return false + } + + //deal with metamask errors - they will have a 'code' field so we can detect those + if ( + response && + response.hasOwnProperty('message') && + response.hasOwnProperty('code') + ) { + Sentry.captureMessage(response.reason) + if (response.hasOwnProperty('reason')) { + console.log('Error reason:', response.reason) + } + + // the basic error message + let errorMessage = response.message + + // provide more information in special cases + // MetaMask user rejected sig - throw up a banner + if ( + (response.code === 4001 || response.hasOwnProperty('reason')) && + response?.reason?.includes('user rejected transaction') + ) { + console.log('MetaMask: user denied signature') + 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') + ) { + 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') + ) { + 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' + ) + ) { + 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') + ) { + console.log('Slow network or rate throttling - code 3') + // intercept error + return false + } + + dispatch({ type: `UI/ERROR/UPDATE`, payload: errorMessage }) + dispatch({ type: `${key}/ERROR` }) + + return false + } + + dispatch({ type: `${key}/SUCCESS`, payload: response }) + return response || true + } catch (error) { + console.log('Unhandled error RAW:', { error, key, asyncAction }) + + Sentry.captureException(error) + return false + } + } diff --git a/src/actions/daoAction.js b/src/actions/daoAction.js deleted file mode 100644 index e434d5f6..00000000 --- a/src/actions/daoAction.js +++ /dev/null @@ -1,79 +0,0 @@ -/* - Varna - A Privacy-Preserving Marketplace - Varna uses Fully Homomorphic Encryption to make markets fair. - Copyright (C) 2021 Enya Inc. Palo Alto, CA - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -import networkService from 'services/networkService'; -import { createAction } from './createAction' - -/***********************************************/ -/***** DAO Action *****/ -/***********************************************/ - -export function fetchDaoBalance() { - return createAction('BALANCE/DAO/GET', () => networkService.getDaoBalance()) -} - -export function fetchDaoVotes() { - return createAction('VOTES/DAO/GET', () => networkService.getDaoVotes()) -} - -export function fetchDaoBalanceX() { - return createAction('BALANCEX/DAO/GET', () => networkService.getDaoBalanceX()) -} - -export function fetchDaoVotesX() { - return createAction('VOTESX/DAO/GET', () => networkService.getDaoVotesX()) -} - -export function transferDao({ recipient, amount }) { - return createAction('TRANSFER/DAO/CREATE', () => networkService.transferDao({ recipient, amount })) -} - -export function delegateVotes({ recipient }) { - return createAction('DELEGATE/VOTES/CREATE', () => networkService.delegateVotes({ recipient })) -} - -export function delegateVotesX({ recipient }) { - return createAction('DELEGATEX/VOTES/CREATE', () => networkService.delegateVotesX({ recipient })) -} - -export function getProposalThreshold() { - return createAction('PROPOSALTHRESHOLD/GET', () => networkService.getProposalThreshold()) -} - -export function fetchDaoProposals() { - return createAction('PROPOSALS/GET', () => networkService.fetchProposals()) -} - -export function createDaoProposal(payload) { - return createAction('PROPOSAL/CREATE', () => networkService.createProposal(payload)) -} - -export function queueProposal(proposalID) { - return createAction('PROPOSAL/QUEUE', () => networkService.queueProposal(proposalID)) -} - -export function executeProposal(proposalID) { - return createAction('PROPOSAL/EXECUTE', () => networkService.executeProposal(proposalID)) -} - -export function castProposalVote(payload) { - return createAction('PROPOSAL/CAST/VOTE', () => networkService.castProposalVote(payload)) -} - - diff --git a/src/actions/daoAction.ts b/src/actions/daoAction.ts new file mode 100644 index 00000000..f61857d1 --- /dev/null +++ b/src/actions/daoAction.ts @@ -0,0 +1,72 @@ +/* + Varna - A Privacy-Preserving Marketplace + Varna uses Fully Homomorphic Encryption to make markets fair. + Copyright (C) 2021 Enya Inc. Palo Alto, CA + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +import networkService from 'services/networkService' +import { createAction } from './createAction' + +/***********************************************/ +/***** DAO Action *****/ +/***********************************************/ + +/***** DAO Action *****/ +export const fetchDaoBalance = () => + createAction('BALANCE/DAO/GET', () => networkService.getDaoBalance()) + +export const fetchDaoVotes = () => + createAction('VOTES/DAO/GET', () => networkService.getDaoVotes()) + +export const fetchDaoBalanceX = () => + createAction('BALANCEX/DAO/GET', () => networkService.getDaoBalanceX()) + +export const fetchDaoVotesX = () => + createAction('VOTESX/DAO/GET', () => networkService.getDaoVotesX()) + +export const delegateVotes = ({ recipient }) => + createAction('DELEGATE/VOTES/CREATE', () => + networkService.delegateVotes({ recipient }) + ) + +export const delegateVotesX = ({ recipient }) => + createAction('DELEGATEX/VOTES/CREATE', () => + networkService.delegateVotesX({ recipient }) + ) + +export const getProposalThreshold = () => + createAction('PROPOSALTHRESHOLD/GET', () => + networkService.getProposalThreshold() + ) + +export const fetchDaoProposals = () => + createAction('PROPOSALS/GET', () => networkService.fetchProposals()) + +export const createDaoProposal = (payload) => + createAction('PROPOSAL/CREATE', () => networkService.createProposal(payload)) + +export const queueProposal = (proposalID) => + createAction('PROPOSAL/QUEUE', () => networkService.queueProposal(proposalID)) + +export const executeProposal = (proposalID) => + createAction('PROPOSAL/EXECUTE', () => + networkService.executeProposal(proposalID) + ) + +export const castProposalVote = (payload) => + createAction('PROPOSAL/CAST/VOTE', () => + networkService.castProposalVote(payload) + ) diff --git a/src/actions/devToolsAction.js b/src/actions/devToolsAction.ts similarity index 67% rename from src/actions/devToolsAction.js rename to src/actions/devToolsAction.ts index ab0b064f..5ac55510 100644 --- a/src/actions/devToolsAction.js +++ b/src/actions/devToolsAction.ts @@ -17,15 +17,19 @@ along with this program. If not, see . */ -import networkService from 'services/networkService'; +import networkService from 'services/networkService' import { createAction } from './createAction' +import { Contract } from 'ethers' -export function submitTxBuilder(contract, methodIndex, methodName, inputs) { - return createAction('TX_BUILDER', () => networkService.submitTxBuilder(contract, methodIndex, methodName, inputs)) -} +export const submitTxBuilder = ( + contract: Contract, + methodIndex: number, + methodName: string, + inputs: any +) => + createAction('TX_BUILDER', () => + networkService.submitTxBuilder(contract, methodIndex, methodName, inputs) + ) -export function resetTxBuilder() { - return function (dispatch) { - return dispatch({ type: 'TX_BUILDER/REST'}) - } -} +export const resetTxBuilder = () => (dispatch) => + dispatch({ type: 'TX_BUILDER/REST' }) diff --git a/src/actions/earnAction.js b/src/actions/earnAction.js deleted file mode 100644 index e7d0b911..00000000 --- a/src/actions/earnAction.js +++ /dev/null @@ -1,124 +0,0 @@ -/* - Varna - A Privacy-Preserving Marketplace - Varna uses Fully Homomorphic Encryption to make markets fair. - Copyright (C) 2021 Enya Inc. Palo Alto, CA - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -import networkService from 'services/networkService' -import { createAction } from './createAction' - -const getEarnInfoBegin = () => ({ - type: 'GET_EARNINFO', -}) - -const getEarnInfoSuccess = (L1PoolInfo, L1UserInfo, L2PoolInfo, L2UserInfo) => ({ - type: 'GET_EARNINFO_SUCCESS', - payload: { L1PoolInfo, L1UserInfo, L2PoolInfo, L2UserInfo } -}) - -// const getL1FeeBegin = () => ({ -// type: 'GET_USERINFO', -// }) - -// const getL2FeeBegin = () => ({ -// type: 'GET_USERINFO', -// }) - -// const getL1FeeSuccess = (totalFeeRate, userRewardFeeRate) => ({ -// type: 'GET_L1FEE_SUCCESS', -// payload: { totalFeeRate, userRewardFeeRate }, -// }) - -// const getL2FeeSuccess = (totalFeeRate, userRewardFeeRate) => ({ -// type: 'GET_L2FEE_SUCCESS', -// payload: { totalFeeRate, userRewardFeeRate }, -// }) - -export const getEarnInfo = () => async (dispatch) => { - dispatch(getEarnInfoBegin()) - const [L1LPInfo, L2LPInfo] = await Promise.all([ - networkService.getL1LPInfo(), - networkService.getL2LPInfo(), - ]) - dispatch(getEarnInfoSuccess( - L1LPInfo.poolInfo, - L1LPInfo.userInfo, - L2LPInfo.poolInfo, - L2LPInfo.userInfo, - )) -} - -// export const getL1Fee = () => async (dispatch) => { -// dispatch(getL1FeeBegin()) -// const [totalFeeRate, userFeeRate] = await Promise.all([ -// networkService.getL1TotalFeeRate(), -// networkService.getL1UserRewardFeeRate(), -// ]) -// console.log("L1 totalFeeRate",totalFeeRate) -// console.log("L1 userRewardFeeRate",userFeeRate) -// dispatch(getL1FeeSuccess(totalFeeRate, userFeeRate)) -// } - -// export const getL2Fee = () => async (dispatch) => { -// dispatch(getL2FeeBegin()) -// const [totalFeeRate, userFeeRate] = await Promise.all([ -// networkService.getL2TotalFeeRate(), -// networkService.getL2UserRewardFeeRate(), -// ]) -// console.log("L2 totalFeeRate",totalFeeRate) -// console.log("L2 userRewardFeeRate",userFeeRate) -// dispatch(getL2FeeSuccess(totalFeeRate, userFeeRate)) -// } - -export function fetchL1UserFee(currency) {return createAction('FETCH/L1USERFEE', () => networkService.getL1UserRewardFeeRate(currency))} -export function fetchL2UserFee(currency) {return createAction('FETCH/L2USERFEE', () => networkService.getL2UserRewardFeeRate(currency))} - -export const updateStakeToken = (stakeToken) => ({ - type: 'UPDATE_STAKE_TOKEN', - payload: stakeToken, -}) - -export const updateWithdrawToken = (withdrawToken) => ({ - type: 'UPDATE_WITHDRAW_TOKEN', - payload: withdrawToken, -}) - -export function fetchAllowance(currency, lpAddress) { - return createAction('FETCH/ALLOWANCE', () => networkService.checkAllowance( - currency, - lpAddress - )) -} - -export function addLiquidity( - currency, - weiString, - L1orL2Pool -) { - return createAction('ADD/LIQUIDITY', () => networkService.addLiquidity( - currency, - weiString, - L1orL2Pool - )) -} - -export function fetchL1LPBalance(currency) { - return createAction('FETCH/L1LPBALANCE', () => networkService.L1LPBalance(currency)) -} - -export function fetchL2LPBalance(currency) { - return createAction('FETCH/L2LPBALANCE', () => networkService.L2LPBalance(currency)) -} diff --git a/src/actions/earnAction.ts b/src/actions/earnAction.ts new file mode 100644 index 00000000..860dbf7b --- /dev/null +++ b/src/actions/earnAction.ts @@ -0,0 +1,81 @@ +/* + Varna - A Privacy-Preserving Marketplace + Varna uses Fully Homomorphic Encryption to make markets fair. + Copyright (C) 2021 Enya Inc. Palo Alto, CA + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +import networkService from 'services/networkService' +import { createAction } from './createAction' + +const getEarnInfoBegin = () => ({ + type: 'GET_EARNINFO', +}) + +const getEarnInfoSuccess = ( + L1PoolInfo, + L1UserInfo, + L2PoolInfo, + L2UserInfo +) => ({ + type: 'GET_EARNINFO_SUCCESS', + payload: { L1PoolInfo, L1UserInfo, L2PoolInfo, L2UserInfo }, +}) + +export const getEarnInfo = () => async (dispatch) => { + dispatch(getEarnInfoBegin()) + const [L1LPInfo, L2LPInfo] = await Promise.all([ + networkService.getL1LPInfo(), + networkService.getL2LPInfo(), + ]) + dispatch( + getEarnInfoSuccess( + L1LPInfo.poolInfo, + L1LPInfo.userInfo, + L2LPInfo.poolInfo, + L2LPInfo.userInfo + ) + ) +} + +export const updateStakeToken = (stakeToken: string) => ({ + type: 'UPDATE_STAKE_TOKEN', + payload: stakeToken, +}) + +export const updateWithdrawToken = (withdrawToken: string) => ({ + type: 'UPDATE_WITHDRAW_TOKEN', + payload: withdrawToken, +}) + +export const fetchAllowance = (currency: string, lpAddress: string) => + createAction('FETCH/ALLOWANCE', () => + networkService.checkAllowance(currency, lpAddress) + ) + +export const addLiquidity = ( + currency: string, + weiString: string, + L1orL2Pool: string +) => + createAction('ADD/LIQUIDITY', () => + networkService.addLiquidity(currency, weiString, L1orL2Pool) + ) + +export const fetchL1LPBalance = (currency: string) => + createAction('FETCH/L1LPBALANCE', () => networkService.L1LPBalance(currency)) + +export const fetchL2LPBalance = (currency: string) => + createAction('FETCH/L2LPBALANCE', () => networkService.L2LPBalance(currency)) diff --git a/src/actions/fixedAction.js b/src/actions/fixedAction.ts similarity index 64% rename from src/actions/fixedAction.js rename to src/actions/fixedAction.ts index d6058090..09694f53 100644 --- a/src/actions/fixedAction.js +++ b/src/actions/fixedAction.ts @@ -20,18 +20,16 @@ import networkService from 'services/networkService' import { createAction } from './createAction' -export function addFS_Savings(weiString) { - return createAction('ADD/FS_SAVINGS', () => networkService.addFS_Savings(weiString)) -} +export const addFS_Savings = (weiString: string) => + createAction('ADD/FS_SAVINGS', () => networkService.addFS_Savings(weiString)) -export function withdrawFS_Savings(stakeID) { - return createAction('WITHDRAW/FS_SAVINGS', () => networkService.withdrawFS_Savings(stakeID)) -} +export const withdrawFS_Savings = (stakeID: number) => + createAction('WITHDRAW/FS_SAVINGS', () => + networkService.withdrawFS_Savings(stakeID) + ) -export function getFS_Saves(currency) { - return createAction('GET/FS_SAVES', () => networkService.getFS_Saves()) -} +export const getFS_Saves = () => + createAction('GET/FS_SAVES', () => networkService.getFS_Saves()) -export function getFS_Info(currency) { - return createAction('GET/FS_INFO', () => networkService.getFS_Info()) -} \ No newline at end of file +export const getFS_Info = () => + createAction('GET/FS_INFO', () => networkService.getFS_Info()) diff --git a/src/actions/networkAction.js b/src/actions/networkAction.js deleted file mode 100644 index b75e39f6..00000000 --- a/src/actions/networkAction.js +++ /dev/null @@ -1,283 +0,0 @@ -/* -Copyright 2021-present Boba Network. - -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 networkService from 'services/networkService' -import transactionService from 'services/transaction.service' -import { createAction } from './createAction' - -export function fetchBalances() { - return createAction('BALANCE/GET', () => networkService.getBalances()) -} - -export function addTokenList() { - return createAction('TOKENLIST/GET', () => networkService.addTokenList()) -} - -export function fetchTransactions() { - return createAction('TRANSACTION/GETALL', () => - transactionService.getTransactions() - ) -} - -export function fetchSevens() { - return createAction('SEVENS/GETALL', () => - transactionService.getSevens() - ) -} - -export function fetchFastExits() { - return createAction('FASTEXITS/GETALL', () => - transactionService.getFastExits() - ) -} - -export function exitBOBA(token, value) { - return createAction('EXIT/CREATE', () => - networkService.exitBOBA(token, value) - ) -} - -//SWAP RELATED -export function depositL1LP(currency,value) { - return createAction('DEPOSIT/CREATE', () => - networkService.depositL1LP(currency,value) - ) -} - -export function isTeleportationOfAssetSupported(layer, asset, destChainId) { - return createAction('DEPOSIT/TELEPORTATION/TOKEN_SUPPORTED', () => - networkService.isTeleportationOfAssetSupported(layer, asset, destChainId) - ) -} - -export function depositWithTeleporter(layer, currency, value, destChainId) { - return createAction('DEPOSIT/CREATE', () => - networkService.depositWithTeleporter(layer, currency, value, destChainId) - ) -} - -export function depositL1LPBatch(payload) { - return createAction('DEPOSIT/CREATE', () => - networkService.depositL1LPBatch(payload) - ) -} - -//SWAP RELATED - Depositing into the L2LP triggers the swap-exit -export function depositL2LP(token, value) { - return createAction('EXIT/CREATE', () => - networkService.depositL2LP(token, value) - ) -} - -//SWAP RELATED - Depositing into the L2LP triggers the swap-exit - variant of depositL2LP -//that handles Exit All -export function fastExitAll(token) { - return createAction('EXIT/CREATE', () => - networkService.fastExitAll(token) - ) -} - -//CLASSIC DEPOSIT ETH -export function depositETHL2(payload) { - return createAction('DEPOSIT/CREATE', () => { - return networkService.depositETHL2(payload) - } - ) -} - -//DEPOSIT ERC20 -export function depositErc20(payload) { - return createAction('DEPOSIT/CREATE', () => - networkService.depositErc20(payload) - ) -} - -//DEPOSIT ERC20 to Alt L1 bridge -export function depositErc20ToL1(payload) { - return createAction('DEPOSIT_ALTL1/CREATE', () => networkService.depositErc20ToL1(payload)) -} - -//EARN -export function earnL1(value_Wei_String, currencyAddress) { - return createAction('EARN/CREATE', () => - networkService.approveERC20_L1LP(value_Wei_String, currencyAddress) - ) -} -export function earnL2(value_Wei_String, currencyAddress) { - return createAction('EARN/CREATE', () => - networkService.approveERC20_L2LP(value_Wei_String, currencyAddress) - ) -} -export function getReward(currencyAddress, value_Wei_String, L1orL2Pool) { - return createAction('EARN/HARVEST', () => - networkService.getReward(currencyAddress, value_Wei_String, L1orL2Pool) - ) -} - -export function withdrawLiquidity(currencyAddress, value_Wei_String, L1orL2Pool) { - - return createAction('EARN/WITHDRAW', () => - networkService.withdrawLiquidity(currencyAddress, value_Wei_String, L1orL2Pool) - ) -} - -export function approveERC20( - value, - currency, - approveContractAddress, - contractABI -) { - return createAction('APPROVE/CREATE', () => - networkService.approveERC20( - value, - currency, - approveContractAddress, - contractABI - ) - ) -} - -export function approveFastDepositBatch(payload) { - return createAction('APPROVE/CREATE', () => - networkService.approveFastDepositBatch( - payload - ) - ) -} - -export function approveERC20_L2LP( - value, - currency, -) { - return createAction('APPROVE/CREATE', () => - networkService.approveERC20_L2LP( - value, - currency, - ) - ) -} - -export function approveERC20_L1LP( - value, - currency, -) { - return createAction('APPROVE/CREATE', () => - networkService.approveERC20_L1LP( - value, - currency, - ) - ) -} - -export function transfer(recipient, value, currency) { - return createAction('TRANSFER/CREATE', () => - networkService.transfer(recipient, value, currency) - ) -} - -export function transferEstimate(value_Wei_String, currency) { - return createAction('TRANSFER_ESTIMATE/CREATE', () => - networkService.transferEstimate(value_Wei_String, currency) - ) -} - -export function transferNFT(recipient, nft) { - return createAction('TRANSFER_NFT/CREATE', () => - networkService.transferNFT(recipient, nft) - ) -} - -export function settle_v0() { - return createAction('SETTLE_v0/CREATE', () => - networkService.settle_v0() - ) -} - -export function settle_v1() { - return createAction('SETTLE_v1/CREATE', () => - networkService.settle_v1() - ) -} - -export function settle_v2() { - return createAction('SETTLE_v2/CREATE', () => - networkService.settle_v2() - ) -} - -export function settle_v2OLO() { - return createAction('SETTLE_v2OLO/CREATE', () => - networkService.settle_v2OLO() - ) -} - -export function settle_v3() { - return createAction('SETTLE_v3/CREATE', () => - networkService.settle_v3() - ) -} - -export function settle_v3OLO() { - return createAction('SETTLE_v3OLO/CREATE', () => - networkService.settle_v3OLO() - ) -} - -export function fetchLookUpPrice(params) { - return createAction('PRICE/GET', () => - networkService.fetchLookUpPrice(params)) -} - -export function clearLookupPrice() { - return function (dispatch) { - return dispatch({ type: 'LOOKUP/PRICE/CLEAR' }) - } -} - -export function enableBrowserWallet(network) { - return createAction('ENABLE/BROWSER/WALLET', () => networkService.enableBrowserWallet(network)) -} - -export function getAllAddresses() { - return createAction('GET/ALL/ADDRESS', () => networkService.getAllAddresses()) -} - - -/********************************/ -/******ONE GATEWAY ACTIONS *****/ -/********************************/ -/** - * @params - * network - ethereum, bnb - * networkType - MAINNET, TESTNET -*/ -export function setNetwork(payload) { - return function (dispatch) { - return dispatch({ type: 'NETWORK/SET', payload: payload }) - } -} - -// to update the active network. -export function setActiveNetwork(payload) { - return function (dispatch) { - return dispatch({ type: 'NETWORK/SET/ACTIVE' }) - } -} - -export function setActiveNetworkType(payload) { - return function (dispatch) { - return dispatch({ type: 'NETWORK/SET_TYPE/ACTIVE', payload }) - } -} diff --git a/src/actions/networkAction.ts b/src/actions/networkAction.ts new file mode 100644 index 00000000..9212736a --- /dev/null +++ b/src/actions/networkAction.ts @@ -0,0 +1,163 @@ +/* +Copyright 2021-present Boba Network. + +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 networkService from 'services/networkService' +import transactionService from 'services/transaction.service' +import { createAction } from './createAction' +import { BigNumberish } from 'ethers' + +export const fetchBalances = () => + createAction('BALANCE/GET', () => networkService.getBalances()) + +export const addTokenList = () => + createAction('TOKENLIST/GET', () => networkService.addTokenList()) + +export const fetchTransactions = () => + createAction('TRANSACTION/GETALL', () => transactionService.getTransactions()) + +export const fetchSevens = () => + createAction('SEVENS/GETALL', () => transactionService.getSevens()) + +export const fetchFastExits = () => + createAction('FASTEXITS/GETALL', () => transactionService.getFastExits()) + +export const exitBOBA = (token: string, value: BigNumberish) => + createAction('EXIT/CREATE', () => networkService.exitBOBA(token, value)) + +//SWAP RELATED +export const depositL1LP = (currency: string, value: BigNumberish) => + createAction('DEPOSIT/CREATE', () => + networkService.depositL1LP(currency, value) + ) + +export const isTeleportationOfAssetSupported = ( + layer: string, + asset: string, + destChainId: string +) => + createAction('DEPOSIT/TELEPORTATION/TOKEN_SUPPORTED', () => + networkService.isTeleportationOfAssetSupported(layer, asset, destChainId) + ) + +export const depositWithLightBridge = ( + layer: string, + currency: string, + value: BigNumberish, + destChainId: BigNumberish +) => + createAction('DEPOSIT/CREATE', () => + networkService.depositWithTeleporter(layer, currency, value, destChainId) + ) + +//SWAP RELATED - Depositing into the L2LP triggers the swap-exit +export const depositL2LP = (token: string, value: BigNumberish) => + createAction('EXIT/CREATE', () => networkService.depositL2LP(token, value)) + +//CLASSIC DEPOSIT ETH +export const depositETHL2 = (payload) => + createAction('DEPOSIT/CREATE', () => { + return networkService.depositETHL2(payload) + }) + +//DEPOSIT ERC20 +export const depositErc20 = (payload) => + createAction('DEPOSIT/CREATE', () => networkService.depositErc20(payload)) + +//EARN +export const earnL1 = ( + value_Wei_String: BigNumberish, + currencyAddress: string +) => + createAction('EARN/CREATE', () => + networkService.approveERC20_L1LP(value_Wei_String, currencyAddress) + ) +export const earnL2 = ( + value_Wei_String: BigNumberish, + currencyAddress: string +) => + createAction('EARN/CREATE', () => + networkService.approveERC20_L2LP(value_Wei_String, currencyAddress) + ) +export const getReward = ( + currencyAddress: string, + value_Wei_String: BigNumberish, + L1orL2Pool: string +) => + createAction('EARN/HARVEST', () => + networkService.getReward(currencyAddress, value_Wei_String, L1orL2Pool) + ) + +export const withdrawLiquidity = ( + currencyAddress: string, + value_Wei_String: string, + L1orL2Pool: string +) => + createAction('EARN/WITHDRAW', () => + networkService.withdrawLiquidity( + currencyAddress, + value_Wei_String, + L1orL2Pool + ) + ) + +export const approveERC20 = ( + value: BigNumberish, + currency: string, + approveContractAddress: string, + contractABI? +) => + createAction('APPROVE/CREATE', () => + networkService.approveERC20( + value, + currency, + approveContractAddress, + contractABI + ) + ) + +export const transfer = ( + recipient: string, + value: BigNumberish, + currency: string +) => + createAction('TRANSFER/CREATE', () => + networkService.transfer(recipient, value, currency) + ) + +export const fetchLookUpPrice = (params) => + createAction('PRICE/GET', () => networkService.fetchLookUpPrice(params)) + +export const clearLookupPrice = () => (dispatch) => + dispatch({ type: 'LOOKUP/PRICE/CLEAR' }) + +export const getAllAddresses = () => + createAction('GET/ALL/ADDRESS', () => networkService.getAllAddresses()) + +/********************************/ +/******ONE GATEWAY ACTIONS *****/ +/********************************/ +/** + * @param payload: {network: ethereum, bnb, networkType + * @param networkType: MAINNET, TESTNET + */ +export const setNetwork = (payload) => (dispatch) => + dispatch({ type: 'NETWORK/SET', payload }) + +// to update the active network. +export const setActiveNetwork = () => (dispatch) => + dispatch({ type: 'NETWORK/SET/ACTIVE' }) + +export const setActiveNetworkType = (payload) => (dispatch) => + dispatch({ type: 'NETWORK/SET_TYPE/ACTIVE', payload }) diff --git a/src/actions/setupAction.js b/src/actions/setupAction.js deleted file mode 100644 index 0a5cc6d0..00000000 --- a/src/actions/setupAction.js +++ /dev/null @@ -1,102 +0,0 @@ -/* -Copyright 2021-present Boba Network. - -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 networkService from 'services/networkService' -import { createAction } from './createAction' -import store from 'store' - -export function setEnableAccount(enabled) { - return function (dispatch) { - return dispatch({ type: 'SETUP/ACCOUNT/SET', payload: enabled }) - } -} - -export function setBaseState(enabled) { - return function (dispatch) { - return dispatch({ type: 'SETUP/BASE/SET', payload: enabled }) - } -} - -export function setLayer(layer) { - return function (dispatch) { - return dispatch({ type: 'SETUP/LAYER/SET', payload: layer }) - } -} - -export function setWalletAddress(account) { - return function (dispatch) { - return dispatch({ type: 'SETUP/WALLETADDRESS/SET', payload: account }) - } -} - -export function switchChain(layer) { - return createAction('SETUP/SWITCH', () => networkService.switchChain(layer)) -} - -export function switchFee(targetFee) { - return createAction('SETUP/SWITCHFEE', () => networkService.switchFee(targetFee)) -} - -export function getETHMetaTransaction() { - return createAction('SETUP/GETETH', () => networkService.getETHMetaTransaction()) -} - -export async function addBobaFee ( bobaFee ) { - store.dispatch({ type: 'BOBAFEE/ADD/SUCCESS', payload: bobaFee }) -} - -export function setConnectETH( state ) { - return function (dispatch) { - return dispatch({ type: 'SETUP/CONNECT_ETH', payload: state }) - } -} - -export function setConnectBOBA( state ) { - return function (dispatch) { - return dispatch({ type: 'SETUP/CONNECT_BOBA', payload: state }) - } -} - -export function setConnect( state ) { - return function (dispatch) { - return dispatch({ type: 'SETUP/CONNECT', payload: state }) - } -} - -export function setWalletConnected( state ) { - return function (dispatch) { - return dispatch({ type: 'SETUP/WALLET_CONNECTED', payload: state }) - } -} - -export function setChainIdChanged(state) { - return function (dispatch) { - return dispatch({ type: 'SETUP/CHAINIDCHANGED/SET', payload: state }) - } -} - -export function resetChainIdChanged() { - return function (dispatch) { - return dispatch({ type: 'SETUP/CHAINIDCHANGED/RESET' }) - } -} - - -export function disconnectSetup() { - return function(dispatch) { - return dispatch({type: 'SETUP/DISCONNECT'}) - } -} \ No newline at end of file diff --git a/src/actions/setupAction.ts b/src/actions/setupAction.ts new file mode 100644 index 00000000..de92f2ad --- /dev/null +++ b/src/actions/setupAction.ts @@ -0,0 +1,55 @@ +/* +Copyright 2021-present Boba Network. + +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 networkService from 'services/networkService' +import { createAction } from './createAction' +import store from 'store' + +export const setEnableAccount = (enabled) => (dispatch) => + dispatch({ type: 'SETUP/ACCOUNT/SET', payload: enabled }) + +export const setBaseState = (enabled) => (dispatch) => + dispatch({ type: 'SETUP/BASE/SET', payload: enabled }) + +export const setLayer = (layer) => (dispatch) => + dispatch({ type: 'SETUP/LAYER/SET', payload: layer }) + +export const setWalletAddress = (account) => (dispatch) => + dispatch({ type: 'SETUP/WALLETADDRESS/SET', payload: account }) + +export const switchFee = (targetFee) => + createAction('SETUP/SWITCHFEE', () => networkService.switchFee(targetFee)) + +export const getETHMetaTransaction = () => + createAction('SETUP/GETETH', () => networkService.getETHMetaTransaction()) + +export const addBobaFee = async (bobaFee) => { + store.dispatch({ type: 'BOBAFEE/ADD/SUCCESS', payload: bobaFee }) +} + +export const setConnectETH = (state) => (dispatch) => + dispatch({ type: 'SETUP/CONNECT_ETH', payload: state }) + +export const setConnectBOBA = (state) => (dispatch) => + dispatch({ type: 'SETUP/CONNECT_BOBA', payload: state }) + +export const setConnect = (state) => (dispatch) => + dispatch({ type: 'SETUP/CONNECT', payload: state }) + +export const setChainIdChanged = (state) => (dispatch) => + dispatch({ type: 'SETUP/CHAINIDCHANGED/SET', payload: state }) + +export const disconnectSetup = () => (dispatch) => + dispatch({ type: 'SETUP/DISCONNECT' }) diff --git a/src/actions/signAction.js b/src/actions/signAction.ts similarity index 55% rename from src/actions/signAction.js rename to src/actions/signAction.ts index 562d869f..94b8a0eb 100644 --- a/src/actions/signAction.js +++ b/src/actions/signAction.ts @@ -13,16 +13,16 @@ 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 store from 'store'; +import store from 'store' -export async function updateSignatureStatus_exitLP ( sigStatus ) { - store.dispatch({type: 'EXIT/LP/SIGNED',payload: sigStatus}) +export const updateSignatureStatus_exitLP = async (sigStatus: boolean) => { + store.dispatch({ type: 'EXIT/LP/SIGNED', payload: sigStatus }) } -export async function updateSignatureStatus_exitTRAD ( sigStatus ) { - store.dispatch({type: 'EXIT/TRAD/SIGNED',payload: sigStatus}) +export const updateSignatureStatus_exitTRAD = async (sigStatus: boolean) => { + store.dispatch({ type: 'EXIT/TRAD/SIGNED', payload: sigStatus }) } -export async function updateSignatureStatus_depositLP ( sigStatus ) { - store.dispatch({type: 'DEPOSIT/LP/SIGNED',payload: sigStatus}) +export const updateSignatureStatus_depositLP = async (sigStatus: boolean) => { + store.dispatch({ type: 'DEPOSIT/LP/SIGNED', payload: sigStatus }) } diff --git a/src/actions/tokenAction.js b/src/actions/tokenAction.ts similarity index 58% rename from src/actions/tokenAction.js rename to src/actions/tokenAction.ts index 4154462e..ad4afa75 100644 --- a/src/actions/tokenAction.js +++ b/src/actions/tokenAction.ts @@ -30,9 +30,10 @@ EVERYTHING IS INDEXED BY L1 TOKEN ADDRESS const ETHL1 = '0x0000000000000000000000000000000000000000' const ETHL2 = '0x4200000000000000000000000000000000000006' -export async function getToken ( tokenContractAddressL1 ) { - - if( tokenContractAddressL1 === null) return +export const getToken = async (tokenContractAddressL1: string) => { + if (tokenContractAddressL1 === null) { + return + } //this *might* be coming from a person, and or copy-paste from Etherscan //so need toLowerCase() @@ -54,9 +55,10 @@ export async function getToken ( tokenContractAddressL1 ) { /* Get the token info from networkService.web3.eth.Contract */ -export async function addToken ( tokenContractAddressL1 ) { - - if( tokenContractAddressL1 === null ) return +export const addToken = async (tokenContractAddressL1: string) => { + if (tokenContractAddressL1 === null) { + return + } const state = store.getState() @@ -68,93 +70,86 @@ export async function addToken ( tokenContractAddressL1 ) { //if we already have looked it up, no need to look up again. if (state.tokenList[_tokenContractAddressL1]) { - console.log("token already in list:",_tokenContractAddressL1) - return state.tokenList[_tokenContractAddressL1]; + console.log('token already in list:', _tokenContractAddressL1) + return state.tokenList[_tokenContractAddressL1] } try { - - let tA = networkService.tokenAddresses + const tA: any = networkService.tokenAddresses let tokenContract - let _tokenContractAddressL2 = null + let _tokenContractAddressL2: string /********* DO WE HAVE L2 DATA?? *************/ // Let's go see // console.log("Addresses for lookup:", networkService.tokenAddresses) - if(_tokenContractAddressL1 === 'xboba') { - if(tA['xBOBA'].L2 !== null) _tokenContractAddressL2 = tA['xBOBA'].L2.toLowerCase() + if (_tokenContractAddressL1 === 'xboba') { + _tokenContractAddressL2 = tA['xBOBA']?.L2?.toLowerCase() tokenContract = new ethers.Contract( _tokenContractAddressL2, erc20abi, - networkService.L2Provider, + networkService.L2Provider! ) } else if (_tokenContractAddressL1 === 'wagmiv0') { - if(tA['WAGMIv0'].L2 !== null) _tokenContractAddressL2 = tA['WAGMIv0'].L2.toLowerCase() + _tokenContractAddressL2 = tA['WAGMIv0']?.L2?.toLowerCase() tokenContract = new ethers.Contract( _tokenContractAddressL2, erc20abi, - networkService.L2Provider, + networkService.L2Provider! ) } else if (_tokenContractAddressL1 === 'wagmiv1') { - if(tA['WAGMIv1'].L2 !== null) _tokenContractAddressL2 = tA['WAGMIv1'].L2.toLowerCase() + _tokenContractAddressL2 = tA['WAGMIv1']?.L2?.toLowerCase() tokenContract = new ethers.Contract( _tokenContractAddressL2, erc20abi, - networkService.L2Provider, + networkService.L2Provider! ) - } - else if (_tokenContractAddressL1 === 'wagmiv2') { - if(tA['WAGMIv2'].L2 !== null) _tokenContractAddressL2 = tA['WAGMIv2'].L2.toLowerCase() + } else if (_tokenContractAddressL1 === 'wagmiv2') { + _tokenContractAddressL2 = tA['WAGMIv2']?.L2?.toLowerCase() tokenContract = new ethers.Contract( _tokenContractAddressL2, erc20abi, - networkService.L2Provider, + networkService.L2Provider! ) - } - else if (_tokenContractAddressL1 === 'wagmiv2-oolong') { - if(tA['WAGMIv2-Oolong'].L2 !== null) _tokenContractAddressL2 = tA['WAGMIv2-Oolong'].L2.toLowerCase() + } else if (_tokenContractAddressL1 === 'wagmiv2-oolong') { + _tokenContractAddressL2 = tA['WAGMIv2-Oolong']?.L2?.toLowerCase() tokenContract = new ethers.Contract( _tokenContractAddressL2, erc20abi, - networkService.L2Provider, + networkService.L2Provider! ) - } - else if (_tokenContractAddressL1 === 'wagmiv3') { - if(tA['WAGMIv3'].L2 !== null) _tokenContractAddressL2 = tA['WAGMIv3'].L2.toLowerCase() + } else if (_tokenContractAddressL1 === 'wagmiv3') { + _tokenContractAddressL2 = tA['WAGMIv3']?.L2?.toLowerCase() tokenContract = new ethers.Contract( _tokenContractAddressL2, erc20abi, - networkService.L2Provider, + networkService.L2Provider! ) - } - else if (_tokenContractAddressL1 === 'wagmiv3-oolong') { - if(tA['WAGMIv3-Oolong'].L2 !== null) _tokenContractAddressL2 = tA['WAGMIv3-Oolong'].L2.toLowerCase() + } else if (_tokenContractAddressL1 === 'wagmiv3-oolong') { + _tokenContractAddressL2 = tA['WAGMIv3-Oolong']?.L2?.toLowerCase() tokenContract = new ethers.Contract( _tokenContractAddressL2, erc20abi, - networkService.L2Provider, + networkService.L2Provider! ) - } - else if (_tokenContractAddressL1 === 'olo') { - if(tA['OLO'].L2 !== null) _tokenContractAddressL2 = tA['OLO'].L2.toLowerCase() + } else if (_tokenContractAddressL1 === 'olo') { + _tokenContractAddressL2 = tA['OLO']?.L2?.toLowerCase() tokenContract = new ethers.Contract( _tokenContractAddressL2, erc20abi, - networkService.L2Provider, + networkService.L2Provider! ) } else { Object.keys(tA).forEach((token, i) => { //let's see if we know about this Token - if(_tokenContractAddressL1 === tA[token].L1.toLowerCase()) { - if( tA[token].L2 !== null) - _tokenContractAddressL2 = tA[token].L2.toLowerCase() + if (_tokenContractAddressL1 === tA[token].L1.toLowerCase()) { + _tokenContractAddressL2 = tA[token]?.L2?.toLowerCase() } }) tokenContract = new ethers.Contract( _tokenContractAddressL1, erc20abi, - networkService.L1Provider, //Everything is defined by the L1 address - will deal with the L2 address later + networkService.L1Provider! //Everything is defined by the L1 address - will deal with the L2 address later ) } @@ -163,71 +158,84 @@ export async function addToken ( tokenContractAddressL1 ) { let _name if (ethers.utils.isAddress(_tokenContractAddressL1)) { - const tokenInfo = networkService.tokenInfo.L1[ethers.utils.getAddress(_tokenContractAddressL1)] - if (tokenInfo) { - _symbolL1 = tokenInfo.symbol - _decimals = tokenInfo.decimals - _name = tokenInfo.name + const tmpTokenInfo = + networkService.tokenInfo.L1[ + ethers.utils.getAddress(_tokenContractAddressL1) + ] + if (tmpTokenInfo) { + _symbolL1 = tmpTokenInfo.symbol + _decimals = tmpTokenInfo.decimals + _name = tmpTokenInfo.name } } if (!_symbolL1 || !_decimals || !_name) { - [ _symbolL1, _decimals, _name ] = await Promise.all([ + ;[_symbolL1, _decimals, _name] = await Promise.all([ tokenContract.symbol(), tokenContract.decimals(), - tokenContract.name() - ]).catch(e => [ null, null, null ]) + tokenContract.name(), + ]).catch((e) => [null, null, null]) } - const decimals = _decimals ? Number(_decimals.toString()) : 'NOT ON ETHEREUM' + const decimals = _decimals + ? Number(_decimals.toString()) + : 'NOT ON ETHEREUM' const symbolL1 = _symbolL1 || 'NOT ON ETHEREUM' const symbolL2 = _symbolL1 || 'NOT ON ETHEREUM' const name = _name || 'NOT ON ETHEREUM' //ETH is special as always - if(_tokenContractAddressL1 === ETHL1 ) { + if (_tokenContractAddressL1 === ETHL1) { _tokenContractAddressL2 = ETHL2 } const tokenInfo = { - currency: ( - _symbolL1 === 'xBOBA' || + currency: + _symbolL1 === 'xBOBA' || _symbolL1 === 'WAGMIv0' || _symbolL1 === 'WAGMIv1' || _symbolL1 === 'WAGMIv2' || _symbolL1 === 'WAGMIv2-Oolong' || _symbolL1 === 'WAGMIv3' || _symbolL1 === 'WAGMIv3-Oolong' - ) ? _tokenContractAddressL2 : _tokenContractAddressL1, + ? _tokenContractAddressL2! + : _tokenContractAddressL1, addressL1: _tokenContractAddressL1, - addressL2: _tokenContractAddressL2, + addressL2: _tokenContractAddressL2!, symbolL1, symbolL2, decimals, name, - redalert: _decimals ? false : true + redalert: !_decimals, } store.dispatch({ type: 'TOKEN/GET/SUCCESS', - payload: tokenInfo - }); + payload: tokenInfo, + }) return tokenInfo - } catch (error) { - store.dispatch({ type: 'TOKEN/GET/FAILURE', - payload: {currency: _tokenContractAddressL1, L1address: _tokenContractAddressL1, L2address: '', symbol: 'Not found', error: 'Not found'}, + payload: { + currency: _tokenContractAddressL1, + L1address: _tokenContractAddressL1, + L2address: '', + symbol: 'Not found', + error: 'Not found', + }, }) - return {currency: _tokenContractAddressL1, L1address: _tokenContractAddressL1, L2address: '', symbol: 'Not found', error: 'Not found'}; + return { + currency: _tokenContractAddressL1, + L1address: _tokenContractAddressL1, + L2address: '', + symbol: 'Not found', + error: 'Not found', + } } } -export function restTokenList () { - return function (dispatch) { - return dispatch({ type: 'TOKEN/GET/RESET' }); - } -} +export const restTokenList = () => (dispatch) => + dispatch({ type: 'TOKEN/GET/RESET' }) diff --git a/src/actions/transactionAction.js b/src/actions/transactionAction.ts similarity index 67% rename from src/actions/transactionAction.js rename to src/actions/transactionAction.ts index a2e84cfe..794a92d1 100644 --- a/src/actions/transactionAction.js +++ b/src/actions/transactionAction.ts @@ -13,14 +13,5 @@ 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. */ -export function setCDMCompletion (payload) { - return function (dispatch) { - return dispatch({ type: 'CDM/COMPLETE/SET', payload }); - } -} - -export function resetCDMCompletion () { - return function (dispatch) { - return dispatch({ type: 'CDM/COMPLETE/RESET' }); - } -} +export const resetCDMCompletion = () => (dispatch) => + dispatch({ type: 'CDM/COMPLETE/RESET' }) diff --git a/src/actions/uiAction.js b/src/actions/uiAction.js deleted file mode 100644 index e6d92653..00000000 --- a/src/actions/uiAction.js +++ /dev/null @@ -1,80 +0,0 @@ -/* -Copyright 2021-present Boba Network. - -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. */ - -export function setTheme (theme) { - return function (dispatch) { - return dispatch({ type: 'UI/THEME/UPDATE', payload: theme }); - } -} - -export function openModal (modal, token, fast, tokenIndex, lock, proposalId, selectionLayer, destNetworkSelection) { - return function (dispatch) { - return dispatch({ type: 'UI/MODAL/OPEN', payload: modal, token, fast, tokenIndex, lock, proposalId, selectionLayer, destNetworkSelection }); - } -} - -export function closeModal (modal) { - return function (dispatch) { - return dispatch({ type: 'UI/MODAL/CLOSE', payload: modal }); - } -} - -export function openAlert (message) { - return function (dispatch) { - return dispatch({ type: 'UI/ALERT/UPDATE', payload: message }); - } -} - -export function closeAlert () { - return function (dispatch) { - return dispatch({ type: 'UI/ALERT/UPDATE', payload: null }); - } -} - -export function openError (message) { - return function (dispatch) { - return dispatch({ type: 'UI/ERROR/UPDATE', payload: message }); - } -} - -export function closeError () { - return function (dispatch) { - return dispatch({ type: 'UI/ERROR/UPDATE', payload: null }); - } -} - -export function ledgerConnect (derivation) { - return function (dispatch) { - return dispatch({ type: 'UI/LEDGER/UPDATE', payload: derivation }); - } -} - -export function setActiveHistoryTab (tab) { - return function (dispatch) { - return dispatch({ type: 'UI/HISTORYTAB/UPDATE', payload: tab }); - } -} - -export function setActiveDataTab (tab) { - return function (dispatch) { - return dispatch({ type: 'UI/DATATAB/UPDATE', payload: tab }); - } -} - -export function setModalData (modal, data) { - return function (dispatch) { - return dispatch({ type: 'UI/MODAL/DATA', payload: { modal, data } }); - } -} diff --git a/src/actions/uiAction.ts b/src/actions/uiAction.ts new file mode 100644 index 00000000..df2a982b --- /dev/null +++ b/src/actions/uiAction.ts @@ -0,0 +1,56 @@ +/* +Copyright 2021-present Boba Network. + +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. */ + +export const setTheme = (theme) => (dispatch) => + dispatch({ type: 'UI/THEME/UPDATE', payload: theme }) + +export const openModal = + ( + modal?, + token?, + fast?, + tokenIndex?, + lock?, + proposalId?, + selectionLayer?, + destNetworkSelection? + ) => + (dispatch) => + dispatch({ + type: 'UI/MODAL/OPEN', + payload: modal, + token, + fast, + tokenIndex, + lock, + proposalId, + selectionLayer, + destNetworkSelection, + }) + +export const closeModal = (modal) => (dispatch) => + dispatch({ type: 'UI/MODAL/CLOSE', payload: modal }) + +export const openAlert = (message) => (dispatch) => + dispatch({ type: 'UI/ALERT/UPDATE', payload: message }) + +export const closeAlert = () => (dispatch) => + dispatch({ type: 'UI/ALERT/UPDATE', payload: null }) + +export const openError = (message) => (dispatch) => + dispatch({ type: 'UI/ERROR/UPDATE', payload: message }) + +export const closeError = () => (dispatch) => + dispatch({ type: 'UI/ERROR/UPDATE', payload: null }) diff --git a/src/actions/verifierAction.js b/src/actions/verifierAction.ts similarity index 68% rename from src/actions/verifierAction.js rename to src/actions/verifierAction.ts index a3c4509f..87f1f5e1 100644 --- a/src/actions/verifierAction.js +++ b/src/actions/verifierAction.ts @@ -14,14 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. */ import verifierService from 'services/verifier.service' -import {createAction} from './createAction' +import { createAction } from './createAction' -export function fetchVerifierStatus() { - return createAction('VERIFIER/GET',() => verifierService.getVerifierStatus()) -} +export const fetchVerifierStatus = () => + createAction('VERIFIER/GET', () => verifierService.getVerifierStatus()) -export function resetVerifierStatus() { - return function(dispatch) { - return dispatch({type: 'VERIFIER/RESET'}); - } -} +export const resetVerifierStatus = () => (dispatch) => + dispatch({ type: 'VERIFIER/RESET' }) diff --git a/src/containers/modals/walletSelector/WalletSelectorModal.js b/src/containers/modals/walletSelector/WalletSelectorModal.js index d0582a09..b46be5ae 100644 --- a/src/containers/modals/walletSelector/WalletSelectorModal.js +++ b/src/containers/modals/walletSelector/WalletSelectorModal.js @@ -6,7 +6,8 @@ import { closeModal } from 'actions/uiAction' import { setConnectBOBA, setConnectETH, -} from 'actions/setupAction.js' + setConnect +} from 'actions/setupAction' import Modal from 'components/modal/Modal' import { Typography } from 'components/global/typography' @@ -19,7 +20,6 @@ import ArrowIcon from 'assets/images/icons/arrowright.svg' import { Wallets, Wallet, Icon, ArrowContainer, IconContainer } from './styles' import { useWalletConnect } from 'hooks/useWalletConnect' -import { setConnect } from 'actions/setupAction' import styled from 'styled-components' const StyledSvg = styled(Svg)` diff --git a/src/hooks/useBridge/index.ts b/src/hooks/useBridge/index.ts index 63b8625b..c56341b6 100644 --- a/src/hooks/useBridge/index.ts +++ b/src/hooks/useBridge/index.ts @@ -4,7 +4,7 @@ import { depositETHL2, depositL1LP, depositL2LP, - depositWithTeleporter, + depositWithLightBridge, exitBOBA, } from 'actions/networkAction' import { closeModal, openError, openModal } from 'actions/uiAction' @@ -129,7 +129,7 @@ export const useBridge = () => { } } return dispatch( - depositWithTeleporter(layer, token.address, amountWei, destChainId) + depositWithLightBridge(layer, token.address, amountWei, destChainId) ) } diff --git a/src/util/network/network.util.ts b/src/util/network/network.util.ts index 35f9b0be..aad6ad38 100644 --- a/src/util/network/network.util.ts +++ b/src/util/network/network.util.ts @@ -89,6 +89,11 @@ export const CHAIN_ID_LIST = { }, } +export interface INetworkClass { + network: typeof NETWORK + networkType: typeof NETWORK_TYPE +} + export interface INetwork { icon: string chain: string