@openzeppelin/upgrades-core 1.45.0 → 1.47.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 (88) hide show
  1. package/dist/cli/validate/validate-upgrade-safety.test.js +18 -0
  2. package/dist/cli/validate/validate-upgrade-safety.test.js.map +1 -1
  3. package/dist/storage/compare.d.ts.map +1 -1
  4. package/dist/storage/compare.js +3 -3
  5. package/dist/storage/compare.js.map +1 -1
  6. package/dist/storage/extract.d.ts +15 -3
  7. package/dist/storage/extract.d.ts.map +1 -1
  8. package/dist/storage/extract.js +68 -22
  9. package/dist/storage/extract.js.map +1 -1
  10. package/dist/storage/namespace.d.ts.map +1 -1
  11. package/dist/storage/namespace.js +26 -13
  12. package/dist/storage/namespace.js.map +1 -1
  13. package/dist/storage/report-rename-retype.test.js +30 -0
  14. package/dist/storage/report-rename-retype.test.js.map +1 -1
  15. package/dist/storage/report.js +9 -1
  16. package/dist/storage/report.js.map +1 -1
  17. package/dist/storage-erc7201-builtin.test.d.ts +2 -0
  18. package/dist/storage-erc7201-builtin.test.d.ts.map +1 -0
  19. package/dist/storage-erc7201-builtin.test.js +105 -0
  20. package/dist/storage-erc7201-builtin.test.js.map +1 -0
  21. package/dist/storage-namespaced-renamed-retyped.test.d.ts +2 -0
  22. package/dist/storage-namespaced-renamed-retyped.test.d.ts.map +1 -0
  23. package/dist/storage-namespaced-renamed-retyped.test.js +278 -0
  24. package/dist/storage-namespaced-renamed-retyped.test.js.map +1 -0
  25. package/dist/storage-struct-member-renamed-retyped.test.d.ts +2 -0
  26. package/dist/storage-struct-member-renamed-retyped.test.d.ts.map +1 -0
  27. package/dist/storage-struct-member-renamed-retyped.test.js +256 -0
  28. package/dist/storage-struct-member-renamed-retyped.test.js.map +1 -0
  29. package/dist/utils/annotations.d.ts +1 -0
  30. package/dist/utils/annotations.d.ts.map +1 -1
  31. package/dist/utils/annotations.js +4 -1
  32. package/dist/utils/annotations.js.map +1 -1
  33. package/dist/utils/erc7201-builtin.d.ts +24 -0
  34. package/dist/utils/erc7201-builtin.d.ts.map +1 -0
  35. package/dist/utils/erc7201-builtin.js +83 -0
  36. package/dist/utils/erc7201-builtin.js.map +1 -0
  37. package/dist/utils/erc7201.d.ts.map +1 -1
  38. package/dist/utils/erc7201.js +5 -3
  39. package/dist/utils/erc7201.js.map +1 -1
  40. package/dist/utils/erc7201.test.js +10 -0
  41. package/dist/utils/erc7201.test.js.map +1 -1
  42. package/dist/utils/integer-literals.d.ts +19 -6
  43. package/dist/utils/integer-literals.d.ts.map +1 -1
  44. package/dist/utils/integer-literals.js +28 -10
  45. package/dist/utils/integer-literals.js.map +1 -1
  46. package/dist/utils/integer-literals.test.js +12 -0
  47. package/dist/utils/integer-literals.test.js.map +1 -1
  48. package/dist/utils/struct-member-docs.d.ts +52 -0
  49. package/dist/utils/struct-member-docs.d.ts.map +1 -0
  50. package/dist/utils/struct-member-docs.js +264 -0
  51. package/dist/utils/struct-member-docs.js.map +1 -0
  52. package/dist/utils/struct-member-docs.test.d.ts +2 -0
  53. package/dist/utils/struct-member-docs.test.d.ts.map +1 -0
  54. package/dist/utils/struct-member-docs.test.js +320 -0
  55. package/dist/utils/struct-member-docs.test.js.map +1 -0
  56. package/dist/validate/data.d.ts +1 -1
  57. package/dist/validate/data.d.ts.map +1 -1
  58. package/dist/validate/data.js +1 -1
  59. package/dist/validate/run.d.ts +1 -1
  60. package/dist/validate/run.d.ts.map +1 -1
  61. package/dist/validate/run.js +22 -2
  62. package/dist/validate/run.js.map +1 -1
  63. package/package.json +5 -5
  64. package/src/cli/validate/validate-upgrade-safety.test.ts +35 -0
  65. package/src/cli/validate/validate-upgrade-safety.test.ts.md +10 -0
  66. package/src/cli/validate/validate-upgrade-safety.test.ts.snap +0 -0
  67. package/src/storage/compare.ts +3 -4
  68. package/src/storage/extract.ts +83 -30
  69. package/src/storage/namespace.ts +31 -14
  70. package/src/storage/report-rename-retype.test.ts +41 -0
  71. package/src/storage/report.ts +9 -1
  72. package/src/storage-erc7201-builtin.test.ts +127 -0
  73. package/src/storage-namespaced-renamed-retyped.test.ts +338 -0
  74. package/src/storage-namespaced-renamed-retyped.test.ts.md +183 -0
  75. package/src/storage-namespaced-renamed-retyped.test.ts.snap +0 -0
  76. package/src/storage-struct-member-renamed-retyped.test.ts +299 -0
  77. package/src/storage-struct-member-renamed-retyped.test.ts.md +260 -0
  78. package/src/storage-struct-member-renamed-retyped.test.ts.snap +0 -0
  79. package/src/utils/annotations.ts +4 -4
  80. package/src/utils/erc7201-builtin.ts +91 -0
  81. package/src/utils/erc7201.test.ts +12 -0
  82. package/src/utils/erc7201.ts +6 -4
  83. package/src/utils/integer-literals.test.ts +15 -1
  84. package/src/utils/integer-literals.ts +29 -10
  85. package/src/utils/struct-member-docs.test.ts +351 -0
  86. package/src/utils/struct-member-docs.ts +293 -0
  87. package/src/validate/data.ts +2 -2
  88. package/src/validate/run.ts +23 -1
@@ -0,0 +1,256 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const ava_1 = __importDefault(require("ava"));
7
+ const hardhat_1 = require("hardhat");
8
+ const utils_1 = require("solidity-ast/utils");
9
+ const validate_1 = require("./validate");
10
+ const overrides_1 = require("./validate/overrides");
11
+ const src_decoder_1 = require("./src-decoder");
12
+ const storage_1 = require("./storage");
13
+ const layout_1 = require("./storage/layout");
14
+ const stabilize_layout_1 = require("./utils/stabilize-layout");
15
+ const source = 'contracts/test/StructMemberRenamedRetyped.sol';
16
+ const test = ava_1.default;
17
+ test.before(async (t) => {
18
+ const buildInfo = await hardhat_1.artifacts.getBuildInfo(`${source}:StructMemberRenamedRetypedV1`);
19
+ if (buildInfo === undefined) {
20
+ throw new Error('Build info not found');
21
+ }
22
+ t.context.buildInfo = buildInfo;
23
+ // The source decoder always uses the original build info, since the tests below only modify the input in ways
24
+ // that keep line numbers unchanged.
25
+ const decodeSrc = (0, src_decoder_1.solcInputOutputDecoder)(buildInfo.input, buildInfo.output);
26
+ t.context.validate = (solcInput = buildInfo.input, solcOutput = buildInfo.output) => (0, validate_1.validate)(solcOutput, decodeSrc, buildInfo.solcVersion, solcInput);
27
+ const validation = t.context.validate();
28
+ t.context.layout = contract => validation[`${source}:${contract}`].layout;
29
+ });
30
+ function getStructMembers(layout, label) {
31
+ const members = Object.values(layout.types).find(type => type.label === label)?.members;
32
+ if (members === undefined || !(0, layout_1.isStructMembers)(members)) {
33
+ throw new Error(`Struct members not found for ${label}`);
34
+ }
35
+ return members;
36
+ }
37
+ /**
38
+ * Replaces the given comment inside a struct body with code of the same length, so that the AST offsets still line up
39
+ * but the text between two members is not whitespace or comments, as it would be with syntax that is not supported.
40
+ */
41
+ function withUnexpectedStructSyntax(solcInput, comment) {
42
+ const content = solcInput.sources[source].content;
43
+ if (content === undefined || !content.includes(comment)) {
44
+ throw new Error(`Comment ${comment} not found in ${source}`);
45
+ }
46
+ const code = 'uint256 q;'.padEnd(comment.length);
47
+ return { ...solcInput, sources: { ...solcInput.sources, [source]: { content: content.replace(comment, code) } } };
48
+ }
49
+ test('layout', t => {
50
+ t.snapshot((0, stabilize_layout_1.stabilizeStorageLayout)(t.context.layout('StructMemberRenamedRetypedV2')));
51
+ });
52
+ test('upgrade ok', t => {
53
+ const v1 = t.context.layout('StructMemberRenamedRetypedV1');
54
+ const v2 = t.context.layout('StructMemberRenamedRetypedV2');
55
+ t.deepEqual((0, storage_1.getStorageUpgradeErrors)(v1, v2), []);
56
+ });
57
+ test('exact map', t => {
58
+ const members = getStructMembers(t.context.layout('StructMemberExactMap'), 'struct StructMemberExactMap.S');
59
+ t.is(members.length, 5);
60
+ for (const member of members) {
61
+ t.is(member.renamedFrom, `old_${member.label}`);
62
+ t.is(member.retypedFrom, undefined);
63
+ }
64
+ });
65
+ test('wrong retype', t => {
66
+ const v1 = t.context.layout('StructMemberBadV1');
67
+ const v2 = t.context.layout('StructMemberWrongRetypeV2');
68
+ t.like((0, storage_1.getStorageUpgradeErrors)(v1, v2), {
69
+ length: 1,
70
+ 0: {
71
+ kind: 'typechange',
72
+ change: {
73
+ kind: 'struct members',
74
+ ops: {
75
+ length: 1,
76
+ 0: { kind: 'typechange', original: { label: 'x' }, updated: { label: 'x', retypedFrom: 'address' } },
77
+ },
78
+ },
79
+ original: { label: 's' },
80
+ updated: { label: 's' },
81
+ },
82
+ });
83
+ });
84
+ test('retype with layout change', t => {
85
+ // A retype annotation that names the original type does not allow the member's size to change
86
+ const v1 = t.context.layout('StructMemberRetypeLayoutChangeV1');
87
+ const v2 = t.context.layout('StructMemberRetypeLayoutChangeV2');
88
+ t.like((0, storage_1.getStorageUpgradeErrors)(v1, v2), {
89
+ length: 1,
90
+ 0: {
91
+ kind: 'typechange',
92
+ change: {
93
+ kind: 'struct members',
94
+ ops: {
95
+ length: 1,
96
+ 0: {
97
+ kind: 'layoutchange',
98
+ original: { label: 'y' },
99
+ updated: { label: 'y', retypedFrom: 'uint256' },
100
+ change: { bytes: { from: '32', to: '16' } },
101
+ },
102
+ },
103
+ },
104
+ original: { label: 's' },
105
+ updated: { label: 's' },
106
+ },
107
+ });
108
+ });
109
+ test('annotation on the wrong member', t => {
110
+ // The annotation makes `x` match the original `y` with a different type, and `x` and `z` are left unmatched
111
+ const v1 = t.context.layout('StructMemberBadV1');
112
+ const v2 = t.context.layout('StructMemberWrongMemberV2');
113
+ t.like((0, storage_1.getStorageUpgradeErrors)(v1, v2), {
114
+ length: 1,
115
+ 0: {
116
+ kind: 'typechange',
117
+ change: {
118
+ kind: 'struct members',
119
+ ops: {
120
+ length: 3,
121
+ 0: { kind: 'delete', original: { label: 'x' } },
122
+ 1: { kind: 'typechange', original: { label: 'y' }, updated: { label: 'x', renamedFrom: 'y' } },
123
+ 2: { kind: 'insert', updated: { label: 'z' } },
124
+ },
125
+ },
126
+ original: { label: 's' },
127
+ updated: { label: 's' },
128
+ },
129
+ });
130
+ });
131
+ test('stale rename annotation', t => {
132
+ const v1 = t.context.layout('StructMemberBadV1');
133
+ const v2 = t.context.layout('StructMemberStaleRenameV2');
134
+ t.like((0, storage_1.getStorageUpgradeErrors)(v1, v2), {
135
+ length: 1,
136
+ 0: {
137
+ kind: 'typechange',
138
+ change: {
139
+ kind: 'struct members',
140
+ ops: {
141
+ length: 1,
142
+ 0: { kind: 'rename', original: { label: 'y' }, updated: { label: 'y', renamedFrom: 'q' } },
143
+ },
144
+ },
145
+ original: { label: 's' },
146
+ updated: { label: 's' },
147
+ },
148
+ });
149
+ });
150
+ test('unannotated rename and retype', t => {
151
+ const v1 = t.context.layout('StructMemberBadV1');
152
+ const v2 = t.context.layout('StructMemberUnannotatedV2');
153
+ t.like((0, storage_1.getStorageUpgradeErrors)(v1, v2), {
154
+ length: 1,
155
+ 0: {
156
+ kind: 'typechange',
157
+ change: {
158
+ kind: 'struct members',
159
+ ops: {
160
+ length: 2,
161
+ 0: { kind: 'typechange', original: { label: 'x' }, updated: { label: 'x' } },
162
+ 1: { kind: 'rename', original: { label: 'y' }, updated: { label: 'z' } },
163
+ },
164
+ },
165
+ original: { label: 's' },
166
+ updated: { label: 's' },
167
+ },
168
+ });
169
+ });
170
+ test('annotated members without layout info', t => {
171
+ // Without the compiler's storage layout, members have no slots. A retype that is not known to be compatible is then uncertain.
172
+ const solcOutput = JSON.parse(JSON.stringify(t.context.buildInfo.output));
173
+ for (const contracts of Object.values(solcOutput.contracts)) {
174
+ for (const contract of Object.values(contracts)) {
175
+ delete contract.storageLayout;
176
+ }
177
+ }
178
+ const validation = t.context.validate(undefined, solcOutput);
179
+ const v1 = validation[`${source}:StructMemberRenamedRetypedV1`].layout;
180
+ const v2 = validation[`${source}:StructMemberRenamedRetypedV2`].layout;
181
+ const report = (0, storage_1.getStorageUpgradeReport)(v1, v2, (0, overrides_1.withValidationDefaults)({}));
182
+ t.false(report.ok);
183
+ t.like(report.ops, {
184
+ length: 4,
185
+ 0: { kind: 'typechange', original: { label: 's' } },
186
+ 1: { kind: 'typechange', original: { label: 'm' } },
187
+ 2: { kind: 'typechange', original: { label: 'arr' } },
188
+ 3: { kind: 'typechange', original: { label: 'other' } },
189
+ });
190
+ t.true(report.explain().includes('Layout could have changed for `x` (bytes32 -> struct TransientSlot.TBytes32)'), report.explain());
191
+ t.snapshot(report.explain());
192
+ });
193
+ test('annotations are not read without source content', t => {
194
+ const { input } = t.context.buildInfo;
195
+ const sources = Object.fromEntries(Object.keys(input.sources).map(path => [path, {}]));
196
+ const validation = t.context.validate({ ...input, sources });
197
+ const v1 = validation[`${source}:StructMemberRenamedRetypedV1`].layout;
198
+ const v2 = validation[`${source}:StructMemberRenamedRetypedV2`].layout;
199
+ t.like((0, storage_1.getStorageUpgradeErrors)(v1, v2), {
200
+ length: 5,
201
+ 0: { kind: 'typechange', original: { label: 's' } },
202
+ 1: { kind: 'typechange', original: { label: 'm' } },
203
+ 2: { kind: 'typechange', original: { label: 'arr' } },
204
+ 3: { kind: 'typechange', original: { label: 'outer' } },
205
+ 4: { kind: 'typechange', original: { label: 'other' } },
206
+ });
207
+ });
208
+ test('unexpected syntax in struct with annotations', t => {
209
+ const { input, output } = t.context.buildInfo;
210
+ const structDef = [...(0, utils_1.findAll)('StructDefinition', output.sources[source].ast)].find(s => s.canonicalName === 'StructMemberUnreadableAnnotated.S');
211
+ if (structDef === undefined) {
212
+ throw new Error('Struct not found');
213
+ }
214
+ const structSrc = (0, src_decoder_1.solcInputOutputDecoder)(input, output)(structDef);
215
+ const error = t.throws(() => t.context.validate(withUnexpectedStructSyntax(input, '// 12345678')));
216
+ t.true(error?.message.includes(`${structSrc}: Could not read storage annotations on members of struct \`StructMemberUnreadableAnnotated.S\``), error?.message);
217
+ t.true(error?.message.includes('Please report this at https://zpl.in/upgrades/report and include the struct definition from your contract.'), error?.message);
218
+ });
219
+ test('unexpected syntax in struct without annotations', t => {
220
+ const validation = t.context.validate(withUnexpectedStructSyntax(t.context.buildInfo.input, '// 87654321'));
221
+ const layout = validation[`${source}:StructMemberUnreadableUnannotated`].layout;
222
+ t.like(getStructMembers(layout, 'struct StructMemberUnreadableUnannotated.S'), {
223
+ length: 2,
224
+ 0: { label: 'b', renamedFrom: undefined, retypedFrom: undefined },
225
+ 1: { label: 'c', renamedFrom: undefined, retypedFrom: undefined },
226
+ });
227
+ // Other structs are unaffected
228
+ const v1 = validation[`${source}:StructMemberRenamedRetypedV1`].layout;
229
+ const v2 = validation[`${source}:StructMemberRenamedRetypedV2`].layout;
230
+ t.deepEqual((0, storage_1.getStorageUpgradeErrors)(v1, v2), []);
231
+ });
232
+ test('unexpected syntax in struct with other annotations', t => {
233
+ const validation = t.context.validate(withUnexpectedStructSyntax(t.context.buildInfo.input, '// 13572468'));
234
+ const layout = validation[`${source}:StructMemberUnreadableOtherAnnotation`].layout;
235
+ t.like(getStructMembers(layout, 'struct StructMemberUnreadableOtherAnnotation.S'), {
236
+ length: 2,
237
+ 0: { label: 'b', renamedFrom: undefined, retypedFrom: undefined },
238
+ 1: { label: 'c', renamedFrom: undefined, retypedFrom: undefined },
239
+ });
240
+ });
241
+ test('multiple annotations in a doc block without line prefixes', t => {
242
+ const layout = t.context.layout('StateVariableDocBlock');
243
+ t.like(layout.storage, { length: 1, 0: { label: 'x', renamedFrom: 'a', retypedFrom: 'uint8' } });
244
+ });
245
+ test('stale rename annotation report', t => {
246
+ const v1 = t.context.layout('StructMemberBadV1');
247
+ const v2 = t.context.layout('StructMemberStaleRenameV2');
248
+ const report = (0, storage_1.getStorageUpgradeReport)(v1, v2, (0, overrides_1.withValidationDefaults)({}));
249
+ t.false(report.ok);
250
+ t.is(report.explain(), `${v2.storage[0].src}: Upgraded \`s\` to an incompatible type\n` +
251
+ ' - Bad upgrade from struct StructMemberBadV1.S to struct StructMemberStaleRenameV2.S\n' +
252
+ ' - In struct StructMemberStaleRenameV2.S\n' +
253
+ " - `y` has a '@custom:oz-renamed-from q' annotation, but it was not renamed\n" +
254
+ ' > If the annotation is left over from an earlier upgrade, remove it.');
255
+ });
256
+ //# sourceMappingURL=storage-struct-member-renamed-retyped.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage-struct-member-renamed-retyped.test.js","sourceRoot":"","sources":["../src/storage-struct-member-renamed-retyped.test.ts"],"names":[],"mappings":";;;;;AAAA,8CAAoC;AACpC,qCAAoC;AAEpC,8CAA6C;AAG7C,yCAAyD;AACzD,oDAA8D;AAC9D,+CAAuD;AACvD,uCAA6E;AAC7E,6CAAkE;AAClE,+DAAkE;AAElE,MAAM,MAAM,GAAG,+CAA+C,CAAC;AAQ/D,MAAM,IAAI,GAAG,aAAwB,CAAC;AAEtC,IAAI,CAAC,MAAM,CAAC,KAAK,EAAC,CAAC,EAAC,EAAE;IACpB,MAAM,SAAS,GAAG,MAAM,mBAAS,CAAC,YAAY,CAAC,GAAG,MAAM,+BAA+B,CAAC,CAAC;IACzF,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAC1C,CAAC;IACD,CAAC,CAAC,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAChC,8GAA8G;IAC9G,oCAAoC;IACpC,MAAM,SAAS,GAAG,IAAA,oCAAsB,EAAC,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IAC5E,CAAC,CAAC,OAAO,CAAC,QAAQ,GAAG,CAAC,SAAS,GAAG,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,CAAC,MAAM,EAAE,EAAE,CAClF,IAAA,mBAAQ,EAAC,UAAU,EAAE,SAAS,EAAE,SAAS,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;IACpE,MAAM,UAAU,GAAG,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;IACxC,CAAC,CAAC,OAAO,CAAC,MAAM,GAAG,QAAQ,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,MAAM,IAAI,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AAC;IAC3E,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACnB,CAAC,CAAC,EAAE,CACF,MAAM,CAAC,OAAO,EAAE,EAChB,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,4CAA4C;QAC9D,yFAAyF;QACzF,6CAA6C;QAC7C,kFAAkF;QAClF,4EAA4E,CAC/E,CAAC;AACJ,CAAC,CAAC,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { Node } from 'solidity-ast/node';
2
+ export declare const ANNOTATION_REGEX: RegExp;
2
3
  /**
3
4
  * Whether the given doc string has an annotation tag.
4
5
  */
@@ -1 +1 @@
1
- {"version":3,"file":"annotations.d.ts","sourceRoot":"","sources":["../../src/utils/annotations.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAGlE;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,YAuB5F;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,UAM1C"}
1
+ {"version":3,"file":"annotations.d.ts","sourceRoot":"","sources":["../../src/utils/annotations.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAGzC,eAAO,MAAM,gBAAgB,QAAqF,CAAC;AAEnH;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAGlE;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,YAoB5F;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,UAM1C"}
@@ -1,9 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ANNOTATION_REGEX = void 0;
3
4
  exports.hasAnnotationTag = hasAnnotationTag;
4
5
  exports.getAnnotationArgs = getAnnotationArgs;
5
6
  exports.getDocumentation = getDocumentation;
6
7
  const execall_1 = require("./execall");
8
+ // Matches one NatSpec tag: `@title:tag args`, where the args run until the next line that starts with a tag
9
+ exports.ANNOTATION_REGEX = /^\s*(?:@(?<title>\w+)(?::(?<tag>[a-z][a-z-]*))? )?(?<args>(?:(?!^\s*@\w+)[^])*)/m;
7
10
  /**
8
11
  * Whether the given doc string has an annotation tag.
9
12
  */
@@ -20,7 +23,7 @@ function hasAnnotationTag(doc, tag) {
20
23
  */
21
24
  function getAnnotationArgs(doc, tag, supportedArgs) {
22
25
  const result = [];
23
- for (const { groups } of (0, execall_1.execall)(/^\s*(?:@(?<title>\w+)(?::(?<tag>[a-z][a-z-]*))? )?(?<args>(?:(?!^\s*@\w+)[^])*)/m, doc)) {
26
+ for (const { groups } of (0, execall_1.execall)(exports.ANNOTATION_REGEX, doc)) {
24
27
  if (groups && groups.title === 'custom' && groups.tag === tag) {
25
28
  const trimmedArgs = groups.args.trim();
26
29
  if (trimmedArgs.length > 0) {
@@ -1 +1 @@
1
- {"version":3,"file":"annotations.js","sourceRoot":"","sources":["../../src/utils/annotations.ts"],"names":[],"mappings":";;AAMA,4CAGC;AASD,8CAuBC;AAOD,4CAMC;AAtDD,uCAAoC;AAGpC;;GAEG;AACH,SAAgB,gBAAgB,CAAC,GAAW,EAAE,GAAW;IACvD,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,iBAAiB,GAAG,UAAU,EAAE,GAAG,CAAC,CAAC;IAC9D,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,C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AM,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,SAAgB,gBAAgB,CAAC,IAAU;IACzC,IAAI,eAAe,IAAI,IAAI,EAAE,CAAC;QAC5B,OAAO,OAAO,IAAI,CAAC,aAAa,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;IACxG,CAAC;SAAM,CAAC;QACN,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { Expression } from 'solidity-ast';
2
+ /**
3
+ * Recognizes the Solidity 0.8.35+ `erc7201(string)` comptime builtin, which evaluates the ERC-7201
4
+ * storage location for a namespace id and can be used in a compile-time context such as a `layout at`
5
+ * specifier (e.g. `contract C layout at erc7201("example.main")`).
6
+ *
7
+ * The builtin compiles to an ordinary `FunctionCall` node, so it is matched by its shape rather than
8
+ * by a dedicated AST node type.
9
+ *
10
+ * @param node The expression to check.
11
+ * @returns The namespace id passed to the builtin (without the `erc7201:` prefix), or undefined if the
12
+ * expression is not a call to the `erc7201` builtin with a single string literal argument.
13
+ */
14
+ export declare function getErc7201BuiltinNamespaceId(node: Expression): string | undefined;
15
+ /**
16
+ * Resolves an expression to its base slot as a normalized uint256 hex string, for either a numeric
17
+ * literal or an `erc7201(...)` builtin call.
18
+ *
19
+ * @param node The expression to resolve.
20
+ * @returns The normalized base slot hex string, or undefined if the expression is neither a numeric
21
+ * literal nor a resolvable `erc7201(...)` builtin call.
22
+ */
23
+ export declare function resolveBaseSlot(node: Expression): string | undefined;
24
+ //# sourceMappingURL=erc7201-builtin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"erc7201-builtin.d.ts","sourceRoot":"","sources":["../../src/utils/erc7201-builtin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAW,MAAM,cAAc,CAAC;AAKnD;;;;;;;;;;;GAWG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,CAmCjF;AAUD;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,CAWpE"}
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getErc7201BuiltinNamespaceId = getErc7201BuiltinNamespaceId;
4
+ exports.resolveBaseSlot = resolveBaseSlot;
5
+ const erc7201_1 = require("./erc7201");
6
+ const integer_literals_1 = require("./integer-literals");
7
+ const error_1 = require("../error");
8
+ /**
9
+ * Recognizes the Solidity 0.8.35+ `erc7201(string)` comptime builtin, which evaluates the ERC-7201
10
+ * storage location for a namespace id and can be used in a compile-time context such as a `layout at`
11
+ * specifier (e.g. `contract C layout at erc7201("example.main")`).
12
+ *
13
+ * The builtin compiles to an ordinary `FunctionCall` node, so it is matched by its shape rather than
14
+ * by a dedicated AST node type.
15
+ *
16
+ * @param node The expression to check.
17
+ * @returns The namespace id passed to the builtin (without the `erc7201:` prefix), or undefined if the
18
+ * expression is not a call to the `erc7201` builtin with a single string literal argument.
19
+ */
20
+ function getErc7201BuiltinNamespaceId(node) {
21
+ // Check that this is a function call to an identifier named `erc7201`. Return undefined for
22
+ // anything else so the caller can fall through to other base-slot forms.
23
+ if (node.nodeType !== 'FunctionCall' || node.kind !== 'functionCall') {
24
+ return undefined;
25
+ }
26
+ const callee = node.expression;
27
+ if (callee.nodeType !== 'Identifier' || callee.name !== 'erc7201') {
28
+ return undefined;
29
+ }
30
+ // Beyond this point, the call is to `erc7201(...)`. Check its expected shape — one string-literal
31
+ // argument with no user-defined declaration shadowing the builtin — and throw if anything is off.
32
+ // Valid Solidity 0.8.35+ cannot produce these mismatches in a call to the builtin:
33
+ // - User-defined `erc7201` (`referencedDeclaration >= 0`): solc resolves the call to the builtin
34
+ // when both are in scope, so this shape doesn't reach a successful compile.
35
+ // - Wrong number of arguments: enforced by the builtin's signature.
36
+ // - Non-`Literal` argument or non-string literal `kind`: the builtin's signature requires a
37
+ // comptime-constant string literal. `hex"..."` is type `bytes` and wouldn't typecheck.
38
+ // We throw instead of returning undefined so a future solc emitting one of these surfaces loudly.
39
+ if (typeof callee.referencedDeclaration === 'number' && callee.referencedDeclaration >= 0) {
40
+ throw unexpectedErc7201BuiltinAst('callee resolves to a user-defined declaration');
41
+ }
42
+ if (node.arguments.length !== 1) {
43
+ throw unexpectedErc7201BuiltinAst(`expected 1 argument, got ${node.arguments.length}`);
44
+ }
45
+ const arg = node.arguments[0];
46
+ if (arg.nodeType !== 'Literal') {
47
+ throw unexpectedErc7201BuiltinAst(`argument is ${arg.nodeType}, expected Literal`);
48
+ }
49
+ if (arg.kind !== 'string' && arg.kind !== 'unicodeString') {
50
+ throw unexpectedErc7201BuiltinAst(`argument literal kind is ${arg.kind}, expected string or unicodeString`);
51
+ }
52
+ return getStringLiteralValue(arg);
53
+ }
54
+ function unexpectedErc7201BuiltinAst(detail) {
55
+ return new error_1.UpgradesError(`Unexpected AST for \`erc7201(...)\` builtin call: ${detail}`, () => 'Please report this at https://zpl.in/upgrades/report and include the `erc7201(...)` expression from your contract.');
56
+ }
57
+ /**
58
+ * Resolves an expression to its base slot as a normalized uint256 hex string, for either a numeric
59
+ * literal or an `erc7201(...)` builtin call.
60
+ *
61
+ * @param node The expression to resolve.
62
+ * @returns The normalized base slot hex string, or undefined if the expression is neither a numeric
63
+ * literal nor a resolvable `erc7201(...)` builtin call.
64
+ */
65
+ function resolveBaseSlot(node) {
66
+ if (node.nodeType === 'Literal') {
67
+ return (0, integer_literals_1.normalizeUint256Literal)(node.value);
68
+ }
69
+ const id = getErc7201BuiltinNamespaceId(node);
70
+ if (id !== undefined) {
71
+ return (0, erc7201_1.calculateERC7201StorageLocation)(id);
72
+ }
73
+ return undefined;
74
+ }
75
+ function getStringLiteralValue(literal) {
76
+ // solc populates `value` for `kind: 'string'`/`'unicodeString'` literals; throw defensively if
77
+ // a future solc ever produces a null/missing `value` for such a literal.
78
+ if (literal.value === undefined || literal.value === null) {
79
+ throw unexpectedErc7201BuiltinAst('string literal `value` is null or missing');
80
+ }
81
+ return literal.value;
82
+ }
83
+ //# sourceMappingURL=erc7201-builtin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"erc7201-builtin.js","sourceRoot":"","sources":["../../src/utils/erc7201-builtin.ts"],"names":[],"mappings":";;AAiBA,oEAmCC;AAkBD,0CAWC;AAhFD,uCAA4D;AAC5D,yDAA6D;AAC7D,oCAAyC;AAEzC;;;;;;;;;;;GAWG;AACH,SAAgB,4BAA4B,CAAC,IAAgB;IAC3D,4FAA4F;IAC5F,yEAAyE;IACzE,IAAI,IAAI,CAAC,QAAQ,KAAK,cAAc,IAAI,IAAI,CAAC,IAAI,KAAK,cAAc,EAAE,CAAC;QACrE,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC;IAC/B,IAAI,MAAM,CAAC,QAAQ,KAAK,YAAY,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAClE,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,kGAAkG;IAClG,kGAAkG;IAClG,mFAAmF;IACnF,mGAAmG;IACnG,gFAAgF;IAChF,sEAAsE;IACtE,8FAA8F;IAC9F,2FAA2F;IAC3F,kGAAkG;IAClG,IAAI,OAAO,MAAM,CAAC,qBAAqB,KAAK,QAAQ,IAAI,MAAM,CAAC,qBAAqB,IAAI,CAAC,EAAE,CAAC;QAC1F,MAAM,2BAA2B,CAAC,+CAA+C,CAAC,CAAC;IACrF,CAAC;IACD,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChC,MAAM,2BAA2B,CAAC,4BAA4B,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;IACzF,CAAC;IACD,MAAM,GAAG,GAAG,IAAI,C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ts","sourceRoot":"","sources":["../../src/utils/erc7201.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,sBAAsB,aAAa,CAAC;AAEjD;;;;;;GAMG;AACH,wBAAgB,+BAA+B,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAalE"}
1
+ {"version":3,"file":"erc7201.d.ts","sourceRoot":"","sources":["../../src/utils/erc7201.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,sBAAsB,aAAa,CAAC;AAEjD;;;;;;GAMG;AACH,wBAAgB,+BAA+B,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAalE"}
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ERC7201_FORMULA_PREFIX = void 0;
4
4
  exports.calculateERC7201StorageLocation = calculateERC7201StorageLocation;
5
5
  const ethereumjs_util_1 = require("ethereumjs-util");
6
+ const integer_literals_1 = require("./integer-literals");
6
7
  exports.ERC7201_FORMULA_PREFIX = 'erc7201:';
7
8
  /**
8
9
  * Returns the ERC-7201 storage location hash for a given namespace id using formula:
@@ -14,11 +15,12 @@ exports.ERC7201_FORMULA_PREFIX = 'erc7201:';
14
15
  function calculateERC7201StorageLocation(id) {
15
16
  const firstHash = (0, ethereumjs_util_1.keccak256)(Buffer.from(id));
16
17
  const minusOne = BigInt(`0x${firstHash.toString('hex')}`) - 1n;
17
- const minusOneBuffer = Buffer.from(minusOne.toString(16), 'hex');
18
+ // Pad to 64 hex chars so that `Buffer.from` doesn't silently truncate odd-length input;
19
+ // `abi.encode(uint256)` is always 32 bytes.
20
+ const minusOneBuffer = Buffer.from(minusOne.toString(16).padStart(64, '0'), 'hex');
18
21
  const secondHash = (0, ethereumjs_util_1.keccak256)(minusOneBuffer);
19
22
  const mask = BigInt('0xff');
20
23
  const masked = BigInt(`0x${secondHash.toString('hex')}`) & ~mask;
21
- const padded = masked.toString(16).padStart(64, '0');
22
- return `0x${padded}`;
24
+ return (0, integer_literals_1.toBytes32Hex)(masked);
23
25
  }
24
26
  //# sourceMappingURL=erc7201.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"erc7201.js","sourceRoot":"","sources":["../../src/utils/erc7201.ts"],"names":[],"mappings":";;;AAWA,0EAaC;AAxBD,qDAA4C;AAE/B,QAAA,sBAAsB,GAAG,UAAU,CAAC;AAEjD;;;;;;GAMG;AACH,SAAgB,+BAA+B,CAAC,EAAU;IACxD,MAAM,SAAS,GAAG,IAAA,2BAAS,EAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IAC7C,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC;IAC/D,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;IAEjE,MAAM,UAAU,GAAG,IAAA,2BAAS,EAAC,cAAc,CAAC,CAAC;IAE7C,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5B,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC;IAEjE,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;IAErD,OAAO,KAAK,MAAM,EAAE,CAAC;AACvB,CAAC"}
1
+ {"version":3,"file":"erc7201.js","sourceRoot":"","sources":["../../src/utils/erc7201.ts"],"names":[],"mappings":";;;AAaA,0EAaC;AA1BD,qDAA4C;AAE5C,yDAAkD;AAErC,QAAA,sBAAsB,GAAG,UAAU,CAAC;AAEjD;;;;;;GAMG;AACH,SAAgB,+BAA+B,CAAC,EAAU;IACxD,MAAM,SAAS,GAAG,IAAA,2BAAS,EAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IAC7C,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC;IAC/D,wFAAwF;IACxF,4CAA4C;IAC5C,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;IAEnF,MAAM,UAAU,GAAG,IAAA,2BAAS,EAAC,cAAc,CAAC,CAAC;IAE7C,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5B,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC;IAEjE,OAAO,IAAA,+BAAY,EAAC,MAAM,CAAC,CAAC;AAC9B,CAAC"}
@@ -8,4 +8,14 @@ const erc7201_1 = require("./erc7201");
8
8
  (0, ava_1.default)('calculateERC7201StorageLocation', t => {
9
9
  t.is((0, erc7201_1.calculateERC7201StorageLocation)('example.main'), '0x183a6125c38840424c4a85fa12bab2ab606c4b6d0e7cc73c0c06ba5300eab500');
10
10
  });
11
+ // `keccak256("ns2") - 1` is 63 hex chars (odd-length), which must be zero-padded to 32 bytes
12
+ // before hashing. Regression test for truncation of the intermediate buffer.
13
+ (0, ava_1.default)('calculateERC7201StorageLocation - odd-length intermediate hash', t => {
14
+ t.is((0, erc7201_1.calculateERC7201StorageLocation)('ns2'), '0xa61069020885c09e922542fb3fa98c8d50e6481fc1251ff86c3319a70f0f7d00');
15
+ });
16
+ // `keccak256("ns297") - 1` is 62 hex chars (i.e., its top byte is `0x00`). Without zero-padding,
17
+ // `Buffer.from('hex')` would interpret it as a 31-byte buffer rather than 32, producing the wrong hash.
18
+ (0, ava_1.default)('calculateERC7201StorageLocation - leading-zero-byte intermediate hash', t => {
19
+ t.is((0, erc7201_1.calculateERC7201StorageLocation)('ns297'), '0xe06f9faa11c8032ea604e1764972c1a5594987f1678d8fabf921c28d1a7a4c00');
20
+ });
11
21
  //# sourceMappingURL=erc7201.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"erc7201.test.js","sourceRoot":"","sources":["../../src/utils/erc7201.test.ts"],"names":[],"mappings":";;;;;AAAA,8CAAuB;AAEvB,uCAA4D;AAE5D,IAAA,aAAI,EAAC,iCAAiC,EAAE,CAAC,CAAC,EAAE;IAC1C,CAAC,CAAC,EAAE,CACF,IAAA,yCAA+B,EAAC,cAAc,CAAC,EAC/C,oEAAoE,CACrE,CAAC;AACJ,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"erc7201.test.js","sourceRoot":"","sources":["../../src/utils/erc7201.test.ts"],"names":[],"mappings":";;;;;AAAA,8CAAuB;AAEvB,uCAA4D;AAE5D,IAAA,aAAI,EAAC,iCAAiC,EAAE,CAAC,CAAC,EAAE;IAC1C,CAAC,CAAC,EAAE,CACF,IAAA,yCAA+B,EAAC,cAAc,CAAC,EAC/C,oEAAoE,CACrE,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,6FAA6F;AAC7F,6EAA6E;AAC7E,IAAA,aAAI,EAAC,gEAAgE,EAAE,CAAC,CAAC,EAAE;IACzE,CAAC,CAAC,EAAE,CAAC,IAAA,yCAA+B,EAAC,KAAK,CAAC,EAAE,oEAAoE,CAAC,CAAC;AACrH,CAAC,CAAC,CAAC;AAEH,iGAAiG;AACjG,wGAAwG;AACxG,IAAA,aAAI,EAAC,uEAAuE,EAAE,CAAC,CAAC,EAAE;IAChF,CAAC,CAAC,EAAE,CAAC,IAAA,yCAA+B,EAAC,OAAO,CAAC,EAAE,oEAAoE,CAAC,CAAC;AACvH,CAAC,CAAC,CAAC"}
@@ -1,15 +1,28 @@
1
1
  /**
2
- * Converts a Solidity unsigned integer literal according to https://docs.soliditylang.org/en/latest/types.html#rational-literals
3
- * to a 64-byte padded hex string.
2
+ * Encodes a bigint as a 0x-prefixed, 64-char lowercase hex string — the canonical text encoding of
3
+ * a `bytes32` value, used throughout this package for storage slots and similar 256-bit identifiers.
4
+ * Throws if the value is outside the 0..2^256-1 range, since that almost certainly indicates a bug
5
+ * upstream (overflow, wrong hash, etc.) and would silently produce a string longer than 64 chars.
4
6
  *
5
- * Accepts decimal, hexadecimal, and scientific notation formats.
7
+ * @param value bigint value to encode
8
+ * @returns 0x-prefixed, 64-char lowercase hex string
9
+ */
10
+ export declare function toBytes32Hex(value: bigint): string;
11
+ /**
12
+ * Parses a Solidity unsigned integer literal source string (per
13
+ * https://docs.soliditylang.org/en/latest/types.html#rational-literals) and returns it in the
14
+ * canonical hex form produced by {@link toBytes32Hex}.
15
+ *
16
+ * Parsing is delegated to {@link BigNumber}, which accepts decimal (`1000`), hex (`0x1f`), and
17
+ * scientific notation (`1e18`). Underscore separators and uppercase digits, which BigNumber rejects
18
+ * but Solidity allows, are stripped/lowercased first. Non-integer results (e.g. `1.5e3`) are rejected.
6
19
  *
7
- * If the input is null or undefined, returns '0x0000000000000000000000000000000000000000000000000000000000000000'.
20
+ * If the input is null or undefined, returns the canonical hex form of zero.
8
21
  *
9
22
  * Assumes the input is a valid uint256-compatible literal for Solidity, and only performs minimal validation.
10
23
  *
11
- * @param literal Integer literal to convert
12
- * @returns Hex string with 0x prefix, padded to 64 bytes with leading zeroes
24
+ * @param literal Integer literal source string to parse
25
+ * @returns 0x-prefixed, 64-char lowercase hex string
13
26
  */
14
27
  export declare function normalizeUint256Literal(literal: string | null | undefined): string;
15
28
  //# sourceMappingURL=integer-literals.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"integer-literals.d.ts","sourceRoot":"","sources":["../../src/utils/integer-literals.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAalF"}
1
+ {"version":3,"file":"integer-literals.d.ts","sourceRoot":"","sources":["../../src/utils/integer-literals.ts"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKlD;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAWlF"}
@@ -3,32 +3,50 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.toBytes32Hex = toBytes32Hex;
6
7
  exports.normalizeUint256Literal = normalizeUint256Literal;
7
8
  const bignumber_js_1 = __importDefault(require("bignumber.js"));
9
+ const MAX_UINT256 = (1n << 256n) - 1n;
8
10
  /**
9
- * Converts a Solidity unsigned integer literal according to https://docs.soliditylang.org/en/latest/types.html#rational-literals
10
- * to a 64-byte padded hex string.
11
+ * Encodes a bigint as a 0x-prefixed, 64-char lowercase hex string — the canonical text encoding of
12
+ * a `bytes32` value, used throughout this package for storage slots and similar 256-bit identifiers.
13
+ * Throws if the value is outside the 0..2^256-1 range, since that almost certainly indicates a bug
14
+ * upstream (overflow, wrong hash, etc.) and would silently produce a string longer than 64 chars.
11
15
  *
12
- * Accepts decimal, hexadecimal, and scientific notation formats.
16
+ * @param value bigint value to encode
17
+ * @returns 0x-prefixed, 64-char lowercase hex string
18
+ */
19
+ function toBytes32Hex(value) {
20
+ if (value < 0n || value > MAX_UINT256) {
21
+ throw new Error(`Value out of uint256 range: ${value}`);
22
+ }
23
+ return `0x${value.toString(16).padStart(64, '0')}`;
24
+ }
25
+ /**
26
+ * Parses a Solidity unsigned integer literal source string (per
27
+ * https://docs.soliditylang.org/en/latest/types.html#rational-literals) and returns it in the
28
+ * canonical hex form produced by {@link toBytes32Hex}.
29
+ *
30
+ * Parsing is delegated to {@link BigNumber}, which accepts decimal (`1000`), hex (`0x1f`), and
31
+ * scientific notation (`1e18`). Underscore separators and uppercase digits, which BigNumber rejects
32
+ * but Solidity allows, are stripped/lowercased first. Non-integer results (e.g. `1.5e3`) are rejected.
13
33
  *
14
- * If the input is null or undefined, returns '0x0000000000000000000000000000000000000000000000000000000000000000'.
34
+ * If the input is null or undefined, returns the canonical hex form of zero.
15
35
  *
16
36
  * Assumes the input is a valid uint256-compatible literal for Solidity, and only performs minimal validation.
17
37
  *
18
- * @param literal Integer literal to convert
19
- * @returns Hex string with 0x prefix, padded to 64 bytes with leading zeroes
38
+ * @param literal Integer literal source string to parse
39
+ * @returns 0x-prefixed, 64-char lowercase hex string
20
40
  */
21
41
  function normalizeUint256Literal(literal) {
22
42
  if (!literal) {
23
- return '0x0000000000000000000000000000000000000000000000000000000000000000';
43
+ return toBytes32Hex(0n);
24
44
  }
25
45
  const lowercaseNoUnderscores = literal.replace(/_/g, '').toLowerCase();
26
46
  const parsed = new bignumber_js_1.default(lowercaseNoUnderscores);
27
47
  if (!parsed.isInteger()) {
28
48
  throw new Error(`Invalid integer literal: ${literal}`);
29
49
  }
30
- const calculatedValueAsHex = parsed.toString(16);
31
- const padded = calculatedValueAsHex.padStart(64, '0');
32
- return `0x${padded}`;
50
+ return toBytes32Hex(BigInt(parsed.toFixed()));
33
51
  }
34
52
  //# sourceMappingURL=integer-literals.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"integer-literals.js","sourceRoot":"","sources":["../../src/utils/integer-literals.ts"],"names":[],"mappings":";;;;;AAeA,0DAaC;AA5BD,gEAAqC;AAErC;;;;;;;;;;;;GAYG;AACH,SAAgB,uBAAuB,CAAC,OAAkC;IACxE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,oEAAoE,CAAC;IAC9E,CAAC;IACD,MAAM,sBAAsB,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IAE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