@openzeppelin/upgrades-core 1.19.1 → 1.20.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/proxy/ERC1967/ERC1967Proxy.sol/ERC1967Proxy.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol/ERC1967Proxy.json +2 -2
- package/artifacts/@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol/BeaconProxy.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol/BeaconProxy.json +2 -2
- package/artifacts/@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol/UpgradeableBeacon.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol/UpgradeableBeacon.json +2 -2
- package/artifacts/@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol/ProxyAdmin.json +2 -2
- package/artifacts/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/TransparentUpgradeableProxy.json +2 -2
- package/artifacts/AdminUpgradeabilityProxy.json +2 -2
- package/artifacts/ProxyAdmin.json +2 -2
- package/artifacts/build-info.json +1 -1
- package/artifacts/contracts/proxy/AdminUpgradeabilityProxy.sol/AdminUpgradeabilityProxy.json +2 -2
- package/artifacts/contracts/proxy/ProxyAdmin.sol/ProxyAdmin.json +2 -2
- package/dist/manifest.test.js +1 -1
- package/dist/manifest.test.js.map +1 -1
- package/dist/storage/compare.d.ts +1 -1
- package/dist/storage/compare.d.ts.map +1 -1
- package/dist/storage/compare.js +12 -1
- package/dist/storage/compare.js.map +1 -1
- package/dist/storage/extract.js +6 -4
- package/dist/storage/extract.js.map +1 -1
- package/dist/storage/layout.d.ts +1 -0
- package/dist/storage/layout.d.ts.map +1 -1
- package/dist/storage/layout.js.map +1 -1
- package/dist/storage/report.js +2 -2
- package/dist/storage-0.8.test.d.ts +2 -0
- package/dist/storage-0.8.test.d.ts.map +1 -0
- package/dist/storage-0.8.test.js +105 -0
- package/dist/storage-0.8.test.js.map +1 -0
- package/dist/storage.test.js +4 -16
- package/dist/storage.test.js.map +1 -1
- package/dist/utils/function.d.ts.map +1 -1
- package/dist/utils/function.js +11 -4
- package/dist/utils/function.js.map +1 -1
- package/dist/utils/stabilize-layout.d.ts +27 -0
- package/dist/utils/stabilize-layout.d.ts.map +1 -0
- package/dist/utils/stabilize-layout.js +19 -0
- package/dist/utils/stabilize-layout.js.map +1 -0
- package/dist/utils/type-id.js +1 -1
- package/dist/utils/type-id.js.map +1 -1
- package/dist/validate/data.d.ts +1 -1
- package/dist/validate/data.d.ts.map +1 -1
- package/dist/validate/data.js +1 -1
- package/dist/validate/query.d.ts.map +1 -1
- package/dist/validate/query.js +9 -4
- package/dist/validate/query.js.map +1 -1
- package/dist/validate/run.d.ts +2 -1
- package/dist/validate/run.d.ts.map +1 -1
- package/dist/validate/run.js +2 -1
- package/dist/validate/run.js.map +1 -1
- package/dist/validate.test.js +1 -0
- package/dist/validate.test.js.map +1 -1
- package/package.json +2 -2
- package/src/manifest.test.ts +1 -1
- package/src/storage/compare.ts +13 -2
- package/src/storage/extract.ts +7 -4
- package/src/storage/layout.ts +1 -0
- package/src/storage/report.ts +2 -2
- package/src/storage-0.8.test.ts +117 -0
- package/src/storage-0.8.test.ts.md +177 -0
- package/src/storage-0.8.test.ts.snap +0 -0
- package/src/storage.test.ts +3 -16
- package/src/utils/function.ts +14 -5
- package/src/utils/stabilize-layout.ts +17 -0
- package/src/utils/type-id.ts +1 -1
- package/src/validate/data.ts +2 -2
- package/src/validate/query.ts +9 -4
- package/src/validate/run.ts +3 -1
- package/src/validate.test.ts +1 -0
package/src/storage.test.ts
CHANGED
|
@@ -6,9 +6,10 @@ import { artifacts } from 'hardhat';
|
|
|
6
6
|
import { SolcOutput } from './solc-api';
|
|
7
7
|
import { astDereferencer } from './ast-dereferencer';
|
|
8
8
|
import { getStorageUpgradeErrors } from './storage';
|
|
9
|
-
import { StorageLayout
|
|
9
|
+
import { StorageLayout } from './storage/layout';
|
|
10
10
|
import { extractStorageLayout } from './storage/extract';
|
|
11
11
|
import { stabilizeTypeIdentifier } from './utils/type-id';
|
|
12
|
+
import { stabilizeStorageLayout } from './utils/stabilize-layout';
|
|
12
13
|
|
|
13
14
|
interface Context {
|
|
14
15
|
extractStorageLayout: (contract: string) => ReturnType<typeof extractStorageLayout>;
|
|
@@ -331,7 +332,7 @@ test('storage upgrade with enums', t => {
|
|
|
331
332
|
},
|
|
332
333
|
3: {
|
|
333
334
|
kind: 'typechange',
|
|
334
|
-
change: { kind: '
|
|
335
|
+
change: { kind: 'type resize' },
|
|
335
336
|
original: { label: 'data4' },
|
|
336
337
|
updated: { label: 'data4' },
|
|
337
338
|
},
|
|
@@ -937,17 +938,3 @@ test('storage upgrade with struct gap', t => {
|
|
|
937
938
|
},
|
|
938
939
|
});
|
|
939
940
|
});
|
|
940
|
-
|
|
941
|
-
function stabilizeStorageLayout(layout: StorageLayout) {
|
|
942
|
-
return {
|
|
943
|
-
storage: layout.storage.map(s => ({ ...s, type: stabilizeTypeIdentifier(s.type) })),
|
|
944
|
-
types: Object.entries(layout.types).map(([type, item]) => {
|
|
945
|
-
const members =
|
|
946
|
-
item.members &&
|
|
947
|
-
(isEnumMembers(item.members)
|
|
948
|
-
? item.members
|
|
949
|
-
: item.members.map(m => ({ ...m, type: stabilizeTypeIdentifier(m.type) })));
|
|
950
|
-
return [stabilizeTypeIdentifier(type), { ...item, members }];
|
|
951
|
-
}),
|
|
952
|
-
};
|
|
953
|
-
}
|
package/src/utils/function.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { FunctionDefinition, VariableDeclaration } from 'solidity-ast';
|
|
1
|
+
import type { FunctionDefinition, TypeName, VariableDeclaration } from 'solidity-ast';
|
|
2
2
|
import { ASTDereferencer } from '../ast-dereferencer';
|
|
3
3
|
import { assert, assertUnreachable } from './assert';
|
|
4
4
|
|
|
5
|
-
function
|
|
5
|
+
function serializeParameterType(parameter: VariableDeclaration, deref: ASTDereferencer): string {
|
|
6
6
|
const { typeName, storageLocation } = parameter;
|
|
7
7
|
assert(!!typeName);
|
|
8
8
|
|
|
@@ -11,6 +11,10 @@ function serializeTypeName(parameter: VariableDeclaration, deref: ASTDereference
|
|
|
11
11
|
return typeName.typeDescriptions.typeString.replace(/^struct /, '') + ' storage';
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
return serializeTypeName(typeName, deref);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function serializeTypeName(typeName: TypeName, deref: ASTDereferencer): string {
|
|
14
18
|
switch (typeName.nodeType) {
|
|
15
19
|
case 'ArrayTypeName':
|
|
16
20
|
case 'ElementaryTypeName': {
|
|
@@ -20,12 +24,12 @@ function serializeTypeName(parameter: VariableDeclaration, deref: ASTDereference
|
|
|
20
24
|
|
|
21
25
|
case 'UserDefinedTypeName': {
|
|
22
26
|
const userDefinedType = deref(
|
|
23
|
-
['StructDefinition', 'EnumDefinition', 'ContractDefinition'],
|
|
27
|
+
['StructDefinition', 'EnumDefinition', 'ContractDefinition', 'UserDefinedValueTypeDefinition'],
|
|
24
28
|
typeName.referencedDeclaration,
|
|
25
29
|
);
|
|
26
30
|
switch (userDefinedType.nodeType) {
|
|
27
31
|
case 'StructDefinition':
|
|
28
|
-
return '(' + userDefinedType.members.map(member =>
|
|
32
|
+
return '(' + userDefinedType.members.map(member => serializeParameterType(member, deref)) + ')';
|
|
29
33
|
|
|
30
34
|
case 'EnumDefinition':
|
|
31
35
|
assert(userDefinedType.members.length < 256);
|
|
@@ -34,6 +38,9 @@ function serializeTypeName(parameter: VariableDeclaration, deref: ASTDereference
|
|
|
34
38
|
case 'ContractDefinition':
|
|
35
39
|
return 'address';
|
|
36
40
|
|
|
41
|
+
case 'UserDefinedValueTypeDefinition':
|
|
42
|
+
return serializeTypeName(userDefinedType.underlyingType, deref);
|
|
43
|
+
|
|
37
44
|
default:
|
|
38
45
|
return assertUnreachable(userDefinedType);
|
|
39
46
|
}
|
|
@@ -49,5 +56,7 @@ function serializeTypeName(parameter: VariableDeclaration, deref: ASTDereference
|
|
|
49
56
|
}
|
|
50
57
|
|
|
51
58
|
export function getFunctionSignature(fnDef: FunctionDefinition, deref: ASTDereferencer): string {
|
|
52
|
-
return `${fnDef.name}(${fnDef.parameters.parameters
|
|
59
|
+
return `${fnDef.name}(${fnDef.parameters.parameters
|
|
60
|
+
.map(parameter => serializeParameterType(parameter, deref))
|
|
61
|
+
.join()})`;
|
|
53
62
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { StorageLayout } from '../storage';
|
|
2
|
+
import { isEnumMembers } from '../storage/layout';
|
|
3
|
+
import { stabilizeTypeIdentifier } from './type-id';
|
|
4
|
+
|
|
5
|
+
export function stabilizeStorageLayout(layout: StorageLayout) {
|
|
6
|
+
return {
|
|
7
|
+
storage: layout.storage.map(s => ({ ...s, type: stabilizeTypeIdentifier(s.type) })),
|
|
8
|
+
types: Object.entries(layout.types).map(([type, item]) => {
|
|
9
|
+
const members =
|
|
10
|
+
item.members &&
|
|
11
|
+
(isEnumMembers(item.members)
|
|
12
|
+
? item.members
|
|
13
|
+
: item.members.map(m => ({ ...m, type: stabilizeTypeIdentifier(m.type) })));
|
|
14
|
+
return [stabilizeTypeIdentifier(type), { ...item, members }];
|
|
15
|
+
}),
|
|
16
|
+
};
|
|
17
|
+
}
|
package/src/utils/type-id.ts
CHANGED
|
@@ -35,7 +35,7 @@ export function normalizeTypeIdentifier(typeIdentifier: string): string {
|
|
|
35
35
|
// identifier by removing all AST ids.
|
|
36
36
|
export function stabilizeTypeIdentifier(typeIdentifier: string): string {
|
|
37
37
|
let decoded = decodeTypeIdentifier(typeIdentifier);
|
|
38
|
-
const re = /(t_struct|t_enum|t_contract)\(/g;
|
|
38
|
+
const re = /(t_struct|t_enum|t_contract|t_userDefinedValueType)\(/g;
|
|
39
39
|
let match;
|
|
40
40
|
while ((match = re.exec(decoded))) {
|
|
41
41
|
let i;
|
package/src/validate/data.ts
CHANGED
|
@@ -7,10 +7,10 @@ type ValidationDataV1 = ValidationRunData;
|
|
|
7
7
|
type ValidationDataV2 = ValidationRunData[];
|
|
8
8
|
|
|
9
9
|
const currentMajor = '3';
|
|
10
|
-
const currentVersion = '3.
|
|
10
|
+
const currentVersion = '3.3';
|
|
11
11
|
|
|
12
12
|
interface ValidationDataV3 {
|
|
13
|
-
version: '3' | '3.1' | '3.2';
|
|
13
|
+
version: '3' | '3.1' | '3.2' | '3.3';
|
|
14
14
|
log: ValidationRunData[];
|
|
15
15
|
}
|
|
16
16
|
|
package/src/validate/query.ts
CHANGED
|
@@ -58,11 +58,16 @@ export function getStorageLayout(data: ValidationData, version: Version): Storag
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
export function unfoldStorageLayout(runData: ValidationRunData, contractName: string): StorageLayout {
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
const c = runData[contractName];
|
|
62
|
+
const { solcVersion } = c;
|
|
63
|
+
if (c.layout.flat) {
|
|
64
|
+
return {
|
|
65
|
+
solcVersion,
|
|
66
|
+
storage: c.layout.storage,
|
|
67
|
+
types: c.layout.types,
|
|
68
|
+
};
|
|
64
69
|
} else {
|
|
65
|
-
const
|
|
70
|
+
const layout: StorageLayout = { solcVersion, storage: [], types: {} };
|
|
66
71
|
for (const name of [contractName].concat(c.inherit)) {
|
|
67
72
|
layout.storage.unshift(...runData[name].layout.storage);
|
|
68
73
|
Object.assign(layout.types, runData[name].layout.types);
|
package/src/validate/run.ts
CHANGED
|
@@ -23,6 +23,7 @@ export interface ContractValidation {
|
|
|
23
23
|
linkReferences: LinkReference[];
|
|
24
24
|
errors: ValidationError[];
|
|
25
25
|
layout: StorageLayout;
|
|
26
|
+
solcVersion?: string;
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
const errorKinds = [
|
|
@@ -113,7 +114,7 @@ function skipCheck(error: string, node: Node): boolean {
|
|
|
113
114
|
return getAllowed(node).includes(error);
|
|
114
115
|
}
|
|
115
116
|
|
|
116
|
-
export function validate(solcOutput: SolcOutput, decodeSrc: SrcDecoder): ValidationRunData {
|
|
117
|
+
export function validate(solcOutput: SolcOutput, decodeSrc: SrcDecoder, solcVersion?: string): ValidationRunData {
|
|
117
118
|
const validation: ValidationRunData = {};
|
|
118
119
|
const fromId: Record<number, string> = {};
|
|
119
120
|
const inheritIds: Record<string, number[]> = {};
|
|
@@ -139,6 +140,7 @@ export function validate(solcOutput: SolcOutput, decodeSrc: SrcDecoder): Validat
|
|
|
139
140
|
storage: [],
|
|
140
141
|
types: {},
|
|
141
142
|
},
|
|
143
|
+
solcVersion,
|
|
142
144
|
};
|
|
143
145
|
}
|
|
144
146
|
|
package/src/validate.test.ts
CHANGED
|
@@ -22,6 +22,7 @@ test.before(async t => {
|
|
|
22
22
|
'contracts/test/Validations.sol:HasEmptyConstructor',
|
|
23
23
|
'contracts/test/ValidationsNatspec.sol:HasNonEmptyConstructorNatspec1',
|
|
24
24
|
'contracts/test/Proxiable.sol:ChildOfProxiable',
|
|
25
|
+
'contracts/test/ValidationsUDVT.sol:ValidationsUDVT',
|
|
25
26
|
];
|
|
26
27
|
|
|
27
28
|
t.context.validation = {} as RunValidation;
|