-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: show no admin and correctly handle explorer link by address type #115
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The latest updates on your projects. Learn more about Vercel for Git ↗︎
4 Ignored Deployments
|
songwongtp
reviewed
Jan 20, 2023
songwongtp
reviewed
Jan 23, 2023
songwongtp
approved these changes
Jan 23, 2023
evilpeach
requested changes
Jan 23, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactor to this
import { chakra, Divider, Flex, Text } from "@chakra-ui/react";
import { ExplorerLink } from "lib/components/ExplorerLink";
import { LabelText } from "lib/components/LabelText";
import { useGetAddressType } from "lib/hooks";
import type { ContractData } from "lib/model/contract";
import { formatUTC, dateFromNow } from "lib/utils";
import { getAddressTypeText } from "lib/utils/address";
interface InstantiateInfoProps {
contractData: ContractData;
}
const Container = chakra(Flex, {
baseStyle: {
direction: "column",
gap: 6,
w: "250px",
},
});
export const InstantiateInfo = ({
contractData: {
instantiateInfo,
chainId,
codeInfo,
initTxHash,
initProposalId,
initProposalTitle,
},
}: InstantiateInfoProps) => {
const getAddressType = useGetAddressType();
if (!instantiateInfo) {
return (
<Container>
<Text variant="body2" color="text.dark">
Error fetching data
</Text>
</Container>
);
}
const instantiatorType = getAddressType(instantiateInfo.instantiator);
const adminTypeOpt = instantiateInfo.admin
? getAddressType(instantiateInfo.admin)
: undefined;
return (
<Container>
<LabelText label="Network">{chainId}</LabelText>
<LabelText label="From Code" helperText1={codeInfo?.description}>
<ExplorerLink
type="code_id"
value={instantiateInfo.codeId}
canCopyWithHover
/>
</LabelText>
<LabelText
label="Admin Address"
helperText1={
adminTypeOpt ? getAddressTypeText(adminTypeOpt) : undefined
}
>
{instantiateInfo.admin ? (
<ExplorerLink
type={adminTypeOpt}
value={instantiateInfo.admin}
canCopyWithHover
/>
) : (
<Text variant="body2" color="text.dark">
No Admin
</Text>
)}
</LabelText>
<Divider border="1px solid" borderColor="divider.main" />
{instantiateInfo &&
(instantiateInfo.createdHeight !== -1 ? (
<LabelText
label="Instantiated Block Height"
helperText1={
instantiateInfo.createdTime
? formatUTC(instantiateInfo.createdTime)
: undefined
}
helperText2={
instantiateInfo.createdTime
? dateFromNow(instantiateInfo.createdTime)
: undefined
}
>
<ExplorerLink
type="block_height"
value={instantiateInfo.createdHeight.toString()}
canCopyWithHover
/>
</LabelText>
) : (
<LabelText label="Instantiated Block Height">N/A</LabelText>
))}
<LabelText
label="Instantiated by"
helperText1={getAddressTypeText(instantiatorType)}
>
<ExplorerLink
type={instantiatorType}
value={instantiateInfo.instantiator}
canCopyWithHover
/>
</LabelText>
{initTxHash ? (
<LabelText label="Instantiate Transaction">
<ExplorerLink
type="tx_hash"
value={initTxHash.toUpperCase()}
canCopyWithHover
/>
</LabelText>
) : (
<LabelText
label="Instantiate Proposal ID"
helperText1={initProposalTitle}
>
<ExplorerLink
value={initProposalId ? `#${initProposalId}` : "Genesis"}
canCopyWithHover
isReadOnly={!initProposalId}
/>
</LabelText>
)}
{instantiateInfo.ibcPortId && (
<LabelText label="IBC Port ID">{instantiateInfo.ibcPortId}</LabelText>
)}
</Container>
);
};
evilpeach
approved these changes
Jan 24, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Describe your changes
(Contract Details Page) show no admin and correctly handle explorer link by address type
Demo Link
(Contract as admin) https://osmosis-celatone-frontend-staging-git-fix-sho-247e4f-alles-labs.vercel.app/testnet/contract/osmo1v7w4c84c3mn5y84alrk7ae34pqk9fxf0l8q5zlehwpcc8jlx8xrsv7kx3q
(No admin)
https://osmosis-celatone-frontend-staging-git-fix-sho-247e4f-alles-labs.vercel.app/testnet/contract/osmo1qqn0dp79xnack2p393tl63nfgf4s906r0tdnjuzjvsapfmwsevkq304yc3