From 3b32987ecf0705e769fcde34f456c81001ab6186 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Thu, 12 Aug 2021 16:01:49 +1000 Subject: [PATCH] Add check in case user tries with incompatible wallet --- .../src/GetEncryptionPublicKey.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/eth-pm-wallet-encryption/src/GetEncryptionPublicKey.tsx b/examples/eth-pm-wallet-encryption/src/GetEncryptionPublicKey.tsx index d7746b22e2..3242d0c61f 100644 --- a/examples/eth-pm-wallet-encryption/src/GetEncryptionPublicKey.tsx +++ b/examples/eth-pm-wallet-encryption/src/GetEncryptionPublicKey.tsx @@ -23,9 +23,14 @@ export default function GetEncryptionPublicKey({ method: 'eth_getEncryptionPublicKey', params: [address], }) - .then((key: string) => { + .then((key: string | undefined) => { console.log('Encryption Public key:', key); + if (typeof key !== 'string') { + console.error('Could not get encryption key'); + return; + } + setEncPublicKey(Buffer.from(key, 'base64')); }) .catch((error) => {