@bananapus/address-registry-v6 0.0.1
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/LICENSE +21 -0
- package/README.md +44 -0
- package/SKILLS.md +51 -0
- package/deployments/nana-address-registry/arbitrum/JBAddressRegistry.json +177 -0
- package/deployments/nana-address-registry/arbitrum_sepolia/JBAddressRegistry.json +177 -0
- package/deployments/nana-address-registry/base/JBAddressRegistry.json +181 -0
- package/deployments/nana-address-registry/base_sepolia/JBAddressRegistry.json +181 -0
- package/deployments/nana-address-registry/ethereum/JBAddressRegistry.json +181 -0
- package/deployments/nana-address-registry/optimism/JBAddressRegistry.json +177 -0
- package/deployments/nana-address-registry/optimism_sepolia/JBAddressRegistry.json +181 -0
- package/deployments/nana-address-registry/sepolia/JBAddressRegistry.json +181 -0
- package/docs/book.css +13 -0
- package/docs/book.toml +12 -0
- package/docs/solidity.min.js +74 -0
- package/docs/src/README.md +164 -0
- package/docs/src/SUMMARY.md +6 -0
- package/docs/src/src/JBAddressRegistry.sol/contract.JBAddressRegistry.md +106 -0
- package/docs/src/src/README.md +5 -0
- package/docs/src/src/interfaces/IJBAddressRegistry.sol/interface.IJBAddressRegistry.md +33 -0
- package/docs/src/src/interfaces/README.md +4 -0
- package/foundry.toml +29 -0
- package/package.json +20 -0
- package/remappings.txt +1 -0
- package/script/Deploy.s.sol +37 -0
- package/script/helpers/AddressRegistryDeploymentLib.sol +68 -0
- package/slither-ci.config.json +10 -0
- package/sphinx.lock +476 -0
- package/src/JBAddressRegistry.sol +96 -0
- package/src/interfaces/IJBAddressRegistry.sol +22 -0
- package/test/JBAddressRegistry.t.sol +104 -0
- package/test/JBAddressRegistry_Fork.t.sol +78 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.23;
|
|
3
|
+
|
|
4
|
+
import "forge-std/Test.sol";
|
|
5
|
+
import "../src/JBAddressRegistry.sol";
|
|
6
|
+
|
|
7
|
+
contract JBAddressRegistryTest is Test {
|
|
8
|
+
event AddressRegistered(address indexed addr, address indexed deployer, address caller);
|
|
9
|
+
|
|
10
|
+
address owner = makeAddr("_owner");
|
|
11
|
+
address deployer = makeAddr("_deployer");
|
|
12
|
+
JBAddressRegistry registry;
|
|
13
|
+
|
|
14
|
+
function setUp() public {
|
|
15
|
+
registry = new JBAddressRegistry();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/// @custom:test When registering a pay hook deployed by an EOA, ensure that the transaction is successful, that the
|
|
19
|
+
/// correct event is emitted, and that the hook is added to the mapping.
|
|
20
|
+
function test_addHook_addAddressFromEOA(uint16 nonce) public {
|
|
21
|
+
// Set the nonce of the deployer EOA (if we need to increase it)
|
|
22
|
+
vm.assume(nonce >= vm.getNonce(address(deployer)));
|
|
23
|
+
if (vm.getNonce(address(deployer)) != nonce) {
|
|
24
|
+
vm.setNonce(address(deployer), nonce);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
vm.prank(deployer);
|
|
28
|
+
address mockValidAddress = address(new MockDeployment());
|
|
29
|
+
|
|
30
|
+
// Check: is the correct event emitted?
|
|
31
|
+
vm.expectEmit(true, true, true, true);
|
|
32
|
+
emit AddressRegistered(mockValidAddress, deployer, address(this));
|
|
33
|
+
|
|
34
|
+
// Test: register the address.
|
|
35
|
+
registry.registerAddress(deployer, nonce);
|
|
36
|
+
|
|
37
|
+
// Check: does the address correspond to the correct deployer in the mapping?
|
|
38
|
+
assertTrue(registry.deployerOf(mockValidAddress) == deployer);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/// @custom:test When registering a pay hook deployed by a contract using `create1`, ensure that the transaction is
|
|
42
|
+
/// successful, that the correct event is emitted, and that the hook is added to the mapping.
|
|
43
|
+
function test_addAddress_addAddressFromContract(uint16 nonce) public {
|
|
44
|
+
Factory factory = new Factory();
|
|
45
|
+
|
|
46
|
+
// Set the nonce of the deployer contract (if we need to increase it).
|
|
47
|
+
vm.assume(nonce >= vm.getNonce(address(factory)));
|
|
48
|
+
if (vm.getNonce(address(factory)) != nonce) {
|
|
49
|
+
vm.setNonce(address(factory), nonce);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Deploy the new address.
|
|
53
|
+
address mockValidAddress = factory.deploy();
|
|
54
|
+
|
|
55
|
+
// Check: is the correct event emitted?
|
|
56
|
+
vm.expectEmit(true, true, true, true);
|
|
57
|
+
emit AddressRegistered(mockValidAddress, address(factory), address(this));
|
|
58
|
+
|
|
59
|
+
// Test: register the address.
|
|
60
|
+
registry.registerAddress(address(factory), nonce); // Nonce starts at 1 for contracts
|
|
61
|
+
|
|
62
|
+
// Check: does the address correspond to the correct deployer in the mapping?
|
|
63
|
+
assertTrue(registry.deployerOf(mockValidAddress) == address(factory));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/// @custom:test When registering a pay hook deployed by a contract using `create2`, ensure that the transaction is
|
|
67
|
+
/// successful, that the correct event is emitted, and that the hook is added to the mapping.
|
|
68
|
+
function test_addAddress_addAddressFromContract(bytes32 salt) public {
|
|
69
|
+
vm.assume(salt != bytes32(0));
|
|
70
|
+
Factory factory = new Factory();
|
|
71
|
+
address mockValidAddress = factory.deploy(salt);
|
|
72
|
+
|
|
73
|
+
// Check: Is the correct event emitted?
|
|
74
|
+
vm.expectEmit(true, true, true, true);
|
|
75
|
+
emit AddressRegistered(mockValidAddress, address(factory), address(this));
|
|
76
|
+
|
|
77
|
+
// Test: register the address.
|
|
78
|
+
registry.registerAddress(address(factory), salt, type(MockDeployment).creationCode);
|
|
79
|
+
|
|
80
|
+
// Check: does the address correspond to the correct deployer in the mapping?
|
|
81
|
+
assertTrue(registry.deployerOf(mockValidAddress) == address(factory));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// This contract doesn't do much, but is nice.
|
|
86
|
+
contract MockDeployment {
|
|
87
|
+
string _stored = "Hello, world!";
|
|
88
|
+
|
|
89
|
+
constructor() {}
|
|
90
|
+
|
|
91
|
+
function getFancyData() external view returns (string memory) {
|
|
92
|
+
return _stored;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
contract Factory {
|
|
97
|
+
function deploy() public returns (address) {
|
|
98
|
+
return address(new MockDeployment());
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function deploy(bytes32 _salt) public returns (address) {
|
|
102
|
+
return address(new MockDeployment{salt: _salt}());
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.23;
|
|
3
|
+
|
|
4
|
+
import "forge-std/Test.sol";
|
|
5
|
+
import "../src/JBAddressRegistry.sol";
|
|
6
|
+
|
|
7
|
+
contract JBAddressRegistryTest_Fork is Test {
|
|
8
|
+
address owner = makeAddr("_owner");
|
|
9
|
+
address deployer = makeAddr("_deployer");
|
|
10
|
+
|
|
11
|
+
uint256 blockHeight = 17_580_288;
|
|
12
|
+
|
|
13
|
+
JBAddressRegistry registry;
|
|
14
|
+
|
|
15
|
+
function setUp() public {
|
|
16
|
+
// Start a mainnet fork.
|
|
17
|
+
vm.createSelectFork(
|
|
18
|
+
"https://rpc.ankr.com/eth/4bdda9badb97f42aa5cc09055318c1ae2e4d3c0a449ebdf8bf4fe6969b20772a", blockHeight
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
registry = new JBAddressRegistry();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/// @custom:test Make sure adding a new hook works for both `create1` and `create2`.
|
|
25
|
+
function test_integration_newDeployments() public {
|
|
26
|
+
// Deploy a `MockDeployment` factory.
|
|
27
|
+
Factory factory = new Factory();
|
|
28
|
+
|
|
29
|
+
// Deploy from an EOA.
|
|
30
|
+
vm.prank(deployer);
|
|
31
|
+
address mockContract = address(new MockDeployment());
|
|
32
|
+
|
|
33
|
+
// `create1` from the factory.
|
|
34
|
+
address mockDeployment1 = factory.deploy();
|
|
35
|
+
|
|
36
|
+
// `create2` from the factory.
|
|
37
|
+
address mockDeployment2 = factory.deploy(keccak256(abi.encode(696_969)));
|
|
38
|
+
|
|
39
|
+
// Register the EOA (nonce 0 from the EOA).
|
|
40
|
+
registry.registerAddress(deployer, 0);
|
|
41
|
+
|
|
42
|
+
// Register the `create1` deployment (nonce 1 from the factory).
|
|
43
|
+
registry.registerAddress(address(factory), 1);
|
|
44
|
+
|
|
45
|
+
// Register the `create2` deployment using the salt above.
|
|
46
|
+
registry.registerAddress(address(factory), keccak256(abi.encode(696_969)), type(MockDeployment).creationCode);
|
|
47
|
+
|
|
48
|
+
// Check: EOA?
|
|
49
|
+
assertEq(registry.deployerOf(mockContract), deployer);
|
|
50
|
+
|
|
51
|
+
// Check: `create1` deployment?
|
|
52
|
+
assertEq(registry.deployerOf(mockDeployment1), address(factory));
|
|
53
|
+
|
|
54
|
+
// Check: `create2` deployment?
|
|
55
|
+
assertEq(registry.deployerOf(mockDeployment2), address(factory));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// This contract doesn't do much, but is nice.
|
|
60
|
+
contract MockDeployment {
|
|
61
|
+
string _stored = "Hello, world!";
|
|
62
|
+
|
|
63
|
+
constructor() {}
|
|
64
|
+
|
|
65
|
+
function getFancyData() external view returns (string memory) {
|
|
66
|
+
return _stored;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
contract Factory {
|
|
71
|
+
function deploy() public returns (address) {
|
|
72
|
+
return address(new MockDeployment());
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function deploy(bytes32 _salt) public returns (address) {
|
|
76
|
+
return address(new MockDeployment{salt: _salt}());
|
|
77
|
+
}
|
|
78
|
+
}
|