Skip to content

Commit

Permalink
Add playground permissions management
Browse files Browse the repository at this point in the history
  • Loading branch information
lykhonis committed Nov 12, 2023
1 parent 0080510 commit 673224a
Showing 1 changed file with 39 additions and 10 deletions.
49 changes: 39 additions & 10 deletions scripts/Playground.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,45 @@ import {
_PERMISSION_SUPER_SETDATA,
_PERMISSION_DELEGATECALL,
_PERMISSION_SUPER_DELEGATECALL,
ALL_REGULAR_PERMISSIONS
ALL_REGULAR_PERMISSIONS,
_LSP6KEY_ADDRESSPERMISSIONS_ARRAY
} from "@lukso/lsp-smart-contracts/contracts/LSP6KeyManager/LSP6Constants.sol";
import {OwnableUnset} from "@erc725/smart-contracts/contracts/custom/OwnableUnset.sol";

contract Playground is Script {
function run() external {
// address owner = vm.envAddress("OWNER_ADDRESS");
// address profileAddress = vm.envOr("PROFILE_ADDRESS", address(0));
address controller = vm.envAddress("PROFILE_CONTROLLER_ADDRESS");
UniversalProfile profile = UniversalProfile(payable(vm.envAddress("PROFILE_ADDRESS")));

// vm.startBroadcast(owner);
vm.startBroadcast(controller);

// (bytes32[] memory keys, bytes[] memory values) = LSP6Utils.generateNewPermissionsKeys(
// profile, 0x3f329Ebe23A6443BEBaf05C092C152a7754f5D32, ALL_REGULAR_PERMISSIONS
// );

// {
// address newController = ...;
// bytes32 permissions = ALL_REGULAR_PERMISSIONS;

// bytes32[] memory keys = new bytes32[](3);
// bytes[] memory values = new bytes[](3);

// uint128 arrayLength = uint128(bytes16(profile.getData(_LSP6KEY_ADDRESSPERMISSIONS_ARRAY)));
// uint128 newArrayLength = arrayLength + 1;

// keys[0] = _LSP6KEY_ADDRESSPERMISSIONS_ARRAY;
// values[0] = abi.encodePacked(newArrayLength);

// keys[1] = LSP2Utils.generateArrayElementKeyAtIndex(_LSP6KEY_ADDRESSPERMISSIONS_ARRAY, arrayLength);
// values[1] = abi.encodePacked(newController);

// keys[2] = LSP2Utils.generateMappingWithGroupingKey(
// _LSP6KEY_ADDRESSPERMISSIONS_PERMISSIONS_PREFIX, bytes20(newController)
// );
// values[2] = abi.encodePacked(permissions);

// profile.setDataBatch(keys, values);
// }

// if (profileAddress == address(0)) {
// (UniversalProfile profile, LSP6KeyManager keyManager) = deployProfile(owner);
Expand All @@ -53,14 +82,14 @@ contract Playground is Script {
// vm.broadcast(controller);
// LSP6Utils.setDataViaKeyManager(address(keyManager), keys, values);

uint256 ownerKey = 0xc0a4cb4f7926b36535ffa6aedc89414216ba5fb84f6c652ad9b6dc6c201924be;
address owner = vm.addr(ownerKey);
console.log("Owner: %s", Strings.toHexString(uint160(owner), 20));
// uint256 ownerKey = 0xc0a4cb4f7926b36535ffa6aedc89414216ba5fb84f6c652ad9b6dc6c201924be;
// address owner = vm.addr(ownerKey);
// console.log("Owner: %s", Strings.toHexString(uint160(owner), 20));

vm.startBroadcast(ownerKey);
// vm.startBroadcast(ownerKey);

(UniversalProfile profile,) = deployProfile(owner);
console.log("Profile deployed at: %s", Strings.toHexString(uint160(address(profile)), 20));
// (UniversalProfile profile,) = deployProfile(owner);
// console.log("Profile deployed at: %s", Strings.toHexString(uint160(address(profile)), 20));
// UniversalProfile profile = UniversalProfile(payable(0x30B3f161Ee7A6b5E449cB5Ad4eeABEFcd8288362));

// {
Expand Down

0 comments on commit 673224a

Please sign in to comment.