Skip to content

Commit

Permalink
Reorder logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ericglau committed Dec 8, 2023
1 parent c4d2ee9 commit f64fbb5
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions packages/core/src/impl-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,19 @@ async function checkForAddressClash(
updated: Deployment & RemoteDeploymentId,
merge: boolean,
): Promise<void> {
// merge only checks primary addresses for clashes, since the address could already exist in an allAddresses field
// but the updated and stored objects are different instances representing the same entry. It still checks for clashes
// in case it's a development network, so that we can delete deployments from older runs.
const clash = lookupDeployment(data, updated.address, !merge);
if (clash !== undefined) {
if (await isDevelopmentNetwork(provider)) {
let clash;
if (await isDevelopmentNetwork(provider)) {
// Look for clashes so that we can delete deployments from older runs.
// `merge` only checks primary addresses for clashes, since the address could already exist in an allAddresses field
// but the updated and stored objects are different instances representing the same entry.
clash = lookupDeployment(data, updated.address, !merge);
if (clash !== undefined) {
debug('deleting a previous deployment at address', updated.address);
clash.set(undefined);
} else if (!merge) {
}
} else if (!merge) {
clash = lookupDeployment(data, updated.address, true);
if (clash !== undefined) {
const existing = clash.get();
// it's a clash if there is no deployment id or if deployment ids don't match
if (
Expand All @@ -249,8 +253,8 @@ async function checkForAddressClash(
`New deployment: ${JSON.stringify(updated, null, 2)}\n\n`,
);
}
} // else, merge indicates that the user is force-importing or redeploying an implementation, so we simply allow merging the entries
}
}
} // else, merge indicates that the user is force-importing or redeploying an implementation, so we simply allow merging the entries
}

function lookupDeployment(
Expand Down

0 comments on commit f64fbb5

Please sign in to comment.