Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(solidity-devops): correctly save new deployments when script entry function is not run() #2883

Merged
merged 3 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/solidity-devops/js/forgeScriptRun.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ if (newDeployments.length === 0) {
logInfo('No new deployments found')
process.exit(0)
}
const newReceipts = getNewDeploymentReceipts(chainName, scriptFN)
const newReceipts = getNewDeploymentReceipts(
chainName,
scriptFN,
currentTimestamp
)
newDeployments.forEach((contractAlias) =>
saveNewDeployment(chainName, contractAlias, newReceipts)
)
18 changes: 15 additions & 3 deletions packages/solidity-devops/js/utils/deployments.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,23 @@ const getAllDeploymentReceipts = (chainName) => {
})
}

const getNewDeploymentReceipts = (chainName, scriptFN) => {
const getNewDeploymentReceipts = (chainName, scriptFN, timestamp) => {
const chainId = getChainId(chainName)
const scriptBaseName = path.basename(scriptFN)
const broadcastFN = `broadcast/${scriptBaseName}/${chainId}/run-latest.json`
return extractDeploymentReceipts(broadcastFN)
const broadcastDir = path.join('broadcast', scriptBaseName, chainId)
// Look for "*-latest.json" files created after the given timestamp.
// These are named after the script entry function, which is usually "run", but could be different.
// In practice there should be only one file, but we implement a generic logic just in case.
return fs
.readdirSync(broadcastDir)
.filter((fn) => {
if (!fn.endsWith('-latest.json')) {
return false
}
const stats = fs.statSync(path.join(broadcastDir, fn))
return stats.mtimeMs > timestamp
})
.flatMap((fn) => extractDeploymentReceipts(path.join(broadcastDir, fn)))
ChiTimesChi marked this conversation as resolved.
Show resolved Hide resolved
}

const extractDeploymentReceipts = (broadcastFN) => {
Expand Down
Loading