diff --git a/src/lib/Client.ts b/src/lib/Client.ts index bc26c71d..745e333b 100644 --- a/src/lib/Client.ts +++ b/src/lib/Client.ts @@ -62,18 +62,26 @@ export class Client { 'sign', async (message: { id: string; message: string }) => { const request: { id: string; message: string } = message - const signatureString = await signer.signMessage(request.message) - const eSig = utils.splitSignature(signatureString) - const r = hexToBytes(eSig.r) - const s = hexToBytes(eSig.s) - const sigBytes = new Uint8Array(65) - sigBytes.set(r) - sigBytes.set(s, r.length) - sigBytes[64] = eSig.recoveryParam - - const signature = Buffer.from(sigBytes).toString('base64') - - XMTPModule.receiveSignature(request.id, signature) + try { + const signatureString = await signer.signMessage(request.message) + const eSig = utils.splitSignature(signatureString) + const r = hexToBytes(eSig.r) + const s = hexToBytes(eSig.s) + const sigBytes = new Uint8Array(65) + sigBytes.set(r) + sigBytes.set(s, r.length) + sigBytes[64] = eSig.recoveryParam + + const signature = Buffer.from(sigBytes).toString('base64') + + XMTPModule.receiveSignature(request.id, signature) + } catch (e) { + const errorMessage = 'ERROR in create. User rejected signature' + console.info(errorMessage, e) + this.removeSubscription(enableSubscription) + this.removeSubscription(createSubscription) + reject(errorMessage) + } } )