@xchainjs/xchain-thorchain-query 0.7.13 → 0.7.14

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
@@ -2218,6 +2218,11 @@ class ThorchainQuery {
2218
2218
  return {
2219
2219
  count: actionsResume.count ? Number(actionsResume.count) : 0,
2220
2220
  swaps: actionsResume.actions.map((action) => {
2221
+ let transaction = action.out.filter((out) => out.txID !== '')[0]; // For non to protocol asset swap
2222
+ if (!transaction) {
2223
+ // For to protocol asset swap
2224
+ transaction = action.out.sort((out1, out2) => Number(out2.coins[0].amount) - Number(out1.coins[0].amount))[0];
2225
+ }
2221
2226
  return {
2222
2227
  date: new Date(Number(action.date) / Math.pow(10, 6)),
2223
2228
  status: action.status,
@@ -2226,11 +2231,13 @@ class ThorchainQuery {
2226
2231
  address: action.in[0].address,
2227
2232
  amount: getInboundCryptoAmount(pools, action.in[0].coins[0].asset, action.in[0].coins[0].amount),
2228
2233
  },
2229
- outboundTx: {
2230
- hash: action.out[0].txID,
2231
- address: action.out[0].address,
2232
- amount: getInboundCryptoAmount(pools, action.out[0].coins[0].asset, action.out[0].coins[0].amount),
2233
- },
2234
+ outboundTx: transaction
2235
+ ? {
2236
+ hash: transaction.txID,
2237
+ address: transaction.address,
2238
+ amount: getInboundCryptoAmount(pools, transaction.coins[0].asset, transaction.coins[0].amount),
2239
+ }
2240
+ : undefined,
2234
2241
  };
2235
2242
  }),
2236
2243
  };