Skip to content

Commit

Permalink
chore: refactor for handling EUR and CRC keys in SessionStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
onmax committed Oct 24, 2024
1 parent d0fbade commit f5a91a5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/request/swap-iframe/SwapIFrameApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
);

Expand Down Expand Up @@ -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,
);

Expand Down

0 comments on commit f5a91a5

Please sign in to comment.