From 64eb1451c503d95a6dc1dcd4b1c69d40f02d82c4 Mon Sep 17 00:00:00 2001 From: songwongtp <16089160+songwongtp@users.noreply.github.com> Date: Mon, 18 Dec 2023 15:30:39 +0700 Subject: [PATCH 1/5] fix: invalid state --- src/lib/components/state/InvalidState.tsx | 29 +++++++---------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/src/lib/components/state/InvalidState.tsx b/src/lib/components/state/InvalidState.tsx index ad19a113b..8ea2b5647 100644 --- a/src/lib/components/state/InvalidState.tsx +++ b/src/lib/components/state/InvalidState.tsx @@ -1,10 +1,9 @@ -import { Flex, Heading, Text } from "@chakra-ui/react"; import { useRouter } from "next/router"; import { useEffect } from "react"; import { trackInvalidState } from "lib/amplitude"; -import { StateImage } from "./StateImage"; +import { EmptyState } from "./EmptyState"; interface InvalidStateProps { title: string; @@ -18,23 +17,13 @@ export const InvalidState = ({ title }: InvalidStateProps) => { }, [router.isReady, title]); return ( - - - - {title} - - - Please double-check your input and make sure you have selected the - correct network. - - + ); }; From b089b9e7d219d3418ca670c59208bcc9756ed8f6 Mon Sep 17 00:00:00 2001 From: songwongtp <16089160+songwongtp@users.noreply.github.com> Date: Mon, 18 Dec 2023 15:37:03 +0700 Subject: [PATCH 2/5] fix: add changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 55c37c072..e71077d55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Features +- [#676](https://github.com/alleslabs/celatone-frontend/pull/676) New error fetching image & refactor empty states - [#671](https://github.com/alleslabs/celatone-frontend/pull/671) Add mahalo-1 - [#652](https://github.com/alleslabs/celatone-frontend/pull/652) Add amp publish module and deploy script - [#648](https://github.com/alleslabs/celatone-frontend/pull/648) Support OPInit transaction in initia From 90e7b3b5370fba6041717a8f6411e9f80a5e7fea Mon Sep 17 00:00:00 2001 From: songwongtp <16089160+songwongtp@users.noreply.github.com> Date: Mon, 18 Dec 2023 17:23:55 +0700 Subject: [PATCH 3/5] fix: move resend --- src/lib/utils/msgFurtherAction.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/utils/msgFurtherAction.ts b/src/lib/utils/msgFurtherAction.ts index 5a2d38b15..0052b9e70 100644 --- a/src/lib/utils/msgFurtherAction.ts +++ b/src/lib/utils/msgFurtherAction.ts @@ -11,7 +11,7 @@ export const getMsgFurtherAction = ( if ( isSigner && length === 1 && - (filters.isExecute || filters.isInstantiate || filters.isMoveExecute) + (filters.isExecute || filters.isInstantiate) ) { return MsgFurtherAction.REDO; } From 87522040056ef497050bd84dad18d32269bee20b Mon Sep 17 00:00:00 2001 From: songwongtp <16089160+songwongtp@users.noreply.github.com> Date: Mon, 18 Dec 2023 17:50:19 +0700 Subject: [PATCH 4/5] fix: error fetching --- src/config/theme/default.ts | 3 +- src/config/theme/initia.ts | 4 +- src/config/theme/osmosis.ts | 4 +- src/config/theme/sei.ts | 4 +- src/config/theme/types.ts | 1 + src/lib/components/state/ErrorFetching.tsx | 43 ++++++------------- src/lib/components/state/StateImage.tsx | 3 +- .../components/asset/AssetSectionContent.tsx | 5 +-- .../components/delegations/index.tsx | 6 +-- .../components/modules/ModuleListsBody.tsx | 5 +-- .../resources/ResourceOverviewBody.tsx | 5 +-- .../resources/ResourceSectionBody.tsx | 6 +-- .../components/tables/AdminContractsTable.tsx | 2 +- .../tables/InstantiatedContractsTable.tsx | 2 +- .../tables/OpenedProposalsTable.tsx | 2 +- .../components/tables/StoredCodesTable.tsx | 2 +- .../tables/bonded/DelegationsTable.tsx | 5 +-- .../tables/bonded/UnbondingsTable.tsx | 5 +-- .../components/tables/txs/index.tsx | 2 +- .../pages/blocks/components/BlocksTable.tsx | 6 +-- .../components/contract-balances/index.tsx | 5 +-- .../components/tables/TxsTable.tsx | 2 +- .../components/tables/ModuleTxsTable.tsx | 2 +- .../components/tables/history/index.tsx | 2 +- .../modules/components/RecentModulesTable.tsx | 2 +- .../components/MyPublishedModulesTable.tsx | 9 ++-- src/lib/pages/not-found/index.tsx | 2 +- .../pool-details/tables/pool-txs/index.tsx | 5 +-- src/lib/pages/txs/components/TxsTable.tsx | 2 +- 29 files changed, 51 insertions(+), 95 deletions(-) diff --git a/src/config/theme/default.ts b/src/config/theme/default.ts index f9fc1f074..d951fae74 100644 --- a/src/config/theme/default.ts +++ b/src/config/theme/default.ts @@ -112,7 +112,8 @@ export const DEFAULT_THEME: ThemeConfig = { }, jsonTheme: "monokai", illustration: { - error: "https://assets.alleslabs.dev/illustration/404.svg", + "404": "https://assets.alleslabs.dev/illustration/404.svg", + error: "https://assets.alleslabs.dev/illustration/error.svg", searchNotFound: "https://assets.alleslabs.dev/illustration/search-not-found.svg", searchEmpty: "https://assets.alleslabs.dev/illustration/search-empty.svg", diff --git a/src/config/theme/initia.ts b/src/config/theme/initia.ts index a784c5671..c22c01420 100644 --- a/src/config/theme/initia.ts +++ b/src/config/theme/initia.ts @@ -123,8 +123,10 @@ export const INITIA_THEME: ThemeConfig = { }, jsonTheme: "monokai", illustration: { - error: + "404": "https://assets.alleslabs.dev/integrations/initia/illustration/404.svg", + error: + "https://assets.alleslabs.dev/integrations/initia/illustration/error.svg", searchNotFound: "https://assets.alleslabs.dev/integrations/initia/illustration/search-not-found.svg", searchEmpty: diff --git a/src/config/theme/osmosis.ts b/src/config/theme/osmosis.ts index 67de537ae..0dab5720c 100644 --- a/src/config/theme/osmosis.ts +++ b/src/config/theme/osmosis.ts @@ -114,8 +114,10 @@ export const OSMOSIS_THEME: ThemeConfig = { }, jsonTheme: "pastel_on_dark", illustration: { - error: + "404": "https://assets.alleslabs.dev/integrations/osmosis/illustration/404.svg", + error: + "https://assets.alleslabs.dev/integrations/osmosis/illustration/error.svg", searchNotFound: "https://assets.alleslabs.dev/integrations/osmosis/illustration/search-not-found.svg", searchEmpty: diff --git a/src/config/theme/sei.ts b/src/config/theme/sei.ts index 2af9f694e..1a6ee2453 100644 --- a/src/config/theme/sei.ts +++ b/src/config/theme/sei.ts @@ -129,7 +129,9 @@ export const SEI_THEME: ThemeConfig = { }, jsonTheme: "one_dark", illustration: { - error: "https://assets.alleslabs.dev/integrations/sei/illustration/404.svg", + "404": "https://assets.alleslabs.dev/integrations/sei/illustration/404.svg", + error: + "https://assets.alleslabs.dev/integrations/sei/illustration/error.svg", searchNotFound: "https://assets.alleslabs.dev/integrations/sei/illustration/search-not-found.svg", searchEmpty: diff --git a/src/config/theme/types.ts b/src/config/theme/types.ts index e5780adba..d2f723611 100644 --- a/src/config/theme/types.ts +++ b/src/config/theme/types.ts @@ -125,6 +125,7 @@ export type ThemeConfig = { stepper: string; }; illustration: { + "404": string; error: string; searchNotFound: string; searchEmpty: string; diff --git a/src/lib/components/state/ErrorFetching.tsx b/src/lib/components/state/ErrorFetching.tsx index 33e703974..5a55ab4a5 100644 --- a/src/lib/components/state/ErrorFetching.tsx +++ b/src/lib/components/state/ErrorFetching.tsx @@ -1,36 +1,17 @@ -import { Flex, Text } from "@chakra-ui/react"; - -import { CustomIcon } from "lib/components/icon"; +import { EmptyState } from "./EmptyState"; interface ErrorFetchingProps { - message: string; + dataName: string; + withBorder?: boolean; } -// TODO: call EmptyState here instead with a format message -export const ErrorFetching = ({ message }: ErrorFetchingProps) => ( - - - - {message} Please try again later. - - +export const ErrorFetching = ({ + dataName, + withBorder = false, +}: ErrorFetchingProps) => ( + ); diff --git a/src/lib/components/state/StateImage.tsx b/src/lib/components/state/StateImage.tsx index 814ea4d3e..41cb5e1a7 100644 --- a/src/lib/components/state/StateImage.tsx +++ b/src/lib/components/state/StateImage.tsx @@ -3,9 +3,10 @@ import { Image } from "@chakra-ui/react"; import { CURR_THEME } from "env"; -export type ImageVariant = "not-found" | "empty" | "disconnected"; +export type ImageVariant = "error" | "not-found" | "empty" | "disconnected"; const imageSourceMap: Record = { + error: CURR_THEME.illustration.error, "not-found": CURR_THEME.illustration.searchNotFound, empty: CURR_THEME.illustration.searchEmpty, disconnected: CURR_THEME.illustration.disconnected, diff --git a/src/lib/pages/account-details/components/asset/AssetSectionContent.tsx b/src/lib/pages/account-details/components/asset/AssetSectionContent.tsx index 7a0805616..1eb5c4b11 100644 --- a/src/lib/pages/account-details/components/asset/AssetSectionContent.tsx +++ b/src/lib/pages/account-details/components/asset/AssetSectionContent.tsx @@ -13,10 +13,7 @@ export const AssetSectionContent = ({ supportedAssets, error, }: AssetSectionContentProps) => { - if (error) - return ( - - ); + if (error) return ; return supportedAssets.length ? ( ; - if (!stakingParams) - return ( - - ); + if (!stakingParams) return ; const redelegationCount = redelegations?.length ?? 0; - return ( ; - if (!modules) - return ( - - ); + if (!modules) return ; if (!filteredModules?.length) return ( ; - if (!resourcesByName) - return ( - - ); + if (!resourcesByName) return ; if (!resourcesByName.length) return ( ; - if (!resourcesByOwner) - return ( - - ); + if (!resourcesByOwner) return ; if (!resourcesByOwner.length) return ; - return ( <> + ) : ( + ) : ( + ) : ( + ) : ( ; - if (!delegations || !rewards) - return ( - - ); + if (!delegations || !rewards) return ; if (!delegations.length) return ( ; - if (!unbondings) - return ( - - ); + if (!unbondings) return ; if (!unbondings.length) return ( + ) : ( ) diff --git a/src/lib/pages/blocks/components/BlocksTable.tsx b/src/lib/pages/blocks/components/BlocksTable.tsx index 64ade8d09..eb328ad58 100644 --- a/src/lib/pages/blocks/components/BlocksTable.tsx +++ b/src/lib/pages/blocks/components/BlocksTable.tsx @@ -40,11 +40,7 @@ export const BlocksTable = ({ isViewMore }: BlocksTableProps) => { }); if (isLoading) return ; - if (error) - return ( - - ); - + if (error) return ; if (!data?.total) return ( - ); + if (error) return ; return ( + ) : ( + ) : ( + ) : ( { isLoading={isLoading} emptyState={ error ? ( - + ) : ( { }, [keyword, mappedModules]); const emptyState = () => { - if (error) - return ( - - ); + if (error) return ; if (!keyword) return ( ); return ( ); }; + return ( <> { mt={6} > page not found diff --git a/src/lib/pages/pools/components/pool-details/tables/pool-txs/index.tsx b/src/lib/pages/pools/components/pool-details/tables/pool-txs/index.tsx index c70a4877a..a8b54384c 100644 --- a/src/lib/pages/pools/components/pool-details/tables/pool-txs/index.tsx +++ b/src/lib/pages/pools/components/pool-details/tables/pool-txs/index.tsx @@ -58,10 +58,7 @@ export const PoolRelatedTxsTable = ({ setCurrentPage(1); }; - if (error) - return ( - - ); + if (error) return ; return ( <> { isLoading={isLoading} emptyState={ error ? ( - + ) : ( Date: Mon, 18 Dec 2023 22:03:26 +0700 Subject: [PATCH 5/5] fix: nonnegative total zod --- src/lib/services/block.ts | 2 +- src/lib/services/code.ts | 2 +- src/lib/services/contract.ts | 2 +- src/lib/services/move/module.ts | 4 ++-- src/lib/services/move/resource.ts | 2 +- src/lib/services/proposal.ts | 2 +- src/lib/services/tx.ts | 4 ++-- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/lib/services/block.ts b/src/lib/services/block.ts index 7047a7159..cb27380d9 100644 --- a/src/lib/services/block.ts +++ b/src/lib/services/block.ts @@ -36,7 +36,7 @@ const zBlocksResponseItem = z const zBlocksResponse = z.object({ items: z.array(zBlocksResponseItem), - total: z.number(), + total: z.number().nonnegative(), }); export type BlocksResponse = z.infer; diff --git a/src/lib/services/code.ts b/src/lib/services/code.ts index 653992d9c..248837306 100644 --- a/src/lib/services/code.ts +++ b/src/lib/services/code.ts @@ -54,7 +54,7 @@ const zCodesResponseItem = z const zCodesResponse = z.object({ items: z.array(zCodesResponseItem), - total: z.number(), + total: z.number().nonnegative(), }); export type CodesResponse = z.infer; diff --git a/src/lib/services/contract.ts b/src/lib/services/contract.ts index f5e1b32cc..64290963f 100644 --- a/src/lib/services/contract.ts +++ b/src/lib/services/contract.ts @@ -129,7 +129,7 @@ const zContractsResponseItem = z const zContractsResponse = z.object({ items: z.array(zContractsResponseItem), - total: z.number(), + total: z.number().nonnegative(), }); export type ContractsResponse = z.infer; diff --git a/src/lib/services/move/module.ts b/src/lib/services/move/module.ts index 9df0fba14..839dde26e 100644 --- a/src/lib/services/move/module.ts +++ b/src/lib/services/move/module.ts @@ -40,7 +40,7 @@ const zAccountModulesResponseItem = z const zAccountModulesResponse = z.object({ items: z.array(zAccountModulesResponseItem), - total: z.number(), + total: z.number().nonnegative(), }); type AccountModulesResponse = z.infer; @@ -182,7 +182,7 @@ const zModulesResponseItem = z const zModulesResponse = z.object({ items: z.array(zModulesResponseItem), - total: z.number(), + total: z.number().nonnegative(), }); export type ModulesResponse = z.infer; diff --git a/src/lib/services/move/resource.ts b/src/lib/services/move/resource.ts index 40af582ab..8d5e322f9 100644 --- a/src/lib/services/move/resource.ts +++ b/src/lib/services/move/resource.ts @@ -19,7 +19,7 @@ const zResourcesResponseItem = z const zResourcesResponse = z.object({ items: z.array(zResourcesResponseItem), - total: z.number(), + total: z.number().nonnegative(), }); export type ResourceResponse = z.infer; diff --git a/src/lib/services/proposal.ts b/src/lib/services/proposal.ts index 8dfcdd1b0..b8395f06c 100644 --- a/src/lib/services/proposal.ts +++ b/src/lib/services/proposal.ts @@ -90,7 +90,7 @@ const zProposalsResponseItem = z const zProposalResponse = z.object({ items: z.array(zProposalsResponseItem), - total: z.number(), + total: z.number().nonnegative(), }); export type ProposalResponse = z.infer; diff --git a/src/lib/services/tx.ts b/src/lib/services/tx.ts index 949c7defb..ab4af4f96 100644 --- a/src/lib/services/tx.ts +++ b/src/lib/services/tx.ts @@ -157,7 +157,7 @@ const zTxsResponseItem = zBaseTxsResponseItem.transform((val) => ({ const zTxsResponse = z.object({ items: z.array(zTxsResponseItem), - total: z.number(), + total: z.number().nonnegative(), }); export type TxsResponse = z.infer; @@ -264,7 +264,7 @@ export const getTxsByAddress = async ( const zBlockTxsResponse = z.object({ items: z.array(zTxsResponseItem), - total: z.number().positive(), + total: z.number().nonnegative(), }); export type BlockTxsResponse = z.infer;