@bitpay-labs/bitcore-wallet-service 11.7.1 → 11.7.3

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.
Files changed (33) hide show
  1. package/README.md +1 -0
  2. package/package.json +4 -4
  3. package/src/externalservices/banxa.ts +6 -0
  4. package/src/lib/chain/xrp/index.ts +1 -1
  5. package/src/lib/expressapp.ts +2 -0
  6. package/src/lib/server.ts +32 -3
  7. package/test/integration/helpers.ts +2 -1
  8. package/test/integration/history.test.ts +152 -1
  9. package/test/integration/server.test.ts +91 -0
  10. package/test/txhistory.paging.test.ts +166 -0
  11. package/ts_build/package.json +4 -4
  12. package/ts_build/src/externalservices/banxa.d.ts.map +1 -1
  13. package/ts_build/src/externalservices/banxa.js +4 -0
  14. package/ts_build/src/externalservices/banxa.js.map +1 -1
  15. package/ts_build/src/lib/chain/xrp/index.js +1 -1
  16. package/ts_build/src/lib/chain/xrp/index.js.map +1 -1
  17. package/ts_build/src/lib/expressapp.d.ts.map +1 -1
  18. package/ts_build/src/lib/expressapp.js +2 -0
  19. package/ts_build/src/lib/expressapp.js.map +1 -1
  20. package/ts_build/src/lib/server.d.ts.map +1 -1
  21. package/ts_build/src/lib/server.js +22 -1
  22. package/ts_build/src/lib/server.js.map +1 -1
  23. package/ts_build/test/integration/helpers.d.ts.map +1 -1
  24. package/ts_build/test/integration/helpers.js +2 -1
  25. package/ts_build/test/integration/helpers.js.map +1 -1
  26. package/ts_build/test/integration/history.test.js +130 -0
  27. package/ts_build/test/integration/history.test.js.map +1 -1
  28. package/ts_build/test/integration/server.test.js +76 -0
  29. package/ts_build/test/integration/server.test.js.map +1 -1
  30. package/ts_build/test/txhistory.paging.test.d.ts +2 -0
  31. package/ts_build/test/txhistory.paging.test.d.ts.map +1 -0
  32. package/ts_build/test/txhistory.paging.test.js +162 -0
  33. package/ts_build/test/txhistory.paging.test.js.map +1 -0
@@ -2657,7 +2657,7 @@ class WalletService {
2657
2657
  if (!txp.deferNonce) {
2658
2658
  return cb(null, txp);
2659
2659
  }
2660
- if (!Constants.EVM_CHAINS[wallet.chain.toUpperCase()]) {
2660
+ if (!Constants.EVM_CHAINS[wallet.chain.toUpperCase()] && wallet.chain.toUpperCase() !== 'XRP') {
2661
2661
  return cb(null, txp);
2662
2662
  }
2663
2663
  try {
@@ -3499,6 +3499,11 @@ class WalletService {
3499
3499
  next => {
3500
3500
  if (streamData) {
3501
3501
  lastTxs = streamData;
3502
+ if (cacheStatus.tipTxId) {
3503
+ lastTxs = _.takeWhile(lastTxs, (tx) => {
3504
+ return tx.txid != cacheStatus.tipTxId;
3505
+ });
3506
+ }
3502
3507
  return next();
3503
3508
  }
3504
3509
  const startBlock = cacheStatus.updatedHeight || 0;
@@ -3523,6 +3528,19 @@ class WalletService {
3523
3528
  });
3524
3529
  },
3525
3530
  next => {
3531
+ if (opts.reverse) {
3532
+ const cachedTxs = _.isNumber(cacheStatus.tipIndex) ? cacheStatus.tipIndex + 1 : 0;
3533
+ const totalTxs = cachedTxs + lastTxs.length;
3534
+ const oldestFirstSkip = skip;
3535
+ limit = Math.max(0, Math.min(limit, totalTxs - oldestFirstSkip));
3536
+ skip = Math.max(0, totalTxs - oldestFirstSkip - limit);
3537
+ }
3538
+ if (limit === 0) {
3539
+ resultTxs = [];
3540
+ fromCache = false;
3541
+ fromBc = false;
3542
+ return next();
3543
+ }
3526
3544
  if (lastTxs.length >= skip + limit) {
3527
3545
  resultTxs = lastTxs.slice(skip, skip + limit);
3528
3546
  fromCache = false;
@@ -3580,6 +3598,9 @@ class WalletService {
3580
3598
  ], err => {
3581
3599
  if (err)
3582
3600
  return cb(err);
3601
+ if (opts.reverse) {
3602
+ resultTxs.reverse();
3603
+ }
3583
3604
  return cb(null, {
3584
3605
  items: resultTxs,
3585
3606
  fromCache,