@openzeppelin/upgrades-core 1.24.1 → 1.26.0

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.
Files changed (53) hide show
  1. package/artifacts/build-info.json +21465 -0
  2. package/dist/deployment.d.ts +28 -4
  3. package/dist/deployment.d.ts.map +1 -1
  4. package/dist/deployment.js +106 -25
  5. package/dist/deployment.js.map +1 -1
  6. package/dist/deployment.test.js +116 -0
  7. package/dist/deployment.test.js.map +1 -1
  8. package/dist/impl-store.d.ts +27 -2
  9. package/dist/impl-store.d.ts.map +1 -1
  10. package/dist/impl-store.js +39 -8
  11. package/dist/impl-store.js.map +1 -1
  12. package/dist/impl-store.test.js +30 -0
  13. package/dist/impl-store.test.js.map +1 -1
  14. package/dist/index.d.ts +1 -1
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +2 -1
  17. package/dist/index.js.map +1 -1
  18. package/dist/manifest.d.ts +3 -3
  19. package/dist/manifest.d.ts.map +1 -1
  20. package/dist/manifest.js +1 -1
  21. package/dist/manifest.js.map +1 -1
  22. package/dist/manifest.test.js +1 -0
  23. package/dist/manifest.test.js.map +1 -1
  24. package/dist/provider.d.ts.map +1 -1
  25. package/dist/provider.js +4 -0
  26. package/dist/provider.js.map +1 -1
  27. package/dist/usage-error.d.ts +6 -0
  28. package/dist/usage-error.d.ts.map +1 -1
  29. package/dist/usage-error.js +10 -1
  30. package/dist/usage-error.js.map +1 -1
  31. package/dist/validate/error.d.ts +3 -0
  32. package/dist/validate/error.d.ts.map +1 -1
  33. package/dist/validate/error.js +7 -1
  34. package/dist/validate/error.js.map +1 -1
  35. package/dist/validate/index.d.ts +1 -1
  36. package/dist/validate/index.d.ts.map +1 -1
  37. package/dist/validate/index.js +2 -1
  38. package/dist/validate/index.js.map +1 -1
  39. package/dist/validate/query.js +1 -1
  40. package/dist/validate/query.js.map +1 -1
  41. package/package.json +3 -2
  42. package/src/deployment.test.ts +182 -1
  43. package/src/deployment.ts +134 -26
  44. package/src/impl-store.test.ts +52 -1
  45. package/src/impl-store.ts +69 -11
  46. package/src/index.ts +1 -0
  47. package/src/manifest.test.ts +1 -0
  48. package/src/manifest.ts +11 -8
  49. package/src/provider.ts +4 -0
  50. package/src/usage-error.ts +13 -0
  51. package/src/validate/error.ts +6 -0
  52. package/src/validate/index.ts +1 -1
  53. package/src/validate/query.ts +2 -2
package/src/manifest.ts CHANGED
@@ -5,7 +5,7 @@ import { EthereumProvider, getChainId, getHardhatMetadata, networkNames } from '
5
5
  import lockfile from 'proper-lockfile';
6
6
  import { compare as compareVersions } from 'compare-versions';
7
7
 
8
- import type { Deployment } from './deployment';
8
+ import type { Deployment, RemoteDeploymentId } from './deployment';
9
9
  import type { StorageLayout } from './storage';
10
10
  import { pick } from './utils/pick';
11
11
  import { mapValues } from './utils/map-values';
@@ -18,9 +18,9 @@ const currentManifestVersion = '3.2';
18
18
  export interface ManifestData {
19
19
  manifestVersion: string;
20
20
  impls: {
21
- [version in string]?: ImplDeployment;
21
+ [version in string]?: ImplDeployment & RemoteDeploymentId;
22
22
  };
23
- proxies: ProxyDeployment[];
23
+ proxies: (ProxyDeployment & RemoteDeploymentId)[];
24
24
  admin?: Deployment;
25
25
  }
26
26
 
@@ -318,11 +318,14 @@ export function normalizeManifestData(input: ManifestData): ManifestData {
318
318
  };
319
319
  }
320
320
 
321
- function normalizeDeployment<D extends Deployment>(input: D): Deployment;
322
- function normalizeDeployment<D extends Deployment, K extends keyof D>(input: D, include: K[]): Deployment & Pick<D, K>;
323
- function normalizeDeployment<D extends Deployment, K extends keyof D>(
321
+ function normalizeDeployment<D extends Deployment & RemoteDeploymentId>(input: D): Deployment & RemoteDeploymentId;
322
+ function normalizeDeployment<D extends Deployment & RemoteDeploymentId, K extends keyof D>(
323
+ input: D,
324
+ include: K[],
325
+ ): Deployment & RemoteDeploymentId & Pick<D, K>;
326
+ function normalizeDeployment<D extends Deployment & RemoteDeploymentId, K extends keyof D>(
324
327
  input: D,
325
328
  include: K[] = [],
326
- ): Deployment & Pick<D, K> {
327
- return pick(input, ['address', 'txHash', ...include]);
329
+ ): Deployment & RemoteDeploymentId & Pick<D, K> {
330
+ return pick(input, ['address', 'txHash', 'remoteDeploymentId', ...include]);
328
331
  }
package/src/provider.ts CHANGED
@@ -127,10 +127,14 @@ export const networkNames: { [chainId in number]?: string } = Object.freeze({
127
127
  137: 'polygon',
128
128
  420: 'optimism-goerli',
129
129
  80001: 'polygon-mumbai',
130
+ 42161: 'arbitrum-one',
131
+ 42170: 'arbitrum-nova',
132
+ 421613: 'arbitrum-goerli',
130
133
  43113: 'avalanche-fuji',
131
134
  43114: 'avalanche',
132
135
  42220: 'celo',
133
136
  44787: 'celo-alfajores',
137
+ 11155111: 'sepolia',
134
138
  });
135
139
 
136
140
  export async function isDevelopmentNetwork(provider: EthereumProvider): Promise<boolean> {
@@ -42,6 +42,9 @@ export class LoadProxyUnsupportedError extends UpgradesError {
42
42
  }
43
43
  }
44
44
 
45
+ /**
46
+ * @deprecated No longer used since prepareUpgrade() supports using an implementation contract as the reference address.
47
+ */
45
48
  export class PrepareUpgradeUnsupportedError extends UpgradesError {
46
49
  constructor(proxyOrBeaconAddress: string) {
47
50
  super(
@@ -82,6 +85,16 @@ export class ValidateUpdateRequiresKindError extends UpgradesError {
82
85
  }
83
86
  }
84
87
 
88
+ export class PrepareUpgradeRequiresKindError extends UpgradesError {
89
+ constructor() {
90
+ super(
91
+ 'The `kind` option must be provided',
92
+ () =>
93
+ 'When preparing an upgrade from an implementation address, pass in the `kind` option for the kind of proxy that you are using.',
94
+ );
95
+ }
96
+ }
97
+
85
98
  export async function assertNotProxy(provider: EthereumProvider, address: string) {
86
99
  if (await isTransparentOrUUPSProxy(provider, address)) {
87
100
  throw new UpgradesError(
@@ -9,3 +9,9 @@ export class ValidationErrors extends UpgradesError {
9
9
  );
10
10
  }
11
11
  }
12
+
13
+ export class ContractSourceNotFoundError extends UpgradesError {
14
+ constructor() {
15
+ super('The requested contract was not found. Make sure the source code is available for compilation');
16
+ }
17
+ }
@@ -1,6 +1,6 @@
1
1
  export { validate, ValidationRunData, ContractValidation } from './run';
2
2
  export { ProxyKindOption, StandaloneValidationOptions, ValidationOptions, withValidationDefaults } from './overrides';
3
- export { ValidationErrors } from './error';
3
+ export { ValidationErrors, ContractSourceNotFoundError } from './error';
4
4
  export { RunValidation, ValidationLog, Validation, ValidationResult } from './compat';
5
5
  export { ValidationData, ValidationDataCurrent, isCurrentValidationData, concatRunData } from './data';
6
6
  export {
@@ -3,7 +3,7 @@ import { ValidationRunData, ValidationError, isOpcodeError } from './run';
3
3
  import { StorageLayout } from '../storage/layout';
4
4
  import { unlinkBytecode } from '../link-refs';
5
5
  import { ValidationOptions, processExceptions } from './overrides';
6
- import { ValidationErrors } from './error';
6
+ import { ContractSourceNotFoundError, ValidationErrors } from './error';
7
7
  import { ValidationData, normalizeValidationData } from './data';
8
8
  import { ProxyDeployment } from '../manifest';
9
9
 
@@ -72,7 +72,7 @@ export function getContractNameAndRunValidation(data: ValidationData, version: V
72
72
  }
73
73
 
74
74
  if (fullContractName === undefined || runValidation === undefined) {
75
- throw new Error('The requested contract was not found. Make sure the source code is available for compilation');
75
+ throw new ContractSourceNotFoundError();
76
76
  }
77
77
 
78
78
  return [fullContractName, runValidation];