Skip to content

Commit

Permalink
Merge branch 'develop' into feat/proposal-details-lite
Browse files Browse the repository at this point in the history
  • Loading branch information
songwongtp committed Jun 12, 2024
2 parents 3d3b9cb + b1eba85 commit 673e74e
Show file tree
Hide file tree
Showing 29 changed files with 589 additions and 302 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Features

- [#966](https://github.com/alleslabs/celatone-frontend/pull/966) Support lite version for proposal details
- [#951](https://github.com/alleslabs/celatone-frontend/pull/951) Support contract details lite version with LCD endpoint
- [#961](https://github.com/alleslabs/celatone-frontend/pull/961) Add and refactor proposal related lcd endpoints
- [#952](https://github.com/alleslabs/celatone-frontend/pull/952) Support module details page lite version with LCD endpoint
- [#940](https://github.com/alleslabs/celatone-frontend/pull/940) Support my published modules page lite version with LCD endpoint
Expand Down Expand Up @@ -72,6 +73,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Improvements

- [#963](https://github.com/alleslabs/celatone-frontend/pull/963) Add separator between token in tx message
- [#959](https://github.com/alleslabs/celatone-frontend/pull/959) Update @cosmos-kit/react to v2.15.0 and friends
- [#947](https://github.com/alleslabs/celatone-frontend/pull/947) Add zod type for sign mode infos
- [#917](https://github.com/alleslabs/celatone-frontend/pull/917) Update filter selection input to support multiple use case
Expand Down
2 changes: 1 addition & 1 deletion src/lib/app-provider/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export enum CELATONE_QUERY_KEYS {
// CONTRACT
CONTRACTS = "CELATONE_QUERY_CONTRACTS",
CONTRACT_DATA = "CELATONE_QUERY_CONTRACT_DATA",
CONTRACT_LCD = "CELATONE_QUERY_CONTRACT_LCD",
CONTRACT_QUERY_MSGS = "CELATONE_QUERY_CONTRACT_QUERY_MSGS",
CONTRACT_QUERY_LCD = "CELATONE_QUERY_CONTRACT_QUERY_LCD",
CONTRACT_STATES = "CELATONE_QUERY_CONTRACT_STATES",
Expand All @@ -45,6 +44,7 @@ export enum CELATONE_QUERY_KEYS {
INSTANTIATED_LIST_BY_WALLET_ADDRESS = "CELATONE_QUERY_INSTANTIATED_LIST_BY_WALLET_ADDRESS",
ADMINS_BY_CONTRACTS = "CELATONE_QUERY_ADMINS_BY_CONTRACTS",
CONTRACT_MIGRATION_HISTORIES_BY_CONTRACT_ADDRESS = "CELATONE_QUERY_CONTRACT_MIGRATION_HISTORIES_BY_CONTRACT_ADDRESS",
CONTRACT_MIGRATION_HISTORIES_BY_CONTRACT_ADDRESS_LCD = "CELATONE_QUERY_CONTRACT_MIGRATION_HISTORIES_BY_CONTRACT_ADDRESS_LCD",
// X/STAKING
STAKING_PARAMS_LCD = "CELATONE_QUERY_STAKING_PARAMS_LCD",
DELEGATIONS_BY_ADDRESS_LCD = "CELATONE_QUERY_DELEGATIONS_BY_ADDRESS_LCD",
Expand Down
8 changes: 4 additions & 4 deletions src/lib/components/ContractSelectSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { useForm } from "react-hook-form";

import { useMobile } from "lib/app-provider";
import { useContractStore } from "lib/providers/store";
import type { ContractLcd } from "lib/services/types";
import { useContractLcd } from "lib/services/wasm/contract";
import type { ContractData } from "lib/services/types";
import { useContractData } from "lib/services/wasm/contract";
import type { ContractLocalInfo } from "lib/stores/contract";
import type { BechAddr, BechAddr32, Option } from "lib/types";

Expand Down Expand Up @@ -37,7 +37,7 @@ interface ContractSelectSectionProps {
mode: "all-lists" | "only-admin";
contractAddress: BechAddr32;
onContractSelect: (contract: BechAddr32) => void;
successCallback?: (data: ContractLcd) => void;
successCallback?: (data: ContractData) => void;
}

const modeStyle = (mode: string) => {
Expand Down Expand Up @@ -157,7 +157,7 @@ export const ContractSelectSection = observer(
mode: "all",
});

const { refetch, isFetching } = useContractLcd(contractAddress, {
const { refetch, isFetching } = useContractData(contractAddress, {
enabled: !!contractAddress,
onSuccess: (data) => {
successCallback?.(data);
Expand Down
14 changes: 8 additions & 6 deletions src/lib/components/action-msg/SingleMsg.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Tag, Text } from "@chakra-ui/react";
import { Flex, Tag, Text } from "@chakra-ui/react";
import { snakeCase } from "snake-case";

import type { LinkType } from "lib/components/ExplorerLink";
Expand Down Expand Up @@ -43,11 +43,13 @@ export const SingleMsg = ({
{type} {text1}
</Text>
{tokens?.map((token: TokenWithValue, index: number) => (
<MsgToken
key={index.toString() + token.denom}
token={token}
// TODO: add `ampCopierSection` later
/>
<Flex key={token.denom}>
<MsgToken
token={token}
// TODO: add `ampCopierSection` later
/>
{index < tokens.length - 2 ? <Text>,</Text> : <Text ml={1}>and</Text>}
</Flex>
))}
{/* Tags */}
{tags?.map((tag, index: number) => (
Expand Down
4 changes: 2 additions & 2 deletions src/lib/components/modal/contract/SaveNewContract.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { OffChainForm } from "lib/components/OffChainForm";
import { INSTANTIATED_LIST_NAME } from "lib/data";
import { useHandleContractSave } from "lib/hooks";
import { useContractStore } from "lib/providers/store";
import { useContractLcd } from "lib/services/wasm/contract";
import { useContractData } from "lib/services/wasm/contract";
import type { BechAddr, BechAddr32, LVPair } from "lib/types";
import {
formatSlugName,
Expand Down Expand Up @@ -88,7 +88,7 @@ export function SaveNewContractModal({
});
};

const { refetch } = useContractLcd(contractAddressState as BechAddr32, {
const { refetch } = useContractData(contractAddressState as BechAddr32, {
onSuccess: (data) => {
const contractLocalInfo = getContractLocalInfo(contractAddressState);
reset({
Expand Down
29 changes: 16 additions & 13 deletions src/lib/components/select-contract/SelectContractInstantiator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
import { DEFAULT_RPC_ERROR } from "lib/data";
import { useInstantiatedByMe } from "lib/model/contract";
import { useContractStore } from "lib/providers/store";
import { useContractLcd } from "lib/services/wasm/contract";
import { useContractData } from "lib/services/wasm/contract";
import type { BechAddr32, RpcQueryError } from "lib/types";

import { AllContractLists } from "./AllContractLists";
Expand Down Expand Up @@ -73,18 +73,21 @@ export const SelectContractInstantiator = ({
resetOnClose();
};

const { refetch, isFetching, isRefetching } = useContractLcd(searchContract, {
enabled: false,
retry: false,
cacheTime: 0,
refetchOnReconnect: false,
onSuccess: () => onSelectThenClose(searchContract),
onError: (err) =>
setInvalid(
(err as AxiosError<RpcQueryError>).response?.data.message ||
DEFAULT_RPC_ERROR
),
});
const { refetch, isFetching, isRefetching } = useContractData(
searchContract,
{
enabled: false,
retry: false,
cacheTime: 0,
refetchOnReconnect: false,
onSuccess: () => onSelectThenClose(searchContract),
onError: (err) =>
setInvalid(
(err as AxiosError<RpcQueryError>).response?.data.message ||
DEFAULT_RPC_ERROR
),
}
);

const handleListSelect = (slug: string) => {
setListSlug(slug);
Expand Down
26 changes: 14 additions & 12 deletions src/lib/components/table/AccordionTx.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { GridItemProps } from "@chakra-ui/react";
import { SlideFade } from "@chakra-ui/react";
import { Flex, SlideFade } from "@chakra-ui/react";
import { useState } from "react";

import { AccordionStepperItem } from "../AccordionStepperItem";
Expand Down Expand Up @@ -55,17 +55,19 @@ export const AccordionTx = ({
onMouseLeave={() => setShowButton(false)}
>
<AccordionStepperItem />
<SingleActionMsg
messages={[message]}
type={extractMsgType(message.type)}
success
singleMsg
/>
{allowFurtherAction && isSigner && (
<SlideFade in={showButton} offsetY="20px">
<RenderButton message={message} />
</SlideFade>
)}
<Flex gap={1} alignItems="center">
<SingleActionMsg
messages={[message]}
type={extractMsgType(message.type)}
success
singleMsg
/>
{allowFurtherAction && isSigner && (
<SlideFade in={showButton} offsetY="20px">
<RenderButton message={message} />
</SlideFade>
)}
</Flex>
</TableRow>
);
};
4 changes: 2 additions & 2 deletions src/lib/pages/account-details/components/tables/txs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ export const TxsTable = ({
undefined,
isSigner,
filters,
offset,
onViewMore ? 5 : pageSize
onViewMore ? 5 : pageSize,
offset
);

const handleOnIsSignerChange = (value: Option<boolean>) => {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/pages/admin/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { TextInput } from "lib/components/forms";
import { UserDocsLink } from "lib/components/UserDocsLink";
import WasmPageContainer from "lib/components/WasmPageContainer";
import { useTxBroadcast } from "lib/hooks";
import { useContractLcd } from "lib/services/wasm/contract";
import { useContractData } from "lib/services/wasm/contract";
import type { BechAddr, BechAddr32 } from "lib/types";
import { MsgType } from "lib/types";
import { composeMsg, getFirstQueryParam } from "lib/utils";
Expand Down Expand Up @@ -107,7 +107,7 @@ const UpdateAdmin = () => {
/**
* @remarks Contract admin validation
*/
useContractLcd(contractAddressParam, {
useContractData(contractAddressParam, {
onSuccess: (data) => {
if (data.contract.admin !== address) onContractPathChange();
},
Expand Down
15 changes: 11 additions & 4 deletions src/lib/pages/contract-details/components/InstantiateInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { Box, chakra, Divider, Flex, Text } from "@chakra-ui/react";

import { useCurrentChain, useGetAddressType } from "lib/app-provider";
import {
useCurrentChain,
useGetAddressType,
useTierConfig,
} from "lib/app-provider";
import { Copier } from "lib/components/copy";
import { ExplorerLink } from "lib/components/ExplorerLink";
import { LabelText } from "lib/components/LabelText";
Expand Down Expand Up @@ -98,6 +102,7 @@ export const InstantiateInfo = ({
contractRest,
codeLocalInfo,
}: InstantiateInfoProps) => {
const isFullTier = useTierConfig() === "full";
const getAddressType = useGetAddressType();
const {
chain: { chain_id: chainId },
Expand Down Expand Up @@ -182,9 +187,11 @@ export const InstantiateInfo = ({
fixedHeight
/>
</LabelText>
<Flex flex="1">
<InitRender {...contract} />
</Flex>
{isFullTier && (
<Flex flex="1">
<InitRender {...contract} />
</Flex>
)}
</Flex>
<Flex direction={{ base: "row", md: "column" }} gap={{ base: 1, md: 6 }}>
{contractRest?.contract_info.ibc_port_id && (
Expand Down
23 changes: 19 additions & 4 deletions src/lib/pages/contract-details/components/tables/TxsTable.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { useTierConfig } from "lib/app-provider";
import { Pagination } from "lib/components/pagination";
import { usePaginator } from "lib/components/pagination/usePaginator";
import { EmptyState, ErrorFetching } from "lib/components/state";
import { TransactionsTable } from "lib/components/table";
import { DEFAULT_TX_FILTERS } from "lib/data";
import { useTxsByAddress } from "lib/services/tx";
import { useTxsByAddress, useTxsByContractAddressLcd } from "lib/services/tx";
import type { BechAddr32, Option } from "lib/types";

interface TxsTableProps {
Expand All @@ -19,7 +20,10 @@ export const TxsTable = ({
totalData,
refetchCount,
}: TxsTableProps) => {
const isFullTier = useTierConfig() === "full";

const {
setTotalData,
pagesQuantity,
currentPage,
setCurrentPage,
Expand All @@ -35,14 +39,21 @@ export const TxsTable = ({
},
});

const { data, isLoading, error } = useTxsByAddress(
const resApi = useTxsByAddress(
contractAddress,
undefined,
undefined,
DEFAULT_TX_FILTERS,
pageSize,
offset,
pageSize
{ enabled: isFullTier }
);
const resLcd = useTxsByContractAddressLcd(contractAddress, pageSize, offset, {
enabled: !isFullTier,
onSuccess: ({ total }) => setTotalData(total),
});

const { data, isLoading, error } = isFullTier ? resApi : resLcd;

return (
<>
Expand All @@ -56,7 +67,11 @@ export const TxsTable = ({
<EmptyState
withBorder
imageVariant="empty"
message="This contract does not have any transactions"
message={
isFullTier
? "This contract does not have any transactions."
: "This contract does not have any transactions, or they are too old and have been pruned from the LCD."
}
/>
)
}
Expand Down
30 changes: 18 additions & 12 deletions src/lib/pages/contract-details/components/tables/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
Tabs,
} from "@chakra-ui/react";

import { useGovConfig } from "lib/app-provider";
import { useGovConfig, useTierConfig } from "lib/app-provider";
import { CustomTab } from "lib/components/CustomTab";
import { useContractTableCounts } from "lib/services/wasm/contract";
import type { BechAddr32 } from "lib/types";
Expand All @@ -20,12 +20,16 @@ interface ContractTablesProps {
contractAddress: BechAddr32;
}

const tableHeaderId = "contractDetailsTableHeader";

export const ContractTables = ({ contractAddress }: ContractTablesProps) => {
const tableHeaderId = "contractDetailsTableHeader";
const isFullTier = useTierConfig() === "full";

const gov = useGovConfig({ shouldRedirect: false });
const { data, refetch: refetchCount } =
useContractTableCounts(contractAddress);
const { data, refetch: refetchCount } = useContractTableCounts(
contractAddress,
{ enabled: isFullTier }
);

return (
<Flex direction="column" gap={6}>
Expand All @@ -45,14 +49,16 @@ export const ContractTables = ({ contractAddress }: ContractTablesProps) => {
<CustomTab count={data?.migration} isDisabled={data?.migration === 0}>
Migrations
</CustomTab>
<CustomTab
count={data?.relatedProposal}
isDisabled={data?.relatedProposal === 0}
whiteSpace="nowrap"
hidden={!gov.enabled}
>
Related Proposals
</CustomTab>
{isFullTier && (
<CustomTab
count={data?.relatedProposal}
isDisabled={data?.relatedProposal === 0}
whiteSpace="nowrap"
hidden={!gov.enabled}
>
Related Proposals
</CustomTab>
)}
</TabList>
<TabPanels>
<TabPanel p={0}>
Expand Down
Loading

0 comments on commit 673e74e

Please sign in to comment.