From ddec6073a3fd589d098a7ba0cc79bd807cafa6a2 Mon Sep 17 00:00:00 2001 From: songwongtp <16089160+songwongtp@users.noreply.github.com> Date: Wed, 3 Jul 2024 10:42:24 +0700 Subject: [PATCH 01/16] fix: misc --- src/lib/components/table/modules/ModulesTable.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/components/table/modules/ModulesTable.tsx b/src/lib/components/table/modules/ModulesTable.tsx index 0018f01f1..f7b21dddf 100644 --- a/src/lib/components/table/modules/ModulesTable.tsx +++ b/src/lib/components/table/modules/ModulesTable.tsx @@ -33,7 +33,7 @@ export const ModulesTable = ({ {modules.map((module) => ( ))} @@ -46,7 +46,7 @@ export const ModulesTable = ({ /> {modules.map((module) => ( Date: Wed, 3 Jul 2024 10:45:56 +0700 Subject: [PATCH 02/16] fix: revert initia --- src/config/chain/initia.ts | 48 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/src/config/chain/initia.ts b/src/config/chain/initia.ts index a04bdd213..fc11e1532 100644 --- a/src/config/chain/initia.ts +++ b/src/config/chain/initia.ts @@ -7,6 +7,54 @@ const INITIA_DECODER = "https://initia-api-jiod42ec2q-as.a.run.app/decode_module"; export const INITIA_CHAIN_CONFIGS: ChainConfigs = { + "tomcat-1-lite": { + tier: "lite", + chain: "initia", + registryChainName: "blackwingtestnet", + prettyName: "Blackwing Testnet Lite", + lcd: "https://maze-rest-18bdff44-3aa4-425e-9bc0-06a2afa40af8.ase1-prod.newmetric.xyz", + rpc: "https://maze-rpc-18bdff44-3aa4-425e-9bc0-06a2afa40af8.ase1-prod.newmetric.xyz", + indexer: "https://tomcat-1-graphql.alleslabs.dev/v1/graphql", + wallets: [...initiaWallets, ...keplrWallets], + features: { + faucet: { + enabled: false, + }, + wasm: { + enabled: false, + }, + move: { + enabled: true, + moduleMaxFileSize: 1_048_576, + decodeApi: INITIA_DECODER, + verify: "", + }, + pool: { + enabled: false, + }, + publicProject: { + enabled: true, + }, + gov: { + enabled: false, + }, + nft: { + enabled: true, + }, + }, + gas: { + gasPrice: { + tokenPerGas: 0.151, + denom: + "l2/aee375e9d0b181f0d9d3a49f9a3d1d6b05d62b0ac81f8c92b9282afa4213d884", + }, + gasAdjustment: 1.5, + maxGasLimit: 25_000_000, + }, + extra: { + isValidatorExternalLink: null, + }, + }, "initiation-1": { tier: "full", chain: "initia", From 6c7b1c43f76e9c3fc100247f6b09e050792fbd20 Mon Sep 17 00:00:00 2001 From: songwongtp <16089160+songwongtp@users.noreply.github.com> Date: Wed, 3 Jul 2024 11:34:54 +0700 Subject: [PATCH 03/16] fix: empty string moniker --- CHANGELOG.md | 2 ++ src/lib/components/ExplorerLink.tsx | 4 ++-- src/lib/components/ValidatorImage.tsx | 13 +++++-------- .../components/validator-top/ValidatorTitle.tsx | 8 ++++---- src/lib/services/validator/index.ts | 2 +- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9bab093b1..ac62f89aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Bug fixes +- [#1004](https://github.com/alleslabs/celatone-frontend/pull/1004) Fix empty string moniker + ## v1.7.0 ### Features diff --git a/src/lib/components/ExplorerLink.tsx b/src/lib/components/ExplorerLink.tsx index 0b023f1db..11663c19f 100644 --- a/src/lib/components/ExplorerLink.tsx +++ b/src/lib/components/ExplorerLink.tsx @@ -121,12 +121,12 @@ const LinkRender = ({ - {textValue} + {textValue || "(empty)"} ); diff --git a/src/lib/components/ValidatorImage.tsx b/src/lib/components/ValidatorImage.tsx index beb0fac62..85f21a950 100644 --- a/src/lib/components/ValidatorImage.tsx +++ b/src/lib/components/ValidatorImage.tsx @@ -1,5 +1,6 @@ import type { ImageProps } from "@chakra-ui/react"; import { Image, SkeletonCircle } from "@chakra-ui/react"; +import { isUndefined } from "lodash"; import { useValidatorImage } from "lib/services/validator"; import type { Nullable, Validator } from "lib/types"; @@ -15,11 +16,9 @@ export const ValidatorImage = ({ }: ValidatorImageProps) => { const { data, isLoading } = useValidatorImage(validator); - if ( - !validator || - !validator.moniker || - validator.moniker.trim().length === 0 - ) { + if (isLoading) return ; + + if (!validator || isUndefined(data) || isUndefined(validator.moniker)) { return ( - ) : ( + return ( ( as="h5" variant="h5" wordBreak="break-word" - color="text.main" + color={info.moniker.length ? "text.main" : "gray.600"} display={{ base: "none", md: "flex" }} > - {info.moniker} + {info.moniker || "(empty)"} @@ -49,10 +49,10 @@ export const ValidatorTitle = ({ info }: ValidatorTitleProps) => ( variant="h6" mt={1} wordBreak="break-word" - color="text.main" + color={info.moniker.length ? "text.main" : "gray.600"} display={{ base: "flex", md: "none" }} > - {info.moniker} + {info.moniker || "(empty)"} { - if (!validator) return Promise.resolve(""); + if (!validator) return ""; return resolveValIdentity(chainName, validator, secondaryMain); }, retry: false, From d6116b8bb4f68e3b13f50c7e5979af7eb1798ce0 Mon Sep 17 00:00:00 2001 From: songwongtp <16089160+songwongtp@users.noreply.github.com> Date: Wed, 3 Jul 2024 13:43:04 +0700 Subject: [PATCH 04/16] fix: show valaddr instead of empty moniker --- src/lib/components/ExplorerLink.tsx | 10 ++++++---- src/lib/components/ValidatorBadge.tsx | 2 +- .../components/validator-top/ValidatorTitle.tsx | 8 ++++---- .../components/validator-top/index.tsx | 3 ++- src/lib/services/validator/index.ts | 1 + src/lib/services/validator/misc.ts | 2 +- 6 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/lib/components/ExplorerLink.tsx b/src/lib/components/ExplorerLink.tsx index 11663c19f..b252a7ef7 100644 --- a/src/lib/components/ExplorerLink.tsx +++ b/src/lib/components/ExplorerLink.tsx @@ -20,8 +20,7 @@ export type LinkType = | "code_id" | "block_height" | "proposal_id" - | "pool_id" - | "proposal_id"; + | "pool_id"; interface ExplorerLinkProps extends FlexProps { value: string; @@ -104,6 +103,7 @@ const LinkRender = ({ isInternal, hrefLink, textValue, + fallbackValue, isEllipsis, textVariant, openNewTab, @@ -112,6 +112,7 @@ const LinkRender = ({ isInternal: boolean; hrefLink: string; textValue: string; + fallbackValue: string; isEllipsis: boolean; textVariant: TextProps["variant"]; openNewTab: Option; @@ -121,12 +122,12 @@ const LinkRender = ({ - {textValue || "(empty)"} + {textValue || fallbackValue} ); @@ -210,6 +211,7 @@ export const ExplorerLink = ({ isInternal={isUndefined(externalLink)} hrefLink={link} textValue={textValue} + fallbackValue={copyValue || value} isEllipsis={textFormat === "ellipsis"} textVariant={textVariant} openNewTab={openNewTab} diff --git a/src/lib/components/ValidatorBadge.tsx b/src/lib/components/ValidatorBadge.tsx index 3b272de7e..061282fd1 100644 --- a/src/lib/components/ValidatorBadge.tsx +++ b/src/lib/components/ValidatorBadge.tsx @@ -39,7 +39,7 @@ export const ValidatorBadge = ({ {isMobile && hasLabel && } ( as="h5" variant="h5" wordBreak="break-word" - color={info.moniker.length ? "text.main" : "gray.600"} + color={info.moniker.length ? "text.main" : "text.disabled"} display={{ base: "none", md: "flex" }} > - {info.moniker || "(empty)"} + {info.moniker || "Untitled"} @@ -49,10 +49,10 @@ export const ValidatorTitle = ({ info }: ValidatorTitleProps) => ( variant="h6" mt={1} wordBreak="break-word" - color={info.moniker.length ? "text.main" : "gray.600"} + color={info.moniker.length ? "text.main" : "text.disabled"} display={{ base: "flex", md: "none" }} > - {info.moniker || "(empty)"} + {info.moniker || "Untitled"} diff --git a/src/lib/services/validator/index.ts b/src/lib/services/validator/index.ts index aadf0d6bf..546636d37 100644 --- a/src/lib/services/validator/index.ts +++ b/src/lib/services/validator/index.ts @@ -77,6 +77,7 @@ export const useValidators = ( { retry: 1, keepPreviousData: true, + refetchOnWindowFocus: false, ...options, } ); diff --git a/src/lib/services/validator/misc.ts b/src/lib/services/validator/misc.ts index 0cd1c5589..31daf8d7b 100644 --- a/src/lib/services/validator/misc.ts +++ b/src/lib/services/validator/misc.ts @@ -23,7 +23,7 @@ export const resolveValIdentity = async ( .catch(async (_) => { if (validator.identity) { const { data } = await axios.get(keybaseUrl); - if (data.them.length) return data.them[0].pictures.primary.url; + if (data.them?.length) return data.them[0].pictures.primary.url; } return uiAvatarsUrl; }) From 83c9bb07e7da07daa976a536fc28f0cc5030da01 Mon Sep 17 00:00:00 2001 From: evilpeach Date: Wed, 3 Jul 2024 17:06:42 +0700 Subject: [PATCH 05/16] feat: add mesa, sequencer tier, TierSwitcher --- CHANGELOG.md | 2 + src/config/chain/initia.ts | 49 +++++++++++++++++ src/config/chain/types.ts | 2 +- src/lib/app-provider/hooks/useConfig.ts | 13 +++-- src/lib/components/TierSwitcher.tsx | 29 +++++++++++ .../modal/account/SaveNewAccount.tsx | 2 +- .../select-code/CodeSelectSection.tsx | 2 +- .../select-contract/ContractListDetail.tsx | 2 +- .../table/contracts/ContractsTableRowCTA.tsx | 2 +- .../table/proposals/ProposalsTable.tsx | 2 +- .../table/proposals/ProposalsTableHeader.tsx | 2 +- .../proposals/ProposalsTableMobileCard.tsx | 2 +- .../table/proposals/ProposalsTableRow.tsx | 2 +- src/lib/hooks/useOpenTab.ts | 2 +- src/lib/hooks/useSingleMessageProps.ts | 2 +- src/lib/layout/InformationFooter.tsx | 2 +- src/lib/layout/Searchbar.tsx | 2 +- src/lib/layout/mobile/NavDrawer.tsx | 2 +- src/lib/layout/navbar/index.tsx | 2 +- src/lib/layout/subheader/index.tsx | 2 +- src/lib/model/contract.ts | 4 +- .../tables/instantiated-contracts/index.tsx | 17 +++--- .../components/tables/txs/Lite.tsx | 2 +- .../components/tables/txs/index.tsx | 13 ++--- src/lib/pages/account-details/data.ts | 2 +- src/lib/pages/account-details/index.tsx | 2 +- src/lib/pages/admin/index.tsx | 30 ++++++----- .../block-details/components/BlockInfo.tsx | 2 +- src/lib/pages/block-details/index.tsx | 25 ++++----- .../code-info/CodeInfoLabelText.tsx | 2 +- .../components/code-info/CodeInfoSection.tsx | 2 +- .../components/code-info/CodeTopInfo.tsx | 2 +- src/lib/pages/code-details/index.tsx | 13 ++--- src/lib/pages/codes/index.tsx | 9 ++-- .../components/InstantiateInfo.tsx | 2 +- .../components/tables/TxsTable.tsx | 2 +- .../components/tables/index.tsx | 2 +- .../tables/migration/MigrationHeader.tsx | 2 +- .../tables/migration/MigrationMobileCard.tsx | 2 +- .../tables/migration/MigrationRow.tsx | 2 +- .../components/tables/migration/index.tsx | 29 +++++------ src/lib/pages/contract-details/data.ts | 2 +- src/lib/pages/home/index.tsx | 5 +- src/lib/pages/instantiate/instantiate.tsx | 2 +- src/lib/pages/migrate/index.tsx | 30 ++++++----- .../components/ModuleActions.tsx | 4 +- .../components/ModuleInfoBody.tsx | 2 +- src/lib/pages/module-details/index.tsx | 2 +- src/lib/pages/past-txs/index.tsx | 5 +- .../components/proposal-top/index.tsx | 2 +- .../deposit-period/DepositPeriodSection.tsx | 2 +- .../vote-details/voting-period/index.tsx | 2 +- src/lib/pages/proposal-details/data.ts | 2 +- .../components/ProposalStatusFilter.tsx | 2 +- src/lib/pages/proposals/index.tsx | 9 ++-- .../VotingPowerOverview.tsx | 2 +- .../components/validator-overview/index.tsx | 2 +- src/lib/pages/validator-details/index.tsx | 15 +++--- src/lib/pages/validators/index.tsx | 52 ++++++++++--------- src/lib/services/account/index.ts | 2 +- src/lib/services/bank/index.ts | 2 +- src/lib/services/move/module/index.ts | 2 +- src/lib/services/proposal/index.ts | 18 +++---- src/lib/services/searchService.ts | 2 +- src/lib/services/tx/index.ts | 2 +- src/lib/services/validator/index.ts | 2 +- src/lib/services/wasm/contract/index.ts | 2 +- 67 files changed, 276 insertions(+), 189 deletions(-) create mode 100644 src/lib/components/TierSwitcher.tsx diff --git a/CHANGELOG.md b/CHANGELOG.md index ac62f89aa..87eaa7e7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Features +- [#993](https://github.com/alleslabs/celatone-frontend/pull/993) Add Sequencer, Mesa tier and TierSwitcher component + ### Improvements ### Bug fixes diff --git a/src/config/chain/initia.ts b/src/config/chain/initia.ts index fc11e1532..17154b151 100644 --- a/src/config/chain/initia.ts +++ b/src/config/chain/initia.ts @@ -1,3 +1,4 @@ +/* eslint-disable sonarjs/no-duplicate-string */ import { wallets as initiaWallets } from "@cosmos-kit/initia"; import { wallets as keplrWallets } from "@cosmos-kit/keplr"; @@ -55,6 +56,54 @@ export const INITIA_CHAIN_CONFIGS: ChainConfigs = { isValidatorExternalLink: null, }, }, + "tomcat-1-sequencer": { + tier: "sequencer", + chain: "initia", + registryChainName: "blackwingtestnet", + prettyName: "Blackwing Testnet Sequencer", + lcd: "https://maze-rest-18bdff44-3aa4-425e-9bc0-06a2afa40af8.ase1-prod.newmetric.xyz", + rpc: "https://maze-rpc-18bdff44-3aa4-425e-9bc0-06a2afa40af8.ase1-prod.newmetric.xyz", + indexer: "https://tomcat-1-graphql.alleslabs.dev/v1/graphql", + wallets: [...initiaWallets, ...keplrWallets], + features: { + faucet: { + enabled: false, + }, + wasm: { + enabled: false, + }, + move: { + enabled: true, + moduleMaxFileSize: 1_048_576, + decodeApi: INITIA_DECODER, + verify: "", + }, + pool: { + enabled: false, + }, + publicProject: { + enabled: true, + }, + gov: { + enabled: false, + }, + nft: { + enabled: true, + }, + }, + gas: { + gasPrice: { + tokenPerGas: 0.151, + denom: + "l2/aee375e9d0b181f0d9d3a49f9a3d1d6b05d62b0ac81f8c92b9282afa4213d884", + }, + gasAdjustment: 1.5, + maxGasLimit: 25_000_000, + }, + extra: { + isValidatorExternalLink: null, + }, + }, "initiation-1": { tier: "full", chain: "initia", diff --git a/src/config/chain/types.ts b/src/config/chain/types.ts index c9f068ed4..f6e5bce49 100644 --- a/src/config/chain/types.ts +++ b/src/config/chain/types.ts @@ -53,7 +53,7 @@ type GovConfig = type NftConfig = { enabled: boolean }; export interface ChainConfig { - tier: "lite" | "full"; + tier: "lite" | "mesa" | "sequencer" | "full"; chain: string; registryChainName: string; prettyName: string; diff --git a/src/lib/app-provider/hooks/useConfig.ts b/src/lib/app-provider/hooks/useConfig.ts index d4963caad..f0f242b42 100644 --- a/src/lib/app-provider/hooks/useConfig.ts +++ b/src/lib/app-provider/hooks/useConfig.ts @@ -5,8 +5,9 @@ import { useInternalNavigate } from "./useInternalNavigate"; const TierMap: Record = { lite: 0, - // new metric 1 - full: 2, + mesa: 1, + sequencer: 2, + full: 3, }; export const useTierConfig = ( @@ -26,7 +27,13 @@ export const useTierConfig = ( if (TierMap[tier] < TierMap[minTier]) navigate({ pathname: "/", replace: true }); - return tier; + return { + tier, + isFullTier: tier === "full", + isLiteTier: tier === "lite", + isMesaTier: tier === "mesa", + isSequencerTier: tier === "sequencer", + }; }; type Features = ChainConfig["features"]; diff --git a/src/lib/components/TierSwitcher.tsx b/src/lib/components/TierSwitcher.tsx new file mode 100644 index 000000000..008cb263b --- /dev/null +++ b/src/lib/components/TierSwitcher.tsx @@ -0,0 +1,29 @@ +import { useTierConfig } from "lib/app-provider"; + +interface TierSwitcherProps { + full: React.ReactNode; + sequencer?: React.ReactNode; + mesa?: React.ReactNode; + lite: React.ReactNode; +} + +export const TierSwitcher = ({ + full, + lite, + mesa, + sequencer, +}: TierSwitcherProps) => { + const { tier } = useTierConfig(); + + switch (tier) { + case "full": + return full; + case "sequencer": + return sequencer ?? lite; + case "mesa": + return mesa ?? lite; + case "lite": + default: + return lite; + } +}; diff --git a/src/lib/components/modal/account/SaveNewAccount.tsx b/src/lib/components/modal/account/SaveNewAccount.tsx index a2d2e2d48..0681b1154 100644 --- a/src/lib/components/modal/account/SaveNewAccount.tsx +++ b/src/lib/components/modal/account/SaveNewAccount.tsx @@ -49,7 +49,7 @@ export function SaveNewAccountModal({ publicDescription, }: SaveNewAccountModalProps) { const { constants } = useCelatoneApp(); - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); const { user: exampleUserAddress } = useExampleAddresses(); const { isSomeValidAddress } = useValidateAddress(); const formatAddresses = useFormatAddresses(); diff --git a/src/lib/components/select-code/CodeSelectSection.tsx b/src/lib/components/select-code/CodeSelectSection.tsx index f3489614d..592abcfa5 100644 --- a/src/lib/components/select-code/CodeSelectSection.tsx +++ b/src/lib/components/select-code/CodeSelectSection.tsx @@ -30,7 +30,7 @@ export const CodeSelectSection = ({ setCodeHash, status, }: CodeSelectSectionProps) => { - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); const [method, setMethod] = useState<"select-existing" | "fill-manually">( isFullTier ? "select-existing" : "fill-manually" ); diff --git a/src/lib/components/select-contract/ContractListDetail.tsx b/src/lib/components/select-contract/ContractListDetail.tsx index 968d4064a..84ff6a590 100644 --- a/src/lib/components/select-contract/ContractListDetail.tsx +++ b/src/lib/components/select-contract/ContractListDetail.tsx @@ -88,7 +88,7 @@ export const ContractListDetail = ({ onContractSelect, isReadOnly = false, }: ContractListDetailProps) => { - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); const dataFull = useAdminByContractAddresses( isReadOnly || !isFullTier ? [] diff --git a/src/lib/components/table/contracts/ContractsTableRowCTA.tsx b/src/lib/components/table/contracts/ContractsTableRowCTA.tsx index 80a33b2b9..192ff7d22 100644 --- a/src/lib/components/table/contracts/ContractsTableRowCTA.tsx +++ b/src/lib/components/table/contracts/ContractsTableRowCTA.tsx @@ -56,7 +56,7 @@ export const ContractsTableRowCTA = ({ showLastUpdate = true, }: ContractsTableRowCTAProps) => { const { address } = useCurrentChain(); - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); const navigate = useInternalNavigate(); const isAdmin = !!address && address === contractInfo.admin; diff --git a/src/lib/components/table/proposals/ProposalsTable.tsx b/src/lib/components/table/proposals/ProposalsTable.tsx index b393ab71f..322a326ff 100644 --- a/src/lib/components/table/proposals/ProposalsTable.tsx +++ b/src/lib/components/table/proposals/ProposalsTable.tsx @@ -18,7 +18,7 @@ export const ProposalsTable = ({ isLoading, emptyState, }: ProposalsTableProps) => { - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); const isMobile = useMobile(); if (isLoading) return ; diff --git a/src/lib/components/table/proposals/ProposalsTableHeader.tsx b/src/lib/components/table/proposals/ProposalsTableHeader.tsx index 27a2966d6..dba9952f9 100644 --- a/src/lib/components/table/proposals/ProposalsTableHeader.tsx +++ b/src/lib/components/table/proposals/ProposalsTableHeader.tsx @@ -13,7 +13,7 @@ export const ProposalsTableHeader = ({ templateColumns, boxShadow, }: ProposalsTableHeaderProps) => { - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); // TODO - Revisit split columnsWidth const columnsWidth = templateColumns?.toString().split(" "); diff --git a/src/lib/components/table/proposals/ProposalsTableMobileCard.tsx b/src/lib/components/table/proposals/ProposalsTableMobileCard.tsx index e979f51c4..bbd814adf 100644 --- a/src/lib/components/table/proposals/ProposalsTableMobileCard.tsx +++ b/src/lib/components/table/proposals/ProposalsTableMobileCard.tsx @@ -20,7 +20,7 @@ export interface ProposalsTableMobileCardProps { export const ProposalsTableMobileCard = ({ proposal, }: ProposalsTableMobileCardProps) => { - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); const navigate = useInternalNavigate(); const onCardSelect = (proposalId: number) => diff --git a/src/lib/components/table/proposals/ProposalsTableRow.tsx b/src/lib/components/table/proposals/ProposalsTableRow.tsx index 6a4478db0..cd731779d 100644 --- a/src/lib/components/table/proposals/ProposalsTableRow.tsx +++ b/src/lib/components/table/proposals/ProposalsTableRow.tsx @@ -25,7 +25,7 @@ export const ProposalsTableRow = ({ templateColumns, boxShadow, }: ProposalsTableRowProps) => { - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); const navigate = useInternalNavigate(); const onRowSelect = (proposalId: number) => diff --git a/src/lib/hooks/useOpenTab.ts b/src/lib/hooks/useOpenTab.ts index 2eb962b34..352192add 100644 --- a/src/lib/hooks/useOpenTab.ts +++ b/src/lib/hooks/useOpenTab.ts @@ -23,7 +23,7 @@ export const useOpenTxTab = (type: "lcd" | "tx-page") => { }; export const useOpenAssetTab = () => { - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); const apiEndpoint = useBaseApiRoute("accounts"); const lcdEndpoint = useLcdEndpoint(); diff --git a/src/lib/hooks/useSingleMessageProps.ts b/src/lib/hooks/useSingleMessageProps.ts index 337906eed..0e1b763fc 100644 --- a/src/lib/hooks/useSingleMessageProps.ts +++ b/src/lib/hooks/useSingleMessageProps.ts @@ -599,7 +599,7 @@ export const useSingleActionMsgProps = ( messages: Message[], singleMsg: Option ): SingleMsgProps => { - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); const { getContractLocalInfo } = useContractStore(); const { data: assetInfos } = useAssetInfos({ withPrices: false }); const { data: movePoolInfos } = useMovePoolInfos({ withPrices: false }); diff --git a/src/lib/layout/InformationFooter.tsx b/src/lib/layout/InformationFooter.tsx index a6db4c4be..3149d3e9e 100644 --- a/src/lib/layout/InformationFooter.tsx +++ b/src/lib/layout/InformationFooter.tsx @@ -27,7 +27,7 @@ const FOOTER_BUTTONS = [ ]; export const InformationFooter = () => { - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); const { data: overviewsStats, isLoading: isLoadingFull } = useOverviewsStats(isFullTier); const { data: latestHeight, isLoading: isLoadingLite } = useLatestBlockLcd(); diff --git a/src/lib/layout/Searchbar.tsx b/src/lib/layout/Searchbar.tsx index 4dc77fbdb..be0f84fd9 100644 --- a/src/lib/layout/Searchbar.tsx +++ b/src/lib/layout/Searchbar.tsx @@ -287,7 +287,7 @@ const getPlaceholder = ({ // eslint-disable-next-line sonarjs/cognitive-complexity const Searchbar = () => { - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); const isMobile = useMobile(); const navigate = useInternalNavigate(); const { diff --git a/src/lib/layout/mobile/NavDrawer.tsx b/src/lib/layout/mobile/NavDrawer.tsx index ac7563199..0a96a6846 100644 --- a/src/lib/layout/mobile/NavDrawer.tsx +++ b/src/lib/layout/mobile/NavDrawer.tsx @@ -32,7 +32,7 @@ import { usePublicProjectStore } from "lib/providers/store"; import { getNavDrawerFull, getNavDrawerLite } from "./utils"; export const NavDrawer = () => { - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); const govConfig = useGovConfig({ shouldRedirect: false }); const wasmConfig = useWasmConfig({ shouldRedirect: false }); const moveConfig = useMoveConfig({ shouldRedirect: false }); diff --git a/src/lib/layout/navbar/index.tsx b/src/lib/layout/navbar/index.tsx index ab4145a9c..ca32400b6 100644 --- a/src/lib/layout/navbar/index.tsx +++ b/src/lib/layout/navbar/index.tsx @@ -39,7 +39,7 @@ const Navbar = observer(({ isExpand, setIsExpand }: NavbarProps) => { const isCurrentPage = useIsCurrentPage(); const wasm = useWasmConfig({ shouldRedirect: false }); const move = useMoveConfig({ shouldRedirect: false }); - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); const { address } = useCurrentChain(); const navMenu: MenuInfo[] = isFullTier diff --git a/src/lib/layout/subheader/index.tsx b/src/lib/layout/subheader/index.tsx index a5afe60ae..1f8bb2b30 100644 --- a/src/lib/layout/subheader/index.tsx +++ b/src/lib/layout/subheader/index.tsx @@ -19,7 +19,7 @@ import { getSubHeaderFull, getSubHeaderLite } from "./utils"; const ACTIVE_COLOR = "primary.light"; const SubHeader = () => { - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); const govConfig = useGovConfig({ shouldRedirect: false }); const wasmConfig = useWasmConfig({ shouldRedirect: false }); const moveConfig = useMoveConfig({ shouldRedirect: false }); diff --git a/src/lib/model/contract.ts b/src/lib/model/contract.ts index ff4040896..ce469dede 100644 --- a/src/lib/model/contract.ts +++ b/src/lib/model/contract.ts @@ -17,7 +17,7 @@ interface InstantiatedByMeState { export const useInstantiatedByMe = (enable: boolean): InstantiatedByMeState => { const { address } = useCurrentChain(); - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); const resApi = useInstantiatedListByAddress(address, enable && isFullTier); const resLcd = useInstantiatedContractsByAddressLcd( @@ -46,7 +46,7 @@ export const useInstantiatedByMe = (enable: boolean): InstantiatedByMeState => { export const useInstantiatedMockInfoByMe = (): ContractListInfo => { const { address } = useCurrentChain(); - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); const resApi = useInstantiatedCountByAddress(address); const resLcd = useInstantiatedContractsByAddressLcd(address, !isFullTier); const count = isFullTier ? resApi.data : resLcd.data?.length ?? 0; diff --git a/src/lib/pages/account-details/components/tables/instantiated-contracts/index.tsx b/src/lib/pages/account-details/components/tables/instantiated-contracts/index.tsx index 61c4c1afe..35066a78d 100644 --- a/src/lib/pages/account-details/components/tables/instantiated-contracts/index.tsx +++ b/src/lib/pages/account-details/components/tables/instantiated-contracts/index.tsx @@ -1,19 +1,16 @@ import { observer } from "mobx-react-lite"; -import { useTierConfig } from "lib/app-provider"; +import { TierSwitcher } from "lib/components/TierSwitcher"; 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 ? ( - - ) : ( - - ); - } + (props: InstantiatedContractsTableProps) => ( + } + lite={} + /> + ) ); diff --git a/src/lib/pages/account-details/components/tables/txs/Lite.tsx b/src/lib/pages/account-details/components/tables/txs/Lite.tsx index e5d6ea16c..3b2ef17f4 100644 --- a/src/lib/pages/account-details/components/tables/txs/Lite.tsx +++ b/src/lib/pages/account-details/components/tables/txs/Lite.tsx @@ -22,7 +22,7 @@ export const TxsTableLite = ({ onViewMore, }: TxsTableProps) => { const isMobile = useMobile(); - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); const { pagesQuantity, diff --git a/src/lib/pages/account-details/components/tables/txs/index.tsx b/src/lib/pages/account-details/components/tables/txs/index.tsx index e22afece7..8d9b59f06 100644 --- a/src/lib/pages/account-details/components/tables/txs/index.tsx +++ b/src/lib/pages/account-details/components/tables/txs/index.tsx @@ -1,11 +1,12 @@ -import { useTierConfig } from "lib/app-provider"; +import { TierSwitcher } from "lib/components/TierSwitcher"; import { TxsTableFull } from "./Full"; import { TxsTableLite } from "./Lite"; import type { TxsTableProps } from "./types"; -export const TxsTable = (props: TxsTableProps) => { - const isFullTier = useTierConfig() === "full"; - - return isFullTier ? : ; -}; +export const TxsTable = (props: TxsTableProps) => ( + } + lite={} + /> +); diff --git a/src/lib/pages/account-details/data.ts b/src/lib/pages/account-details/data.ts index a73386438..f26bd841f 100644 --- a/src/lib/pages/account-details/data.ts +++ b/src/lib/pages/account-details/data.ts @@ -36,7 +36,7 @@ interface AccountDetailsTableCounts { export const useAccountDetailsTableCounts = ( address: BechAddr ): AccountDetailsTableCounts => { - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); const { data, refetch, diff --git a/src/lib/pages/account-details/index.tsx b/src/lib/pages/account-details/index.tsx index e463cfc5a..0bb028132 100644 --- a/src/lib/pages/account-details/index.tsx +++ b/src/lib/pages/account-details/index.tsx @@ -76,7 +76,7 @@ const AccountDetailsBody = ({ const navigate = useInternalNavigate(); const { address: accountAddress, hex: hexAddress } = formatAddresses(accountAddressParam); - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); // ------------------------------------------// // ------------------QUERIES-----------------// diff --git a/src/lib/pages/admin/index.tsx b/src/lib/pages/admin/index.tsx index a13f1ac53..9c2e534a0 100644 --- a/src/lib/pages/admin/index.tsx +++ b/src/lib/pages/admin/index.tsx @@ -10,7 +10,6 @@ import { useGetAddressType, useInternalNavigate, useSimulateFeeQuery, - useTierConfig, useUpdateAdminTx, useValidateAddress, useWasmConfig, @@ -23,6 +22,7 @@ import { EstimatedFeeRender } from "lib/components/EstimatedFeeRender"; import type { FormStatus } from "lib/components/forms"; import { TextInput } from "lib/components/forms"; import { CelatoneSeo } from "lib/components/Seo"; +import { TierSwitcher } from "lib/components/TierSwitcher"; import { UserDocsLink } from "lib/components/UserDocsLink"; import WasmPageContainer from "lib/components/WasmPageContainer"; import { useTxBroadcast } from "lib/hooks"; @@ -35,7 +35,6 @@ const UpdateAdmin = () => { useWasmConfig({ shouldRedirect: true }); const router = useRouter(); const { address } = useCurrentChain(); - const isFullTier = useTierConfig() === "full"; const { validateContractAddress, validateUserAddress } = useValidateAddress(); const getAddressType = useGetAddressType(); const navigate = useInternalNavigate(); @@ -189,20 +188,23 @@ const UpdateAdmin = () => { mb={6} subtitle="You need to connect your wallet to perform this action" /> - {isFullTier ? ( - onContractPathChange(contract)} - /> - ) : ( - - onContractPathChange(contract)} /> - - )} + } + lite={ + + onContractPathChange(contract)} + /> + + } + /> { const { currentChainId } = useCelatoneApp(); - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); return ( diff --git a/src/lib/pages/block-details/index.tsx b/src/lib/pages/block-details/index.tsx index 3aa3f7254..be441bd0c 100644 --- a/src/lib/pages/block-details/index.tsx +++ b/src/lib/pages/block-details/index.tsx @@ -2,9 +2,9 @@ import { useRouter } from "next/router"; import { useEffect } from "react"; import { AmpEvent, track } from "lib/amplitude"; -import { useTierConfig } from "lib/app-provider"; import PageContainer from "lib/components/PageContainer"; import { CelatoneSeo } from "lib/components/Seo"; +import { TierSwitcher } from "lib/components/TierSwitcher"; import { InvalidBlock } from "./components/InvalidBlock"; import { BlockDetailsFull } from "./full"; @@ -15,20 +15,15 @@ interface BlockDetailsBodyProps { height: number; } -const BlockDetailsBody = ({ height }: BlockDetailsBodyProps) => { - const isFullTier = useTierConfig() === "full"; - - return ( - <> - - {isFullTier ? ( - - ) : ( - - )} - - ); -}; +const BlockDetailsBody = ({ height }: BlockDetailsBodyProps) => ( + <> + + } + lite={} + /> + +); const BlockDetails = () => { const router = useRouter(); diff --git a/src/lib/pages/code-details/components/code-info/CodeInfoLabelText.tsx b/src/lib/pages/code-details/components/code-info/CodeInfoLabelText.tsx index 69d02871f..dc223c235 100644 --- a/src/lib/pages/code-details/components/code-info/CodeInfoLabelText.tsx +++ b/src/lib/pages/code-details/components/code-info/CodeInfoLabelText.tsx @@ -3,7 +3,7 @@ import type { LabelTextProps } from "lib/components/LabelText"; import { LabelText } from "lib/components/LabelText"; export const CodeInfoLabelText = (props: LabelTextProps) => { - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); return ( { - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); const { isOpen, onClose, onOpen } = useDisclosure(); const getAddressType = useGetAddressType(); diff --git a/src/lib/pages/code-details/components/code-info/CodeTopInfo.tsx b/src/lib/pages/code-details/components/code-info/CodeTopInfo.tsx index a7ccc42dd..053918a15 100644 --- a/src/lib/pages/code-details/components/code-info/CodeTopInfo.tsx +++ b/src/lib/pages/code-details/components/code-info/CodeTopInfo.tsx @@ -26,7 +26,7 @@ export const CodeTopInfo = ({ projectInfo, publicInfo, }: CodeTopInfoProps) => { - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); const { getCodeLocalInfo } = useCodeStore(); const localCodeInfo = getCodeLocalInfo(codeId); diff --git a/src/lib/pages/code-details/index.tsx b/src/lib/pages/code-details/index.tsx index 6bfcdb650..baea6b616 100644 --- a/src/lib/pages/code-details/index.tsx +++ b/src/lib/pages/code-details/index.tsx @@ -16,6 +16,7 @@ import { Loading } from "lib/components/Loading"; import PageContainer from "lib/components/PageContainer"; import { CelatoneSeo } from "lib/components/Seo"; import { ErrorFetching, InvalidState } from "lib/components/state"; +import { TierSwitcher } from "lib/components/TierSwitcher"; import { UserDocsLink } from "lib/components/UserDocsLink"; import { useSchemaStore } from "lib/providers/store"; import { useCodeData } from "lib/services/wasm/code"; @@ -41,7 +42,7 @@ const InvalidCode = () => ; const CodeDetailsBody = observer(({ codeId, tab }: CodeDetailsBodyProps) => { const isMobile = useMobile(); - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); const navigate = useInternalNavigate(); const { getSchemaByCodeHash } = useSchemaStore(); @@ -117,11 +118,11 @@ const CodeDetailsBody = observer(({ codeId, tab }: CodeDetailsBodyProps) => { attached={!!jsonSchema} toJsonSchemaTab={handleTabChange(TabIndex.JsonSchema)} /> - {isFullTier ? ( - - ) : ( - - )} + } + lite={} + /> + { useWasmConfig({ shouldRedirect: true }); - const tier = useTierConfig(); const router = useRouter(); useEffect(() => { @@ -28,7 +28,10 @@ const RecentCodes = observer(() => { subtitle="This page displays all codes on this network sorted by recency" docHref="introduction/overview#recent-codes" /> - {tier === "lite" ? : } + } + lite={} + /> ); }); diff --git a/src/lib/pages/contract-details/components/InstantiateInfo.tsx b/src/lib/pages/contract-details/components/InstantiateInfo.tsx index ae2031648..db40b4d7d 100644 --- a/src/lib/pages/contract-details/components/InstantiateInfo.tsx +++ b/src/lib/pages/contract-details/components/InstantiateInfo.tsx @@ -102,7 +102,7 @@ export const InstantiateInfo = ({ contractRest, codeLocalInfo, }: InstantiateInfoProps) => { - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); const getAddressType = useGetAddressType(); const { chain: { chain_id: chainId }, diff --git a/src/lib/pages/contract-details/components/tables/TxsTable.tsx b/src/lib/pages/contract-details/components/tables/TxsTable.tsx index ef6e514f7..99afde049 100644 --- a/src/lib/pages/contract-details/components/tables/TxsTable.tsx +++ b/src/lib/pages/contract-details/components/tables/TxsTable.tsx @@ -20,7 +20,7 @@ export const TxsTable = ({ totalData, refetchCount, }: TxsTableProps) => { - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); const { setTotalData, diff --git a/src/lib/pages/contract-details/components/tables/index.tsx b/src/lib/pages/contract-details/components/tables/index.tsx index a5286af75..2e0252cba 100644 --- a/src/lib/pages/contract-details/components/tables/index.tsx +++ b/src/lib/pages/contract-details/components/tables/index.tsx @@ -23,7 +23,7 @@ interface ContractTablesProps { const tableHeaderId = "contractDetailsTableHeader"; export const ContractTables = ({ contractAddress }: ContractTablesProps) => { - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); const gov = useGovConfig({ shouldRedirect: false }); const { data, refetch: refetchCount } = useContractTableCounts( diff --git a/src/lib/pages/contract-details/components/tables/migration/MigrationHeader.tsx b/src/lib/pages/contract-details/components/tables/migration/MigrationHeader.tsx index 51ff502d9..104124d39 100644 --- a/src/lib/pages/contract-details/components/tables/migration/MigrationHeader.tsx +++ b/src/lib/pages/contract-details/components/tables/migration/MigrationHeader.tsx @@ -9,7 +9,7 @@ export const MigrationHeader = ({ }: { templateColumns: GridProps["templateColumns"]; }) => { - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); return ( diff --git a/src/lib/pages/contract-details/components/tables/migration/MigrationMobileCard.tsx b/src/lib/pages/contract-details/components/tables/migration/MigrationMobileCard.tsx index df8851f09..c4afd397f 100644 --- a/src/lib/pages/contract-details/components/tables/migration/MigrationMobileCard.tsx +++ b/src/lib/pages/contract-details/components/tables/migration/MigrationMobileCard.tsx @@ -19,7 +19,7 @@ interface MigrationMobileCardProps { history: ContractMigrationHistory; } export const MigrationMobileCard = ({ history }: MigrationMobileCardProps) => { - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); const getAddressType = useGetAddressType(); const cw2Info = getCw2Info(history.cw2Contract, history.cw2Version); const navigate = useInternalNavigate(); diff --git a/src/lib/pages/contract-details/components/tables/migration/MigrationRow.tsx b/src/lib/pages/contract-details/components/tables/migration/MigrationRow.tsx index bf3fd1a8d..4b41dfc08 100644 --- a/src/lib/pages/contract-details/components/tables/migration/MigrationRow.tsx +++ b/src/lib/pages/contract-details/components/tables/migration/MigrationRow.tsx @@ -16,7 +16,7 @@ export const MigrationRow = ({ templateColumns, history, }: MigrationRowProps) => { - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); const getAddressType = useGetAddressType(); const cw2Info = getCw2Info(history.cw2Contract, history.cw2Version); diff --git a/src/lib/pages/contract-details/components/tables/migration/index.tsx b/src/lib/pages/contract-details/components/tables/migration/index.tsx index 4094ad7df..ea1c195f1 100644 --- a/src/lib/pages/contract-details/components/tables/migration/index.tsx +++ b/src/lib/pages/contract-details/components/tables/migration/index.tsx @@ -1,4 +1,4 @@ -import { useTierConfig } from "lib/app-provider"; +import { TierSwitcher } from "lib/components/TierSwitcher"; import type { BechAddr32, Option } from "lib/types"; import { MigrationTableFull } from "./MigrationTableFull"; @@ -16,17 +16,16 @@ export const MigrationTable = ({ scrollComponentId, totalData, refetchCount, -}: MigrationTableProps) => { - const isFullTier = useTierConfig() === "full"; - - return isFullTier ? ( - - ) : ( - - ); -}; +}: MigrationTableProps) => ( + + } + lite={} + /> +); diff --git a/src/lib/pages/contract-details/data.ts b/src/lib/pages/contract-details/data.ts index 90c2fe049..3b3afbeab 100644 --- a/src/lib/pages/contract-details/data.ts +++ b/src/lib/pages/contract-details/data.ts @@ -17,7 +17,7 @@ const useContractDataLcd = ( contractData: UseQueryResult, contractAddress: BechAddr32 ) => { - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); const { data: code } = useCodeLcd( Number(contractData.data?.contract.codeId), diff --git a/src/lib/pages/home/index.tsx b/src/lib/pages/home/index.tsx index 669ea710d..a47d4a358 100644 --- a/src/lib/pages/home/index.tsx +++ b/src/lib/pages/home/index.tsx @@ -2,20 +2,19 @@ import { useRouter } from "next/router"; import { useEffect } from "react"; import { AmpEvent, track } from "lib/amplitude"; -import { useTierConfig } from "lib/app-provider"; +import { TierSwitcher } from "lib/components/TierSwitcher"; import { HomeFull } from "./full"; import { HomeLite } from "./lite"; const Home = () => { const router = useRouter(); - const tier = useTierConfig({ minTier: "lite" }); useEffect(() => { if (router.isReady) track(AmpEvent.TO_OVERVIEW); }, [router.isReady]); - return tier === "lite" ? : ; + return } lite={} />; }; export default Home; diff --git a/src/lib/pages/instantiate/instantiate.tsx b/src/lib/pages/instantiate/instantiate.tsx index 367da650c..3ec76a2b6 100644 --- a/src/lib/pages/instantiate/instantiate.tsx +++ b/src/lib/pages/instantiate/instantiate.tsx @@ -99,7 +99,7 @@ const Instantiate = ({ onComplete }: InstantiatePageProps) => { const { validateUserAddress, validateContractAddress } = useValidateAddress(); const getAttachFunds = useAttachFunds(); const { getSchemaByCodeHash } = useSchemaStore(); - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); // ------------------------------------------// // ------------------STATES------------------// diff --git a/src/lib/pages/migrate/index.tsx b/src/lib/pages/migrate/index.tsx index b54f97b4c..68bc5aa47 100644 --- a/src/lib/pages/migrate/index.tsx +++ b/src/lib/pages/migrate/index.tsx @@ -7,7 +7,6 @@ import { trackToMigrate } from "lib/amplitude"; import { useCurrentChain, useInternalNavigate, - useTierConfig, useWasmConfig, } from "lib/app-provider"; import { ConnectWalletAlert } from "lib/components/ConnectWalletAlert"; @@ -18,6 +17,7 @@ import { FooterCTA } from "lib/components/layouts"; import { Loading } from "lib/components/Loading"; import { CelatoneSeo } from "lib/components/Seo"; import { Stepper } from "lib/components/stepper"; +import { TierSwitcher } from "lib/components/TierSwitcher"; import WasmPageContainer from "lib/components/WasmPageContainer"; import { useUploadCode } from "lib/hooks"; import { useUploadAccessParamsLcd } from "lib/services/wasm/code"; @@ -41,7 +41,6 @@ const Migrate = () => { useWasmConfig({ shouldRedirect: true }); const router = useRouter(); const navigate = useInternalNavigate(); - const isFullTier = useTierConfig() === "full"; const { data: uploadAccessParams, isFetching } = useUploadAccessParamsLcd(); const { proceed, @@ -185,18 +184,21 @@ const Migrate = () => { subtitle="You need to connect your wallet to perform this action" /> {/* Select Migrate Contract modal */} - {isFullTier ? ( - - ) : ( - - )} + + } + lite={ + + } + /> {renderBody()} diff --git a/src/lib/pages/module-details/components/ModuleActions.tsx b/src/lib/pages/module-details/components/ModuleActions.tsx index a9297227e..c3ee7062b 100644 --- a/src/lib/pages/module-details/components/ModuleActions.tsx +++ b/src/lib/pages/module-details/components/ModuleActions.tsx @@ -32,7 +32,7 @@ export const ModuleActions = ({ allTxsCount, onSelectAction, }: ModuleActionsProps) => { - const isFulTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); const actionList: ActionInfo[] = [ { @@ -61,7 +61,7 @@ export const ModuleActions = ({ count: allTxsCount, onClick: () => onSelectAction(TabIndex.TxsHistories), disabled: allTxsCount === 0, - hidden: !isFulTier, + hidden: !isFullTier, }, ]; diff --git a/src/lib/pages/module-details/components/ModuleInfoBody.tsx b/src/lib/pages/module-details/components/ModuleInfoBody.tsx index 242e1d3ae..4814cf51c 100644 --- a/src/lib/pages/module-details/components/ModuleInfoBody.tsx +++ b/src/lib/pages/module-details/components/ModuleInfoBody.tsx @@ -48,7 +48,7 @@ export const ModuleInfoBody = ({ indexedModule, modulePublishInfo, }: Omit) => { - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); const { address, upgradePolicy } = indexedModule; return ( diff --git a/src/lib/pages/module-details/index.tsx b/src/lib/pages/module-details/index.tsx index 99c7b78ff..e18716c55 100644 --- a/src/lib/pages/module-details/index.tsx +++ b/src/lib/pages/module-details/index.tsx @@ -47,7 +47,7 @@ const ModuleDetailsBody = ({ const formatAddresses = useFormatAddresses(); const { hex: vmAddress } = formatAddresses(address); - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); const currentTab = !isFullTier && tab === TabIndex.TxsHistories ? TabIndex.Overview : tab; diff --git a/src/lib/pages/past-txs/index.tsx b/src/lib/pages/past-txs/index.tsx index 026f584f2..9c366a582 100644 --- a/src/lib/pages/past-txs/index.tsx +++ b/src/lib/pages/past-txs/index.tsx @@ -2,20 +2,19 @@ import { useRouter } from "next/router"; import { useEffect } from "react"; import { AmpEvent, track } from "lib/amplitude"; -import { useTierConfig } from "lib/app-provider"; +import { TierSwitcher } from "lib/components/TierSwitcher"; import { PastTxsFull } from "./full"; import { PastTxsLite } from "./lite"; const PastTxs = () => { const router = useRouter(); - const isFullTier = useTierConfig() === "full"; useEffect(() => { if (router.isReady) track(AmpEvent.TO_PAST_TXS); }, [router.isReady]); - return isFullTier ? : ; + return } lite={} />; }; export default PastTxs; diff --git a/src/lib/pages/proposal-details/components/proposal-top/index.tsx b/src/lib/pages/proposal-details/components/proposal-top/index.tsx index 3755e61a1..e7ecf5470 100644 --- a/src/lib/pages/proposal-details/components/proposal-top/index.tsx +++ b/src/lib/pages/proposal-details/components/proposal-top/index.tsx @@ -18,7 +18,7 @@ interface ProposalTopProps { } export const ProposalTop = ({ proposalData }: ProposalTopProps) => { - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); const isMobile = useMobile(); const isDepositOrVoting = diff --git a/src/lib/pages/proposal-details/components/vote-details/deposit-period/DepositPeriodSection.tsx b/src/lib/pages/proposal-details/components/vote-details/deposit-period/DepositPeriodSection.tsx index 3abaefa5d..a62fffad7 100644 --- a/src/lib/pages/proposal-details/components/vote-details/deposit-period/DepositPeriodSection.tsx +++ b/src/lib/pages/proposal-details/components/vote-details/deposit-period/DepositPeriodSection.tsx @@ -19,7 +19,7 @@ export const DepositPeriodSection = ({ isLoading, isDepositsLoading, }: ProposalOverviewProps) => { - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); const isMobile = useMobile(); if (isLoading) return ; diff --git a/src/lib/pages/proposal-details/components/vote-details/voting-period/index.tsx b/src/lib/pages/proposal-details/components/vote-details/voting-period/index.tsx index ca3c00776..914698bea 100644 --- a/src/lib/pages/proposal-details/components/vote-details/voting-period/index.tsx +++ b/src/lib/pages/proposal-details/components/vote-details/voting-period/index.tsx @@ -53,7 +53,7 @@ const scrollComponentId = "voting-period"; export const VotingPeriod = ({ proposalData, ...props }: VoteDetailsProps) => { const isMobile = useMobile(); - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); const gov = useGovConfig({ shouldRedirect: false }); const disableVotingPeriodTally = gov.enabled && gov.disableVotingPeriodTally; diff --git a/src/lib/pages/proposal-details/data.ts b/src/lib/pages/proposal-details/data.ts index 7c23a9bcf..407e75cf6 100644 --- a/src/lib/pages/proposal-details/data.ts +++ b/src/lib/pages/proposal-details/data.ts @@ -27,7 +27,7 @@ interface DerivedProposalDataResponse { export const useDerivedProposalData = ( id: number ): DerivedProposalDataResponse => { - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); const { data: dataApi, isLoading: isApiLoading } = useProposalData( id, isFullTier diff --git a/src/lib/pages/proposals/components/ProposalStatusFilter.tsx b/src/lib/pages/proposals/components/ProposalStatusFilter.tsx index 4eddecb93..8a7069ffc 100644 --- a/src/lib/pages/proposals/components/ProposalStatusFilter.tsx +++ b/src/lib/pages/proposals/components/ProposalStatusFilter.tsx @@ -43,7 +43,7 @@ export const ProposalStatusFilter = forwardRef< const [isDropdown, setIsDropdown] = useState(false); const inputRef = useRef(null); const boxRef = useRef(null); - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); const OPTIONS = isFullTier ? Object.values(ProposalStatus) diff --git a/src/lib/pages/proposals/index.tsx b/src/lib/pages/proposals/index.tsx index 793be3b82..ef81503ff 100644 --- a/src/lib/pages/proposals/index.tsx +++ b/src/lib/pages/proposals/index.tsx @@ -1,9 +1,10 @@ import { Flex, Heading } from "@chakra-ui/react"; -import { useGovConfig, useMobile, useTierConfig } from "lib/app-provider"; +import { useGovConfig, useMobile } from "lib/app-provider"; import { NewProposalButton } from "lib/components/button/NewProposalButton"; import PageContainer from "lib/components/PageContainer"; import { CelatoneSeo } from "lib/components/Seo"; +import { TierSwitcher } from "lib/components/TierSwitcher"; import { UserDocsLink } from "lib/components/UserDocsLink"; import { ProposalsTableFull } from "./components/ProposalsTableFull"; @@ -12,7 +13,6 @@ import { ProposalsTableLite } from "./components/ProposalsTableLite"; const Proposals = () => { useGovConfig({ shouldRedirect: true }); const isMobile = useMobile(); - const isFullTier = useTierConfig() === "full"; return ( @@ -29,7 +29,10 @@ const Proposals = () => { {!isMobile && } - {isFullTier ? : } + } + lite={} + /> ); }; diff --git a/src/lib/pages/validator-details/components/validator-overview/VotingPowerOverview.tsx b/src/lib/pages/validator-details/components/validator-overview/VotingPowerOverview.tsx index 478e0ef41..abbdfa413 100644 --- a/src/lib/pages/validator-details/components/validator-overview/VotingPowerOverview.tsx +++ b/src/lib/pages/validator-details/components/validator-overview/VotingPowerOverview.tsx @@ -96,7 +96,7 @@ export const VotingPowerOverview = ({ totalVotingPower, selfVotingPower, }: VotingPowerOverviewProps) => { - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); const isMobile = useMobile(); const assetInfo = singleStakingDenom ? assetInfos?.[singleStakingDenom] diff --git a/src/lib/pages/validator-details/components/validator-overview/index.tsx b/src/lib/pages/validator-details/components/validator-overview/index.tsx index b056f1abb..c68aea3e8 100644 --- a/src/lib/pages/validator-details/components/validator-overview/index.tsx +++ b/src/lib/pages/validator-details/components/validator-overview/index.tsx @@ -42,7 +42,7 @@ export const ValidatorOverview = ({ totalVotingPower, selfVotingPower, }: ValidatorOverviewProps) => { - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); const isMobile = useMobile(); return ( diff --git a/src/lib/pages/validator-details/index.tsx b/src/lib/pages/validator-details/index.tsx index 9a142030e..7fa883fe0 100644 --- a/src/lib/pages/validator-details/index.tsx +++ b/src/lib/pages/validator-details/index.tsx @@ -2,8 +2,9 @@ import { useRouter } from "next/router"; import { useEffect } from "react"; import { AmpEvent, track } from "lib/amplitude"; -import { useGovConfig, useTierConfig } from "lib/app-provider"; +import { useGovConfig } from "lib/app-provider"; import { InvalidState } from "lib/components/state"; +import { TierSwitcher } from "lib/components/TierSwitcher"; import { ValidatorDetailsBodyFull, @@ -14,7 +15,6 @@ import { zValidatorDetailsQueryParams } from "./types"; const ValidatorDetails = () => { const router = useRouter(); useGovConfig({ shouldRedirect: true }); - const isFullTier = useTierConfig() === "full"; const validated = zValidatorDetailsQueryParams.safeParse(router.query); @@ -29,13 +29,10 @@ const ValidatorDetails = () => { {!validated.success ? ( ) : ( - <> - {isFullTier ? ( - - ) : ( - - )} - + } + lite={} + /> )} ); diff --git a/src/lib/pages/validators/index.tsx b/src/lib/pages/validators/index.tsx index 8516e9f54..13a8df7e2 100644 --- a/src/lib/pages/validators/index.tsx +++ b/src/lib/pages/validators/index.tsx @@ -9,6 +9,7 @@ import PageContainer from "lib/components/PageContainer"; import { PageHeader } from "lib/components/PageHeader"; import PageHeaderContainer from "lib/components/PageHeaderContainer"; import { CelatoneSeo } from "lib/components/Seo"; +import { TierSwitcher } from "lib/components/TierSwitcher"; import { useDebounce } from "lib/hooks"; import { @@ -25,7 +26,7 @@ const SCROLL_COMPONENT_ID = "validator-table-header"; const Validators = () => { const router = useRouter(); const isMobile = useMobile(); - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); useGovConfig({ shouldRedirect: true }); const [isActive, setIsActive] = useState(true); @@ -86,29 +87,32 @@ const Validators = () => { - {isFullTier ? ( - - ) : ( - - )} + + } + lite={ + + } + /> ); diff --git a/src/lib/services/account/index.ts b/src/lib/services/account/index.ts index 8909e3f83..9ee98612f 100644 --- a/src/lib/services/account/index.ts +++ b/src/lib/services/account/index.ts @@ -19,7 +19,7 @@ import { getAccountDataLcd, getAccountTypeLcd } from "./lcd"; export const useAccountData = ( address: BechAddr ): UseQueryResult => { - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); const apiEndpoint = useBaseApiRoute("accounts"); const lcdEndpoint = useLcdEndpoint(); const endpoint = isFullTier ? apiEndpoint : lcdEndpoint; diff --git a/src/lib/services/bank/index.ts b/src/lib/services/bank/index.ts index 78bf916e9..fff6a0cb7 100644 --- a/src/lib/services/bank/index.ts +++ b/src/lib/services/bank/index.ts @@ -25,7 +25,7 @@ import { getBalances } from "./api"; import { getBalancesLcd } from "./lcd"; export const useBalances = (address: BechAddr): UseQueryResult => { - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); const apiEndpoint = useBaseApiRoute("accounts"); const lcdEndpoint = useLcdEndpoint(); const endpoint = isFullTier ? apiEndpoint : lcdEndpoint; diff --git a/src/lib/services/move/module/index.ts b/src/lib/services/move/module/index.ts index c056b5a41..ec2e967e5 100644 --- a/src/lib/services/move/module/index.ts +++ b/src/lib/services/move/module/index.ts @@ -83,7 +83,7 @@ export const useModulesByAddress = ({ onSuccess?: (data: AccountModulesResponse) => void; onError?: (err: AxiosError) => void; }) => { - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); const apiEndpoint = useBaseApiRoute("accounts"); const lcdEndpoint = useLcdEndpoint(); const endpoint = isFullTier ? apiEndpoint : lcdEndpoint; diff --git a/src/lib/services/proposal/index.ts b/src/lib/services/proposal/index.ts index f44da51a5..bc2b58af2 100644 --- a/src/lib/services/proposal/index.ts +++ b/src/lib/services/proposal/index.ts @@ -52,14 +52,13 @@ import { } from "./lcd"; export const useProposalParams = () => { - const tier = useTierConfig(); + const { isFullTier } = useTierConfig(); const apiEndpoint = useBaseApiRoute("proposals"); const lcdEndpoint = useLcdEndpoint(); - const [endpoint, queryFn] = - tier === "full" - ? [apiEndpoint, getProposalParams] - : [lcdEndpoint, getProposalParamsLcd]; + const [endpoint, queryFn] = isFullTier + ? [apiEndpoint, getProposalParams] + : [lcdEndpoint, getProposalParamsLcd]; return useQuery>( [CELATONE_QUERY_KEYS.PROPOSAL_PARAMS, endpoint], @@ -223,14 +222,13 @@ export const useProposalDepositsLcd = (id: number, enabled = true) => { }; export const useProposalVotesInfo = (id: number, enabled: boolean) => { - const tier = useTierConfig(); + const { isFullTier } = useTierConfig(); const apiEndpoint = useBaseApiRoute("proposals"); const lcdEndpoint = useLcdEndpoint(); - const [endpoint, queryFn] = - tier === "full" - ? [apiEndpoint, getProposalVotesInfo] - : [lcdEndpoint, getProposalVotesInfoLcd]; + const [endpoint, queryFn] = isFullTier + ? [apiEndpoint, getProposalVotesInfo] + : [lcdEndpoint, getProposalVotesInfoLcd]; return useQuery( [CELATONE_QUERY_KEYS.PROPOSAL_VOTES_INFO, endpoint, id], diff --git a/src/lib/services/searchService.ts b/src/lib/services/searchService.ts index f9f1af23e..954e41e31 100644 --- a/src/lib/services/searchService.ts +++ b/src/lib/services/searchService.ts @@ -68,7 +68,7 @@ export const useSearchHandler = ( resetHandlerStates: () => void // eslint-disable-next-line sonarjs/cognitive-complexity ): SearchHandlerResponse => { - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); const [debouncedKeyword, setDebouncedKeyword] = useState(keyword); const { chainConfig: { diff --git a/src/lib/services/tx/index.ts b/src/lib/services/tx/index.ts index 678b68802..e2b4f4f96 100644 --- a/src/lib/services/tx/index.ts +++ b/src/lib/services/tx/index.ts @@ -55,7 +55,7 @@ export const useTxData = ( enabled = true ): UseQueryResult => { const { currentChainId } = useCelatoneApp(); - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); const apiEndpoint = useBaseApiRoute("txs"); const lcdEndpoint = useLcdEndpoint(); diff --git a/src/lib/services/validator/index.ts b/src/lib/services/validator/index.ts index 546636d37..39567509f 100644 --- a/src/lib/services/validator/index.ts +++ b/src/lib/services/validator/index.ts @@ -156,7 +156,7 @@ export const useValidatorDataLcd = ( }; export const useValidatorStakingProvisions = (enabled: boolean) => { - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); const apiEndpoint = useBaseApiRoute("validators"); const lcdEndpoint = useLcdEndpoint(); const endpoint = isFullTier ? apiEndpoint : lcdEndpoint; diff --git a/src/lib/services/wasm/contract/index.ts b/src/lib/services/wasm/contract/index.ts index 41fb29221..bfeb9d5fc 100644 --- a/src/lib/services/wasm/contract/index.ts +++ b/src/lib/services/wasm/contract/index.ts @@ -143,7 +143,7 @@ export const useContractData = ( contractAddress: BechAddr32, options?: UseQueryOptions ) => { - const isFullTier = useTierConfig() === "full"; + const { isFullTier } = useTierConfig(); const apiEndpoint = useBaseApiRoute("contracts"); const lcdEndpoint = useLcdEndpoint(); const endpoint = isFullTier ? apiEndpoint : lcdEndpoint; From da194ba43f180528234c4d679dac488213ce09f6 Mon Sep 17 00:00:00 2001 From: evilpeach Date: Wed, 3 Jul 2024 17:38:52 +0700 Subject: [PATCH 06/16] docs: fix changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87eaa7e7b..9fea0a467 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,7 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Features -- [#993](https://github.com/alleslabs/celatone-frontend/pull/993) Add Sequencer, Mesa tier and TierSwitcher component +- [#994](https://github.com/alleslabs/celatone-frontend/pull/994) Add Sequencer, Mesa tier and TierSwitcher component ### Improvements From 91076a0df1d34ffc6efdc4e14357be73a970e41d Mon Sep 17 00:00:00 2001 From: evilpeach Date: Fri, 5 Jul 2024 10:17:51 +0700 Subject: [PATCH 07/16] fix: remove id from module verification --- src/lib/services/types/move/module.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lib/services/types/move/module.ts b/src/lib/services/types/move/module.ts index e06bf8f85..a754f088c 100644 --- a/src/lib/services/types/move/module.ts +++ b/src/lib/services/types/move/module.ts @@ -49,7 +49,6 @@ export type AccountModulesResponse = z.infer; export const zModuleVerificationInternal = z .object({ - id: z.number(), module_address: zHexAddr, module_name: z.string(), verified_at: z.string(), From f47f0d45332c695f2a348dbaef838f81a6046621 Mon Sep 17 00:00:00 2001 From: evilpeach Date: Sat, 6 Jul 2024 10:09:39 +0700 Subject: [PATCH 08/16] feat: support both new, old db schema --- CHANGELOG.md | 1 + src/lib/query/collection.ts | 12 +- src/lib/query/collectionOld.ts | 32 +- src/lib/query/nft.ts | 4 +- src/lib/query/nftOld.ts | 24 +- src/lib/services/expression/nftExpression.ts | 106 +++--- .../services/expression/nftExpressionOld.ts | 111 +++--- src/lib/services/nft/collection.ts | 347 ++++++++++++++---- src/lib/services/nft/collectionService.ts | 174 ++------- src/lib/services/nft/nft.ts | 275 ++++++++++---- src/lib/services/nft/nftService.ts | 127 +------ 11 files changed, 661 insertions(+), 552 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fea0a467..909237246 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 +- [#1008](https://github.com/alleslabs/celatone-frontend/pull/1008) Support both new, old DB schema for NFTs - [#994](https://github.com/alleslabs/celatone-frontend/pull/994) Add Sequencer, Mesa tier and TierSwitcher component ### Improvements diff --git a/src/lib/query/collection.ts b/src/lib/query/collection.ts index 85525d276..e027550be 100644 --- a/src/lib/query/collection.ts +++ b/src/lib/query/collection.ts @@ -3,11 +3,11 @@ import { gql } from "graphql-request"; export const getCollectionsQuery = gql` query getCollectionsQuery( $offset: Int! - $pageSize: Int! + $limit: Int! $expression: collections_bool_exp! ) { collections( - limit: $pageSize + limit: $limit offset: $offset where: $expression order_by: { name: asc } @@ -107,10 +107,10 @@ export const getCollectionActivitiesQuery = gql` query getCollectionActivitiesQuery( $expression: collection_transactions_bool_exp $offset: Int! - $pageSize: Int! + $limit: Int! ) { collection_transactions( - limit: $pageSize + limit: $limit offset: $offset where: $expression order_by: [ @@ -144,10 +144,10 @@ export const getCollectionMutateEventsQuery = gql` query getCollectionMutateEventsQuery( $collectionAddress: String! $offset: Int! - $pageSize: Int! + $limit: Int! ) { collection_mutation_events( - limit: $pageSize + limit: $limit offset: $offset where: { collection_id: { _eq: $collectionAddress } } order_by: { block_height: desc } diff --git a/src/lib/query/collectionOld.ts b/src/lib/query/collectionOld.ts index d2c7dccbf..f19aa18cf 100644 --- a/src/lib/query/collectionOld.ts +++ b/src/lib/query/collectionOld.ts @@ -1,13 +1,13 @@ import { gql } from "graphql-request"; export const getCollectionsQueryOld = gql` - query getCollectionsQuery( + query getCollectionsQueryOld( $offset: Int! - $pageSize: Int! + $limit: Int! $expression: collections_bool_exp! ) { collections( - limit: $pageSize + limit: $limit offset: $offset where: $expression order_by: { name: asc } @@ -31,7 +31,7 @@ export const getCollectionsQueryOld = gql` `; export const getCollectionByCollectionAddressQueryOld = gql` - query getCollectionByCollectionAddressQuery($vmAddress: String!) { + query getCollectionByCollectionAddressQueryOld($vmAddress: String!) { collections(where: { vm_address: { vm_address: { _eq: $vmAddress } } }) { name uri @@ -50,7 +50,7 @@ export const getCollectionByCollectionAddressQueryOld = gql` `; export const getCollectionTotalBurnedCountQueryOld = gql` - query getCollectionTotalBurnedCountQuery($vmAddress: String!) { + query getCollectionTotalBurnedCountQueryOld($vmAddress: String!) { nfts_aggregate( where: { collectionByCollection: { @@ -67,7 +67,7 @@ export const getCollectionTotalBurnedCountQueryOld = gql` `; export const getCollectionCreatorQueryOld = gql` - query getCollectionCreatorQuery($vmAddress: String!) { + query getCollectionCreatorQueryOld($vmAddress: String!) { collections(where: { vm_address: { vm_address: { _eq: $vmAddress } } }) { vmAddressByCreator { vm_address @@ -89,7 +89,7 @@ export const getCollectionCreatorQueryOld = gql` `; export const getCollectionActivitiesCountQueryOld = gql` - query getCollectionActivitiesCountQuery($vmAddress: String!) { + query getCollectionActivitiesCountQueryOld($vmAddress: String!) { collection_transactions_aggregate( where: { collection: { vm_address: { vm_address: { _eq: $vmAddress } } } } ) { @@ -101,7 +101,7 @@ export const getCollectionActivitiesCountQueryOld = gql` `; export const getCollectionMutateEventsCountQueryOld = gql` - query getCollectionMutateEventsCountQuery($vmAddress: String!) { + query getCollectionMutateEventsCountQueryOld($vmAddress: String!) { collection_mutation_events_aggregate( where: { collection: { vm_address: { vm_address: { _eq: $vmAddress } } } } ) { @@ -113,7 +113,7 @@ export const getCollectionMutateEventsCountQueryOld = gql` `; export const getCollectionUniqueHoldersCountQueryOld = gql` - query getCollectionUniqueHoldersCountQuery($vmAddress: String!) { + query getCollectionUniqueHoldersCountQueryOld($vmAddress: String!) { nfts_aggregate( where: { collectionByCollection: { @@ -130,13 +130,13 @@ export const getCollectionUniqueHoldersCountQueryOld = gql` `; export const getCollectionActivitiesQueryOld = gql` - query getCollectionActivitiesQuery( + query getCollectionActivitiesQueryOld( $expression: collection_transactions_bool_exp $offset: Int! - $pageSize: Int! + $limit: Int! ) { collection_transactions( - limit: $pageSize + limit: $limit offset: $offset where: $expression order_by: [ @@ -169,13 +169,13 @@ export const getCollectionActivitiesQueryOld = gql` `; export const getCollectionMutateEventsQueryOld = gql` - query getCollectionMutateEventsQuery( + query getCollectionMutateEventsQueryOld( $collectionAddress: String! $offset: Int! - $pageSize: Int! + $limit: Int! ) { collection_mutation_events( - limit: $pageSize + limit: $limit offset: $offset where: { collection: { vm_address: { vm_address: { _eq: $collectionAddress } } } @@ -194,7 +194,7 @@ export const getCollectionMutateEventsQueryOld = gql` `; export const getCollectionsByAccountQueryOld = gql` - query getCollectionsByAccountQuery($accountAddress: String!) { + query getCollectionsByAccountQueryOld($accountAddress: String!) { collections( where: { nfts: { vmAddressByOwner: { vm_address: { _eq: $accountAddress } } } diff --git a/src/lib/query/nft.ts b/src/lib/query/nft.ts index 9d607537b..7f8fa977c 100644 --- a/src/lib/query/nft.ts +++ b/src/lib/query/nft.ts @@ -141,12 +141,12 @@ export const getNftMutateEventsCountQuery = gql` export const getNftsByAccountQuery = gql` query getNftsByAccountQuery( - $pageSize: Int! + $limit: Int! $offset: Int! $expression: nfts_bool_exp! ) { nfts( - limit: $pageSize + limit: $limit offset: $offset order_by: { token_id: asc } where: $expression diff --git a/src/lib/query/nftOld.ts b/src/lib/query/nftOld.ts index bc54d7b1d..08cef4b08 100644 --- a/src/lib/query/nftOld.ts +++ b/src/lib/query/nftOld.ts @@ -1,7 +1,7 @@ import { gql } from "graphql-request"; export const getNftQueryOld = gql` - query getNftQuery($collectionAddress: String!, $nftAddress: String!) { + query getNftQueryOld($collectionAddress: String!, $nftAddress: String!) { nfts( where: { collectionByCollection: { @@ -28,7 +28,11 @@ export const getNftQueryOld = gql` `; export const getNftsQueryOld = gql` - query getNftsQuery($limit: Int!, $offset: Int!, $expression: nfts_bool_exp!) { + query getNftsQueryOld( + $limit: Int! + $offset: Int! + $expression: nfts_bool_exp! + ) { nfts( limit: $limit offset: $offset @@ -56,7 +60,7 @@ export const getNftsQueryOld = gql` `; export const getNftTransactionsCountQueryOld = gql` - query getNftTransactionsCountQuery($nftAddress: String!) { + query getNftTransactionsCountQueryOld($nftAddress: String!) { nft_transactions_aggregate( where: { nft: { vm_address: { vm_address: { _eq: $nftAddress } } } } ) { @@ -68,7 +72,7 @@ export const getNftTransactionsCountQueryOld = gql` `; export const getNftTransactionsQueryOld = gql` - query getNftTransactionsQuery( + query getNftTransactionsQueryOld( $limit: Int! $offset: Int! $nftAddress: String! @@ -101,7 +105,7 @@ export const getNftTransactionsQueryOld = gql` `; export const getNftMutateEventsQueryOld = gql` - query getNftMutateEventsQuery( + query getNftMutateEventsQueryOld( $limit: Int! $offset: Int! $nftAddress: String! @@ -124,7 +128,7 @@ export const getNftMutateEventsQueryOld = gql` `; export const getNftMutateEventsCountQueryOld = gql` - query getNftMutateEventsCountQuery($nftAddress: String!) { + query getNftMutateEventsCountQueryOld($nftAddress: String!) { nft_mutation_events_aggregate( where: { nft: { vm_address: { vm_address: { _eq: $nftAddress } } } } ) { @@ -136,13 +140,13 @@ export const getNftMutateEventsCountQueryOld = gql` `; export const getNftsByAccountQueryOld = gql` - query getNftsByAccountQuery( - $pageSize: Int! + query getNftsByAccountQueryOld( + $limit: Int! $offset: Int! $expression: nfts_bool_exp! ) { nfts( - limit: $pageSize + limit: $limit offset: $offset order_by: { token_id: asc } where: $expression @@ -172,7 +176,7 @@ export const getNftsByAccountQueryOld = gql` `; export const getNftsCountByAccountQueryOld = gql` - query getNftsCountByAccountQuery($accountAddress: String!) { + query getNftsCountByAccountQueryOld($accountAddress: String!) { nfts_aggregate( where: { vmAddressByOwner: { vm_address: { _eq: $accountAddress } } diff --git a/src/lib/services/expression/nftExpression.ts b/src/lib/services/expression/nftExpression.ts index ad7d770c2..b0b513c7e 100644 --- a/src/lib/services/expression/nftExpression.ts +++ b/src/lib/services/expression/nftExpression.ts @@ -1,21 +1,15 @@ -import { useMemo } from "react"; - import type { HexAddr, HexAddr32 } from "lib/types"; import { isHexModuleAddress, isTxHash } from "lib/utils"; -export const useCollectionsExpression = (search = "") => - useMemo(() => { - if (search.trim().length === 0) return {}; +export const getCollectionsExpression = (search = "") => { + if (search.trim().length === 0) return {}; - return { - _or: [ - { name: { _iregex: search } }, - { id: { _eq: search.toLowerCase() } }, - ], - }; - }, [search]); + return { + _or: [{ name: { _iregex: search } }, { id: { _eq: search.toLowerCase() } }], + }; +}; -export const useCollectionActivitiesExpression = ( +export const getCollectionActivitiesExpression = ( collectionAddress: HexAddr32, search = "" ) => { @@ -35,56 +29,54 @@ export const useCollectionActivitiesExpression = ( const searchOption = isHash ? txHashSearch : tokenIdSearch; - return useMemo( - () => ({ - collection_id: { _eq: collectionAddress }, - ...(search ? { _and: searchOption } : {}), - }), - [collectionAddress, search, searchOption] - ); + return { + collection_id: { _eq: collectionAddress }, + ...(search ? { _and: searchOption } : {}), + }; }; -export const useNftsExpression = (collectionAddress: HexAddr32, search = "") => - useMemo(() => { - const orExpression = { - _or: [ - { token_id: { _iregex: search } }, - ...(isHexModuleAddress(search) - ? [{ id: { _eq: search.toLowerCase() } }] - : []), - ], - }; +export const getNftsExpression = ( + collectionAddress: HexAddr32, + search = "" +) => { + const orExpression = { + _or: [ + { token_id: { _iregex: search } }, + ...(isHexModuleAddress(search) + ? [{ id: { _eq: search.toLowerCase() } }] + : []), + ], + }; - return { - collection: { _eq: collectionAddress }, - is_burned: { _eq: false }, - ...(search.trim().length > 0 ? orExpression : {}), - }; - }, [collectionAddress, search]); + return { + collection: { _eq: collectionAddress }, + is_burned: { _eq: false }, + ...(search.trim().length > 0 ? orExpression : {}), + }; +}; -export const useNftsByAccountExpression = ( +export const getNftsByAccountExpression = ( accountAddress: HexAddr, collectionAddress?: HexAddr32, search = "" -) => - useMemo(() => { - const orExpression = { - _or: [ - { token_id: { _iregex: search } }, - ...(isHexModuleAddress(search) - ? [{ id: { _eq: search.toLowerCase() } }] - : []), - ], - }; +) => { + const orExpression = { + _or: [ + { token_id: { _iregex: search } }, + ...(isHexModuleAddress(search) + ? [{ id: { _eq: search.toLowerCase() } }] + : []), + ], + }; - const collectionExpression = { - collection: { _eq: collectionAddress?.toLowerCase() }, - }; + const collectionExpression = { + collection: { _eq: collectionAddress?.toLowerCase() }, + }; - return { - owner: { _eq: accountAddress }, - is_burned: { _eq: false }, - ...(collectionAddress ? collectionExpression : {}), - ...(search.trim().length > 0 ? orExpression : {}), - }; - }, [accountAddress, collectionAddress, search]); + return { + owner: { _eq: accountAddress }, + is_burned: { _eq: false }, + ...(collectionAddress ? collectionExpression : {}), + ...(search.trim().length > 0 ? orExpression : {}), + }; +}; diff --git a/src/lib/services/expression/nftExpressionOld.ts b/src/lib/services/expression/nftExpressionOld.ts index 237961220..f51e6a757 100644 --- a/src/lib/services/expression/nftExpressionOld.ts +++ b/src/lib/services/expression/nftExpressionOld.ts @@ -1,21 +1,18 @@ -import { useMemo } from "react"; - import type { HexAddr, HexAddr32 } from "lib/types"; import { isHexModuleAddress, isTxHash } from "lib/utils"; -export const useCollectionsExpressionOld = (search = "") => - useMemo(() => { - if (search.trim().length === 0) return {}; +export const getCollectionsExpressionOld = (search = "") => { + if (search.trim().length === 0) return {}; - return { - _or: [ - { name: { _iregex: search } }, - { vm_address: { vm_address: { _eq: search.toLowerCase() } } }, - ], - }; - }, [search]); + return { + _or: [ + { name: { _iregex: search } }, + { vm_address: { vm_address: { _eq: search.toLowerCase() } } }, + ], + }; +}; -export const useCollectionActivitiesExpressionOld = ( +export const getCollectionActivitiesExpressionOld = ( collectionAddress: HexAddr32, search = "" ) => { @@ -37,62 +34,60 @@ export const useCollectionActivitiesExpressionOld = ( const searchOption = isHash ? txHashSearch : tokenIdSearch; - return useMemo( - () => ({ - collection: { vm_address: { vm_address: { _eq: collectionAddress } } }, - ...(search ? { _and: searchOption } : {}), - }), - [collectionAddress, search, searchOption] - ); + return { + collection: { vm_address: { vm_address: { _eq: collectionAddress } } }, + ...(search ? { _and: searchOption } : {}), + }; }; -export const useNftsExpressionOld = ( +export const getNftsExpressionOld = ( collectionAddress: HexAddr32, search = "" -) => - useMemo(() => { - const orExpression = { - _or: [ - { token_id: { _iregex: search } }, - ...(isHexModuleAddress(search) - ? [{ vm_address: { vm_address: { _eq: search.toLowerCase() } } }] - : []), - ], - }; +) => { + const orExpression = { + _or: [ + { token_id: { _iregex: search } }, + ...(isHexModuleAddress(search) + ? [{ vm_address: { vm_address: { _eq: search.toLowerCase() } } }] + : []), + ], + }; - return { - collectionByCollection: { - vm_address: { vm_address: { _eq: collectionAddress } }, - }, - is_burned: { _eq: false }, - ...(search.trim().length > 0 ? orExpression : {}), - }; - }, [collectionAddress, search]); + return { + collectionByCollection: { + vm_address: { vm_address: { _eq: collectionAddress } }, + }, + is_burned: { _eq: false }, + ...(search.trim().length > 0 ? orExpression : {}), + }; +}; -export const useNftsByAccountExpressionOld = ( +export const getNftsByAccountExpressionOld = ( accountAddress: HexAddr, collectionAddress?: HexAddr32, search = "" -) => - useMemo(() => { - const orExpression = { - _or: [{ token_id: { _iregex: search } }], - }; +) => { + const orExpression = { + _or: [ + { token_id: { _iregex: search } }, + ...(isHexModuleAddress(search) + ? [{ vm_address: { vm_address: { _eq: search.toLowerCase() } } }] + : []), + ], + }; - const collectionExpression = collectionAddress - ? [ - { + return { + vmAddressByOwner: { vm_address: { _eq: accountAddress } }, + is_burned: { _eq: false }, + ...(collectionAddress + ? { + collectionByCollection: { vm_address: { vm_address: { _eq: collectionAddress.toLowerCase() }, }, }, - ] - : []; - - return { - vmAddressByOwner: { vm_address: { _eq: accountAddress } }, - is_burned: { _eq: false }, - ...(collectionAddress ? collectionExpression : {}), - ...(search.trim().length > 0 ? orExpression : {}), - }; - }, [accountAddress, collectionAddress, search]); + } + : {}), + ...(search.trim().length > 0 ? orExpression : {}), + }; +}; diff --git a/src/lib/services/nft/collection.ts b/src/lib/services/nft/collection.ts index cb519fc25..630810f8a 100644 --- a/src/lib/services/nft/collection.ts +++ b/src/lib/services/nft/collection.ts @@ -1,16 +1,31 @@ import axios from "axios"; import { z } from "zod"; +import { + getCollectionActivitiesExpression, + getCollectionActivitiesExpressionOld, + getCollectionsExpression, + getCollectionsExpressionOld, +} from "../expression"; import { getCollectionActivitiesCountQuery, + getCollectionActivitiesCountQueryOld, getCollectionActivitiesQuery, + getCollectionActivitiesQueryOld, getCollectionByCollectionAddressQuery, + getCollectionByCollectionAddressQueryOld, getCollectionCreatorQuery, + getCollectionCreatorQueryOld, getCollectionMutateEventsCountQuery, + getCollectionMutateEventsCountQueryOld, getCollectionMutateEventsQuery, + getCollectionMutateEventsQueryOld, getCollectionsByAccountQuery, + getCollectionsByAccountQueryOld, getCollectionsQuery, + getCollectionsQueryOld, getCollectionUniqueHoldersCountQuery, + getCollectionUniqueHoldersCountQueryOld, } from "lib/query"; import type { HexAddr, HexAddr32, MutateEvent } from "lib/types"; import { zHexAddr, zHexAddr32, zRemark, zUtcDate } from "lib/types"; @@ -33,9 +48,25 @@ const zCollection = z })); export type Collection = z.infer; +const zCollectionOld = z + .object({ + name: z.string(), + vm_address: z.object({ vm_address: zHexAddr32 }), + uri: z.string(), + description: z.string(), + vmAddressByCreator: z.object({ vm_address: zHexAddr32 }), + }) + .transform((val) => ({ + description: val.description, + uri: val.uri, + name: val.name, + collectionAddress: val.vm_address.vm_address, + creator: val.vmAddressByCreator.vm_address, + })); + const zCollectionsResponse = z .object({ - collections: zCollection.array(), + collections: z.union([zCollection, zCollectionOld]).array(), collections_aggregate: z.object({ aggregate: z.object({ count: z.number(), @@ -50,16 +81,27 @@ export type CollectionsResponse = z.infer; export const getCollections = async ( indexer: string, + limit: number, offset: number, - pageSize: number, - expression: object -) => - axios - .post(indexer, { + search?: string +) => { + const expressionNew = getCollectionsExpression(search); + const expressionOld = getCollectionsExpressionOld(search); + + try { + const res = await axios.post(indexer, { query: getCollectionsQuery, - variables: { offset, pageSize, expression }, - }) - .then(({ data: res }) => parseWithError(zCollectionsResponse, res.data)); + variables: { offset, limit, expression: expressionNew }, + }); + return parseWithError(zCollectionsResponse, res.data.data); + } catch { + const res = await axios.post(indexer, { + query: getCollectionsQueryOld, + variables: { offset, limit, expression: expressionOld }, + }); + return parseWithError(zCollectionsResponse, res.data.data); + } +}; const zCollectionByCollectionAddressResponse = z.object({ data: z @@ -96,17 +138,25 @@ export type CollectionByCollectionAddressResponse = z.infer< export const getCollectionByCollectionAddress = async ( indexer: string, collectionAddress: HexAddr32 -) => - axios - .post(indexer, { +) => { + try { + const res = await axios.post(indexer, { query: getCollectionByCollectionAddressQuery, variables: { vmAddress: collectionAddress }, - }) - .then(({ data: res }) => - parseWithError(zCollectionByCollectionAddressResponse, { - data: res.data.collections[0], - }) - ); + }); + return parseWithError(zCollectionByCollectionAddressResponse, { + data: res.data.data.collections[0], + }); + } catch { + const res = await axios.post(indexer, { + query: getCollectionByCollectionAddressQueryOld, + variables: { vmAddress: collectionAddress }, + }); + return parseWithError(zCollectionByCollectionAddressResponse, { + data: res.data.data.collections[0], + }); + } +}; const zCollectionCreatorResponse = z .object({ @@ -128,18 +178,53 @@ export type CollectionCreatorResponse = z.infer< typeof zCollectionCreatorResponse >; +const zCollectionCreatorResponseOld = z + .object({ + collections: z + .object({ + collection_transactions: z + .object({ + transaction: z.object({ + block: z.object({ height: z.number(), timestamp: zUtcDate }), + hash: z.string(), + }), + }) + .array(), + vmAddressByCreator: z.object({ vm_address: zHexAddr }), + }) + .array(), + }) + .transform((val) => ({ + creatorAddress: val.collections[0].vmAddressByCreator.vm_address, + height: + val.collections[0].collection_transactions[0].transaction.block.height, + timestamp: + val.collections[0].collection_transactions[0].transaction.block.timestamp, + txhash: + val.collections[0].collection_transactions[0].transaction.hash.replace( + "\\x", + "" + ), + })); + export const getCollectionCreator = async ( indexer: string, collectionAddress: HexAddr32 -) => - axios - .post(indexer, { +) => { + try { + const res = await axios.post(indexer, { query: getCollectionCreatorQuery, variables: { vmAddress: collectionAddress }, - }) - .then(({ data: res }) => - parseWithError(zCollectionCreatorResponse, res.data) - ); + }); + return parseWithError(zCollectionCreatorResponse, res.data.data); + } catch { + const res = await axios.post(indexer, { + query: getCollectionCreatorQueryOld, + variables: { vmAddress: collectionAddress }, + }); + return parseWithError(zCollectionCreatorResponseOld, res.data.data); + } +}; const zActivity = z .object({ @@ -171,26 +256,81 @@ const zActivity = z })); export type Activity = z.infer; +const zActivityOld = z + .object({ + transaction: z.object({ + block: z.object({ timestamp: zUtcDate }), + hash: z.string().transform(parseTxHash), + }), + is_nft_burn: z.boolean(), + is_nft_mint: z.boolean(), + is_nft_transfer: z.boolean(), + nft: z + .object({ + token_id: z.string(), + vm_address: z.object({ vm_address: zHexAddr }), + }) + .optional() + .nullable(), + is_collection_create: z.boolean(), + }) + .transform((data) => ({ + timestamp: data.transaction.block.timestamp, + txhash: data.transaction.hash, + isNftBurn: data.is_nft_burn, + isNftMint: data.is_nft_mint, + isNftTransfer: data.is_nft_transfer, + tokenId: data.nft?.token_id, + nftAddress: data.nft?.vm_address.vm_address, + isCollectionCreate: data.is_collection_create, + })); + export const getCollectionActivities = async ( indexer: string, - pageSize: number, + collectionAddress: HexAddr32, + limit: number, offset: number, - expression?: object + search?: string ) => { - return axios - .post(indexer, { + const expressionNew = getCollectionActivitiesExpression( + collectionAddress, + search + ); + const expressionOld = getCollectionActivitiesExpressionOld( + collectionAddress, + search + ); + + try { + const res = await axios.post(indexer, { query: getCollectionActivitiesQuery, variables: { - pageSize, + limit, offset, - expression, + expression: expressionNew, }, - }) - .then(({ data: res }) => - parseWithError(zActivity.array(), res.data.collection_transactions) + }); + return parseWithError( + zActivity.array(), + res.data.data.collection_transactions ); + } catch { + const res = await axios.post(indexer, { + query: getCollectionActivitiesQueryOld, + variables: { + limit, + offset, + expression: expressionOld, + }, + }); + return parseWithError( + zActivityOld.array(), + res.data.data.collection_transactions + ); + } }; +// TODO: here const zActivitiesCountResponse = z .object({ collection_transactions_aggregate: z.object({ @@ -204,13 +344,21 @@ const zActivitiesCountResponse = z export const getCollectionActivitiesCount = async ( indexer: string, collectionAddress: HexAddr32 -) => - axios - .post(indexer, { +) => { + try { + const res = await axios.post(indexer, { query: getCollectionActivitiesCountQuery, variables: { vmAddress: collectionAddress }, - }) - .then(({ data }) => parseWithError(zActivitiesCountResponse, data.data)); + }); + return parseWithError(zActivitiesCountResponse, res.data.data); + } catch { + const res = await axios.post(indexer, { + query: getCollectionActivitiesCountQueryOld, + variables: { vmAddress: collectionAddress }, + }); + return parseWithError(zActivitiesCountResponse, res.data.data); + } +}; const zCollectionMutateEventsResponse = z .object({ @@ -231,24 +379,29 @@ const zCollectionMutateEventsResponse = z export const getCollectionMutateEvents = async ( indexer: string, collectionAddress: HexAddr32, - pageSize: number, + limit: number, offset: number -) => - axios - .post(indexer, { +) => { + try { + const res = await axios.post(indexer, { query: getCollectionMutateEventsQuery, - variables: { - collectionAddress, - pageSize, - offset, - }, - }) - .then(({ data: res }) => - parseWithError( - zCollectionMutateEventsResponse.array(), - res.data.collection_mutation_events - ) + variables: { collectionAddress, limit, offset }, + }); + return parseWithError( + zCollectionMutateEventsResponse.array(), + res.data.data.collection_mutation_events + ); + } catch { + const res = await axios.post(indexer, { + query: getCollectionMutateEventsQueryOld, + variables: { collectionAddress, limit, offset }, + }); + return parseWithError( + zCollectionMutateEventsResponse.array(), + res.data.data.collection_mutation_events ); + } +}; const zMutationEventsCountResponseItem = z .object({ @@ -263,15 +416,21 @@ const zMutationEventsCountResponseItem = z export const getCollectionMutateEventsCount = async ( indexer: string, collectionAddress: HexAddr32 -) => - axios - .post(indexer, { +) => { + try { + const res = await axios.post(indexer, { query: getCollectionMutateEventsCountQuery, variables: { vmAddress: collectionAddress }, - }) - .then(({ data }) => - parseWithError(zMutationEventsCountResponseItem, data.data) - ); + }); + return parseWithError(zMutationEventsCountResponseItem, res.data.data); + } catch { + const res = await axios.post(indexer, { + query: getCollectionMutateEventsCountQueryOld, + variables: { vmAddress: collectionAddress }, + }); + return parseWithError(zMutationEventsCountResponseItem, res.data.data); + } +}; const zUniqueHoldersCountResponseItem = z .object({ @@ -284,15 +443,21 @@ const zUniqueHoldersCountResponseItem = z export const getCollectionUniqueHoldersCount = async ( indexer: string, collectionAddress: HexAddr32 -) => - axios - .post(indexer, { +) => { + try { + const res = await axios.post(indexer, { query: getCollectionUniqueHoldersCountQuery, variables: { vmAddress: collectionAddress }, - }) - .then(({ data }) => - parseWithError(zUniqueHoldersCountResponseItem, data.data) - ); + }); + return parseWithError(zUniqueHoldersCountResponseItem, res.data.data); + } catch { + const res = await axios.post(indexer, { + query: getCollectionUniqueHoldersCountQueryOld, + variables: { vmAddress: collectionAddress }, + }); + return parseWithError(zUniqueHoldersCountResponseItem, res.data.data); + } +}; const zCollectionsByAccountResponse = z .object({ @@ -306,24 +471,46 @@ const zCollectionsByAccountResponse = z collectionAddress: val.id, uri: val.uri, hold: val.nfts_aggregate.aggregate.count, - })) - .array(); + })); export type CollectionsByAccountResponse = z.infer< typeof zCollectionsByAccountResponse >; +const zCollectionsByAccountResponseOld = z + .object({ + name: z.string(), + vm_address: z.object({ vm_address: zHexAddr32 }), + uri: z.string(), + nfts_aggregate: z.object({ aggregate: z.object({ count: z.number() }) }), + }) + .transform((val) => ({ + collectionName: val.name, + collectionAddress: val.vm_address.vm_address, + uri: val.uri, + hold: val.nfts_aggregate.aggregate.count, + })); + export const getCollectionsByAccount = async ( indexer: string, accountAddress: HexAddr -) => - axios - .post(indexer, { +) => { + try { + const res = await axios.post(indexer, { query: getCollectionsByAccountQuery, variables: { accountAddress }, - }) - .then(({ data: res }) => - parseWithError( - zCollectionsByAccountResponse, - res.data.collections - ).filter((collection) => collection.hold > 0) - ); + }); + return parseWithError( + zCollectionsByAccountResponse.array(), + res.data.data.collections + ).filter((collection) => collection.hold > 0); + } catch { + const res = await axios.post(indexer, { + query: getCollectionsByAccountQueryOld, + variables: { accountAddress }, + }); + return parseWithError( + zCollectionsByAccountResponseOld.array(), + res.data.data.collections + ).filter((collection) => collection.hold > 0); + } +}; diff --git a/src/lib/services/nft/collectionService.ts b/src/lib/services/nft/collectionService.ts index 5dd3f8bf9..d3596c959 100644 --- a/src/lib/services/nft/collectionService.ts +++ b/src/lib/services/nft/collectionService.ts @@ -1,17 +1,7 @@ import type { UseQueryOptions } from "@tanstack/react-query"; import { useQuery } from "@tanstack/react-query"; -import { - useCollectionActivitiesExpression, - useCollectionActivitiesExpressionOld, - useCollectionsExpression, - useCollectionsExpressionOld, -} from "../expression"; -import { - CELATONE_QUERY_KEYS, - useCelatoneApp, - useCurrentChain, -} from "lib/app-provider"; +import { CELATONE_QUERY_KEYS, useCelatoneApp } from "lib/app-provider"; import type { HexAddr, HexAddr32, MutateEvent } from "lib/types"; import type { @@ -32,47 +22,23 @@ import { getCollectionsByAccount, getCollectionUniqueHoldersCount, } from "./collection"; -import { - getCollectionActivitiesCountOld, - getCollectionActivitiesOld, - getCollectionByCollectionAddressOld, - getCollectionCreatorOld, - getCollectionMutateEventsCountOld, - getCollectionMutateEventsOld, - getCollectionsByAccountOld, - getCollectionsOld, - getCollectionUniqueHoldersCountOld, -} from "./collectionOld"; - -const INITIATION_CHAIN_ID = "initiation-1"; export const useCollections = ( - pageSize: number, + limit: number, offset: number, search?: string, options?: Pick, "onSuccess"> ) => { const { chainConfig } = useCelatoneApp(); - const { - chain: { chain_id: chainId }, - } = useCurrentChain(); - const expressionNew = useCollectionsExpression(search); - const expressionOld = useCollectionsExpressionOld(search); - const expression = - chainId === INITIATION_CHAIN_ID ? expressionNew : expressionOld; - return useQuery( [ CELATONE_QUERY_KEYS.NFT_COLLECTIONS, chainConfig.indexer, - pageSize, + limit, offset, - expression, + search, ], - async () => - chainId === INITIATION_CHAIN_ID - ? getCollections(chainConfig.indexer, offset, pageSize, expression) - : getCollectionsOld(chainConfig.indexer, offset, pageSize, expression), + async () => getCollections(chainConfig.indexer, limit, offset, search), { retry: 1, refetchOnWindowFocus: false, @@ -85,9 +51,6 @@ export const useCollectionByCollectionAddress = ( collectionAddress: HexAddr32 ) => { const { chainConfig } = useCelatoneApp(); - const { - chain: { chain_id: chainId }, - } = useCurrentChain(); return useQuery( [ CELATONE_QUERY_KEYS.NFT_COLLECTION_BY_COLLECTION_ADDRESS, @@ -95,15 +58,7 @@ export const useCollectionByCollectionAddress = ( collectionAddress, ], async () => - chainId === INITIATION_CHAIN_ID - ? getCollectionByCollectionAddress( - chainConfig.indexer, - collectionAddress - ) - : getCollectionByCollectionAddressOld( - chainConfig.indexer, - collectionAddress - ), + getCollectionByCollectionAddress(chainConfig.indexer, collectionAddress), { retry: 1, refetchOnWindowFocus: false, @@ -113,19 +68,13 @@ export const useCollectionByCollectionAddress = ( export const useCollectionCreator = (collectionAddress: HexAddr32) => { const { chainConfig } = useCelatoneApp(); - const { - chain: { chain_id: chainId }, - } = useCurrentChain(); return useQuery( [ CELATONE_QUERY_KEYS.NFT_COLLECTION_CREATOR, chainConfig.indexer, collectionAddress, ], - async () => - chainId === INITIATION_CHAIN_ID - ? getCollectionCreator(chainConfig.indexer, collectionAddress) - : getCollectionCreatorOld(chainConfig.indexer, collectionAddress), + async () => getCollectionCreator(chainConfig.indexer, collectionAddress), { retry: 1, refetchOnWindowFocus: false, @@ -135,48 +84,28 @@ export const useCollectionCreator = (collectionAddress: HexAddr32) => { export const useCollectionActivities = ( collectionAddress: HexAddr32, - pageSize: number, + limit: number, offset: number, search?: string ) => { const { chainConfig } = useCelatoneApp(); - const { - chain: { chain_id: chainId }, - } = useCurrentChain(); - const expressionNew = useCollectionActivitiesExpression( - collectionAddress, - search - ); - const expressionOld = useCollectionActivitiesExpressionOld( - collectionAddress, - search - ); - const expression = - chainId === INITIATION_CHAIN_ID ? expressionNew : expressionOld; - return useQuery( [ CELATONE_QUERY_KEYS.NFT_COLLECTION_ACTIVITIES, chainConfig.indexer, collectionAddress, + limit, offset, - pageSize, - expression, + search, ], async () => - chainId === INITIATION_CHAIN_ID - ? getCollectionActivities( - chainConfig.indexer, - pageSize, - offset, - expression - ) - : getCollectionActivitiesOld( - chainConfig.indexer, - pageSize, - offset, - expression - ), + getCollectionActivities( + chainConfig.indexer, + collectionAddress, + limit, + offset, + search + ), { retry: 1, refetchOnWindowFocus: false, @@ -186,9 +115,6 @@ export const useCollectionActivities = ( export const useCollectionActivitiesCount = (collectionAddress: HexAddr32) => { const { chainConfig } = useCelatoneApp(); - const { - chain: { chain_id: chainId }, - } = useCurrentChain(); return useQuery( [ CELATONE_QUERY_KEYS.NFT_COLLECTION_ACTIVITIES_COUNT, @@ -196,12 +122,7 @@ export const useCollectionActivitiesCount = (collectionAddress: HexAddr32) => { collectionAddress, ], async () => - chainId === INITIATION_CHAIN_ID - ? getCollectionActivitiesCount(chainConfig.indexer, collectionAddress) - : getCollectionActivitiesCountOld( - chainConfig.indexer, - collectionAddress - ), + getCollectionActivitiesCount(chainConfig.indexer, collectionAddress), { retry: 1, refetchOnWindowFocus: false, @@ -211,35 +132,25 @@ export const useCollectionActivitiesCount = (collectionAddress: HexAddr32) => { export const useCollectionMutateEvents = ( collectionAddress: HexAddr32, - pageSize: number, + limit: number, offset: number ) => { const { chainConfig } = useCelatoneApp(); - const { - chain: { chain_id: chainId }, - } = useCurrentChain(); return useQuery( [ CELATONE_QUERY_KEYS.NFT_COLLECTION_MUTATE_EVENTS, chainConfig.indexer, collectionAddress, + limit, offset, - pageSize, ], async () => - chainId === INITIATION_CHAIN_ID - ? getCollectionMutateEvents( - chainConfig.indexer, - collectionAddress, - pageSize, - offset - ) - : getCollectionMutateEventsOld( - chainConfig.indexer, - collectionAddress, - pageSize, - offset - ), + getCollectionMutateEvents( + chainConfig.indexer, + collectionAddress, + limit, + offset + ), { retry: 1, refetchOnWindowFocus: false, @@ -251,9 +162,6 @@ export const useCollectionMutateEventsCount = ( collectionAddress: HexAddr32 ) => { const { chainConfig } = useCelatoneApp(); - const { - chain: { chain_id: chainId }, - } = useCurrentChain(); return useQuery( [ CELATONE_QUERY_KEYS.NFT_COLLECTION_MUTATE_EVENTS_COUNT, @@ -261,12 +169,7 @@ export const useCollectionMutateEventsCount = ( collectionAddress, ], async () => - chainId === INITIATION_CHAIN_ID - ? getCollectionMutateEventsCount(chainConfig.indexer, collectionAddress) - : getCollectionMutateEventsCountOld( - chainConfig.indexer, - collectionAddress - ), + getCollectionMutateEventsCount(chainConfig.indexer, collectionAddress), { retry: 1, refetchOnWindowFocus: false, @@ -278,9 +181,6 @@ export const useCollectionUniqueHoldersCount = ( collectionAddress: HexAddr32 ) => { const { chainConfig } = useCelatoneApp(); - const { - chain: { chain_id: chainId }, - } = useCurrentChain(); return useQuery( [ CELATONE_QUERY_KEYS.NFT_COLLECTION_UNIQUE_HOLDERS_COUNT, @@ -288,15 +188,7 @@ export const useCollectionUniqueHoldersCount = ( collectionAddress, ], async () => - chainId === INITIATION_CHAIN_ID - ? getCollectionUniqueHoldersCount( - chainConfig.indexer, - collectionAddress - ) - : getCollectionUniqueHoldersCountOld( - chainConfig.indexer, - collectionAddress - ), + getCollectionUniqueHoldersCount(chainConfig.indexer, collectionAddress), { retry: 1, refetchOnWindowFocus: false, @@ -306,19 +198,13 @@ export const useCollectionUniqueHoldersCount = ( export const useCollectionsByAccount = (accountAddress: HexAddr) => { const { chainConfig } = useCelatoneApp(); - const { - chain: { chain_id: chainId }, - } = useCurrentChain(); - return useQuery( + return useQuery( [ CELATONE_QUERY_KEYS.NFT_COLLECTIONS_BY_ACCOUNT, chainConfig.indexer, accountAddress, ], - async () => - chainId === INITIATION_CHAIN_ID - ? getCollectionsByAccount(chainConfig.indexer, accountAddress) - : getCollectionsByAccountOld(chainConfig.indexer, accountAddress), + async () => getCollectionsByAccount(chainConfig.indexer, accountAddress), { retry: 1, refetchOnWindowFocus: false, diff --git a/src/lib/services/nft/nft.ts b/src/lib/services/nft/nft.ts index 62fca62cd..75fd955f1 100644 --- a/src/lib/services/nft/nft.ts +++ b/src/lib/services/nft/nft.ts @@ -1,16 +1,30 @@ import axios from "axios"; import { z } from "zod"; +import { + getNftsByAccountExpression, + getNftsByAccountExpressionOld, + getNftsExpression, + getNftsExpressionOld, +} from "../expression"; import { getNftMintInfoQuery, getNftMutateEventsCountQuery, + getNftMutateEventsCountQueryOld, getNftMutateEventsQuery, + getNftMutateEventsQueryOld, getNftQuery, + getNftQueryOld, getNftsByAccountQuery, + getNftsByAccountQueryOld, getNftsCountByAccountQuery, + getNftsCountByAccountQueryOld, getNftsQuery, + getNftsQueryOld, getNftTransactionsCountQuery, + getNftTransactionsCountQueryOld, getNftTransactionsQuery, + getNftTransactionsQueryOld, } from "lib/query"; import { zBechAddr, zHexAddr, zHexAddr32, zRemark, zUtcDate } from "lib/types"; import type { HexAddr, HexAddr32, MutateEvent } from "lib/types"; @@ -41,36 +55,65 @@ const zNft = z })); export type Nft = z.infer; +const zNftOld = z + .object({ + uri: z.string(), + token_id: z.string(), + description: z.string().optional(), + is_burned: z.boolean(), + vmAddressByOwner: z.object({ vm_address: zHexAddr }), + vm_address: z.object({ vm_address: zHexAddr32 }).optional(), + collectionByCollection: z.object({ + vm_address: z.object({ vm_address: zHexAddr32 }), + name: z.string(), + }), + }) + .transform((val) => ({ + uri: val.uri, + tokenId: val.token_id, + description: val.description, + isBurned: val.is_burned, + ownerAddress: val.vmAddressByOwner?.vm_address, + nftAddress: val.vm_address?.vm_address || ("" as HexAddr32), + collectionAddress: val.collectionByCollection.vm_address.vm_address, + collectionName: val.collectionByCollection.name, + })); + export const getNfts = async ( indexer: string, - pageSize: number, - offset: number, - expression: object -) => - axios - .post(indexer, { + collectionAddress: HexAddr32, + search: string, + limit: number, + offset: number +) => { + const expressionNew = getNftsExpression(collectionAddress, search); + const expressionOld = getNftsExpressionOld(collectionAddress, search); + + try { + const res = await axios.post(indexer, { query: getNftsQuery, variables: { - limit: pageSize, + limit, offset, - expression, + expression: expressionNew, }, - }) - .then(({ data: res }) => parseWithError(zNft.array(), res.data.nfts)); - -export const getNftsCountByAccount = async ( - indexer: string, - accountAddress: HexAddr -) => - axios - .post(indexer, { - query: getNftsCountByAccountQuery, - variables: { accountAddress }, - }) - .then(({ data: res }) => res.data.nfts_aggregate.aggregate.count); + }); + return parseWithError(zNft.array(), res.data.data.nfts); + } catch { + const res = await axios.post(indexer, { + query: getNftsQueryOld, + variables: { + limit, + offset, + expression: expressionOld, + }, + }); + return parseWithError(zNftOld.array(), res.data.data.nfts); + } +}; const zNftByNftAddressResponse = z.object({ - data: zNft.optional(), + data: z.union([zNft, zNftOld]).optional(), }); export type NftByNftAddressResponse = z.infer; @@ -78,15 +121,44 @@ export const getNftByNftAddress = async ( indexer: string, collectionAddress: HexAddr32, nftAddress: HexAddr32 -) => - axios - .post(indexer, { +) => { + try { + const res = await axios.post(indexer, { query: getNftQuery, variables: { collectionAddress, nftAddress }, - }) - .then(({ data }) => - parseWithError(zNftByNftAddressResponse, { data: data.data.nfts[0] }) - ); + }); + return parseWithError(zNftByNftAddressResponse, { + data: res.data.data.nfts[0], + }); + } catch { + const res = await axios.post(indexer, { + query: getNftQueryOld, + variables: { collectionAddress, nftAddress }, + }); + return parseWithError(zNftByNftAddressResponse, { + data: res.data.data.nfts[0], + }); + } +}; + +export const getNftsCountByAccount = async ( + indexer: string, + accountAddress: HexAddr +) => { + try { + const res = await axios.post(indexer, { + query: getNftsCountByAccountQuery, + variables: { accountAddress }, + }); + return z.number().parse(res.data.data.nfts_aggregate.aggregate.count); + } catch { + const res = await axios.post(indexer, { + query: getNftsCountByAccountQueryOld, + variables: { accountAddress }, + }); + return z.number().parse(res.data.data.nfts_aggregate.aggregate.count); + } +}; const zNftMintInfoResponse = z .object({ @@ -164,33 +236,52 @@ export type NftTransactions = z.infer; export const getNftTransactions = async ( indexer: string, nftAddress: HexAddr32, - offset: number, - limit: number -) => - axios - .post(indexer, { + limit: number, + offset: number +) => { + try { + const res = await axios.post(indexer, { query: getNftTransactionsQuery, variables: { limit, offset, nftAddress }, - }) - .then(({ data: res }) => - parseWithError( - zNftTransactionsResponse.array(), - res.data.nft_transactions - ) + }); + return parseWithError( + zNftTransactionsResponse.array(), + res.data.data.nft_transactions ); + } catch (err) { + const res = await axios.post(indexer, { + query: getNftTransactionsQueryOld, + variables: { limit, offset, nftAddress }, + }); + return parseWithError( + zNftTransactionsResponse.array(), + res.data.data.nft_transactions + ); + } +}; export const getNftTransactionsCount = async ( indexer: string, nftAddress: HexAddr32 -) => - axios - .post(indexer, { +) => { + try { + const res = await axios.post(indexer, { query: getNftTransactionsCountQuery, variables: { nftAddress }, - }) - .then( - ({ data: res }) => res.data.nft_transactions_aggregate.aggregate.count - ); + }); + return z + .number() + .parse(res.data.data.nft_transactions_aggregate.aggregate.count); + } catch { + const res = await axios.post(indexer, { + query: getNftTransactionsCountQueryOld, + variables: { nftAddress }, + }); + return z + .number() + .parse(res.data.data.nft_transactions_aggregate.aggregate.count); + } +}; const zNftMutateEventsResponseItem = z .object({ @@ -213,35 +304,54 @@ export const getNftMutateEvents = async ( nftAddress: HexAddr32, offset: number, limit: number -) => - axios - .post(indexer, { +) => { + try { + const res = await axios.post(indexer, { query: getNftMutateEventsQuery, variables: { limit, offset, nftAddress }, - }) - .then(({ data: res }) => - parseWithError( - zNftMutateEventsResponseItem.array(), - res.data.nft_mutation_events - ) + }); + return parseWithError( + zNftMutateEventsResponseItem.array(), + res.data.data.nft_mutation_events + ); + } catch { + const res = await axios.post(indexer, { + query: getNftMutateEventsQueryOld, + variables: { limit, offset, nftAddress }, + }); + return parseWithError( + zNftMutateEventsResponseItem.array(), + res.data.data.nft_mutation_events ); + } +}; export const getNftMutateEventsCount = async ( indexer: string, nftAddress: HexAddr32 -) => - axios - .post(indexer, { +) => { + try { + const rest = await axios.post(indexer, { query: getNftMutateEventsCountQuery, variables: { nftAddress }, - }) - .then( - ({ data }) => data.data.nft_mutation_events_aggregate.aggregate.count - ); + }); + return z + .number() + .parse(rest.data.data.nft_mutation_events_aggregate.aggregate.count); + } catch { + const res = await axios.post(indexer, { + query: getNftMutateEventsCountQueryOld, + variables: { nftAddress }, + }); + return z + .number() + .parse(res.data.data.nft_mutation_events_aggregate.aggregate.count); + } +}; const zNftsByAccountResponse = z .object({ - nfts: zNft.array(), + nfts: z.union([zNft, zNftOld]).array(), nfts_aggregate: z.object({ aggregate: z.object({ count: z.number(), @@ -256,13 +366,34 @@ export type NftsByAccountResponse = z.infer; export const getNftsByAccount = async ( indexer: string, - pageSize: number, + accountAddress: HexAddr, + limit: number, offset: number, - expression: object -) => - axios - .post(indexer, { + collectionAddress?: HexAddr32, + search?: string +) => { + const expressionNew = getNftsByAccountExpression( + accountAddress, + collectionAddress, + search + ); + const expressionOld = getNftsByAccountExpressionOld( + accountAddress, + collectionAddress, + search + ); + + try { + const res = await axios.post(indexer, { query: getNftsByAccountQuery, - variables: { pageSize, offset, expression }, - }) - .then(({ data: res }) => parseWithError(zNftsByAccountResponse, res.data)); + variables: { limit, offset, expression: expressionNew }, + }); + return parseWithError(zNftsByAccountResponse, res.data.data); + } catch { + const res = await axios.post(indexer, { + query: getNftsByAccountQueryOld, + variables: { limit, offset, expression: expressionOld }, + }); + return parseWithError(zNftsByAccountResponse, res.data.data); + } +}; diff --git a/src/lib/services/nft/nftService.ts b/src/lib/services/nft/nftService.ts index e7d6b376a..fdfe9e0ac 100644 --- a/src/lib/services/nft/nftService.ts +++ b/src/lib/services/nft/nftService.ts @@ -1,16 +1,9 @@ import type { UseQueryOptions } from "@tanstack/react-query"; import { useQuery } from "@tanstack/react-query"; -import { - useNftsByAccountExpression, - useNftsByAccountExpressionOld, - useNftsExpression, - useNftsExpressionOld, -} from "../expression"; import { CELATONE_QUERY_KEYS, useCelatoneApp, - useCurrentChain, useNftConfig, } from "lib/app-provider"; import type { HexAddr, HexAddr32, MutateEvent } from "lib/types"; @@ -35,48 +28,26 @@ import { getNftTransactions, getNftTransactionsCount, } from "./nft"; -import { - getNftByNftAddressOld, - getNftMutateEventsCountOld, - getNftMutateEventsOld, - getNftsByAccountOld, - getNftsCountByAccountOld, - getNftsOld, - getNftTransactionsCountOld, - getNftTransactionsOld, -} from "./nftOld"; - -const INITIATION_CHAIN_ID = "initiation-1"; export const useNfts = ( collectionAddress: HexAddr32, - pageSize: number, + limit: number, offset: number, search = "" ) => { const { chainConfig } = useCelatoneApp(); - const { - chain: { chain_id: chainId }, - } = useCurrentChain(); - const expressionNew = useNftsExpression(collectionAddress, search); - const expressionOld = useNftsExpressionOld(collectionAddress, search); - const expression = - chainId === INITIATION_CHAIN_ID ? expressionNew : expressionOld; return useQuery( [ CELATONE_QUERY_KEYS.NFTS, chainConfig.indexer, collectionAddress, + limit, offset, - pageSize, search, - expression, ], async () => - chainId === INITIATION_CHAIN_ID - ? getNfts(chainConfig.indexer, pageSize, offset, expression) - : getNftsOld(chainConfig.indexer, pageSize, offset, expression), + getNfts(chainConfig.indexer, collectionAddress, search, limit, offset), { retry: 1, refetchOnWindowFocus: false, @@ -89,9 +60,6 @@ export const useNftByNftAddress = ( nftAddress: HexAddr32 ) => { const { chainConfig } = useCelatoneApp(); - const { - chain: { chain_id: chainId }, - } = useCurrentChain(); return useQuery( [ @@ -101,13 +69,7 @@ export const useNftByNftAddress = ( nftAddress, ], async () => - chainId === INITIATION_CHAIN_ID - ? getNftByNftAddress(chainConfig.indexer, collectionAddress, nftAddress) - : getNftByNftAddressOld( - chainConfig.indexer, - collectionAddress, - nftAddress - ), + getNftByNftAddress(chainConfig.indexer, collectionAddress, nftAddress), { retry: 1, refetchOnWindowFocus: false, @@ -145,10 +107,6 @@ export const useNftTransactions = ( nftAddress: HexAddr32 ) => { const { chainConfig } = useCelatoneApp(); - const { - chain: { chain_id: chainId }, - } = useCurrentChain(); - return useQuery( [ CELATONE_QUERY_KEYS.NFT_TRANSACTIONS, @@ -158,9 +116,7 @@ export const useNftTransactions = ( offset, ], async () => - chainId === INITIATION_CHAIN_ID - ? getNftTransactions(chainConfig.indexer, nftAddress, offset, limit) - : getNftTransactionsOld(chainConfig.indexer, nftAddress, offset, limit), + getNftTransactions(chainConfig.indexer, nftAddress, limit, offset), { retry: 1, refetchOnWindowFocus: false, @@ -170,20 +126,13 @@ export const useNftTransactions = ( export const useNftTransactionsCount = (nftAddress: HexAddr32) => { const { chainConfig } = useCelatoneApp(); - const { - chain: { chain_id: chainId }, - } = useCurrentChain(); - return useQuery( [ CELATONE_QUERY_KEYS.NFT_TRANSACTIONS_COUNT, chainConfig.indexer, nftAddress, ], - async () => - chainId === INITIATION_CHAIN_ID - ? getNftTransactionsCount(chainConfig.indexer, nftAddress) - : getNftTransactionsCountOld(chainConfig.indexer, nftAddress), + async () => getNftTransactionsCount(chainConfig.indexer, nftAddress), { retry: 1, refetchOnWindowFocus: false, @@ -197,10 +146,6 @@ export const useNftMutateEvents = ( nftAddress: HexAddr32 ) => { const { chainConfig } = useCelatoneApp(); - const { - chain: { chain_id: chainId }, - } = useCurrentChain(); - return useQuery( [ CELATONE_QUERY_KEYS.NFT_MUTATE_EVENTS, @@ -210,9 +155,7 @@ export const useNftMutateEvents = ( offset, ], async () => - chainId === INITIATION_CHAIN_ID - ? getNftMutateEvents(chainConfig.indexer, nftAddress, offset, limit) - : getNftMutateEventsOld(chainConfig.indexer, nftAddress, offset, limit), + getNftMutateEvents(chainConfig.indexer, nftAddress, offset, limit), { retry: 1, refetchOnWindowFocus: false, @@ -222,20 +165,13 @@ export const useNftMutateEvents = ( export const useNftMutateEventsCount = (nftAddress: HexAddr32) => { const { chainConfig } = useCelatoneApp(); - const { - chain: { chain_id: chainId }, - } = useCurrentChain(); - return useQuery( [ CELATONE_QUERY_KEYS.NFT_MUTATE_EVENTS_COUNT, chainConfig.indexer, nftAddress, ], - async () => - chainId === INITIATION_CHAIN_ID - ? getNftMutateEventsCount(chainConfig.indexer, nftAddress) - : getNftMutateEventsCountOld(chainConfig.indexer, nftAddress), + async () => getNftMutateEventsCount(chainConfig.indexer, nftAddress), { retry: 1, refetchOnWindowFocus: false, @@ -246,20 +182,13 @@ export const useNftMutateEventsCount = (nftAddress: HexAddr32) => { export const useNftsCountByAccount = (accountAddress: HexAddr) => { const { chainConfig } = useCelatoneApp(); const { enabled } = useNftConfig({ shouldRedirect: false }); - const { - chain: { chain_id: chainId }, - } = useCurrentChain(); - return useQuery( [ CELATONE_QUERY_KEYS.NFTS_COUNT_BY_ACCOUNT, chainConfig.indexer, accountAddress, ], - async () => - chainId === INITIATION_CHAIN_ID - ? getNftsCountByAccount(chainConfig.indexer, accountAddress) - : getNftsCountByAccountOld(chainConfig.indexer, accountAddress), + async () => getNftsCountByAccount(chainConfig.indexer, accountAddress), { retry: 1, refetchOnWindowFocus: false, @@ -270,48 +199,32 @@ export const useNftsCountByAccount = (accountAddress: HexAddr) => { export const useNftsByAccountByCollection = ( accountAddress: HexAddr, - pageSize: number, + limit: number, offset: number, search = "", collectionAddress?: HexAddr32, options: Pick, "onSuccess"> = {} ) => { const { chainConfig } = useCelatoneApp(); - const { - chain: { chain_id: chainId }, - } = useCurrentChain(); - const expressionNew = useNftsByAccountExpression( - accountAddress, - collectionAddress, - search - ); - const expressionOld = useNftsByAccountExpressionOld( - accountAddress, - collectionAddress, - search - ); - const expression = - chainId === INITIATION_CHAIN_ID ? expressionNew : expressionOld; - return useQuery( [ CELATONE_QUERY_KEYS.NFTS_BY_ACCOUNT_BY_COLLECTION, chainConfig.indexer, accountAddress, - pageSize, + limit, offset, collectionAddress, - expression, + search, ], async () => - chainId === INITIATION_CHAIN_ID - ? getNftsByAccount(chainConfig.indexer, pageSize, offset, expression) - : getNftsByAccountOld( - chainConfig.indexer, - pageSize, - offset, - expression - ), + getNftsByAccount( + chainConfig.indexer, + accountAddress, + limit, + offset, + collectionAddress, + search + ), { retry: 1, refetchOnWindowFocus: false, From 071eaec8a7a4d1e8d5c0e4ced260b214c0c74c00 Mon Sep 17 00:00:00 2001 From: songwongtp <16089160+songwongtp@users.noreply.github.com> Date: Mon, 8 Jul 2024 13:29:34 +0700 Subject: [PATCH 09/16] fix: sign mode multi --- CHANGELOG.md | 1 + src/lib/services/types/tx.ts | 51 +++++++++++++++++++----------------- src/lib/types/account.ts | 15 ++++++++++- src/lib/types/common.ts | 6 ----- src/lib/types/validator.ts | 4 +-- src/lib/utils/address.ts | 11 +++++--- 6 files changed, 51 insertions(+), 37 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fea0a467..bc3a935e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Bug fixes - [#1004](https://github.com/alleslabs/celatone-frontend/pull/1004) Fix empty string moniker +- [#1010](https://github.com/alleslabs/celatone-frontend/pull/1010) Fix signer info sign mode multi type validation ## v1.7.0 diff --git a/src/lib/services/types/tx.ts b/src/lib/services/types/tx.ts index 024cb9e92..fe4e3c6f4 100644 --- a/src/lib/services/types/tx.ts +++ b/src/lib/services/types/tx.ts @@ -1,10 +1,5 @@ import type { Log } from "@cosmjs/stargate/build/logs"; import { SignMode } from "cosmjs-types/cosmos/tx/signing/v1beta1/signing"; -import type { - ModeInfo, - ModeInfo_Multi as ModeInfoMulti, - ModeInfo_Single as ModeInfoSingle, -} from "cosmjs-types/cosmos/tx/v1beta1/tx"; import { z } from "zod"; import type { @@ -18,8 +13,8 @@ import { zBechAddr, zCoin, zMessageResponse, - zPubkey, - zUint8Schema, + zPubkeyMulti, + zPubkeySingle, zUtcDate, } from "lib/types"; import { @@ -36,31 +31,39 @@ import { zAny } from "./protobuf"; // --------------AuthInfo------------------ // ---------------------------------------- -let zModeInfo: z.ZodType; - -const zModeInfoSingle: z.ZodType = z.object({ - mode: z.custom((val) => SignMode[val as keyof typeof SignMode]), +const zModeInfoSingle = z.object({ + single: z.object({ + mode: z.custom((val) => SignMode[val as keyof typeof SignMode]), + }), }); -const zModeInfoMulti: z.ZodType = z.object({ - bitarray: z.object({ - extraBitsStored: z.number(), - elems: zUint8Schema, +const zModeInfoMulti = z.object({ + multi: z.object({ + bitarray: z.object({ + extra_bits_stored: z.number(), + elems: z.string(), // base64 encoded of Uint8Array + }), + // assuming one nesting level for now as multisig pubkey is also one level + mode_infos: z.array(zModeInfoSingle), }), - modeInfos: z.lazy(() => z.array(zModeInfo)), }); -zModeInfo = z.object({ - single: zModeInfoSingle.optional(), - multi: zModeInfoMulti.optional(), +const zSignerInfoBase = z.object({ + sequence: z.string(), +}); + +const zSignerInfoSingle = zSignerInfoBase.extend({ + mode_info: zModeInfoSingle, + public_key: zPubkeySingle, +}); + +const zSignerInfoMulti = zSignerInfoBase.extend({ + mode_info: zModeInfoMulti, + public_key: zPubkeyMulti, }); const zSignerInfo = z - .object({ - public_key: zPubkey, - mode_info: zModeInfo.optional(), - sequence: z.string(), - }) + .union([zSignerInfoSingle, zSignerInfoMulti]) .transform(snakeToCamel); const zAuthInfo = z diff --git a/src/lib/types/account.ts b/src/lib/types/account.ts index 036316039..0880e3931 100644 --- a/src/lib/types/account.ts +++ b/src/lib/types/account.ts @@ -1,5 +1,7 @@ import { z } from "zod"; +import { snakeToCamel } from "lib/utils/formatter/snakeToCamel"; + export enum AccountType { BaseAccount = "BaseAccount", InterchainAccount = "InterchainAccount", @@ -18,9 +20,20 @@ export enum AccountTypeLcd { ModuleAccount = "/cosmos.auth.v1beta1.ModuleAccount", } -export const zPubkey = z.object({ +export const zPubkeySingle = z.object({ "@type": z.string(), key: z.string(), }); +export type PubkeySingle = z.infer; + +export const zPubkeyMulti = z + .object({ + "@type": z.string(), + public_keys: z.array(zPubkeySingle), + threshold: z.number(), + }) + .transform(snakeToCamel); +export type PubkeyMulti = z.infer; +export const zPubkey = z.union([zPubkeySingle, zPubkeyMulti]); export type Pubkey = z.infer; diff --git a/src/lib/types/common.ts b/src/lib/types/common.ts index f3d5352a8..f1414b4e8 100644 --- a/src/lib/types/common.ts +++ b/src/lib/types/common.ts @@ -1,5 +1,3 @@ -import { z } from "zod"; - export type Dict = Partial>; export type Option = T | undefined; @@ -9,7 +7,3 @@ export type Nullable = T | null; export type Nullish = T | null | undefined; export type NominalType = { __type: T }; - -export const zUint8Schema: z.ZodType = z.custom( - (val) => val instanceof Uint8Array -); diff --git a/src/lib/types/validator.ts b/src/lib/types/validator.ts index 25fcabad6..547193ad6 100644 --- a/src/lib/types/validator.ts +++ b/src/lib/types/validator.ts @@ -3,7 +3,7 @@ import { z } from "zod"; import { snakeToCamel } from "lib/utils/formatter/snakeToCamel"; import { formatUrl } from "lib/utils/formatter/url"; -import { zPubkey } from "./account"; +import { zPubkeySingle } from "./account"; import { zBechAddr20, zConsensusAddr, zValidatorAddr } from "./addrs"; import { zBig } from "./big"; import type { Ratio } from "./currency"; @@ -44,7 +44,7 @@ export const zValidatorData = z })); export type ValidatorData = z.infer; -export const zConsensusPubkey = zPubkey; +export const zConsensusPubkey = zPubkeySingle; export type ConsensusPubkey = z.infer; export enum BlockVote { diff --git a/src/lib/utils/address.ts b/src/lib/utils/address.ts index 9e9b64579..de69534b4 100644 --- a/src/lib/utils/address.ts +++ b/src/lib/utils/address.ts @@ -54,14 +54,17 @@ export const convertAccountPubkeyToAccountAddress = ( accountPubkey: Pubkey, prefix: string ) => { - if (accountPubkey["@type"] === "/cosmos.crypto.ed25519.PubKey") { - const pubkey = fromBase64(accountPubkey.key); + const firstAccountPubkey = + "key" in accountPubkey ? accountPubkey : accountPubkey.publicKeys[0]; + + if (firstAccountPubkey["@type"] === "/cosmos.crypto.ed25519.PubKey") { + const pubkey = fromBase64(firstAccountPubkey.key); const data = fromHex(toHex(sha256(pubkey)).slice(0, 40)); return zBechAddr20.parse(toBech32(prefix, data)); } - if (accountPubkey["@type"] === "/cosmos.crypto.secp256k1.PubKey") { - const pubkey = fromBase64(accountPubkey.key); + if (firstAccountPubkey["@type"] === "/cosmos.crypto.secp256k1.PubKey") { + const pubkey = fromBase64(firstAccountPubkey.key); const data = new Ripemd160().update(sha256(pubkey)).digest(); return zBechAddr20.parse(toBech32(prefix, data)); } From 648f062119e9356d5f2ff736dba35dae6c3b5633 Mon Sep 17 00:00:00 2001 From: evilpeach Date: Mon, 8 Jul 2024 13:47:13 +0700 Subject: [PATCH 10/16] fix: remove redundant --- src/lib/services/nft/collection.ts | 34 +++++++++++++------------- src/lib/services/nft/nft.ts | 38 ++++++++++++++++-------------- 2 files changed, 38 insertions(+), 34 deletions(-) diff --git a/src/lib/services/nft/collection.ts b/src/lib/services/nft/collection.ts index 630810f8a..9996acbe0 100644 --- a/src/lib/services/nft/collection.ts +++ b/src/lib/services/nft/collection.ts @@ -85,19 +85,24 @@ export const getCollections = async ( offset: number, search?: string ) => { - const expressionNew = getCollectionsExpression(search); - const expressionOld = getCollectionsExpressionOld(search); - try { const res = await axios.post(indexer, { query: getCollectionsQuery, - variables: { offset, limit, expression: expressionNew }, + variables: { + offset, + limit, + expression: getCollectionsExpression(search), + }, }); return parseWithError(zCollectionsResponse, res.data.data); } catch { const res = await axios.post(indexer, { query: getCollectionsQueryOld, - variables: { offset, limit, expression: expressionOld }, + variables: { + offset, + limit, + expression: getCollectionsExpressionOld(search), + }, }); return parseWithError(zCollectionsResponse, res.data.data); } @@ -292,22 +297,16 @@ export const getCollectionActivities = async ( offset: number, search?: string ) => { - const expressionNew = getCollectionActivitiesExpression( - collectionAddress, - search - ); - const expressionOld = getCollectionActivitiesExpressionOld( - collectionAddress, - search - ); - try { const res = await axios.post(indexer, { query: getCollectionActivitiesQuery, variables: { limit, offset, - expression: expressionNew, + expression: getCollectionActivitiesExpression( + collectionAddress, + search + ), }, }); return parseWithError( @@ -320,7 +319,10 @@ export const getCollectionActivities = async ( variables: { limit, offset, - expression: expressionOld, + expression: getCollectionActivitiesExpressionOld( + collectionAddress, + search + ), }, }); return parseWithError( diff --git a/src/lib/services/nft/nft.ts b/src/lib/services/nft/nft.ts index 75fd955f1..2106b4214 100644 --- a/src/lib/services/nft/nft.ts +++ b/src/lib/services/nft/nft.ts @@ -86,16 +86,13 @@ export const getNfts = async ( limit: number, offset: number ) => { - const expressionNew = getNftsExpression(collectionAddress, search); - const expressionOld = getNftsExpressionOld(collectionAddress, search); - try { const res = await axios.post(indexer, { query: getNftsQuery, variables: { limit, offset, - expression: expressionNew, + expression: getNftsExpression(collectionAddress, search), }, }); return parseWithError(zNft.array(), res.data.data.nfts); @@ -105,7 +102,7 @@ export const getNfts = async ( variables: { limit, offset, - expression: expressionOld, + expression: getNftsExpressionOld(collectionAddress, search), }, }); return parseWithError(zNftOld.array(), res.data.data.nfts); @@ -372,27 +369,32 @@ export const getNftsByAccount = async ( collectionAddress?: HexAddr32, search?: string ) => { - const expressionNew = getNftsByAccountExpression( - accountAddress, - collectionAddress, - search - ); - const expressionOld = getNftsByAccountExpressionOld( - accountAddress, - collectionAddress, - search - ); - try { const res = await axios.post(indexer, { query: getNftsByAccountQuery, - variables: { limit, offset, expression: expressionNew }, + variables: { + limit, + offset, + expression: getNftsByAccountExpression( + accountAddress, + collectionAddress, + search + ), + }, }); return parseWithError(zNftsByAccountResponse, res.data.data); } catch { const res = await axios.post(indexer, { query: getNftsByAccountQueryOld, - variables: { limit, offset, expression: expressionOld }, + variables: { + limit, + offset, + expression: getNftsByAccountExpressionOld( + accountAddress, + collectionAddress, + search + ), + }, }); return parseWithError(zNftsByAccountResponse, res.data.data); } From ab7aee8d1c8d950714b55b3fe1987aca2fba8794 Mon Sep 17 00:00:00 2001 From: evilpeach Date: Mon, 8 Jul 2024 15:16:33 +0700 Subject: [PATCH 11/16] feat: query modules, balances from lcd --- src/lib/services/bank/index.ts | 13 ++++++++----- src/lib/services/move/module/api.ts | 10 ---------- src/lib/services/move/module/index.ts | 11 ++--------- 3 files changed, 10 insertions(+), 24 deletions(-) diff --git a/src/lib/services/bank/index.ts b/src/lib/services/bank/index.ts index fff6a0cb7..6c8bdb19c 100644 --- a/src/lib/services/bank/index.ts +++ b/src/lib/services/bank/index.ts @@ -9,8 +9,8 @@ import type { BalanceInfos } from "../types"; import { CELATONE_QUERY_KEYS, useBaseApiRoute, + useCelatoneApp, useLcdEndpoint, - useTierConfig, } from "lib/app-provider"; import { big } from "lib/types"; import type { BechAddr, TokenWithValue, USD } from "lib/types"; @@ -25,15 +25,18 @@ import { getBalances } from "./api"; import { getBalancesLcd } from "./lcd"; export const useBalances = (address: BechAddr): UseQueryResult => { - const { isFullTier } = useTierConfig(); + const { + chainConfig: { chain }, + } = useCelatoneApp(); + const isSei = chain === "sei"; const apiEndpoint = useBaseApiRoute("accounts"); const lcdEndpoint = useLcdEndpoint(); - const endpoint = isFullTier ? apiEndpoint : lcdEndpoint; + const endpoint = isSei ? apiEndpoint : lcdEndpoint; return useQuery( - [CELATONE_QUERY_KEYS.BALANCES, endpoint, address, isFullTier], + [CELATONE_QUERY_KEYS.BALANCES, endpoint, address, isSei], async () => - isFullTier + isSei ? getBalances(endpoint, address) : getBalancesLcd(endpoint, address), { retry: 1, refetchOnWindowFocus: false } diff --git a/src/lib/services/move/module/api.ts b/src/lib/services/move/module/api.ts index acb10c1df..2c06efb13 100644 --- a/src/lib/services/move/module/api.ts +++ b/src/lib/services/move/module/api.ts @@ -1,13 +1,11 @@ import axios from "axios"; import type { - AccountModulesResponse, DecodeModuleReturn, ModuleTableCountsResponse, ModuleVerificationInternal, } from "lib/services/types"; import { - zAccountModulesResponse, zModuleHistoriesResponse, zModulePublishInfoResponse, zModuleRelatedProposalsResponse, @@ -32,14 +30,6 @@ import { serializeAbiData, } from "lib/utils"; -export const getModulesByAddress = async ( - endpoint: string, - address: Addr -): Promise => - axios - .get(`${endpoint}/${encodeURI(address)}/move/modules`) - .then(({ data }) => parseWithError(zAccountModulesResponse, data)); - export const getModuleVerificationStatus = async ( endpoint: string, address: Addr, diff --git a/src/lib/services/move/module/index.ts b/src/lib/services/move/module/index.ts index ec2e967e5..a6480b81e 100644 --- a/src/lib/services/move/module/index.ts +++ b/src/lib/services/move/module/index.ts @@ -13,7 +13,6 @@ import { useInitia, useLcdEndpoint, useMoveConfig, - useTierConfig, } from "lib/app-provider"; import type { AccountModulesResponse, @@ -46,7 +45,6 @@ import { getModulePublishInfo, getModuleRelatedProposals, getModules, - getModulesByAddress, getModuleTableCounts, getModuleTxs, getModuleVerificationStatus, @@ -83,19 +81,14 @@ export const useModulesByAddress = ({ onSuccess?: (data: AccountModulesResponse) => void; onError?: (err: AxiosError) => void; }) => { - const { isFullTier } = useTierConfig(); - const apiEndpoint = useBaseApiRoute("accounts"); - const lcdEndpoint = useLcdEndpoint(); - const endpoint = isFullTier ? apiEndpoint : lcdEndpoint; + const endpoint = useLcdEndpoint(); return useQuery( [CELATONE_QUERY_KEYS.MODULES_BY_ADDRESS, endpoint, address], async () => { if (!address) throw new Error("address is undefined (useModulesByAddress)"); - return isFullTier - ? getModulesByAddress(endpoint, address) - : getModulesByAddressLcd(endpoint, address); + return getModulesByAddressLcd(endpoint, address); }, { enabled, From 54e32b626158386ed7939322d2d5ac039909e675 Mon Sep 17 00:00:00 2001 From: evilpeach Date: Mon, 8 Jul 2024 15:17:48 +0700 Subject: [PATCH 12/16] docs: add changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 505bc0fcb..5a0336a98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Improvements +- [#1012](https://github.com/alleslabs/celatone-frontend/pull/1012) Move modules, balances query to LCD + ### Bug fixes - [#1004](https://github.com/alleslabs/celatone-frontend/pull/1004) Fix empty string moniker From a06ca1a20e33875de1a960e6d2552aa65e077f37 Mon Sep 17 00:00:00 2001 From: evilpeach Date: Mon, 8 Jul 2024 15:58:09 +0700 Subject: [PATCH 13/16] fix: remove setTotal on useModuleTxs --- .../module-details/components/tables/ModuleTxsTable.tsx | 5 +---- src/lib/services/move/module/index.ts | 5 ++--- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/lib/pages/module-details/components/tables/ModuleTxsTable.tsx b/src/lib/pages/module-details/components/tables/ModuleTxsTable.tsx index 79fc46ff2..61da6a5a8 100644 --- a/src/lib/pages/module-details/components/tables/ModuleTxsTable.tsx +++ b/src/lib/pages/module-details/components/tables/ModuleTxsTable.tsx @@ -32,7 +32,6 @@ export const ModuleTxsTable = ({ pageSize, setPageSize, offset, - setTotalData, } = usePaginator({ total: txCount, initialState: { @@ -46,9 +45,7 @@ export const ModuleTxsTable = ({ data: moduleTxs, isLoading, error, - } = useModuleTxs(vmAddress, moduleName, pageSize, offset, { - onSuccess: ({ total }) => setTotalData(total), - }); + } = useModuleTxs(vmAddress, moduleName, pageSize, offset); useEffect(() => { if (!onViewMore) setPageSize(10); diff --git a/src/lib/services/move/module/index.ts b/src/lib/services/move/module/index.ts index a6480b81e..9aba4aa07 100644 --- a/src/lib/services/move/module/index.ts +++ b/src/lib/services/move/module/index.ts @@ -300,8 +300,7 @@ export const useModuleTxs = ( vmAddress: HexAddr, moduleName: string, limit: number, - offset: number, - options: Pick, "onSuccess"> = {} + offset: number ) => { const endpoint = useBaseApiRoute("move"); const isInitia = useInitia(); @@ -318,7 +317,7 @@ export const useModuleTxs = ( ], async () => getModuleTxs(endpoint, vmAddress, moduleName, limit, offset, isInitia), - { retry: 1, refetchOnWindowFocus: false, ...options } + { retry: 1, refetchOnWindowFocus: false } ); }; From af207e3bd1fbfdb20f2a1c959809ffa93834f136 Mon Sep 17 00:00:00 2001 From: evilpeach Date: Mon, 8 Jul 2024 16:30:27 +0700 Subject: [PATCH 14/16] fix: remove unused delegators, Sentry --- CHANGELOG.md | 1 + sentry.client.config.js | 1 + sentry.edge.config.js | 1 + sentry.server.config.js | 1 + src/lib/services/validator/api.ts | 9 --------- 5 files changed, 4 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a0336a98..72dc3efdc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Improvements +- [#1013](https://github.com/alleslabs/celatone-frontend/pull/1013) Remove unused validator's delegator count, disable Sentry - [#1012](https://github.com/alleslabs/celatone-frontend/pull/1012) Move modules, balances query to LCD ### Bug fixes diff --git a/sentry.client.config.js b/sentry.client.config.js index f9feee01e..652a36b73 100644 --- a/sentry.client.config.js +++ b/sentry.client.config.js @@ -16,4 +16,5 @@ Sentry.init({ // `release` value here - use the environment variable `SENTRY_RELEASE`, so // that it will also get attached to your source maps integrations: [new CaptureConsole({ levels: ["error"] })], + enabled: false, }); diff --git a/sentry.edge.config.js b/sentry.edge.config.js index 80607bdc1..ce047a903 100644 --- a/sentry.edge.config.js +++ b/sentry.edge.config.js @@ -16,4 +16,5 @@ Sentry.init({ // `release` value here - use the environment variable `SENTRY_RELEASE`, so // that it will also get attached to your source maps integrations: [new CaptureConsole({ levels: ["error"] })], + enabled: false, }); diff --git a/sentry.server.config.js b/sentry.server.config.js index 06f4ff829..efa14614b 100644 --- a/sentry.server.config.js +++ b/sentry.server.config.js @@ -16,4 +16,5 @@ Sentry.init({ // `release` value here - use the environment variable `SENTRY_RELEASE`, so // that it will also get attached to your source maps integrations: [new CaptureConsole({ levels: ["error"] })], + enabled: false, }); diff --git a/src/lib/services/validator/api.ts b/src/lib/services/validator/api.ts index 9b5c331a1..e9f10df0b 100644 --- a/src/lib/services/validator/api.ts +++ b/src/lib/services/validator/api.ts @@ -6,7 +6,6 @@ import { zStakingProvisionsResponse, zValidatorDataResponse, zValidatorDelegationRelatedTxsResponse, - zValidatorDelegatorsResponse, zValidatorsResponse, zValidatorUptimeResponse, zValidatorVotedProposalsResponse, @@ -50,14 +49,6 @@ export const getValidatorStakingProvisions = async (endpoint: string) => .get(`${endpoint}/staking-provisions`) .then(({ data }) => parseWithError(zStakingProvisionsResponse, data)); -export const getValidatorDelegators = async ( - endpoint: string, - validatorAddress: ValidatorAddr -) => - axios - .get(`${endpoint}/${encodeURIComponent(validatorAddress)}/delegators`) - .then(({ data }) => parseWithError(zValidatorDelegatorsResponse, data)); - export const getValidatorVotedProposalsAnswerCounts = async ( endpoint: string, validatorAddress: ValidatorAddr From a7573c8069de4a22e09531a7eb3c6ae432002e02 Mon Sep 17 00:00:00 2001 From: evilpeach Date: Mon, 8 Jul 2024 14:06:02 +0700 Subject: [PATCH 15/16] docs: cut release v1.7.1 --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 72dc3efdc..1996d6386 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Features +### Improvements + +### Bug fixes + +## v1.7.1 + +### Features + - [#1008](https://github.com/alleslabs/celatone-frontend/pull/1008) Support both new, old DB schema for NFTs - [#994](https://github.com/alleslabs/celatone-frontend/pull/994) Add Sequencer, Mesa tier and TierSwitcher component From b68c18dff258f43b0dbd840b71a326a884b43f38 Mon Sep 17 00:00:00 2001 From: evilpeach Date: Mon, 8 Jul 2024 14:59:21 +0700 Subject: [PATCH 16/16] feat: edit untitled validator --- .../components/validator-top/ValidatorTitle.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/pages/validator-details/components/validator-top/ValidatorTitle.tsx b/src/lib/pages/validator-details/components/validator-top/ValidatorTitle.tsx index b4afe5de1..045a88889 100644 --- a/src/lib/pages/validator-details/components/validator-top/ValidatorTitle.tsx +++ b/src/lib/pages/validator-details/components/validator-top/ValidatorTitle.tsx @@ -40,7 +40,7 @@ export const ValidatorTitle = ({ info }: ValidatorTitleProps) => ( color={info.moniker.length ? "text.main" : "text.disabled"} display={{ base: "none", md: "flex" }} > - {info.moniker || "Untitled"} + {info.moniker || "Untitled Validator"} @@ -52,7 +52,7 @@ export const ValidatorTitle = ({ info }: ValidatorTitleProps) => ( color={info.moniker.length ? "text.main" : "text.disabled"} display={{ base: "flex", md: "none" }} > - {info.moniker || "Untitled"} + {info.moniker || "Untitled Validator"}