Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: PaulRBerg/prb-proxy
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: c2fe949631c86576f4fd9f1d0ddc24f83791289c
Choose a base ref
..
head repository: PaulRBerg/prb-proxy
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: fff7a2c78cc635de93a5b943ce4e391010d44ddd
Choose a head ref
4 changes: 2 additions & 2 deletions src/PRBProxyRegistry.sol
Original file line number Diff line number Diff line change
@@ -50,8 +50,8 @@ contract PRBProxyRegistry is IPRBProxyRegistry {
//////////////////////////////////////////////////////////////////////////*/

/// @inheritdoc IPRBProxyRegistry
function getNextSeed(address eoa) external view override returns (bytes32 nextSeed) {
nextSeed = nextSeeds[eoa];
function getNextSeed(address origin) external view override returns (bytes32 nextSeed) {
nextSeed = nextSeeds[origin];
}

/// @inheritdoc IPRBProxyRegistry
6 changes: 3 additions & 3 deletions src/interfaces/IPRBProxyRegistry.sol
Original file line number Diff line number Diff line change
@@ -42,9 +42,9 @@ interface IPRBProxyRegistry {
/// @dev This is stored in the registry rather than the proxy to save gas for end users.
function VERSION() external view returns (string memory);

/// @notice Gets the next seed that will be used to deploy the proxy.
/// @param eoa The externally owned account (EOA) which will own the proxy.
function getNextSeed(address eoa) external view returns (bytes32 result);
/// @notice Returns the next seed that will be used to deploy the proxy.
/// @param origin The externally owned account (EOA) that is part of the CREATE2 salt.
function getNextSeed(address origin) external view returns (bytes32 result);

/// @notice Gets the current proxy of the provided owner.
/// @param proxy The address of the current proxy.
22 changes: 22 additions & 0 deletions test/registry/deploy-and-execute-for/deployAndExecuteFor.t.sol
Original file line number Diff line number Diff line change
@@ -41,11 +41,29 @@ contract DeployAndExecuteFor_Test is Registry_Test {
ownerDoesNotHaveProxy
{
changePrank({ txOrigin: origin, msgSender: operator });

(IPRBProxy actualProxy,) = registry.deployAndExecuteFor(owner, target, data);
address expectedProxy = computeProxyAddress(origin, SEED_ZERO);
assertEq(address(actualProxy), expectedProxy, "deployed proxy address");
}

/// @dev it should update the next seeds mapping.
function testFuzz_DeployAndExecuteFor_UpdateNextSeeds(
address origin,
address operator,
address owner
)
external
ownerDoesNotHaveProxy
{
changePrank({ txOrigin: origin, msgSender: operator });
registry.deployAndExecuteFor(owner, target, data);

bytes32 actualNextSeed = registry.getNextSeed(origin);
bytes32 expectedNextSeed = SEED_ONE;
assertEq(actualNextSeed, expectedNextSeed, "next seed");
}

/// @dev it should update the current proxies mapping.
function testFuzz_DeployAndExecuteFor_UpdateCurrentProxies(
address origin,
@@ -57,6 +75,7 @@ contract DeployAndExecuteFor_Test is Registry_Test {
{
changePrank({ txOrigin: origin, msgSender: operator });
registry.deployAndExecuteFor(owner, target, data);

address actualProxyAddress = address(registry.getProxy(owner));
address expectedProxyAddress = computeProxyAddress(origin, SEED_ZERO);
assertEq(actualProxyAddress, expectedProxyAddress, "proxy address");
@@ -72,6 +91,7 @@ contract DeployAndExecuteFor_Test is Registry_Test {
ownerDoesNotHaveProxy
{
changePrank({ txOrigin: origin, msgSender: operator });

(, bytes memory actualResponse) = registry.deployAndExecuteFor(owner, target, data);
bytes memory expectedResponse = abi.encode(input);
assertEq(actualResponse, expectedResponse, "echo.echoUint256 response");
@@ -87,6 +107,7 @@ contract DeployAndExecuteFor_Test is Registry_Test {
ownerDoesNotHaveProxy
{
changePrank({ txOrigin: origin, msgSender: operator });

expectEmit();
emit DeployProxy({
origin: origin,
@@ -109,6 +130,7 @@ contract DeployAndExecuteFor_Test is Registry_Test {
ownerDoesNotHaveProxy
{
changePrank({ txOrigin: origin, msgSender: operator });

expectEmit();
emit Execute({ target: address(targets.echo), data: data, response: abi.encode(input) });
registry.deployAndExecuteFor(owner, target, data);
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ deployAndExecuteFor.t.sol
│ └── it should revert
└── when the owner does not have a proxy
├── it should deploy the proxy
├── it should update the next seeds mapping
├── it should update the proxies mapping
├── it should delegate call to the target contract
├── it should emit a {DeployProxy} event
14 changes: 14 additions & 0 deletions test/registry/deploy-and-execute/deployAndExecute.t.sol
Original file line number Diff line number Diff line change
@@ -36,15 +36,27 @@ contract DeployAndExecute_Test is Registry_Test {
/// @dev it should deploy the proxy.
function testFuzz_DeployAndExecute_Deploy(address origin, address owner) external ownerDoesNotHaveProxy {
changePrank({ txOrigin: origin, msgSender: owner });

(IPRBProxy actualProxy,) = registry.deployAndExecute(target, data);
address expectedProxy = computeProxyAddress(origin, SEED_ZERO);
assertEq(address(actualProxy), expectedProxy, "deployed proxy address");
}

/// @dev it should update the next seeds mapping.
function testFuzz_DeployAndExecute_UpdateNextSeeds(address origin, address owner) external ownerDoesNotHaveProxy {
changePrank({ txOrigin: origin, msgSender: owner });
registry.deployAndExecute(target, data);

bytes32 actualNextSeed = registry.getNextSeed(origin);
bytes32 expectedNextSeed = SEED_ONE;
assertEq(actualNextSeed, expectedNextSeed, "next seed");
}

/// @dev it should update the proxies mapping.
function testFuzz_DeployAndExecute_UpdateProxies(address origin, address owner) external ownerDoesNotHaveProxy {
changePrank({ txOrigin: origin, msgSender: owner });
registry.deployAndExecute(target, data);

address actualProxyAddress = address(registry.getProxy(owner));
address expectedProxyAddress = computeProxyAddress(origin, SEED_ZERO);
assertEq(actualProxyAddress, expectedProxyAddress, "proxy address");
@@ -61,6 +73,7 @@ contract DeployAndExecute_Test is Registry_Test {
/// @dev it should emit a {DeployProxy} event.
function testFuzz_DeployAndExecute_Event_Deploy(address origin, address owner) external ownerDoesNotHaveProxy {
changePrank({ txOrigin: origin, msgSender: owner });

expectEmit();
emit DeployProxy({
origin: origin,
@@ -76,6 +89,7 @@ contract DeployAndExecute_Test is Registry_Test {
/// @dev it should emit an {Execute} event.
function testFuzz_DeployAndExecute_Event_Execute(address origin, address owner) external ownerDoesNotHaveProxy {
changePrank({ txOrigin: origin, msgSender: owner });

expectEmit();
emit Execute({ target: address(targets.echo), data: data, response: abi.encode(input) });
registry.deployAndExecute(target, data);
1 change: 1 addition & 0 deletions test/registry/deploy-and-execute/deployAndExecute.tree
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ deployAndExecute.t.sol
│ └── it should revert
└── when the owner does not have a proxy
├── it should deploy the proxy
├── it should update the next seeds mapping
├── it should update the proxies mapping
├── it should delegate call to the target contract
├── it should emit a {DeployProxy} event
19 changes: 19 additions & 0 deletions test/registry/deploy-for/deployFor.t.sol
Original file line number Diff line number Diff line change
@@ -32,6 +32,23 @@ contract DeployFor_Test is Registry_Test {
assertEq(actualProxy, expectedProxy, "deployed proxy address");
}

/// @dev it should update the next seeds mapping.
function testFuzz_DeployFor_UpdateNextSeeds(
address origin,
address operator,
address owner
)
external
ownerDoesNotHaveProxy
{
changePrank({ txOrigin: origin, msgSender: operator });
registry.deployFor(owner);

bytes32 actualNextSeed = registry.getNextSeed(origin);
bytes32 expectedNextSeed = SEED_ONE;
assertEq(actualNextSeed, expectedNextSeed, "next seed");
}

/// @dev it should update the proxies mapping.
function testFuzz_DeployFor_UpdateProxies(
address origin,
@@ -43,6 +60,7 @@ contract DeployFor_Test is Registry_Test {
{
changePrank({ txOrigin: origin, msgSender: operator });
registry.deployFor(owner);

address actualProxyAddress = address(registry.getProxy(owner));
address expectedProxyAddress = computeProxyAddress(origin, SEED_ZERO);
assertEq(actualProxyAddress, expectedProxyAddress, "proxy address");
@@ -51,6 +69,7 @@ contract DeployFor_Test is Registry_Test {
/// @dev it should emit a {DeployProxy} event.
function testFuzz_DeployFor_Event(address origin, address operator, address owner) external ownerDoesNotHaveProxy {
changePrank({ txOrigin: origin, msgSender: operator });

expectEmit();
emit DeployProxy({
origin: origin,
1 change: 1 addition & 0 deletions test/registry/deploy-for/deployFor.tree
Original file line number Diff line number Diff line change
@@ -3,5 +3,6 @@ deployFor.t.sol
│ └── it should revert
└── when the owner does not have a proxy
├── it should deploy the proxy
├── it should update the next seeds mapping
├── it should update the proxies mapping
└── it should emit a {DeployProxy} event
10 changes: 10 additions & 0 deletions test/registry/deploy/deploy.t.sol
Original file line number Diff line number Diff line change
@@ -32,6 +32,16 @@ contract Deploy_Test is Registry_Test {
assertEq(actualProxy, expectedProxy, "deployed proxy address");
}

/// @dev it should update the next seeds mapping.
function testFuzz_Deploy_UpdateNextSeeds(address origin, address owner) external ownerDoesNotHaveProxy {
changePrank({ txOrigin: origin, msgSender: owner });
registry.deploy();

bytes32 actualNextSeed = registry.getNextSeed(origin);
bytes32 expectedNextSeed = SEED_ONE;
assertEq(actualNextSeed, expectedNextSeed, "next seed");
}

/// @dev it should update the proxies mapping.
function testFuzz_Deploy_UpdateProxies(address origin, address owner) external ownerDoesNotHaveProxy {
changePrank({ txOrigin: origin, msgSender: owner });
1 change: 1 addition & 0 deletions test/registry/deploy/deploy.tree
Original file line number Diff line number Diff line change
@@ -3,5 +3,6 @@ deploy.t.sol
│ └── it should revert
└── when the owner does not have a proxy
├── it should deploy the proxy
├── it should update the next seeds mapping
├── it should update the proxies mapping
└── it should emit a {DeployProxy} event