Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: reroute cosmwasm pool back to pool detail page #694

Merged
merged 3 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,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
evilpeach marked this conversation as resolved.
Show resolved Hide resolved
- [#211](https://github.com/alleslabs/celatone-frontend/pull/211) Fix contract count not display for code table in public project
- [#208](https://github.com/alleslabs/celatone-frontend/pull/208) Fix messages shown in past tx page (should show only wasm and send messages)
- [#200](https://github.com/alleslabs/celatone-frontend/pull/200) Fix add attached assets property
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
Loading