diff --git a/wallets/react-wallet-v2/src/components/Modal.tsx b/wallets/react-wallet-v2/src/components/Modal.tsx index cf7ee66..ff2fdc9 100644 --- a/wallets/react-wallet-v2/src/components/Modal.tsx +++ b/wallets/react-wallet-v2/src/components/Modal.tsx @@ -3,6 +3,7 @@ import SessionProposalModal from '@/views/SessionProposalModal' import SessionSendTransactionModal from '@/views/SessionSendTransactionModal' import SessionRequestModal from '@/views/SessionSignModal' import SessionSignTypedDataModal from '@/views/SessionSignTypedDataModal' +import SessionUnsuportedMethodModal from '@/views/SessionUnsuportedMethodModal' import { Modal as NextModal } from '@nextui-org/react' import { useSnapshot } from 'valtio' @@ -15,6 +16,7 @@ export default function Modal() { {view === 'SessionSignModal' && } {view === 'SessionSignTypedDataModal' && } {view === 'SessionSendTransactionModal' && } + {view === 'SessionUnsuportedMethodModal' && } ) } diff --git a/wallets/react-wallet-v2/src/hooks/useWalletConnectEventsManager.ts b/wallets/react-wallet-v2/src/hooks/useWalletConnectEventsManager.ts index 032bb1f..afb0d35 100644 --- a/wallets/react-wallet-v2/src/hooks/useWalletConnectEventsManager.ts +++ b/wallets/react-wallet-v2/src/hooks/useWalletConnectEventsManager.ts @@ -26,20 +26,21 @@ export default function useWalletConnectEventsManager(initialized: boolean) { const { method } = request const requestSession = await walletConnectClient.session.get(topic) - console.log(method) + switch (method) { + case EIP155_SIGNING_METHODS.ETH_SIGN: + case EIP155_SIGNING_METHODS.PERSONAL_SIGN: + return ModalStore.open('SessionSignModal', { requestEvent, requestSession }) - if ([EIP155_SIGNING_METHODS.ETH_SIGN, EIP155_SIGNING_METHODS.PERSONAL_SIGN].includes(method)) { - ModalStore.open('SessionSignModal', { requestEvent, requestSession }) - } else if ( - [ - EIP155_SIGNING_METHODS.ETH_SIGN_TYPED_DATA, - EIP155_SIGNING_METHODS.ETH_SIGN_TYPED_DATA_V3, - EIP155_SIGNING_METHODS.ETH_SIGN_TYPED_DATA_V4 - ].includes(method) - ) { - ModalStore.open('SessionSignTypedDataModal', { requestEvent, requestSession }) - } else if (EIP155_SIGNING_METHODS.ETH_SEND_TRANSACTION) { - ModalStore.open('SessionSendTransactionModal', { requestEvent, requestSession }) + case EIP155_SIGNING_METHODS.ETH_SIGN_TYPED_DATA: + case EIP155_SIGNING_METHODS.ETH_SIGN_TYPED_DATA_V3: + case EIP155_SIGNING_METHODS.ETH_SIGN_TYPED_DATA_V4: + return ModalStore.open('SessionSignTypedDataModal', { requestEvent, requestSession }) + + case EIP155_SIGNING_METHODS.ETH_SEND_TRANSACTION: + return ModalStore.open('SessionSendTransactionModal', { requestEvent, requestSession }) + + default: + return ModalStore.open('SessionUnsuportedMethodModal', { requestEvent, requestSession }) } }, []) diff --git a/wallets/react-wallet-v2/src/store/ModalStore.ts b/wallets/react-wallet-v2/src/store/ModalStore.ts index 171553c..656d1ba 100644 --- a/wallets/react-wallet-v2/src/store/ModalStore.ts +++ b/wallets/react-wallet-v2/src/store/ModalStore.ts @@ -18,6 +18,7 @@ interface State { | 'SessionSignModal' | 'SessionSignTypedDataModal' | 'SessionSendTransactionModal' + | 'SessionUnsuportedMethodModal' data?: ModalData } diff --git a/wallets/react-wallet-v2/src/views/SessionUnsuportedMethodModal.tsx b/wallets/react-wallet-v2/src/views/SessionUnsuportedMethodModal.tsx new file mode 100644 index 0000000..8b939a2 --- /dev/null +++ b/wallets/react-wallet-v2/src/views/SessionUnsuportedMethodModal.tsx @@ -0,0 +1,68 @@ +import { EIP155_CHAINS, TEIP155Chain } from '@/data/EIP155Data' +import ModalStore from '@/store/ModalStore' +import { Avatar, Button, Col, Container, Divider, Link, Modal, Row, Text } from '@nextui-org/react' +import { Fragment } from 'react' + +export default function SessionUnsuportedMethodModal() { + // Get request and wallet data from store + const requestEvent = ModalStore.state.data?.requestEvent + const requestSession = ModalStore.state.data?.requestSession + + // Ensure request and wallet are defined + if (!requestEvent || !requestSession) { + return Missing request data + } + + // Get required request data + const { chainId } = requestEvent + const { method } = requestEvent.request + const { name, icons, url } = requestSession.peer.metadata + + return ( + + + Unsuported Method + + + + + + + + + + {name} + {url} + + + + + + + + Blockchain + + {EIP155_CHAINS[chainId as TEIP155Chain]?.name ?? chainId} + + + + + + + + + Method + {method} + + + + + + + + + + ) +}