@bananapus/address-registry-v6 0.0.19 → 0.0.20

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bananapus/address-registry-v6",
3
- "version": "0.0.19",
3
+ "version": "0.0.20",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -72,6 +72,8 @@ library AddressRegistryDeploymentLib {
72
72
  string memory deploymentJson =
73
73
  // forge-lint: disable-next-line(unsafe-cheatcode)
74
74
  vm.readFile(string.concat(path, projectName, "/", networkName, "/", contractName, ".json"));
75
- return stdJson.readAddress({json: deploymentJson, key: ".address"});
75
+ address deployed = stdJson.readAddress({json: deploymentJson, key: ".address"});
76
+ require(deployed.code.length != 0, "AddressRegistryDeploymentLib: registry has no code");
77
+ return deployed;
76
78
  }
77
79
  }
@@ -0,0 +1,62 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity 0.8.28;
3
+
4
+ import {Test} from "forge-std/Test.sol";
5
+ import {stdJson} from "forge-std/Script.sol";
6
+
7
+ import {
8
+ AddressRegistryDeploymentLib,
9
+ AddressRegistryDeployment
10
+ } from "../../script/helpers/AddressRegistryDeploymentLib.sol";
11
+
12
+ /// @notice Wrapper that makes the library's internal functions callable externally so vm.expectRevert works.
13
+ contract DeploymentLibCaller {
14
+ function getDeployment(
15
+ string memory path,
16
+ string memory networkName
17
+ )
18
+ external
19
+ returns (AddressRegistryDeployment memory)
20
+ {
21
+ return AddressRegistryDeploymentLib.getDeployment({path: path, networkName: networkName});
22
+ }
23
+ }
24
+
25
+ /// @notice Tests M-40: Deployment helper rejects stale artifacts pointing to non-contract addresses.
26
+ contract DeploymentHelperValidationTest is Test {
27
+ DeploymentLibCaller internal caller;
28
+
29
+ function setUp() public {
30
+ caller = new DeploymentLibCaller();
31
+ }
32
+
33
+ /// @notice Stale deployment artifact pointing to an EOA reverts.
34
+ function test_deploymentHelper_revertsForEOARegistry() external {
35
+ address eoa = makeAddr("staleEOA");
36
+ string memory json = string.concat('{"address":"', vm.toString(eoa), '"}');
37
+
38
+ string memory dir = "test/audit/tmp-eoa/nana-address-registry-v6/testnet/";
39
+ vm.createDir(dir, true);
40
+ vm.writeFile(string.concat(dir, "JBAddressRegistry.json"), json);
41
+
42
+ vm.expectRevert("AddressRegistryDeploymentLib: registry has no code");
43
+ caller.getDeployment({path: "test/audit/tmp-eoa/", networkName: "testnet"});
44
+
45
+ vm.removeFile(string.concat(dir, "JBAddressRegistry.json"));
46
+ }
47
+
48
+ /// @notice Valid deployment artifact with a contract address is accepted.
49
+ function test_deploymentHelper_acceptsContractRegistry() external {
50
+ address registry = makeAddr("registryContract");
51
+ vm.etch(registry, hex"6080604052");
52
+ string memory json = string.concat('{"address":"', vm.toString(registry), '"}');
53
+
54
+ string memory dir = "test/audit/tmp-contract/nana-address-registry-v6/testnet/";
55
+ vm.createDir(dir, true);
56
+ vm.writeFile(string.concat(dir, "JBAddressRegistry.json"), json);
57
+
58
+ caller.getDeployment({path: "test/audit/tmp-contract/", networkName: "testnet"});
59
+
60
+ vm.removeFile(string.concat(dir, "JBAddressRegistry.json"));
61
+ }
62
+ }