Skip to content

Commit

Permalink
Merge pull request #48 from ethereum-optimism/01-14-fix_allow_verifyi…
Browse files Browse the repository at this point in the history
…ng_from_interactive_mode_for_deploy

fix: allow verifying from interactive mode for deploy
  • Loading branch information
jakim929 authored Jan 15, 2025
2 parents 88fcaa1 + 2f100de commit d97d072
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {SelectChains} from '@/deploy-create2-wizard/SelectChains';
import {getArtifactPathForContract} from '@/forge/foundryProject';
import {useSaveWizardProgress} from '@/hooks/useSaveWizardProgress';
import {DeployCreate2Command} from '@/deploy-create2/DeployCreate2Command';
import {ShouldVerifyContract} from '@/deploy-create2-wizard/ShouldVerifyContract';

type StepStatus = 'done' | 'current' | 'upcoming';

Expand Down Expand Up @@ -116,6 +117,7 @@ export const DeployCreate2Wizard = () => {
),
constructorArgs: wizardState.constructorArgs.join(','),
network: wizardState.network,
verify: wizardState.shouldVerifyContract,
};

return <DeployCreate2Command options={options} />;
Expand All @@ -135,6 +137,7 @@ export const DeployCreate2Wizard = () => {
{stepId === 'configure-salt' && <ConfigureSalt />}
{stepId === 'select-network' && <SelectNetwork />}
{stepId === 'select-chains' && <SelectChains />}
{stepId === 'should-verify-contract' && <ShouldVerifyContract />}
</Box>
);
};
26 changes: 26 additions & 0 deletions packages/cli/src/deploy-create2-wizard/ShouldVerifyContract.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import {useDeployCreate2WizardStore} from '@/deploy-create2-wizard/deployCreate2WizardStore';
import {ConfirmInput} from '@inkjs/ui';
import {Box, Text} from 'ink';

export const ShouldVerifyContract = () => {
const {wizardState, submitShouldVerifyContract} =
useDeployCreate2WizardStore();

if (wizardState.stepId !== 'should-verify-contract') {
throw new Error('Invalid state');
}

return (
<Box paddingX={1} gap={1}>
<Text>Do you want to verify the contract on the block explorer?</Text>
<ConfirmInput
onConfirm={() => {
submitShouldVerifyContract({shouldVerifyContract: true});
}}
onCancel={() => {
submitShouldVerifyContract({shouldVerifyContract: false});
}}
/>
</Box>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,14 @@ const deployCreate2WizardStore = defineWizard()
title: 'Select Chains',
getSummary: state => state.chainNames.join(', '),
})
// .addStep({
// id: 'enter-private-key',
// schema: z.object({
// privateKey: zodHex,
// address: zodAddress,
// }),
// title: 'Enter Private Key',
// getSummary: state => `${state.address}`,
// })
.addStep({
id: 'should-verify-contract',
schema: z.object({
shouldVerifyContract: z.boolean(),
}),
title: 'Verify Contract',
getSummary: state => (state.shouldVerifyContract ? 'Yes' : 'No'),
})
.build();

export type DeployCreate2WizardStore = typeof deployCreate2WizardStore;
Expand Down
24 changes: 23 additions & 1 deletion packages/cli/src/queries/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,25 @@ import {querySuperchainRegistryChainList} from '@/queries/superchainRegistryChai
import {SuperchainRegistryAddresses} from '@/superchain-registry/fetchSuperchainRegistryAddresses';
import {ChainListItem} from '@/superchain-registry/fetchSuperchainRegistryChainList';
import {chainConfig} from 'viem/op-stack';
import {mainnet, sepolia} from 'viem/chains';
import {
base,
baseSepolia,
mainnet,
optimism,
optimismSepolia,
sepolia,
} from 'viem/chains';
import {defineChain} from 'viem';
import {queryClient} from '@/commands/_app';
import {viemChainById} from '@/viemChainById';

const TEMP_overrideBlockExplorerUrlByChainId = {
[baseSepolia.id]: 'https://base-sepolia.blockscout.com/',
[base.id]: 'https://base.blockscout.com/',
[optimismSepolia.id]: 'https://optimism-sepolia.blockscout.com/',
[optimism.id]: 'https://optimism.blockscout.com/',
} as Record<number, string>;

const chainIdByParentChainName = {
mainnet: mainnet.id,
sepolia: sepolia.id,
Expand All @@ -34,6 +48,14 @@ const toViemChain = (
},
},
},
blockExplorers: {
default: {
name: 'Blockscout',
url:
TEMP_overrideBlockExplorerUrlByChainId[chainId] ??
(chainListItem.explorers[0] as string),
},
},
};

const viemChain = viemChainById[chainListItem.chainId];
Expand Down

0 comments on commit d97d072

Please sign in to comment.