@openzeppelin/upgrades-core 1.39.0 → 1.41.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 (38) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/index.d.ts +2 -1
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +4 -1
  5. package/dist/index.js.map +1 -1
  6. package/dist/utils/make-namespaced.d.ts +18 -3
  7. package/dist/utils/make-namespaced.d.ts.map +1 -1
  8. package/dist/utils/make-namespaced.js +83 -55
  9. package/dist/utils/make-namespaced.js.map +1 -1
  10. package/dist/utils/make-namespaced.test.js +4 -1
  11. package/dist/utils/make-namespaced.test.js.map +1 -1
  12. package/package.json +2 -2
  13. package/src/cli/cli.test.ts.snap +0 -0
  14. package/src/cli/validate/project-report.test.ts.snap +0 -0
  15. package/src/cli/validate/validate-upgrade-safety.test.ts.snap +0 -0
  16. package/src/cli/validate/validations.test.ts.snap +0 -0
  17. package/src/index.ts +2 -1
  18. package/src/scripts/migrate-oz-cli-project.test.ts.snap +0 -0
  19. package/src/storage/report-gap.test.ts.snap +0 -0
  20. package/src/storage/report-rename-retype.test.ts.snap +0 -0
  21. package/src/storage/report.test.ts.snap +0 -0
  22. package/src/storage-0.8.test.ts.snap +0 -0
  23. package/src/storage-memory-0.5.test.ts.snap +0 -0
  24. package/src/storage-namespaced-conflicts-layout.test.ts.snap +0 -0
  25. package/src/storage-namespaced-conflicts.test.ts.snap +0 -0
  26. package/src/storage-namespaced-layout.test.ts.snap +0 -0
  27. package/src/storage-namespaced.test.ts.snap +0 -0
  28. package/src/storage.test.ts.snap +0 -0
  29. package/src/utils/make-namespaced.test.ts +5 -6
  30. package/src/utils/make-namespaced.test.ts.md +89 -37
  31. package/src/utils/make-namespaced.test.ts.snap +0 -0
  32. package/src/utils/make-namespaced.ts +107 -66
  33. package/src/utils/parse-type-id.test.ts.snap +0 -0
  34. package/dist/utils/slang/trivia.d.ts +0 -9
  35. package/dist/utils/slang/trivia.d.ts.map +0 -1
  36. package/dist/utils/slang/trivia.js +0 -23
  37. package/dist/utils/slang/trivia.js.map +0 -1
  38. package/src/utils/slang/trivia.ts +0 -23
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.41.0 (2024-11-25)
4
+
5
+ - Update Slang dependency to 0.18.3. ([#1102](https://github.com/OpenZeppelin/openzeppelin-upgrades/pull/1102))
6
+ - Improves reliability of Hardhat compilation step for namespaced storage layout validations when using Solidity versions 0.8.27 and 0.8.28.
7
+
8
+ ## 1.40.0 (2024-10-10)
9
+
10
+ - Fix Hardhat compile error when overriding interface functions with public constant variables. ([#1091](https://github.com/OpenZeppelin/openzeppelin-upgrades/pull/1091))
11
+ - Support ignoring Hardhat compile errors when extracting detailed namespaced storage layouts for validations. ([#1090](https://github.com/OpenZeppelin/openzeppelin-upgrades/pull/1090))
12
+
3
13
  ## 1.39.0 (2024-10-02)
4
14
 
5
15
  - Fix Hardhat compile error when library or interface has struct with namespace annotation. ([#1086](https://github.com/OpenZeppelin/openzeppelin-upgrades/pull/1086))
package/dist/index.d.ts CHANGED
@@ -22,7 +22,8 @@ export { addProxyToManifest } from './add-proxy-to-manifest';
22
22
  export { BeaconProxyUnsupportedError, LoadProxyUnsupportedError, PrepareUpgradeUnsupportedError, DeployBeaconProxyUnsupportedError, DeployBeaconProxyImplUnknownError, DeployBeaconProxyKindError, ForceImportUnsupportedError, NoContractImportError, ValidateUpdateRequiresKindError, PrepareUpgradeRequiresKindError, InitialOwnerUnsupportedKindError, assertNotProxy, } from './usage-error';
23
23
  export { ValidateUpgradeSafetyOptions, validateUpgradeSafety, ProjectReport, ReferenceContractNotFound } from './cli';
24
24
  export { getUpgradeInterfaceVersion } from './upgrade-interface-version';
25
- export { makeNamespacedInput } from './utils/make-namespaced';
25
+ export { makeNamespacedInput, trySanitizeNatSpec } from './utils/make-namespaced';
26
26
  export { isNamespaceSupported } from './storage/namespace';
27
27
  export { inferProxyAdmin } from './infer-proxy-admin';
28
+ export { assertUnreachable } from './utils/assert';
28
29
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAC7F,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,OAAO,EACL,qBAAqB,EACrB,6BAA6B,EAC7B,eAAe,EACf,gBAAgB,EAChB,wBAAwB,EACxB,aAAa,EACb,qBAAqB,EACrB,WAAW,GACZ,MAAM,YAAY,CAAC;AACpB,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AAExB,OAAO,EACL,YAAY,EACZ,cAAc,EACd,eAAe,EACf,QAAQ,EACR,eAAe,EACf,kBAAkB,GACnB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AAEvE,cAAc,kCAAkC,CAAC;AAEjD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,EAAE,wBAAwB,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC9F,OAAO,EAAE,kCAAkC,EAAE,iCAAiC,EAAE,MAAM,gBAAgB,CAAC;AACvG,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,C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OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,EAAE,wBAAwB,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC9F,OAAO,EAAE,kCAAkC,EAAE,iCAAiC,EAAE,MAAM,gBAAgB,CAAC;AACvG,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,EACL,2BAA2B,EAC3B,yBAAyB,EACzB,8BAA8B,EAC9B,iCAAiC,EACjC,iCAAiC,EACjC,0BAA0B,EAC1B,2BAA2B,EAC3B,qBAAqB,EACrB,+BAA+B,EAC/B,+BAA+B,EAC/B,gCAAgC,EAChC,cAAc,GACf,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,4BAA4B,EAAE,qBAAqB,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,OAAO,CAAC;AAEtH,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClF,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC"}
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.inferProxyAdmin = exports.isNamespaceSupported = exports.makeNamespacedInput = exports.getUpgradeInterfaceVersion = exports.ReferenceContractNotFound = exports.ProjectReport = exports.validateUpgradeSafety = exports.assertNotProxy = exports.InitialOwnerUnsupportedKindError = exports.PrepareUpgradeRequiresKindError = exports.ValidateUpdateRequiresKindError = exports.NoContractImportError = exports.ForceImportUnsupportedError = exports.DeployBeaconProxyKindError = exports.DeployBeaconProxyImplUnknownError = exports.DeployBeaconProxyUnsupportedError = exports.PrepareUpgradeUnsupportedError = exports.LoadProxyUnsupportedError = exports.BeaconProxyUnsupportedError = exports.addProxyToManifest = exports.isBeacon = exports.getImplementationAddressFromProxy = exports.getImplementationAddressFromBeacon = exports.isTransparentProxy = exports.isBeaconProxy = exports.isTransparentOrUUPSProxy = exports.UpgradeableContract = exports.detectProxyKind = exports.processProxyKind = exports.setProxyKind = exports.logWarning = exports.getStorageLayoutForAddress = exports.DeploymentNotFound = exports.migrateManifest = exports.Manifest = exports.isEmptySlot = exports.toFallbackEip1967Hash = exports.toEip1967Hash = exports.getImplementationAddress = exports.getBeaconAddress = exports.getAdminAddress = exports.EIP1967ImplementationNotFound = exports.EIP1967BeaconNotFound = exports.fetchOrDeployGetDeployment = exports.fetchOrDeployAdmin = exports.fetchOrDeploy = void 0;
17
+ exports.assertUnreachable = exports.inferProxyAdmin = exports.isNamespaceSupported = exports.trySanitizeNatSpec = exports.makeNamespacedInput = exports.getUpgradeInterfaceVersion = exports.ReferenceContractNotFound = exports.ProjectReport = exports.validateUpgradeSafety = exports.assertNotProxy = exports.InitialOwnerUnsupportedKindError = exports.PrepareUpgradeRequiresKindError = exports.ValidateUpdateRequiresKindError = exports.NoContractImportError = exports.ForceImportUnsupportedError = exports.DeployBeaconProxyKindError = exports.DeployBeaconProxyImplUnknownError = exports.DeployBeaconProxyUnsupportedError = exports.PrepareUpgradeUnsupportedError = exports.LoadProxyUnsupportedError = exports.BeaconProxyUnsupportedError = exports.addProxyToManifest = exports.isBeacon = exports.getImplementationAddressFromProxy = exports.getImplementationAddressFromBeacon = exports.isTransparentProxy = exports.isBeaconProxy = exports.isTransparentOrUUPSProxy = exports.UpgradeableContract = exports.detectProxyKind = exports.processProxyKind = exports.setProxyKind = exports.logWarning = exports.getStorageLayoutForAddress = exports.DeploymentNotFound = exports.migrateManifest = exports.Manifest = exports.isEmptySlot = exports.toFallbackEip1967Hash = exports.toEip1967Hash = exports.getImplementationAddress = exports.getBeaconAddress = exports.getAdminAddress = exports.EIP1967ImplementationNotFound = exports.EIP1967BeaconNotFound = exports.fetchOrDeployGetDeployment = exports.fetchOrDeployAdmin = exports.fetchOrDeploy = void 0;
18
18
  __exportStar(require("./validate"), exports);
19
19
  var impl_store_1 = require("./impl-store");
20
20
  Object.defineProperty(exports, "fetchOrDeploy", { enumerable: true, get: function () { return impl_store_1.fetchOrDeploy; } });
@@ -84,8 +84,11 @@ var upgrade_interface_version_1 = require("./upgrade-interface-version");
84
84
  Object.defineProperty(exports, "getUpgradeInterfaceVersion", { enumerable: true, get: function () { return upgrade_interface_version_1.getUpgradeInterfaceVersion; } });
85
85
  var make_namespaced_1 = require("./utils/make-namespaced");
86
86
  Object.defineProperty(exports, "makeNamespacedInput", { enumerable: true, get: function () { return make_namespaced_1.makeNamespacedInput; } });
87
+ Object.defineProperty(exports, "trySanitizeNatSpec", { enumerable: true, get: function () { return make_namespaced_1.trySanitizeNatSpec; } });
87
88
  var namespace_1 = require("./storage/namespace");
88
89
  Object.defineProperty(exports, "isNamespaceSupported", { enumerable: true, get: function () { return namespace_1.isNamespaceSupported; } });
89
90
  var infer_proxy_admin_1 = require("./infer-proxy-admin");
90
91
  Object.defineProperty(exports, "inferProxyAdmin", { enumerable: true, get: function () { return infer_proxy_admin_1.inferProxyAdmin; } });
92
+ var assert_1 = require("./utils/assert");
93
+ Object.defineProperty(exports, "assertUnreachable", { enumerable: true, get: function () { return assert_1.assertUnreachable; } });
91
94
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","source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ACnB,2CAA+E;AAAtE,0GAAA,YAAY,OAAA;AAAE,8GAAA,gBAAgB,OAAA;AAAE,6GAAA,eAAe,OAAA;AAExD,2CAAmD;AAA1C,iHAAA,mBAAmB,OAAA;AAE5B,iDAA8F;AAArF,yHAAA,wBAAwB,OAAA;AAAE,8GAAA,aAAa,OAAA;AAAE,mHAAA,kBAAkB,OAAA;AACpE,+CAAuG;AAA9F,kIAAA,kCAAkC,OAAA;AAAE,iIAAA,iCAAiC,OAAA;AAC9E,mCAAoC;AAA3B,kGAAA,QAAQ,OAAA;AACjB,iEAA6D;AAApD,2HAAA,kBAAkB,OAAA;AAE3B,6CAauB;AAZrB,0HAAA,2BAA2B,OAAA;AAC3B,wHAAA,yBAAyB,OAAA;AACzB,6HAAA,8BAA8B,OAAA;AAC9B,gIAAA,iCAAiC,OAAA;AACjC,gIAAA,iCAAiC,OAAA;AACjC,yHAAA,0BAA0B,OAAA;AAC1B,0HAAA,2BAA2B,OAAA;AAC3B,oHAAA,qBAAqB,OAAA;AACrB,8HAAA,+BAA+B,OAAA;AAC/B,8HAAA,+BAA+B,OAAA;AAC/B,+HAAA,gCAAgC,OAAA;AAChC,6GAAA,cAAc,OAAA;AAGhB,6BAAsH;AAA/E,4GAAA,qBAAqB,OAAA;AAAE,oGAAA,aAAa,OAAA;AAAE,gHAAA,yBAAyB,OAAA;AAEtG,yEAAyE;AAAhE,uIAAA,0BAA0B,OAAA;AACnC,2DAAkF;AAAzE,sHAAA,mBAAmB,OAAA;AAAE,qHAAA,kBAAkB,OAAA;AAChD,iDAA2D;AAAlD,iHAAA,oBAAoB,OAAA;AAC7B,yDAAsD;AAA7C,oHAAA,eAAe,OAAA;AACxB,yCAAmD;AAA1C,2GAAA,iBAAiB,OAAA"}
@@ -6,10 +6,14 @@ import { SolcInput, SolcOutput } from '../solc-api';
6
6
  * This makes the following modifications to the input:
7
7
  * - Adds a state variable for each namespaced struct definition
8
8
  * - For each contract, for all node types that are not needed for storage layout or may call functions and constructors, converts them to dummy enums with random id
9
+ * - Mark contracts as abstract, since state variables are converted to dummy enums which would not generate public getters for inherited interface functions
9
10
  * - Converts all using for directives (at file level and in contracts) to dummy enums with random id (do not delete them to avoid orphaning possible NatSpec documentation)
10
11
  * - Converts all custom errors and constants (at file level) to dummy enums with the same name (do not delete them since they might be imported by other files)
11
12
  * - Replaces functions as follows:
12
- * - For regular function and free function, keep declarations since they may be referenced by constants (free functions may also be imported by other files). But simplify compilation by removing modifiers and body, and replace return parameters with bools which can be default initialized.
13
+ * - For regular function and free function, keep declarations since they may be referenced by constants (free functions may also be imported by other files). But simplify compilation as follows:
14
+ * - Avoid having to initialize return parameters: convert function to virtual if possible, or convert return parameters to bools which can be default initialized.
15
+ * - Delete modifiers
16
+ * - Delete function bodies
13
17
  * - Constructors are not needed, since we removed anything that may call constructors. Convert to dummy enums to avoid orphaning possible NatSpec.
14
18
  * - Fallback and receive functions are not needed, since they don't have signatures. Convert to dummy enums to avoid orphaning possible NatSpec.
15
19
  *
@@ -17,8 +21,19 @@ import { SolcInput, SolcOutput } from '../solc-api';
17
21
  *
18
22
  * @param input The original solc input.
19
23
  * @param output The original solc output.
20
- * @param solcVersion The version of the solc compiler that was originally used to compile the input.
24
+ * @param _solcVersion The version of the solc compiler that was originally used to compile the input. This argument is no longer used and is kept for backwards compatibility.
21
25
  * @returns The modified solc input with storage layout that includes namespaced type information.
22
26
  */
23
- export declare function makeNamespacedInput(input: SolcInput, output: SolcOutput, solcVersion?: string): SolcInput;
27
+ export declare function makeNamespacedInput(input: SolcInput, output: SolcOutput, _solcVersion?: string): SolcInput;
28
+ /**
29
+ * Attempts to remove all NatSpec comments that do not precede a struct definition from the input source contents.
30
+ * Directly modifies the input source contents, and also returns the modified input.
31
+ *
32
+ * If the solc version is not supported by the parser, the original content is kept.
33
+ *
34
+ * @param solcInput Solc input.
35
+ * @param solcVersion The version of the solc compiler that was originally used to compile the input.
36
+ * @returns The modified solc input with NatSpec comments removed where they do not precede a struct definition.
37
+ */
38
+ export declare function trySanitizeNatSpec(solcInput: SolcInput, solcVersion: string): Promise<SolcInput>;
24
39
  //# sourceMappingURL=make-namespaced.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"make-namespaced.d.ts","sourceRoot":"","sources":["../../src/utils/make-namespaced.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAYpD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAoIzG"}
1
+ {"version":3,"file":"make-namespaced.d.ts","sourceRoot":"","sources":["../../src/utils/make-namespaced.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAYpD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAkI1G;AAED;;;;;;;;;GASG;AACH,wBAAsB,kBAAkB,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAOtG"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.makeNamespacedInput = makeNamespacedInput;
4
+ exports.trySanitizeNatSpec = trySanitizeNatSpec;
4
5
  const utils_1 = require("solidity-ast/utils");
5
6
  const namespace_1 = require("../storage/namespace");
6
7
  const assert_1 = require("./assert");
@@ -17,10 +18,14 @@ const OUTPUT_SELECTION = {
17
18
  * This makes the following modifications to the input:
18
19
  * - Adds a state variable for each namespaced struct definition
19
20
  * - For each contract, for all node types that are not needed for storage layout or may call functions and constructors, converts them to dummy enums with random id
21
+ * - Mark contracts as abstract, since state variables are converted to dummy enums which would not generate public getters for inherited interface functions
20
22
  * - Converts all using for directives (at file level and in contracts) to dummy enums with random id (do not delete them to avoid orphaning possible NatSpec documentation)
21
23
  * - Converts all custom errors and constants (at file level) to dummy enums with the same name (do not delete them since they might be imported by other files)
22
24
  * - Replaces functions as follows:
23
- * - For regular function and free function, keep declarations since they may be referenced by constants (free functions may also be imported by other files). But simplify compilation by removing modifiers and body, and replace return parameters with bools which can be default initialized.
25
+ * - For regular function and free function, keep declarations since they may be referenced by constants (free functions may also be imported by other files). But simplify compilation as follows:
26
+ * - Avoid having to initialize return parameters: convert function to virtual if possible, or convert return parameters to bools which can be default initialized.
27
+ * - Delete modifiers
28
+ * - Delete function bodies
24
29
  * - Constructors are not needed, since we removed anything that may call constructors. Convert to dummy enums to avoid orphaning possible NatSpec.
25
30
  * - Fallback and receive functions are not needed, since they don't have signatures. Convert to dummy enums to avoid orphaning possible NatSpec.
26
31
  *
@@ -28,10 +33,10 @@ const OUTPUT_SELECTION = {
28
33
  *
29
34
  * @param input The original solc input.
30
35
  * @param output The original solc output.
31
- * @param solcVersion The version of the solc compiler that was originally used to compile the input.
36
+ * @param _solcVersion The version of the solc compiler that was originally used to compile the input. This argument is no longer used and is kept for backwards compatibility.
32
37
  * @returns The modified solc input with storage layout that includes namespaced type information.
33
38
  */
34
- function makeNamespacedInput(input, output, solcVersion) {
39
+ function makeNamespacedInput(input, output, _solcVersion) {
35
40
  const modifiedSources = {};
36
41
  for (const [sourcePath] of Object.entries(input.sources)) {
37
42
  const source = input.sources[sourcePath];
@@ -62,7 +67,7 @@ function makeNamespacedInput(input, output, solcVersion) {
62
67
  for (const contractNode of contractNodes) {
63
68
  switch (contractNode.nodeType) {
64
69
  case 'FunctionDefinition': {
65
- replaceFunction(contractNode, orig, modifications);
70
+ replaceFunction(contractNode, orig, modifications, contractDef);
66
71
  break;
67
72
  }
68
73
  case 'VariableDeclaration': {
@@ -145,64 +150,62 @@ function makeNamespacedInput(input, output, solcVersion) {
145
150
  }
146
151
  }
147
152
  }
148
- const modifiedSource = tryRemoveNonStructNatSpec(getModifiedSource(orig, modifications), solcVersion);
149
- modifiedSources[sourcePath] = { ...source, content: modifiedSource };
153
+ modifiedSources[sourcePath] = { ...source, content: getModifiedSource(orig, modifications) };
150
154
  }
151
155
  return { ...input, sources: modifiedSources, settings: { ...input.settings, outputSelection: OUTPUT_SELECTION } };
152
156
  }
153
157
  /**
154
- * If we have the compiler version available and Slang is supported for the current platform and compiler version,
155
- * use Slang to parse and remove all NatSpec comments that do not precede a struct definition and return the modified content.
158
+ * Attempts to remove all NatSpec comments that do not precede a struct definition from the input source contents.
159
+ * Directly modifies the input source contents, and also returns the modified input.
156
160
  *
157
- * Otherwise, return the original content.
161
+ * If the solc version is not supported by the parser, the original content is kept.
162
+ *
163
+ * @param solcInput Solc input.
164
+ * @param solcVersion The version of the solc compiler that was originally used to compile the input.
165
+ * @returns The modified solc input with NatSpec comments removed where they do not precede a struct definition.
158
166
  */
159
- function tryRemoveNonStructNatSpec(origContent, solcVersion) {
160
- const natSpecRemovals = [];
161
- if (solcVersion !== undefined && tryRequire('@nomicfoundation/slang') && slangSupportsVersion(solcVersion)) {
162
- /* eslint-disable @typescript-eslint/no-var-requires */
163
- const { Language } = require('@nomicfoundation/slang/language');
164
- const { NonterminalKind, TerminalKind } = require('@nomicfoundation/slang/kinds');
165
- const { TerminalNode } = require('@nomicfoundation/slang/cst');
166
- const { isTrivia } = require('./slang/trivia');
167
- /* eslint-enable @typescript-eslint/no-var-requires */
168
- const language = new Language(solcVersion);
169
- const parseOutput = language.parse(NonterminalKind.SourceUnit, origContent);
170
- const cursor = parseOutput.createTreeCursor();
171
- while (cursor.goToNextTerminalWithKinds([TerminalKind.MultiLineNatSpecComment, TerminalKind.SingleLineNatSpecComment])) {
172
- // Lookahead to determine if the next non-trivia node is the struct keyword.
173
- // If so, this NatSpec is part of the struct definition and should not be removed.
174
- const lookaheadCursor = cursor.clone();
175
- while (lookaheadCursor.goToNextTerminal() && isTrivia(lookaheadCursor.node())) {
176
- // skip over trivia nodes
177
- }
178
- if (lookaheadCursor.node().kind === TerminalKind.StructKeyword) {
179
- continue;
180
- }
181
- const triviaNode = cursor.node();
182
- (0, assert_1.assert)(triviaNode instanceof TerminalNode);
183
- natSpecRemovals.push(makeDeleteRange(cursor.textRange.start.utf8, cursor.textRange.end.utf8));
167
+ async function trySanitizeNatSpec(solcInput, solcVersion) {
168
+ for (const [sourcePath, source] of Object.entries(solcInput.sources)) {
169
+ if (source.content !== undefined) {
170
+ solcInput.sources[sourcePath].content = await tryRemoveNonStructNatSpec(source.content, solcVersion);
184
171
  }
185
- return getModifiedSource(Buffer.from(origContent, 'utf8'), natSpecRemovals);
186
172
  }
187
- else {
173
+ return solcInput;
174
+ }
175
+ /**
176
+ * If Slang is supported for the current compiler version, use Slang to parse and remove all NatSpec comments
177
+ * that do not precede a struct definition and return the modified content.
178
+ *
179
+ * Otherwise, return the original content.
180
+ */
181
+ async function tryRemoveNonStructNatSpec(origContent, solcVersion) {
182
+ if (solcVersion === undefined) {
188
183
  return origContent;
189
184
  }
190
- }
191
- function tryRequire(id) {
192
- try {
193
- require(id);
194
- return true;
185
+ const { Parser } = await import('@nomicfoundation/slang/parser');
186
+ if (!Parser.supportedVersions().includes(solcVersion)) {
187
+ return origContent;
195
188
  }
196
- catch (e) {
197
- // do nothing
189
+ const { TerminalKind, TerminalKindExtensions } = await import('@nomicfoundation/slang/cst');
190
+ const parser = Parser.create(solcVersion);
191
+ const parseOutput = parser.parse(Parser.rootKind(), origContent);
192
+ const cursor = parseOutput.createTreeCursor();
193
+ const natSpecRemovals = [];
194
+ while (cursor.goToNextTerminalWithKinds([TerminalKind.MultiLineNatSpecComment, TerminalKind.SingleLineNatSpecComment])) {
195
+ // Lookahead to determine if the next non-trivia node is the struct keyword.
196
+ // If so, this NatSpec is part of the struct definition and should not be removed.
197
+ const lookaheadCursor = cursor.clone();
198
+ while (lookaheadCursor.goToNextTerminal() &&
199
+ lookaheadCursor.node.isTerminalNode() &&
200
+ TerminalKindExtensions.isTrivia(lookaheadCursor.node.kind)) {
201
+ // skip over trivia nodes
202
+ }
203
+ if (lookaheadCursor.node.kind === TerminalKind.StructKeyword) {
204
+ continue;
205
+ }
206
+ natSpecRemovals.push(makeDeleteRange(cursor.textRange.start.utf8, cursor.textRange.end.utf8));
198
207
  }
199
- return false;
200
- }
201
- function slangSupportsVersion(solcVersion) {
202
- /* eslint-disable @typescript-eslint/no-var-requires */
203
- const { Language } = require('@nomicfoundation/slang/language');
204
- /* eslint-enable @typescript-eslint/no-var-requires */
205
- return Language.supportedVersions().includes(solcVersion);
208
+ return getModifiedSource(Buffer.from(origContent, 'utf8'), natSpecRemovals);
206
209
  }
207
210
  function toDummyEnumWithName(name) {
208
211
  return `enum ${name} { dummy }`;
@@ -210,20 +213,45 @@ function toDummyEnumWithName(name) {
210
213
  function toDummyEnumWithAstId(astId) {
211
214
  return `enum $astId_${astId}_${(Math.random() * 1e6).toFixed(0)} { dummy }`;
212
215
  }
213
- function replaceFunction(node, orig, modifications) {
216
+ function replaceFunction(node, orig, modifications, contractDef) {
214
217
  switch (node.kind) {
215
218
  case 'freeFunction':
216
219
  case 'function': {
220
+ let virtual = node.virtual;
221
+ if (contractDef !== undefined &&
222
+ contractDef.contractKind === 'contract' &&
223
+ node.visibility !== 'private' &&
224
+ !virtual) {
225
+ (0, assert_1.assert)(node.kind !== 'freeFunction');
226
+ // If this is a contract function and not private, it could possibly override an interface function.
227
+ // We don't want to change its return parameters because that might cause a mismatch with the interface.
228
+ // Simply convert the function to virtual (if not already)
229
+ modifications.push(makeInsertAfter(node.parameters, ' virtual '));
230
+ virtual = true;
231
+ }
217
232
  if (node.modifiers.length > 0) {
233
+ // Delete modifiers
218
234
  for (const modifier of node.modifiers) {
219
235
  modifications.push(makeDelete(modifier, orig));
220
236
  }
221
237
  }
222
- if (node.returnParameters.parameters.length > 0) {
223
- modifications.push(makeReplace(node.returnParameters, orig, `(${node.returnParameters.parameters.map(param => toReturnParameterReplacement(param)).join(', ')})`));
224
- }
225
238
  if (node.body) {
226
- modifications.push(makeReplace(node.body, orig, '{}'));
239
+ // Delete body
240
+ if (virtual) {
241
+ modifications.push(makeReplace(node.body, orig, ';'));
242
+ }
243
+ else {
244
+ // This is a non-virtual function with a body, so that means it is not an interface function.
245
+ (0, assert_1.assert)(contractDef?.contractKind !== 'interface');
246
+ // Since all contract functions that are non-private were converted to virtual above, this cannot possibly override another function.
247
+ (0, assert_1.assert)(!node.overrides);
248
+ // The remaining scenarios may mean this is a library function, free function, or private function.
249
+ // In any of these cases, we can convert the return parameters to bools so that they can be default initialized.
250
+ if (node.returnParameters.parameters.length > 0) {
251
+ modifications.push(makeReplace(node.returnParameters, orig, `(${node.returnParameters.parameters.map(param => toReturnParameterReplacement(param)).join(', ')})`));
252
+ }
253
+ modifications.push(makeReplace(node.body, orig, '{}'));
254
+ }
227
255
  }
228
256
  break;
229
257
  }
@@ -1 +1 @@
1
- {"version":3,"file":"make-namespaced.js","sourceRoot":"","sources":["../../src/utils/make-namespaced.ts"],"names":[],"mappings":";;AAmCA,kDAoIC;AAvKD,8CAAgD;AAGhD,oDAAoE;AACpE,qCAAqD;AAGrD,MAAM,gBAAgB,GAAG;IACvB,GAAG,EAAE;QACH,GAAG,EAAE,CAAC,eAAe,CAAC;QACtB,EAAE,EAAE,CAAC,KAAK,CAAC;KACZ;CACF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAgB,mBAAmB,CAAC,KAAgB,EAAE,MAAkB,EAAE,WAAoB;IAC5F,MAAM,eAAe,GAAyC,EAAE,CAAC;IAEjE,KAAK,MAAM,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QACzD,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAEzC,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS,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AAC,CAAC;IAEtB,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE,CAAC;QACzC,IAAA,eAAM,EAAC,YAAY,CAAC,KAAK,IAAI,aAAa,CAAC,CAAC;QAC5C,MAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,aAAa,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC;QAEnE,IAAI,YAAY,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YACpC,MAAM,IAAI,YAAY,CAAC,IAAI,CAAC;QAC9B,CAAC;QAED,aAAa,GAAG,YAAY,CAAC,GAAG,CAAC;IACnC,CAAC;IAED,IAAA,eAAM,EAAC,aAAa,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC;IACrC,MAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAE/C,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -26,7 +26,10 @@ async function testMakeNamespaced(origBuildInfo, t, solcVersion, keepAllNatSpec
26
26
  }
27
27
  // Inefficient, but we want to test that we don't actually modify the original input object
28
28
  const origInput = JSON.parse(JSON.stringify(origBuildInfo.input));
29
- const modifiedInput = (0, make_namespaced_1.makeNamespacedInput)(origBuildInfo.input, origBuildInfo.output, keepAllNatSpec ? undefined : origBuildInfo.solcVersion);
29
+ let modifiedInput = (0, make_namespaced_1.makeNamespacedInput)(origBuildInfo.input, origBuildInfo.output, origBuildInfo.solcVersion);
30
+ if (!keepAllNatSpec) {
31
+ modifiedInput = await (0, make_namespaced_1.trySanitizeNatSpec)(modifiedInput, origBuildInfo.solcVersion);
32
+ }
30
33
  // Run hardhat compile on the modified input and make sure it has no errors
31
34
  const modifiedOutput = await hardhatCompile(modifiedInput, solcVersion);
32
35
  t.is(modifiedOutput.errors, undefined, JSON.stringify(modifiedInput.sources, null, 2));
@@ -1 +1 @@
1
- {"version":3,"file":"make-namespaced.test.js","sourceRoot":"","sources":["../../src/utils/make-namespaced.test.ts"],"names":[],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AAC,wBAAwB,EAAE,qBAAqB,CAAC;iBACxD,OAAO,CAAC,6BAA6B,EAAE,0BAA0B,CAAC;iBAClE,OAAO,CAAC,+BAA+B,EAAE,4BAA4B,CAAC;iBACtE,OAAO,CAAC,sBAAsB,EAAE,kBAAkB,CAAC,CAAC;QACzD,CAAC;IACH,CAAC;AACH,CAAC;AAED,KAAK,UAAU,cAAc,CAAC,KAAgB,EAAE,WAAmB;IACjE,MAAM,SAAS,GAAc,MAAM,IAAA,aAAG,EAAC,iDAAoC,EAAE;QAC3E,KAAK,EAAE,IAAI;QACX,WAAW;KACZ,CAAC,CAAC;IAEH,IAAI,SAAS,CAAC,QAAQ,EAAE,CAAC;QACvB,OAAO,MAAM,IAAA,aAAG,EAAC,6CAAgC,EAAE;YACjD,KAAK;YACL,UAAU,EAAE,SAAS,CAAC,YAAY;SACnC,CAAC,CAAC;IACL,CAAC;SAAM,CAAC;QACN,OAAO,MAAM,IAAA,aAAG,EAAC,2CAA8B,EAAE;YAC/C,KAAK;YACL,QAAQ,EAAE,SAAS,CAAC,YAAY;SACjC,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openzeppelin/upgrades-core",
3
- "version": "1.39.0",
3
+ "version": "1.41.0",
4
4
  "description": "",
5
5
  "repository": "https://github.com/OpenZeppelin/openzeppelin-upgrades/tree/master/packages/core",
6
6
  "license": "MIT",
@@ -61,7 +61,7 @@
61
61
  "typescript": "^5.0.0"
62
62
  },
63
63
  "dependencies": {
64
- "@nomicfoundation/slang": "^0.17.0",
64
+ "@nomicfoundation/slang": "^0.18.3",
65
65
  "cbor": "^9.0.0",
66
66
  "chalk": "^4.1.0",
67
67
  "compare-versions": "^6.0.0",
Binary file
package/src/index.ts CHANGED
@@ -60,6 +60,7 @@ export {
60
60
  export { ValidateUpgradeSafetyOptions, validateUpgradeSafety, ProjectReport, ReferenceContractNotFound } from './cli';
61
61
 
62
62
  export { getUpgradeInterfaceVersion } from './upgrade-interface-version';
63
- export { makeNamespacedInput } from './utils/make-namespaced';
63
+ export { makeNamespacedInput, trySanitizeNatSpec } from './utils/make-namespaced';
64
64
  export { isNamespaceSupported } from './storage/namespace';
65
65
  export { inferProxyAdmin } from './infer-proxy-admin';
66
+ export { assertUnreachable } from './utils/assert';
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -6,7 +6,7 @@ import {
6
6
  TASK_COMPILE_SOLIDITY_RUN_SOLCJS,
7
7
  } from 'hardhat/builtin-tasks/task-names';
8
8
 
9
- import { makeNamespacedInput } from './make-namespaced';
9
+ import { makeNamespacedInput, trySanitizeNatSpec } from './make-namespaced';
10
10
  import { SolcBuild } from 'hardhat/types/builtin-tasks';
11
11
  import { SolcInput, SolcOutput } from '../solc-api';
12
12
  import { BuildInfo } from 'hardhat/types';
@@ -40,11 +40,10 @@ async function testMakeNamespaced(
40
40
  // Inefficient, but we want to test that we don't actually modify the original input object
41
41
  const origInput = JSON.parse(JSON.stringify(origBuildInfo.input));
42
42
 
43
- const modifiedInput = makeNamespacedInput(
44
- origBuildInfo.input,
45
- origBuildInfo.output,
46
- keepAllNatSpec ? undefined : origBuildInfo.solcVersion,
47
- );
43
+ let modifiedInput = makeNamespacedInput(origBuildInfo.input, origBuildInfo.output, origBuildInfo.solcVersion);
44
+ if (!keepAllNatSpec) {
45
+ modifiedInput = await trySanitizeNatSpec(modifiedInput, origBuildInfo.solcVersion);
46
+ }
48
47
 
49
48
  // Run hardhat compile on the modified input and make sure it has no errors
50
49
  const modifiedOutput = await hardhatCompile(modifiedInput, solcVersion);
@@ -53,13 +53,13 @@ Generated by [AVA](https://avajs.dev).
53
53
  } StorageWithComment $StorageWithComment_random;␊
54
54
  ␊
55
55
  ␊
56
- function foo() public {}␊
56
+ function foo() virtual public ;␊
57
57
  ␊
58
58
  ␊
59
- function foo1(uint a) public {}␊
59
+ function foo1(uint a) virtual public ;␊
60
60
  ␊
61
61
  ␊
62
- function foo2(uint a) internal {}␊
62
+ function foo2(uint a) virtual internal ;␊
63
63
  struct MyStruct { uint b; }␊
64
64
  ␊
65
65
  // keccak256(abi.encode(uint256(keccak256("example.main")) - 1)) & ~bytes32(uint256(0xff));␊
@@ -68,7 +68,7 @@ Generated by [AVA](https://avajs.dev).
68
68
  ␊
69
69
  function _getMainStorage() private pure returns (bool $) {}␊
70
70
  ␊
71
- function _getXTimesY() internal view returns (bool) {}␊
71
+ function _getXTimesY() virtual internal view returns (uint256) ;␊
72
72
  ␊
73
73
  ␊
74
74
  ␊
@@ -80,10 +80,10 @@ Generated by [AVA](https://avajs.dev).
80
80
  ␊
81
81
  ␊
82
82
  ␊
83
- function foo3() public {}␊
83
+ function foo3() virtual public ;␊
84
84
  ␊
85
85
  ␊
86
- function foo4() public {}␊
86
+ function foo4() virtual public ;␊
87
87
  ␊
88
88
  ␊
89
89
  enum $astId_id_random { dummy }␊
@@ -99,7 +99,7 @@ Generated by [AVA](https://avajs.dev).
99
99
  ␊
100
100
  enum $astId_id_random { dummy }␊
101
101
  ␊
102
- function foo() pure public returns (bool) {}␊
102
+ function foo() virtual pure public returns (uint) ;␊
103
103
  }␊
104
104
  ␊
105
105
  abstract contract UsingFunction is HasFunction {␊
@@ -119,11 +119,11 @@ Generated by [AVA](https://avajs.dev).
119
119
  abstract contract Consumer {␊
120
120
  enum $astId_id_random { dummy }␊
121
121
  ␊
122
- function usingFreeFunction() pure public returns (bool) {}␊
122
+ function usingFreeFunction() virtual pure public returns (bytes4) ;␊
123
123
  ␊
124
- function usingConstant() pure public returns (bool) {}␊
124
+ function usingConstant() virtual pure public returns (bytes4) ;␊
125
125
  ␊
126
- function usingLibraryFunction() pure public returns (bool) {}␊
126
+ function usingLibraryFunction() virtual pure public returns (bytes4) ;␊
127
127
  }␊
128
128
  ␊
129
129
  abstract contract HasConstantWithSelector {␊
@@ -150,7 +150,7 @@ Generated by [AVA](https://avajs.dev).
150
150
  abstract contract UsingForDirectives {␊
151
151
  enum $astId_id_random { dummy }␊
152
152
  ␊
153
- function usingFor(uint x) pure public returns (bool) {}␊
153
+ function usingFor(uint x) virtual pure public returns (uint) ;␊
154
154
  }␊
155
155
  ␊
156
156
  ␊
@@ -190,7 +190,14 @@ Generated by [AVA](https://avajs.dev).
190
190
  ␊
191
191
  abstract contract HasFunctionWithRequiredReturn {␊
192
192
  struct S { uint x; }␊
193
- function foo(S calldata s) internal pure returns (bool) {}␊
193
+ enum $astId_id_random { dummy }␊
194
+ function foo(S calldata s) virtual internal pure returns (S calldata) ;␊
195
+ }␊
196
+ ␊
197
+ library LibWithRequiredReturn {␊
198
+ struct S { uint x; }␊
199
+ enum $astId_id_random { dummy }␊
200
+ function foo(S calldata s) internal pure returns (bool) {}␊
194
201
  }␊
195
202
  ␊
196
203
  ␊
@@ -204,17 +211,17 @@ Generated by [AVA](https://avajs.dev).
204
211
  ␊
205
212
  abstract contract HasNatSpecWithMultipleReturns {␊
206
213
  ␊
207
- function hasMultipleReturnsInContract() public pure returns (bool, bool) {}␊
214
+ function hasMultipleReturnsInContract() virtual public pure returns (uint, uint) ;␊
208
215
  ␊
209
216
  ␊
210
- function hasMultipleNamedReturnsInContract() public pure returns (bool a, bool b) {}␊
217
+ function hasMultipleNamedReturnsInContract() virtual public pure returns (uint a, uint b) ;␊
211
218
  ␊
212
219
  ␊
213
- function hasReturnsDocumentedAsParamsInContract() public pure returns (bool a, bool b) {}␊
220
+ function hasReturnsDocumentedAsParamsInContract() virtual public pure returns (uint a, uint b) ;␊
214
221
  }␊
215
222
  ␊
216
223
  interface IHasExternalViewFunction {␊
217
- function foo() external view returns (bool);␊
224
+ function foo() external view returns (uint256);␊
218
225
  }␊
219
226
  ␊
220
227
  abstract contract HasExternalViewFunction is IHasExternalViewFunction {␊
@@ -240,7 +247,7 @@ Generated by [AVA](https://avajs.dev).
240
247
  enum $astId_id_random { dummy }␊
241
248
  ␊
242
249
  // Regular function but payable␊
243
- function hasPayable() public payable {}␊
250
+ function hasPayable() virtual public payable ;␊
244
251
  ␊
245
252
  bytes4 constant PAYABLE_SELECTOR = this.hasPayable.selector;␊
246
253
  }␊
@@ -261,7 +268,26 @@ Generated by [AVA](https://avajs.dev).
261
268
  uint256 y;␊
262
269
  }␊
263
270
  }␊
264
- `,
271
+ ␊
272
+ interface IHasConstantGetter {␊
273
+ function a() external view returns (bytes32);␊
274
+ }␊
275
+ ␊
276
+ abstract contract HasConstantGetter is IHasConstantGetter {␊
277
+ bytes32 public override constant a = bytes32("foo");␊
278
+ }␊
279
+ ␊
280
+ abstract contract AbstractHasConstantGetter {␊
281
+ function a() virtual external pure returns (bytes32) ;␊
282
+ }␊
283
+ ␊
284
+ abstract contract HasConstantGetterOverride is AbstractHasConstantGetter {␊
285
+ bytes32 public override constant a = bytes32("foo");␊
286
+ }␊
287
+ ␊
288
+ abstract contract HasFunctionOverride is AbstractHasConstantGetter {␊
289
+ function a() override virtual external pure returns (bytes32) ;␊
290
+ }`,
265
291
  },
266
292
  'contracts/test/NamespacedToModifyImported.sol': {
267
293
  content: `// SPDX-License-Identifier: MIT␊
@@ -324,13 +350,13 @@ Generated by [AVA](https://avajs.dev).
324
350
  } StorageWithComment $StorageWithComment_random;␊
325
351
  ␊
326
352
  /// @notice some natspec␊
327
- function foo() public {}␊
353
+ function foo() virtual public ;␊
328
354
  ␊
329
355
  /// @param a docs␊
330
- function foo1(uint a) public {}␊
356
+ function foo1(uint a) virtual public ;␊
331
357
  ␊
332
358
  /// @param a docs␊
333
- function foo2(uint a) internal {}␊
359
+ function foo2(uint a) virtual internal ;␊
334
360
  struct MyStruct { uint b; }␊
335
361
  ␊
336
362
  // keccak256(abi.encode(uint256(keccak256("example.main")) - 1)) & ~bytes32(uint256(0xff));␊
@@ -339,7 +365,7 @@ Generated by [AVA](https://avajs.dev).
339
365
  ␊
340
366
  function _getMainStorage() private pure returns (bool $) {}␊
341
367
  ␊
342
- function _getXTimesY() internal view returns (bool) {}␊
368
+ function _getXTimesY() virtual internal view returns (uint256) ;␊
343
369
  ␊
344
370
  /// @notice standlone natspec␊
345
371
  ␊
@@ -355,14 +381,14 @@ Generated by [AVA](https://avajs.dev).
355
381
  /**␊
356
382
  * doc block without natspec␊
357
383
  */␊
358
- function foo3() public {}␊
384
+ function foo3() virtual public ;␊
359
385
  ␊
360
386
  /**␊
361
387
  * doc block with natspec␊
362
388
  *␊
363
389
  * @notice some natspec␊
364
390
  */␊
365
- function foo4() public {}␊
391
+ function foo4() virtual public ;␊
366
392
  ␊
367
393
  /**␊
368
394
  * @dev a custom error inside a contract␊
@@ -380,7 +406,7 @@ Generated by [AVA](https://avajs.dev).
380
406
  /// @param myInt an integer␊
381
407
  enum $astId_id_random { dummy }␊
382
408
  ␊
383
- function foo() pure public returns (bool) {}␊
409
+ function foo() virtual pure public returns (uint) ;␊
384
410
  }␊
385
411
  ␊
386
412
  abstract contract UsingFunction is HasFunction {␊
@@ -400,11 +426,11 @@ Generated by [AVA](https://avajs.dev).
400
426
  abstract contract Consumer {␊
401
427
  enum $astId_id_random { dummy }␊
402
428
  ␊
403
- function usingFreeFunction() pure public returns (bool) {}␊
429
+ function usingFreeFunction() virtual pure public returns (bytes4) ;␊
404
430
  ␊
405
- function usingConstant() pure public returns (bool) {}␊
431
+ function usingConstant() virtual pure public returns (bytes4) ;␊
406
432
  ␊
407
- function usingLibraryFunction() pure public returns (bool) {}␊
433
+ function usingLibraryFunction() virtual pure public returns (bytes4) ;␊
408
434
  }␊
409
435
  ␊
410
436
  abstract contract HasConstantWithSelector {␊
@@ -442,7 +468,7 @@ Generated by [AVA](https://avajs.dev).
442
468
  abstract contract UsingForDirectives {␊
443
469
  enum $astId_id_random { dummy }␊
444
470
  ␊
445
- function usingFor(uint x) pure public returns (bool) {}␊
471
+ function usingFor(uint x) virtual pure public returns (uint) ;␊
446
472
  }␊
447
473
  ␊
448
474
  /**␊
@@ -494,7 +520,14 @@ Generated by [AVA](https://avajs.dev).
494
520
  ␊
495
521
  abstract contract HasFunctionWithRequiredReturn {␊
496
522
  struct S { uint x; }␊
497
- function foo(S calldata s) internal pure returns (bool) {}␊
523
+ enum $astId_id_random { dummy }␊
524
+ function foo(S calldata s) virtual internal pure returns (S calldata) ;␊
525
+ }␊
526
+ ␊
527
+ library LibWithRequiredReturn {␊
528
+ struct S { uint x; }␊
529
+ enum $astId_id_random { dummy }␊
530
+ function foo(S calldata s) internal pure returns (bool) {}␊
498
531
  }␊
499
532
  ␊
500
533
  /**␊
@@ -520,23 +553,23 @@ Generated by [AVA](https://avajs.dev).
520
553
  * @return uint 1␊
521
554
  * @return uint 2␊
522
555
  */␊
523
- function hasMultipleReturnsInContract() public pure returns (bool, bool) {}␊
556
+ function hasMultipleReturnsInContract() virtual public pure returns (uint, uint) ;␊
524
557
  ␊
525
558
  /**␊
526
559
  * @return a first␊
527
560
  * @return b second␊
528
561
  */␊
529
- function hasMultipleNamedReturnsInContract() public pure returns (bool a, bool b) {}␊
562
+ function hasMultipleNamedReturnsInContract() virtual public pure returns (uint a, uint b) ;␊
530
563
  ␊
531
564
  /**␊
532
565
  * @param a first␊
533
566
  * @param b second␊
534
567
  */␊
535
- function hasReturnsDocumentedAsParamsInContract() public pure returns (bool a, bool b) {}␊
568
+ function hasReturnsDocumentedAsParamsInContract() virtual public pure returns (uint a, uint b) ;␊
536
569
  }␊
537
570
  ␊
538
571
  interface IHasExternalViewFunction {␊
539
- function foo() external view returns (bool);␊
572
+ function foo() external view returns (uint256);␊
540
573
  }␊
541
574
  ␊
542
575
  abstract contract HasExternalViewFunction is IHasExternalViewFunction {␊
@@ -562,7 +595,7 @@ Generated by [AVA](https://avajs.dev).
562
595
  enum $astId_id_random { dummy }␊
563
596
  ␊
564
597
  // Regular function but payable␊
565
- function hasPayable() public payable {}␊
598
+ function hasPayable() virtual public payable ;␊
566
599
  ␊
567
600
  bytes4 constant PAYABLE_SELECTOR = this.hasPayable.selector;␊
568
601
  }␊
@@ -583,7 +616,26 @@ Generated by [AVA](https://avajs.dev).
583
616
  uint256 y;␊
584
617
  }␊
585
618
  }␊
586
- `,
619
+ ␊
620
+ interface IHasConstantGetter {␊
621
+ function a() external view returns (bytes32);␊
622
+ }␊
623
+ ␊
624
+ abstract contract HasConstantGetter is IHasConstantGetter {␊
625
+ bytes32 public override constant a = bytes32("foo");␊
626
+ }␊
627
+ ␊
628
+ abstract contract AbstractHasConstantGetter {␊
629
+ function a() virtual external pure returns (bytes32) ;␊
630
+ }␊
631
+ ␊
632
+ abstract contract HasConstantGetterOverride is AbstractHasConstantGetter {␊
633
+ bytes32 public override constant a = bytes32("foo");␊
634
+ }␊
635
+ ␊
636
+ abstract contract HasFunctionOverride is AbstractHasConstantGetter {␊
637
+ function a() override virtual external pure returns (bytes32) ;␊
638
+ }`,
587
639
  },
588
640
  'contracts/test/NamespacedToModifyImported.sol': {
589
641
  content: `// SPDX-License-Identifier: MIT␊
@@ -626,7 +678,7 @@ Generated by [AVA](https://avajs.dev).
626
678
  ␊
627
679
  abstract contract HasFunction {␊
628
680
  enum $astId_id_random { dummy }␊
629
- function foo() pure public returns (bool) {}␊
681
+ function foo() virtual pure public returns (uint) ;␊
630
682
  }␊
631
683
  ␊
632
684
  abstract contract UsingFunction is HasFunction {␊
@@ -3,7 +3,7 @@ import { Node } from 'solidity-ast/node';
3
3
  import { SolcInput, SolcOutput } from '../solc-api';
4
4
  import { getStorageLocationAnnotation } from '../storage/namespace';
5
5
  import { assert, assertUnreachable } from './assert';
6
- import { FunctionDefinition, VariableDeclaration } from 'solidity-ast';
6
+ import { ContractDefinition, FunctionDefinition, VariableDeclaration } from 'solidity-ast';
7
7
 
8
8
  const OUTPUT_SELECTION = {
9
9
  '*': {
@@ -19,10 +19,14 @@ const OUTPUT_SELECTION = {
19
19
  * This makes the following modifications to the input:
20
20
  * - Adds a state variable for each namespaced struct definition
21
21
  * - For each contract, for all node types that are not needed for storage layout or may call functions and constructors, converts them to dummy enums with random id
22
+ * - Mark contracts as abstract, since state variables are converted to dummy enums which would not generate public getters for inherited interface functions
22
23
  * - Converts all using for directives (at file level and in contracts) to dummy enums with random id (do not delete them to avoid orphaning possible NatSpec documentation)
23
24
  * - Converts all custom errors and constants (at file level) to dummy enums with the same name (do not delete them since they might be imported by other files)
24
25
  * - Replaces functions as follows:
25
- * - For regular function and free function, keep declarations since they may be referenced by constants (free functions may also be imported by other files). But simplify compilation by removing modifiers and body, and replace return parameters with bools which can be default initialized.
26
+ * - For regular function and free function, keep declarations since they may be referenced by constants (free functions may also be imported by other files). But simplify compilation as follows:
27
+ * - Avoid having to initialize return parameters: convert function to virtual if possible, or convert return parameters to bools which can be default initialized.
28
+ * - Delete modifiers
29
+ * - Delete function bodies
26
30
  * - Constructors are not needed, since we removed anything that may call constructors. Convert to dummy enums to avoid orphaning possible NatSpec.
27
31
  * - Fallback and receive functions are not needed, since they don't have signatures. Convert to dummy enums to avoid orphaning possible NatSpec.
28
32
  *
@@ -30,10 +34,10 @@ const OUTPUT_SELECTION = {
30
34
  *
31
35
  * @param input The original solc input.
32
36
  * @param output The original solc output.
33
- * @param solcVersion The version of the solc compiler that was originally used to compile the input.
37
+ * @param _solcVersion The version of the solc compiler that was originally used to compile the input. This argument is no longer used and is kept for backwards compatibility.
34
38
  * @returns The modified solc input with storage layout that includes namespaced type information.
35
39
  */
36
- export function makeNamespacedInput(input: SolcInput, output: SolcOutput, solcVersion?: string): SolcInput {
40
+ export function makeNamespacedInput(input: SolcInput, output: SolcOutput, _solcVersion?: string): SolcInput {
37
41
  const modifiedSources: Record<string, { content?: string }> = {};
38
42
 
39
43
  for (const [sourcePath] of Object.entries(input.sources)) {
@@ -72,7 +76,7 @@ export function makeNamespacedInput(input: SolcInput, output: SolcOutput, solcVe
72
76
  for (const contractNode of contractNodes) {
73
77
  switch (contractNode.nodeType) {
74
78
  case 'FunctionDefinition': {
75
- replaceFunction(contractNode, orig, modifications);
79
+ replaceFunction(contractNode, orig, modifications, contractDef);
76
80
  break;
77
81
  }
78
82
  case 'VariableDeclaration': {
@@ -159,74 +163,77 @@ export function makeNamespacedInput(input: SolcInput, output: SolcOutput, solcVe
159
163
  }
160
164
  }
161
165
 
162
- const modifiedSource = tryRemoveNonStructNatSpec(getModifiedSource(orig, modifications), solcVersion);
163
-
164
- modifiedSources[sourcePath] = { ...source, content: modifiedSource };
166
+ modifiedSources[sourcePath] = { ...source, content: getModifiedSource(orig, modifications) };
165
167
  }
166
168
 
167
169
  return { ...input, sources: modifiedSources, settings: { ...input.settings, outputSelection: OUTPUT_SELECTION } };
168
170
  }
169
171
 
170
172
  /**
171
- * If we have the compiler version available and Slang is supported for the current platform and compiler version,
172
- * use Slang to parse and remove all NatSpec comments that do not precede a struct definition and return the modified content.
173
+ * Attempts to remove all NatSpec comments that do not precede a struct definition from the input source contents.
174
+ * Directly modifies the input source contents, and also returns the modified input.
175
+ *
176
+ * If the solc version is not supported by the parser, the original content is kept.
177
+ *
178
+ * @param solcInput Solc input.
179
+ * @param solcVersion The version of the solc compiler that was originally used to compile the input.
180
+ * @returns The modified solc input with NatSpec comments removed where they do not precede a struct definition.
181
+ */
182
+ export async function trySanitizeNatSpec(solcInput: SolcInput, solcVersion: string): Promise<SolcInput> {
183
+ for (const [sourcePath, source] of Object.entries(solcInput.sources)) {
184
+ if (source.content !== undefined) {
185
+ solcInput.sources[sourcePath].content = await tryRemoveNonStructNatSpec(source.content, solcVersion);
186
+ }
187
+ }
188
+ return solcInput;
189
+ }
190
+
191
+ /**
192
+ * If Slang is supported for the current compiler version, use Slang to parse and remove all NatSpec comments
193
+ * that do not precede a struct definition and return the modified content.
173
194
  *
174
195
  * Otherwise, return the original content.
175
196
  */
176
- function tryRemoveNonStructNatSpec(origContent: string, solcVersion: string | undefined): string {
177
- const natSpecRemovals: Modification[] = [];
197
+ async function tryRemoveNonStructNatSpec(origContent: string, solcVersion: string): Promise<string> {
198
+ if (solcVersion === undefined) {
199
+ return origContent;
200
+ }
178
201
 
179
- if (solcVersion !== undefined && tryRequire('@nomicfoundation/slang') && slangSupportsVersion(solcVersion)) {
180
- /* eslint-disable @typescript-eslint/no-var-requires */
181
- const { Language } = require('@nomicfoundation/slang/language');
182
- const { NonterminalKind, TerminalKind } = require('@nomicfoundation/slang/kinds');
183
- const { TerminalNode } = require('@nomicfoundation/slang/cst');
184
- const { isTrivia } = require('./slang/trivia');
185
- /* eslint-enable @typescript-eslint/no-var-requires */
202
+ const { Parser } = await import('@nomicfoundation/slang/parser');
203
+ if (!Parser.supportedVersions().includes(solcVersion)) {
204
+ return origContent;
205
+ }
186
206
 
187
- const language = new Language(solcVersion);
188
- const parseOutput = language.parse(NonterminalKind.SourceUnit, origContent);
189
- const cursor = parseOutput.createTreeCursor();
207
+ const { TerminalKind, TerminalKindExtensions } = await import('@nomicfoundation/slang/cst');
190
208
 
209
+ const parser = Parser.create(solcVersion);
210
+ const parseOutput = parser.parse(Parser.rootKind(), origContent);
211
+ const cursor = parseOutput.createTreeCursor();
212
+
213
+ const natSpecRemovals: Modification[] = [];
214
+
215
+ while (
216
+ cursor.goToNextTerminalWithKinds([TerminalKind.MultiLineNatSpecComment, TerminalKind.SingleLineNatSpecComment])
217
+ ) {
218
+ // Lookahead to determine if the next non-trivia node is the struct keyword.
219
+ // If so, this NatSpec is part of the struct definition and should not be removed.
220
+ const lookaheadCursor = cursor.clone();
191
221
  while (
192
- cursor.goToNextTerminalWithKinds([TerminalKind.MultiLineNatSpecComment, TerminalKind.SingleLineNatSpecComment])
222
+ lookaheadCursor.goToNextTerminal() &&
223
+ lookaheadCursor.node.isTerminalNode() &&
224
+ TerminalKindExtensions.isTrivia(lookaheadCursor.node.kind)
193
225
  ) {
194
- // Lookahead to determine if the next non-trivia node is the struct keyword.
195
- // If so, this NatSpec is part of the struct definition and should not be removed.
196
- const lookaheadCursor = cursor.clone();
197
- while (lookaheadCursor.goToNextTerminal() && isTrivia(lookaheadCursor.node())) {
198
- // skip over trivia nodes
199
- }
200
- if (lookaheadCursor.node().kind === TerminalKind.StructKeyword) {
201
- continue;
202
- }
226
+ // skip over trivia nodes
227
+ }
203
228
 
204
- const triviaNode = cursor.node();
205
- assert(triviaNode instanceof TerminalNode);
206
- natSpecRemovals.push(makeDeleteRange(cursor.textRange.start.utf8, cursor.textRange.end.utf8));
229
+ if (lookaheadCursor.node.kind === TerminalKind.StructKeyword) {
230
+ continue;
207
231
  }
208
- return getModifiedSource(Buffer.from(origContent, 'utf8'), natSpecRemovals);
209
- } else {
210
- return origContent;
211
- }
212
- }
213
232
 
214
- function tryRequire(id: string) {
215
- try {
216
- require(id);
217
- return true;
218
- } catch (e: any) {
219
- // do nothing
233
+ natSpecRemovals.push(makeDeleteRange(cursor.textRange.start.utf8, cursor.textRange.end.utf8));
220
234
  }
221
- return false;
222
- }
223
-
224
- function slangSupportsVersion(solcVersion: string): boolean {
225
- /* eslint-disable @typescript-eslint/no-var-requires */
226
- const { Language } = require('@nomicfoundation/slang/language');
227
- /* eslint-enable @typescript-eslint/no-var-requires */
228
235
 
229
- return Language.supportedVersions().includes(solcVersion);
236
+ return getModifiedSource(Buffer.from(origContent, 'utf8'), natSpecRemovals);
230
237
  }
231
238
 
232
239
  interface Modification {
@@ -243,28 +250,62 @@ function toDummyEnumWithAstId(astId: number) {
243
250
  return `enum $astId_${astId}_${(Math.random() * 1e6).toFixed(0)} { dummy }`;
244
251
  }
245
252
 
246
- function replaceFunction(node: FunctionDefinition, orig: Buffer, modifications: Modification[]) {
253
+ function replaceFunction(
254
+ node: FunctionDefinition,
255
+ orig: Buffer,
256
+ modifications: Modification[],
257
+ contractDef?: ContractDefinition,
258
+ ) {
247
259
  switch (node.kind) {
248
260
  case 'freeFunction':
249
261
  case 'function': {
262
+ let virtual = node.virtual;
263
+
264
+ if (
265
+ contractDef !== undefined &&
266
+ contractDef.contractKind === 'contract' &&
267
+ node.visibility !== 'private' &&
268
+ !virtual
269
+ ) {
270
+ assert(node.kind !== 'freeFunction');
271
+
272
+ // If this is a contract function and not private, it could possibly override an interface function.
273
+ // We don't want to change its return parameters because that might cause a mismatch with the interface.
274
+ // Simply convert the function to virtual (if not already)
275
+ modifications.push(makeInsertAfter(node.parameters, ' virtual '));
276
+ virtual = true;
277
+ }
278
+
250
279
  if (node.modifiers.length > 0) {
280
+ // Delete modifiers
251
281
  for (const modifier of node.modifiers) {
252
282
  modifications.push(makeDelete(modifier, orig));
253
283
  }
254
284
  }
255
285
 
256
- if (node.returnParameters.parameters.length > 0) {
257
- modifications.push(
258
- makeReplace(
259
- node.returnParameters,
260
- orig,
261
- `(${node.returnParameters.parameters.map(param => toReturnParameterReplacement(param)).join(', ')})`,
262
- ),
263
- );
264
- }
265
-
266
286
  if (node.body) {
267
- modifications.push(makeReplace(node.body, orig, '{}'));
287
+ // Delete body
288
+ if (virtual) {
289
+ modifications.push(makeReplace(node.body, orig, ';'));
290
+ } else {
291
+ // This is a non-virtual function with a body, so that means it is not an interface function.
292
+ assert(contractDef?.contractKind !== 'interface');
293
+ // Since all contract functions that are non-private were converted to virtual above, this cannot possibly override another function.
294
+ assert(!node.overrides);
295
+
296
+ // The remaining scenarios may mean this is a library function, free function, or private function.
297
+ // In any of these cases, we can convert the return parameters to bools so that they can be default initialized.
298
+ if (node.returnParameters.parameters.length > 0) {
299
+ modifications.push(
300
+ makeReplace(
301
+ node.returnParameters,
302
+ orig,
303
+ `(${node.returnParameters.parameters.map(param => toReturnParameterReplacement(param)).join(', ')})`,
304
+ ),
305
+ );
306
+ }
307
+ modifications.push(makeReplace(node.body, orig, '{}'));
308
+ }
268
309
  }
269
310
 
270
311
  break;
@@ -1,9 +0,0 @@
1
- import { Node } from '@nomicfoundation/slang/cst';
2
- /**
3
- * Returns true if the node is a trivia terminal (whitespace or comment or NatSpec)
4
- *
5
- * CAUTION: This must be imported dynamically.
6
- * Only import this file if Slang is supported on the current platform, otherwise an error will be thrown on import.
7
- */
8
- export declare function isTrivia(node: Node): boolean;
9
- //# sourceMappingURL=trivia.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"trivia.d.ts","sourceRoot":"","sources":["../../../src/utils/slang/trivia.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAgB,MAAM,4BAA4B,CAAC;AAEhE;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,WAElC"}
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isTrivia = isTrivia;
4
- const kinds_1 = require("@nomicfoundation/slang/kinds");
5
- const cst_1 = require("@nomicfoundation/slang/cst");
6
- /**
7
- * Returns true if the node is a trivia terminal (whitespace or comment or NatSpec)
8
- *
9
- * CAUTION: This must be imported dynamically.
10
- * Only import this file if Slang is supported on the current platform, otherwise an error will be thrown on import.
11
- */
12
- function isTrivia(node) {
13
- return node instanceof cst_1.TerminalNode && isTriviaKind(node.kind);
14
- }
15
- function isTriviaKind(kind) {
16
- return (kind === kinds_1.TerminalKind.EndOfLine ||
17
- kind === kinds_1.TerminalKind.MultiLineComment ||
18
- kind === kinds_1.TerminalKind.MultiLineNatSpecComment ||
19
- kind === kinds_1.TerminalKind.SingleLineComment ||
20
- kind === kinds_1.TerminalKind.SingleLineNatSpecComment ||
21
- kind === kinds_1.TerminalKind.Whitespace);
22
- }
23
- //# sourceMappingURL=trivia.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"trivia.js","sourceRoot":"","sources":["../../../src/utils/slang/trivia.ts"],"names":[],"mappings":";;AASA,4BAEC;AAXD,wDAA4D;AAC5D,oDAAgE;AAEhE;;;;;GAKG;AACH,SAAgB,QAAQ,CAAC,IAAU;IACjC,OAAO,IAAI,YAAY,kBAAY,IAAI,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjE,CAAC;AAED,SAAS,YAAY,CAAC,IAAkB;IACtC,OAAO,CACL,IAAI,KAAK,oBAAY,CAAC,SAAS;QAC/B,IAAI,KAAK,oBAAY,CAAC,gBAAgB;QACtC,IAAI,KAAK,oBAAY,CAAC,uBAAuB;QAC7C,IAAI,KAAK,oBAAY,CAAC,iBAAiB;QACvC,IAAI,KAAK,oBAAY,CAAC,wBAAwB;QAC9C,IAAI,KAAK,oBAAY,CAAC,UAAU,CACjC,CAAC;AACJ,CAAC"}
@@ -1,23 +0,0 @@
1
- import { TerminalKind } from '@nomicfoundation/slang/kinds';
2
- import { Node, TerminalNode } from '@nomicfoundation/slang/cst';
3
-
4
- /**
5
- * Returns true if the node is a trivia terminal (whitespace or comment or NatSpec)
6
- *
7
- * CAUTION: This must be imported dynamically.
8
- * Only import this file if Slang is supported on the current platform, otherwise an error will be thrown on import.
9
- */
10
- export function isTrivia(node: Node) {
11
- return node instanceof TerminalNode && isTriviaKind(node.kind);
12
- }
13
-
14
- function isTriviaKind(kind: TerminalKind) {
15
- return (
16
- kind === TerminalKind.EndOfLine ||
17
- kind === TerminalKind.MultiLineComment ||
18
- kind === TerminalKind.MultiLineNatSpecComment ||
19
- kind === TerminalKind.SingleLineComment ||
20
- kind === TerminalKind.SingleLineNatSpecComment ||
21
- kind === TerminalKind.Whitespace
22
- );
23
- }