Skip to content

Commit

Permalink
chore: enable transaction button outside of mainnet (#2629)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomiir authored Jul 30, 2024
1 parent a95731f commit 9866b3d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Button, Stack, Link, Text, Spacer } from '@chakra-ui/react'
import { useWeb3ModalAccount, useWeb3ModalProvider } from '@web3modal/ethers/react'
import { BrowserProvider, JsonRpcSigner, ethers } from 'ethers'
import { sepolia, optimism } from '../../utils/ChainsUtil'
import { useState } from 'react'
import { mainnet } from '../../utils/ChainsUtil'
import { vitalikEthAddress } from '../../utils/DataUtil'
import { useChakraToast } from '../Toast'

Expand Down Expand Up @@ -41,9 +41,7 @@ export function EthersTransactionTest() {
}
}

const allowedChains = [sepolia.chainId, optimism.chainId]

return allowedChains.includes(Number(chainId)) && address ? (
return Number(chainId) !== mainnet.chainId && address ? (
<Stack direction={['column', 'column', 'row']}>
<Button
data-test-id="sign-transaction-button"
Expand All @@ -69,7 +67,7 @@ export function EthersTransactionTest() {
</Stack>
) : (
<Text fontSize="md" color="yellow">
Switch to Sepolia or OP to test this feature
Feature not enabled on Ethereum Mainnet
</Text>
)
}
8 changes: 3 additions & 5 deletions apps/laboratory/src/components/Wagmi/WagmiTransactionTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,22 @@ import { parseGwei, type Address } from 'viem'
import { useEstimateGas, useSendTransaction, useAccount } from 'wagmi'
import { vitalikEthAddress } from '../../utils/DataUtil'
import { useCallback, useState } from 'react'
import { optimism, optimismSepolia, sepolia } from 'wagmi/chains'
import { mainnet } from 'wagmi/chains'
import { useChakraToast } from '../Toast'

const TEST_TX = {
to: vitalikEthAddress as Address,
value: parseGwei('0.001')
}

const ALLOWED_CHAINS = [sepolia.id, optimism.id, optimismSepolia.id] as number[]

export function WagmiTransactionTest() {
const { status, chain } = useAccount()

return ALLOWED_CHAINS.includes(Number(chain?.id)) && status === 'connected' ? (
return Number(chain?.id) !== mainnet.id && status === 'connected' ? (
<AvailableTestContent />
) : (
<Text fontSize="md" color="yellow">
Switch to Sepolia or OP to test this feature
Feature not available on Ethereum Mainnet
</Text>
)
}
Expand Down

0 comments on commit 9866b3d

Please sign in to comment.