|
1 | 1 | import './ConnectedContent.css'; |
2 | 2 |
|
| 3 | +import { type PrimaryWallet } from '@zetachain/wallet'; |
| 4 | + |
3 | 5 | import { NetworkSelector } from './components/NetworkSelector'; |
4 | 6 | import type { SupportedChain } from './constants/chains'; |
| 7 | +import { USE_DYNAMIC_WALLET } from './constants/wallets'; |
5 | 8 | import { Footer } from './Footer'; |
| 9 | +import { useDynamicSwitchChainHook } from './hooks/useDynamicSwitchChainHook'; |
6 | 10 | import { useSwitchChain } from './hooks/useSwitchChain'; |
7 | 11 | import { MessageFlowCard } from './MessageFlowCard'; |
8 | 12 | import type { EIP6963ProviderDetail } from './types/wallet'; |
9 | 13 |
|
10 | 14 | interface ConnectedContentProps { |
11 | | - selectedProvider: EIP6963ProviderDetail; |
| 15 | + selectedProvider: EIP6963ProviderDetail | null; |
12 | 16 | supportedChain: SupportedChain | undefined; |
| 17 | + primaryWallet?: PrimaryWallet | null; // Dynamic wallet from context |
13 | 18 | } |
14 | 19 |
|
15 | | -export function ConnectedContent({ |
| 20 | +const DynamicConnectedContent = ({ |
16 | 21 | selectedProvider, |
17 | 22 | supportedChain, |
18 | | -}: ConnectedContentProps) { |
| 23 | + primaryWallet, |
| 24 | +}: ConnectedContentProps) => { |
| 25 | + const { switchChain } = useDynamicSwitchChainHook(); |
| 26 | + |
| 27 | + const handleNetworkSelect = (chain: SupportedChain) => { |
| 28 | + switchChain(chain.chainId); |
| 29 | + }; |
| 30 | + |
| 31 | + return ( |
| 32 | + <div className="main-container"> |
| 33 | + <div className="content-container"> |
| 34 | + <div className="content-container-inner"> |
| 35 | + <div className="content-container-inner-header"> |
| 36 | + <h1>Say Hello from</h1> |
| 37 | + <NetworkSelector |
| 38 | + selectedChain={supportedChain} |
| 39 | + onNetworkSelect={handleNetworkSelect} |
| 40 | + /> |
| 41 | + </div> |
| 42 | + <p className="content-container-inner-description"> |
| 43 | + Make a cross-chain call with a message from{' '} |
| 44 | + {supportedChain?.name || 'a supported network'} to a universal |
| 45 | + contract on ZetaChain that emits a{' '} |
| 46 | + <span className="highlight">HelloEvent</span>. |
| 47 | + </p> |
| 48 | + </div> |
| 49 | + <MessageFlowCard |
| 50 | + selectedProvider={selectedProvider} |
| 51 | + supportedChain={supportedChain} |
| 52 | + primaryWallet={primaryWallet} |
| 53 | + /> |
| 54 | + </div> |
| 55 | + <Footer /> |
| 56 | + </div> |
| 57 | + ); |
| 58 | +}; |
| 59 | + |
| 60 | +const Eip6963ConnectedContent = ({ |
| 61 | + selectedProvider, |
| 62 | + supportedChain, |
| 63 | + primaryWallet, |
| 64 | +}: ConnectedContentProps) => { |
19 | 65 | const { switchChain } = useSwitchChain(); |
20 | 66 |
|
21 | 67 | const handleNetworkSelect = (chain: SupportedChain) => { |
@@ -43,9 +89,30 @@ export function ConnectedContent({ |
43 | 89 | <MessageFlowCard |
44 | 90 | selectedProvider={selectedProvider} |
45 | 91 | supportedChain={supportedChain} |
| 92 | + primaryWallet={primaryWallet} |
46 | 93 | /> |
47 | 94 | </div> |
48 | 95 | <Footer /> |
49 | 96 | </div> |
50 | 97 | ); |
| 98 | +}; |
| 99 | + |
| 100 | +export function ConnectedContent({ |
| 101 | + selectedProvider, |
| 102 | + supportedChain, |
| 103 | + primaryWallet, |
| 104 | +}: ConnectedContentProps) { |
| 105 | + return USE_DYNAMIC_WALLET ? ( |
| 106 | + <DynamicConnectedContent |
| 107 | + selectedProvider={selectedProvider} |
| 108 | + supportedChain={supportedChain} |
| 109 | + primaryWallet={primaryWallet} |
| 110 | + /> |
| 111 | + ) : ( |
| 112 | + <Eip6963ConnectedContent |
| 113 | + selectedProvider={selectedProvider} |
| 114 | + supportedChain={supportedChain} |
| 115 | + primaryWallet={primaryWallet} |
| 116 | + /> |
| 117 | + ); |
51 | 118 | } |
0 commit comments