@xchainjs/xchain-thorchain-query 0.7.4 → 0.7.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.esm.js CHANGED
@@ -1093,10 +1093,17 @@ class ThorchainQuery {
1093
1093
  const inputAmount = getBaseAmountWithDiffDecimals(amount, 8);
1094
1094
  // Fetch quote
1095
1095
  const swapQuote = yield this.thorchainCache.thornode.getSwapQuote(fromAssetString, toAssetString, inputAmount.toNumber(), destinationAddress, streamingInterval, streamingQuantity, toleranceBps, affiliateBps, affiliateAddress, height);
1096
- // Error handling for fetch response
1097
- const response = JSON.parse(JSON.stringify(swapQuote));
1098
- if (response.error)
1099
- errors.push(`Thornode request quote: ${response.error}`);
1096
+ let response;
1097
+ // Check if swapQuote is a string, which we assume indicates an error message
1098
+ if (typeof swapQuote === 'string') {
1099
+ response = { error: swapQuote };
1100
+ }
1101
+ else {
1102
+ response = swapQuote;
1103
+ }
1104
+ const responseError = JSON.parse(JSON.stringify(response));
1105
+ if (responseError.error)
1106
+ errors.push(`Thornode request quote: ${responseError.error}`);
1100
1107
  if (errors.length > 0) {
1101
1108
  // If there are errors, construct and return a transaction details object with error information
1102
1109
  return {