@openzeppelin/upgrades-core 1.11.0 → 1.13.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 (109) 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 +35 -4
  9. package/dist/deployment.d.ts.map +1 -1
  10. package/dist/deployment.js +85 -28
  11. package/dist/deployment.js.map +1 -1
  12. package/dist/deployment.test.js +23 -0
  13. package/dist/deployment.test.js.map +1 -1
  14. package/dist/eip-1967-type.d.ts +1 -0
  15. package/dist/eip-1967-type.d.ts.map +1 -1
  16. package/dist/eip-1967-type.js +6 -1
  17. package/dist/eip-1967-type.js.map +1 -1
  18. package/dist/eip-1967.d.ts +1 -0
  19. package/dist/eip-1967.d.ts.map +1 -1
  20. package/dist/eip-1967.js +3 -2
  21. package/dist/eip-1967.js.map +1 -1
  22. package/dist/impl-address.js +1 -1
  23. package/dist/impl-address.js.map +1 -1
  24. package/dist/impl-store.d.ts +24 -3
  25. package/dist/impl-store.d.ts.map +1 -1
  26. package/dist/impl-store.js +77 -22
  27. package/dist/impl-store.js.map +1 -1
  28. package/dist/impl-store.test.js +24 -0
  29. package/dist/impl-store.test.js.map +1 -1
  30. package/dist/index.d.ts +6 -5
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +20 -4
  33. package/dist/index.js.map +1 -1
  34. package/dist/manifest-storage-layout.d.ts.map +1 -1
  35. package/dist/manifest-storage-layout.js +3 -2
  36. package/dist/manifest-storage-layout.js.map +1 -1
  37. package/dist/manifest-storage-layout.test.js.map +1 -1
  38. package/dist/manifest.d.ts +2 -0
  39. package/dist/manifest.d.ts.map +1 -1
  40. package/dist/manifest.js +6 -4
  41. package/dist/manifest.js.map +1 -1
  42. package/dist/manifest.test.js +32 -0
  43. package/dist/manifest.test.js.map +1 -1
  44. package/dist/provider.d.ts +1 -0
  45. package/dist/provider.d.ts.map +1 -1
  46. package/dist/provider.js +6 -2
  47. package/dist/provider.js.map +1 -1
  48. package/dist/proxy-kind.d.ts +9 -0
  49. package/dist/proxy-kind.d.ts.map +1 -1
  50. package/dist/proxy-kind.js +27 -1
  51. package/dist/proxy-kind.js.map +1 -1
  52. package/dist/scripts/migrate-oz-cli-project.test.js +1 -1
  53. package/dist/scripts/migrate-oz-cli-project.test.js.map +1 -1
  54. package/dist/solc-api.d.ts +5 -0
  55. package/dist/solc-api.d.ts.map +1 -1
  56. package/dist/standalone.test.js.map +1 -1
  57. package/dist/storage/extract.d.ts +1 -1
  58. package/dist/storage/extract.d.ts.map +1 -1
  59. package/dist/storage/extract.js +76 -38
  60. package/dist/storage/extract.js.map +1 -1
  61. package/dist/storage/layout.d.ts +4 -0
  62. package/dist/storage/layout.d.ts.map +1 -1
  63. package/dist/storage/layout.js.map +1 -1
  64. package/dist/storage/report.test.js.map +1 -1
  65. package/dist/storage.test.js +1 -1
  66. package/dist/storage.test.js.map +1 -1
  67. package/dist/usage-error.d.ts +3 -0
  68. package/dist/usage-error.d.ts.map +1 -1
  69. package/dist/usage-error.js +7 -1
  70. package/dist/usage-error.js.map +1 -1
  71. package/dist/validate/query.d.ts.map +1 -1
  72. package/dist/validate/query.js +10 -5
  73. package/dist/validate/query.js.map +1 -1
  74. package/dist/validate/run.d.ts.map +1 -1
  75. package/dist/validate/run.js +1 -1
  76. package/dist/validate/run.js.map +1 -1
  77. package/dist/validate.test.js.map +1 -1
  78. package/package.json +5 -5
  79. package/src/add-proxy-to-manifest.ts +12 -0
  80. package/src/deployment.test.ts +25 -0
  81. package/src/deployment.ts +124 -27
  82. package/src/eip-1967-type.ts +7 -0
  83. package/src/eip-1967.ts +4 -3
  84. package/src/impl-address.ts +1 -1
  85. package/src/impl-store.test.ts +33 -1
  86. package/src/impl-store.ts +91 -18
  87. package/src/index.ts +22 -4
  88. package/src/manifest-storage-layout.test.ts +3 -2
  89. package/src/manifest-storage-layout.ts +8 -3
  90. package/src/manifest.test.ts +34 -1
  91. package/src/manifest.ts +9 -4
  92. package/src/provider.ts +5 -1
  93. package/src/proxy-kind.ts +24 -1
  94. package/src/scripts/migrate-oz-cli-project.test.ts +1 -1
  95. package/src/scripts/migrate-oz-cli-project.test.ts.snap +0 -0
  96. package/src/solc-api.ts +5 -0
  97. package/src/standalone.test.ts +2 -2
  98. package/src/storage/extract.ts +98 -52
  99. package/src/storage/layout.ts +4 -0
  100. package/src/storage/report.test.ts +2 -2
  101. package/src/storage/report.test.ts.snap +0 -0
  102. package/src/storage.test.ts +3 -3
  103. package/src/storage.test.ts.snap +0 -0
  104. package/src/usage-error.ts +9 -0
  105. package/src/utils/parse-type-id.test.ts.md +106 -106
  106. package/src/utils/parse-type-id.test.ts.snap +0 -0
  107. package/src/validate/query.ts +9 -5
  108. package/src/validate/run.ts +6 -1
  109. package/src/validate.test.ts +2 -2
@@ -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 = [