@openzeppelin/upgrades-core 1.12.0 → 1.14.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 (131) hide show
  1. package/artifacts/@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol/ERC1967Proxy.dbg.json +1 -1
  2. package/artifacts/@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol/BeaconProxy.dbg.json +1 -1
  3. package/artifacts/@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol/UpgradeableBeacon.dbg.json +1 -1
  4. package/dist/add-proxy-to-manifest.d.ts +3 -0
  5. package/dist/add-proxy-to-manifest.d.ts.map +1 -0
  6. package/dist/add-proxy-to-manifest.js +15 -0
  7. package/dist/add-proxy-to-manifest.js.map +1 -0
  8. package/dist/deployment.d.ts +21 -1
  9. package/dist/deployment.d.ts.map +1 -1
  10. package/dist/deployment.js +65 -15
  11. package/dist/deployment.js.map +1 -1
  12. package/dist/eip-1967-type.d.ts +1 -0
  13. package/dist/eip-1967-type.d.ts.map +1 -1
  14. package/dist/eip-1967-type.js +6 -1
  15. package/dist/eip-1967-type.js.map +1 -1
  16. package/dist/eip-1967.d.ts +1 -0
  17. package/dist/eip-1967.d.ts.map +1 -1
  18. package/dist/eip-1967.js +3 -2
  19. package/dist/eip-1967.js.map +1 -1
  20. package/dist/impl-address.js +1 -1
  21. package/dist/impl-address.js.map +1 -1
  22. package/dist/impl-store.d.ts +22 -2
  23. package/dist/impl-store.d.ts.map +1 -1
  24. package/dist/impl-store.js +59 -15
  25. package/dist/impl-store.js.map +1 -1
  26. package/dist/impl-store.test.js +24 -0
  27. package/dist/impl-store.test.js.map +1 -1
  28. package/dist/index.d.ts +6 -5
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +20 -4
  31. package/dist/index.js.map +1 -1
  32. package/dist/manifest-storage-layout.d.ts.map +1 -1
  33. package/dist/manifest-storage-layout.js +3 -2
  34. package/dist/manifest-storage-layout.js.map +1 -1
  35. package/dist/manifest-storage-layout.test.js.map +1 -1
  36. package/dist/manifest.d.ts +2 -0
  37. package/dist/manifest.d.ts.map +1 -1
  38. package/dist/manifest.js +6 -4
  39. package/dist/manifest.js.map +1 -1
  40. package/dist/manifest.test.js +32 -0
  41. package/dist/manifest.test.js.map +1 -1
  42. package/dist/provider.d.ts +1 -0
  43. package/dist/provider.d.ts.map +1 -1
  44. package/dist/provider.js +6 -2
  45. package/dist/provider.js.map +1 -1
  46. package/dist/proxy-kind.d.ts +9 -0
  47. package/dist/proxy-kind.d.ts.map +1 -1
  48. package/dist/proxy-kind.js +27 -1
  49. package/dist/proxy-kind.js.map +1 -1
  50. package/dist/scripts/migrate-oz-cli-project.test.js +1 -1
  51. package/dist/scripts/migrate-oz-cli-project.test.js.map +1 -1
  52. package/dist/solc-api.d.ts +5 -0
  53. package/dist/solc-api.d.ts.map +1 -1
  54. package/dist/standalone.test.js.map +1 -1
  55. package/dist/storage/compare.d.ts +15 -4
  56. package/dist/storage/compare.d.ts.map +1 -1
  57. package/dist/storage/compare.js +46 -4
  58. package/dist/storage/compare.js.map +1 -1
  59. package/dist/storage/extract.d.ts +1 -1
  60. package/dist/storage/extract.d.ts.map +1 -1
  61. package/dist/storage/extract.js +96 -38
  62. package/dist/storage/extract.js.map +1 -1
  63. package/dist/storage/layout.d.ts +18 -0
  64. package/dist/storage/layout.d.ts.map +1 -1
  65. package/dist/storage/layout.js +6 -2
  66. package/dist/storage/layout.js.map +1 -1
  67. package/dist/storage/report-rename-retype.test.d.ts +2 -0
  68. package/dist/storage/report-rename-retype.test.d.ts.map +1 -0
  69. package/dist/storage/report-rename-retype.test.js +93 -0
  70. package/dist/storage/report-rename-retype.test.js.map +1 -0
  71. package/dist/storage/report.d.ts.map +1 -1
  72. package/dist/storage/report.js +32 -2
  73. package/dist/storage/report.js.map +1 -1
  74. package/dist/storage/report.test.js +6 -0
  75. package/dist/storage/report.test.js.map +1 -1
  76. package/dist/storage.test.js +11 -3
  77. package/dist/storage.test.js.map +1 -1
  78. package/dist/usage-error.d.ts +3 -0
  79. package/dist/usage-error.d.ts.map +1 -1
  80. package/dist/usage-error.js +7 -1
  81. package/dist/usage-error.js.map +1 -1
  82. package/dist/utils/execall.d.ts +2 -0
  83. package/dist/utils/execall.d.ts.map +1 -0
  84. package/dist/utils/execall.js +17 -0
  85. package/dist/utils/execall.js.map +1 -0
  86. package/dist/validate/query.d.ts.map +1 -1
  87. package/dist/validate/query.js +10 -5
  88. package/dist/validate/query.js.map +1 -1
  89. package/dist/validate/run.d.ts.map +1 -1
  90. package/dist/validate/run.js +1 -1
  91. package/dist/validate/run.js.map +1 -1
  92. package/dist/validate.test.js.map +1 -1
  93. package/package.json +4 -4
  94. package/src/add-proxy-to-manifest.ts +12 -0
  95. package/src/deployment.ts +81 -14
  96. package/src/eip-1967-type.ts +7 -0
  97. package/src/eip-1967.ts +4 -3
  98. package/src/impl-address.ts +1 -1
  99. package/src/impl-store.test.ts +33 -1
  100. package/src/impl-store.ts +69 -12
  101. package/src/index.ts +22 -4
  102. package/src/manifest-storage-layout.test.ts +3 -2
  103. package/src/manifest-storage-layout.ts +8 -3
  104. package/src/manifest.test.ts +34 -1
  105. package/src/manifest.ts +9 -4
  106. package/src/provider.ts +5 -1
  107. package/src/proxy-kind.ts +24 -1
  108. package/src/scripts/migrate-oz-cli-project.test.ts +1 -1
  109. package/src/scripts/migrate-oz-cli-project.test.ts.snap +0 -0
  110. package/src/solc-api.ts +5 -0
  111. package/src/standalone.test.ts +2 -2
  112. package/src/storage/compare.ts +57 -8
  113. package/src/storage/extract.ts +111 -52
  114. package/src/storage/layout.ts +21 -2
  115. package/src/storage/report-rename-retype.test.ts +106 -0
  116. package/src/storage/report-rename-retype.test.ts.md +44 -0
  117. package/src/storage/report-rename-retype.test.ts.snap +0 -0
  118. package/src/storage/report.test.ts +9 -2
  119. package/src/storage/report.test.ts.md +11 -0
  120. package/src/storage/report.test.ts.snap +0 -0
  121. package/src/storage/report.ts +39 -4
  122. package/src/storage.test.ts +15 -5
  123. package/src/storage.test.ts.md +348 -109
  124. package/src/storage.test.ts.snap +0 -0
  125. package/src/usage-error.ts +9 -0
  126. package/src/utils/execall.ts +11 -0
  127. package/src/utils/parse-type-id.test.ts.md +106 -106
  128. package/src/utils/parse-type-id.test.ts.snap +0 -0
  129. package/src/validate/query.ts +9 -5
  130. package/src/validate/run.ts +6 -1
  131. package/src/validate.test.ts +2 -2
Binary file
@@ -51,6 +51,15 @@ export class PrepareUpgradeUnsupportedError extends UpgradesError {
51
51
  }
52
52
  }
53
53
 
54
+ export class ForceImportUnsupportedError extends UpgradesError {
55
+ constructor(proxyOrBeaconAddress: string) {
56
+ super(
57
+ `Contract at address ${proxyOrBeaconAddress} doesn't look like a supported proxy or beacon`,
58
+ () => `Only transparent, UUPS, or beacon proxies or beacons can be used with the forceImport() function.`,
59
+ );
60
+ }
61
+ }
62
+
54
63
  export async function assertNotProxy(provider: EthereumProvider, address: string) {
55
64
  if (await isTransparentOrUUPSProxy(provider, address)) {
56
65
  throw new UpgradesError(
@@ -0,0 +1,11 @@
1
+ export function* execall(re: RegExp, text: string) {
2
+ re = new RegExp(re, re.flags + (re.sticky ? '' : 'y'));
3
+ while (true) {
4
+ const match = re.exec(text);
5
+ if (match && match[0] !== '') {
6
+ yield match;
7
+ } else {
8
+ break;
9
+ }
10
+ }
11
+ }
@@ -4,40 +4,56 @@ The actual snapshot is saved in `parse-type-id.test.ts.snap`.
4
4
 
5
5
  Generated by [AVA](https://avajs.dev).
6
6
 
7
- ## t_array(t_function_internal_nonpayable(t_uint256)returns(t_address))10_storage
7
+ ## t_uint256
8
+
9
+ > Snapshot 1
10
+
11
+ {
12
+ args: undefined,
13
+ head: 't_uint256',
14
+ id: 't_uint256',
15
+ rets: undefined,
16
+ tail: undefined,
17
+ }
18
+
19
+ ## t_enum(MyEnum)
8
20
 
9
21
  > Snapshot 1
10
22
 
11
23
  {
12
24
  args: [
13
25
  {
14
- args: [
15
- {
16
- args: undefined,
17
- head: 't_uint256',
18
- id: 't_uint256',
19
- rets: undefined,
20
- tail: undefined,
21
- },
22
- ],
23
- head: 't_function_internal_nonpayable',
24
- id: 't_function_internal_nonpayable(t_uint256)returns(t_address)',
25
- rets: [
26
- {
27
- args: undefined,
28
- head: 't_address',
29
- id: 't_address',
30
- rets: undefined,
31
- tail: undefined,
32
- },
33
- ],
26
+ args: undefined,
27
+ head: 'MyEnum',
28
+ id: 'MyEnum',
29
+ rets: undefined,
34
30
  tail: undefined,
35
31
  },
36
32
  ],
37
- head: 't_array',
38
- id: 't_array(t_function_internal_nonpayable(t_uint256)returns(t_address))10_storage',
33
+ head: 't_enum',
34
+ id: 't_enum(MyEnum)',
39
35
  rets: undefined,
40
- tail: '10_storage',
36
+ tail: undefined,
37
+ }
38
+
39
+ ## t_struct(MyComplexStruct)storage
40
+
41
+ > Snapshot 1
42
+
43
+ {
44
+ args: [
45
+ {
46
+ args: undefined,
47
+ head: 'MyComplexStruct',
48
+ id: 'MyComplexStruct',
49
+ rets: undefined,
50
+ tail: undefined,
51
+ },
52
+ ],
53
+ head: 't_struct',
54
+ id: 't_struct(MyComplexStruct)storage',
55
+ rets: undefined,
56
+ tail: 'storage',
41
57
  }
42
58
 
43
59
  ## t_array(t_uint256)3_storage
@@ -60,7 +76,7 @@ Generated by [AVA](https://avajs.dev).
60
76
  tail: '3_storage',
61
77
  }
62
78
 
63
- ## t_function_internal_nonpayable(t_uint256)returns()
79
+ ## t_mapping(t_uint256,t_uint256)
64
80
 
65
81
  > Snapshot 1
66
82
 
@@ -73,10 +89,44 @@ Generated by [AVA](https://avajs.dev).
73
89
  rets: undefined,
74
90
  tail: undefined,
75
91
  },
92
+ {
93
+ args: undefined,
94
+ head: 't_uint256',
95
+ id: 't_uint256',
96
+ rets: undefined,
97
+ tail: undefined,
98
+ },
76
99
  ],
77
- head: 't_function_internal_nonpayable',
78
- id: 't_function_internal_nonpayable(t_uint256)returns()',
79
- rets: [],
100
+ head: 't_mapping',
101
+ id: 't_mapping(t_uint256,t_uint256)',
102
+ rets: undefined,
103
+ tail: undefined,
104
+ }
105
+
106
+ ## t_mapping(unknown,t_uint256)
107
+
108
+ > Snapshot 1
109
+
110
+ {
111
+ args: [
112
+ {
113
+ args: undefined,
114
+ head: 'unknown',
115
+ id: 'unknown',
116
+ rets: undefined,
117
+ tail: undefined,
118
+ },
119
+ {
120
+ args: undefined,
121
+ head: 't_uint256',
122
+ id: 't_uint256',
123
+ rets: undefined,
124
+ tail: undefined,
125
+ },
126
+ ],
127
+ head: 't_mapping',
128
+ id: 't_mapping(unknown,t_uint256)',
129
+ rets: undefined,
80
130
  tail: undefined,
81
131
  }
82
132
 
@@ -157,58 +207,12 @@ Generated by [AVA](https://avajs.dev).
157
207
  tail: undefined,
158
208
  }
159
209
 
160
- ## t_mapping(t_uint256,t_uint256)
161
-
162
- > Snapshot 1
163
-
164
- {
165
- args: [
166
- {
167
- args: undefined,
168
- head: 't_uint256',
169
- id: 't_uint256',
170
- rets: undefined,
171
- tail: undefined,
172
- },
173
- {
174
- args: undefined,
175
- head: 't_uint256',
176
- id: 't_uint256',
177
- rets: undefined,
178
- tail: undefined,
179
- },
180
- ],
181
- head: 't_mapping',
182
- id: 't_mapping(t_uint256,t_uint256)',
183
- rets: undefined,
184
- tail: undefined,
185
- }
186
-
187
- ## t_uint256
188
-
189
- > Snapshot 1
190
-
191
- {
192
- args: undefined,
193
- head: 't_uint256',
194
- id: 't_uint256',
195
- rets: undefined,
196
- tail: undefined,
197
- }
198
-
199
- ## t_mapping(unknown,t_uint256)
210
+ ## t_function_internal_nonpayable(t_uint256)returns()
200
211
 
201
212
  > Snapshot 1
202
213
 
203
214
  {
204
215
  args: [
205
- {
206
- args: undefined,
207
- head: 'unknown',
208
- id: 'unknown',
209
- rets: undefined,
210
- tail: undefined,
211
- },
212
216
  {
213
217
  args: undefined,
214
218
  head: 't_uint256',
@@ -217,48 +221,44 @@ Generated by [AVA](https://avajs.dev).
217
221
  tail: undefined,
218
222
  },
219
223
  ],
220
- head: 't_mapping',
221
- id: 't_mapping(unknown,t_uint256)',
222
- rets: undefined,
223
- tail: undefined,
224
- }
225
-
226
- ## t_enum(MyEnum)
227
-
228
- > Snapshot 1
229
-
230
- {
231
- args: [
232
- {
233
- args: undefined,
234
- head: 'MyEnum',
235
- id: 'MyEnum',
236
- rets: undefined,
237
- tail: undefined,
238
- },
239
- ],
240
- head: 't_enum',
241
- id: 't_enum(MyEnum)',
242
- rets: undefined,
224
+ head: 't_function_internal_nonpayable',
225
+ id: 't_function_internal_nonpayable(t_uint256)returns()',
226
+ rets: [],
243
227
  tail: undefined,
244
228
  }
245
229
 
246
- ## t_struct(MyComplexStruct)storage
230
+ ## t_array(t_function_internal_nonpayable(t_uint256)returns(t_address))10_storage
247
231
 
248
232
  > Snapshot 1
249
233
 
250
234
  {
251
235
  args: [
252
236
  {
253
- args: undefined,
254
- head: 'MyComplexStruct',
255
- id: 'MyComplexStruct',
256
- rets: undefined,
237
+ args: [
238
+ {
239
+ args: undefined,
240
+ head: 't_uint256',
241
+ id: 't_uint256',
242
+ rets: undefined,
243
+ tail: undefined,
244
+ },
245
+ ],
246
+ head: 't_function_internal_nonpayable',
247
+ id: 't_function_internal_nonpayable(t_uint256)returns(t_address)',
248
+ rets: [
249
+ {
250
+ args: undefined,
251
+ head: 't_address',
252
+ id: 't_address',
253
+ rets: undefined,
254
+ tail: undefined,
255
+ },
256
+ ],
257
257
  tail: undefined,
258
258
  },
259
259
  ],
260
- head: 't_struct',
261
- id: 't_struct(MyComplexStruct)storage',
260
+ head: 't_array',
261
+ id: 't_array(t_function_internal_nonpayable(t_uint256)returns(t_address))10_storage',
262
262
  rets: undefined,
263
- tail: 'storage',
263
+ tail: '10_storage',
264
264
  }
@@ -58,13 +58,17 @@ export function getStorageLayout(data: ValidationData, version: Version): Storag
58
58
  }
59
59
 
60
60
  export function unfoldStorageLayout(runData: ValidationRunData, contractName: string): StorageLayout {
61
- const c = runData[contractName];
62
61
  const layout: StorageLayout = { storage: [], types: {} };
63
- for (const name of [contractName].concat(c.inherit)) {
64
- layout.storage.unshift(...runData[name].layout.storage);
65
- Object.assign(layout.types, runData[name].layout.types);
62
+ if (runData[contractName].layout.flat) {
63
+ return { storage: runData[contractName].layout.storage, types: runData[contractName].layout.types };
64
+ } else {
65
+ const c = runData[contractName];
66
+ for (const name of [contractName].concat(c.inherit)) {
67
+ layout.storage.unshift(...runData[name].layout.storage);
68
+ Object.assign(layout.types, runData[name].layout.types);
69
+ }
70
+ return layout;
66
71
  }
67
- return layout;
68
72
  }
69
73
 
70
74
  export function* findVersionWithoutMetadataMatches(
@@ -162,7 +162,12 @@ export function validate(solcOutput: SolcOutput, decodeSrc: SrcDecoder): Validat
162
162
  ...getLinkingErrors(contractDef, bytecode),
163
163
  ];
164
164
 
165
- validation[contractDef.name].layout = extractStorageLayout(contractDef, decodeSrc, deref);
165
+ validation[contractDef.name].layout = extractStorageLayout(
166
+ contractDef,
167
+ decodeSrc,
168
+ deref,
169
+ solcOutput.contracts[source][contractDef.name].storageLayout,
170
+ );
166
171
  validation[contractDef.name].methods = [...findAll('FunctionDefinition', contractDef)]
167
172
  .filter(fnDef => ['external', 'public'].includes(fnDef.visibility))
168
173
  .map(fnDef => getFunctionSignature(fnDef, deref));
@@ -1,4 +1,4 @@
1
- import _test, { TestInterface } from 'ava';
1
+ import _test, { TestFn } from 'ava';
2
2
  import { artifacts } from 'hardhat';
3
3
 
4
4
  import {
@@ -15,7 +15,7 @@ interface Context {
15
15
  validation: RunValidation;
16
16
  }
17
17
 
18
- const test = _test as TestInterface<Context>;
18
+ const test = _test as TestFn<Context>;
19
19
 
20
20
  test.before(async t => {
21
21
  const contracts = [