Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
lykhonis committed Apr 10, 2024
2 parents a6bf4aa + eda85b2 commit 2feafd8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
| mainnet | Vault | 0xa5b37d755b97c272853b9726c905414706a0553a |
| mainnet | Elections | 0xd813fd267a5d3d10adbe9d22ba6dc7fda2ddf517 |
| mainnet | ProfilesOracle | 0x482a6fd801fe3290a49e465c168ad9f8772b8d7e |
| mainnet | ProfilesReverseLookup | 0xf70873b68c5c912072631d947b21cdf56fbbc2b0 |
| mainnet | ProfilesReverseLookup | 0xa0eb05c666fcf6cbeca77e14ec43cb5d5a852601 |
| testnet | PageName | 0x8b08eeb9183081de7e2d4ae49fad4afb56e31ab4 |
| testnet | GenesisDigitalAsset | 0xc06bcd7a286308861bd99da220acbc8901949fbd |
| testnet | CollectorDigitalAsset | 0x2eef6216274bf0ede21a8a55cbb5b896bb82ac8b |
Expand All @@ -38,7 +38,7 @@
| testnet | Points | 0x3582f474F6E9FB087651b135d6224500A89e6f44 |
| testnet | Royalties | 0x1c51619209EFE37C759e4a9Ca91F1e68A96E19E3 |
| testnet | Elections | 0xbe69df047c7e10766cbe5e8bd2fac3dc18a9b745 |
| testnet | ProfilesReverseLookup | 0xa28d3307f5a09ad404385460062bad5d379d1925 |
| testnet | ProfilesReverseLookup | 0x953eef8151770c4cc60ec27468acee85eb8d81f8 |

## Analyze

Expand Down
5 changes: 5 additions & 0 deletions artifacts/abi/profiles/ProfilesReverseLookup.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@
},
{
"inputs": [
{
"internalType": "address",
"name": "controller",
"type": "address"
},
{
"internalType": "address",
"name": "profile",
Expand Down
6 changes: 4 additions & 2 deletions src/profiles/ProfilesReverseLookup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ contract ProfilesReverseLookup {
return keccak256(abi.encodePacked(controller, profile));
}

function register(address profile, bytes calldata data) external {
address controller = msg.sender;
function register(address controller, address profile, bytes calldata data) external {
if (msg.sender != controller && msg.sender != profile) {
revert Unathorized();
}

bytes32 permissions = LSP6Utils.getPermissionsFor(IERC725Y(profile), controller);
bool granted = LSP6Utils.hasPermission(permissions, _PERMISSION_SIGN);
Expand Down
12 changes: 6 additions & 6 deletions test/profiles/ProfilesReverseLookup.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ contract ProfilesReverseLookupTest is Test {
vm.prank(controller);
vm.expectEmit();
emit ProfileRegistered(controller, address(alice), "0x");
lookup.register(address(alice), "0x");
lookup.register(controller, address(alice), "0x");

assertEq(lookup.profilesOf(controller).length, 1);
assertEq(lookup.profilesOf(controller)[0], address(alice));
Expand All @@ -50,7 +50,7 @@ contract ProfilesReverseLookupTest is Test {
vm.expectRevert(
abi.encodeWithSelector(ProfilesReverseLookup.UnathorizedController.selector, controller, address(alice))
);
lookup.register(address(alice), "0x");
lookup.register(controller, address(alice), "0x");
}

function test_Revert_AlreadyRegistered() public {
Expand All @@ -62,13 +62,13 @@ contract ProfilesReverseLookupTest is Test {
alice.setDataBatch(keys, values);

vm.prank(controller);
lookup.register(address(alice), "0x");
lookup.register(controller, address(alice), "0x");

vm.prank(controller);
vm.expectRevert(
abi.encodeWithSelector(ProfilesReverseLookup.AlreadyRegistered.selector, controller, address(alice))
);
lookup.register(address(alice), "0x");
lookup.register(controller, address(alice), "0x");
}

function test_UnregisterAsController() public {
Expand All @@ -82,7 +82,7 @@ contract ProfilesReverseLookupTest is Test {
vm.prank(controller);
vm.expectEmit();
emit ProfileRegistered(controller, address(alice), "0x");
lookup.register(address(alice), "0x");
lookup.register(controller, address(alice), "0x");

assertEq(lookup.profilesOf(controller).length, 1);
assertEq(lookup.profilesOf(controller)[0], address(alice));
Expand All @@ -108,7 +108,7 @@ contract ProfilesReverseLookupTest is Test {
vm.prank(controller);
vm.expectEmit();
emit ProfileRegistered(controller, address(alice), "0x");
lookup.register(address(alice), "0x");
lookup.register(controller, address(alice), "0x");

assertEq(lookup.profilesOf(controller).length, 1);
assertEq(lookup.profilesOf(controller)[0], address(alice));
Expand Down

0 comments on commit 2feafd8

Please sign in to comment.