Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/account/AccountStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ struct SelectorData {
// The plugin that implements this execution function.
// If this is a native function, the address must remain address(0).
address plugin;
// Whether or not the function needs runtime validation, or can be called by anyone.
// Whether or not the function needs runtime validation, or can be called by anyone. The function can still be
// state changing if this flag is set to true.
// Note that even if this is set to true, user op validation will still be required, otherwise anyone could
// drain the account of native tokens by wasting gas.
bool isPublic;
Expand Down Expand Up @@ -59,8 +60,8 @@ function getAccountStorage() pure returns (AccountStorage storage _storage) {

using EnumerableSet for EnumerableSet.Bytes32Set;

function toSetValue(PluginEntity functionReference) pure returns (bytes32) {
return bytes32(PluginEntity.unwrap(functionReference));
function toSetValue(PluginEntity pluginEntity) pure returns (bytes32) {
return bytes32(PluginEntity.unwrap(pluginEntity));
}

function toPluginEntity(bytes32 setValue) pure returns (PluginEntity) {
Expand Down
40 changes: 40 additions & 0 deletions test/libraries/PluginEntityLib.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.19;

import {Test} from "forge-std/Test.sol";

import {PluginEntityLib} from "../../src/helpers/PluginEntityLib.sol";
import {PluginEntity} from "../../src/interfaces/IPluginManager.sol";

contract PluginEntityLibTest is Test {
using PluginEntityLib for PluginEntity;

function testFuzz_pluginEntity_packing(address addr, uint32 entityId) public {
// console.log("addr: ", addr);
// console.log("entityId: ", vm.toString(entityId));
PluginEntity fr = PluginEntityLib.pack(addr, entityId);
// console.log("packed: ", vm.toString(PluginEntity.unwrap(fr)));
(address addr2, uint32 entityId2) = PluginEntityLib.unpack(fr);
// console.log("addr2: ", addr2);
// console.log("entityId2: ", vm.toString(entityId2));
assertEq(addr, addr2);
assertEq(entityId, entityId2);
}

function testFuzz_pluginEntity_operators(PluginEntity a, PluginEntity b) public {
assertTrue(a.eq(a));
assertTrue(b.eq(b));

if (PluginEntity.unwrap(a) == PluginEntity.unwrap(b)) {
assertTrue(a.eq(b));
assertTrue(b.eq(a));
assertFalse(a.notEq(b));
assertFalse(b.notEq(a));
} else {
assertTrue(a.notEq(b));
assertTrue(b.notEq(a));
assertFalse(a.eq(b));
assertFalse(b.eq(a));
}
}
}