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