Skip to content

Commit

Permalink
Merge pull request #227 from G7DAO/feat/network-toggle
Browse files Browse the repository at this point in the history
Feat/network toggle
  • Loading branch information
elclandestin0 authored Dec 4, 2024
2 parents ef888e5 + 0e5e1c4 commit ad7eed5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
8 changes: 5 additions & 3 deletions webapps/world-builder-dashboard/constants.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { NetworkInterface, HighNetworkInterface, NetworkType } from '@/contexts/BlockchainContext'
import { TokenAddressMap } from 'game7-bridge-sdk'
import * as dotenv from 'dotenv';
dotenv.config()

export const L1_NETWORK: NetworkInterface = {
chainId: 11155111,
name: 'sepolia',
displayName: 'Sepolia',
rpcs: ['https://eth-sepolia.g.alchemy.com/v2/C-njXZM_UTlPbC2ukOvg4ojFz2V9yCS6'],
rpcs: ['https://eth-sepolia.g.alchemy.com/v2/'],
blockExplorerUrls: ['https://sepolia.etherscan.io'],
nativeCurrency: {
decimals: 18,
Expand Down Expand Up @@ -57,7 +59,7 @@ export const L1_MAIN_NETWORK: NetworkInterface = {
chainId: 1,
name: 'ethereum',
displayName: 'Ethereum',
rpcs: ['https://eth-mainnet.g.alchemy.com/v2/C-njXZM_UTlPbC2ukOvg4ojFz2V9yCS6'],
rpcs: [`https://eth-mainnet.g.alchemy.com/v2/${process.env.ALCHEMY_KEY}`],
blockExplorerUrls: ['https://etherscan.io'],
nativeCurrency: {
decimals: 18,
Expand All @@ -73,7 +75,7 @@ export const L2_MAIN_NETWORK: NetworkInterface = {
chainId: 42161,
name: 'arbitrumOne',
displayName: 'Arbitrum One',
rpcs: ['https://arb-mainnet.g.alchemy.com/v2/C-njXZM_UTlPbC2ukOvg4ojFz2V9yCS6'],
rpcs: [`https://arb-mainnet.g.alchemy.com/v2/${process.env.ALCHEMY_KEY}`],
blockExplorerUrls: ['https://arbiscan.io'],
nativeCurrency: {
decimals: 18,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Bridger, BridgeTransferStatus } from 'game7-bridge-sdk'
// Absolute Imports
import { useBlockchainContext } from '@/contexts/BlockchainContext'
import { useBridgeNotificationsContext } from '@/contexts/BridgeNotificationsContext'
import { getTokensForNetwork } from '@/utils/tokens'
import { ZERO_ADDRESS } from '@/utils/web3utils'

interface ActionButtonProps {
Expand Down Expand Up @@ -84,9 +85,12 @@ const ActionButton: React.FC<ActionButtonProps> = ({
const network = networks?.find((n) => n.chainId === bridger?.originNetwork.chainId)!
const provider = await getProvider(network)
const signer = provider.getSigner()
const destinationRPC = direction === 'DEPOSIT' ? selectedHighNetwork.rpcs[0] : selectedLowNetwork.rpcs[0]
const destinationChain = direction === 'DEPOSIT' ? selectedHighNetwork : selectedLowNetwork
const destinationRPC = destinationChain.rpcs[0]
const destinationProvider = new ethers.providers.JsonRpcProvider(destinationRPC) as ethers.providers.Provider

const destinationTokenAddress = getTokensForNetwork(destinationChain.chainId, connectedAccount).find(
(token) => token.symbol === selectedBridgeToken.symbol
)?.address
// Amount to send variable parsed to correct decimal places depending on the token
const amountToSend = ethers.utils.parseUnits(amount, decimals)

Expand Down Expand Up @@ -115,7 +119,7 @@ const ActionButton: React.FC<ActionButtonProps> = ({
newTransaction: true,
symbol: symbol,
status:
selectedBridgeToken.address === ZERO_ADDRESS
destinationTokenAddress === ZERO_ADDRESS
? BridgeTransferStatus.DEPOSIT_GAS_PENDING
: BridgeTransferStatus.DEPOSIT_ERC20_NOT_YET_CREATED
}
Expand All @@ -129,7 +133,7 @@ const ActionButton: React.FC<ActionButtonProps> = ({
highNetworkChainId: selectedHighNetwork.chainId,
highNetworkHash: tx?.hash,
highNetworkTimestamp: Date.now() / 1000,
challengePeriod: selectedNetworkType === 'Testnet' ? (60 * 60) : (60 * 60) * 24 * 7,
challengePeriod: selectedNetworkType === 'Testnet' ? 60 * 60 : 60 * 60 * 24 * 7,
symbol: symbol,
status: BridgeTransferStatus.WITHDRAW_UNCONFIRMED
}
Expand Down

0 comments on commit ad7eed5

Please sign in to comment.