From f5a91a545dbdb27befcca924f403ea9044368768 Mon Sep 17 00:00:00 2001
From: onmax <maximogarciamtnez@gmail.com>
Date: Thu, 24 Oct 2024 11:58:17 +0200
Subject: [PATCH] chore: refactor for handling EUR and CRC keys in
 SessionStorage

---
 src/request/swap-iframe/SwapIFrameApi.js | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/request/swap-iframe/SwapIFrameApi.js b/src/request/swap-iframe/SwapIFrameApi.js
index 6d270765..276adcfc 100644
--- a/src/request/swap-iframe/SwapIFrameApi.js
+++ b/src/request/swap-iframe/SwapIFrameApi.js
@@ -68,9 +68,9 @@ class SwapIFrameApi extends BitcoinRequestParserMixin(RequestParser) { // eslint
             if (privateKeys.usdc.length !== 66) throw new Error('Invalid USDC key stored in SessionStorage');
         }
 
-        if (request.redeem.type === 'EUR') {
-            if (!privateKeys.eur) throw new Error('No EUR key stored in SessionStorage');
-            if (privateKeys.eur.length !== 64) throw new Error('Invalid EUR key stored in SessionStorage');
+        if (request.redeem.type === 'EUR' || request.redeem.type === 'CRC') {
+            if (!privateKeys.eur) throw new Error(`No ${request.redeem.type} key stored in SessionStorage`);
+            if (privateKeys.eur.length !== 64) throw new Error(`Invalid ${request.redeem.type} key stored in SessionStorage`);
         }
 
         if (request.redeem.type === 'CRC') {
@@ -441,7 +441,7 @@ class SwapIFrameApi extends BitcoinRequestParserMixin(RequestParser) { // eslint
                     throw new Errors.KeyguardError('Missing address in funding change output');
                 }
 
-                outputs.push(/** @type {{address: string, value: number}} */ (storedRequest.fund.changeOutput));
+                outputs.push(/** @type {{address: string, value: number}} */(storedRequest.fund.changeOutput));
             }
 
             // Sort outputs by value ASC, then address ASC
@@ -615,7 +615,7 @@ class SwapIFrameApi extends BitcoinRequestParserMixin(RequestParser) { // eslint
 
             const signature = await wallet._signTypedData(
                 typedData.domain,
-                /** @type {Record<string, ethers.ethers.TypedDataField[]>} */ (/** @type {unknown} */ (cleanedTypes)),
+                /** @type {Record<string, ethers.ethers.TypedDataField[]>} */(/** @type {unknown} */ (cleanedTypes)),
                 typedData.message,
             );
 
@@ -764,7 +764,7 @@ class SwapIFrameApi extends BitcoinRequestParserMixin(RequestParser) { // eslint
 
             const signature = await wallet._signTypedData(
                 typedData.domain,
-                /** @type {Record<string, ethers.ethers.TypedDataField[]>} */ (/** @type {unknown} */ (cleanedTypes)),
+                /** @type {Record<string, ethers.ethers.TypedDataField[]>} */(/** @type {unknown} */ (cleanedTypes)),
                 typedData.message,
             );