@naculus/connect-appkit-core 0.11.0 → 0.12.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.
package/dist/index.cjs CHANGED
@@ -55,6 +55,7 @@ __export(src_exports, {
55
55
  encodeErc20Approve: () => encodeErc20Approve,
56
56
  encodeErc20Transfer: () => encodeErc20Transfer,
57
57
  encodeErc20TransferFrom: () => encodeErc20TransferFrom,
58
+ errorMessage: () => errorMessage,
58
59
  explainSpend: () => explainSpend,
59
60
  fetchUserOperationReceipt: () => fetchUserOperationReceipt,
60
61
  findX402Provider: () => findX402Provider,
@@ -306,6 +307,27 @@ function toChainSwitchError(error, fallback = "chain_unsupported") {
306
307
  }
307
308
  }
308
309
 
310
+ // src/error-message.ts
311
+ function errorMessage(cause) {
312
+ if (typeof cause === "string") return cause;
313
+ if (cause instanceof Error) {
314
+ const code = errorCode(cause);
315
+ return code === void 0 ? cause.message : `${cause.message} (code ${code})`;
316
+ }
317
+ if (cause && typeof cause === "object") {
318
+ const message = cause.message;
319
+ if (typeof message === "string") {
320
+ const code = errorCode(cause);
321
+ return code === void 0 ? message : `${message} (code ${code})`;
322
+ }
323
+ }
324
+ return "Unknown error";
325
+ }
326
+ function errorCode(cause) {
327
+ const code = cause.code;
328
+ return typeof code === "string" || typeof code === "number" ? code : void 0;
329
+ }
330
+
309
331
  // src/revert-reason.ts
310
332
  var ERROR_STRING_SELECTOR = "08c379a0";
311
333
  var PANIC_SELECTOR = "4e487b71";
@@ -1931,6 +1953,7 @@ function siwxResultToSession(result, now = /* @__PURE__ */ new Date()) {
1931
1953
  encodeErc20Approve,
1932
1954
  encodeErc20Transfer,
1933
1955
  encodeErc20TransferFrom,
1956
+ errorMessage,
1934
1957
  explainSpend,
1935
1958
  fetchUserOperationReceipt,
1936
1959
  findX402Provider,