diff --git a/src/languages/en_US.json b/src/languages/en_US.json index c9d1420b2b8..4faecc580f6 100644 --- a/src/languages/en_US.json +++ b/src/languages/en_US.json @@ -2258,6 +2258,8 @@ "pairing_timeout": "This session timed-out before a connection could be established. This is usually due to a network error. Please try again.", "pairing_unsupported_methods": "The dapp requested wallet RPC methods that are unsupported by Rainbow.", "pairing_unsupported_networks": "The dapp requested network(s) that are unsupported by Rainbow.", + "read_only_wallet_on_signing_method": "It looks like you're using a read-only wallet, which is not allowed for this request.", + "namespaces_invalid": "There was an issue with the namespaces requested by the dapp. Please try again or contact Rainbow and/or dapp support teams.", "request_invalid": "The request contained invalid parameters. Please try again or contact Rainbow and/or dapp support teams.", "request_unsupported_network": "The network specified in this request is not supported by Rainbow.", "request_unsupported_methods": "The RPC method(s) specified in this request are not supported by Rainbow." diff --git a/src/walletConnect/index.tsx b/src/walletConnect/index.tsx index e9b210bcb94..a1933e71afa 100644 --- a/src/walletConnect/index.tsx +++ b/src/walletConnect/index.tsx @@ -570,7 +570,7 @@ export async function onSessionProposal( showErrorSheet({ title: lang.t(T.errors.generic_title), - body: `${lang.t(T.errors.generic_error)} \n \n ${ + body: `${lang.t(T.errors.namespaces_invalid)} \n \n ${ namespaces.error.message }`, sheetHeight: 400, @@ -621,6 +621,7 @@ export async function onSessionProposal( } } +// For WC v2 export async function onSessionRequest( event: SignClientTypes.EventArguments['session_request'] ) { @@ -692,7 +693,8 @@ export async function onSessionRequest( const selectedWallet = findWalletWithAccount(allWallets, address); - if (!selectedWallet || selectedWallet?.type === WalletTypes.readOnly) { + const isReadOnly = selectedWallet?.type === WalletTypes.readOnly; + if (!selectedWallet || isReadOnly) { logger.error( new RainbowError( `WC v2: session_request exited, selectedWallet was falsy or read only` @@ -702,6 +704,10 @@ export async function onSessionRequest( } ); + const errorMessageBody = isReadOnly + ? lang.t(T.errors.read_only_wallet_on_signing_method) + : lang.t(T.errors.generic_error); + await client.respondSessionRequest({ topic, response: formatJsonRpcError(id, `Wallet is read-only`), @@ -709,7 +715,7 @@ export async function onSessionRequest( showErrorSheet({ title: lang.t(T.errors.generic_title), - body: lang.t(T.errors.request_invalid), + body: errorMessageBody, sheetHeight: 270, onClose: maybeGoBackAndClearHasPendingRedirect, });