@@ -92,8 +119,26 @@ export function OrderDetails({
>
-
Order Details
-
+
+
Order Details
+ {isUpdating ? (
+
+ ) : (
+
+ )}
+
+
{formatNumber(amountIn, 4)}{" "}
-
+
{formatNumber(amountOut, 4)}{" "}
-
+
{formatNumber(strikePrice, 4)}{" "}
- {priceUnit}
+ {priceUnit}
{formatNumber(limitPrice, 4)}{" "}
- {priceUnit}
+ {priceUnit}
{(order?.filledPct || 0) > 0 && (
@@ -318,7 +369,7 @@ export function OrderDetails({
();
const { tokenBuyOracle, tokenSellOracle, advancedSettings, isLoading } =
@@ -50,6 +50,7 @@ export function SwapCardSubmitButton() {
tokenSellOracle,
tokenBuyOracle,
advancedSettings,
+ errors,
});
return (
@@ -77,6 +78,7 @@ function getButtonState({
tokenSellOracle,
tokenBuyOracle,
advancedSettings,
+ errors,
}: {
draftOrders: DraftOrder[];
tokenBuy?: IToken;
@@ -89,6 +91,7 @@ function getButtonState({
tokenSellOracle?: Address;
tokenBuyOracle?: Address;
advancedSettings: AdvancedSwapSettings;
+ errors: FieldErrors
;
}): {
disabled: boolean;
text: string;
@@ -151,6 +154,18 @@ function getButtonState({
text: "Error quoting tokens, make sure that CoW supports them.",
};
}
+ if (Object.values(errors).length) {
+ const errorList = Object.values(errors);
+ const firstErrorMessage = errorList[0];
+ const firstErrorKey = Object.keys(errors).find(
+ // @ts-ignore
+ (key) => errors[key] === firstErrorMessage
+ );
+ return {
+ disabled: false,
+ text: `Error on ${firstErrorKey}: ${firstErrorMessage}. Click to try again`,
+ };
+ }
return {
disabled: false,
text: "Review Stop Loss order",
diff --git a/src/lib/schema.ts b/src/lib/schema.ts
index 4e7fbcd..25fe5d3 100644
--- a/src/lib/schema.ts
+++ b/src/lib/schema.ts
@@ -17,21 +17,26 @@ const basicTokenSchema = z.object({
symbol: z.string(),
});
-const ensSchema = z
- .string()
- .min(1)
- .refine((value) => value.includes(".eth"), {
- message: "Provided address is invalid",
- })
- .transform(async (value) => {
- const publicClient = publicClientsFromIds[1];
- return (await publicClient.getEnsAddress({
- name: normalize(value),
- })) as Address;
- })
- .refine((value) => isAddress(value), {
- message: "Provided address is invalid",
- });
+const generateEnsSchema = (chainId: number) => {
+ if (chainId === 1) {
+ return z
+ .string()
+ .min(1)
+ .refine((value) => value.includes(".eth"), {
+ message: "Provided address is invalid",
+ })
+ .transform(async (value) => {
+ const publicClient = publicClientsFromIds[1];
+ return (await publicClient.getEnsAddress({
+ name: normalize(value),
+ })) as Address;
+ })
+ .refine((value) => isAddress(value), {
+ message: "Provided address is invalid",
+ });
+ }
+ return basicAddressSchema;
+};
const generateOracleSchema = ({ chainId }: { chainId: ChainId }) => {
const publicClient = publicClientsFromIds[chainId];
@@ -48,7 +53,7 @@ const generateOracleSchema = ({ chainId }: { chainId: ChainId }) => {
},
{
message: "Address does not conform to Oracle interface",
- },
+ }
);
};
@@ -70,7 +75,7 @@ export const generateSwapSchema = (chainId: ChainId) =>
{
path: ["tokenBuy"],
message: "Tokens sell and buy must be different",
- },
+ }
)
.superRefine((data, ctx) => {
const amountDecimals = data.isSellOrder
@@ -109,7 +114,7 @@ export const generateAdvancedSettingsSchema = (chainId: ChainId) =>
generateOracleSchema({ chainId }),
z.literal(""),
]),
- receiver: z.union([basicAddressSchema, ensSchema]),
+ receiver: z.union([basicAddressSchema, generateEnsSchema(chainId)]),
partiallyFillable: z.coerce.boolean(),
})
.refine(
@@ -122,7 +127,7 @@ export const generateAdvancedSettingsSchema = (chainId: ChainId) =>
{
message: "If one oracle is set, both must be set",
path: ["tokenSellOracle"],
- },
+ }
)
.refine(
(data) => {
@@ -134,5 +139,5 @@ export const generateAdvancedSettingsSchema = (chainId: ChainId) =>
{
message: "If one oracle is set, both must be set",
path: ["tokenBuyOracle"],
- },
+ }
);