@medialane/sdk 0.127.0 → 0.129.0

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.
@@ -248,12 +248,11 @@ function deriveErrorCode(status) {
248
248
  return "UNKNOWN";
249
249
  }
250
250
  var MedialaneApiError = class extends Error {
251
- constructor(status, message, retryAfterMs, details, isAuthored = false) {
251
+ constructor(status, message, retryAfterMs, details) {
252
252
  super(message);
253
253
  this.status = status;
254
254
  this.retryAfterMs = retryAfterMs;
255
255
  this.details = details;
256
- this.isAuthored = isAuthored;
257
256
  this.name = "MedialaneApiError";
258
257
  this.code = deriveErrorCode(status);
259
258
  }
@@ -290,14 +289,12 @@ var ApiClient = class {
290
289
  });
291
290
  if (!response.ok && !allowed(response.status)) {
292
291
  const text = await response.text().catch(() => response.statusText);
293
- let message = text;
294
- let details;
295
- let isAuthored = false;
292
+ let message = `Request failed with status ${response.status}`;
293
+ let details = text;
296
294
  try {
297
295
  const body = JSON.parse(text);
298
296
  if (typeof body.error === "string" && body.error.trim() !== "") {
299
297
  message = body.error;
300
- isAuthored = true;
301
298
  }
302
299
  details = body;
303
300
  } catch {
@@ -306,8 +303,7 @@ var ApiClient = class {
306
303
  response.status,
307
304
  message,
308
305
  parseRetryAfter(response.headers.get("retry-after")),
309
- details,
310
- isAuthored
306
+ details
311
307
  );
312
308
  }
313
309
  return response;
@@ -11622,6 +11618,14 @@ async function requestSiwsToken({
11622
11618
  return token;
11623
11619
  }
11624
11620
 
11621
+ // src/errors.ts
11622
+ var UserFacingError = class extends Error {
11623
+ constructor(message) {
11624
+ super(message);
11625
+ this.name = "UserFacingError";
11626
+ }
11627
+ };
11628
+
11625
11629
  // src/starknet/services/executeIntent.ts
11626
11630
  async function confirmIntentBestEffort(client, intentId, txHash) {
11627
11631
  await client.api.confirmIntent(intentId, txHash).catch(() => {
@@ -11651,14 +11655,14 @@ async function assertTransactionSucceeded(provider, txHash, retryDelaysMs = RECE
11651
11655
  const receipt = await provider.getTransactionReceipt(txHash);
11652
11656
  const status = receipt.execution_status ?? receipt.status;
11653
11657
  if (status === "REVERTED" || status === "REJECTED") {
11654
- throw new Error("Transaction was submitted but reverted onchain. Please check your balance and try again.");
11658
+ throw new UserFacingError("Transaction was submitted but reverted onchain. Please check your balance and try again.");
11655
11659
  }
11656
11660
  if (status) return receipt;
11657
11661
  } catch (err) {
11658
11662
  if (err instanceof Error && err.message.includes("reverted onchain")) throw err;
11659
11663
  }
11660
11664
  }
11661
- throw new Error("Verification timed out. Check your account for the transaction status.");
11665
+ throw new UserFacingError("Verification timed out. Check your account for the transaction status.");
11662
11666
  }
11663
11667
  async function executeIntent(provider, signer, client, intent, opts = {}) {
11664
11668
  let calls;
@@ -12929,6 +12933,7 @@ exports.SponsoredCallRejectedError = SponsoredCallRejectedError;
12929
12933
  exports.SponsorshipService = SponsorshipService;
12930
12934
  exports.StarknetVenue = StarknetVenue;
12931
12935
  exports.TicketService = TicketService;
12936
+ exports.UserFacingError = UserFacingError;
12932
12937
  exports.VALIDATED_EKUBO_PARAMS = VALIDATED_EKUBO_PARAMS;
12933
12938
  exports.accountFor = accountFor;
12934
12939
  exports.adminRequestDigest = adminRequestDigest;