From 4a95f9edbdbf41b019b49e8f8ee0f91e3d4b2b8b Mon Sep 17 00:00:00 2001 From: Ilja Date: Fri, 11 Feb 2022 15:21:34 +0200 Subject: [PATCH] WIP on sign handling --- .../src/views/SessionProposalModal.tsx | 6 ++--- .../src/views/SessionRequestModal.tsx | 22 ++++++++++++++----- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/wallets/react-wallet-v2/src/views/SessionProposalModal.tsx b/wallets/react-wallet-v2/src/views/SessionProposalModal.tsx index 76ec238..8d778d0 100644 --- a/wallets/react-wallet-v2/src/views/SessionProposalModal.tsx +++ b/wallets/react-wallet-v2/src/views/SessionProposalModal.tsx @@ -10,12 +10,12 @@ export default function SessionProposalModal() { const proposal = ModalStore.state.data?.proposal const address = WalletStore.state.wallet?.address - // Ensure proposal and client are defined - if (!proposal || !client) { + // Ensure proposal is defined + if (!proposal) { return Missing proposal data } - // Get data to display + // Get required proposal data const { proposer, permissions, relay } = proposal const { icons, name, url } = proposer.metadata const { chains } = permissions.blockchain diff --git a/wallets/react-wallet-v2/src/views/SessionRequestModal.tsx b/wallets/react-wallet-v2/src/views/SessionRequestModal.tsx index ddf411f..7b7f22e 100644 --- a/wallets/react-wallet-v2/src/views/SessionRequestModal.tsx +++ b/wallets/react-wallet-v2/src/views/SessionRequestModal.tsx @@ -1,25 +1,35 @@ import ModalStore from '@/store/ModalStore' +import WalletStore from '@/store/WalletStore' import { CHAIN, MAINNET_CHAINS } from '@/utils/EIP155ChainsUtil' +import { client } from '@/utils/WalletConnectUtil' import { Avatar, Button, Col, Container, Divider, Link, Modal, Row, Text } from '@nextui-org/react' import { Fragment } from 'react' export default function SessionRequestModal() { + // Get request and wallet data from store const request = ModalStore.state.data?.request const requestSession = ModalStore.state.data?.requestSession + const { wallet } = WalletStore.state - if (!request || !requestSession) { + // Ensure request and wallet are defined + if (!request || !requestSession || !wallet) { return Missing request data } - const { - chainId, - request: { method } - } = request + // Get required request data + const { chainId } = request + const { method } = request.request const { protocol } = requestSession.relay const { name, icons, url } = requestSession.peer.metadata - async function onApprove() {} + // Handle approve action (logic varies based on request method) + async function onApprove() { + if (client && wallet) { + // TODO figure out how to sign different personal messages correctly with ethers + } + } + // Handle reject action async function onReject() {} return (