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

Feat: Implement Account Details Page #970

Merged
merged 5 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -39,6 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Features

- [#970](https://github.com/alleslabs/celatone-frontend/pull/970) Support account details lite version
- [#964](https://github.com/alleslabs/celatone-frontend/pull/964) Support migrate page lite version with LCD
- [#966](https://github.com/alleslabs/celatone-frontend/pull/966) Support lite version for proposal details
- [#958](https://github.com/alleslabs/celatone-frontend/pull/958) Support lite version for block index page
Expand Down
2 changes: 1 addition & 1 deletion src/config/chain/osmosis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const OSMOSIS_CHAIN_CONFIGS: ChainConfigs = {
prettyName: "Osmosis Testnet",
lcd: "https://lcd.osmotest5.osmosis.zone",
rpc: "https://osmosis-testnet-rpc.polkachu.com:443",
indexer: "https://osmo-test-5-graphql.alleslabs.dev/v1/graphql",
indexer: "",
evilpeach marked this conversation as resolved.
Show resolved Hide resolved
wallets: [...keplrWallets],
features: {
faucet: {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/modal/account/SaveNewAccount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { ControllerInput, ControllerTextarea } from "lib/components/forms";
import { useGetMaxLengthError, useHandleAccountSave } from "lib/hooks";
import { useFormatAddresses } from "lib/hooks/useFormatAddresses";
import { useAccountStore } from "lib/providers/store";
import { useAccountType } from "lib/services/accountService";
import { useAccountType } from "lib/services/account";
import type { BechAddr } from "lib/types";
import { AccountType } from "lib/types";

Expand Down
2 changes: 1 addition & 1 deletion src/lib/pages/account-details/components/AccountHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import { PrimaryNameMark } from "lib/components/PrimaryNameMark";
import { TotalValue } from "lib/components/TotalValue";
import { useAccountStore } from "lib/providers/store";
import type { AccountData } from "lib/services/account";
import type { AccountData } from "lib/services/types";
import type { BechAddr, HexAddr, Option } from "lib/types";

interface AccounHeaderProps {
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion src/lib/pages/account-details/components/tables/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from "./txs";
export * from "./AdminContractsTable";
export * from "./InstantiatedContractsTable";
export * from "./instantiated-contracts";
export * from "./OpenedProposalsTable";
export * from "./StoredCodesTable";
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import { Box } from "@chakra-ui/react";
import type { ChangeEvent } from "react";

import { useInternalNavigate, useMobile } 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 {
ContractsTable,
MobileTitle,
TableTitle,
ViewMore,
} from "lib/components/table";
import { useAccountContracts } from "lib/pages/account-details/data";
import type { BechAddr32 } from "lib/types";

import type { InstantiatedContractsTableProps } from "./types";

export const InstantiatedContractsTableFull = ({
address,
scrollComponentId,
totalData,
refetchCount,
onViewMore,
}: InstantiatedContractsTableProps) => {
const isMobile = useMobile();
const navigate = useInternalNavigate();
const onRowSelect = (contract: BechAddr32) =>
navigate({
pathname: "/contracts/[contract]",
query: { contract },
});

const {
pagesQuantity,
currentPage,
setCurrentPage,
pageSize,
setPageSize,
offset,
} = usePaginator({
total: totalData,
initialState: {
pageSize: 10,
currentPage: 1,
isDisabled: false,
},
});
const { contracts, isLoading } = useAccountContracts(
address,
offset,
onViewMore ? 5 : pageSize
);

const onPageChange = (nextPage: number) => {
refetchCount();
setCurrentPage(nextPage);
};

const onPageSizeChange = (e: ChangeEvent<HTMLSelectElement>) => {
const size = Number(e.target.value);
refetchCount();
setPageSize(size);
setCurrentPage(1);
};

const isMobileOverview = isMobile && !!onViewMore;
return (
<Box mt={{ base: 4, md: 8 }}>
{isMobileOverview ? (
<MobileTitle
title="Contract Instances"
count={totalData}
onViewMore={onViewMore}
/>
) : (
<>
<TableTitle
title="Contract Instances"
count={totalData}
helperText="This account instantiated the following contracts"
mb={2}
/>
<ContractsTable
contracts={contracts}
isLoading={isLoading}
emptyState={
!contracts ? (
<ErrorFetching dataName="contracts" />
) : (
<EmptyState
message="No contracts have been instantiated by this account before."
withBorder
/>
)
}
onRowSelect={onRowSelect}
/>
</>
)}
{!!totalData &&
(onViewMore
? totalData > 5 && !isMobile && <ViewMore onClick={onViewMore} />
: totalData > 10 && (
<Pagination
currentPage={currentPage}
pagesQuantity={pagesQuantity}
offset={offset}
totalData={totalData}
scrollComponentId={scrollComponentId}
pageSize={pageSize}
onPageChange={onPageChange}
onPageSizeChange={onPageSizeChange}
/>
))}
</Box>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { Box } from "@chakra-ui/react";

import { useInternalNavigate, useMobile } from "lib/app-provider";
import { EmptyState, ErrorFetching } from "lib/components/state";
import {
ContractsTable,
MobileTitle,
TableTitle,
ViewMore,
} from "lib/components/table";
import { useAccountContractsLcd } from "lib/pages/account-details/data";
import type { BechAddr32 } from "lib/types";

import type { InstantiatedContractsTableProps } from "./types";

export const InstantiatedContractsTableLite = ({
address,
onViewMore,
}: InstantiatedContractsTableProps) => {
const isMobile = useMobile();
const navigate = useInternalNavigate();
const onRowSelect = (contract: BechAddr32) =>
navigate({
pathname: "/contracts/[contract]",
query: { contract },
});
const { contracts, isLoading } = useAccountContractsLcd(address);

const contractsCount = contracts?.length;
const isMobileOverview = isMobile && !!onViewMore;
return (
<Box mt={{ base: 4, md: 8 }}>
{isMobileOverview ? (
<MobileTitle
title="Contract Instances"
count={contractsCount}
onViewMore={onViewMore}
/>
) : (
<>
<TableTitle
title="Contract Instances"
count={contractsCount}
helperText="This account instantiated the following contracts"
mb={2}
/>
<ContractsTable
contracts={onViewMore ? contracts?.slice(0, 5) : contracts}
isLoading={isLoading}
emptyState={
!contracts ? (
<ErrorFetching dataName="contracts" />
) : (
<EmptyState
message="No contracts have been instantiated by this account before."
withBorder
/>
)
}
onRowSelect={onRowSelect}
showLastUpdate={false}
/>
</>
)}
{!!contractsCount &&
(onViewMore
? contractsCount > 5 && !isMobile && <ViewMore onClick={onViewMore} />
: null)}
</Box>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { observer } from "mobx-react-lite";

import { useTierConfig } from "lib/app-provider";

import { InstantiatedContractsTableFull } from "./Full";
import { InstantiatedContractsTableLite } from "./Lite";
import type { InstantiatedContractsTableProps } from "./types";

export const InstantiatedContractsTable = observer(
(props: InstantiatedContractsTableProps) => {
const isFullTier = useTierConfig() === "full";

return isFullTier ? (
<InstantiatedContractsTableFull {...props} />
) : (
<InstantiatedContractsTableLite {...props} />
);
}
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { BechAddr, Option } from "lib/types";

export interface InstantiatedContractsTableProps {
address: BechAddr;
scrollComponentId: string;
totalData: Option<number>;
refetchCount: () => void;
onViewMore?: () => void;
}
Loading
Loading