Skip to content

Commit

Permalink
Merge pull request sphinx-labs#582 from chugsplash/sg/rollback
Browse files Browse the repository at this point in the history
fix(ct): allow bundles to be proposed after being completed or cancelled
  • Loading branch information
sam-goldman authored Apr 1, 2023
2 parents 44ac97d + b204c6e commit 66069fd
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 29 deletions.
6 changes: 6 additions & 0 deletions .changeset/polite-peas-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@chugsplash/contracts': patch
'@chugsplash/core': patch
---

Allow bundles to be proposed after being completed or cancelled
14 changes: 7 additions & 7 deletions packages/contracts/contracts/ChugSplashManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,12 @@ contract ChugSplashManager is OwnableUpgradeable, ReentrancyGuardUpgradeable {
);
ChugSplashBundleState storage bundle = _bundles[bundleId];

ChugSplashBundleStatus status = bundle.status;
require(
bundle.status == ChugSplashBundleStatus.EMPTY,
"ChugSplashManager: bundle already exists"
status == ChugSplashBundleStatus.EMPTY ||
status == ChugSplashBundleStatus.COMPLETED ||
status == ChugSplashBundleStatus.CANCELLED,
"ChugSplashManager: bundle cannot be proposed"
);

bundle.status = ChugSplashBundleStatus.PROPOSED;
Expand Down Expand Up @@ -471,12 +474,9 @@ contract ChugSplashManager is OwnableUpgradeable, ReentrancyGuardUpgradeable {

ChugSplashBundleState storage bundle = _bundles[_bundleId];

ChugSplashBundleStatus status = bundle.status;
require(
status == ChugSplashBundleStatus.PROPOSED ||
status == ChugSplashBundleStatus.COMPLETED ||
status == ChugSplashBundleStatus.CANCELLED,
"ChugSplashManager: bundle cannot be approved"
bundle.status == ChugSplashBundleStatus.PROPOSED,
"ChugSplashManager: bundle must be proposed"
);

require(
Expand Down
39 changes: 17 additions & 22 deletions packages/core/src/tasks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,19 +169,16 @@ export const chugsplashProposeAbstractTask = async (
)

const networkName = await resolveNetworkName(provider, integration)
if (bundleState.status === ChugSplashBundleStatus.APPROVED) {
if (
bundleState.status === ChugSplashBundleStatus.APPROVED ||
bundleState.status === ChugSplashBundleStatus.INITIATED
) {
spinner.fail(
`Project was already proposed and is currently being executed on ${networkName}.`
)
} else if (bundleState.status === ChugSplashBundleStatus.COMPLETED) {
spinner.fail(`Project was already completed on ${networkName}.`)
} else if (bundleState.status === ChugSplashBundleStatus.CANCELLED) {
throw new Error(
`Project was already cancelled on ${networkName}. Please propose a new project
with a name other than ${parsedConfig.options.projectName}`
)
} else {
// Bundle is either in the `EMPTY` or `PROPOSED` state.
// If we make it to this point, we know that the bundle is either currently proposed or can be
// proposed.

// Get the amount that the user must send to the ChugSplashManager to execute the bundle
// including a buffer in case the gas price increases during execution.
Expand All @@ -193,10 +190,18 @@ with a name other than ${parsedConfig.options.projectName}`
true
)

if (bundleState.status === ChugSplashBundleStatus.EMPTY) {
spinner.succeed(
`${parsedConfig.options.projectName} has not been proposed before.`
if (bundleState.status === ChugSplashBundleStatus.PROPOSED) {
spinner.fail(
await alreadyProposedMessage(
provider,
amountToDeposit,
configPath,
integration
)
)
} else {
spinner.succeed(`${parsedConfig.options.projectName} can be proposed.`)
spinner.start(`Proposing ${parsedConfig.options.projectName}...`)

await proposeChugSplashBundle(
provider,
Expand All @@ -218,16 +223,6 @@ with a name other than ${parsedConfig.options.projectName}`
integration
)
spinner.succeed(message)
} else {
// Bundle was already in the `PROPOSED` state before the call to this task.
spinner.fail(
await alreadyProposedMessage(
provider,
amountToDeposit,
configPath,
integration
)
)
}
}
}
Expand Down

0 comments on commit 66069fd

Please sign in to comment.