@compass-labs/widgets 0.1.2 → 0.1.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.js CHANGED
@@ -4037,8 +4037,9 @@ function useSwapQuote({ fromToken, toToken, amount, enabled = true }) {
4037
4037
  });
4038
4038
  const response = await fetch(`/api/compass/swap/quote?${params}`);
4039
4039
  if (!response.ok) {
4040
- const error = await response.json();
4041
- throw new Error(error.error || "Failed to get swap quote");
4040
+ const errorData = await response.json();
4041
+ const errorMessage = errorData.message || errorData.error || "Failed to get swap quote";
4042
+ throw new Error(errorMessage);
4042
4043
  }
4043
4044
  const data = await response.json();
4044
4045
  const outputAmount = data.estimatedAmountOut || "0";
@@ -4085,7 +4086,7 @@ function SwapWidget({
4085
4086
  const [swapStatus, setSwapStatus] = react.useState("");
4086
4087
  const { address, isConnected, signTypedData } = useCompassWallet();
4087
4088
  const { chainId } = useChain();
4088
- const { quote, isLoading: isQuoteLoading } = useSwapQuote({
4089
+ const { quote, isLoading: isQuoteLoading, error: quoteError } = useSwapQuote({
4089
4090
  fromToken,
4090
4091
  toToken,
4091
4092
  amount: fromAmount,
@@ -4157,9 +4158,8 @@ function SwapWidget({
4157
4158
  setIsSwapping(false);
4158
4159
  }
4159
4160
  }, [address, fromAmount, quote, chainId, fromToken, toToken, signTypedData, onSwapSuccess, onSwapError]);
4160
- const isCompact = layout === "compact";
4161
4161
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-4", children: [
4162
- !isCompact && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-2 flex-wrap", children: [
4162
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-2 flex-wrap", children: [
4163
4163
  /* @__PURE__ */ jsxRuntime.jsx(ChainSwitcher, {}),
4164
4164
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
4165
4165
  /* @__PURE__ */ jsxRuntime.jsx(EarnAccountBalance, { compact: true }),
@@ -4233,6 +4233,20 @@ function SwapWidget({
4233
4233
  toToken
4234
4234
  ] })
4235
4235
  ] }),
4236
+ quoteError && /* @__PURE__ */ jsxRuntime.jsxs(
4237
+ "div",
4238
+ {
4239
+ className: "flex items-center gap-2 p-3 rounded-lg text-sm",
4240
+ style: {
4241
+ backgroundColor: "var(--compass-color-error-muted)",
4242
+ color: "var(--compass-color-error)"
4243
+ },
4244
+ children: [
4245
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertCircle, { size: 16 }),
4246
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: quoteError.message })
4247
+ ]
4248
+ }
4249
+ ),
4236
4250
  swapStatus && /* @__PURE__ */ jsxRuntime.jsxs(
4237
4251
  "div",
4238
4252
  {