Skip to content

Commit

Permalink
fix: add error on buy token is native token on deposit and create ves…
Browse files Browse the repository at this point in the history
…ting
  • Loading branch information
yvesfracari committed Nov 19, 2024
1 parent df8f1a7 commit bb331be
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
14 changes: 13 additions & 1 deletion apps/create-vesting/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Info, Spinner, useIFrameContext } from "@bleu/cow-hooks-ui";
import { useCallback, useState } from "react";
import { useFormContext, useFormState, useWatch } from "react-hook-form";

import { COW_NATIVE_TOKEN_ADDRESS } from "@bleu/utils";
import { ALL_SUPPORTED_CHAIN_IDS } from "@cowprotocol/cow-sdk";
import { AmountInput } from "#/components/AmountInput";
import { Button } from "#/components/Button";
Expand Down Expand Up @@ -102,7 +103,7 @@ export default function Page() {
</span>
);

if (!context?.orderParams?.buyAmount || !context?.orderParams?.buyAmount)
if (!context?.orderParams?.sellAmount || !context?.orderParams?.buyAmount)
return (
<span className="block w-full mt-10 text-center">
Please specify your swap order first
Expand All @@ -115,6 +116,17 @@ export default function Page() {
);
}

if (
context?.orderParams?.buyTokenAddress.toLowerCase() ===
COW_NATIVE_TOKEN_ADDRESS
) {
return (
<span className="block w-full mt-10 text-center">
Vesting native token is not supported
</span>
);
}

const amountPreview = vestAllFromSwap
? formattedSwapAmount
: formattedAllAfterSwap;
Expand Down
12 changes: 12 additions & 0 deletions apps/deposit-pool/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
Spinner,
useIFrameContext,
} from "@bleu/cow-hooks-ui";
import { COW_NATIVE_TOKEN_ADDRESS } from "@bleu/utils";
import { ALL_SUPPORTED_CHAIN_IDS, type Address } from "@cowprotocol/cow-sdk";
import { useCallback, useState } from "react";
import { useFormContext } from "react-hook-form";
Expand Down Expand Up @@ -93,6 +94,17 @@ export default function Page() {
);
}

if (
context?.orderParams?.buyTokenAddress.toLowerCase() ===
COW_NATIVE_TOKEN_ADDRESS
) {
return (
<span className="block w-full mt-10 text-center">
Deposit native token is not supported
</span>
);
}

if (isLoadingPools || sellTokenAmountAfterSwap === undefined) {
return (
<div className="text-center mt-10 p-2">
Expand Down
3 changes: 3 additions & 0 deletions packages/utils/cowTokenList.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// data collected from https://github.com/cowprotocol/cowswap/blob/12191b4296708214263445b88b9ddf1aa20f3f78/libs/tokens/src/const/tokensList.json
// TODO: use codegen to generate the list

export const COW_NATIVE_TOKEN_ADDRESS =
"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";

const cowSwapTokenList = [
{
symbol: "SPELL",
Expand Down

0 comments on commit bb331be

Please sign in to comment.