Skip to content

Commit

Permalink
chore: merge eur and crc requests
Browse files Browse the repository at this point in the history
  • Loading branch information
onmax committed Oct 24, 2024
1 parent c337d49 commit 2fab399
Showing 1 changed file with 6 additions and 27 deletions.
33 changes: 6 additions & 27 deletions src/request/swap-iframe/SwapIFrameApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,10 @@ class SwapIFrameApi extends BitcoinRequestParserMixin(RequestParser) { // eslint
};
}

if (request.fund.type === 'EUR' && storedRequest.fund.type === 'EUR') {
if ((request.fund.type === 'EUR' && storedRequest.fund.type === 'EUR')
|| (request.fund.type === 'CRC' && storedRequest.fund.type === 'CRC')) {
fund = {
type: 'EUR',
type: request.fund.type,
htlcDetails: {
hash: Nimiq.BufferUtils.toHex(Nimiq.BufferUtils.fromAny(request.fund.hash)),
timeoutTimestamp: this.parsePositiveInteger(request.fund.timeout, false, 'fund.timeout'),
Expand All @@ -289,31 +290,10 @@ class SwapIFrameApi extends BitcoinRequestParserMixin(RequestParser) { // eslint
};
}

if (request.redeem.type === 'EUR' && storedRequest.redeem.type === 'EUR') {
if ((request.redeem.type === 'EUR' && storedRequest.redeem.type === 'EUR')
|| (request.redeem.type === 'CRC' && storedRequest.redeem.type === 'CRC')) {
redeem = {
type: 'EUR',
htlcDetails: {
hash: Nimiq.BufferUtils.toHex(Nimiq.BufferUtils.fromAny(request.redeem.hash)),
timeoutTimestamp: this.parsePositiveInteger(request.redeem.timeout, false, 'redeem.timeout'),
},
htlcId: /** @type {string} */ (this.parseLabel(request.redeem.htlcId, false, 'redeem.htlcId')),
};
}

if (request.fund.type === 'CRC' && storedRequest.fund.type === 'CRC') {
fund = {
type: 'CRC',
htlcDetails: {
hash: Nimiq.BufferUtils.toHex(Nimiq.BufferUtils.fromAny(request.fund.hash)),
timeoutTimestamp: this.parsePositiveInteger(request.fund.timeout, false, 'fund.timeout'),
},
htlcId: /** @type {string} */ (this.parseLabel(request.fund.htlcId, false, 'fund.htlcId')),
};
}

if (request.redeem.type === 'CRC' && storedRequest.redeem.type === 'CRC') {
redeem = {
type: 'CRC',
type: request.redeem.type,
htlcDetails: {
hash: Nimiq.BufferUtils.toHex(Nimiq.BufferUtils.fromAny(request.redeem.hash)),
timeoutTimestamp: this.parsePositiveInteger(request.redeem.timeout, false, 'redeem.timeout'),
Expand Down Expand Up @@ -812,4 +792,3 @@ class SwapIFrameApi extends BitcoinRequestParserMixin(RequestParser) { // eslint
return result;
}
}

0 comments on commit 2fab399

Please sign in to comment.