@openzeppelin/upgrades-core 1.45.0-alpha.1 → 1.46.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.
- package/artifacts/@openzeppelin/contracts-v5/proxy/ERC1967/ERC1967Proxy.sol/ERC1967Proxy.json +2 -2
- package/artifacts/@openzeppelin/contracts-v5/proxy/transparent/ProxyAdmin.sol/ProxyAdmin.json +2 -2
- package/artifacts/@openzeppelin/contracts-v5/proxy/transparent/TransparentUpgradeableProxy.sol/TransparentUpgradeableProxy.json +2 -2
- package/artifacts/build-info-v5.json +22 -22
- package/dist/cli/validate/build-info-file.js +4 -1
- package/dist/cli/validate/build-info-file.js.map +1 -1
- package/dist/cli/validate/build-info-file.test.js +115 -1
- package/dist/cli/validate/build-info-file.test.js.map +1 -1
- package/dist/provider.d.ts.map +1 -1
- package/dist/provider.js +1 -0
- package/dist/provider.js.map +1 -1
- package/dist/storage/extract.d.ts.map +1 -1
- package/dist/storage/extract.js +21 -7
- package/dist/storage/extract.js.map +1 -1
- package/dist/storage/namespace.d.ts.map +1 -1
- package/dist/storage/namespace.js +18 -11
- package/dist/storage/namespace.js.map +1 -1
- package/dist/storage-erc7201-builtin.test.d.ts +2 -0
- package/dist/storage-erc7201-builtin.test.d.ts.map +1 -0
- package/dist/storage-erc7201-builtin.test.js +105 -0
- package/dist/storage-erc7201-builtin.test.js.map +1 -0
- package/dist/utils/erc7201-builtin.d.ts +24 -0
- package/dist/utils/erc7201-builtin.d.ts.map +1 -0
- package/dist/utils/erc7201-builtin.js +83 -0
- package/dist/utils/erc7201-builtin.js.map +1 -0
- package/dist/utils/erc7201.d.ts.map +1 -1
- package/dist/utils/erc7201.js +5 -3
- package/dist/utils/erc7201.js.map +1 -1
- package/dist/utils/erc7201.test.js +10 -0
- package/dist/utils/erc7201.test.js.map +1 -1
- package/dist/utils/integer-literals.d.ts +19 -6
- package/dist/utils/integer-literals.d.ts.map +1 -1
- package/dist/utils/integer-literals.js +28 -10
- package/dist/utils/integer-literals.js.map +1 -1
- package/dist/utils/integer-literals.test.js +12 -0
- package/dist/utils/integer-literals.test.js.map +1 -1
- package/package.json +3 -3
- package/src/cli/validate/build-info-file.test.ts +156 -1
- package/src/cli/validate/build-info-file.ts +6 -1
- package/src/provider.ts +1 -0
- package/src/storage/extract.ts +28 -12
- package/src/storage/namespace.ts +21 -11
- package/src/storage-erc7201-builtin.test.ts +127 -0
- package/src/utils/erc7201-builtin.ts +91 -0
- package/src/utils/erc7201.test.ts +12 -0
- package/src/utils/erc7201.ts +6 -4
- package/src/utils/integer-literals.test.ts +15 -1
- package/src/utils/integer-literals.ts +29 -10
|
@@ -1,21 +1,42 @@
|
|
|
1
1
|
import BigNumber from 'bignumber.js';
|
|
2
2
|
|
|
3
|
+
const MAX_UINT256 = (1n << 256n) - 1n;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Encodes a bigint as a 0x-prefixed, 64-char lowercase hex string — the canonical text encoding of
|
|
7
|
+
* a `bytes32` value, used throughout this package for storage slots and similar 256-bit identifiers.
|
|
8
|
+
* Throws if the value is outside the 0..2^256-1 range, since that almost certainly indicates a bug
|
|
9
|
+
* upstream (overflow, wrong hash, etc.) and would silently produce a string longer than 64 chars.
|
|
10
|
+
*
|
|
11
|
+
* @param value bigint value to encode
|
|
12
|
+
* @returns 0x-prefixed, 64-char lowercase hex string
|
|
13
|
+
*/
|
|
14
|
+
export function toBytes32Hex(value: bigint): string {
|
|
15
|
+
if (value < 0n || value > MAX_UINT256) {
|
|
16
|
+
throw new Error(`Value out of uint256 range: ${value}`);
|
|
17
|
+
}
|
|
18
|
+
return `0x${value.toString(16).padStart(64, '0')}`;
|
|
19
|
+
}
|
|
20
|
+
|
|
3
21
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
22
|
+
* Parses a Solidity unsigned integer literal source string (per
|
|
23
|
+
* https://docs.soliditylang.org/en/latest/types.html#rational-literals) and returns it in the
|
|
24
|
+
* canonical hex form produced by {@link toBytes32Hex}.
|
|
6
25
|
*
|
|
7
|
-
*
|
|
26
|
+
* Parsing is delegated to {@link BigNumber}, which accepts decimal (`1000`), hex (`0x1f`), and
|
|
27
|
+
* scientific notation (`1e18`). Underscore separators and uppercase digits, which BigNumber rejects
|
|
28
|
+
* but Solidity allows, are stripped/lowercased first. Non-integer results (e.g. `1.5e3`) are rejected.
|
|
8
29
|
*
|
|
9
|
-
* If the input is null or undefined, returns
|
|
30
|
+
* If the input is null or undefined, returns the canonical hex form of zero.
|
|
10
31
|
*
|
|
11
32
|
* Assumes the input is a valid uint256-compatible literal for Solidity, and only performs minimal validation.
|
|
12
33
|
*
|
|
13
|
-
* @param literal Integer literal to
|
|
14
|
-
* @returns
|
|
34
|
+
* @param literal Integer literal source string to parse
|
|
35
|
+
* @returns 0x-prefixed, 64-char lowercase hex string
|
|
15
36
|
*/
|
|
16
37
|
export function normalizeUint256Literal(literal: string | null | undefined): string {
|
|
17
38
|
if (!literal) {
|
|
18
|
-
return
|
|
39
|
+
return toBytes32Hex(0n);
|
|
19
40
|
}
|
|
20
41
|
const lowercaseNoUnderscores = literal.replace(/_/g, '').toLowerCase();
|
|
21
42
|
|
|
@@ -23,7 +44,5 @@ export function normalizeUint256Literal(literal: string | null | undefined): str
|
|
|
23
44
|
if (!parsed.isInteger()) {
|
|
24
45
|
throw new Error(`Invalid integer literal: ${literal}`);
|
|
25
46
|
}
|
|
26
|
-
|
|
27
|
-
const padded = calculatedValueAsHex.padStart(64, '0');
|
|
28
|
-
return `0x${padded}`;
|
|
47
|
+
return toBytes32Hex(BigInt(parsed.toFixed()));
|
|
29
48
|
}
|