Skip to content

Commit

Permalink
Merge branch 'develop' into release/v1.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
evilpeach committed Jul 2, 2024
2 parents 8261d57 + 6e9dfcd commit 0afb1f0
Show file tree
Hide file tree
Showing 18 changed files with 1,347 additions and 106 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Improvements

- [#1001](https://github.com/alleslabs/celatone-frontend/pull/1001) Support pre and post db schema on nft & collection queries
- [#1000](https://github.com/alleslabs/celatone-frontend/pull/1000) Query module info from lcd directly
- [#998](https://github.com/alleslabs/celatone-frontend/pull/998) Use expression on Nft query
- [#996](https://github.com/alleslabs/celatone-frontend/pull/996) Allow disable voting period tally config
- [#960](https://github.com/alleslabs/celatone-frontend/pull/960) Adjust UI in contract and account detail page
Expand Down
19 changes: 11 additions & 8 deletions src/lib/pages/module-details/components/ModuleInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@ import { Flex, Heading, Text } from "@chakra-ui/react";
import { CustomIcon } from "lib/components/icon";
import { ModuleSourceCode } from "lib/components/module";
import type { ModuleVerificationInternal } from "lib/services/types";
import type { ModuleData, Nullable, Option } from "lib/types";
import type {
IndexedModule,
ModulePublishInfo,
Nullish,
Option,
} from "lib/types";

import { ModuleInfoBody } from "./ModuleInfoBody";

export interface ModuleInfoProps {
verificationData: Option<Nullable<ModuleVerificationInternal>>;
moduleData: Partial<ModuleData>;
indexedModule: IndexedModule;
modulePublishInfo: Option<ModulePublishInfo>;
verificationData: Nullish<ModuleVerificationInternal>;
}

export const ModuleInfo = ({
verificationData,
moduleData,
}: ModuleInfoProps) => (
export const ModuleInfo = ({ verificationData, ...props }: ModuleInfoProps) => (
<Flex flexDirection="column" gap={4}>
<Flex justifyContent="space-between" alignItems="center" w="full">
<Heading as="h6" variant="h6" fontWeight={600}>
Expand All @@ -31,7 +34,7 @@ export const ModuleInfo = ({
</Flex>
)}
</Flex>
<ModuleInfoBody moduleData={moduleData} />
<ModuleInfoBody {...props} />
<ModuleSourceCode sourceCode={verificationData?.source} />
</Flex>
);
51 changes: 25 additions & 26 deletions src/lib/pages/module-details/components/ModuleInfoBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,38 @@ import { Grid } from "@chakra-ui/react";
import { useTierConfig } from "lib/app-provider";
import { ExplorerLink } from "lib/components/ExplorerLink";
import { LabelText } from "lib/components/LabelText";
import type { ModuleData } from "lib/types";
import { dateFromNow, formatUTC } from "lib/utils";

import type { ModuleInfoProps } from "./ModuleInfo";

const ModuleInfoBodyPublishedAndRepublished = ({
moduleData,
}: {
moduleData: Partial<ModuleData>;
}) => {
const { isRepublished, recentPublishTransaction, recentPublishProposal } =
moduleData;
const labelPrefix = isRepublished ? "Latest Republished" : "Published";
modulePublishInfo,
}: Pick<ModuleInfoProps, "modulePublishInfo">) => {
const labelPrefix = modulePublishInfo?.isRepublished
? "Latest Republished"
: "Published";

if (recentPublishTransaction) {
if (modulePublishInfo?.recentPublishTransaction) {
return (
<LabelText label={`${labelPrefix} Transaction`}>
<ExplorerLink
type="tx_hash"
value={recentPublishTransaction}
value={modulePublishInfo.recentPublishTransaction}
showCopyOnHover
/>
</LabelText>
);
}

if (recentPublishProposal) {
if (modulePublishInfo?.recentPublishProposal) {
return (
<LabelText
label={`${labelPrefix} Proposal ID`}
helperText1={recentPublishProposal.title}
helperText1={modulePublishInfo.recentPublishProposal.title}
>
<ExplorerLink
type="proposal_id"
value={recentPublishProposal.id.toString()}
value={modulePublishInfo.recentPublishProposal.id.toString()}
showCopyOnHover
/>
</LabelText>
Expand All @@ -48,15 +45,11 @@ const ModuleInfoBodyPublishedAndRepublished = ({
};

export const ModuleInfoBody = ({
moduleData,
indexedModule,
modulePublishInfo,
}: Omit<ModuleInfoProps, "verificationData">) => {
const isFullTier = useTierConfig() === "full";
const {
address,
upgradePolicy,
recentPublishBlockHeight,
recentPublishBlockTimestamp,
} = moduleData;
const { address, upgradePolicy } = indexedModule;

return (
<Grid
Expand All @@ -77,24 +70,30 @@ export const ModuleInfoBody = ({
</LabelText>
{isFullTier && (
<>
{recentPublishBlockTimestamp && (
{modulePublishInfo?.recentPublishBlockTimestamp && (
<LabelText
label="Published Block Height"
helperText1={formatUTC(recentPublishBlockTimestamp)}
helperText2={dateFromNow(recentPublishBlockTimestamp)}
helperText1={formatUTC(
modulePublishInfo.recentPublishBlockTimestamp
)}
helperText2={dateFromNow(
modulePublishInfo.recentPublishBlockTimestamp
)}
>
{recentPublishBlockHeight ? (
{modulePublishInfo?.recentPublishBlockHeight ? (
<ExplorerLink
type="block_height"
value={recentPublishBlockHeight.toString()}
value={modulePublishInfo.recentPublishBlockHeight.toString()}
showCopyOnHover
/>
) : (
"N/A"
)}
</LabelText>
)}
<ModuleInfoBodyPublishedAndRepublished moduleData={moduleData} />
<ModuleInfoBodyPublishedAndRepublished
modulePublishInfo={modulePublishInfo}
/>
</>
)}
</Grid>
Expand Down
15 changes: 8 additions & 7 deletions src/lib/pages/module-details/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { UserDocsLink } from "lib/components/UserDocsLink";
import { useFormatAddresses } from "lib/hooks/useFormatAddresses";
import {
useModuleByAddressLcd,
useModuleData,
useModulePublishInfo,
useModuleTableCounts,
useVerifyModule,
} from "lib/services/move/module";
Expand Down Expand Up @@ -50,13 +50,13 @@ const ModuleDetailsBody = ({
const isFullTier = useTierConfig() === "full";
const currentTab =
!isFullTier && tab === TabIndex.TxsHistories ? TabIndex.Overview : tab;
const fullData = useModuleData(vmAddress, moduleName, isFullTier);
const liteData = useModuleByAddressLcd({

const { data, isLoading: isModuleLoading } = useModuleByAddressLcd({
address: vmAddress,
moduleName,
options: { enabled: !isFullTier },
});
const { data, isLoading } = isFullTier ? fullData : liteData;
const { data: modulePublishInfo, isFetching: isPublishInfoLoading } =
useModulePublishInfo(vmAddress, moduleName, isFullTier);

const { data: moduleTableCounts } = useModuleTableCounts(
vmAddress,
Expand Down Expand Up @@ -115,7 +115,7 @@ const ModuleDetailsBody = ({
? Object.values(TabIndex)
: Object.values(TabIndex).filter((t) => t !== TabIndex.TxsHistories);

if (isLoading) return <Loading />;
if (isModuleLoading || isPublishInfoLoading) return <Loading />;
if (!data) return <ErrorFetching dataName="module information" />;

return (
Expand Down Expand Up @@ -187,8 +187,9 @@ const ModuleDetailsBody = ({
}}
/>
<ModuleInfo
indexedModule={data}
modulePublishInfo={modulePublishInfo}
verificationData={verificationData}
moduleData={data}
/>
{isFullTier && (
<ModuleTables
Expand Down
Loading

0 comments on commit 0afb1f0

Please sign in to comment.