@openzeppelin/upgrades-core 1.32.0-alpha.0 → 1.32.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/artifacts/@openzeppelin/contracts-v5/proxy/beacon/UpgradeableBeacon.sol/UpgradeableBeacon.json +2 -2
- package/artifacts/@openzeppelin/contracts-v5/proxy/transparent/ProxyAdmin.sol/ProxyAdmin.json +2 -2
- package/artifacts/@openzeppelin/contracts-v5/proxy/transparent/TransparentUpgradeableProxy.sol/TransparentUpgradeableProxy.json +2 -2
- package/artifacts/build-info-v5.json +30 -30
- package/dist/cli/cli.test.js +14 -0
- package/dist/cli/cli.test.js.map +1 -1
- package/dist/cli/validate/contract-report.js +2 -2
- package/dist/cli/validate/contract-report.js.map +1 -1
- package/dist/impl-store.d.ts.map +1 -1
- package/dist/impl-store.js +24 -14
- package/dist/impl-store.js.map +1 -1
- package/dist/impl-store.test.js +73 -4
- package/dist/impl-store.test.js.map +1 -1
- package/package.json +3 -3
- package/src/cli/cli.test.ts +24 -0
- package/src/cli/cli.test.ts.md +18 -0
- package/src/cli/cli.test.ts.snap +0 -0
- package/src/cli/validate/contract-report.ts +2 -2
- package/src/impl-store.test.ts +128 -4
- package/src/impl-store.ts +27 -16
package/src/impl-store.ts
CHANGED
|
@@ -72,12 +72,10 @@ async function fetchOrDeployGeneric<T extends Deployment, U extends T = T>(
|
|
|
72
72
|
);
|
|
73
73
|
if (updated !== stored) {
|
|
74
74
|
if (merge && deployment.merge) {
|
|
75
|
-
|
|
76
|
-
// but the above updated and stored objects are different instances representing the same entry
|
|
77
|
-
await checkForAddressClash(provider, data, updated, false);
|
|
75
|
+
await checkForAddressClash(provider, data, updated, true);
|
|
78
76
|
deployment.merge(updated);
|
|
79
77
|
} else {
|
|
80
|
-
await checkForAddressClash(provider, data, updated,
|
|
78
|
+
await checkForAddressClash(provider, data, updated, false);
|
|
81
79
|
deployment.set(updated);
|
|
82
80
|
}
|
|
83
81
|
await manifest.write(data);
|
|
@@ -172,12 +170,17 @@ export async function fetchOrDeployGetDeployment<T extends ImplDeployment>(
|
|
|
172
170
|
const implLens = (versionWithoutMetadata: string) =>
|
|
173
171
|
lens(`implementation ${versionWithoutMetadata}`, 'implementation', data => ({
|
|
174
172
|
get: () => data.impls[versionWithoutMetadata],
|
|
175
|
-
set: (value?: ImplDeployment) => (data.impls[versionWithoutMetadata] = value),
|
|
176
|
-
merge: (value?: ImplDeployment) => {
|
|
173
|
+
set: (value?: ImplDeployment & RemoteDeploymentId) => (data.impls[versionWithoutMetadata] = value),
|
|
174
|
+
merge: (value?: ImplDeployment & RemoteDeploymentId) => {
|
|
177
175
|
const existing = data.impls[versionWithoutMetadata];
|
|
178
176
|
if (existing !== undefined && value !== undefined) {
|
|
179
177
|
const { address, allAddresses } = mergeAddresses(existing, value);
|
|
180
|
-
data.impls[versionWithoutMetadata] = {
|
|
178
|
+
data.impls[versionWithoutMetadata] = {
|
|
179
|
+
...existing,
|
|
180
|
+
address,
|
|
181
|
+
allAddresses,
|
|
182
|
+
remoteDeploymentId: value.remoteDeploymentId,
|
|
183
|
+
};
|
|
181
184
|
} else {
|
|
182
185
|
data.impls[versionWithoutMetadata] = value;
|
|
183
186
|
}
|
|
@@ -223,14 +226,23 @@ async function checkForAddressClash(
|
|
|
223
226
|
provider: EthereumProvider,
|
|
224
227
|
data: ManifestData,
|
|
225
228
|
updated: Deployment & RemoteDeploymentId,
|
|
226
|
-
|
|
229
|
+
merge: boolean,
|
|
227
230
|
): Promise<void> {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
+
let clash;
|
|
232
|
+
const findClash = () => lookupDeployment(data, updated.address, !merge);
|
|
233
|
+
|
|
234
|
+
if (await isDevelopmentNetwork(provider)) {
|
|
235
|
+
// Look for clashes so that we can delete deployments from older runs.
|
|
236
|
+
// `merge` only checks primary addresses for clashes, since the address could already exist in an allAddresses field
|
|
237
|
+
// but the updated and stored objects are different instances representing the same entry.
|
|
238
|
+
clash = findClash();
|
|
239
|
+
if (clash !== undefined) {
|
|
231
240
|
debug('deleting a previous deployment at address', updated.address);
|
|
232
241
|
clash.set(undefined);
|
|
233
|
-
}
|
|
242
|
+
}
|
|
243
|
+
} else if (!merge) {
|
|
244
|
+
clash = findClash();
|
|
245
|
+
if (clash !== undefined) {
|
|
234
246
|
const existing = clash.get();
|
|
235
247
|
// it's a clash if there is no deployment id or if deployment ids don't match
|
|
236
248
|
if (
|
|
@@ -238,13 +250,12 @@ async function checkForAddressClash(
|
|
|
238
250
|
(existing.remoteDeploymentId === undefined || existing.remoteDeploymentId !== updated.remoteDeploymentId)
|
|
239
251
|
) {
|
|
240
252
|
throw new Error(
|
|
241
|
-
`The
|
|
242
|
-
JSON.stringify(updated, null, 2)
|
|
243
|
-
`\n\n`,
|
|
253
|
+
`The deployment clashes with an existing one at ${updated.address}.\n\n` +
|
|
254
|
+
`Deployments: ${JSON.stringify({ existing, updated }, null, 2)}\n\n`,
|
|
244
255
|
);
|
|
245
256
|
}
|
|
246
257
|
}
|
|
247
|
-
}
|
|
258
|
+
} // else, merge indicates that the user is force-importing or redeploying an implementation, so we simply allow merging the entries
|
|
248
259
|
}
|
|
249
260
|
|
|
250
261
|
function lookupDeployment(
|