Skip to content

Commit

Permalink
Merge pull request #694 from alleslabs/fix/cosmwasm-pool
Browse files Browse the repository at this point in the history
fix: reroute cosmwasm pool back to pool detail page
  • Loading branch information
songwongtp committed Dec 21, 2023
2 parents 5a7def6 + 8781e0c commit 746734c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 21 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Bug fixes

- [#694](https://github.com/alleslabs/celatone-frontend/pull/694) Reroute cosmwasm pool back to pool detail page
- [#691](https://github.com/alleslabs/celatone-frontend/pull/691) Fix unsupported token card
- [#693](https://github.com/alleslabs/celatone-frontend/pull/693) Fix ui styling for contract card and states
- [#687](https://github.com/alleslabs/celatone-frontend/pull/687) Fix resource and module related bugs
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/LabelText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface LabelTextProps extends FlexProps {
labelColor?: string;
isSmall?: boolean;
tooltipText?: string;
children: string | JSX.Element;
children?: string | JSX.Element;
helperText1?: string;
helperText2?: string;
}
Expand Down
23 changes: 5 additions & 18 deletions src/lib/pages/pools/components/supportedSection/PoolCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { CustomIcon } from "lib/components/icon";
import { LabelText } from "lib/components/LabelText";
import { Tooltip } from "lib/components/Tooltip";
import type { USD, Pool, Token, U } from "lib/types";
import { PoolType } from "lib/types";
import { formatPrice } from "lib/utils";

import { AllocationBadge } from "./AllocationBadge";
Expand All @@ -23,23 +22,11 @@ interface PoolCardProps {
}

export const PoolCard = ({ item, mode = "percent-value" }: PoolCardProps) => {
const navigate = useInternalNavigate();
const poolConfig = usePoolConfig({ shouldRedirect: true });
// Remark: the empty string has never been used when poolConfig is disabled
const poolUrl = poolConfig.enabled ? poolConfig.url : "";

const navigate = useInternalNavigate();
const handleOnClick = () => {
// First version, navigate to contract details page if pool type is CosmWasm
if (item?.type === PoolType.COSMWASM && item.contractAddress)
navigate({
pathname: `/contracts/[contractAddress]`,
query: { contractAddress: item.contractAddress },
});
else {
navigate({ pathname: `/pools/[poolId]`, query: { poolId: item.id } });
}
};

const liquidity = item.poolLiquidity.reduce(
(total, asset) => total.add(asset.value ?? big(0)) as USD<Big>,
big(0) as USD<Big>
Expand All @@ -52,7 +39,9 @@ export const PoolCard = ({ item, mode = "percent-value" }: PoolCardProps) => {
justifyContent="space-between"
gap={4}
flexDirection="column"
onClick={handleOnClick}
onClick={() =>
navigate({ pathname: `/pools/[poolId]`, query: { poolId: item.id } })
}
bg="gray.900"
borderRadius="8px"
p={4}
Expand Down Expand Up @@ -100,9 +89,7 @@ export const PoolCard = ({ item, mode = "percent-value" }: PoolCardProps) => {
<LabelText
label="Liquidity"
tooltipText="The total amount of asset liquidity provided in the pool."
>
{" "}
</LabelText>
/>

<Text variant="body2" color="text.main">
{item.poolLiquidity.some((coin) => !coin.amount)
Expand Down
6 changes: 4 additions & 2 deletions src/lib/types/pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type {
Addr,
ContractAddr,
Nullable,
Nullish,
Option,
Token,
TokenWithValue,
Expand Down Expand Up @@ -34,7 +35,8 @@ export interface Pool<
type: PoolType;
isSuperfluid: boolean;
poolLiquidity: TLiquidity[];
contractAddress: Option<Nullable<ContractAddr>>;
// NOTE: not used any more
contractAddress: Nullish<ContractAddr>;
}

export interface PoolDetail<
Expand All @@ -54,7 +56,7 @@ export interface PoolDetail<
scalingFactorController: Nullable<string>;
spreadFactor: Nullable<string>;
tickSpacing: Nullable<number>;
contractAddress: Nullable<ContractAddr>;
contractAddress: Nullish<ContractAddr>;
}

export interface PoolInfo {
Expand Down

2 comments on commit 746734c

@vercel
Copy link

@vercel vercel bot commented on 746734c Dec 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 746734c Dec 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.