@bananapus/address-registry-v6 0.0.24 → 0.0.25
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
|
@@ -3,14 +3,12 @@ pragma solidity 0.8.28;
|
|
|
3
3
|
|
|
4
4
|
import {IJBAddressRegistry} from "./interfaces/IJBAddressRegistry.sol";
|
|
5
5
|
|
|
6
|
-
/// @notice
|
|
7
|
-
///
|
|
8
|
-
///
|
|
9
|
-
///
|
|
10
|
-
///
|
|
11
|
-
///
|
|
12
|
-
/// @dev The addresses of the deployed contracts are computed deterministically based on the deployer's address, and a
|
|
13
|
-
/// nonce (for `create`) or `create2` salt and deployment bytecode (for `create2`).
|
|
6
|
+
/// @notice A public registry that records who deployed a given contract. Anyone can register a contract's deployer,
|
|
7
|
+
/// and anyone can look it up — enabling frontend clients and other contracts to verify that a Juicebox hook or
|
|
8
|
+
/// extension was deployed by a trusted source.
|
|
9
|
+
/// @dev Supports both `create` (deployer + nonce) and `create2` (deployer + salt + bytecode) deployments. The
|
|
10
|
+
/// registry computes the expected contract address deterministically and verifies that code exists there before
|
|
11
|
+
/// recording the deployer. Each address can only be registered once.
|
|
14
12
|
contract JBAddressRegistry is IJBAddressRegistry {
|
|
15
13
|
//*********************************************************************//
|
|
16
14
|
// --------------------------- custom errors ------------------------- //
|
|
@@ -34,19 +32,20 @@ contract JBAddressRegistry is IJBAddressRegistry {
|
|
|
34
32
|
// --------------------- public stored properties -------------------- //
|
|
35
33
|
//*********************************************************************//
|
|
36
34
|
|
|
37
|
-
/// @notice
|
|
35
|
+
/// @notice Look up who deployed a registered contract. Returns `address(0)` if the contract hasn't been
|
|
36
|
+
/// registered.
|
|
38
37
|
/// @dev Whoever deploys a contract is responsible for registering it.
|
|
39
|
-
/// @custom:param addr The address of the contract to
|
|
38
|
+
/// @custom:param addr The address of the contract to check.
|
|
40
39
|
mapping(address addr => address deployer) public override deployerOf;
|
|
41
40
|
|
|
42
41
|
//*********************************************************************//
|
|
43
42
|
// ---------------------- external transactions ---------------------- //
|
|
44
43
|
//*********************************************************************//
|
|
45
44
|
|
|
46
|
-
/// @notice Register a deployed
|
|
47
|
-
///
|
|
48
|
-
/// @param deployer The address
|
|
49
|
-
/// @param nonce The
|
|
45
|
+
/// @notice Register a contract that was deployed with `create` (standard deployment). The registry computes the
|
|
46
|
+
/// expected address from the deployer and nonce, then verifies code exists there.
|
|
47
|
+
/// @param deployer The address that deployed the contract.
|
|
48
|
+
/// @param nonce The deployer's transaction nonce at the time of deployment.
|
|
50
49
|
function registerAddress(address deployer, uint256 nonce) external override {
|
|
51
50
|
// Calculate the address of the contract, assuming it was deployed using `create` with the specified nonce.
|
|
52
51
|
address hook = _addressFrom({origin: deployer, nonce: nonce});
|
|
@@ -55,14 +54,14 @@ contract JBAddressRegistry is IJBAddressRegistry {
|
|
|
55
54
|
_registerAddress({addr: hook, deployer: deployer});
|
|
56
55
|
}
|
|
57
56
|
|
|
58
|
-
/// @notice Register a deployed
|
|
59
|
-
///
|
|
57
|
+
/// @notice Register a contract that was deployed with `create2` (deterministic deployment). The registry computes
|
|
58
|
+
/// the expected address from the deployer, salt, and bytecode, then verifies code exists there.
|
|
60
59
|
/// @dev The `create2` salt is determined by the deployer's logic. The deployment bytecode can be retrieved offchain
|
|
61
60
|
/// (from the deployment transaction) or onchain (with `abi.encodePacked(type(deployedContract).creationCode,
|
|
62
61
|
/// abi.encode(constructorArguments))`).
|
|
63
|
-
/// @param deployer The address
|
|
64
|
-
/// @param salt The `create2` salt used
|
|
65
|
-
/// @param bytecode The
|
|
62
|
+
/// @param deployer The address that deployed the contract.
|
|
63
|
+
/// @param salt The `create2` salt used during deployment.
|
|
64
|
+
/// @param bytecode The full deployment bytecode, including constructor arguments.
|
|
66
65
|
function registerAddress(address deployer, bytes32 salt, bytes calldata bytecode) external override {
|
|
67
66
|
// Calculate the address of the contract using the provided `create2` salt and deployment bytecode.
|
|
68
67
|
address hook =
|
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity ^0.8.0;
|
|
3
3
|
|
|
4
|
-
/// @notice A registry that maps deployed contract addresses to their deployers
|
|
4
|
+
/// @notice A registry that maps deployed contract addresses to their deployers, allowing anyone to verify who deployed
|
|
5
|
+
/// a given contract. Primarily used to verify the trustworthiness of Juicebox hooks and extensions.
|
|
5
6
|
interface IJBAddressRegistry {
|
|
6
|
-
/// @notice Emitted when a contract
|
|
7
|
+
/// @notice Emitted when a contract's deployer is registered.
|
|
7
8
|
/// @param addr The address of the registered contract.
|
|
8
|
-
/// @param deployer The address
|
|
9
|
+
/// @param deployer The address that deployed the contract.
|
|
9
10
|
/// @param caller The address that called the register function.
|
|
10
11
|
event AddressRegistered(address indexed addr, address indexed deployer, address caller);
|
|
11
12
|
|
|
12
|
-
/// @notice
|
|
13
|
-
/// @param addr The address of the contract to
|
|
14
|
-
/// @return deployer The
|
|
13
|
+
/// @notice Look up who deployed a registered contract.
|
|
14
|
+
/// @param addr The address of the contract to check.
|
|
15
|
+
/// @return deployer The address that deployed the contract, or `address(0)` if not registered.
|
|
15
16
|
function deployerOf(address addr) external view returns (address deployer);
|
|
16
17
|
|
|
17
|
-
/// @notice Register a contract deployed with `create
|
|
18
|
-
/// @param deployer The address
|
|
19
|
-
/// @param nonce The
|
|
18
|
+
/// @notice Register a contract that was deployed with `create` (standard deployment).
|
|
19
|
+
/// @param deployer The address that deployed the contract.
|
|
20
|
+
/// @param nonce The deployer's transaction nonce at the time of deployment.
|
|
20
21
|
function registerAddress(address deployer, uint256 nonce) external;
|
|
21
22
|
|
|
22
|
-
/// @notice Register a contract deployed with `create2
|
|
23
|
-
/// @param deployer The address
|
|
24
|
-
/// @param salt The `create2` salt used
|
|
25
|
-
/// @param bytecode The
|
|
23
|
+
/// @notice Register a contract that was deployed with `create2` (deterministic deployment).
|
|
24
|
+
/// @param deployer The address that deployed the contract.
|
|
25
|
+
/// @param salt The `create2` salt used during deployment.
|
|
26
|
+
/// @param bytecode The full deployment bytecode, including constructor arguments.
|
|
26
27
|
function registerAddress(address deployer, bytes32 salt, bytes calldata bytecode) external;
|
|
27
28
|
}
|