Skip to content

Commit

Permalink
chore: allow laboratory solana tests on mainnet (#2863)
Browse files Browse the repository at this point in the history
  • Loading branch information
zoruka authored Sep 18, 2024
1 parent ee2c818 commit 4598968
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 62 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState } from 'react'
import { Button, Stack, Text, Spacer, Link } from '@chakra-ui/react'
import { useAppKitAccount, useAppKitNetwork, useAppKitProvider } from '@reown/appkit/react'
import { Button, Stack, Spacer, Link } from '@chakra-ui/react'
import { useAppKitAccount, useAppKitProvider } from '@reown/appkit/react'
import {
PublicKey,
Transaction,
Expand All @@ -9,7 +9,6 @@ import {
SystemProgram
} from '@solana/web3.js'

import { solana } from '@reown/appkit/networks'
import { useChakraToast } from '../Toast'
import { type Provider, useAppKitConnection } from '@reown/appkit-adapter-solana/react'

Expand All @@ -20,7 +19,6 @@ const amountInLamports = 10_000_000
export function SolanaSendTransactionTest() {
const toast = useChakraToast()
const { address } = useAppKitAccount()
const { caipNetwork } = useAppKitNetwork()
const { walletProvider } = useAppKitProvider<Provider>('solana')
const { connection } = useAppKitConnection()
const [loading, setLoading] = useState(false)
Expand Down Expand Up @@ -131,14 +129,6 @@ export function SolanaSendTransactionTest() {
return null
}

if (caipNetwork?.chainId === solana.chainId) {
return (
<Text fontSize="md" color="yellow">
Switch to Solana Devnet or Testnet to test this feature
</Text>
)
}

return (
<Stack direction={['column', 'column', 'row']}>
<Button
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState } from 'react'
import { Button, Stack, Text, Spacer } from '@chakra-ui/react'
import { Button, Stack, Spacer } from '@chakra-ui/react'
import {
PublicKey,
Transaction,
Expand All @@ -10,9 +10,8 @@ import {
} from '@solana/web3.js'

import { type Provider, useAppKitConnection } from '@reown/appkit-adapter-solana/react'
import { useAppKitNetwork, useAppKitProvider } from '@reown/appkit/react'
import { useAppKitProvider } from '@reown/appkit/react'

import { solana } from '@reown/appkit/networks'
import { useChakraToast } from '../Toast'
import bs58 from 'bs58'

Expand All @@ -22,7 +21,6 @@ const amountInLamports = 1_000_000

export function SolanaSignAllTransactionsTest() {
const toast = useChakraToast()
const { chainId } = useAppKitNetwork()
const { walletProvider } = useAppKitProvider<Provider>('solana')
const { connection } = useAppKitConnection()
const [loading, setLoading] = useState(false)
Expand Down Expand Up @@ -74,14 +72,6 @@ export function SolanaSignAllTransactionsTest() {
}
}

if (chainId === solana.chainId) {
return (
<Text fontSize="md" color="yellow">
Switch to Solana Devnet or Testnet to test this feature
</Text>
)
}

return (
<Stack direction={['column', 'column', 'row']}>
<Button
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState } from 'react'
import { Button, Stack, Text, Spacer, Link } from '@chakra-ui/react'
import { Button, Stack, Spacer, Link } from '@chakra-ui/react'

import {
PublicKey,
Expand All @@ -9,9 +9,8 @@ import {
VersionedTransaction
} from '@solana/web3.js'

import { solana } from '@reown/appkit/networks'
import { useChakraToast } from '../Toast'
import { useAppKitAccount, useAppKitNetwork, useAppKitProvider } from '@reown/appkit/react'
import { useAppKitAccount, useAppKitProvider } from '@reown/appkit/react'
import { useAppKitConnection, type Provider } from '@reown/appkit-adapter-solana/react'

const PHANTOM_TESTNET_ADDRESS = '8vCyX7oB6Pc3pbWMGYYZF5pbSnAdQ7Gyr32JqxqCy8ZR'
Expand All @@ -21,7 +20,6 @@ const amountInLamports = 10_000_000
export function SolanaSignAndSendTransaction() {
const toast = useChakraToast()
const { address } = useAppKitAccount()
const { caipNetwork } = useAppKitNetwork()
const { walletProvider } = useAppKitProvider<Provider>('solana')
const { connection } = useAppKitConnection()

Expand Down Expand Up @@ -92,14 +90,6 @@ export function SolanaSignAndSendTransaction() {
return null
}

if (caipNetwork?.chainId === solana.chainId) {
return (
<Text fontSize="md" color="yellow">
Switch to Solana Devnet or Testnet to test this feature
</Text>
)
}

return (
<Stack direction={['column', 'column', 'row']}>
<Button
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import { useState } from 'react'
import { Button, Stack, Text, Spacer } from '@chakra-ui/react'
import { Button, Stack, Spacer } from '@chakra-ui/react'
import { PublicKey, VersionedTransaction } from '@solana/web3.js'

import { useAppKitNetwork, useAppKitProvider } from '@reown/appkit/react'
import { solana } from '@reown/appkit/networks'
import { useAppKitProvider } from '@reown/appkit/react'
import { useChakraToast } from '../Toast'
import bs58 from 'bs58'
import { useAppKitConnection, type Provider } from '@reown/appkit-adapter-solana/react'

export function SolanaSignJupiterSwapTest() {
const toast = useChakraToast()
const { connection } = useAppKitConnection()
const { caipNetwork } = useAppKitNetwork()
const { walletProvider } = useAppKitProvider<Provider>('solana')
const [loading, setLoading] = useState(false)

Expand Down Expand Up @@ -52,14 +50,6 @@ export function SolanaSignJupiterSwapTest() {
}
}

if (caipNetwork?.chainId === solana.chainId) {
return (
<Text fontSize="md" color="yellow">
Switch to Solana Devnet or Testnet to test this feature
</Text>
)
}

return (
<Stack direction={['column', 'column', 'row']}>
<Button
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState } from 'react'
import { Button, Stack, Text, Spacer } from '@chakra-ui/react'
import { Button, Stack, Spacer } from '@chakra-ui/react'
import {
PublicKey,
Transaction,
Expand All @@ -8,9 +8,8 @@ import {
SystemProgram
} from '@solana/web3.js'

import { useAppKitNetwork, useAppKitProvider } from '@reown/appkit/react'
import { useAppKitProvider } from '@reown/appkit/react'
import { useAppKitConnection, type Provider } from '@reown/appkit-adapter-solana/react'
import { solana } from '@reown/appkit/networks'
import { useChakraToast } from '../Toast'
import bs58 from 'bs58'

Expand All @@ -20,7 +19,6 @@ const amountInLamports = 10_000_000

export function SolanaSignTransactionTest() {
const toast = useChakraToast()
const { caipNetwork } = useAppKitNetwork()
const { walletProvider } = useAppKitProvider<Provider>('solana')
const { connection } = useAppKitConnection()
const [loading, setLoading] = useState(false)
Expand Down Expand Up @@ -124,14 +122,6 @@ export function SolanaSignTransactionTest() {
}
}

if (caipNetwork?.chainId === solana.chainId) {
return (
<Text fontSize="md" color="yellow">
Switch to Solana Devnet or Testnet to test this feature
</Text>
)
}

return (
<Stack direction={['column', 'column', 'row']}>
<Button
Expand Down
5 changes: 3 additions & 2 deletions apps/laboratory/src/components/Solana/SolanaTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ export function SolanaTests() {
</Heading>
<SolanaSignMessageTest />
</Box>
{caipNetwork?.chainId !== solana.chainId && (
{caipNetwork?.chainId === solana.chainId && (
<Box>
<Text fontSize="md" color="yellow">
Please ensure your wallet is connected to the {caipNetwork?.name}
Please be aware that you are connected to the mainnet. Be careful with your
transactions.
</Text>
</Box>
)}
Expand Down

0 comments on commit 4598968

Please sign in to comment.