Skip to content

Commit

Permalink
fix(website): cannonfile diff (#911)
Browse files Browse the repository at this point in the history
  • Loading branch information
noahlitvin authored Apr 16, 2024
1 parent ae1dae6 commit 2d325ec
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 20 deletions.
26 changes: 15 additions & 11 deletions packages/website/src/features/Deploy/TransactionDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const TransactionDetailsPage: FC<{

const { nonce: safeNonce, staged, stagedQuery } = useSafeTransactions(safe);

const verify = parsedNonce >= safeNonce;
const isTransactionExecuted = parsedNonce < safeNonce;

const history = useExecutedTransactions(safe);

Expand Down Expand Up @@ -111,7 +111,7 @@ const TransactionDetailsPage: FC<{

const hintData = parseHintedMulticall(safeTxn?.data as any);

const allowPublishing = hintData?.type == 'deploy';
const queuedWithGitOps = hintData?.type == 'deploy';

const cannonPackage = useCannonPackage(
hintData?.cannonPackage
Expand Down Expand Up @@ -141,7 +141,7 @@ const TransactionDetailsPage: FC<{
);

let prevDeployGitHash: string;
if (allowPublishing) {
if (queuedWithGitOps) {
prevDeployGitHash =
(hintData?.prevGitRepoHash || hintData?.gitRepoHash) ?? '';
} else {
Expand Down Expand Up @@ -181,7 +181,10 @@ const TransactionDetailsPage: FC<{

useEffect(
() => buildInfo.doBuild(),
[verify && (!prevDeployGitHash || prevCannonDeployInfo.ipfsQuery.isFetched)]
[
!isTransactionExecuted &&
(!prevDeployGitHash || prevCannonDeployInfo.ipfsQuery.isFetched),
]
);

// compare proposed build info with expected transaction batch
Expand Down Expand Up @@ -251,7 +254,7 @@ const TransactionDetailsPage: FC<{
cannonPackage={cannonPackage}
safeTxn={safeTxn}
published={existingRegistryUrl == hintData?.cannonPackage}
publishable={allowPublishing}
publishable={queuedWithGitOps}
signers={signers}
threshold={threshold}
/>
Expand All @@ -268,8 +271,9 @@ const TransactionDetailsPage: FC<{
<TransactionDisplay
safe={safe}
safeTxn={safeTxn as any}
allowPublishing={allowPublishing}
queuedWithGitOps={queuedWithGitOps}
showQueueSource={true}
isTransactionExecuted={isTransactionExecuted}
/>
<Box position="relative">
<Box position="sticky" top={8}>
Expand Down Expand Up @@ -324,20 +328,20 @@ const TransactionDetailsPage: FC<{
</Box>
))}

{verify && remainingSignatures > 0 && (
{!isTransactionExecuted && remainingSignatures > 0 && (
<Text fontWeight="bold" mt="3">
{remainingSignatures} additional{' '}
{remainingSignatures === 1 ? 'signature' : 'signatures'}{' '}
required
</Text>
)}

{verify && stager.alreadySigned && (
{!isTransactionExecuted && stager.alreadySigned && (
<Box mt={4}>
<Alert status="success">Transaction signed</Alert>
</Box>
)}
{verify && !stager.alreadySigned && (
{!isTransactionExecuted && !stager.alreadySigned && (
<Flex mt={4} gap={4}>
{account.isConnected &&
walletChainId === safe.chainId ? (
Expand Down Expand Up @@ -400,7 +404,7 @@ const TransactionDetailsPage: FC<{
)}
</Box>

{verify && allowPublishing && (
{!isTransactionExecuted && queuedWithGitOps && (
<Box
background="gray.800"
p={4}
Expand Down Expand Up @@ -492,7 +496,7 @@ const TransactionDetailsPage: FC<{
</Box>
)}

{allowPublishing && (
{queuedWithGitOps && (
<Box
background="gray.800"
p={4}
Expand Down
24 changes: 15 additions & 9 deletions packages/website/src/features/Deploy/TransactionDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ const parseDiffFileNames = (diffString: string): string[] => {
export function TransactionDisplay(props: {
safeTxn: SafeTransaction;
safe: SafeDefinition;
allowPublishing?: boolean;
queuedWithGitOps?: boolean;
showQueueSource?: boolean;
isTransactionExecuted?: boolean;
}) {
const { isOpen, onOpen, onClose } = useDisclosure();
const hintData = parseHintedMulticall(props.safeTxn?.data);
Expand All @@ -66,11 +67,12 @@ export function TransactionDisplay(props: {
hintData?.gitRepoUrl ?? ''
);

let prevDeployGitHash: string =
(hintData?.prevGitRepoHash || hintData?.gitRepoHash) ?? '';
// Determine whether we should use the hint data or the previous git info query
let prevDeployGitHash: string = hintData?.prevGitRepoHash ?? '';
if (
!props.allowPublishing &&
prevDeployHashQuery.data &&
props.queuedWithGitOps &&
!props.isTransactionExecuted &&
prevDeployHashQuery.data?.length &&
prevDeployHashQuery.data[0].result &&
((prevDeployHashQuery.data[0].result as any).length as number) > 2
) {
Expand Down Expand Up @@ -117,7 +119,7 @@ export function TransactionDisplay(props: {
return (
<Box maxW="100%" overflowX="auto">
{props.showQueueSource &&
(props.allowPublishing ? (
(props.queuedWithGitOps ? (
<>
<ChakraAlert
bg="gray.800"
Expand All @@ -144,9 +146,13 @@ export function TransactionDisplay(props: {
) : (
<>
These transactions were generated by{' '}
<Link onClick={onOpen}>
modifying {diffFiles?.length} cannonfiles
</Link>{' '}
{diffFiles?.length ? (
<Link onClick={onOpen}>
modifying {diffFiles?.length} cannonfiles
</Link>
) : (
'modifying cannonfiles'
)}{' '}
in{' '}
<Link isExternal href={gitUrl}>
this repository
Expand Down

0 comments on commit 2d325ec

Please sign in to comment.