diff --git a/package.json b/package.json index d490d90..e1f00e4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@0xmetropolis/metal", - "version": "0.8.3", - "description": "Smart contract visualization tool.", + "version": "0.9.0", + "description": "Smart contract deployment tool.", "author": "Metropolis (@0xmetropolis)", "bin": { "metal": "./bin/run" diff --git a/src/commands/preview.ts b/src/commands/preview.ts index 0572733..3da5629 100644 --- a/src/commands/preview.ts +++ b/src/commands/preview.ts @@ -82,7 +82,13 @@ async function validateInputs({ _: [, scriptPath], 'chain-id': chainId }: Handle } // @dev pulls any args from process.argv and replaces any fork-url aliases with the preview-service's fork url -export const configureForgeScriptInputs = ({ rpcUrl }: { rpcUrl: string }): string[] => { +export const configureForgeScriptInputs = ({ + rpcUrl, + previewId, +}: { + rpcUrl: string; + previewId: string; +}): string[] => { // pull anything after `metal preview ` as forge arguments let forgeArguments = process.argv.slice(3); // rewrap function signatures in quotes, ex: --sig "run()" @@ -123,6 +129,14 @@ export const configureForgeScriptInputs = ({ rpcUrl }: { rpcUrl: string }): stri if (!forgeArguments.includes('--broadcast')) forgeArguments.push('--broadcast'); if (!forgeArguments.includes('--slow')) forgeArguments.push('--slow'); + if (forgeArguments.includes('--verify') || forgeArguments.includes('--verifier-url')) + throw Error( + 'Must verify contracts against the metal backend, please do not include --verify or --verifier-url flags', + ); + forgeArguments.push( + `--verify --verifier-url ${METAL_SERVICE_URL}/contracts/verification/${previewId} --etherscan-api-key null`, + ); + return forgeArguments; }; @@ -137,7 +151,7 @@ export const sendDataToMetalService = async ( ? authenticationStatus.access_token : undefined; - let headers: HeadersInit = { + const headers: HeadersInit = { 'Content-Type': 'application/json', }; if (authToken) headers['Authorization'] = `Bearer ${authToken}`; @@ -192,6 +206,7 @@ export const handler = async (yargs: HandlerInput) => { logInfo(`Running Forge Script at ${forgeScriptPath}...`); const foundryArguments = configureForgeScriptInputs({ rpcUrl: yargs['UNSAFE-RPC-OVERRIDE'] ?? rpcUrl, + previewId, }); await runForgeScriptForPreviewCommand(foundryArguments); diff --git a/src/utils/foundry.ts b/src/utils/foundry.ts index 530cff2..8597a77 100644 --- a/src/utils/foundry.ts +++ b/src/utils/foundry.ts @@ -226,6 +226,7 @@ const mutateForgeMessages = (msg: string | number | bigint | boolean | object): // search the output for messages that should be filtered if (msgAsString.includes('Sending transactions')) return ''; + if (msgAsString.includes('Total Paid')) return ''; if (msgAsString.includes('txes (') && msgAsString.includes('[00:0')) return ''; else if (msgAsString.includes('ONCHAIN EXECUTION COMPLETE & SUCCESSFUL.')) return msgAsString.replace('ONCHAIN EXECUTION COMPLETE & SUCCESSFUL.\n', ''); @@ -246,7 +247,12 @@ const watchForgeOutput = ( const magicEmojis = ['🧙', '🪄', '🧚', '✨']; stdout.on('data', (chunk: any) => { - // if the chunk contains the succes label, then it's related to a transaction + if (chunk.toString().includes('Start verification for')) { + logInfo('Submitting contract verification to metal ⛓️...\n\n'); + return; + } + + // if the chunk contains the success label, then it's related to a transaction if (chunk.toString().includes('[Success]Hash')) { // increment the transaction counter state.transactionCounter++; @@ -256,11 +262,12 @@ const watchForgeOutput = ( state.transactionCounter + '...', ); - } else { - // otherwise, use the normal filter flow - const msg = mutateForgeMessages(chunk); - if (msg) logInfo(msg); + return; } + + // otherwise, use the normal filter flow + const msg = mutateForgeMessages(chunk); + if (msg) logInfo(msg); }); };