@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.cjs CHANGED
@@ -593,7 +593,7 @@ var init_constants = __esm({
593
593
  "src/constants.ts"() {
594
594
  "use strict";
595
595
  SDK_NAME = "@trustware/sdk";
596
- SDK_VERSION = "1.1.16-staging.2";
596
+ SDK_VERSION = "1.1.16-staging.3";
597
597
  API_ROOT = "https://bv-staging-api.trustware.io";
598
598
  GTM_ID = "GTM-TZDGNCXB";
599
599
  API_PREFIX = "/api";
@@ -2654,10 +2654,12 @@ function routeErrorFromResponse(status, body, fallbackMessage) {
2654
2654
  }
2655
2655
  function parseRouteError(raw) {
2656
2656
  if (isRouteError(raw) && raw.providers.length > 0) {
2657
+ const rejected = raw.providers.some((p) => p.outcome === "rejected");
2657
2658
  return {
2658
2659
  codes: providerCodes(raw.providers),
2659
2660
  providers: raw.providers,
2660
- allDeclined: raw.providers.every((p) => p.outcome !== "failed"),
2661
+ allDeclined: !rejected && raw.providers.every((p) => p.outcome !== "failed"),
2662
+ rejected,
2661
2663
  minimum: firstMinimum(raw.providers.map((p) => p.message))
2662
2664
  };
2663
2665
  }
@@ -2672,6 +2674,7 @@ function parseRouteError(raw) {
2672
2674
  codes,
2673
2675
  providers: [],
2674
2676
  allDeclined: !codes.some((code) => failureCodes.includes(code)),
2677
+ rejected: false,
2675
2678
  minimum: firstMinimum([text])
2676
2679
  };
2677
2680
  }
@@ -2721,7 +2724,7 @@ function formatMinimum(minimum) {
2721
2724
  if (minimum.symbol.toUpperCase() === "USD") return `$${minimum.amount}`;
2722
2725
  return `${minimum.amount} ${minimum.symbol}`;
2723
2726
  }
2724
- var RouteDeclineCode, RouteFailureCode, RouteErrorCode, ALL_PROVIDER_CODES, RouteError, MAX_ROUTE_ERROR_TEXT, ROUTE_SUMMARIES;
2727
+ var RouteDeclineCode, RouteFailureCode, RouteRejectionCode, RouteErrorCode, ALL_PROVIDER_CODES, RouteError, MAX_ROUTE_ERROR_TEXT, ROUTE_SUMMARIES;
2725
2728
  var init_routeError = __esm({
2726
2729
  "src/core/routeError.ts"() {
2727
2730
  "use strict";
@@ -2743,18 +2746,25 @@ var init_routeError = __esm({
2743
2746
  Timeout: "timeout",
2744
2747
  ProviderError: "provider_error"
2745
2748
  };
2749
+ RouteRejectionCode = {
2750
+ InvalidAddress: "invalid_address"
2751
+ };
2746
2752
  RouteErrorCode = {
2747
2753
  /** Every provider declined: a negative result, returned as 404. */
2748
2754
  NoRouteAvailable: "no_route_available",
2749
2755
  /** At least one provider failed, so "unroutable" cannot be claimed: 502. */
2750
2756
  ProvidersFailed: "providers_failed",
2757
+ /** The caller's address cannot be valid on its chain; no provider was
2758
+ * asked. Returned as 400. Fix the request rather than retry it. */
2759
+ InvalidAddress: "invalid_address",
2751
2760
  /** A route came back but the SDK refused it: its fees exceed its output.
2752
2761
  * Reached client-side, so `status` is 0. */
2753
2762
  FeesExceedOutput: "fees_exceed_output"
2754
2763
  };
2755
2764
  ALL_PROVIDER_CODES = [
2756
2765
  ...Object.values(RouteDeclineCode),
2757
- ...Object.values(RouteFailureCode)
2766
+ ...Object.values(RouteFailureCode),
2767
+ ...Object.values(RouteRejectionCode)
2758
2768
  ];
2759
2769
  RouteError = class extends Error {
2760
2770
  constructor(params) {
@@ -2768,6 +2778,10 @@ var init_routeError = __esm({
2768
2778
  get isNoRouteAvailable() {
2769
2779
  return this.code === RouteErrorCode.NoRouteAvailable || this.status === 404;
2770
2780
  }
2781
+ /** True when the caller's address was rejected — nothing to retry, fix the request. */
2782
+ get isInvalidAddress() {
2783
+ return this.code === RouteErrorCode.InvalidAddress;
2784
+ }
2771
2785
  /** The distinct provider codes, e.g. ["amount_too_low", "no_routes"]. */
2772
2786
  get providerCodes() {
2773
2787
  return providerCodes(this.providers);
@@ -3235,6 +3249,9 @@ function bodyMessage(body) {
3235
3249
  }
3236
3250
  function mapRouteFacts(facts) {
3237
3251
  if (facts.codes.length === 0) return null;
3252
+ if (facts.rejected) {
3253
+ return INVALID_ADDRESS;
3254
+ }
3238
3255
  if (!facts.allDeclined) {
3239
3256
  return {
3240
3257
  category: "route_error",
@@ -3367,6 +3384,9 @@ function classifyError(raw, msg) {
3367
3384
  if (lower.includes("destination contract call")) {
3368
3385
  return DESTINATION_CALL_FAILED;
3369
3386
  }
3387
+ if (lower.includes("invalid address") || lower.includes("address is not valid")) {
3388
+ return INVALID_ADDRESS;
3389
+ }
3370
3390
  if (lower.includes("did not respond") || lower.includes("routing provider")) {
3371
3391
  return {
3372
3392
  category: "route_error",
@@ -3445,12 +3465,17 @@ function classifyError(raw, msg) {
3445
3465
  message: "An unexpected error occurred. Please try again."
3446
3466
  };
3447
3467
  }
3448
- var SELF_MAPPED, DESTINATION_CALL_FAILED;
3468
+ var SELF_MAPPED, INVALID_ADDRESS, DESTINATION_CALL_FAILED;
3449
3469
  var init_mapError = __esm({
3450
3470
  "src/widget/lib/mapError.ts"() {
3451
3471
  "use strict";
3452
3472
  init_core2();
3453
3473
  SELF_MAPPED = /* @__PURE__ */ new Map();
3474
+ INVALID_ADDRESS = {
3475
+ category: "invalid_address",
3476
+ title: "Invalid Address",
3477
+ message: "The recipient address is not valid for the selected network. Check the address and try again."
3478
+ };
3454
3479
  DESTINATION_CALL_FAILED = {
3455
3480
  category: "route_error",
3456
3481
  title: "Destination Call Failed",