@paraspell/sdk 10.10.0 → 10.10.2

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/dist/index.cjs CHANGED
@@ -329,22 +329,28 @@ var processAssetsDepositedEvents = function processAssetsDepositedEvents(events,
329
329
  if (assetsDepositedEvents.length === 1) {
330
330
  return BigInt(assetsDepositedEvents[0].value.value.amount);
331
331
  }
332
- var sortedEvents = _toConsumableArray(assetsDepositedEvents).sort(function (a, b) {
333
- return Number(BigInt(b.value.value.amount) - BigInt(a.value.value.amount));
334
- });
335
- // Remove the biggest value (first in sorted array)
336
- var filteredEvents = sortedEvents.slice(1);
337
- var sum = filteredEvents.reduce(function (total, event) {
338
- return total + BigInt(event.value.value.amount);
339
- }, BigInt(0));
340
- // If sum is still bigger than amount, remove one more event (the next biggest)
341
- while (sum > amount && filteredEvents.length > 0) {
342
- filteredEvents = filteredEvents.slice(1);
343
- sum = filteredEvents.reduce(function (total, event) {
332
+ // Start with all events
333
+ var currentEvents = _toConsumableArray(assetsDepositedEvents);
334
+ var threshold = amount * BigInt(90) / BigInt(100); // 90% of amount
335
+ while (currentEvents.length > 0) {
336
+ // 1. Make a sum of all amounts in events
337
+ var sum = currentEvents.reduce(function (total, event) {
344
338
  return total + BigInt(event.value.value.amount);
345
339
  }, BigInt(0));
340
+ // 2. If that sum is bigger than 90% of amount, remove the biggest event
341
+ if (sum > threshold) {
342
+ // Sort events by amount (descending) and remove the biggest
343
+ currentEvents.sort(function (a, b) {
344
+ return Number(BigInt(b.value.value.amount) - BigInt(a.value.value.amount));
345
+ });
346
+ currentEvents = currentEvents.slice(1); // Remove the biggest event
347
+ } else {
348
+ // If not, return the summed value
349
+ return sum;
350
+ }
346
351
  }
347
- return sum > 0 ? sum : undefined;
352
+ // If we've removed all events, return undefined
353
+ return undefined;
348
354
  };
349
355
 
350
356
  var checkAndConvertToNumberOrBigInt = function checkAndConvertToNumberOrBigInt(input) {
@@ -1524,7 +1530,7 @@ var PapiApi = /*#__PURE__*/function () {
1524
1530
  } : undefined;
1525
1531
  forwardedXcms = result.value.forwarded_xcms.length > 0 ? result.value.forwarded_xcms[0] : [];
1526
1532
  destParaId = forwardedXcms.length === 0 ? undefined : forwardedXcms[0].value.interior.type === 'Here' ? 0 : forwardedXcms[0].value.interior.value.value;
1527
- if (!(sdkCore.hasXcmPaymentApiSupport(node) && asset && node !== 'AssetHubPolkadot')) {
1533
+ if (!(sdkCore.hasXcmPaymentApiSupport(node) && asset && node !== 'AssetHubPolkadot' && node !== 'Polkadot')) {
1528
1534
  _context21.n = 5;
1529
1535
  break;
1530
1536
  }
package/dist/index.mjs CHANGED
@@ -328,22 +328,28 @@ var processAssetsDepositedEvents = function processAssetsDepositedEvents(events,
328
328
  if (assetsDepositedEvents.length === 1) {
329
329
  return BigInt(assetsDepositedEvents[0].value.value.amount);
330
330
  }
331
- var sortedEvents = _toConsumableArray(assetsDepositedEvents).sort(function (a, b) {
332
- return Number(BigInt(b.value.value.amount) - BigInt(a.value.value.amount));
333
- });
334
- // Remove the biggest value (first in sorted array)
335
- var filteredEvents = sortedEvents.slice(1);
336
- var sum = filteredEvents.reduce(function (total, event) {
337
- return total + BigInt(event.value.value.amount);
338
- }, BigInt(0));
339
- // If sum is still bigger than amount, remove one more event (the next biggest)
340
- while (sum > amount && filteredEvents.length > 0) {
341
- filteredEvents = filteredEvents.slice(1);
342
- sum = filteredEvents.reduce(function (total, event) {
331
+ // Start with all events
332
+ var currentEvents = _toConsumableArray(assetsDepositedEvents);
333
+ var threshold = amount * BigInt(90) / BigInt(100); // 90% of amount
334
+ while (currentEvents.length > 0) {
335
+ // 1. Make a sum of all amounts in events
336
+ var sum = currentEvents.reduce(function (total, event) {
343
337
  return total + BigInt(event.value.value.amount);
344
338
  }, BigInt(0));
339
+ // 2. If that sum is bigger than 90% of amount, remove the biggest event
340
+ if (sum > threshold) {
341
+ // Sort events by amount (descending) and remove the biggest
342
+ currentEvents.sort(function (a, b) {
343
+ return Number(BigInt(b.value.value.amount) - BigInt(a.value.value.amount));
344
+ });
345
+ currentEvents = currentEvents.slice(1); // Remove the biggest event
346
+ } else {
347
+ // If not, return the summed value
348
+ return sum;
349
+ }
345
350
  }
346
- return sum > 0 ? sum : undefined;
351
+ // If we've removed all events, return undefined
352
+ return undefined;
347
353
  };
348
354
 
349
355
  var checkAndConvertToNumberOrBigInt = function checkAndConvertToNumberOrBigInt(input) {
@@ -1523,7 +1529,7 @@ var PapiApi = /*#__PURE__*/function () {
1523
1529
  } : undefined;
1524
1530
  forwardedXcms = result.value.forwarded_xcms.length > 0 ? result.value.forwarded_xcms[0] : [];
1525
1531
  destParaId = forwardedXcms.length === 0 ? undefined : forwardedXcms[0].value.interior.type === 'Here' ? 0 : forwardedXcms[0].value.interior.value.value;
1526
- if (!(hasXcmPaymentApiSupport(node) && asset && node !== 'AssetHubPolkadot')) {
1532
+ if (!(hasXcmPaymentApiSupport(node) && asset && node !== 'AssetHubPolkadot' && node !== 'Polkadot')) {
1527
1533
  _context21.n = 5;
1528
1534
  break;
1529
1535
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk",
3
- "version": "10.10.0",
3
+ "version": "10.10.2",
4
4
  "description": "SDK for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -25,7 +25,7 @@
25
25
  "dependencies": {
26
26
  "@noble/hashes": "^1.8.0",
27
27
  "viem": "^2.31.6",
28
- "@paraspell/sdk-core": "10.10.0"
28
+ "@paraspell/sdk-core": "10.10.2"
29
29
  },
30
30
  "peerDependencies": {
31
31
  "polkadot-api": ">= 1.14.1 < 2"