Skip to content

Commit

Permalink
fix(builder): Add contract address for create2 on alter import (#1254)
Browse files Browse the repository at this point in the history
  • Loading branch information
FuzzB0t authored Aug 14, 2024
1 parent c733fc8 commit 51e3dc0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/builder/src/steps/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,13 +414,17 @@ const deploySpec = {

const txn = await runtime.provider.getTransactionReceipt({ hash: existingKeys[0] as viem.Hash });

if (!txn.contractAddress) {
// When a CREATE2 contract is deployed, it doesnt output the contractAddress property.
// However the txn will emit events from the deployed contract address which can be found in the txn logs
const contractAddress = config.create2 ? txn.logs[0].address : txn.contractAddress;

if (!viem.isAddress(contractAddress as string)) {
throw new Error('imported txn does not appear to deploy a contract');
}

const block = await runtime.provider.getBlock({ blockNumber: txn?.blockNumber });

return generateOutputs(config, ctx, artifactData, txn, block, txn.contractAddress!, packageState.currentLabel);
return generateOutputs(config, ctx, artifactData, txn, block, contractAddress!, packageState.currentLabel);
},
};

Expand Down

0 comments on commit 51e3dc0

Please sign in to comment.