@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/index.cjs CHANGED
@@ -572,7 +572,7 @@ var init_constants = __esm({
572
572
  "src/constants.ts"() {
573
573
  "use strict";
574
574
  SDK_NAME = "@trustware/sdk";
575
- SDK_VERSION = "1.1.16-staging.2";
575
+ SDK_VERSION = "1.1.16-staging.3";
576
576
  API_ROOT = "https://bv-staging-api.trustware.io";
577
577
  GTM_ID = "GTM-TZDGNCXB";
578
578
  API_PREFIX = "/api";
@@ -4518,10 +4518,12 @@ function routeErrorFromResponse(status, body, fallbackMessage) {
4518
4518
  }
4519
4519
  function parseRouteError(raw) {
4520
4520
  if (isRouteError(raw) && raw.providers.length > 0) {
4521
+ const rejected = raw.providers.some((p) => p.outcome === "rejected");
4521
4522
  return {
4522
4523
  codes: providerCodes(raw.providers),
4523
4524
  providers: raw.providers,
4524
- allDeclined: raw.providers.every((p) => p.outcome !== "failed"),
4525
+ allDeclined: !rejected && raw.providers.every((p) => p.outcome !== "failed"),
4526
+ rejected,
4525
4527
  minimum: firstMinimum(raw.providers.map((p) => p.message))
4526
4528
  };
4527
4529
  }
@@ -4536,6 +4538,7 @@ function parseRouteError(raw) {
4536
4538
  codes,
4537
4539
  providers: [],
4538
4540
  allDeclined: !codes.some((code) => failureCodes.includes(code)),
4541
+ rejected: false,
4539
4542
  minimum: firstMinimum([text])
4540
4543
  };
4541
4544
  }
@@ -4585,7 +4588,7 @@ function formatMinimum(minimum) {
4585
4588
  if (minimum.symbol.toUpperCase() === "USD") return `$${minimum.amount}`;
4586
4589
  return `${minimum.amount} ${minimum.symbol}`;
4587
4590
  }
4588
- var RouteDeclineCode, RouteFailureCode, RouteErrorCode, ALL_PROVIDER_CODES, RouteError, MAX_ROUTE_ERROR_TEXT, ROUTE_SUMMARIES;
4591
+ var RouteDeclineCode, RouteFailureCode, RouteRejectionCode, RouteErrorCode, ALL_PROVIDER_CODES, RouteError, MAX_ROUTE_ERROR_TEXT, ROUTE_SUMMARIES;
4589
4592
  var init_routeError = __esm({
4590
4593
  "src/core/routeError.ts"() {
4591
4594
  "use strict";
@@ -4607,18 +4610,25 @@ var init_routeError = __esm({
4607
4610
  Timeout: "timeout",
4608
4611
  ProviderError: "provider_error"
4609
4612
  };
4613
+ RouteRejectionCode = {
4614
+ InvalidAddress: "invalid_address"
4615
+ };
4610
4616
  RouteErrorCode = {
4611
4617
  /** Every provider declined: a negative result, returned as 404. */
4612
4618
  NoRouteAvailable: "no_route_available",
4613
4619
  /** At least one provider failed, so "unroutable" cannot be claimed: 502. */
4614
4620
  ProvidersFailed: "providers_failed",
4621
+ /** The caller's address cannot be valid on its chain; no provider was
4622
+ * asked. Returned as 400. Fix the request rather than retry it. */
4623
+ InvalidAddress: "invalid_address",
4615
4624
  /** A route came back but the SDK refused it: its fees exceed its output.
4616
4625
  * Reached client-side, so `status` is 0. */
4617
4626
  FeesExceedOutput: "fees_exceed_output"
4618
4627
  };
4619
4628
  ALL_PROVIDER_CODES = [
4620
4629
  ...Object.values(RouteDeclineCode),
4621
- ...Object.values(RouteFailureCode)
4630
+ ...Object.values(RouteFailureCode),
4631
+ ...Object.values(RouteRejectionCode)
4622
4632
  ];
4623
4633
  RouteError = class extends Error {
4624
4634
  constructor(params) {
@@ -4632,6 +4642,10 @@ var init_routeError = __esm({
4632
4642
  get isNoRouteAvailable() {
4633
4643
  return this.code === RouteErrorCode.NoRouteAvailable || this.status === 404;
4634
4644
  }
4645
+ /** True when the caller's address was rejected — nothing to retry, fix the request. */
4646
+ get isInvalidAddress() {
4647
+ return this.code === RouteErrorCode.InvalidAddress;
4648
+ }
4635
4649
  /** The distinct provider codes, e.g. ["amount_too_low", "no_routes"]. */
4636
4650
  get providerCodes() {
4637
4651
  return providerCodes(this.providers);
@@ -8984,6 +8998,9 @@ function bodyMessage(body) {
8984
8998
  }
8985
8999
  function mapRouteFacts(facts) {
8986
9000
  if (facts.codes.length === 0) return null;
9001
+ if (facts.rejected) {
9002
+ return INVALID_ADDRESS;
9003
+ }
8987
9004
  if (!facts.allDeclined) {
8988
9005
  return {
8989
9006
  category: "route_error",
@@ -9116,6 +9133,9 @@ function classifyError(raw, msg) {
9116
9133
  if (lower.includes("destination contract call")) {
9117
9134
  return DESTINATION_CALL_FAILED;
9118
9135
  }
9136
+ if (lower.includes("invalid address") || lower.includes("address is not valid")) {
9137
+ return INVALID_ADDRESS;
9138
+ }
9119
9139
  if (lower.includes("did not respond") || lower.includes("routing provider")) {
9120
9140
  return {
9121
9141
  category: "route_error",
@@ -9194,12 +9214,17 @@ function classifyError(raw, msg) {
9194
9214
  message: "An unexpected error occurred. Please try again."
9195
9215
  };
9196
9216
  }
9197
- var SELF_MAPPED, DESTINATION_CALL_FAILED;
9217
+ var SELF_MAPPED, INVALID_ADDRESS, DESTINATION_CALL_FAILED;
9198
9218
  var init_mapError = __esm({
9199
9219
  "src/widget/lib/mapError.ts"() {
9200
9220
  "use strict";
9201
9221
  init_core2();
9202
9222
  SELF_MAPPED = /* @__PURE__ */ new Map();
9223
+ INVALID_ADDRESS = {
9224
+ category: "invalid_address",
9225
+ title: "Invalid Address",
9226
+ message: "The recipient address is not valid for the selected network. Check the address and try again."
9227
+ };
9203
9228
  DESTINATION_CALL_FAILED = {
9204
9229
  category: "route_error",
9205
9230
  title: "Destination Call Failed",
@@ -40720,6 +40745,7 @@ __export(index_exports, {
40720
40745
  RouteError: () => RouteError,
40721
40746
  RouteErrorCode: () => RouteErrorCode,
40722
40747
  RouteFailureCode: () => RouteFailureCode,
40748
+ RouteRejectionCode: () => RouteRejectionCode,
40723
40749
  SDK_NAME: () => SDK_NAME,
40724
40750
  SDK_VERSION: () => SDK_VERSION,
40725
40751
  Trustware: () => Trustware,
@@ -40797,6 +40823,7 @@ init_index();
40797
40823
  RouteError,
40798
40824
  RouteErrorCode,
40799
40825
  RouteFailureCode,
40826
+ RouteRejectionCode,
40800
40827
  SDK_NAME,
40801
40828
  SDK_VERSION,
40802
40829
  Trustware,