Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ime-392): disable iso cache #524

4 changes: 3 additions & 1 deletion audit-ci.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
"GHSA-qwcr-r2fm-qrc7",
"GHSA-rv95-896h-c2vc",
"GHSA-3xgq-45jj-v275", // https://github.com/advisories/GHSA-3xgq-45jj-v275
"GHSA-7q7g-4xm8-89cq" // https://github.com/advisories/GHSA-7q7g-4xm8-89cq
"GHSA-7q7g-4xm8-89cq", // https://github.com/advisories/GHSA-7q7g-4xm8-89cq
"GHSA-mwcw-c2x4-8c55",
"GHSA-rhx6-c78j-4q9w"
]
}
17 changes: 5 additions & 12 deletions modules/api-svc/src/lib/model/InboundTransfersModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ class InboundTransfersModel {
}
this.data.quoteResponse = {
headers: res.originalRequest.headers,
body: res.originalRequest.body,
body: JSON.stringify(mojaloopResponse),
Ujjwal-Izyane marked this conversation as resolved.
Show resolved Hide resolved
};
this.data.currentState = SDKStateEnum.WAITING_FOR_QUOTE_ACCEPTANCE;
await this._save();
Expand Down Expand Up @@ -466,9 +466,10 @@ class InboundTransfersModel {
// make a callback to the source fsp with the transfer fulfilment
const res = await this._mojaloopRequests.putTransfers(prepareRequest.transferId, mojaloopResponse,
sourceFspId);

this.data.fulfil = {
headers: res.originalRequest.headers,
body: res.originalRequest.body,
body: JSON.stringify(mojaloopResponse),
Ujjwal-Izyane marked this conversation as resolved.
Show resolved Hide resolved
};
this.data.currentState = response.transferState || (this._reserveNotification ? SDKStateEnum.RESERVED : SDKStateEnum.COMPLETED);
await this._save();
Expand Down Expand Up @@ -573,12 +574,8 @@ class InboundTransfersModel {

this.data.fxQuoteResponse = {
headers: res.originalRequest.headers,
body: res.originalRequest.body,
body: JSON.stringify(mojaloopResponse),
Ujjwal-Izyane marked this conversation as resolved.
Show resolved Hide resolved
};
this._logger.log('=======================================');
this._logger.log(`Data from the fxQuoteResponse headers are ${res.originalRequest.headers}`);
this._logger.log('=======================================');


this.data.currentState = SDKStateEnum.FX_QUOTE_WAITING_FOR_ACCEPTANCE;
await this.saveFxState();
Expand Down Expand Up @@ -645,12 +642,8 @@ class InboundTransfersModel {

this.data.fulfil = {
headers: res.originalRequest.headers,
body: res.originalRequest.body,
body: JSON.stringify(mojaloopResponse),
};
this._logger.log('=======================================');
this._logger.log(`Data from the pustFxTransfers headers are ${res.originalRequest.headers}`);
this._logger.log('=======================================');


this.data.currentState = beResponse.conversionState;
await this.saveFxState();
Expand Down
24 changes: 19 additions & 5 deletions modules/api-svc/src/lib/model/OutboundTransfersModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -560,8 +560,14 @@ class OutboundTransfersModel {
const subscribing = this._cache.subscribeToOneMessageWithTimer(channel);

const resp = await this._requests.postFxQuotes(payload, payload.conversionTerms.counterPartyFsp);

const { originalRequest } = resp;
this.data.fxQuoteRequest = originalRequest;
// Setting the fxQuoteRequest to have the fspiop payload
// If ISO20022 is required then use originalRequest
this.data.fxQuoteRequest = {
body: JSON.stringify(payload),
Ujjwal-Izyane marked this conversation as resolved.
Show resolved Hide resolved
headers: originalRequest.headers
};
this._logger.debug('fxQuote request is sent to hub');

const message = await subscribing;
Expand All @@ -575,7 +581,7 @@ class OutboundTransfersModel {
throw error;
}

this._logger.push({ body, originalRequest }).verbose('fxQuote callback response received');
// this._logger.push({ body, originalRequest }).verbose('fxQuote callback response received');

if (this._rejectExpiredQuoteResponses) {
const now = new Date().toISOString();
Expand Down Expand Up @@ -658,6 +664,8 @@ class OutboundTransfersModel {
if (error) {
return reject(error);
}
// originalIso20022QuoteResponse is being sent as post transfers payload to hub
// Can't remove this at the moment
this.data.quoteResponse = {
headers: message.data.headers,
body: message.data.body,
Expand Down Expand Up @@ -696,7 +704,10 @@ class OutboundTransfersModel {
latencyTimerDone = this.metrics.quoteRequestLatency.startTimer();
const res = await this._requests.postQuotes(quote, this.data.to.fspId);

this.data.quoteRequest = res.originalRequest;
this.data.quoteRequest = {
body: quote,
headers: res.originalRequest.headers
};

this.metrics.quoteRequests.inc();
this._logger.isDebugEnabled && this._logger.push({ res }).debug('Quote request sent to peer');
Expand Down Expand Up @@ -788,7 +799,7 @@ class OutboundTransfersModel {
const subscribing = this._cache.subscribeToOneMessageWithTimer(channel);

const { originalRequest } = await this._requests.postFxTransfers(payload, payload.counterPartyFsp);
this.data.fxTransferRequest = originalRequest;
this.data.fxTransferRequest = { body: payload , headers: originalRequest.headers };
this._logger.push({ originalRequest }).verbose('fxTransfers request is sent to hub');

const message = await subscribing;
Expand Down Expand Up @@ -945,7 +956,10 @@ class OutboundTransfersModel {
res = await this._requests.postTransfers(prepare, this.data.quoteResponseSource, {});
}

this.data.prepare = res.originalRequest;
this.data.prepare = {
body: prepare,
headers: res.originalRequest.headers
};

this.metrics.transferPrepares.inc();
this._logger.isDebugEnabled && this._logger.push({ res }).debug('Transfer prepare sent to peer');
Expand Down