diff --git a/packages/core/src/list-transactions.ts b/packages/core/src/list-transactions.ts index 74b39154b..d83d8d6ae 100644 --- a/packages/core/src/list-transactions.ts +++ b/packages/core/src/list-transactions.ts @@ -3,6 +3,7 @@ import type { ArtifactResolver } from "./types/artifact"; import findLastIndex from "lodash/findLastIndex"; import { IgnitionError } from "./errors"; +import { builtinChains } from "./internal/chain-config"; import { FileDeploymentLoader } from "./internal/deployment-loader/file-deployment-loader"; import { ERRORS } from "./internal/errors-list"; import { loadDeploymentState } from "./internal/execution/deployment-state-helpers"; @@ -76,6 +77,10 @@ export async function listTransactions( (tx) => tx.hash === message.transaction.hash ); + const browserUrl = builtinChains.find( + ({ chainId }) => chainId === deploymentState.chainId + ); + const transaction = networkInteraction.transactions[lastTxIndex]; switch (exState.type) { @@ -97,6 +102,7 @@ export async function listTransactions( : undefined, params: exState.constructorArgs, value: networkInteraction.value, + browserUrl: browserUrl?.urls.browserURL, }); break; @@ -118,6 +124,7 @@ export async function listTransactions( to: networkInteraction.to, params: exState.args, value: networkInteraction.value, + browserUrl: browserUrl?.urls.browserURL, }); break; @@ -133,6 +140,7 @@ export async function listTransactions( ), to: networkInteraction.to, value: networkInteraction.value, + browserUrl: browserUrl?.urls.browserURL, }); break; diff --git a/packages/core/src/types/list-transactions.ts b/packages/core/src/types/list-transactions.ts index 81aafa37a..d84ad5fbb 100644 --- a/packages/core/src/types/list-transactions.ts +++ b/packages/core/src/types/list-transactions.ts @@ -27,6 +27,7 @@ export interface TransactionInfo { address?: string; params?: SolidityParameterType[]; value?: bigint; + browserUrl?: string; } /** diff --git a/packages/core/test/list-transactions.ts b/packages/core/test/list-transactions.ts index 796cf0611..4b10f7464 100644 --- a/packages/core/test/list-transactions.ts +++ b/packages/core/test/list-transactions.ts @@ -22,6 +22,7 @@ describe("listTransactions", () => { address: "0x74e720c9B362ae3A65fF356ad62866511486BBBc", params: ["0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266"], value: 0n, + browserUrl: undefined, }, { type: "DEPLOYMENT_EXECUTION_STATE", @@ -33,6 +34,7 @@ describe("listTransactions", () => { address: "0x1c947344BA932fC7f3D622600dA0199520A67EFd", params: [], value: 0n, + browserUrl: undefined, }, { type: "DEPLOYMENT_EXECUTION_STATE", @@ -44,6 +46,7 @@ describe("listTransactions", () => { address: "0xBdAce15b3211019E272418B8014971c1cefbC8f0", params: [], value: 0n, + browserUrl: undefined, }, { type: "CALL_EXECUTION_STATE", @@ -55,6 +58,7 @@ describe("listTransactions", () => { to: "0x74e720c9B362ae3A65fF356ad62866511486BBBc", params: [40], value: 0n, + browserUrl: undefined, }, { type: "DEPLOYMENT_EXECUTION_STATE", @@ -66,6 +70,7 @@ describe("listTransactions", () => { address: "0xD369D9aB22D85C2A12bEabc0B581a419789E3755", params: [], value: 0n, + browserUrl: undefined, }, { type: "SEND_DATA_EXECUTION_STATE", @@ -75,6 +80,7 @@ describe("listTransactions", () => { status: TransactionStatus.SUCCESS, to: "0x74e720c9B362ae3A65fF356ad62866511486BBBc", value: 123n, + browserUrl: undefined, }, ]; diff --git a/packages/hardhat-plugin/src/index.ts b/packages/hardhat-plugin/src/index.ts index 133df4e0e..e64ef4cc6 100644 --- a/packages/hardhat-plugin/src/index.ts +++ b/packages/hardhat-plugin/src/index.ts @@ -58,6 +58,7 @@ extendConfig((config, userConfig) => { maxPriorityFeePerGas: userNetworkConfig.ignition?.maxPriorityFeePerGas, gasPrice: userNetworkConfig.ignition?.gasPrice, disableFeeBumping: userNetworkConfig.ignition?.disableFeeBumping, + explorerUrl: userNetworkConfig.ignition?.explorerUrl, }; }); @@ -717,7 +718,11 @@ ignitionScope } console.log( - calculateListTransactionsDisplay(deploymentId, listTransactionsResult) + calculateListTransactionsDisplay( + deploymentId, + listTransactionsResult, + hre.config.networks[hre.network.name]?.ignition?.explorerUrl + ) ); }); diff --git a/packages/hardhat-plugin/src/type-extensions.ts b/packages/hardhat-plugin/src/type-extensions.ts index e79353260..3a0c6cda8 100644 --- a/packages/hardhat-plugin/src/type-extensions.ts +++ b/packages/hardhat-plugin/src/type-extensions.ts @@ -19,6 +19,7 @@ declare module "hardhat/types/config" { maxPriorityFeePerGas?: bigint; gasPrice?: bigint; disableFeeBumping?: boolean; + explorerUrl?: string; }; } @@ -28,6 +29,7 @@ declare module "hardhat/types/config" { maxPriorityFeePerGas?: bigint; gasPrice?: bigint; disableFeeBumping?: boolean; + explorerUrl?: string; }; } @@ -37,6 +39,7 @@ declare module "hardhat/types/config" { maxPriorityFeePerGas?: bigint; gasPrice?: bigint; disableFeeBumping?: boolean; + explorerUrl?: string; }; } @@ -46,6 +49,7 @@ declare module "hardhat/types/config" { maxPriorityFeePerGas?: bigint; gasPrice?: bigint; disableFeeBumping?: boolean; + explorerUrl?: string; }; } diff --git a/packages/hardhat-plugin/src/ui/helpers/calculate-list-transactions-display.ts b/packages/hardhat-plugin/src/ui/helpers/calculate-list-transactions-display.ts index 78b6bb717..4bb9c839d 100644 --- a/packages/hardhat-plugin/src/ui/helpers/calculate-list-transactions-display.ts +++ b/packages/hardhat-plugin/src/ui/helpers/calculate-list-transactions-display.ts @@ -4,12 +4,18 @@ import { stringify } from "json5"; export function calculateListTransactionsDisplay( deploymentId: string, - listTransactionsResult: ListTransactionsResult + listTransactionsResult: ListTransactionsResult, + configUrl?: string ): string { let text = `Logging transactions for deployment ${deploymentId}\n\n`; for (const [index, transaction] of listTransactionsResult.entries()) { - text += `Transaction ${index + 1}:\n`; + const txLink = getTransactionLink( + transaction.txHash, + configUrl ?? transaction.browserUrl + ); + + text += `Transaction ${index + 1}${txLink === undefined ? "" : txLink}:\n`; text += ` - Type: ${transactionTypeToDisplayType(transaction.type)}\n`; text += ` - Status: ${transaction.status}\n`; text += ` - TxHash: ${transaction.txHash}\n`; @@ -70,3 +76,14 @@ export function transactionDisplaySerializeReplacer( return value; } + +function getTransactionLink( + txHash: string, + browserURL?: string +): string | undefined { + if (browserURL === undefined) { + return undefined; + } + + return `\x1b]8;;${browserURL}/tx/${txHash}\x1b\\ (🔗 view on block explorer)\x1b]8;;\x1b\\`; +}