@trustware/sdk-staging 1.1.16-staging.2 → 1.1.16-staging.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.
package/dist/widget.mjs CHANGED
@@ -571,7 +571,7 @@ var init_constants = __esm({
571
571
  "src/constants.ts"() {
572
572
  "use strict";
573
573
  SDK_NAME = "@trustware/sdk";
574
- SDK_VERSION = "1.1.16-staging.2";
574
+ SDK_VERSION = "1.1.16-staging.3";
575
575
  API_ROOT = "https://bv-staging-api.trustware.io";
576
576
  GTM_ID = "GTM-TZDGNCXB";
577
577
  API_PREFIX = "/api";
@@ -2632,10 +2632,12 @@ function routeErrorFromResponse(status, body, fallbackMessage) {
2632
2632
  }
2633
2633
  function parseRouteError(raw) {
2634
2634
  if (isRouteError(raw) && raw.providers.length > 0) {
2635
+ const rejected = raw.providers.some((p) => p.outcome === "rejected");
2635
2636
  return {
2636
2637
  codes: providerCodes(raw.providers),
2637
2638
  providers: raw.providers,
2638
- allDeclined: raw.providers.every((p) => p.outcome !== "failed"),
2639
+ allDeclined: !rejected && raw.providers.every((p) => p.outcome !== "failed"),
2640
+ rejected,
2639
2641
  minimum: firstMinimum(raw.providers.map((p) => p.message))
2640
2642
  };
2641
2643
  }
@@ -2650,6 +2652,7 @@ function parseRouteError(raw) {
2650
2652
  codes,
2651
2653
  providers: [],
2652
2654
  allDeclined: !codes.some((code) => failureCodes.includes(code)),
2655
+ rejected: false,
2653
2656
  minimum: firstMinimum([text])
2654
2657
  };
2655
2658
  }
@@ -2699,7 +2702,7 @@ function formatMinimum(minimum) {
2699
2702
  if (minimum.symbol.toUpperCase() === "USD") return `$${minimum.amount}`;
2700
2703
  return `${minimum.amount} ${minimum.symbol}`;
2701
2704
  }
2702
- var RouteDeclineCode, RouteFailureCode, RouteErrorCode, ALL_PROVIDER_CODES, RouteError, MAX_ROUTE_ERROR_TEXT, ROUTE_SUMMARIES;
2705
+ var RouteDeclineCode, RouteFailureCode, RouteRejectionCode, RouteErrorCode, ALL_PROVIDER_CODES, RouteError, MAX_ROUTE_ERROR_TEXT, ROUTE_SUMMARIES;
2703
2706
  var init_routeError = __esm({
2704
2707
  "src/core/routeError.ts"() {
2705
2708
  "use strict";
@@ -2721,18 +2724,25 @@ var init_routeError = __esm({
2721
2724
  Timeout: "timeout",
2722
2725
  ProviderError: "provider_error"
2723
2726
  };
2727
+ RouteRejectionCode = {
2728
+ InvalidAddress: "invalid_address"
2729
+ };
2724
2730
  RouteErrorCode = {
2725
2731
  /** Every provider declined: a negative result, returned as 404. */
2726
2732
  NoRouteAvailable: "no_route_available",
2727
2733
  /** At least one provider failed, so "unroutable" cannot be claimed: 502. */
2728
2734
  ProvidersFailed: "providers_failed",
2735
+ /** The caller's address cannot be valid on its chain; no provider was
2736
+ * asked. Returned as 400. Fix the request rather than retry it. */
2737
+ InvalidAddress: "invalid_address",
2729
2738
  /** A route came back but the SDK refused it: its fees exceed its output.
2730
2739
  * Reached client-side, so `status` is 0. */
2731
2740
  FeesExceedOutput: "fees_exceed_output"
2732
2741
  };
2733
2742
  ALL_PROVIDER_CODES = [
2734
2743
  ...Object.values(RouteDeclineCode),
2735
- ...Object.values(RouteFailureCode)
2744
+ ...Object.values(RouteFailureCode),
2745
+ ...Object.values(RouteRejectionCode)
2736
2746
  ];
2737
2747
  RouteError = class extends Error {
2738
2748
  constructor(params) {
@@ -2746,6 +2756,10 @@ var init_routeError = __esm({
2746
2756
  get isNoRouteAvailable() {
2747
2757
  return this.code === RouteErrorCode.NoRouteAvailable || this.status === 404;
2748
2758
  }
2759
+ /** True when the caller's address was rejected — nothing to retry, fix the request. */
2760
+ get isInvalidAddress() {
2761
+ return this.code === RouteErrorCode.InvalidAddress;
2762
+ }
2749
2763
  /** The distinct provider codes, e.g. ["amount_too_low", "no_routes"]. */
2750
2764
  get providerCodes() {
2751
2765
  return providerCodes(this.providers);
@@ -3213,6 +3227,9 @@ function bodyMessage(body) {
3213
3227
  }
3214
3228
  function mapRouteFacts(facts) {
3215
3229
  if (facts.codes.length === 0) return null;
3230
+ if (facts.rejected) {
3231
+ return INVALID_ADDRESS;
3232
+ }
3216
3233
  if (!facts.allDeclined) {
3217
3234
  return {
3218
3235
  category: "route_error",
@@ -3345,6 +3362,9 @@ function classifyError(raw, msg) {
3345
3362
  if (lower.includes("destination contract call")) {
3346
3363
  return DESTINATION_CALL_FAILED;
3347
3364
  }
3365
+ if (lower.includes("invalid address") || lower.includes("address is not valid")) {
3366
+ return INVALID_ADDRESS;
3367
+ }
3348
3368
  if (lower.includes("did not respond") || lower.includes("routing provider")) {
3349
3369
  return {
3350
3370
  category: "route_error",
@@ -3423,12 +3443,17 @@ function classifyError(raw, msg) {
3423
3443
  message: "An unexpected error occurred. Please try again."
3424
3444
  };
3425
3445
  }
3426
- var SELF_MAPPED, DESTINATION_CALL_FAILED;
3446
+ var SELF_MAPPED, INVALID_ADDRESS, DESTINATION_CALL_FAILED;
3427
3447
  var init_mapError = __esm({
3428
3448
  "src/widget/lib/mapError.ts"() {
3429
3449
  "use strict";
3430
3450
  init_core2();
3431
3451
  SELF_MAPPED = /* @__PURE__ */ new Map();
3452
+ INVALID_ADDRESS = {
3453
+ category: "invalid_address",
3454
+ title: "Invalid Address",
3455
+ message: "The recipient address is not valid for the selected network. Check the address and try again."
3456
+ };
3432
3457
  DESTINATION_CALL_FAILED = {
3433
3458
  category: "route_error",
3434
3459
  title: "Destination Call Failed",